Search in sources :

Example 1 with CircleButtonWidget

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

the class TerminalDesktopWidget method installApplication.

public void installApplication(AbstractApplication application) {
    int r = 12;
    int index = appDiv.widgets.size();
    int x = this.getSize().width / 2 + (3 * r) * (index % rowCount - rowCount / 2);
    int y = (index / rowCount) * (3 * r) + 40;
    CircleButtonWidget button = new CircleButtonWidget(x, y).setColors(TerminalTheme.COLOR_B_2.getColor(), application.getThemeColor(), TerminalTheme.COLOR_B_2.getColor()).setIcon(application.getIcon()).setHoverText(application.getUnlocalizedName());
    button.setClickListener(clickData -> os.openApplication(application, clickData.isClient));
    appDiv.addWidget(button);
}
Also used : CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget)

Example 2 with CircleButtonWidget

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

the class TerminalMenuWidget method addComponent.

public void addComponent(IMenuComponent component) {
    WidgetGroup group = new WidgetGroup();
    int x = 15;
    int y = 40 + components.size() * 25;
    CircleButtonWidget button = new CircleButtonWidget(x, y, 10, 1, 16).setColors(0, 0xFFFFFFFF, 0).setHoverText(component.hoverText()).setIcon(component.buttonIcon());
    button.setClickListener(c -> {
        components.forEach(tuple -> {
            if (tuple.getFirst() instanceof Widget && tuple.getFirst() != component) {
                ((Widget) tuple.getFirst()).setActive(false);
                ((Widget) tuple.getFirst()).setVisible(false);
                ((CircleButtonWidget) tuple.getSecond().widgets.get(0)).setFill(0);
            }
        });
        if (component instanceof Widget) {
            Widget widget = (Widget) component;
            widget.setVisible(!widget.isVisible());
            widget.setActive(!widget.isActive());
            button.setFill(widget.isVisible() ? 0xFF94E2C1 : 0);
        }
        component.click(c);
    });
    group.addWidget(button);
    if (component instanceof Widget) {
        Widget widget = (Widget) component;
        widget.setSelfPosition(new Position(x + 20, 0));
        widget.setVisible(false);
        widget.setActive(false);
        group.addWidget(widget);
    }
    this.addWidget(group);
    components.add(new Tuple<>(component, group));
}
Also used : CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) Position(gregtech.api.util.Position) TerminalOSWidget(gregtech.api.terminal.os.TerminalOSWidget) Widget(gregtech.api.gui.Widget) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup)

Example 3 with CircleButtonWidget

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

the class RGNode method init.

private void init(RGContainer container) {
    this.container = container;
    textWidget = new SimpleTextWidget(9, -5, "", -1, () -> {
        if (head instanceof ItemStack) {
            return ((ItemStack) head).getDisplayName();
        } else if (head instanceof FluidStack) {
            return ((FluidStack) head).getLocalizedName();
        }
        return "terminal.recipe_chart.drag";
    }, true).setShadow(true);
    textWidget.setVisible(false);
    textWidget.setActive(false);
    this.addWidget(textWidget);
    inputsGroup = new WidgetGroup(0, 0, 0, 0);
    this.addWidget(inputsGroup);
    toolGroup = new WidgetGroup(0, 0, 0, 0);
    this.addWidget(toolGroup);
    toolGroup.addWidget(new CircleButtonWidget(-11, 9, 8, 1, 12).setColors(0, TerminalTheme.COLOR_7.getColor(), TerminalTheme.COLOR_3.getColor()).setIcon(GuiTextures.ICON_REMOVE).setHoverText("terminal.guide_editor.remove").setClickListener(cd -> remove()));
    toolGroup.addWidget(new CircleButtonWidget(-11, 29, 8, 1, 12).setColors(0, TerminalTheme.COLOR_7.getColor(), 0).setIcon(GuiTextures.ICON_VISIBLE).setHoverText("terminal.recipe_chart.visible").setClickListener(cd -> {
        textWidget.setActive(!textWidget.isActive());
        textWidget.setVisible(!textWidget.isVisible());
    }));
    toolGroup.addWidget(new CircleButtonWidget(9, 29, 8, 1, 12).setColors(0, TerminalTheme.COLOR_7.getColor(), 0).setIcon(GuiTextures.ICON_LOCATION).setHoverText("terminal.recipe_chart.jei").setClickListener(cd -> {
        if (GTJeiPlugin.jeiRuntime != null && head != null) {
            GTJeiPlugin.jeiRuntime.getRecipesGui().show(new Focus<>(IFocus.Mode.OUTPUT, head));
        }
    }));
    inputsGroup.setVisible(false);
    inputsGroup.setActive(false);
    toolGroup.setVisible(false);
    toolGroup.setActive(false);
    parentNodes = new HashMap<>();
    // important
    children = new LinkedHashMap<>();
}
Also used : SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget) java.util(java.util) IRenderContext(gregtech.api.gui.IRenderContext) Constants(net.minecraftforge.common.util.Constants) IDraggable(gregtech.api.terminal.gui.IDraggable) TerminalTheme(gregtech.api.terminal.os.TerminalTheme) TerminalDialogWidget(gregtech.api.terminal.os.TerminalDialogWidget) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) ItemStack(net.minecraft.item.ItemStack) NBTTagList(net.minecraft.nbt.NBTTagList) Widget(gregtech.api.gui.Widget) TankWidget(gregtech.api.gui.widgets.TankWidget) SimpleMachineMetaTileEntity(gregtech.api.metatileentity.SimpleMachineMetaTileEntity) ObfuscationReflectionHelper(net.minecraftforge.fml.common.ObfuscationReflectionHelper) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Fluid(net.minecraftforge.fluids.Fluid) Focus(mezz.jei.gui.Focus) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) IRecipeLayout(mezz.jei.api.gui.IRecipeLayout) SlotWidget(gregtech.api.gui.widgets.SlotWidget) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ModularUIContainer(gregtech.api.gui.impl.ModularUIContainer) Recipe(gregtech.api.recipes.Recipe) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) CapabilityFluidHandler(net.minecraftforge.fluids.capability.CapabilityFluidHandler) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) NBTBase(net.minecraft.nbt.NBTBase) NBTTagIntArray(net.minecraft.nbt.NBTTagIntArray) Collectors(java.util.stream.Collectors) GuiTextures(gregtech.api.gui.GuiTextures) IFocus(mezz.jei.api.recipe.IFocus) Position(gregtech.api.util.Position) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) IFluidHandlerItem(net.minecraftforge.fluids.capability.IFluidHandlerItem) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) FluidStack(net.minecraftforge.fluids.FluidStack) FluidTank(net.minecraftforge.fluids.FluidTank) IRecipeCategory(mezz.jei.api.recipe.IRecipeCategory) GTUtility(gregtech.api.util.GTUtility) GTJeiPlugin(gregtech.integration.jei.GTJeiPlugin) GTRecipeWrapper(gregtech.integration.jei.recipe.GTRecipeWrapper) RecipeLayout(mezz.jei.gui.recipes.RecipeLayout) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget) FluidStack(net.minecraftforge.fluids.FluidStack) Focus(mezz.jei.gui.Focus) IFocus(mezz.jei.api.recipe.IFocus) WidgetGroup(gregtech.api.gui.widgets.WidgetGroup) ItemStack(net.minecraft.item.ItemStack) SimpleTextWidget(gregtech.api.gui.widgets.SimpleTextWidget)

Example 4 with CircleButtonWidget

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

the class ThemeSettings method addColorButton.

private void addColorButton(ColorRectTexture texture, String name, int x, int y) {
    CircleButtonWidget buttonWidget = new CircleButtonWidget(x, y, 8, 1, 0).setFill(texture.getColor()).setStrokeAnima(-1).setHoverText(name);
    buttonWidget.setClickListener(cd -> TerminalDialogWidget.showColorDialog(os, name, color -> {
        if (color != null) {
            buttonWidget.setFill(color);
            texture.setColor(color);
            if (!TerminalTheme.saveConfig()) {
                TerminalDialogWidget.showInfoDialog(os, "terminal.component.error", "terminal.component.save_file.error").setClientSide().open();
            }
        }
    }, texture.color).setClientSide().open());
    addWidget(buttonWidget);
}
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) CircleButtonWidget(gregtech.api.terminal.gui.widgets.CircleButtonWidget)

Example 5 with CircleButtonWidget

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

Aggregations

CircleButtonWidget (gregtech.api.terminal.gui.widgets.CircleButtonWidget)7 Position (gregtech.api.util.Position)4 IRenderContext (gregtech.api.gui.IRenderContext)3 Widget (gregtech.api.gui.Widget)3 TerminalDialogWidget (gregtech.api.terminal.os.TerminalDialogWidget)3 TerminalTheme (gregtech.api.terminal.os.TerminalTheme)3 ItemStack (net.minecraft.item.ItemStack)3 GuiTextures (gregtech.api.gui.GuiTextures)2 ColorRectTexture (gregtech.api.gui.resources.ColorRectTexture)2 gregtech.api.gui.widgets (gregtech.api.gui.widgets)2 WidgetGroup (gregtech.api.gui.widgets.WidgetGroup)2 ColorWidget (gregtech.api.terminal.gui.widgets.ColorWidget)2 RectButtonWidget (gregtech.api.terminal.gui.widgets.RectButtonWidget)2 TerminalOSWidget (gregtech.api.terminal.os.TerminalOSWidget)2 Size (gregtech.api.util.Size)2 Consumer (java.util.function.Consumer)2 GlStateManager (net.minecraft.client.renderer.GlStateManager)2 PacketBuffer (net.minecraft.network.PacketBuffer)2 MachineItemBlock (gregtech.api.block.machines.MachineItemBlock)1 ModularUIContainer (gregtech.api.gui.impl.ModularUIContainer)1