Search in sources :

Example 71 with HorizontalLayout

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

the class TupleEditor method build.

@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
    Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
    fieldX = new TextField(mc, gui).addTextEvent((parent, newText) -> callback.valueChanged(readValue())).addTextEnterEvent((parent, newText) -> closeWindow());
    fieldY = new TextField(mc, gui).addTextEvent((parent, newText) -> callback.valueChanged(readValue())).addTextEnterEvent((parent, newText) -> closeWindow());
    constantPanel.addChild(fieldX).addChild(fieldY);
    createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_TUPLE);
}
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) Tuple(mcjty.rftoolscontrol.api.parameters.Tuple) Minecraft(net.minecraft.client.Minecraft) Panel(mcjty.lib.gui.widgets.Panel) TextField(mcjty.lib.gui.widgets.TextField) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 72 with HorizontalLayout

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

the class FloatEditor 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);
    createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_FLOAT);
}
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) Panel(mcjty.lib.gui.widgets.Panel) TextField(mcjty.lib.gui.widgets.TextField) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 73 with HorizontalLayout

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

the class ItemEditor method build.

@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
    Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
    Label<?> label = new Label(mc, gui).setText("Drop item:");
    constantPanel.addChild(label);
    blockRender = new BlockRender(mc, gui).setDesiredWidth(18 + 100).setDesiredHeight(18).setFilledRectThickness(1).setFilledBackground(0xff555555).setShowLabel(true);
    constantPanel.addChild(blockRender);
    blockRender.addSelectionEvent(new BlockRenderEvent() {

        @Override
        public void select(Widget widget) {
            ItemStack holding = Minecraft.getMinecraft().player.inventory.getItemStack();
            if (holding.isEmpty()) {
                blockRender.setRenderItem(null);
            } else {
                ItemStack copy = holding.copy();
                copy.setCount(1);
                blockRender.setRenderItem(copy);
            }
            callback.valueChanged(readValue());
        }

        @Override
        public void doubleClick(Widget widget) {
        }
    });
    createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_ITEM);
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Label(mcjty.lib.gui.widgets.Label) Widget(mcjty.lib.gui.widgets.Widget) BlockRenderEvent(mcjty.lib.gui.events.BlockRenderEvent) ItemStack(net.minecraft.item.ItemStack) BlockRender(mcjty.lib.gui.widgets.BlockRender) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 74 with HorizontalLayout

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

the class GuiController method populateList.

private void populateList() {
    if (!listsReady()) {
        return;
    }
    if (!needsRefresh) {
        return;
    }
    needsRefresh = false;
    connectorList.removeChildren();
    int sel = connectorList.getSelected();
    BlockPos prevPos = null;
    String selectedText = searchBar.getText().trim().toLowerCase();
    for (ConnectedBlockClientInfo connectedBlock : fromServer_connectedBlocks) {
        SidedPos sidedPos = connectedBlock.getPos();
        BlockPos coordinate = sidedPos.getPos();
        String name = connectedBlock.getName();
        String blockUnlocName = connectedBlock.getBlockUnlocName();
        String blockName = I18n.format(blockUnlocName).trim();
        int color = StyleConfig.colorTextInListNormal;
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0));
        if (!selectedText.isEmpty()) {
            if (blockName.toLowerCase().contains(selectedText)) {
                panel.setFilledBackground(0xffddeeaa);
            }
        }
        BlockRender br;
        if (coordinate.equals(prevPos)) {
            br = new BlockRender(mc, this);
        } else {
            br = new BlockRender(mc, this).setRenderItem(connectedBlock.getConnectedBlock());
            prevPos = coordinate;
        }
        br.setUserObject("block");
        panel.addChild(br);
        if (!name.isEmpty()) {
            br.setTooltips(TextFormatting.GREEN + "Connector: " + TextFormatting.WHITE + name, TextFormatting.GREEN + "Block: " + TextFormatting.WHITE + blockName, TextFormatting.GREEN + "Position: " + TextFormatting.WHITE + BlockPosTools.toString(coordinate), TextFormatting.WHITE + "(doubleclick to highlight)");
        } else {
            br.setTooltips(TextFormatting.GREEN + "Block: " + TextFormatting.WHITE + blockName, TextFormatting.GREEN + "Position: " + TextFormatting.WHITE + BlockPosTools.toString(coordinate), TextFormatting.WHITE + "(doubleclick to highlight)");
        }
        panel.addChild(new Label(mc, this).setText(sidedPos.getSide().getName().substring(0, 1).toUpperCase()).setColor(color).setDesiredWidth(18));
        for (int i = 0; i < MAX_CHANNELS; i++) {
            Button but = new Button(mc, this).setDesiredWidth(14);
            ChannelClientInfo info = fromServer_channels.get(i);
            if (info != null) {
                ConnectorClientInfo clientInfo = findClientInfo(info, sidedPos);
                if (clientInfo != null) {
                    IndicatorIcon icon = clientInfo.getConnectorSettings().getIndicatorIcon();
                    if (icon != null) {
                        but.setImage(icon.getImage(), icon.getU(), icon.getV(), icon.getIw(), icon.getIh());
                    }
                    String indicator = clientInfo.getConnectorSettings().getIndicator();
                    but.setText(indicator != null ? indicator : "");
                }
            }
            int finalI = i;
            but.addButtonEvent(parent -> {
                selectConnectorEditor(sidedPos, finalI);
            });
            panel.addChild(but);
        }
        connectorList.addChild(panel);
    }
    connectorList.setSelected(sel);
}
Also used : Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) ConnectedBlockClientInfo(mcjty.xnet.clientinfo.ConnectedBlockClientInfo) ChannelClientInfo(mcjty.xnet.clientinfo.ChannelClientInfo) SidedPos(mcjty.xnet.api.keys.SidedPos) Button(mcjty.lib.gui.widgets.Button) BlockPos(net.minecraft.util.math.BlockPos) IndicatorIcon(mcjty.xnet.api.gui.IndicatorIcon) ConnectorClientInfo(mcjty.xnet.clientinfo.ConnectorClientInfo)

Example 75 with HorizontalLayout

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

the class GuiController method initChannelSelectionPanel.

private Panel initChannelSelectionPanel() {
    Panel channelSelectionPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(41, 1, 124, 24));
    for (int i = 0; i < MAX_CHANNELS; i++) {
        String channel = String.valueOf(i + 1);
        channelButtons[i] = new ToggleButton(mc, this).setDesiredWidth(14).setText(channel).setTooltips("Edit channel " + channel);
        int finalI = i;
        channelButtons[i].addButtonEvent(parent -> {
            selectChannelEditor(finalI);
        });
        channelSelectionPanel.addChild(channelButtons[i]);
    }
    return channelSelectionPanel;
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) 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