use of gregtech.api.terminal.gui.widgets.RectButtonWidget in project GregTech by GregTechCEu.
the class BatteryManagerApp method addBatteryApps.
private void addBatteryApps() {
AtomicInteger index = new AtomicInteger();
for (AbstractApplication installed : getOs().installedApps) {
TerminalRegistry.getAppHardwareDemand(installed.getRegistryName(), getOs().tabletNBT.getCompoundTag(installed.getRegistryName()).getInteger("_tier")).stream().filter(i -> i instanceof BatteryHardware).findFirst().ifPresent(battery -> {
long charge = ((BatteryHardware) battery).getCharge();
this.addWidget(new RectButtonWidget(180 + (index.get() % 5) * 30, 15 + (index.get() / 5) * 30, 20, 20, 2).setIcon(installed.getIcon()).setHoverText(I18n.format("terminal.battery.hover", I18n.format(installed.getUnlocalizedName()), charge)).setColors(0, TerminalTheme.COLOR_7.getColor(), 0));
index.getAndIncrement();
});
}
}
use of gregtech.api.terminal.gui.widgets.RectButtonWidget in project GregTech by GregTechCEu.
the class StringConfigurator method init.
protected void init() {
this.addWidget(new RectButtonWidget(76, 15, 40, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> updateString()).setIcon(new TextTexture("terminal.guide_editor.update", -1)));
textFieldWidget = new TextFieldWidget(0, 15, 76, 20, TerminalTheme.COLOR_B_2, null, null).setMaxStringLength(Integer.MAX_VALUE).setValidator(s -> true);
if (config.has(name) && config.get(name).isJsonPrimitive()) {
textFieldWidget.setCurrentString(config.get(name).getAsString());
}
this.addWidget(textFieldWidget);
}
use of gregtech.api.terminal.gui.widgets.RectButtonWidget in project GregTech by GregTechCEu.
the class MultiBlockPreviewARApp method initApp.
@Override
public AbstractApplication initApp() {
// 232 333
int bW = 120;
int bH = 120;
addWidget(new ImageWidget(10, 10, 313, 212, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor())));
addWidget(new ImageWidget(333 / 2, 20, 1, 222 - 40, new ColorRectTexture(-1)));
addWidget(new LabelWidget(10 + 313 / 4, 35, "terminal.multiblock_ar.tier.0", -1).setXCentered(true).setYCentered(true));
addWidget(new RectButtonWidget(10 + (313 / 2 - bW) / 2, 50, bW, bH).setIcon(TextureArea.fullImage("textures/gui/terminal/multiblock_ar/profile.png")).setColors(-1, 0xff00ff00, 0).setHoverText("terminal.ar.open").setClickListener(clickData -> openAR()));
addWidget(new LabelWidget(333 / 2 + 313 / 4, 35, "terminal.multiblock_ar.tier.1", getAppTier() == 0 ? 0xffff0000 : -1).setXCentered(true).setYCentered(true));
addWidget(new RectButtonWidget(333 / 2 + (313 / 2 - bW) / 2, 50, bW, bH).setIcon(this::drawBuilderButton).setColors(getAppTier() == 0 ? 0xffff0000 : -1, getAppTier() == 0 ? 0xffff0000 : 0xff00ff00, 0).setHoverText(getAppTier() > 0 ? "terminal.multiblock_ar.builder.hover" : "terminal.multiblock_ar.unlock").setClickListener(clickData -> buildMode()));
return this;
}
use of gregtech.api.terminal.gui.widgets.RectButtonWidget 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.RectButtonWidget in project GregTech by GregTechCEu.
the class NumberConfigurator method init.
protected void init() {
int y = 15;
this.addWidget(new RectButtonWidget(0, y, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> adjustTransferRate(data.isShiftClick ? -100 : -10)).setIcon(new TextTexture("-10", -1)));
this.addWidget(new RectButtonWidget(96, y, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> adjustTransferRate(data.isShiftClick ? +100 : +10)).setIcon(new TextTexture("+10", -1)));
this.addWidget(new RectButtonWidget(20, y, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> adjustTransferRate(data.isShiftClick ? -5 : -1)).setIcon(new TextTexture("-1", -1)));
this.addWidget(new RectButtonWidget(76, y, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> adjustTransferRate(data.isShiftClick ? +5 : +1)).setIcon(new TextTexture("+1", -1)));
this.addWidget(new ImageWidget(40, y, 36, 20, TerminalTheme.COLOR_B_2));
this.addWidget(new SimpleTextWidget(58, 25, "", 0xFFFFFF, () -> {
JsonElement element = config.get(name);
if (element.isJsonNull()) {
return Integer.toString(defaultValue);
}
return element.getAsString();
}, true));
}
Aggregations