Search in sources :

Example 1 with TerminalDialogWidget

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);
}
Also used : IRenderContext(gregtech.api.gui.IRenderContext) TerminalOSWidget(gregtech.api.terminal.os.TerminalOSWidget) gregtech.api.gui.resources(gregtech.api.gui.resources) Eases(gregtech.api.util.interpolate.Eases) AnimaWidgetGroup(gregtech.api.terminal.gui.widgets.AnimaWidgetGroup) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) ImageWidget(gregtech.api.gui.widgets.ImageWidget) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) java.awt(java.awt) Interpolator(gregtech.api.util.interpolate.Interpolator) List(java.util.List) GTValues(gregtech.api.GTValues) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) RenderUtil(gregtech.client.utils.RenderUtil) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) Shaders(gregtech.client.shader.Shaders) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) TerminalBehaviour(gregtech.common.items.behaviors.TerminalBehaviour) PacketBuffer(net.minecraft.network.PacketBuffer) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) Interpolator(gregtech.api.util.interpolate.Interpolator)

Aggregations

GTValues (gregtech.api.GTValues)1 IRenderContext (gregtech.api.gui.IRenderContext)1 gregtech.api.gui.resources (gregtech.api.gui.resources)1 ImageWidget (gregtech.api.gui.widgets.ImageWidget)1 AbstractApplication (gregtech.api.terminal.app.AbstractApplication)1 AnimaWidgetGroup (gregtech.api.terminal.gui.widgets.AnimaWidgetGroup)1 CircleButtonWidget (gregtech.api.terminal.gui.widgets.CircleButtonWidget)1 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)1 TerminalOSWidget (gregtech.api.terminal.os.TerminalOSWidget)1 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)1 Eases (gregtech.api.util.interpolate.Eases)1 Interpolator (gregtech.api.util.interpolate.Interpolator)1 Shaders (gregtech.client.shader.Shaders)1 RenderUtil (gregtech.client.utils.RenderUtil)1 TerminalBehaviour (gregtech.common.items.behaviors.TerminalBehaviour)1 java.awt (java.awt)1 List (java.util.List)1 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 PacketBuffer (net.minecraft.network.PacketBuffer)1