Search in sources :

Example 26 with ChoiceEvent

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

the class GuiRemoteStorage method initGui.

@Override
public void initGui() {
    super.initGui();
    int maxEnergyStored = tileEntity.getMaxEnergyStored(ForgeDirection.DOWN);
    energyBar = new EnergyBar(mc, this).setVertical().setMaxValue(maxEnergyStored).setLayoutHint(new PositionalLayout.PositionalHint(10, 7, 8, 54)).setShowText(false);
    energyBar.setValue(tileEntity.getCurrentRF());
    Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(energyBar);
    for (int i = 0; i < 4; i++) {
        global[i] = new ImageChoiceLabel(mc, this);
        final int finalI = i;
        global[i].addChoiceEvent(new ChoiceEvent() {

            @Override
            public void choiceChanged(Widget parent, String newChoice) {
                changeGlobal(finalI);
            }
        });
        global[i].addChoice("off" + i, "Inter-dimensional access only", guiElements, 0, 32);
        global[i].addChoice("on" + i, "Cross-dimension access enabled", guiElements, 16, 32);
        global[i].setLayoutHint(new PositionalLayout.PositionalHint(i < 2 ? (43 - 18) : (120 - 18), (i % 2) == 0 ? 9 : 36, 16, 16));
        global[i].setCurrentChoice(tileEntity.isGlobal(i) ? 1 : 0);
        toplevel.addChild(global[i]);
    }
    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) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Widget(mcjty.lib.gui.widgets.Widget) ImageChoiceLabel(mcjty.lib.gui.widgets.ImageChoiceLabel) EnergyBar(mcjty.lib.gui.widgets.EnergyBar)

Example 27 with ChoiceEvent

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

the class GuiBuilder method setupModePanel.

private Panel setupModePanel() {
    modeChoice = new ChoiceLabel(mc, this).addChoices(MODES[MODE_COPY], MODES[MODE_MOVE], MODES[MODE_SWAP], MODES[MODE_BACK]).setTooltips("Set the building mode").setLayoutHint(new PositionalLayout.PositionalHint(4, 4, 42, 14)).addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateMode();
        }
    });
    modeChoice.setChoice(MODES[tileEntity.getMode()]);
    silentMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(4, 18, 17, 17)).setWithBorder(true).setHighlightedChoice(1).setTooltips("Suppress the placement/breaking sound", "when moving blocks").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            setSilentMode();
        }
    });
    silentMode.addChoice("off", "Moving blocks make sound", guiElements, 11 * 16, 3 * 16);
    silentMode.addChoice("on", "Block sounds are muted", guiElements, 10 * 16, 3 * 16);
    silentMode.setCurrentChoice(tileEntity.isSilent() ? 1 : 0);
    supportMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(28, 18, 17, 17)).setWithBorder(true).setHighlightedChoice(1).setTooltips("Use supporting blocks when moving.", "Useful for liquids, gravel, ...").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            setSupportMode();
        }
    });
    supportMode.addChoice("off", "Support/preview mode disabled", guiElements, 7 * 16, 3 * 16);
    supportMode.addChoice("on", "Support/preview mode enabled", guiElements, 6 * 16, 3 * 16);
    supportMode.setCurrentChoice(tileEntity.hasSupportMode() ? 1 : 0);
    entityMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(4, 37, 17, 17)).setWithBorder(true).setHighlightedChoice(1).setTooltips("Move entities").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            setEntityMode();
        }
    });
    entityMode.addChoice("off", "Entities are not moved", guiElements, 9 * 16, 3 * 16);
    entityMode.addChoice("on", "Entities are moved", guiElements, 8 * 16, 3 * 16);
    entityMode.setCurrentChoice(tileEntity.hasEntityMode() ? 1 : 0);
    loopMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(28, 37, 17, 17)).setWithBorder(true).setHighlightedChoice(1).setTooltips("Loop mode").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            setLoopMode();
        }
    });
    loopMode.addChoice("off", "Do a single run and stop", guiElements, 13 * 16, 3 * 16);
    loopMode.addChoice("on", "Keep running with redstone signal", guiElements, 12 * 16, 3 * 16);
    loopMode.setCurrentChoice(tileEntity.hasLoopMode() ? 1 : 0);
    return new Panel(mc, this).setLayout(new PositionalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(23, 6, 50, 59)).addChild(modeChoice).addChild(silentMode).addChild(supportMode).addChild(entityMode).addChild(loopMode).setFilledRectThickness(-2).setFilledBackground(StyleConfig.colorListBackground);
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 28 with ChoiceEvent

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

the class GuiSpaceProjector 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)

Example 29 with ChoiceEvent

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

the class GuiDialingDevice method populateReceivers.

private void populateReceivers() {
    List<TeleportDestinationClientInfo> newReceivers = fromServer_receivers;
    if (newReceivers == null) {
        return;
    }
    boolean newReceiversFiltered = favoriteButton.getCurrentChoiceIndex() == 1;
    if (newReceivers.equals(receivers) && newReceiversFiltered == receiversFiltered) {
        return;
    }
    receiversFiltered = newReceiversFiltered;
    if (receiversFiltered) {
        receivers = new ArrayList<TeleportDestinationClientInfo>();
        // We only show favorited receivers. Remove the rest.
        for (TeleportDestinationClientInfo receiver : newReceivers) {
            if (receiver.isFavorite()) {
                receivers.add(receiver);
            }
        }
    } else {
        // Show all receivers.
        receivers = new ArrayList<TeleportDestinationClientInfo>(newReceivers);
    }
    receiverList.removeChildren();
    for (TeleportDestinationClientInfo destination : receivers) {
        Coordinate coordinate = destination.getCoordinate();
        String dimName = destination.getDimensionName();
        if (dimName == null || dimName.trim().isEmpty()) {
            dimName = "Id " + destination.getDimension();
        }
        boolean favorite = destination.isFavorite();
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setSpacing(1).setHorizontalMargin(3));
        panel.addChild(new Label(mc, this).setColor(StyleConfig.colorTextInListNormal).setText(destination.getName()).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(96).setTooltips("The name of the", "destination receiver:", destination.getName() + " (" + coordinate.toString() + ")"));
        panel.addChild(new Label(mc, this).setColor(StyleConfig.colorTextInListNormal).setText(dimName).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDynamic(true).setTooltips("The name of the", "destination dimension:", dimName).setDesiredWidth(110));
        ImageChoiceLabel choiceLabel = new ImageChoiceLabel(mc, this).addChoiceEvent(new ChoiceEvent() {

            @Override
            public void choiceChanged(Widget parent, String newChoice) {
                changeFavorite();
            }
        }).setDesiredWidth(10);
        choiceLabel.addChoice("No", "Not favorited", guielements, 131, 19);
        choiceLabel.addChoice("Yes", "Favorited", guielements, 115, 19);
        choiceLabel.setCurrentChoice(favorite ? 1 : 0);
        panel.addChild(choiceLabel);
        receiverList.addChild(panel);
    }
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Coordinate(mcjty.lib.varia.Coordinate) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 30 with ChoiceEvent

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

the class GuiMatterTransmitter method initGui.

@Override
public void initGui() {
    super.initGui();
    int maxEnergyStored = tileEntity.getMaxEnergyStored(ForgeDirection.DOWN);
    energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setHorizontal().setDesiredHeight(12).setDesiredWidth(80).setMaxValue(maxEnergyStored).setShowText(false);
    energyBar.setValue(tileEntity.getCurrentRF());
    TextField textField = new TextField(mc, this).setTooltips("Use this name to", "identify this transmitter", "in the dialer").addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            setTransmitterName(newText);
        }
    });
    textField.setText(tileEntity.getName());
    Panel namePanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(new Label(mc, this).setText("Name:")).addChild(textField).setDesiredHeight(16);
    privateSetting = new ChoiceLabel(mc, this).addChoices(ACCESS_PUBLIC, ACCESS_PRIVATE).setDesiredHeight(14).setDesiredWidth(60).setChoiceTooltip(ACCESS_PUBLIC, "Everyone can access this transmitter", "and change the dialing destination").setChoiceTooltip(ACCESS_PRIVATE, "Only people in the access list below", "can access this transmitter").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            changeAccessMode(newChoice);
        }
    });
    if (tileEntity.isPrivateAccess()) {
        privateSetting.setChoice(ACCESS_PRIVATE);
    } else {
        privateSetting.setChoice(ACCESS_PUBLIC);
    }
    beamToggle = new ToggleButton(mc, this).setText("Hide").setCheckMarker(true).setDesiredHeight(14).setDesiredWidth(49).setTooltips("Hide the teleportation beam").addButtonEvent(new ButtonEvent() {

        @Override
        public void buttonClicked(Widget parent) {
            changeBeamState();
        }
    }).setPressed(tileEntity.isBeamHidden());
    Panel privatePanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(new Label(mc, this).setText("Access:")).addChild(privateSetting).addChild(beamToggle).setDesiredHeight(16);
    allowedPlayers = new WidgetList(mc, this);
    Slider allowedPlayerSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(allowedPlayers);
    Panel allowedPlayersPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(allowedPlayers).addChild(allowedPlayerSlider).setFilledBackground(0xff9e9e9e);
    nameField = new TextField(mc, this);
    addButton = new Button(mc, this).setText("Add").setDesiredHeight(13).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(13).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()).addChild(nameField).addChild(addButton).addChild(delButton).setDesiredHeight(16);
    Widget toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout().setHorizontalMargin(3).setVerticalMargin(3).setSpacing(1)).addChild(energyBar).addChild(namePanel).addChild(privatePanel).addChild(allowedPlayersPanel).addChild(buttonPanel);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, MATTER_WIDTH, MATTER_HEIGHT));
    window = new Window(this, toplevel);
    Keyboard.enableRepeatEvents(true);
    listDirty = 0;
    requestPlayers();
    tileEntity.requestRfFromServer(RFToolsMessages.INSTANCE);
}
Also used : Window(mcjty.lib.gui.Window) TextEvent(mcjty.lib.gui.events.TextEvent) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) ButtonEvent(mcjty.lib.gui.events.ButtonEvent) Button(mcjty.lib.gui.widgets.Button) TextField(mcjty.lib.gui.widgets.TextField) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout)

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