Search in sources :

Example 6 with HorizontalLayout

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

the class GuiStorageScanner method makeStoragePanel.

private Panel makeStoragePanel(Panel energyPanel) {
    storageList = new WidgetList(mc, this).addSelectionEvent(new DefaultSelectionEvent() {

        @Override
        public void select(Widget parent, int index) {
            getInventoryOnServer();
        }

        @Override
        public void doubleClick(Widget parent, int index) {
            hilightSelectedContainer(index);
        }
    }).setPropagateEventsToChildren(true);
    Slider storageListSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(storageList);
    return new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(1).setHorizontalMargin(1)).setLayoutHint(new PositionalLayout.PositionalHint(3, 4, getStoragePanelWidth(), 86 + 54)).setDesiredHeight(86 + 54).addChild(energyPanel).addChild(storageList).addChild(storageListSlider);
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) DefaultSelectionEvent(mcjty.lib.gui.events.DefaultSelectionEvent) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 7 with HorizontalLayout

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

the class GuiStorageScanner method initGui.

@Override
public void initGui() {
    super.initGui();
    int maxEnergyStored = tileEntity.getMaxEnergyStored();
    energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setVertical().setDesiredWidth(10).setDesiredHeight(50).setMaxValue(maxEnergyStored).setShowText(false);
    energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
    openViewButton = new ToggleButton(mc, this).setCheckMarker(false).setText("V").setTooltips("Toggle wide storage list");
    openViewButton.setPressed(tileEntity.isOpenWideView());
    openViewButton.addButtonEvent(widget -> toggleView());
    upButton = new Button(mc, this).setText("U").setTooltips("Move inventory up").addButtonEvent(widget -> moveUp());
    topButton = new Button(mc, this).setText("T").setTooltips("Move inventory to the top").addButtonEvent(widget -> moveTop());
    downButton = new Button(mc, this).setText("D").setTooltips("Move inventory down").addButtonEvent(widget -> moveDown());
    bottomButton = new Button(mc, this).setText("B").setTooltips("Move inventory to the bottom").addButtonEvent(widget -> moveBottom());
    removeButton = new Button(mc, this).setText("R").setTooltips("Remove inventory from list").addButtonEvent(widget -> removeFromList());
    Panel energyPanel = new Panel(mc, this).setLayout(new VerticalLayout().setVerticalMargin(0).setSpacing(1)).setDesiredWidth(10);
    energyPanel.addChild(openViewButton).addChild(energyBar).addChild(topButton).addChild(upButton).addChild(downButton).addChild(bottomButton).addChild(new Label(mc, this).setText(" ")).addChild(removeButton);
    exportToStarred = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(12, 223, 13, 13)).addChoiceEvent((parent, newChoice) -> changeExportMode());
    exportToStarred.addChoice("No", "Export to current container", guielements, 131, 19);
    exportToStarred.addChoice("Yes", "Export to first routable container", guielements, 115, 19);
    storagePanel = makeStoragePanel(energyPanel);
    itemPanel = makeItemPanel();
    Button scanButton = new Button(mc, this).setText("Scan").setDesiredWidth(50).setDesiredHeight(14).addButtonEvent(parent -> RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new InventoriesInfoPacketServer(tileEntity.getDimension(), tileEntity.getStorageScannerPos(), true))));
    if (RFTools.instance.xnet) {
        if (StorageScannerConfiguration.xnetRequired) {
            scanButton.setTooltips("Do a scan of all", "storage units connected", "with an active XNet channel");
        } else {
            scanButton.setTooltips("Do a scan of all", "storage units in radius", "Use 'xnet' radius to", "restrict to XNet only");
        }
    } else {
        scanButton.setTooltips("Do a scan of all", "storage units in radius");
    }
    radiusLabel = new ScrollableLabel(mc, this).addValueEvent((parent, newValue) -> changeRadius(newValue)).setRealMinimum(RFTools.instance.xnet ? 0 : 1).setRealMaximum(20);
    radiusLabel.setRealValue(tileEntity.getRadius());
    visibleRadiusLabel = new Label(mc, this);
    visibleRadiusLabel.setDesiredWidth(40);
    searchField = new TextField(mc, this).addTextEvent((parent, newText) -> {
        storageList.clearHilightedRows();
        fromServer_foundInventories.clear();
        startSearch(newText);
    });
    Panel searchPanel = new Panel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 142, 256 - 11, 18)).setLayout(new HorizontalLayout()).setDesiredHeight(18).addChild(new Label(mc, this).setText("Search:")).addChild(searchField);
    Slider radiusSlider = new Slider(mc, this).setHorizontal().setTooltips("Radius of scan").setMinimumKnobSize(12).setDesiredHeight(14).setScrollable(radiusLabel);
    Panel scanPanel = new Panel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 162, 74, 54)).setFilledRectThickness(-2).setFilledBackground(StyleConfig.colorListBackground).setLayout(new VerticalLayout().setVerticalMargin(6).setSpacing(1)).addChild(scanButton);
    if (!(RFTools.instance.xnet && StorageScannerConfiguration.xnetRequired)) {
        scanPanel.addChild(radiusSlider);
    }
    scanPanel.addChild(visibleRadiusLabel);
    if (tileEntity.isDummy()) {
        scanButton.setEnabled(false);
        radiusLabel.setVisible(false);
        radiusSlider.setVisible(false);
    }
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(storagePanel).addChild(itemPanel).addChild(searchPanel).addChild(scanPanel).addChild(exportToStarred);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
    Keyboard.enableRepeatEvents(true);
    fromServer_foundInventories.clear();
    fromServer_inventory.clear();
    if (tileEntity.isDummy()) {
        fromServer_inventories.clear();
    } else {
        tileEntity.requestRfFromServer(RFTools.MODID);
    }
    BlockPos pos = tileEntity.getCraftingGridContainerPos();
    craftingGrid.initGui(modBase, network, mc, this, pos, tileEntity.getCraftingGridProvider(), guiLeft, guiTop, xSize, ySize);
    sendServerCommand(RFTools.MODID, CommandHandler.CMD_REQUEST_GRID_SYNC, Arguments.builder().value(pos).build());
    if (StorageScannerConfiguration.hilightStarredOnGuiOpen) {
        storageList.setSelected(0);
    }
    init = true;
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) BlockRenderEvent(mcjty.lib.gui.events.BlockRenderEvent) TextField(mcjty.lib.gui.widgets.TextField) java.util(java.util) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) Keyboard(org.lwjgl.input.Keyboard) Label(mcjty.lib.gui.widgets.Label) Arguments(mcjty.lib.network.Arguments) StyleConfig(mcjty.lib.base.StyleConfig) Window(mcjty.lib.gui.Window) BlockPosTools(mcjty.lib.varia.BlockPosTools) ItemStack(net.minecraft.item.ItemStack) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) DefaultSelectionEvent(mcjty.lib.gui.events.DefaultSelectionEvent) Panel(mcjty.lib.gui.widgets.Panel) MutablePair(org.apache.commons.lang3.tuple.MutablePair) Pair(org.apache.commons.lang3.tuple.Pair) Logging(mcjty.lib.varia.Logging) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) PacketGetInfoFromServer(mcjty.lib.network.clientinfo.PacketGetInfoFromServer) RFTools(mcjty.rftools.RFTools) Predicate(java.util.function.Predicate) GhostOutputSlot(mcjty.lib.container.GhostOutputSlot) TextFormatting(net.minecraft.util.text.TextFormatting) GenericEnergyStorageTileEntity(mcjty.lib.entity.GenericEnergyStorageTileEntity) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) Mouse(org.lwjgl.input.Mouse) java.awt(java.awt) 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) CommandHandler(mcjty.rftools.CommandHandler) GuiCraftingGrid(mcjty.rftools.craftinggrid.GuiCraftingGrid) Window(mcjty.lib.gui.Window) Label(mcjty.lib.gui.widgets.Label) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) PacketGetInfoFromServer(mcjty.lib.network.clientinfo.PacketGetInfoFromServer) Button(mcjty.lib.gui.widgets.Button) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) TextField(mcjty.lib.gui.widgets.TextField) BlockPos(net.minecraft.util.math.BlockPos)

Example 8 with HorizontalLayout

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

the class StringEditor 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_STRING);
}
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 9 with HorizontalLayout

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

the class VectorEditor method build.

@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
    Panel constantPanel = new Panel(mc, gui).setLayout(new HorizontalLayout());
    constantPanel.addChild(new Label(mc, gui).setText("No constant editor"));
    createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_VECTOR);
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 10 with HorizontalLayout

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

the class GuiRouter method makeChannelLine.

private Panel makeChannelLine(ControllerChannelClientInfo channel, boolean local) {
    String name = channel.getChannelName();
    String publishedName = channel.getPublishedName();
    BlockPos controllerPos = channel.getPos();
    IChannelType type = channel.getChannelType();
    int index = channel.getIndex();
    Panel panel = new Panel(mc, this).setLayout(new PositionalLayout()).setDesiredHeight(30);
    Panel panel1 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 160, 13));
    panel1.addChild(new Label<>(mc, this).setText("Ch").setColor(0xff2244aa));
    panel1.addChild(new Label<>(mc, this).setText(name));
    panel1.addChild(new Label<>(mc, this).setText(">").setColor(0xff2244aa));
    if (local) {
        TextField pubName = new TextField(mc, this).setText(publishedName).setDesiredWidth(50).setDesiredHeight(13).addTextEvent((parent, newText) -> updatePublish(controllerPos, index, newText));
        panel1.addChild(pubName);
    } else {
        panel1.addChild(new Label<>(mc, this).setText(publishedName).setColor(0xff33ff00));
    }
    Panel panel2 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 13, 160, 13));
    panel2.addChild(new Label<>(mc, this).setText("Pos").setColor(0xff2244aa));
    panel2.addChild(new Label<>(mc, this).setText(BlockPosTools.toString(controllerPos)));
    Panel panel3 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 26, 160, 13));
    panel3.addChild(new Label<>(mc, this).setText("Index").setColor(0xff2244aa));
    panel3.addChild(new Label<>(mc, this).setText(index + " (" + type.getName() + ")"));
    panel.addChild(panel1).addChild(panel2).addChild(panel3);
    return panel;
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) TextField(mcjty.lib.gui.widgets.TextField) BlockPos(net.minecraft.util.math.BlockPos) IChannelType(mcjty.xnet.api.channels.IChannelType) 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