use of gregtech.api.gui.resources.ColorRectTexture in project GregTech by GregTechCEu.
the class TerminalDialogWidget method showFileDialog.
/**
* Show FileDialog
* @param dir root directory
* @param isSelector select a file or save a file
* @param result selected file or (saved)
*/
public static TerminalDialogWidget showFileDialog(TerminalOSWidget os, String title, File dir, boolean isSelector, Consumer<File> result) {
Size size = os.getSize();
TerminalDialogWidget dialog = new TerminalDialogWidget(os, 0, 0, size.width, size.height).setBackground(new ColorRectTexture(0x4f000000));
if (!dir.isDirectory()) {
if (!dir.mkdirs()) {
return dialog.addInfo(I18n.format("terminal.dialog.error_path") + dir.getPath()).addOkButton(null);
}
}
AtomicReference<File> selected = new AtomicReference<>();
selected.set(dir);
dialog.addWidget(new TreeListWidget<>(0, 0, 130, size.height, new FileTree(dir), node -> selected.set(node.getKey())).setNodeTexture(GuiTextures.BORDERED_BACKGROUND).canSelectNode(true).setLeafTexture(GuiTextures.SLOT_DARKENED));
int x = 130 + (size.width - 133 - WIDTH) / 2;
int y = (size.height - HEIGHT) / 2;
dialog.addWidget(new ImageWidget(x, y, WIDTH, HEIGHT, DIALOG_BACKGROUND));
dialog.addWidget(new CircleButtonWidget(x + WIDTH / 2 - 30, y + HEIGHT - 22, 12, 0, 24).setClickListener(cd -> {
dialog.close();
if (result != null)
result.accept(selected.get());
}).setColors(0, 0, 0).setIcon(OK_NORMAL).setHoverIcon(OK_HOVER));
dialog.addWidget(new CircleButtonWidget(x + WIDTH / 2 + 30, y + HEIGHT - 22, 12, 0, 24).setClickListener(cd -> {
dialog.close();
if (result != null)
result.accept(null);
}).setColors(0, 0, 0).setIcon(CANCEL_NORMAL).setHoverIcon(CANCEL_HOVER));
if (isSelector) {
dialog.addWidget(new SimpleTextWidget(x + WIDTH / 2, y + HEIGHT / 2 - 5, "", -1, () -> {
if (selected.get() != null) {
return selected.get().toString();
}
return "terminal.dialog.no_file_selected";
}, true).setWidth(WIDTH - 16));
} else {
dialog.addWidget(new TextFieldWidget(x + WIDTH / 2 - 38, y + HEIGHT / 2 - 10, 76, 20, new ColorRectTexture(0x4f000000), null, null).setTextResponder(res -> {
File file = selected.get();
if (file == null)
return;
if (file.isDirectory()) {
selected.set(new File(file, res));
} else {
selected.set(new File(file.getParent(), res));
}
}, true).setTextSupplier(() -> {
File file = selected.get();
if (file != null && !file.isDirectory()) {
return selected.get().getName();
}
return "";
}, true).setMaxStringLength(Integer.MAX_VALUE).setValidator(s -> true));
}
dialog.addWidget(new CircleButtonWidget(x + 17, y + 15, 10, 1, 16).setClickListener(cd -> {
File file = selected.get();
if (file != null) {
try {
Desktop.getDesktop().open(file.isDirectory() ? file : file.getParentFile());
} catch (IOException e) {
e.printStackTrace();
}
}
}).setColors(0, 0xFFFFFFFF, 0).setHoverText("terminal.dialog.folder").setIcon(GuiTextures.ICON_LOAD));
dialog.addWidget(new LabelWidget(x + WIDTH / 2, y + 11, title, -1).setXCentered(true));
if (os.isRemote()) {
os.menu.hideMenu();
}
return dialog.setClientSide();
}
use of gregtech.api.gui.resources.ColorRectTexture 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;
}
use of gregtech.api.gui.resources.ColorRectTexture in project GregTech by GregTechCEu.
the class MazeApp method initApp.
public AbstractApplication initApp() {
if (isClient) {
movementStore = new ArrayList<>();
FSM = new List[4];
FSM[0] = new LinkedList<>();
FSM[1] = new LinkedList<>();
FSM[2] = new LinkedList<>();
FSM[3] = new LinkedList<>();
this.setOs(os);
this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, TerminalTheme.COLOR_B_2));
// enemy 0: Title
this.addWidget(new LabelWidget(333 / 2, 222 / 2 - 50, "Theseus's Escape", 0xFFFFFFFF).setXCentered(true), 0);
this.addWidget(new ClickButtonWidget(323 / 2 - 10, 222 / 2 - 10, 30, 30, "Play", (clickData -> {
this.setGameState(1);
this.resetGame();
})).setShouldClientCallback(true), 0);
// GameState 1: Play
this.setMaze(new MazeWidget());
this.setPlayer(new PlayerWidget(0, 0, this));
this.setEnemy(new EnemyWidget(-100, -100, this));
// GameState 2: Pause
this.addWidget(new ImageWidget(5, 5, 333 - 10, 232 - 10, new ColorRectTexture(0xFF000000)), 2, 3);
this.addWidget(new ClickButtonWidget(323 / 2 - 10, 222 / 2 - 10, 50, 20, "Continue", (clickData) -> this.setGameState(1)).setShouldClientCallback(true), 2);
this.addWidget(new LabelWidget(333 / 2, 222 / 2 - 50, "Game Paused", 0xFFFFFFFF).setXCentered(true), 2);
// GameState 3: Death
this.addWidget(new SimpleTextWidget(333 / 2, 232 / 2 - 40, "", 0xFFFFFFFF, () -> "Oh no! You were eaten by the Minotaur!", true), 3);
this.addWidget(new SimpleTextWidget(333 / 2, 232 / 2 - 28, "", 0xFFFFFFFF, () -> "You got through " + this.getMazesSolved() + " mazes before losing.", true), 3);
this.addWidget(new SimpleTextWidget(333 / 2, 232 / 2 - 16, "", 0xFFFFFFFF, () -> "Try again?", true), 3);
this.addWidget(new ClickButtonWidget(323 / 2 - 10, 222 / 2 + 10, 40, 20, "Retry", (clickData -> {
this.setGameState(1);
this.setMazesSolved(0);
MAZE_SIZE = 9;
speed = 25;
this.resetGame();
})).setShouldClientCallback(true), 3);
}
return this;
}
Aggregations