Search in sources :

Example 1 with RectButtonWidget

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

the class BatteryManagerApp method addBatteryApps.

private void addBatteryApps() {
    AtomicInteger index = new AtomicInteger();
    for (AbstractApplication installed : getOs().installedApps) {
        TerminalRegistry.getAppHardwareDemand(installed.getRegistryName(), getOs().tabletNBT.getCompoundTag(installed.getRegistryName()).getInteger("_tier")).stream().filter(i -> i instanceof BatteryHardware).findFirst().ifPresent(battery -> {
            long charge = ((BatteryHardware) battery).getCharge();
            this.addWidget(new RectButtonWidget(180 + (index.get() % 5) * 30, 15 + (index.get() / 5) * 30, 20, 20, 2).setIcon(installed.getIcon()).setHoverText(I18n.format("terminal.battery.hover", I18n.format(installed.getUnlocalizedName()), charge)).setColors(0, TerminalTheme.COLOR_7.getColor(), 0));
            index.getAndIncrement();
        });
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) BatteryHardware(gregtech.common.terminal.hardware.BatteryHardware) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 2 with RectButtonWidget

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

the class StringConfigurator method init.

protected void init() {
    this.addWidget(new RectButtonWidget(76, 15, 40, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> updateString()).setIcon(new TextTexture("terminal.guide_editor.update", -1)));
    textFieldWidget = new TextFieldWidget(0, 15, 76, 20, TerminalTheme.COLOR_B_2, null, null).setMaxStringLength(Integer.MAX_VALUE).setValidator(s -> true);
    if (config.has(name) && config.get(name).isJsonPrimitive()) {
        textFieldWidget.setCurrentString(config.get(name).getAsString());
    }
    this.addWidget(textFieldWidget);
}
Also used : java.awt(java.awt) JsonObject(com.google.gson.JsonObject) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TextTexture(gregtech.api.gui.resources.TextTexture) TextFieldWidget(gregtech.api.gui.widgets.TextFieldWidget) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) TextTexture(gregtech.api.gui.resources.TextTexture) TextFieldWidget(gregtech.api.gui.widgets.TextFieldWidget) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 3 with RectButtonWidget

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

the class MultiBlockPreviewARApp method initApp.

@Override
public AbstractApplication initApp() {
    // 232 333
    int bW = 120;
    int bH = 120;
    addWidget(new ImageWidget(10, 10, 313, 212, new ColorRectTexture(TerminalTheme.COLOR_B_2.getColor())));
    addWidget(new ImageWidget(333 / 2, 20, 1, 222 - 40, new ColorRectTexture(-1)));
    addWidget(new LabelWidget(10 + 313 / 4, 35, "terminal.multiblock_ar.tier.0", -1).setXCentered(true).setYCentered(true));
    addWidget(new RectButtonWidget(10 + (313 / 2 - bW) / 2, 50, bW, bH).setIcon(TextureArea.fullImage("textures/gui/terminal/multiblock_ar/profile.png")).setColors(-1, 0xff00ff00, 0).setHoverText("terminal.ar.open").setClickListener(clickData -> openAR()));
    addWidget(new LabelWidget(333 / 2 + 313 / 4, 35, "terminal.multiblock_ar.tier.1", getAppTier() == 0 ? 0xffff0000 : -1).setXCentered(true).setYCentered(true));
    addWidget(new RectButtonWidget(333 / 2 + (313 / 2 - bW) / 2, 50, bW, bH).setIcon(this::drawBuilderButton).setColors(getAppTier() == 0 ? 0xffff0000 : -1, getAppTier() == 0 ? 0xffff0000 : 0xff00ff00, 0).setHoverText(getAppTier() > 0 ? "terminal.multiblock_ar.builder.hover" : "terminal.multiblock_ar.unlock").setClickListener(clickData -> buildMode()));
    return this;
}
Also used : MultiblockShapeInfo(gregtech.api.pattern.MultiblockShapeInfo) java.util(java.util) IRenderContext(gregtech.api.gui.IRenderContext) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) ImageWidget(gregtech.api.gui.widgets.ImageWidget) ConfigHolder(gregtech.common.ConfigHolder) MachineSceneWidget(gregtech.api.terminal.gui.widgets.MachineSceneWidget) ShaderTexture(gregtech.api.gui.resources.ShaderTexture) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) RenderUtil(gregtech.client.utils.RenderUtil) MultiblockControllerBase(gregtech.api.metatileentity.multiblock.MultiblockControllerBase) GL13(org.lwjgl.opengl.GL13) GL11(org.lwjgl.opengl.GL11) Shaders(gregtech.client.shader.Shaders) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) GLAllocation(net.minecraft.client.renderer.GLAllocation) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) GlStateManager(net.minecraft.client.renderer.GlStateManager) TextureMap(net.minecraft.client.renderer.texture.TextureMap) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) BlockPos(net.minecraft.util.math.BlockPos) LabelWidget(gregtech.api.gui.widgets.LabelWidget) MultiblockPreviewRenderer(gregtech.client.renderer.handler.MultiblockPreviewRenderer) GuiTextures(gregtech.api.gui.GuiTextures) ARApplication(gregtech.api.terminal.app.ARApplication) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) TextureArea(gregtech.api.gui.resources.TextureArea) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntity(net.minecraft.tileentity.TileEntity) LabelWidget(gregtech.api.gui.widgets.LabelWidget) ColorRectTexture(gregtech.api.gui.resources.ColorRectTexture) ImageWidget(gregtech.api.gui.widgets.ImageWidget) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 4 with RectButtonWidget

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

the class FluidStackConfigurator method addSlot.

private void addSlot(DraggableScrollableWidgetGroup container, TankListWidget.FluidStackInfo fluidStackInfo) {
    WidgetGroup group = new WidgetGroup(0, tanks.size() * 20, 116, 20);
    tanks.add(fluidStackInfo);
    group.addWidget(new PhantomFluidWidget(1, 1, 18, 18, null, null).setBackgroundTexture(TerminalTheme.COLOR_B_2).setFluidStackSupplier(fluidStackInfo::getInstance, true).setFluidStackUpdater(fluidStack -> {
        fluidStackInfo.update(fluidStack);
        updateValue();
    }, true));
    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 -> {
        fluidStackInfo.amount = Math.max(0, fluidStackInfo.amount - (data.isShiftClick ? data.isCtrlClick ? 1000 : 10 : data.isCtrlClick ? 100 : 1));
        updateValue();
    }).setHoverText("Shift -10|Ctrl -100|Shift+Ctrl -1000").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 -> {
        fluidStackInfo.amount = Math.max(0, fluidStackInfo.amount + (data.isShiftClick ? data.isCtrlClick ? 1000 : 10 : data.isCtrlClick ? 100 : 1));
        updateValue();
    }).setHoverText("Shift +10|Ctrl +100|Shift+Ctrl +1000").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(fluidStackInfo.amount), 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);
        tanks.remove(fluidStackInfo);
        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 : JsonObject(com.google.gson.JsonObject) TankListWidget(gregtech.common.terminal.app.guide.widget.TankListWidget) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TextTexture(gregtech.api.gui.resources.TextTexture) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) GuiTextures(gregtech.api.gui.GuiTextures) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) java.awt(java.awt) List(java.util.List) gregtech.api.gui.widgets(gregtech.api.gui.widgets) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget) Gson(com.google.gson.Gson) DraggableScrollableWidgetGroup(gregtech.api.terminal.gui.widgets.DraggableScrollableWidgetGroup) TextTexture(gregtech.api.gui.resources.TextTexture) RectButtonWidget(gregtech.api.terminal.gui.widgets.RectButtonWidget)

Example 5 with RectButtonWidget

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

the class NumberConfigurator method init.

protected void init() {
    int y = 15;
    this.addWidget(new RectButtonWidget(0, y, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> adjustTransferRate(data.isShiftClick ? -100 : -10)).setIcon(new TextTexture("-10", -1)));
    this.addWidget(new RectButtonWidget(96, y, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> adjustTransferRate(data.isShiftClick ? +100 : +10)).setIcon(new TextTexture("+10", -1)));
    this.addWidget(new RectButtonWidget(20, y, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> adjustTransferRate(data.isShiftClick ? -5 : -1)).setIcon(new TextTexture("-1", -1)));
    this.addWidget(new RectButtonWidget(76, y, 20, 20).setColors(TerminalTheme.COLOR_B_1.getColor(), TerminalTheme.COLOR_1.getColor(), TerminalTheme.COLOR_B_1.getColor()).setClickListener(data -> adjustTransferRate(data.isShiftClick ? +5 : +1)).setIcon(new TextTexture("+1", -1)));
    this.addWidget(new ImageWidget(40, y, 36, 20, TerminalTheme.COLOR_B_2));
    this.addWidget(new SimpleTextWidget(58, 25, "", 0xFFFFFF, () -> {
        JsonElement element = config.get(name);
        if (element.isJsonNull()) {
            return Integer.toString(defaultValue);
        }
        return element.getAsString();
    }, true));
}
Also used : JsonElement(com.google.gson.JsonElement) 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