Search in sources :

Example 1 with ChoiceEvent

use of mcjty.lib.gui.events.ChoiceEvent in project RFToolsDimensions 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)

Example 2 with ChoiceEvent

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

the class GuiCrafter 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(31, 186, 16, 16));
    redstoneMode.setCurrentChoice(tileEntity.getRedstoneMode().ordinal());
}
Also used : ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 3 with ChoiceEvent

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

the class GuiBuilder method setupPositionPanel.

private Panel setupPositionPanel() {
    rotateButton = new ChoiceLabel(mc, this).addChoices(ROTATE_0, ROTATE_90, ROTATE_180, ROTATE_270).setLayoutHint(new PositionalLayout.PositionalHint(4, 4, 42, 14)).setTooltips("Set the horizontal rotation angle").addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            updateRotate();
        }
    });
    switch(tileEntity.getRotate()) {
        case 0:
            rotateButton.setChoice(ROTATE_0);
            break;
        case 1:
            rotateButton.setChoice(ROTATE_90);
            break;
        case 2:
            rotateButton.setChoice(ROTATE_180);
            break;
        case 3:
            rotateButton.setChoice(ROTATE_270);
            break;
    }
    Panel positionPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setLayoutHint(new PositionalLayout.PositionalHint(122, 6, 50, 59)).addChild(rotateButton).setFilledRectThickness(-2).setFilledBackground(StyleConfig.colorListBackground);
    String[] choiceDescriptions = { "Builder at south west corner", "Builder at south east corner", "Builder at north west corner", "Builder at north east corner" };
    for (int y = 0; y <= 1; y++) {
        for (int x = 0; x <= 1; x++) {
            final int index = x + y * 2;
            anchor[index] = new ImageChoiceLabel(mc, this).setWithBorder(true).setHighlightedChoice(1).setLayoutHint(new PositionalLayout.PositionalHint(4 + x * 24, 18 + (1 - y) * 19, 17, 17)).setTooltips("Set the anchor where you want to", "place the blocks in front of the", "builder");
            anchor[index].addChoice("off", choiceDescriptions[index], guiElements, (7 + index * 2) * 16, 4 * 16);
            anchor[index].addChoice("on", choiceDescriptions[index], guiElements, (6 + index * 2) * 16, 4 * 16);
            anchor[index].addChoiceEvent(new ChoiceEvent() {

                @Override
                public void choiceChanged(Widget widget, String s) {
                    selectAnchor(index);
                }
            });
            positionPanel.addChild(anchor[index]);
        }
    }
    if (!isShapeCard()) {
        anchor[tileEntity.getAnchor()].setCurrentChoice(1);
    }
    return positionPanel;
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout)

Example 4 with ChoiceEvent

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

the class GuiMatterReceiver 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 receiver", "in the dialer").addTextEvent(new TextEvent() {

        @Override
        public void textChanged(Widget parent, String newText) {
            setReceiverName(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 dial to this receiver").setChoiceTooltip(ACCESS_PRIVATE, "Only people in the access list below", "can dial to this receiver").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);
    }
    Panel privatePanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(new Label(mc, this).setText("Access:")).addChild(privateSetting).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) Button(mcjty.lib.gui.widgets.Button) ButtonEvent(mcjty.lib.gui.events.ButtonEvent) TextField(mcjty.lib.gui.widgets.TextField) VerticalLayout(mcjty.lib.gui.layout.VerticalLayout)

Example 5 with ChoiceEvent

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

the class GuiDialingDevice method initGui.

@Override
public void initGui() {
    super.initGui();
    int maxEnergyStored = tileEntity.getMaxEnergyStored(ForgeDirection.DOWN);
    energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setHorizontal().setDesiredWidth(80).setDesiredHeight(12).setMaxValue(maxEnergyStored).setShowText(false);
    energyBar.setValue(tileEntity.getCurrentRF());
    Panel transmitterPanel = setupTransmitterPanel();
    Panel receiverPanel = setupReceiverPanel();
    dialButton = new Button(mc, this).setText("Dial").setTooltips("Start a connection between", "the selected transmitter", "and the selected receiver").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(new ButtonEvent() {

        @Override
        public void buttonClicked(Widget parent) {
            dial(false);
        }
    });
    dialOnceButton = new Button(mc, this).setText("Dial Once").setTooltips("Dial a connection for a", "single teleport").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(new ButtonEvent() {

        @Override
        public void buttonClicked(Widget parent) {
            dial(true);
        }
    });
    interruptButton = new Button(mc, this).setText("Interrupt").setTooltips("Interrupt a connection", "for the selected transmitter").setDesiredHeight(14).setDesiredWidth(65).addButtonEvent(new ButtonEvent() {

        @Override
        public void buttonClicked(Widget parent) {
            interruptDial();
        }
    });
    favoriteButton = new ImageChoiceLabel(mc, this).addChoiceEvent(new ChoiceEvent() {

        @Override
        public void choiceChanged(Widget parent, String newChoice) {
            changeShowFavorite();
        }
    }).setDesiredWidth(10).setDesiredHeight(10);
    favoriteButton.addChoice("No", "Unfavorited receiver", guielements, 131, 19);
    favoriteButton.addChoice("Yes", "Favorited receiver", guielements, 115, 19);
    favoriteButton.setCurrentChoice(tileEntity.isShowOnlyFavorites() ? 1 : 0);
    Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(dialButton).addChild(dialOnceButton).addChild(interruptButton).addChild(favoriteButton).setDesiredHeight(16);
    analyzerAvailable = DialingDeviceTileEntity.isDestinationAnalyzerAvailable(mc.theWorld, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
    statusButton = new Button(mc, this).setText("Check").setDesiredHeight(14).setDesiredWidth(65).setEnabled(analyzerAvailable).addButtonEvent(new ButtonEvent() {

        @Override
        public void buttonClicked(Widget parent) {
            checkStatus();
        }
    });
    if (analyzerAvailable) {
        statusButton.setTooltips("Check the status of", "the selected receiver");
    } else {
        statusButton.setTooltips("Check the status of", "the selected receiver", "(needs an adjacent analyzer!)");
    }
    statusLabel = new Label(mc, this);
    statusLabel.setDesiredWidth(170).setDesiredHeight(14).setFilledRectThickness(1);
    Panel statusPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(statusButton).addChild(statusLabel).setDesiredHeight(16);
    Widget toplevel = new Panel(mc, this).setFilledRectThickness(2).setLayout(new VerticalLayout().setVerticalMargin(3).setSpacing(1)).addChild(energyBar).addChild(transmitterPanel).addChild(receiverPanel).addChild(buttonPanel).addChild(statusPanel);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, DIALER_WIDTH, DIALER_HEIGHT));
    window = new mcjty.lib.gui.Window(this, toplevel);
    Keyboard.enableRepeatEvents(true);
    listDirty = 0;
    clearSelectedStatus();
    requestReceivers();
    requestTransmitters();
    tileEntity.requestRfFromServer(RFToolsMessages.INSTANCE);
}
Also used : ChoiceEvent(mcjty.lib.gui.events.ChoiceEvent) Label(mcjty.lib.gui.widgets.Label) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Panel(mcjty.lib.gui.widgets.Panel) Button(mcjty.lib.gui.widgets.Button) ButtonEvent(mcjty.lib.gui.events.ButtonEvent) 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