Search in sources :

Example 6 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class ScreenModuleGuiBuilder method setupFormatCombo.

private static ChoiceLabel setupFormatCombo(Minecraft mc, Gui gui, final NBTTagCompound currentData, final ModuleGuiChanged moduleGuiChanged) {
    final String modeFull = FormatStyle.MODE_FULL.getName();
    final String modeCompact = FormatStyle.MODE_COMPACT.getName();
    final String modeCommas = FormatStyle.MODE_COMMAS.getName();
    final ChoiceLabel modeButton = new ChoiceLabel(mc, gui).setDesiredWidth(58).setDesiredHeight(14).addChoices(modeFull, modeCompact, modeCommas).setChoiceTooltip(modeFull, "Full format: 3123555").setChoiceTooltip(modeCompact, "Compact format: 3.1M").setChoiceTooltip(modeCommas, "Comma format: 3,123,555").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            currentData.setInteger("format", FormatStyle.getStyle(newChoice).ordinal());
            moduleGuiChanged.updateData();
        }
    });
    FormatStyle currentFormat = FormatStyle.values()[currentData.getInteger("format")];
    modeButton.setChoice(currentFormat.getName());
    return modeButton;
}
Also used : ColorChoiceEvent(mcjty.lib.gui.events.ColorChoiceEvent) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent)

Example 7 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class ScreenModuleGuiBuilder method setupModeCombo.

private static ChoiceLabel setupModeCombo(Minecraft mc, Gui gui, final String componentName, final NBTTagCompound currentData, final ModuleGuiChanged moduleGuiChanged) {
    String modeNone = "None";
    final String modePertick = componentName + "/t";
    final String modePct = componentName + "%";
    final ChoiceLabel modeButton = new ChoiceLabel(mc, gui).setDesiredWidth(50).setDesiredHeight(14).addChoices(modeNone, componentName, modePertick, modePct).setChoiceTooltip(modeNone, "No text is shown").setChoiceTooltip(componentName, "Show the amount of " + componentName).setChoiceTooltip(modePertick, "Show the average " + componentName + "/tick", "gain or loss").setChoiceTooltip(modePct, "Show the amount of " + componentName, "as a percentage").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            if (componentName.equals(newChoice)) {
                currentData.setBoolean("showdiff", false);
                currentData.setBoolean("showpct", false);
                currentData.setBoolean("hidetext", false);
            } else if (modePertick.equals(newChoice)) {
                currentData.setBoolean("showdiff", true);
                currentData.setBoolean("showpct", false);
                currentData.setBoolean("hidetext", false);
            } else if (modePct.equals(newChoice)) {
                currentData.setBoolean("showdiff", false);
                currentData.setBoolean("showpct", true);
                currentData.setBoolean("hidetext", false);
            } else {
                currentData.setBoolean("showdiff", false);
                currentData.setBoolean("showpct", false);
                currentData.setBoolean("hidetext", true);
            }
            moduleGuiChanged.updateData();
        }
    });
    if (currentData.getBoolean("hidetext")) {
        modeButton.setChoice(modeNone);
    } else if (currentData.getBoolean("showdiff")) {
        modeButton.setChoice(modePertick);
    } else if (currentData.getBoolean("showpct")) {
        modeButton.setChoice(modePct);
    } else {
        modeButton.setChoice(componentName);
    }
    return modeButton;
}
Also used : ColorChoiceEvent(mcjty.lib.gui.events.ColorChoiceEvent) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent)

Example 8 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class GuiSecurityManager method initGui.

@Override
public void initGui() {
    super.initGui();
    players = new WidgetList(mc, this);
    Slider allowedPlayerSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(players);
    Panel allowedPlayersPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(players).addChild(allowedPlayerSlider).setLayoutHint(new PositionalLayout.PositionalHint(72, 5, SECURITYMANAGER_WIDTH - 76, 96));
    nameField = new TextField(mc, this).setDesiredHeight(15);
    addButton = new Button(mc, this).setText("Add").setDesiredHeight(14).setDesiredWidth(34).setTooltips("Add a player to the access list").addButtonEvent(new ButtonEvent() {

        @Override
        public void buttonClicked(Widget parent) {
            addPlayer();
        }
    });
    delButton = new Button(mc, this).setText("Del").setDesiredHeight(14).setDesiredWidth(34).setTooltips("Remove the selected player", "from the access list").addButtonEvent(new ButtonEvent() {

        @Override
        public void buttonClicked(Widget parent) {
            delPlayer();
        }
    });
    Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(nameField).addChild(addButton).addChild(delButton).setDesiredHeight(16).setLayoutHint(new PositionalLayout.PositionalHint(72, 100, SECURITYMANAGER_WIDTH - 76, 14));
    channelNameField = new TextField(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 27, 60, 14)).addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            updateChannelName();
        }
    });
    blacklistMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(10, 44, 16, 16)).setTooltips("Black or whitelist mode").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateSettings();
        }
    });
    blacklistMode.addChoice("White", "Whitelist players", guiElements, 15 * 16, 32);
    blacklistMode.addChoice("Black", "Blacklist players", guiElements, 14 * 16, 32);
    Widget toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(allowedPlayersPanel).addChild(buttonPanel).addChild(channelNameField).addChild(blacklistMode);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
    Keyboard.enableRepeatEvents(true);
    channelFromServer = null;
}
Also used : Window(mcjty.lib.gui.Window) TextEvent(mcjty.lib.gui.events.TextEvent) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) ButtonEvent(mcjty.lib.gui.events.ButtonEvent) TextField(mcjty.lib.gui.widgets.TextField)

Example 9 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class GuiEnderMonitor method initGuiMode.

private void initGuiMode() {
    mode = new ChoiceLabel(mc, this).setDesiredHeight(13).setDesiredWidth(80);
    for (EnderMonitorMode m : EnderMonitorMode.values()) {
        mode.addChoices(m.getDescription());
    }
    mode.setChoiceTooltip(EnderMonitorMode.MODE_LOSTPEARL.getDescription(), "Send a redstone pulse when a", "pearl is lost");
    mode.setChoiceTooltip(EnderMonitorMode.MODE_PEARLFIRED.getDescription(), "Send a redstone pulse when a", "pearl is fired");
    mode.setChoiceTooltip(EnderMonitorMode.MODE_PEARLARRIVED.getDescription(), "Send a redstone pulse when a", "pearl arrives");
    mode.setChoice(tileEntity.getMode().getDescription());
    mode.addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            changeMode();
        }
    });
}
Also used : ChoiceLabel(mcjty.lib.gui.widgets.ChoiceLabel) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) Widget(mcjty.lib.gui.widgets.Widget)

Example 10 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFTools by McJty.

the class GuiDimensionBuilder method initRedstoneMode.

private void initRedstoneMode() {
    redstoneMode = new ImageChoiceLabel(mc, this).addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            changeRedstoneMode();
        }
    }).addChoice(RedstoneMode.REDSTONE_IGNORED.getDescription(), "Redstone mode:\nIgnored", iconGuiElements, 0, 0).addChoice(RedstoneMode.REDSTONE_OFFREQUIRED.getDescription(), "Redstone mode:\nOff to activate", iconGuiElements, 16, 0).addChoice(RedstoneMode.REDSTONE_ONREQUIRED.getDescription(), "Redstone mode:\nOn to activate", iconGuiElements, 32, 0);
    redstoneMode.setLayoutHint(new PositionalLayout.PositionalHint(150, 46, 16, 16));
    redstoneMode.setCurrentChoice(tileEntity.getRedstoneMode().ordinal());
}
Also used : ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Aggregations

ChoiceEvent (mcjty.lib.gui.events.ChoiceEvent)33 Panel (mcjty.lib.gui.widgets.Panel)19 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)15 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)14 Window (mcjty.lib.gui.Window)12 Label (mcjty.lib.gui.widgets.Label)9 TextField (mcjty.lib.gui.widgets.TextField)9 TextEvent (mcjty.lib.gui.events.TextEvent)8 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)7 Button (mcjty.lib.gui.widgets.Button)7 ButtonEvent (mcjty.lib.gui.events.ButtonEvent)6 ColorChoiceEvent (mcjty.lib.gui.events.ColorChoiceEvent)6 Widget (mcjty.lib.gui.widgets.Widget)5 ImageChoiceLabel (mcjty.lib.gui.widgets.ImageChoiceLabel)4 Coordinate (mcjty.lib.varia.Coordinate)4 ValueEvent (mcjty.lib.gui.events.ValueEvent)3 DefaultSelectionEvent (mcjty.lib.gui.events.DefaultSelectionEvent)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 HashMap (java.util.HashMap)1