Search in sources :

Example 1 with ColorWidget

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;
}
Also used : ColorWidget(gregtech.api.terminal.gui.widgets.ColorWidget)

Example 2 with ColorWidget

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;
    }
}
Also used : SelectorWidget(gregtech.api.terminal.gui.widgets.SelectorWidget) Arrays(java.util.Arrays) Size(gregtech.api.util.Size) TerminalOSWidget(gregtech.api.terminal.os.TerminalOSWidget) gregtech.api.gui.resources(gregtech.api.gui.resources) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) TerminalRegistry(gregtech.api.terminal.TerminalRegistry) ColorWidget(gregtech.api.terminal.gui.widgets.ColorWidget) Consumer(java.util.function.Consumer) Position(gregtech.api.util.Position) gregtech.api.gui.widgets(gregtech.api.gui.widgets) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) ResourceLocation(net.minecraft.util.ResourceLocation) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) ColorWidget(gregtech.api.terminal.gui.widgets.ColorWidget) ResourceLocation(net.minecraft.util.ResourceLocation) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Aggregations

ColorWidget (gregtech.api.terminal.gui.widgets.ColorWidget)2 gregtech.api.gui.resources (gregtech.api.gui.resources)1 gregtech.api.gui.widgets (gregtech.api.gui.widgets)1 TerminalRegistry (gregtech.api.terminal.TerminalRegistry)1 CircleButtonWidget (gregtech.api.terminal.gui.widgets.CircleButtonWidget)1 RectButtonWidget (gregtech.api.terminal.gui.widgets.RectButtonWidget)1 SelectorWidget (gregtech.api.terminal.gui.widgets.SelectorWidget)1 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)1 TerminalOSWidget (gregtech.api.terminal.os.TerminalOSWidget)1 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)1 Position (gregtech.api.util.Position)1 Size (gregtech.api.util.Size)1 Arrays (java.util.Arrays)1 Consumer (java.util.function.Consumer)1 ResourceLocation (net.minecraft.util.ResourceLocation)1