Search in sources :

Example 6 with RectButtonWidget

use of gregtech.api.terminal.gui.widgets.RectButtonWidget 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)

Example 7 with RectButtonWidget

use of gregtech.api.terminal.gui.widgets.RectButtonWidget 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;
}
Also used : java.util(java.util) IRenderContext(gregtech.api.gui.IRenderContext) Blocks(net.minecraft.init.Blocks) MetaItems(gregtech.common.items.MetaItems) BlockStateMatcher(gregtech.common.terminal.app.worldprospector.matcher.BlockStateMatcher) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) ItemStackTexture(gregtech.api.gui.resources.ItemStackTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) ShaderTexture(gregtech.api.gui.resources.ShaderTexture) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) RenderBufferHelper(gregtech.client.utils.RenderBufferHelper) GL11(org.lwjgl.opengl.GL11) Shaders(gregtech.client.shader.Shaders) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) PhantomSlotWidget(gregtech.api.gui.widgets.PhantomSlotWidget) IMatcher(gregtech.common.terminal.app.worldprospector.matcher.IMatcher) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DepthTextureUtil(gregtech.client.utils.DepthTextureUtil) Entity(net.minecraft.entity.Entity) BlockFalling(net.minecraft.block.BlockFalling) World(net.minecraft.world.World) GlStateManager(net.minecraft.client.renderer.GlStateManager) Tuple(net.minecraft.util.Tuple) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) BlockPos(net.minecraft.util.math.BlockPos) LabelWidget(gregtech.api.gui.widgets.LabelWidget) ARApplication(gregtech.api.terminal.app.ARApplication) Framebuffer(net.minecraft.client.shader.Framebuffer) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) Tessellator(net.minecraft.client.renderer.Tessellator) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) ItemBlock(net.minecraft.item.ItemBlock) PacketBuffer(net.minecraft.network.PacketBuffer) ItemStackTexture(gregtech.api.gui.resources.ItemStackTexture) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) PhantomSlotWidget(gregtech.api.gui.widgets.PhantomSlotWidget) LabelWidget(gregtech.api.gui.widgets.LabelWidget) ImageWidget(gregtech.api.gui.widgets.ImageWidget) ItemStack(net.minecraft.item.ItemStack) PacketBuffer(net.minecraft.network.PacketBuffer) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 8 with RectButtonWidget

use of gregtech.api.terminal.gui.widgets.RectButtonWidget in project GregTech by GregTechCEu.

the class HardwareManagerApp method initApp.

@Override
public AbstractApplication initApp() {
    apps = new WidgetGroup();
    this.addWidget(apps);
    int x = 10;
    int y = 65;
    for (Hardware hardware : os.hardwareProvider.getProviders().values()) {
        HardwareSlotWidget hardwareSlotWidget = new HardwareSlotWidget(x, y, os, hardware);
        this.addWidget(hardwareSlotWidget);
        hardwareSlotWidget.setOnSelected(() -> {
            selected = hardwareSlotWidget;
            apps.clearAllWidgets();
            AtomicInteger index = new AtomicInteger(0);
            for (AbstractApplication installed : getOs().installedApps) {
                TerminalRegistry.getAppHardwareDemand(installed.getRegistryName(), getOs().tabletNBT.getCompoundTag(installed.getRegistryName()).getInteger("_tier")).stream().filter(hardware::isHardwareAdequate).findFirst().ifPresent(X -> {
                    apps.addWidget(new RectButtonWidget(162 + (index.get() % 4) * 25, 122 + (index.get() / 4) * 30, 20, 20, 2).setIcon(installed.getIcon()).setHoverText(installed.getUnlocalizedName()).setColors(0, TerminalTheme.COLOR_7.getColor(), 0));
                    index.getAndIncrement();
                });
            }
        });
        x += 25;
    }
    return this;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) Hardware(gregtech.api.terminal.hardware.Hardware) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 9 with RectButtonWidget

use of gregtech.api.terminal.gui.widgets.RectButtonWidget in project GregTech by GregTechCEu.

the class FluidStackConfigurator method init.

protected void init() {
    container = new DraggableScrollableWidgetGroup(0, 27, 116, 100);
    this.addWidget(container);
    this.addWidget(new RectButtonWidget(0, 15, 116, 10, 1).setIcon(new TextTexture("terminal.guide_editor.add_slot", -1)).setClickListener(cd -> {
        addSlot(container, new TankListWidget.FluidStackInfo(null, 0));
        updateValue();
    }).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()));
    tanks = new ArrayList<>();
    if (!config.get(name).isJsonNull()) {
        Gson gson = new Gson();
        for (JsonElement o : config.get(name).getAsJsonArray()) {
            addSlot(container, gson.fromJson(o, TankListWidget.FluidStackInfo.class));
        }
    }
}
Also used : TankListWidget(gregtech.common.terminal.app.guide.widget.TankListWidget) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) JsonElement(com.google.gson.JsonElement) TextTexture(gregtech.api.gui.resources.TextTexture) Gson(com.google.gson.Gson) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 10 with RectButtonWidget

use of gregtech.api.terminal.gui.widgets.RectButtonWidget 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);
}
Also used : IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) PhantomSlotWidget(gregtech.api.gui.widgets.PhantomSlotWidget) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) SingleItemStackHandler(gregtech.common.inventory.handlers.SingleItemStackHandler) TextTexture(gregtech.api.gui.resources.TextTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget)

Aggregations

RectButtonWidget (gregtech.api.terminal.gui.widgets.RectButtonWidget)13 TextTexture (gregtech.api.gui.resources.TextTexture)8 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)7 DraggableScrollableWidgetGroup (gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup)6 ImageWidget (gregtech.api.gui.widgets.ImageWidget)5 AbstractApplication (gregtech.api.terminal.app.AbstractApplication)5 JsonElement (com.google.gson.JsonElement)4 GuiTextures (gregtech.api.gui.GuiTextures)4 WidgetGroup (gregtech.api.gui.widgets.WidgetGroup)4 Gson (com.google.gson.Gson)3 IRenderContext (gregtech.api.gui.IRenderContext)3 gregtech.api.gui.widgets (gregtech.api.gui.widgets)3 LabelWidget (gregtech.api.gui.widgets.LabelWidget)3 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)3 java.util (java.util)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 GlStateManager (net.minecraft.client.renderer.GlStateManager)3 PacketBuffer (net.minecraft.network.PacketBuffer)3 JsonObject (com.google.gson.JsonObject)2 ColorRectTexture (gregtech.api.gui.resources.ColorRectTexture)2