Search in sources :

Example 6 with IGuideWidget

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

the class GuidePageEditorWidget method addGuideWidget.

public JsonObject addGuideWidget(IGuideWidget widget, boolean isFixed) {
    int pageWidth = getPageWidth();
    int margin = getMargin();
    JsonObject widgetConfig = widget.getTemplate(isFixed);
    Widget guideWidget;
    if (isFixed) {
        int width = widgetConfig.get("width").getAsInt();
        int height = widgetConfig.get("height").getAsInt();
        guideWidget = widget.updateOrCreateFixedWidget((pageWidth - width) / 2 + 5, this.scrollYOffset + (this.getSize().height - height) / 2, width, height, widgetConfig);
        fixed.add(guideWidget);
        this.addWidget(guideWidget);
    } else {
        int index = stream.indexOf(selected);
        if (index >= 0) {
            guideWidget = widget.updateOrCreateStreamWidget(margin, selected.getSize().height + selected.getSelfPosition().y + scrollYOffset + 5, pageWidth - 2 * margin, widgetConfig);
            for (int i = index + 1; i < stream.size(); i++) {
                stream.get(i).addSelfPosition(0, guideWidget.getSize().height + 5);
            }
            stream.add(index + 1, guideWidget);
        } else {
            guideWidget = widget.updateOrCreateStreamWidget(margin, getStreamBottom() + 5, pageWidth - 2 * margin, widgetConfig);
            stream.add(guideWidget);
        }
        this.addWidget(guideWidget);
        computeMax();
    }
    return widgetConfig;
}
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) JsonObject(com.google.gson.JsonObject)

Example 7 with IGuideWidget

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

the class GuidePageEditorWidget method setToolButton.

private void setToolButton(Widget widget) {
    customPositionSizeWidget.setControlled(widget);
    customPositionSizeWidget.setVisible(true);
    customPositionSizeWidget.setActive(!(widget instanceof IGuideWidget) || ((IGuideWidget) widget).isFixed());
    toolButtons.setVisible(true);
    toolButtons.setSelfPosition(new Position(widget.getSelfPosition().x + widget.getSize().width / 2, widget.getSelfPosition().y));
}
Also used : Position(gregtech.api.util.Position) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget)

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