Search in sources :

Example 1 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.

the class AppStoreApp method onOSSizeUpdate.

@Override
public void onOSSizeUpdate(int width, int height) {
    this.setSize(new Size(width, height));
    for (Widget dragWidget : this.widgets) {
        if (dragWidget instanceof DraggableScrollableWidgetGroup) {
            int lastWidth = dragWidget.getSize().width;
            for (Widget widget : ((DraggableScrollableWidgetGroup) dragWidget).widgets) {
                if (widget instanceof AppCardWidget) {
                    widget.addSelfPosition((width - lastWidth) / 2, 0);
                } else if (widget instanceof ImageWidget) {
                    widget.setSize(new Size(width, 30));
                } else {
                    widget.addSelfPosition((width - lastWidth) / 2, 0);
                }
            }
            dragWidget.setSize(new Size(width, height));
        }
    }
}
Also used : DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) Size(gregtech.api.util.Size) LabelWidget(gregtech.api.gui.widgets.LabelWidget) ImageWidget(gregtech.api.gui.widgets.ImageWidget) Widget(gregtech.api.gui.Widget) ImageWidget(gregtech.api.gui.widgets.ImageWidget)

Example 2 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.

the class FluidStackConfigurator method addSlot.

private void addSlot(DraggableScrollableWidgetGroup container, TankListWidget.FluidStackInfo fluidStackInfo) {
    WidgetGroup group = new WidgetGroup(0, tanks.size() * 20, 116, 20);
    tanks.add(fluidStackInfo);
    group.addWidget(new PhantomFluidWidget(1, 1, 18, 18, null, null).setBackgroundTexture(TerminalTheme.COLOR_B_2).setFluidStackSupplier(fluidStackInfo::getInstance, true).setFluidStackUpdater(fluidStack -> {
        fluidStackInfo.update(fluidStack);
        updateValue();
    }, true));
    group.addWidget(new RectButtonWidget(20, 0, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> {
        fluidStackInfo.amount = Math.max(0, fluidStackInfo.amount - (data.isShiftClick ? data.isCtrlClick ? 1000 : 10 : data.isCtrlClick ? 100 : 1));
        updateValue();
    }).setHoverText("Shift -10|Ctrl -100|Shift+Ctrl -1000").setIcon(new TextTexture("-1", -1)));
    group.addWidget(new RectButtonWidget(76, 0, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> {
        fluidStackInfo.amount = Math.max(0, fluidStackInfo.amount + (data.isShiftClick ? data.isCtrlClick ? 1000 : 10 : data.isCtrlClick ? 100 : 1));
        updateValue();
    }).setHoverText("Shift +10|Ctrl +100|Shift+Ctrl +1000").setIcon(new TextTexture("+1", -1)));
    group.addWidget(new ImageWidget(40, 0, 36, 20, TerminalTheme.COLOR_B_2));
    group.addWidget(new SimpleTextWidget(58, 10, "", 0xFFFFFF, () -> Integer.toString(fluidStackInfo.amount), true));
    group.addWidget(new RectButtonWidget(96, 0, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> {
        container.waitToRemoved(group);
        tanks.remove(fluidStackInfo);
        int index = container.widgets.indexOf(group);
        for (int i = container.widgets.size() - 1; i > index; i--) {
            container.widgets.get(i).addSelfPosition(0, -20);
        }
        updateValue();
    }).setIcon(GuiTextures.ICON_REMOVE));
    container.addWidget(group);
}
Also used : JsonObject(com.google.gson.JsonObject) TankListWidget(gregtech.common.terminal.app.guide.widget.TankListWidget) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TextTexture(gregtech.api.gui.resources.TextTexture) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) GuiTextures(gregtech.api.gui.GuiTextures) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) java.awt(java.awt) List(java.util.List) gregtech.api.gui.widgets(gregtech.api.gui.widgets) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) Gson(com.google.gson.Gson) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) TextTexture(gregtech.api.gui.resources.TextTexture) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 3 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup 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)

Example 4 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.

the class GuideConfigEditor method createPageConfig.

private DraggableScrollableWidgetGroup createPageConfig() {
    DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, getSize().width, getSize().height - 10).setBackground(TerminalTheme.COLOR_B_3).setYScrollBarWidth(4).setYBarStyle(null, TerminalTheme.COLOR_F_1);
    group.addWidget(new LabelWidget(5, 5, "section", -1).setShadow(true));
    group.addWidget(new TextFieldWidget(5, 15, 116, 20, new ColorRectTexture(0x9f000000), null, null).setTextResponder(s -> {
        if (pageEditor != null) {
            pageEditor.setSection(s);
        }
    }, true).setTextSupplier(() -> getPageEditor().getSection(), true).setMaxStringLength(Integer.MAX_VALUE).setValidator(s -> true));
    group.addWidget(new ImageWidget(5, 40, 116, 1, new ColorRectTexture(-1)));
    group.addWidget(new LabelWidget(5, 45, "type", -1).setShadow(true));
    group.addWidget(new SelectorWidget(30, 55, 91, 20, candidates, -1, () -> type, true).setIsUp(true).setOnChanged(type -> this.type = type).setColors(TerminalTheme.COLOR_B_2.getColor(), TerminalTheme.COLOR_F_1.getColor(), TerminalTheme.COLOR_B_2.getColor()).setBackground(TerminalTheme.COLOR_6));
    group.addWidget(new PhantomSlotWidget(handler, 0, 6, 56).setBackgroundTexture(TerminalTheme.COLOR_B_2));
    group.addWidget(new ImageWidget(5, 80, 116, 1, new ColorRectTexture(-1)));
    group.addWidget(new LabelWidget(5, 85, "title", -1).setShadow(true));
    titleEditor = new TextEditorWidget(5, 95, 116, 70, s -> {
        if (pageEditor != null) {
            pageEditor.setTitle(s);
        }
    }, true).setContent("Template").setBackground(new ColorRectTexture(0xA3FFFFFF));
    group.addWidget(titleEditor);
    return group;
}
Also used : JsonObject(com.google.gson.JsonObject) Size(gregtech.api.util.Size) MultiBlockGuideApp(gregtech.common.terminal.app.guide.MultiBlockGuideApp) Item(net.minecraft.item.Item) IGuiTextureTabInfo(gregtech.api.gui.widgets.tab.IGuiTextureTabInfo) SimpleMachineGuideApp(gregtech.common.terminal.app.guide.SimpleMachineGuideApp) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) TextTexture(gregtech.api.gui.resources.TextTexture) TerminalRegistry(gregtech.api.terminal.TerminalRegistry) ItemStack(net.minecraft.item.ItemStack) Widget(gregtech.api.gui.Widget) GregTechAPI(gregtech.api.GregTechAPI) gregtech.api.gui.widgets(gregtech.api.gui.widgets) Map(java.util.Map) FileUtility(gregtech.api.util.FileUtility) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) IGuideWidget(gregtech.common.terminal.app.guide.widget.IGuideWidget) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) SelectorWidget(gregtech.api.terminal.gui.widgets.SelectorWidget) CustomTabListRenderer(gregtech.api.terminal.gui.CustomTabListRenderer) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) GuideApp(gregtech.common.terminal.app.guide.GuideApp) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) Collectors(java.util.stream.Collectors) GuiTextures(gregtech.api.gui.GuiTextures) File(java.io.File) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) java.awt(java.awt) Objects(java.util.Objects) Position(gregtech.api.util.Position) ItemGuideApp(gregtech.common.terminal.app.guide.ItemGuideApp) List(java.util.List) TextEditorWidget(gregtech.api.terminal.gui.widgets.TextEditorWidget) GuideEditorApp(gregtech.common.terminal.app.guideeditor.GuideEditorApp) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) GuidePageWidget(gregtech.common.terminal.app.guide.widget.GuidePageWidget) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) SelectorWidget(gregtech.api.terminal.gui.widgets.SelectorWidget) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) TextEditorWidget(gregtech.api.terminal.gui.widgets.TextEditorWidget)

Example 5 with DraggableScrollableWidgetGroup

use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.

the class FluidStackConfigurator method init.

protected void init() {
    container = new DraggableScrollableWidgetGroup(0, 27, 116, 100);
    this.addWidget(container);
    this.addWidget(new RectButtonWidget(0, 15, 116, 10, 1).setIcon(new TextTexture("terminal.guide_editor.add_slot", -1)).setClickListener(cd -> {
        addSlot(container, new TankListWidget.FluidStackInfo(null, 0));
        updateValue();
    }).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()));
    tanks = new ArrayList<>();
    if (!config.get(name).isJsonNull()) {
        Gson gson = new Gson();
        for (JsonElement o : config.get(name).getAsJsonArray()) {
            addSlot(container, gson.fromJson(o, TankListWidget.FluidStackInfo.class));
        }
    }
}
Also used : TankListWidget(gregtech.common.terminal.app.guide.widget.TankListWidget) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) JsonElement(com.google.gson.JsonElement) TextTexture(gregtech.api.gui.resources.TextTexture) Gson(com.google.gson.Gson) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Aggregations

DraggableScrollableWidgetGroup (gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup)9 TextTexture (gregtech.api.gui.resources.TextTexture)7 RectButtonWidget (gregtech.api.terminal.gui.widgets.RectButtonWidget)5 ImageWidget (gregtech.api.gui.widgets.ImageWidget)4 Gson (com.google.gson.Gson)3 JsonElement (com.google.gson.JsonElement)3 JsonObject (com.google.gson.JsonObject)3 GuiTextures (gregtech.api.gui.GuiTextures)3 Widget (gregtech.api.gui.Widget)3 LabelWidget (gregtech.api.gui.widgets.LabelWidget)3 AbstractApplication (gregtech.api.terminal.app.AbstractApplication)3 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)3 ColorRectTexture (gregtech.api.gui.resources.ColorRectTexture)2 gregtech.api.gui.widgets (gregtech.api.gui.widgets)2 WidgetGroup (gregtech.api.gui.widgets.WidgetGroup)2 CircleButtonWidget (gregtech.api.terminal.gui.widgets.CircleButtonWidget)2 SelectorWidget (gregtech.api.terminal.gui.widgets.SelectorWidget)2 TextEditorWidget (gregtech.api.terminal.gui.widgets.TextEditorWidget)2 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)2 Position (gregtech.api.util.Position)2