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));
}
}
}
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);
}
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;
}
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;
}
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));
}
}
}
Aggregations