Search in sources :

Example 66 with HorizontalLayout

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

the class GuiProgrammer method fillOpcodes.

private void fillOpcodes() {
    opcodeList.removeChildren();
    int x = 0;
    int y = 0;
    Panel childPanel = null;
    for (Opcode opcode : Opcodes.SORTED_OPCODES) {
        if (currentCategory != null) {
            if (!opcode.getCategories().contains(currentCategory)) {
                continue;
            }
        }
        String key = opcode.getId();
        if (childPanel == null) {
            childPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setVerticalMargin(1).setSpacing(1).setHorizontalMargin(0)).setDesiredHeight(ICONSIZE + 1);
            opcodeList.addChild(childPanel);
        }
        IconHolder holder = new IconHolder(mc, this) {

            @Override
            public List<String> getTooltips() {
                return getIconTooltip(getIcon());
            }
        }.setDesiredWidth(ICONSIZE).setDesiredHeight(ICONSIZE).setMakeCopy(true);
        holder.setIcon(ICONS.get(key).clone());
        childPanel.addChild(holder);
        x++;
        if (x >= 3) {
            y++;
            x = 0;
            childPanel = null;
        }
    }
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Opcode(mcjty.rftoolscontrol.api.code.Opcode) List(java.util.List) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 67 with HorizontalLayout

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

the class GuiCraftingStation method updateRequestList.

private void updateRequestList() {
    requestList.removeChildren();
    for (CraftingRequest request : fromServer_requests) {
        final ItemStack stack = request.getStack();
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredWidth(16);
        requestList.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));
                    }
                }
                return list;
            }
        }.setRenderItem(stack).setOffsetX(-1).setOffsetY(-1);
        panel.addChild(blockRender);
        boolean failed = request.getFailed() != -1;
        boolean ok = request.getOk() != -1;
        panel.addChild(new Label(mc, this).setColor(failed ? 0xffff3030 : (ok ? 0xff30ff30 : StyleConfig.colorTextNormal)).setText(failed ? "Failed!" : (ok ? "Ok" : "Wait (" + request.getTodo() + ")")));
    }
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) ITooltipFlag(net.minecraft.client.util.ITooltipFlag) Label(mcjty.lib.gui.widgets.Label) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 68 with HorizontalLayout

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

the class GuiNode method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout());
    channelField = new TextField(mc, this).setTooltips("Set the name of the network", "channel to connect too").addTextEvent((parent, newText) -> updateNode());
    channelField.setText(tileEntity.getChannelName());
    nodeNameField = new TextField(mc, this).setTooltips("Set the name of this node").addTextEvent((parent, newText) -> updateNode());
    nodeNameField.setText(tileEntity.getNodeName());
    Panel bottomPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(new Label(mc, this).setText("Channel:")).addChild(channelField).addChild(new Label(mc, this).setText("Node:")).addChild(nodeNameField);
    toplevel.addChild(bottomPanel);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, WIDTH, HEIGHT));
    window = new Window(this, toplevel);
}
Also used : EmptyContainer(mcjty.lib.container.EmptyContainer) GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) Window(mcjty.lib.gui.Window) java.awt(java.awt) RFToolsCtrlMessages(mcjty.rftoolscontrol.network.RFToolsCtrlMessages) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) TextField(mcjty.lib.gui.widgets.TextField) Argument(mcjty.lib.network.Argument) Panel(mcjty.lib.gui.widgets.Panel) RFToolsControl(mcjty.rftoolscontrol.RFToolsControl) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) Label(mcjty.lib.gui.widgets.Label) Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) Label(mcjty.lib.gui.widgets.Label) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) TextField(mcjty.lib.gui.widgets.TextField) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 69 with HorizontalLayout

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

the class GuiTools method askSomething.

public static void askSomething(Minecraft mc, Gui gui, WindowManager windowManager, int x, int y, String title, String initialValue, Consumer<String> callback) {
    Panel ask = new Panel(mc, gui).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
    ask.setBounds(new Rectangle(x, y, 100, 60));
    Window askWindow = windowManager.createModalWindow(ask);
    ask.addChild(new Label(mc, gui).setText(title));
    TextField input = new mcjty.lib.gui.widgets.TextField(mc, gui).addTextEnterEvent(((parent, newText) -> {
        windowManager.closeWindow(askWindow);
        callback.accept(newText);
    }));
    input.setText(initialValue);
    ask.addChild(input);
    Panel buttons = new Panel(mc, gui).setLayout(new HorizontalLayout()).setDesiredWidth(100).setDesiredHeight(18);
    buttons.addChild(new Button(mc, gui).setText("Ok").addButtonEvent((parent -> {
        windowManager.closeWindow(askWindow);
        callback.accept(input.getText());
    })));
    buttons.addChild(new Button(mc, gui).setText("Cancel").addButtonEvent((parent -> {
        windowManager.closeWindow(askWindow);
    })));
    ask.addChild(buttons);
}
Also used : Window(mcjty.lib.gui.Window) Window(mcjty.lib.gui.Window) java.awt(java.awt) Consumer(java.util.function.Consumer) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) TextField(mcjty.lib.gui.widgets.TextField) Gui(net.minecraft.client.gui.Gui) Panel(mcjty.lib.gui.widgets.Panel) Minecraft(net.minecraft.client.Minecraft) Button(mcjty.lib.gui.widgets.Button) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) Label(mcjty.lib.gui.widgets.Label) WindowManager(mcjty.lib.gui.WindowManager) Panel(mcjty.lib.gui.widgets.Panel) TextField(mcjty.lib.gui.widgets.TextField) Button(mcjty.lib.gui.widgets.Button) Label(mcjty.lib.gui.widgets.Label) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) TextField(mcjty.lib.gui.widgets.TextField) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 70 with HorizontalLayout

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

the class LongEditor method build.

@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
    Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
    field = new TextField(mc, gui).addTextEvent((parent, newText) -> callback.valueChanged(readValue())).addTextEnterEvent((parent, newText) -> closeWindow());
    constantPanel.addChild(field);
    hexMode = new ToggleButton(mc, gui).addButtonEvent(widget -> updateHex()).setCheckMarker(true).setText("Hex");
    constantPanel.addChild(hexMode);
    createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_LONG);
}
Also used : Window(mcjty.lib.gui.Window) ParameterType(mcjty.rftoolscontrol.api.parameters.ParameterType) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) TextField(mcjty.lib.gui.widgets.TextField) Gui(net.minecraft.client.gui.Gui) Panel(mcjty.lib.gui.widgets.Panel) ParameterValue(mcjty.rftoolscontrol.api.parameters.ParameterValue) Minecraft(net.minecraft.client.Minecraft) ToggleButton(mcjty.lib.gui.widgets.ToggleButton) Panel(mcjty.lib.gui.widgets.Panel) ToggleButton(mcjty.lib.gui.widgets.ToggleButton) TextField(mcjty.lib.gui.widgets.TextField) 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