Search in sources :

Example 1 with IGuideWidget

use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.

the class GuidePageEditorWidget method mouseClicked.

@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
    if (super.mouseClicked(mouseX, mouseY, button)) {
        return true;
    }
    boolean flag = false;
    for (int i = fixed.size() - 1; i >= 0; i--) {
        Widget widget = fixed.get(i);
        if (widget.isMouseOverElement(mouseX, mouseY)) {
            if (widget instanceof IGuideWidget && widget != selected) {
                configEditor.loadConfigurator((IGuideWidget) widget);
                selected = widget;
                setToolButton(selected);
            }
            playButtonClickSound();
            flag = true;
            break;
        }
    }
    if (!flag) {
        for (Widget widget : stream) {
            if (widget.isMouseOverElement(mouseX, mouseY)) {
                if (widget instanceof IGuideWidget && widget != selected) {
                    configEditor.loadConfigurator((IGuideWidget) widget);
                    selected = widget;
                    setToolButton(selected);
                }
                playButtonClickSound();
                flag = true;
                break;
            }
        }
    }
    return flag;
}
Also used : 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) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget)

Example 2 with IGuideWidget

use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.

the class GuidePageEditorWidget method onPosSizeChanged.

private void onPosSizeChanged(Position pos, Size size) {
    Widget widget = customPositionSizeWidget.getControlled();
    if (widget instanceof IGuideWidget && ((IGuideWidget) widget).isFixed()) {
        JsonObject config = ((IGuideWidget) widget).getConfig();
        if (config.has("x")) {
            config.addProperty("x", pos.x + scrollXOffset);
            ((IGuideWidget) widget).updateValue("x");
        }
        if (config.has("y")) {
            config.addProperty("y", pos.y + scrollYOffset);
            ((IGuideWidget) widget).updateValue("y");
        }
        if (config.has("width")) {
            config.addProperty("width", size.width);
            ((IGuideWidget) widget).updateValue("width");
        }
        if (config.has("height")) {
            config.addProperty("height", size.height);
            ((IGuideWidget) widget).updateValue("height");
        }
        ((IGuideWidget) widget).onFixedPositionSizeChanged(pos, size);
    }
    toolButtons.setSelfPosition(new Position(pos.x + size.width / 2, pos.y));
}
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) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget) JsonObject(com.google.gson.JsonObject)

Example 3 with IGuideWidget

use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.

the class GuidePageEditorWidget method getJsonConfig.

public JsonObject getJsonConfig() {
    JsonObject json = new JsonObject();
    json.addProperty("section", section);
    json.addProperty("title", title.content.get(0));
    JsonArray array = new JsonArray();
    json.add("stream", array);
    stream.forEach(widget -> {
        if (widget instanceof IGuideWidget) {
            array.add(((IGuideWidget) widget).getConfig());
        }
    });
    JsonArray array2 = new JsonArray();
    json.add("fixed", array2);
    fixed.forEach(widget -> {
        if (widget instanceof IGuideWidget) {
            array2.add(((IGuideWidget) widget).getConfig());
        }
    });
    return json;
}
Also used : JsonArray(com.google.gson.JsonArray) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget) JsonObject(com.google.gson.JsonObject)

Example 4 with IGuideWidget

use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.

the class GuideConfigEditor method mouseClicked.

@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
    boolean flag = super.mouseClicked(mouseX, mouseY, button);
    if (selectedTabIndex == 1 && widgetSelector != null) {
        for (Widget widget : widgetSelector.widgets) {
            if (widget.isMouseOverElement(mouseX, mouseY)) {
                if (widget instanceof IGuideWidget) {
                    if (selected != null) {
                        selected.setStroke(0);
                    }
                    ((IGuideWidget) widget).setStroke(0xFF7CA1FF);
                    selected = (IGuideWidget) widget;
                }
                playButtonClickSound();
                return true;
            }
        }
    }
    return flag;
}
Also used : TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) Widget(gregtech.api.gui.Widget) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget) SelectorWidget(gregtech.api.terminal.gui.widgets.SelectorWidget) TextEditorWidget(gregtech.api.terminal.gui.widgets.TextEditorWidget) GuidePageWidget(gregtech.common.terminal.app.guide.widget.GuidePageWidget) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget)

Example 5 with IGuideWidget

use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.

the class GuideConfigEditor method createWidgetSelector.

private DraggableScrollableWidgetGroup createWidgetSelector() {
    DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, getSize().width, getSize().height - 10).setBackground(TerminalTheme.COLOR_B_3).setYScrollBarWidth(4).setYBarStyle(null, TerminalTheme.COLOR_F_1);
    // 133
    int y = 10;
    for (Map.Entry<String, IGuideWidget> entry : GuidePageWidget.REGISTER_WIDGETS.entrySet()) {
        IGuideWidget widgetTemplate = entry.getValue();
        JsonObject template = widgetTemplate.getTemplate(false);
        Widget guideWidget = widgetTemplate.updateOrCreateStreamWidget(5, y + 10, getSize().width - 14, template);
        group.addWidget(new LabelWidget(getSize().width / 2 - 1, y - 3, entry.getKey(), -1).setXCentered(true).setShadow(true));
        y += guideWidget.getSize().height + 25;
        group.addWidget(guideWidget);
    }
    group.addWidget(new WidgetGroup(new Position(5, group.getWidgetBottomHeight() + 5), Size.ZERO));
    return group;
}
Also used : DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) Position(gregtech.api.util.Position) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) Widget(gregtech.api.gui.Widget) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget) SelectorWidget(gregtech.api.terminal.gui.widgets.SelectorWidget) TextEditorWidget(gregtech.api.terminal.gui.widgets.TextEditorWidget) GuidePageWidget(gregtech.common.terminal.app.guide.widget.GuidePageWidget) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) JsonObject(com.google.gson.JsonObject) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) Map(java.util.Map)

Aggregations

IGuideWidget (gregtech.common.terminal.app.guide.widget.IGuideWidget)7 Widget (gregtech.api.gui.Widget)5 CircleButtonWidget (gregtech.api.terminal.gui.widgets.CircleButtonWidget)5 GuidePageWidget (gregtech.common.terminal.app.guide.widget.GuidePageWidget)5 JsonObject (com.google.gson.JsonObject)4 CustomPositionSizeWidget (gregtech.api.terminal.gui.widgets.CustomPositionSizeWidget)3 Position (gregtech.api.util.Position)3 SelectorWidget (gregtech.api.terminal.gui.widgets.SelectorWidget)2 TextEditorWidget (gregtech.api.terminal.gui.widgets.TextEditorWidget)2 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)2 JsonArray (com.google.gson.JsonArray)1 DraggableScrollableWidgetGroup (gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup)1 Map (java.util.Map)1