Search in sources :

Example 1 with Button

use of mcjty.lib.gui.widgets.Button in project RFToolsDimensions by McJty.

the class GuiEssencePainter method initGui.

@Override
public void initGui() {
    super.initGui();
    extractButton = new Button(mc, this).setText("Extract").setLayoutHint(new PositionalLayout.PositionalHint(13, 164, 60, 16)).addButtonEvent(parent -> {
        extractDimlets();
    }).setTooltips("Extract the dimlets out of", "a realized dimension tab");
    storeButton = new Button(mc, this).setText("Store").setLayoutHint(new PositionalLayout.PositionalHint(13, 182, 60, 16)).addButtonEvent(parent -> {
        storeDimlets();
    }).setTooltips("Store dimlets in a", "empty dimension tab");
    nameField = new TextField(mc, this).addTextEvent((parent, newText) -> {
        storeName(newText);
    }).setLayoutHint(new PositionalLayout.PositionalHint(13, 200, 60, 16));
    validateField = new Label(mc, this).setText("Val");
    validateField.setTooltips("Hover here for errors...");
    validateField.setLayoutHint(new PositionalLayout.PositionalHint(35, 142, 38, 16));
    setNameFromDimensionTab();
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(extractButton).addChild(storeButton).addChild(nameField).addChild(validateField);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) Label(mcjty.lib.gui.widgets.Label) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) TextField(mcjty.lib.gui.widgets.TextField)

Example 2 with Button

use of mcjty.lib.gui.widgets.Button 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 3 with Button

use of mcjty.lib.gui.widgets.Button in project RFToolsControl by McJty.

the class GuiProgrammer method validateProgram.

private void validateProgram() {
    Panel panel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
    panel.setBounds(new Rectangle(60, 10, 200, 130));
    Window modalWindow = getWindowManager().createModalWindow(panel);
    WidgetList errorList = new WidgetList(mc, this);
    errorList.addSelectionEvent(new SelectionEvent() {

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

        @Override
        public void doubleClick(Widget parent, int index) {
            if (errorList.getSelected() != -1) {
                Widget<?> child = errorList.getChild(errorList.getSelected());
                GridPos pos = (GridPos) child.getUserObject();
                if (pos != null) {
                    window.setTextFocus(getHolder(pos.getX(), pos.getY()));
                }
            }
            getWindowManager().closeWindow(modalWindow);
        }
    });
    panel.addChild(errorList);
    panel.addChild(new Button(mc, this).addButtonEvent(w -> {
        getWindowManager().closeWindow(modalWindow);
    }).setText("Close"));
    ProgramCardInstance instance = makeGridInstance(false);
    List<Pair<GridPos, String>> errors = ProgramValidator.validate(instance);
    for (Pair<GridPos, String> entry : errors) {
        GridPos p = entry.getKey();
        errorList.addChild(new Label(mc, this).setColor(0xffff0000).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setText(entry.getValue()).setUserObject(p));
    }
}
Also used : Window(mcjty.lib.gui.Window) Label(mcjty.lib.gui.widgets.Label) Panel(mcjty.lib.gui.widgets.Panel) ProgramCardInstance(mcjty.rftoolscontrol.logic.grid.ProgramCardInstance) Button(mcjty.lib.gui.widgets.Button) GridPos(mcjty.rftoolscontrol.logic.grid.GridPos) SelectionEvent(mcjty.lib.gui.events.SelectionEvent) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) Pair(org.apache.commons.lang3.tuple.Pair)

Example 4 with Button

use of mcjty.lib.gui.widgets.Button in project RFToolsControl by McJty.

the class GuiProgrammer method openValueEditor.

private void openValueEditor(IIcon icon, IconHolder iconHolder, ParameterDescription parameter, TextField field, boolean constantOnly) {
    ParameterEditor editor = ParameterEditors.getEditor(parameter.getType());
    Panel editPanel;
    if (editor != null) {
        editPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setFilledRectThickness(1);
        Map<String, Object> data = icon.getData() == null ? Collections.emptyMap() : icon.getData();
        editor.build(mc, this, editPanel, o -> {
            icon.addData(parameter.getName(), o);
            field.setText(ParameterTypeTools.stringRepresentation(parameter.getType(), o));
        });
        editor.writeValue((ParameterValue) data.get(parameter.getName()));
        if (constantOnly) {
            editor.constantOnly();
        }
    } else {
        return;
    }
    Panel panel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
    panel.setBounds(new Rectangle(50, 25, 200, 60 + editor.getHeight()));
    Window modalWindow = getWindowManager().createModalWindow(panel);
    panel.addChild(new Label(mc, this).setText(StringUtils.capitalize(parameter.getName()) + ":"));
    panel.addChild(editPanel);
    panel.addChild(new Button(mc, this).addButtonEvent(w -> {
        getWindowManager().closeWindow(modalWindow);
        window.setTextFocus(iconHolder);
    }).setText("Close"));
    editor.initialFocus(modalWindow);
    editor.setOnClose(() -> window.setTextFocus(iconHolder));
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) ParameterEditor(mcjty.rftoolscontrol.logic.editors.ParameterEditor)

Example 5 with Button

use of mcjty.lib.gui.widgets.Button 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)

Aggregations

Button (mcjty.lib.gui.widgets.Button)30 Panel (mcjty.lib.gui.widgets.Panel)27 Window (mcjty.lib.gui.Window)24 Label (mcjty.lib.gui.widgets.Label)24 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)17 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)17 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)15 java.awt (java.awt)14 TextField (mcjty.lib.gui.widgets.TextField)14 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)13 ResourceLocation (net.minecraft.util.ResourceLocation)11 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)10 List (java.util.List)9 RFTools (mcjty.rftools.RFTools)9 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)8 Argument (mcjty.lib.network.Argument)8 RFToolsMessages (mcjty.rftools.network.RFToolsMessages)8 StyleConfig (mcjty.lib.base.StyleConfig)7 GenericEnergyStorageTileEntity (mcjty.lib.entity.GenericEnergyStorageTileEntity)7 IOException (java.io.IOException)6