use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.
the class ItemStackConfigurator method addSlot.
private void addSlot(DraggableScrollableWidgetGroup container, SlotListWidget.ItemStackInfo itemStackInfo) {
WidgetGroup group = new WidgetGroup(0, slots.size() * 20, 116, 20);
slots.add(itemStackInfo);
IItemHandlerModifiable handler = new SingleItemStackHandler(1);
handler.setStackInSlot(0, itemStackInfo.getInstance());
group.addWidget(new PhantomSlotWidget(handler, 0, 1, 1).setBackgroundTexture(TerminalTheme.COLOR_B_2).setChangeListener(() -> {
itemStackInfo.update(handler.getStackInSlot(0));
updateValue();
}));
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 -> {
itemStackInfo.count = Math.max(0, itemStackInfo.count - (data.isShiftClick ? 10 : 1));
updateValue();
}).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 -> {
itemStackInfo.count = Math.max(0, itemStackInfo.count + (data.isShiftClick ? 10 : 1));
updateValue();
}).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(itemStackInfo.count), 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);
slots.remove(itemStackInfo);
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 ItemStackConfigurator 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 SlotListWidget.ItemStackInfo("minecraft:air", 0, 0));
updateValue();
}).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()));
slots = new ArrayList<>();
if (!config.get(name).isJsonNull()) {
Gson gson = new Gson();
for (JsonElement o : config.get(name).getAsJsonArray()) {
addSlot(container, gson.fromJson(o, SlotListWidget.ItemStackInfo.class));
}
}
}
use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.
the class VirtualTankApp method initApp.
@Override
public AbstractApplication initApp() {
this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2));
this.addWidget(new LabelWidget(10, 10, "terminal.vtank_viewer.title", -1));
this.addWidget(new RectButtonWidget(216, 7, 110, 18).setClickListener(cd -> {
if (cd.isClient) {
reloadWidgets(cacheClient);
}
}).setIcon(new TextTexture("terminal.vtank_viewer.refresh", -1)).setFill(TerminalTheme.COLOR_B_2.getColor()));
widgetGroup = new DraggableScrollableWidgetGroup(10, 30, 313, 195).setDraggable(true).setYScrollBarWidth(3).setYBarStyle(null, TerminalTheme.COLOR_F_1);
if (isClient) {
cacheClient = new HashMap<>();
} else {
cacheServer = new HashMap<>();
}
this.addWidget(widgetGroup);
if (!isRemote()) {
refresh();
}
return this;
}
use of gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup in project GregTech by GregTechCEu.
the class AppStoreApp method initApp.
@Override
public AbstractApplication initApp() {
DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, 333, 232);
this.addWidget(group);
int index = 0;
int yOffset = 50;
group.addWidget(new ImageWidget(0, 0, 333, 30, GuiTextures.UI_FRAME_SIDE_UP));
group.addWidget(new LabelWidget(333 / 2, 10, getUnlocalizedName(), -1).setShadow(true).setYCentered(true).setXCentered(true));
for (AbstractApplication app : TerminalRegistry.getAllApps()) {
group.addWidget(new AppCardWidget(5 + 110 * (index % 3), yOffset + 110 * (index / 3), app, this));
index++;
}
int y = yOffset + 110 * ((index + 2) / 3);
group.addWidget(new ImageWidget(0, y, 333, 30, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor())));
group.addWidget(new ImageWidget(0, y, 333, 30, new TextTexture("Copyright @2021-xxxx Gregicality Team XD", -1)));
loadLocalConfig(nbt -> this.darkMode = nbt.getBoolean("dark"));
return this;
}
Aggregations