Search in sources :

Example 21 with Button

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

the class GuiSequencer method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout());
    initGuiGrid(toplevel);
    Button clearButton = new Button(mc, this).setText("Clear").setTooltips("Clear the grid").setDesiredHeight(13).setDesiredWidth(38).addButtonEvent(parent -> fillGrid());
    Button flipButton = new Button(mc, this).setText("Flip").setTooltips("Invert all values in the grid").setDesiredHeight(13).setDesiredWidth(34).addButtonEvent(parent -> flipGrid());
    Label endLabel = new Label(mc, this).setText("End on:");
    ImageChoiceLabel choiceLabel = new ImageChoiceLabel(mc, this).addChoiceEvent((parent, newChoice) -> setEndState(newChoice)).setDesiredHeight(11).addChoice("0", "Disabled", iconGuiElements, 160, 0).addChoice("1", "Enabled", iconGuiElements, 176, 0);
    choiceLabel.setCurrentChoice(tileEntity.getEndState() ? 1 : 0);
    Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(clearButton).addChild(flipButton).addChild(endLabel).addChild(choiceLabel);
    toplevel.addChild(buttonPanel);
    initGuiMode();
    Label speedLabel = new Label(mc, this).setText("Delay:");
    speedField = new TextField(mc, this).addTextEvent((parent, newText) -> setDelay());
    int delay = tileEntity.getDelay();
    if (delay <= 0) {
        delay = 1;
    }
    speedField.setText(String.valueOf(delay));
    Panel bottomPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(mode).addChild(speedLabel).addChild(speedField);
    toplevel.addChild(bottomPanel);
    Label countLabel = new Label(mc, this).setText("Sequence length:");
    countField = new TextField(mc, this).addTextEvent((parent, newText) -> setCount());
    int count = tileEntity.getStepCount();
    if (count < 1 || count > 64) {
        count = 64;
    }
    countField.setText(String.valueOf(count));
    Panel countPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(countLabel).addChild(countField);
    toplevel.addChild(countPanel);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, SEQUENCER_WIDTH, SEQUENCER_HEIGHT));
    window = new Window(this, toplevel);
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) TextField(mcjty.lib.gui.widgets.TextField) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) Label(mcjty.lib.gui.widgets.Label) ArrayList(java.util.ArrayList) EmptyContainer(mcjty.lib.container.EmptyContainer) Window(mcjty.lib.gui.Window) java.awt(java.awt) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Argument(mcjty.lib.network.Argument) List(java.util.List) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) ResourceLocation(net.minecraft.util.ResourceLocation) RFTools(mcjty.rftools.RFTools) 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) TextField(mcjty.lib.gui.widgets.TextField) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 22 with Button

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

the class GuiShield method initGui.

@Override
public void initGui() {
    super.initGui();
    int maxEnergyStored = tileEntity.getMaxEnergyStored();
    energyBar = new EnergyBar(mc, this).setVertical().setMaxValue(maxEnergyStored).setLayoutHint(new PositionalLayout.PositionalHint(12, 141, 10, 76)).setShowText(false);
    energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
    initVisibilityMode();
    initActionOptions();
    initTypeOptions();
    initRedstoneMode();
    initDamageType();
    filterList = new WidgetList(mc, this).setDesiredHeight(120).addSelectionEvent(new DefaultSelectionEvent() {

        @Override
        public void select(Widget parent, int index) {
            selectFilter();
        }
    });
    Slider filterSlider = new Slider(mc, this).setVertical().setScrollable(filterList).setDesiredWidth(11).setDesiredHeight(120);
    Panel filterPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(1).setHorizontalMargin(3)).setLayoutHint(new PositionalLayout.PositionalHint(12, 10, 154, 124)).addChild(filterList).addChild(filterSlider).setFilledBackground(0xff9e9e9e);
    Button applyCamo = new Button(mc, this).setText("Set").setTooltips("Set the camouflage block").setLayoutHint(new PositionalLayout.PositionalHint(51, 142, 28, 16)).addButtonEvent(parent -> applyCamoToShield());
    // applyCamo.setEnabled(false);
    // applyCamo.setTooltips("Not implemented yet");   // @todo
    colorSelector = new ColorChoiceLabel(mc, this).setTooltips("Color for the shield").setLayoutHint(new PositionalLayout.PositionalHint(31, 177, 48, 16));
    colorSelector.addColors(0x96ffc8);
    for (EnumDyeColor color : EnumDyeColor.values()) {
        colorSelector.addColors(color.getColorValue());
    }
    colorSelector.setCurrentColor(tileEntity.getShieldColor());
    colorSelector.addChoiceEvent((parent, newColor) -> sendServerCommand(RFToolsMessages.INSTANCE, ShieldTEBase.CMD_SETCOLOR, new Argument("color", newColor)));
    player = new TextField(mc, this).setTooltips("Optional player name").setLayoutHint(new PositionalLayout.PositionalHint(170, 44, 80, 14));
    addFilter = new Button(mc, this).setText("Add").setTooltips("Add selected filter").setLayoutHint(new PositionalLayout.PositionalHint(4, 6, 36, 14)).addButtonEvent(parent -> addNewFilter());
    delFilter = new Button(mc, this).setText("Del").setTooltips("Delete selected filter").setLayoutHint(new PositionalLayout.PositionalHint(39, 6, 36, 14)).addButtonEvent(parent -> removeSelectedFilter());
    upFilter = new Button(mc, this).setText("Up").setTooltips("Move filter up").setLayoutHint(new PositionalLayout.PositionalHint(4, 22, 36, 14)).addButtonEvent(parent -> moveFilterUp());
    downFilter = new Button(mc, this).setText("Down").setTooltips("Move filter down").setLayoutHint(new PositionalLayout.PositionalHint(39, 22, 36, 14)).addButtonEvent(parent -> moveFilterDown());
    Panel controlPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(170, 58, 80, 43)).addChild(addFilter).addChild(delFilter).addChild(upFilter).addChild(downFilter).setFilledRectThickness(-2).setFilledBackground(StyleConfig.colorListBackground);
    Label lootingBonus = new Label(mc, this).setHorizontalAlignment(HorizontalAlignment.ALIGN_RIGHT).setText("Looting:");
    lootingBonus.setTooltips("Insert dimensional shards", "for looting bonus").setLayoutHint(new PositionalLayout.PositionalHint(160, 118, 60, 18));
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(energyBar).addChild(visibilityOptions).addChild(applyCamo).addChild(redstoneMode).addChild(filterPanel).addChild(actionOptions).addChild(typeOptions).addChild(player).addChild(controlPanel).addChild(damageType).addChild(colorSelector).addChild(lootingBonus);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
    listDirty = 0;
    requestFilters();
    tileEntity.requestRfFromServer(RFTools.MODID);
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) TextField(mcjty.lib.gui.widgets.TextField) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) Label(mcjty.lib.gui.widgets.Label) ArrayList(java.util.ArrayList) StyleConfig(mcjty.lib.base.StyleConfig) Window(mcjty.lib.gui.Window) ItemStack(net.minecraft.item.ItemStack) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) DefaultSelectionEvent(mcjty.lib.gui.events.DefaultSelectionEvent) mcjty.rftools.blocks.shield.filters(mcjty.rftools.blocks.shield.filters) Panel(mcjty.lib.gui.widgets.Panel) Block(net.minecraft.block.Block) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) RFTools(mcjty.rftools.RFTools) GenericEnergyStorageTileEntity(mcjty.lib.entity.GenericEnergyStorageTileEntity) RedstoneMode(mcjty.lib.varia.RedstoneMode) java.awt(java.awt) Argument(mcjty.lib.network.Argument) List(java.util.List) EnumDyeColor(net.minecraft.item.EnumDyeColor) Button(mcjty.lib.gui.widgets.Button) ResourceLocation(net.minecraft.util.ResourceLocation) Window(mcjty.lib.gui.Window) Argument(mcjty.lib.network.Argument) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) EnumDyeColor(net.minecraft.item.EnumDyeColor) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) TextField(mcjty.lib.gui.widgets.TextField) DefaultSelectionEvent(mcjty.lib.gui.events.DefaultSelectionEvent)

Example 23 with Button

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

the class GuiXNetManual 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(XNet.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);
    Panel 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) XNet(mcjty.xnet.XNet) java.awt(java.awt) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) GuiScreen(net.minecraft.client.gui.GuiScreen) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) ResourceLocation(net.minecraft.util.ResourceLocation) 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)

Example 24 with Button

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

the class GuiProgrammer method createValuePanel.

private Panel createValuePanel(ParameterDescription parameter, IIcon icon, IconHolder iconHolder, String tempDefault, boolean constantOnly) {
    Label<?> label = (Label<?>) new Label(mc, this).setText(StringUtils.capitalize(parameter.getName()) + ":").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredHeight(13).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 53, 13));
    List<String> description = new ArrayList<>(parameter.getDescription());
    if (parameter.isOptional()) {
        description.set(description.size() - 1, description.get(description.size() - 1) + TextFormatting.GOLD + " [Optional]");
    }
    if (tempDefault != null && !tempDefault.isEmpty()) {
        description.add(TextFormatting.BLUE + tempDefault);
    }
    String[] tooltips = description.toArray(new String[description.size()]);
    TextField field = new TextField(mc, this).setText(tempDefault).setTooltips(tooltips).setDesiredHeight(13).setEditable(false).setLayoutHint(new PositionalLayout.PositionalHint(0, 12, 68, 13));
    Button button = new Button(mc, this).setText("...").setDesiredHeight(13).setTooltips(tooltips).addButtonEvent(w -> openValueEditor(icon, iconHolder, parameter, field, constantOnly)).setLayoutHint(new PositionalLayout.PositionalHint(58, 0, 11, 13));
    return new Panel(mc, this).setLayout(new PositionalLayout()).addChild(label).addChild(field).addChild(button).setDesiredWidth(68);
}
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) Label(mcjty.lib.gui.widgets.Label) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) TextField(mcjty.lib.gui.widgets.TextField)

Example 25 with Button

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

the class GuiProcessor method openValueEditor.

private void openValueEditor(int varIdx) {
    if (fromServer_vars == null || varIdx > fromServer_vars.size()) {
        return;
    }
    if (fromServer_vars.get(varIdx) == null) {
        GuiTools.showMessage(mc, this, getWindowManager(), 50, 50, "Variable is not defined!");
        return;
    }
    Parameter parameter = fromServer_vars.get(varIdx);
    if (parameter == null) {
        GuiTools.showMessage(mc, this, getWindowManager(), 50, 50, "Variable is not defined!");
        return;
    }
    ParameterType type = parameter.getParameterType();
    ParameterEditor editor = ParameterEditors.getEditor(type);
    Panel editPanel;
    if (editor != null) {
        editPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setFilledRectThickness(1);
        editor.build(mc, this, editPanel, o -> {
            NBTTagCompound tag = new NBTTagCompound();
            ParameterTypeTools.writeToNBT(tag, type, o);
            RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketVariableToServer(tileEntity.getPos(), varIdx, tag));
        });
        editor.writeValue(parameter.getParameterValue());
        editor.constantOnly();
    } else {
        return;
    }
    Panel panel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
    panel.setBounds(new Rectangle(50, 50, 200, 60 + editor.getHeight()));
    Window modalWindow = getWindowManager().createModalWindow(panel);
    panel.addChild(new Label(mc, this).setText("Var " + varIdx + ":"));
    panel.addChild(editPanel);
    panel.addChild(new Button(mc, this).addButtonEvent(w -> {
        getWindowManager().closeWindow(modalWindow);
    }).setText("Close"));
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) ParameterType(mcjty.rftoolscontrol.api.parameters.ParameterType) Button(mcjty.lib.gui.widgets.Button) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Label(mcjty.lib.gui.widgets.Label) Parameter(mcjty.rftoolscontrol.api.parameters.Parameter) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) ParameterEditor(mcjty.rftoolscontrol.logic.editors.ParameterEditor)

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