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;
}
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;
}
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;
}
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();
}
});
}
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());
}
Aggregations