use of gregtech.api.terminal.os.TerminalDialogWidget in project GregTech by GregTechCEu.
the class AppCardWidget method hookDrawInForeground.
@Override
public void hookDrawInForeground(int mouseX, int mouseY) {
// hover
int x = getPosition().x;
int y = getPosition().y;
int width = getSize().width;
int height = getSize().height;
if (isMouseOverElement(mouseX, mouseY) && store.getOs().desktop.widgets.stream().noneMatch(app -> app instanceof TerminalDialogWidget)) {
int dur = 7;
// 0-255!!!!!
int maxAlpha = 100;
float partialTicks = Minecraft.getMinecraft().getRenderPartialTicks();
if (alpha != maxAlpha && interpolator == null) {
interpolator = new Interpolator(0, maxAlpha, dur, Eases.EaseLinear, value -> alpha = value.intValue(), value -> interpolator = null);
interpolator.start();
}
// smooth
int color;
if (alpha == maxAlpha) {
color = TerminalTheme.COLOR_B_2.getColor() & 0x00ffffff | ((alpha) << 24);
} else {
color = TerminalTheme.COLOR_B_2.getColor() & 0x00ffffff | ((alpha + (int) (maxAlpha * partialTicks / dur)) << 24);
}
int finalColor = color;
RenderUtil.useScissor(store.getPosition().x, store.getPosition().y, store.getSize().width, store.getSize().height, () -> {
drawSolidRect(0, 0, gui.getScreenWidth(), y, finalColor);
drawSolidRect(0, y + height, gui.getScreenWidth(), gui.getScreenHeight(), finalColor);
drawSolidRect(0, y, x, height, finalColor);
drawSolidRect(x + width, y, gui.getScreenWidth(), height, finalColor);
drawBorder(x, y, width, height, application.getThemeColor(), -1);
});
} else {
alpha = 0;
}
super.hookDrawInForeground(mouseX, mouseY);
}
Aggregations