use of gregtech.api.terminal.gui.widgets.CircleButtonWidget in project GregTech by GregTechCEu.
the class TerminalDesktopWidget method installApplication.
public void installApplication(AbstractApplication application) {
int r = 12;
int index = appDiv.widgets.size();
int x = this.getSize().width / 2 + (3 * r) * (index % rowCount - rowCount / 2);
int y = (index / rowCount) * (3 * r) + 40;
CircleButtonWidget button = new CircleButtonWidget(x, y).setColors(TerminalTheme.COLOR_B_2.getColor(), application.getThemeColor(), TerminalTheme.COLOR_B_2.getColor()).setIcon(application.getIcon()).setHoverText(application.getUnlocalizedName());
button.setClickListener(clickData -> os.openApplication(application, clickData.isClient));
appDiv.addWidget(button);
}
use of gregtech.api.terminal.gui.widgets.CircleButtonWidget in project GregTech by GregTechCEu.
the class TerminalMenuWidget method addComponent.
public void addComponent(IMenuComponent component) {
WidgetGroup group = new WidgetGroup();
int x = 15;
int y = 40 + components.size() * 25;
CircleButtonWidget button = new CircleButtonWidget(x, y, 10, 1, 16).setColors(0, 0xFFFFFFFF, 0).setHoverText(component.hoverText()).setIcon(component.buttonIcon());
button.setClickListener(c -> {
components.forEach(tuple -> {
if (tuple.getFirst() instanceof Widget && tuple.getFirst() != component) {
((Widget) tuple.getFirst()).setActive(false);
((Widget) tuple.getFirst()).setVisible(false);
((CircleButtonWidget) tuple.getSecond().widgets.get(0)).setFill(0);
}
});
if (component instanceof Widget) {
Widget widget = (Widget) component;
widget.setVisible(!widget.isVisible());
widget.setActive(!widget.isActive());
button.setFill(widget.isVisible() ? 0xFF94E2C1 : 0);
}
component.click(c);
});
group.addWidget(button);
if (component instanceof Widget) {
Widget widget = (Widget) component;
widget.setSelfPosition(new Position(x + 20, 0));
widget.setVisible(false);
widget.setActive(false);
group.addWidget(widget);
}
this.addWidget(group);
components.add(new Tuple<>(component, group));
}
use of gregtech.api.terminal.gui.widgets.CircleButtonWidget in project GregTech by GregTechCEu.
the class RGNode method init.
private void init(RGContainer container) {
this.container = container;
textWidget = new SimpleTextWidget(9, -5, "", -1, () -> {
if (head instanceof ItemStack) {
return ((ItemStack) head).getDisplayName();
} else if (head instanceof FluidStack) {
return ((FluidStack) head).getLocalizedName();
}
return "terminal.recipe_chart.drag";
}, true).setShadow(true);
textWidget.setVisible(false);
textWidget.setActive(false);
this.addWidget(textWidget);
inputsGroup = new WidgetGroup(0, 0, 0, 0);
this.addWidget(inputsGroup);
toolGroup = new WidgetGroup(0, 0, 0, 0);
this.addWidget(toolGroup);
toolGroup.addWidget(new CircleButtonWidget(-11, 9, 8, 1, 12).setColors(0, TerminalTheme.COLOR_7.getColor(), TerminalTheme.COLOR_3.getColor()).setIcon(GuiTextures.ICON_REMOVE).setHoverText("terminal.guide_editor.remove").setClickListener(cd -> remove()));
toolGroup.addWidget(new CircleButtonWidget(-11, 29, 8, 1, 12).setColors(0, TerminalTheme.COLOR_7.getColor(), 0).setIcon(GuiTextures.ICON_VISIBLE).setHoverText("terminal.recipe_chart.visible").setClickListener(cd -> {
textWidget.setActive(!textWidget.isActive());
textWidget.setVisible(!textWidget.isVisible());
}));
toolGroup.addWidget(new CircleButtonWidget(9, 29, 8, 1, 12).setColors(0, TerminalTheme.COLOR_7.getColor(), 0).setIcon(GuiTextures.ICON_LOCATION).setHoverText("terminal.recipe_chart.jei").setClickListener(cd -> {
if (GTJeiPlugin.jeiRuntime != null && head != null) {
GTJeiPlugin.jeiRuntime.getRecipesGui().show(new Focus<>(IFocus.Mode.OUTPUT, head));
}
}));
inputsGroup.setVisible(false);
inputsGroup.setActive(false);
toolGroup.setVisible(false);
toolGroup.setActive(false);
parentNodes = new HashMap<>();
// important
children = new LinkedHashMap<>();
}
use of gregtech.api.terminal.gui.widgets.CircleButtonWidget in project GregTech by GregTechCEu.
the class ThemeSettings method addColorButton.
private void addColorButton(ColorRectTexture texture, String name, int x, int y) {
CircleButtonWidget buttonWidget = new CircleButtonWidget(x, y, 8, 1, 0).setFill(texture.getColor()).setStrokeAnima(-1).setHoverText(name);
buttonWidget.setClickListener(cd -> TerminalDialogWidget.showColorDialog(os, name, color -> {
if (color != null) {
buttonWidget.setFill(color);
texture.setColor(color);
if (!TerminalTheme.saveConfig()) {
TerminalDialogWidget.showInfoDialog(os, "terminal.component.error", "terminal.component.save_file.error").setClientSide().open();
}
}
}, texture.color).setClientSide().open());
addWidget(buttonWidget);
}
use of gregtech.api.terminal.gui.widgets.CircleButtonWidget 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;
}
Aggregations