Search in sources :

Example 16 with Window

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

the class GuiRFToolsManual 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(RFToolsControl.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);
    Widget<?> 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) java.awt(java.awt) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) GuiScreen(net.minecraft.client.gui.GuiScreen) Panel(mcjty.lib.gui.widgets.Panel) Minecraft(net.minecraft.client.Minecraft) Button(mcjty.lib.gui.widgets.Button) ResourceLocation(net.minecraft.util.ResourceLocation) RFToolsControl(mcjty.rftoolscontrol.RFToolsControl) 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 17 with Window

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

the class GuiTools method showMessage.

public static void showMessage(Minecraft mc, Gui gui, WindowManager windowManager, int x, int y, String title) {
    Panel ask = new Panel(mc, gui).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
    ask.setBounds(new Rectangle(x, y, 200, 40));
    Window askWindow = windowManager.createModalWindow(ask);
    ask.addChild(new Label(mc, gui).setText(title));
    Panel buttons = new Panel(mc, gui).setLayout(new HorizontalLayout()).setDesiredWidth(100).setDesiredHeight(18);
    buttons.addChild(new Button(mc, gui).setText("Cancel").addButtonEvent((parent -> {
        windowManager.closeWindow(askWindow);
    })));
    ask.addChild(buttons);
}
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) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 18 with Window

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

the class GuiSensor method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout());
    numberField = new TextField(mc, this).setTooltips("Set a number specific to the type of sensor").setLayoutHint(new PositionalLayout.PositionalHint(60, 51, 80, 14)).addTextEvent((parent, newText) -> setNumber());
    int number = tileEntity.getNumber();
    numberField.setText(String.valueOf(number));
    typeLabel = new ChoiceLabel(mc, this);
    for (SensorType sensorType : SensorType.values()) {
        typeLabel.addChoices(sensorType.getName());
        typeLabel.setChoiceTooltip(sensorType.getName(), sensorType.getDescription());
    }
    typeLabel.setLayoutHint(new PositionalLayout.PositionalHint(60, 3, 80, 14));
    typeLabel.setChoice(tileEntity.getSensorType().getName());
    typeLabel.addChoiceEvent((parent, newChoice) -> setType());
    areaLabel = new ChoiceLabel(mc, this);
    for (AreaType areaType : AreaType.values()) {
        areaLabel.addChoices(areaType.getName());
        areaLabel.setChoiceTooltip(areaType.getName(), areaType.getDescription());
    }
    areaLabel.setLayoutHint(new PositionalLayout.PositionalHint(60, 19, 80, 14));
    areaLabel.setChoice(tileEntity.getAreaType().getName());
    areaLabel.addChoiceEvent((parent, newChoice) -> setArea());
    groupLabel = new ChoiceLabel(mc, this);
    for (GroupType groupType : GroupType.values()) {
        groupLabel.addChoices(groupType.getName());
        groupLabel.setChoiceTooltip(groupType.getName(), groupType.getDescription());
    }
    groupLabel.setLayoutHint(new PositionalLayout.PositionalHint(60, 35, 80, 14));
    groupLabel.setChoice(tileEntity.getGroupType().getName());
    groupLabel.addChoiceEvent((parent, newChoice) -> setGroup());
    toplevel.addChild(new Label(mc, this).setText("Type:").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setLayoutHint(new PositionalLayout.PositionalHint(10, 3, 50, 14))).addChild(areaLabel).addChild(new Label(mc, this).setText("Area:").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setLayoutHint(new PositionalLayout.PositionalHint(10, 19, 50, 14))).addChild(typeLabel).addChild(new Label(mc, this).setText("Group:").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setLayoutHint(new PositionalLayout.PositionalHint(10, 35, 50, 14))).addChild(groupLabel).addChild(new Label(mc, this).setText("Number:").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setLayoutHint(new PositionalLayout.PositionalHint(10, 51, 50, 14))).addChild(numberField);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) TextField(mcjty.lib.gui.widgets.TextField) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) Label(mcjty.lib.gui.widgets.Label) Window(mcjty.lib.gui.Window) java.awt(java.awt) Argument(mcjty.lib.network.Argument) Panel(mcjty.lib.gui.widgets.Panel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) ResourceLocation(net.minecraft.util.ResourceLocation) ChoiceLabel(mcjty.lib.gui.widgets.ChoiceLabel) NamedEnum(mcjty.rftools.varia.NamedEnum) RFTools(mcjty.rftools.RFTools) Window(mcjty.lib.gui.Window) ChoiceLabel(mcjty.lib.gui.widgets.ChoiceLabel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) ChoiceLabel(mcjty.lib.gui.widgets.ChoiceLabel) Panel(mcjty.lib.gui.widgets.Panel) TextField(mcjty.lib.gui.widgets.TextField)

Example 19 with Window

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

the class GuiScreen method initGui.

@Override
public void initGui() {
    super.initGui();
    toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout());
    for (int i = 0; i < ScreenContainer.SCREEN_MODULES; i++) {
        buttons[i] = new ToggleButton(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(30, 7 + i * 18 + 1, 40, 16)).setEnabled(false).setTooltips("Open the gui for this", "module");
        final int finalI = i;
        buttons[i].addButtonEvent(parent -> selectPanel(finalI));
        toplevel.addChild(buttons[i]);
        modulePanels[i] = null;
        clientScreenModules[i] = null;
    }
    bright = new ToggleButton(mc, this).setText("Bright").setCheckMarker(true).setTooltips("Toggle full brightness").setLayoutHint(new PositionalLayout.PositionalHint(85, 123, 55, 14));
    // .setLayoutHint(new PositionalLayout.PositionalHint(7, 208, 63, 14));
    bright.setPressed(tileEntity.isBright());
    bright.addButtonEvent(parent -> sendServerCommand(RFToolsMessages.INSTANCE, ScreenTileEntity.CMD_SETBRIGHT, new Argument("b", bright.isPressed())));
    toplevel.addChild(bright);
    toplevel.addChild(new Label(mc, this).setText("Font:").setHorizontalAlignment(HorizontalAlignment.ALIGN_RIGHT).setLayoutHint(new PositionalLayout.PositionalHint(85 + 50 + 9, 123, 30, 14)));
    trueType = new ChoiceLabel(mc, this).addChoices("Default", "Truetype", "Vanilla").setTooltips("Set truetype font mode", "for the screen").setLayoutHint(new PositionalLayout.PositionalHint(85 + 50 + 14 + 30, 123, 68, 14));
    int trueTypeMode = tileEntity.getTrueTypeMode();
    trueType.setChoice(trueTypeMode == 0 ? "Default" : (trueTypeMode == -1 ? "Vanilla" : "Truetype"));
    trueType.addChoiceEvent((a, b) -> sendServerCommand(RFToolsMessages.INSTANCE, ScreenTileEntity.CMD_SETTRUETYPE, new Argument("b", getCurrentTruetypeChoice())));
    toplevel.addChild(trueType);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
    Keyboard.enableRepeatEvents(true);
    selected = -1;
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) ToggleButton(mcjty.lib.gui.widgets.ToggleButton) Argument(mcjty.lib.network.Argument) ChoiceLabel(mcjty.lib.gui.widgets.ChoiceLabel) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Label(mcjty.lib.gui.widgets.Label) ChoiceLabel(mcjty.lib.gui.widgets.ChoiceLabel)

Example 20 with Window

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

the class GuiThreeLogic method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout());
    for (int i = 0; i < 8; i++) {
        final int finalI = i;
        ChoiceLabel tl = new ChoiceLabel(mc, this).addChoices("On", "Off", "Keep").setDesiredWidth(38).setDesiredHeight(14).setLayoutHint(new PositionalLayout.PositionalHint(146, 25 + i * 15));
        tl.setChoiceTooltip("On", "Emit redstone signal");
        tl.setChoiceTooltip("Off", "Don't emit redstone signal");
        tl.setChoiceTooltip("Keep", "Keep previous redstone signal");
        int state = tileEntity.getState(i);
        switch(state) {
            case 0:
                tl.setChoice("Off");
                break;
            case 1:
                tl.setChoice("On");
                break;
            default:
                tl.setChoice("Keep");
                break;
        }
        tl.addChoiceEvent((widget, s) -> {
            String current = tl.getCurrentChoice();
            int st = "On".equals(current) ? 1 : "Off".equals(current) ? 0 : -1;
            sendServerCommand(RFToolsMessages.INSTANCE, ThreeLogicTileEntity.CMD_SETSTATE, new Argument("index", finalI), new Argument("state", st));
        });
        outputs.add(tl);
        toplevel.addChild(tl);
    }
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, LOGIC3_WIDTH, LOGIC3_HEIGHT));
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) Panel(mcjty.lib.gui.widgets.Panel) ChoiceLabel(mcjty.lib.gui.widgets.ChoiceLabel) Argument(mcjty.lib.network.Argument) 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