Search in sources :

Example 11 with Window

use of mcjty.lib.gui.Window 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 12 with Window

use of mcjty.lib.gui.Window in project RFToolsControl by McJty.

the class GuiProgrammer method initGui.

@Override
public void initGui() {
    super.initGui();
    // --- Main window ---
    Panel editorPanel = setupEditorPanel();
    Panel controlPanel = setupControlPanel();
    Panel gridPanel = setupGridPanel();
    Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(mainBackground).addChild(editorPanel).addChild(controlPanel).addChild(gridPanel);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel).addFocusEvent((parent, focused) -> selectIcon(parent, focused));
    // --- Side window ---
    Panel listPanel = setupListPanel();
    Panel sidePanel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(sideBackground).addChild(listPanel);
    sidePanel.setBounds(new Rectangle(guiLeft - SIDEWIDTH, guiTop, SIDEWIDTH, ySize));
    sideWindow = new Window(this, sidePanel);
    loadProgram(ProgrammerContainer.SLOT_DUMMY);
    clearCategoryLabels();
}
Also used : Window(mcjty.lib.gui.Window) 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) Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 13 with Window

use of mcjty.lib.gui.Window 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 14 with Window

use of mcjty.lib.gui.Window in project RFToolsControl by McJty.

the class GuiProcessor method initGui.

@Override
public void initGui() {
    super.initGui();
    // --- Main window ---
    Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(mainBackground);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    int maxEnergyStored = tileEntity.getMaxEnergyStored();
    energyBar = new EnergyBar(mc, this).setVertical().setMaxValue(maxEnergyStored).setLayoutHint(new PositionalLayout.PositionalHint(122, 4, 70, 10)).setShowText(false).setHorizontal();
    energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
    toplevel.addChild(energyBar);
    exclusive = new ToggleButton(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(122, 16, 40, 15)).setCheckMarker(true).setText("Excl.").setTooltips(TextFormatting.YELLOW + "Exclusive mode", "If pressed then programs on", "card X can only run on core X");
    exclusive.setPressed(tileEntity.isExclusive());
    exclusive.addButtonEvent(parent -> {
        tileEntity.setExclusive(exclusive.isPressed());
        sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_SETEXCLUSIVE, new Argument("v", exclusive.isPressed()));
    });
    toplevel.addChild(exclusive);
    hudMode = new ChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(122 + 40 + 1, 16, 28, 15)).addChoices("Off", "Log", "Db", "Gfx").setChoiceTooltip("Off", "No overhead log").setChoiceTooltip("Log", "Show the normal log").setChoiceTooltip("Db", "Show a debug display").setChoiceTooltip("Gfx", "Graphics display");
    switch(tileEntity.getShowHud()) {
        case HUD_OFF:
            hudMode.setChoice("Off");
            break;
        case HUD_LOG:
            hudMode.setChoice("Log");
            break;
        case HUD_DB:
            hudMode.setChoice("Db");
            break;
        case HUD_GFX:
            hudMode.setChoice("Gfx");
            break;
    }
    hudMode.addChoiceEvent((parent, newChoice) -> {
        String choice = hudMode.getCurrentChoice();
        int m = HUD_OFF;
        if ("Off".equals(choice)) {
            m = HUD_OFF;
        } else if ("Log".equals(choice)) {
            m = HUD_LOG;
        } else if ("Db".equals(choice)) {
            m = HUD_DB;
        } else {
            m = HUD_GFX;
        }
        sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_SETHUDMODE, new Argument("v", m));
    });
    toplevel.addChild(hudMode);
    setupLogWindow(toplevel);
    for (int i = 0; i < ProcessorTileEntity.CARD_SLOTS; i++) {
        setupButtons[i] = new ToggleButton(mc, this).addButtonEvent(this::setupMode).setTooltips(TextFormatting.YELLOW + "Resource allocation", "Setup item and variable", "allocation for this card").setLayoutHint(new PositionalLayout.PositionalHint(11 + i * 18, 6, 15, 7)).setUserObject("allowed");
        toplevel.addChild(setupButtons[i]);
    }
    window = new Window(this, toplevel);
    // --- Side window ---
    Panel listPanel = setupVariableListPanel();
    Panel sidePanel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(sideBackground).addChild(listPanel);
    sidePanel.setBounds(new Rectangle(guiLeft - SIDEWIDTH, guiTop, SIDEWIDTH, ySize));
    sideWindow = new Window(this, sidePanel);
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) Argument(mcjty.lib.network.Argument) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 15 with Window

use of mcjty.lib.gui.Window in project RFToolsControl by McJty.

the class GuiCraftingStation method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(mainBackground);
    initRecipeList(toplevel);
    initProgressList(toplevel);
    initButtons(toplevel);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, WIDTH, HEIGHT));
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Aggregations

Window (mcjty.lib.gui.Window)74 Panel (mcjty.lib.gui.widgets.Panel)57 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)48 Label (mcjty.lib.gui.widgets.Label)36 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)29 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)28 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)24 Argument (mcjty.lib.network.Argument)24 RFToolsMessages (mcjty.rftools.network.RFToolsMessages)23 java.awt (java.awt)22 Button (mcjty.lib.gui.widgets.Button)22 RFTools (mcjty.rftools.RFTools)22 TextField (mcjty.lib.gui.widgets.TextField)21 Rectangle (java.awt.Rectangle)20 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)20 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)18 ResourceLocation (net.minecraft.util.ResourceLocation)17 StyleConfig (mcjty.lib.base.StyleConfig)15 List (java.util.List)12 EmptyContainer (mcjty.lib.container.EmptyContainer)11