use of gregtech.api.gui.widgets.PhantomSlotWidget in project GregTech by GregTechCEu.
the class MetaTileEntityCreativeChest method createUI.
@Override
protected ModularUI createUI(EntityPlayer entityPlayer) {
ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, 176, 209).bindPlayerInventory(entityPlayer.inventory, 126);
builder.widget(new PhantomSlotWidget(handler, 0, 36, 6).setClearSlotOnRightClick(true).setBackgroundTexture(GuiTextures.SLOT).setChangeListener(this::markDirty));
builder.label(7, 9, "gregtech.creative.chest.item");
builder.widget(new ImageWidget(7, 48, 154, 14, GuiTextures.DISPLAY));
builder.widget(new TextFieldWidget2(9, 50, 152, 10, () -> String.valueOf(itemsPerCycle), value -> {
if (!value.isEmpty()) {
itemsPerCycle = Integer.parseInt(value);
}
}).setMaxLength(11).setNumbersOnly(1, Integer.MAX_VALUE));
builder.label(7, 28, "gregtech.creative.chest.ipc");
builder.widget(new ImageWidget(7, 85, 154, 14, GuiTextures.DISPLAY));
builder.widget(new TextFieldWidget2(9, 87, 152, 10, () -> String.valueOf(ticksPerCycle), value -> {
if (!value.isEmpty()) {
ticksPerCycle = Integer.parseInt(value);
}
}).setMaxLength(11).setNumbersOnly(1, Integer.MAX_VALUE));
builder.label(7, 65, "gregtech.creative.chest.tpc");
builder.widget(new CycleButtonWidget(7, 101, 162, 20, () -> active, value -> active = value, "gregtech.creative.activity.off", "gregtech.creative.activity.on"));
return builder.build(getHolder(), entityPlayer);
}
use of gregtech.api.gui.widgets.PhantomSlotWidget in project GregTech by GregTechCEu.
the class WorldProspectorARApp method initApp.
@Override
public AbstractApplication initApp() {
addWidget(new ImageWidget(10, 10, 313, 212, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor())));
addWidget(new LabelWidget(15 + 150 / 2, 232 / 2, "terminal.world_prospector.radius", -1, new Object[] { getMaxRadius() }).setShadow(true).setYCentered(true).setXCentered(true));
int slotSize = (int) Math.pow(2, getAppTier());
int x = 250 - slotSize * 12;
int y = 232 / 2 - 18;
handlers = new SingleItemStackHandler[slotSize];
colors = new int[slotSize];
for (int i = 0; i < slotSize; i++) {
int index = i;
Tuple<ItemStack, Integer> stack = getSlotStack(i);
if (stack == null) {
handlers[i] = new SingleItemStackHandler(ItemStack.EMPTY);
colors[i] = 0;
} else {
handlers[i] = new SingleItemStackHandler(stack.getFirst());
colors[i] = stack.getSecond();
}
RectButtonWidget buttonWidget = new RectButtonWidget(x + i * 24, y + 18, 18, 18, 1);
addWidget(new PhantomSlotWidget(handlers[i], 0, x + i * 24, y) {
@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
if (handlers[index].getStackInSlot(0).isEmpty() && isMouseOverElement(mouseX, mouseY)) {
writeClientAction(-1, buffer -> {
});
selectReference(index, buttonWidget);
return true;
}
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void handleClientAction(int id, PacketBuffer buffer) {
if (id == -1) {
selectReference(index, buttonWidget);
} else {
super.handleClientAction(id, buffer);
}
}
}.setBackgroundTexture(new ColorRectTexture(0x4fffffff)));
addWidget(buttonWidget.setHoverText("terminal.world_prospector.color").setColors(0x4fffffff, -1, colors[i]).setClickListener(cd -> TerminalDialogWidget.showColorDialog(getOs(), "terminal.world_prospector.color", res -> {
if (res != null) {
buttonWidget.setFill(res | 0xff000000);
colors[index] = res | 0xff000000;
}
}, colors[index]).open()));
}
addWidget(new CircleButtonWidget(333 / 2, 200).setClickListener(cd -> openAR()).setHoverText("terminal.ar.open").setColors(0, -1, TerminalTheme.COLOR_B_3.getColor()).setIcon(new ItemStackTexture(MetaItems.CAMERA.getStackForm())));
return this;
}
use of gregtech.api.gui.widgets.PhantomSlotWidget 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);
}
Aggregations