Search in sources :

Example 11 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.

the class GuiProgrammer method setupGridPanel.

private Panel setupGridPanel() {
    Panel panel = new Panel(mc, this).setLayout(new PositionalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(5, 5, 246, 130));
    gridList = new WidgetList(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 236, 130)).setPropagateEventsToChildren(true).setInvisibleSelection(true).setDrawHorizontalLines(false).setRowheight(ICONSIZE + 1);
    Slider slider = new Slider(mc, this).setVertical().setScrollable(gridList).setLayoutHint(new PositionalLayout.PositionalHint(237, 0, 9, 130));
    for (int y = 0; y < GRID_HEIGHT; y++) {
        Panel rowPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(-1).setHorizontalMargin(0).setVerticalMargin(0));
        for (int x = 0; x < GRID_WIDTH; x++) {
            int finalX = x;
            int finalY = y;
            IconHolder holder = new IconHolder(mc, this) {

                @Override
                public List<String> getTooltips() {
                    return getGridIconTooltips(finalX, finalY);
                }
            }.setDesiredWidth(ICONSIZE + 2).setDesiredHeight(ICONSIZE + 2).setBorder(1).setBorderColor(0xff777777).setSelectable(true).setUserObject(new GridPos(finalX, finalY)).addIconHoverEvent(((iconHolder, iIcon, dx, dy) -> {
                handleConnectorHighlight(finalX, finalY, iIcon, dx, dy);
            })).addIconLeavesEvent(((parent, icon) -> {
                iconLeavesFromX = finalX;
                iconLeavesFromY = finalY;
                return true;
            })).addIconArrivesEvent(((parent, icon) -> {
                if (icon != null && !loading) {
                    handleNewIconOverlay(icon, finalX, finalY);
                }
                return true;
            })).addIconClickedEvent((parent, icon, dx, dy) -> {
                gridIconClicked(icon, finalX, finalY, dx, dy);
                return true;
            });
            rowPanel.addChild(holder);
        }
        gridList.addChild(rowPanel);
    }
    panel.addChild(gridList).addChild(slider);
    return panel;
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) ProgramCardInstance(mcjty.rftoolscontrol.logic.grid.ProgramCardInstance) GeneralConfiguration(mcjty.rftoolscontrol.config.GeneralConfiguration) OpcodeCategory(mcjty.rftoolscontrol.api.code.OpcodeCategory) Opcode(mcjty.rftoolscontrol.api.code.Opcode) ParameterDescription(mcjty.rftoolscontrol.api.parameters.ParameterDescription) ParameterEditors(mcjty.rftoolscontrol.logic.editors.ParameterEditors) Keyboard(org.lwjgl.input.Keyboard) StringUtils(org.apache.commons.lang3.StringUtils) StyleConfig(mcjty.lib.base.StyleConfig) Panel(mcjty.lib.gui.widgets.Panel) Pair(org.apache.commons.lang3.tuple.Pair) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) ParameterEditor(mcjty.rftoolscontrol.logic.editors.ParameterEditor) Clipboard(java.awt.datatransfer.Clipboard) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) ParameterTypeTools(mcjty.rftoolscontrol.logic.registry.ParameterTypeTools) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) List(java.util.List) Button(mcjty.lib.gui.widgets.Button) IIcon(mcjty.lib.gui.icons.IIcon) Connection(mcjty.rftoolscontrol.logic.Connection) TextField(mcjty.lib.gui.widgets.TextField) java.util(java.util) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) ParameterValue(mcjty.rftoolscontrol.api.parameters.ParameterValue) DataFlavor(java.awt.datatransfer.DataFlavor) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) OpcodeOutput(mcjty.rftoolscontrol.api.code.OpcodeOutput) Label(mcjty.lib.gui.widgets.Label) Window(mcjty.lib.gui.Window) GridInstance(mcjty.rftoolscontrol.logic.grid.GridInstance) ItemStack(net.minecraft.item.ItemStack) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) ProgramValidator(mcjty.rftoolscontrol.logic.compiled.ProgramValidator) GuiTools(mcjty.rftoolscontrol.gui.GuiTools) Logging(mcjty.lib.varia.Logging) ProgramCardItem(mcjty.rftoolscontrol.items.ProgramCardItem) StringSelection(java.awt.datatransfer.StringSelection) RFToolsControl(mcjty.rftoolscontrol.RFToolsControl) Parameter(mcjty.rftoolscontrol.api.parameters.Parameter) RFToolsCtrlMessages(mcjty.rftoolscontrol.network.RFToolsCtrlMessages) GridPos(mcjty.rftoolscontrol.logic.grid.GridPos) SelectionEvent(mcjty.lib.gui.events.SelectionEvent) Opcodes(mcjty.rftoolscontrol.logic.registry.Opcodes) TextFormatting(net.minecraft.util.text.TextFormatting) IOException(java.io.IOException) WindowManager(mcjty.lib.gui.WindowManager) java.awt(java.awt) Slot(net.minecraft.inventory.Slot) ResourceLocation(net.minecraft.util.ResourceLocation) ImageIcon(mcjty.lib.gui.icons.ImageIcon) ClickType(net.minecraft.inventory.ClickType) Panel(mcjty.lib.gui.widgets.Panel) GridPos(mcjty.rftoolscontrol.logic.grid.GridPos) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 12 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.

the class GuiProcessor method updateFluidList.

private void updateFluidList() {
    fluidList.removeChildren();
    for (int i = 0; i < fluidListMapping.length; i++) {
        fluidListMapping[i] = -1;
    }
    int setupMode = getSetupMode();
    int fluidAlloc = 0;
    if (setupMode != -1) {
        CardInfo cardInfo = tileEntity.getCardInfo(setupMode);
        fluidAlloc = cardInfo.getFluidAllocation();
    }
    fluidList.setPropagateEventsToChildren(setupMode == -1);
    int index = 0;
    for (int i = 0; i < fromServer_fluids.size(); i++) {
        PacketGetFluids.FluidEntry entry = fromServer_fluids.get(i);
        if (entry.isAllocated()) {
            fluidListMapping[fluidList.getChildCount()] = i;
            EnumFacing side = EnumFacing.values()[i / TANKS];
            String l = side.getName().substring(0, 1).toUpperCase() + (i % TANKS);
            Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredWidth(40);
            AbstractWidget<?> label;
            if (setupMode != -1) {
                boolean allocated = ((fluidAlloc >> i) & 1) != 0;
                int fill = allocated ? 0x7700ff00 : (tileEntity.isFluidAllocated(-1, i) ? 0x77660000 : 0x77444444);
                panel.setFilledBackground(fill);
                if (allocated) {
                    label = new Label(mc, this).setColor(0xffffffff).setText(String.valueOf(index)).setDesiredWidth(26).setUserObject("allowed");
                    index++;
                } else {
                    label = new Label(mc, this).setText("/").setDesiredWidth(26).setUserObject("allowed");
                }
            } else {
                label = new Label(mc, this).setText(l).setDesiredWidth(26).setUserObject("allowed");
            }
            label.setUserObject("allowed");
            panel.addChild(label);
            FluidStack fluidStack = entry.getFluidStack();
            if (fluidStack != null) {
                BlockRender fluid = new BlockRender(mc, this).setRenderItem(fluidStack);
                fluid.setTooltips(TextFormatting.GREEN + "Fluid: " + TextFormatting.WHITE + fluidStack.getLocalizedName(), TextFormatting.GREEN + "Amount: " + TextFormatting.WHITE + fluidStack.amount + "mb");
                fluid.setUserObject("allowed");
                panel.addChild(fluid);
            }
            panel.setUserObject("allowed");
            fluidList.addChild(panel);
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EnumFacing(net.minecraft.util.EnumFacing) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel)

Example 13 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.

the class GuiProcessor method updateVariableList.

private void updateVariableList() {
    variableList.removeChildren();
    int setupMode = getSetupMode();
    int varAlloc = 0;
    if (setupMode != -1) {
        CardInfo cardInfo = tileEntity.getCardInfo(setupMode);
        varAlloc = cardInfo.getVarAllocation();
    }
    variableList.setPropagateEventsToChildren(setupMode == -1);
    int index = 0;
    for (int i = 0; i < tileEntity.getMaxvars(); i++) {
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredWidth(40);
        if (setupMode != -1) {
            boolean allocated = ((varAlloc >> i) & 1) != 0;
            int fill = allocated ? 0x7700ff00 : (tileEntity.isVarAllocated(-1, i) ? 0x77660000 : 0x77444444);
            panel.setFilledBackground(fill);
            if (allocated) {
                panel.addChild(new Label(mc, this).setColor(0xffffffff).setText(String.valueOf(index)).setDesiredWidth(26).setUserObject("allowed"));
                index++;
            } else {
                panel.addChild(new Label(mc, this).setText("/").setDesiredWidth(26).setUserObject("allowed"));
            }
        } else {
            panel.addChild(new Label(mc, this).setText(String.valueOf(i)).setDesiredWidth(26).setUserObject("allowed"));
        }
        int finalI = i;
        panel.addChild(new Button(mc, this).addButtonEvent(w -> openValueEditor(finalI)).setText("...").setUserObject("allowed"));
        panel.setUserObject("allowed");
        variableList.addChild(panel);
    }
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) TextField(mcjty.lib.gui.widgets.TextField) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) ParameterEditors(mcjty.rftoolscontrol.logic.editors.ParameterEditors) TextSpecialKeyEvent(mcjty.lib.gui.events.TextSpecialKeyEvent) Label(mcjty.lib.gui.widgets.Label) ArrayList(java.util.ArrayList) Window(mcjty.lib.gui.Window) ParameterType(mcjty.rftoolscontrol.api.parameters.ParameterType) ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) GuiTools(mcjty.rftoolscontrol.gui.GuiTools) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) RFToolsControl(mcjty.rftoolscontrol.RFToolsControl) Parameter(mcjty.rftoolscontrol.api.parameters.Parameter) ParameterEditor(mcjty.rftoolscontrol.logic.editors.ParameterEditor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SelectionEvent(mcjty.lib.gui.events.SelectionEvent) GlStateManager(net.minecraft.client.renderer.GlStateManager) TextFormatting(net.minecraft.util.text.TextFormatting) GenericEnergyStorageTileEntity(mcjty.lib.entity.GenericEnergyStorageTileEntity) EnumFacing(net.minecraft.util.EnumFacing) ParameterTypeTools(mcjty.rftoolscontrol.logic.registry.ParameterTypeTools) IOException(java.io.IOException) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) WindowManager(mcjty.lib.gui.WindowManager) java.awt(java.awt) mcjty.rftoolscontrol.network(mcjty.rftoolscontrol.network) Argument(mcjty.lib.network.Argument) List(java.util.List) Button(mcjty.lib.gui.widgets.Button) Slot(net.minecraft.inventory.Slot) ResourceLocation(net.minecraft.util.ResourceLocation) Optional(java.util.Optional) TANKS(mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity.TANKS) RenderHelper(mcjty.lib.gui.RenderHelper) FluidStack(net.minecraftforge.fluids.FluidStack) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 14 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.

the class GuiCraftingStation method updateRecipeList.

private void updateRecipeList() {
    String filterText = searchField.getText().toLowerCase().trim();
    fromServer_craftables.sort((r1, r2) -> {
        return r1.getDisplayName().compareTo(r2.getDisplayName());
    });
    recipeList.removeChildren();
    Panel panel = null;
    int index = 0;
    for (ItemStack stack : fromServer_craftables) {
        String displayName = stack.getDisplayName();
        if ((!filterText.isEmpty()) && !displayName.toLowerCase().contains(filterText)) {
            continue;
        }
        if (panel == null || panel.getChildCount() >= 6) {
            panel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(3).setHorizontalMargin(1)).setDesiredHeight(16);
            recipeList.addChild(panel);
        }
        BlockRender blockRender = new BlockRender(mc, this) {

            @Override
            public List<String> getTooltips() {
                ITooltipFlag flag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
                List<String> list = stack.getTooltip(this.mc.player, flag);
                for (int i = 0; i < list.size(); ++i) {
                    if (i == 0) {
                        list.set(i, stack.getRarity().rarityColor + list.get(i));
                    } else {
                        list.set(i, TextFormatting.GRAY + list.get(i));
                    }
                }
                List<String> newlist = new ArrayList<>();
                newlist.add(TextFormatting.GREEN + "Click: " + TextFormatting.WHITE + "craft single");
                newlist.add(TextFormatting.GREEN + "Shift + click: " + TextFormatting.WHITE + "craft amount");
                newlist.add("");
                newlist.addAll(list);
                return newlist;
            }
        }.setRenderItem(stack).setHilightOnHover(true).setOffsetX(-1).setOffsetY(-1).setUserObject(index);
        index++;
        blockRender.addSelectionEvent(new BlockRenderEvent() {

            @Override
            public void select(Widget widget) {
                BlockRender br = (BlockRender) widget;
                Object item = br.getRenderItem();
                if (item != null) {
                    boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
                    Object index = br.getUserObject();
                    if (shift) {
                        askAmountToCraft(stack);
                    } else {
                        requestItem(stack, 1);
                    }
                }
            }

            @Override
            public void doubleClick(Widget widget) {
            }
        });
        panel.addChild(blockRender);
    }
}
Also used : ITooltipFlag(net.minecraft.client.util.ITooltipFlag) BlockRenderEvent(mcjty.lib.gui.events.BlockRenderEvent) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Example 15 with HorizontalLayout

use of mcjty.lib.gui.layout.HorizontalLayout in project RFToolsControl by McJty.

the class GuiRFToolsManual method initGui.

@Override
public void initGui() {
    super.initGui();
    int k = (this.width - this.xSize) / 2;
    int l = (this.height - this.ySize) / 2;
    textPage = new TextPage(RFToolsControl.instance, mc, this).setText(manualText).setArrowImage(iconGuiElements, 144, 0).setCraftingGridImage(iconGuiElements, 0, 192);
    prevButton = new Button(mc, this).setText("<").addButtonEvent(parent -> {
        textPage.prevPage();
        window.setTextFocus(textPage);
    });
    pageLabel = new Label(mc, this).setText("0 / 0");
    nextButton = new Button(mc, this).setText(">").addButtonEvent(parent -> {
        textPage.nextPage();
        window.setTextFocus(textPage);
    });
    Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredHeight(16).addChild(prevButton).addChild(pageLabel).addChild(nextButton);
    Widget<?> toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout()).addChild(textPage).addChild(buttonPanel);
    toplevel.setBounds(new Rectangle(k, l, xSize, ySize));
    window = new Window(this, toplevel);
    window.setTextFocus(textPage);
    if (locatePage != null) {
        textPage.gotoNode(locatePage);
        locatePage = null;
    }
}
Also used : mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) IOException(java.io.IOException) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) Label(mcjty.lib.gui.widgets.Label) Mouse(org.lwjgl.input.Mouse) Window(mcjty.lib.gui.Window) java.awt(java.awt) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) GuiScreen(net.minecraft.client.gui.GuiScreen) Panel(mcjty.lib.gui.widgets.Panel) Minecraft(net.minecraft.client.Minecraft) Button(mcjty.lib.gui.widgets.Button) ResourceLocation(net.minecraft.util.ResourceLocation) RFToolsControl(mcjty.rftoolscontrol.RFToolsControl) Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) Label(mcjty.lib.gui.widgets.Label) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Aggregations

HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)75 Panel (mcjty.lib.gui.widgets.Panel)55 Window (mcjty.lib.gui.Window)38 Label (mcjty.lib.gui.widgets.Label)36 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)32 TextField (mcjty.lib.gui.widgets.TextField)25 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)24 java.awt (java.awt)21 RFToolsMessages (mcjty.rftools.network.RFToolsMessages)21 List (java.util.List)20 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)20 Button (mcjty.lib.gui.widgets.Button)20 Argument (mcjty.lib.network.Argument)19 RFTools (mcjty.rftools.RFTools)19 BlockPos (net.minecraft.util.math.BlockPos)19 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)18 StyleConfig (mcjty.lib.base.StyleConfig)16 ResourceLocation (net.minecraft.util.ResourceLocation)15 Minecraft (net.minecraft.client.Minecraft)14 EmptyContainer (mcjty.lib.container.EmptyContainer)13