Search in sources :

Example 1 with Interpolator

use of gregtech.api.util.interpolate.Interpolator in project GregTech by GregTechCEu.

the class TerminalMenuWidget method showMenu.

@SideOnly(Side.CLIENT)
public void showMenu() {
    if (isHide && interpolator == null) {
        setVisible(true);
        int y = getSelfPosition().y;
        interpolator = new Interpolator(getSelfPosition().x, getSelfPosition().x + getSize().width, 6, Eases.EaseLinear, value -> setSelfPosition(new Position(value.intValue(), y)), value -> {
            interpolator = null;
            isHide = false;
        });
        interpolator.start();
        os.desktop.addTopWidget(this);
    }
}
Also used : IRenderContext(gregtech.api.gui.IRenderContext) SystemCall(gregtech.api.terminal.os.SystemCall) Size(gregtech.api.util.Size) TerminalOSWidget(gregtech.api.terminal.os.TerminalOSWidget) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) Eases(gregtech.api.util.interpolate.Eases) GlStateManager(net.minecraft.client.renderer.GlStateManager) Tuple(net.minecraft.util.Tuple) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) ArrayList(java.util.ArrayList) java.awt(java.awt) Position(gregtech.api.util.Position) Interpolator(gregtech.api.util.interpolate.Interpolator) List(java.util.List) Widget(gregtech.api.gui.Widget) Side(net.minecraftforge.fml.relauncher.Side) IGuiTexture(gregtech.api.gui.resources.IGuiTexture) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Position(gregtech.api.util.Position) Interpolator(gregtech.api.util.interpolate.Interpolator) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with Interpolator

use of gregtech.api.util.interpolate.Interpolator in project GregTech by GregTechCEu.

the class GuidePageEditorWidget method moveUp.

public void moveUp(Widget widget) {
    int index = stream.indexOf(widget);
    if (index > 0) {
        Widget target = stream.get(index - 1);
        if (interpolator == null) {
            int offsetD = 5 + widget.getSize().height;
            int offsetU = widget.getPosition().y - target.getPosition().y;
            int y1 = widget.getSelfPosition().y;
            int y2 = target.getSelfPosition().y;
            interpolator = new Interpolator(0, 1, 10, Eases.EaseLinear, value -> {
                widget.setSelfPosition(new Position(widget.getSelfPosition().x, (int) (y1 - value.floatValue() * offsetU)));
                target.setSelfPosition(new Position(target.getSelfPosition().x, (int) (y2 + value.floatValue() * offsetD)));
                if (widget == selected) {
                    setToolButton(selected);
                }
                widget.setVisible(widget.getSelfPosition().y < scrollYOffset + getSize().height && widget.getSelfPosition().y + widget.getSize().height > 0);
                target.setVisible(target.getSelfPosition().y < scrollYOffset + getSize().height && target.getSelfPosition().y + target.getSize().height > 0);
            }, value -> {
                interpolator = null;
                stream.remove(widget);
                stream.add(index - 1, widget);
            }).start();
        }
    } else {
        int index2 = fixed.indexOf(widget);
        if (index2 >= 0 && index2 < fixed.size() - 1) {
            Widget target = fixed.get(index2 + 1);
            fixed.remove(widget);
            fixed.add(index2 + 1, widget);
        }
    }
}
Also used : Position(gregtech.api.util.Position) CustomPositionSizeWidget(gregtech.api.terminal.gui.widgets.CustomPositionSizeWidget) Widget(gregtech.api.gui.Widget) GuidePageWidget(gregtech.common.terminal.app.guide.widget.GuidePageWidget) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget) Interpolator(gregtech.api.util.interpolate.Interpolator)

Example 3 with Interpolator

use of gregtech.api.util.interpolate.Interpolator in project GregTech by GregTechCEu.

the class GuidePageWidget method jumpToRef.

public void jumpToRef(String ref) {
    if (interpolator != null && !interpolator.isFinish())
        return;
    for (Widget widget : widgets) {
        if (widget instanceof IGuideWidget && ref.equals(((IGuideWidget) widget).getRef())) {
            interpolator = new Interpolator(scrollYOffset, widget.getSelfPosition().y + scrollYOffset, 20, Eases.EaseQuadOut, value -> setScrollYOffset(value.intValue()), value -> interpolator = null);
            interpolator.start();
        }
    }
}
Also used : JsonObject(com.google.gson.JsonObject) java.util(java.util) Size(gregtech.api.util.Size) Eases(gregtech.api.util.interpolate.Eases) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) JsonParser(com.google.gson.JsonParser) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) JsonElement(com.google.gson.JsonElement) java.awt(java.awt) Position(gregtech.api.util.Position) Interpolator(gregtech.api.util.interpolate.Interpolator) List(java.util.List) Widget(gregtech.api.gui.Widget) Widget(gregtech.api.gui.Widget) Interpolator(gregtech.api.util.interpolate.Interpolator)

Example 4 with Interpolator

use of gregtech.api.util.interpolate.Interpolator in project GregTech by GregTechCEu.

the class AnimaWidgetGroup method maximizeWidget.

@SideOnly(Side.CLIENT)
public final void maximizeWidget(Consumer<AnimaWidgetGroup> callback) {
    this.scale = 0;
    setVisible(true);
    interpolator = new Interpolator(0, 1, 10, Eases.EaseLinear, value -> scale = value.floatValue(), value -> {
        interpolator = null;
        if (callback != null) {
            callback.accept(this);
        }
    });
    interpolator.start();
}
Also used : Consumer(java.util.function.Consumer) Position(gregtech.api.util.Position) Interpolator(gregtech.api.util.interpolate.Interpolator) IRenderContext(gregtech.api.gui.IRenderContext) Size(gregtech.api.util.Size) Side(net.minecraftforge.fml.relauncher.Side) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) Eases(gregtech.api.util.interpolate.Eases) GlStateManager(net.minecraft.client.renderer.GlStateManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Interpolator(gregtech.api.util.interpolate.Interpolator) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with Interpolator

use of gregtech.api.util.interpolate.Interpolator in project GregTech by GregTechCEu.

the class AnimaWidgetGroup method minimizeWidget.

@SideOnly(Side.CLIENT)
public final void minimizeWidget(Consumer<AnimaWidgetGroup> callback) {
    this.scale = 1;
    interpolator = new Interpolator(1, 0, 10, Eases.EaseLinear, value -> scale = value.floatValue(), value -> {
        setVisible(false);
        interpolator = null;
        if (callback != null) {
            callback.accept(this);
        }
    });
    interpolator.start();
}
Also used : Consumer(java.util.function.Consumer) Position(gregtech.api.util.Position) Interpolator(gregtech.api.util.interpolate.Interpolator) IRenderContext(gregtech.api.gui.IRenderContext) Size(gregtech.api.util.Size) Side(net.minecraftforge.fml.relauncher.Side) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) Eases(gregtech.api.util.interpolate.Eases) GlStateManager(net.minecraft.client.renderer.GlStateManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Interpolator(gregtech.api.util.interpolate.Interpolator) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Interpolator (gregtech.api.util.interpolate.Interpolator)9 Position (gregtech.api.util.Position)7 Eases (gregtech.api.util.interpolate.Eases)7 IRenderContext (gregtech.api.gui.IRenderContext)6 CircleButtonWidget (gregtech.api.terminal.gui.widgets.CircleButtonWidget)6 Widget (gregtech.api.gui.Widget)5 Size (gregtech.api.util.Size)5 List (java.util.List)5 GlStateManager (net.minecraft.client.renderer.GlStateManager)5 Side (net.minecraftforge.fml.relauncher.Side)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 WidgetGroup (gregtech.api.gui.widgets.WidgetGroup)4 AbstractApplication (gregtech.api.terminal.app.AbstractApplication)4 TerminalOSWidget (gregtech.api.terminal.os.TerminalOSWidget)4 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)4 java.awt (java.awt)4 IGuiTexture (gregtech.api.gui.resources.IGuiTexture)3 ArrayList (java.util.ArrayList)3 ColorRectTexture (gregtech.api.gui.resources.ColorRectTexture)2 ImageWidget (gregtech.api.gui.widgets.ImageWidget)2