use of gregtech.api.terminal.gui.widgets.ColorWidget in project GregTech by GregTechCEu.
the class TerminalDialogWidget method showColorDialog.
/**
* Show Color Dialog
* @return color (rgba)
*/
public static TerminalDialogWidget showColorDialog(TerminalOSWidget os, String title, Consumer<Integer> result, int startColor) {
TerminalDialogWidget dialog = createEmptyTemplate(os).addTitle(title);
ColorWidget colorWidget = new ColorWidget(WIDTH / 2 - 60, HEIGHT / 2 - 35, 80, 10);
colorWidget.setStartColor(startColor);
dialog.addWidget(colorWidget);
dialog.addConfirmButton(b -> {
if (b) {
if (result != null)
result.accept(colorWidget.getColor());
} else {
if (result != null)
result.accept(null);
}
});
return dialog;
}
use of gregtech.api.terminal.gui.widgets.ColorWidget in project GregTech by GregTechCEu.
the class ThemeSettings method onModifyTextureChanged.
private void onModifyTextureChanged(String type) {
textureGroup.clearAllWidgets();
switch(type) {
case "resource":
if (!(TerminalTheme.WALL_PAPER.getTexture() instanceof TextureArea)) {
TerminalTheme.WALL_PAPER.setTexture(new TextureArea(new ResourceLocation("gregtech:textures/gui/terminal/terminal_background.png"), 0.0, 0.0, 1.0, 1.0));
TerminalTheme.saveConfig();
}
addStringSetting(((TextureArea) TerminalTheme.WALL_PAPER.getTexture()).imageLocation.toString(), s -> {
TerminalTheme.WALL_PAPER.setTexture(new TextureArea(new ResourceLocation(s), 0.0, 0.0, 1.0, 1.0));
TerminalTheme.saveConfig();
});
break;
case "url":
if (!(TerminalTheme.WALL_PAPER.getTexture() instanceof URLTexture)) {
TerminalTheme.WALL_PAPER.setTexture(new URLTexture(null));
TerminalTheme.saveConfig();
}
addStringSetting(((URLTexture) TerminalTheme.WALL_PAPER.getTexture()).url, s -> {
TerminalTheme.WALL_PAPER.setTexture(new URLTexture(s));
TerminalTheme.saveConfig();
});
break;
case "color":
ColorRectTexture texture;
if (!(TerminalTheme.WALL_PAPER.getTexture() instanceof ColorRectTexture)) {
texture = new ColorRectTexture(-1);
TerminalTheme.WALL_PAPER.setTexture(texture);
TerminalTheme.saveConfig();
} else {
texture = (ColorRectTexture) TerminalTheme.WALL_PAPER.getTexture();
}
textureGroup.addWidget(new ColorWidget(0, 0, 80, 10).setColorSupplier(texture::getColor, true).setOnColorChanged(texture::setColor));
break;
case "file":
if (!(TerminalTheme.WALL_PAPER.getTexture() instanceof FileTexture)) {
TerminalTheme.WALL_PAPER.setTexture(new FileTexture(null));
TerminalTheme.saveConfig();
}
textureGroup.addWidget(new RectButtonWidget(0, 0, 116, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(cd -> TerminalDialogWidget.showFileDialog(os, "terminal.settings.theme.image", TerminalRegistry.TERMINAL_PATH, true, file -> {
if (file != null && file.isFile()) {
TerminalTheme.WALL_PAPER.setTexture(new FileTexture(file));
TerminalTheme.saveConfig();
}
}).setClientSide().open()).setIcon(new TextTexture("terminal.settings.theme.select", -1)));
break;
}
}
Aggregations