use of mcjty.lib.gui.widgets.Button in project RFTools by McJty.
the class GuiPowerCell method initGui.
@Override
public void initGui() {
super.initGui();
energyBar = new EnergyBar(mc, this).setVertical().setMaxValue(1000).setLayoutHint(new PositionalLayout.PositionalHint(10, 7, 8, 54)).setShowText(false);
energyBar.setValue(0);
Button allNone = new Button(mc, this).setText("None").setTooltips("Set all sides to 'none'").setLayoutHint(new PositionalLayout.PositionalHint(140, 10, 32, 15)).addButtonEvent(e -> sendServerCommand(RFToolsMessages.INSTANCE, PowerCellTileEntity.CMD_SETNONE));
Button allInput = new Button(mc, this).setText("In").setTooltips("Set all sides to", "accept energy").setLayoutHint(new PositionalLayout.PositionalHint(140, 27, 32, 15)).addButtonEvent(e -> sendServerCommand(RFToolsMessages.INSTANCE, PowerCellTileEntity.CMD_SETINPUT));
Button allOutput = new Button(mc, this).setText("Out").setTooltips("Set all sides to", "send energy").setLayoutHint(new PositionalLayout.PositionalHint(140, 44, 32, 15)).addButtonEvent(e -> sendServerCommand(RFToolsMessages.INSTANCE, PowerCellTileEntity.CMD_SETOUTPUT));
stats = new Button(mc, this).setText("Stats").setTooltips("Power statistics. Press to clear:").setLayoutHint(new PositionalLayout.PositionalHint(100, 10, 32, 15)).addButtonEvent(e -> sendServerCommand(RFToolsMessages.INSTANCE, PowerCellTileEntity.CMD_CLEARSTATS));
Label label = new Label(mc, this);
label.setText("Link:").setTooltips("Link a powercard to card", "on the left").setLayoutHint(new PositionalLayout.PositionalHint(26, 30, 40, 18));
Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(energyBar).addChild(allNone).addChild(allInput).addChild(allOutput).addChild(label).addChild(stats);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
window = new Window(this, toplevel);
requestRF();
}
use of mcjty.lib.gui.widgets.Button in project RFTools by McJty.
the class GuiRelay method createSubPanel.
private Panel createSubPanel(int side, String redstoneState) {
String labelText = String.valueOf(RelayTileEntity.DUNSWE.charAt(side));
int rf;
boolean input;
if ("Off".equals(redstoneState)) {
rf = tileEntity.getRfOff(side);
input = tileEntity.isInputModeOff(side);
} else {
rf = tileEntity.getRfOn(side);
input = tileEntity.isInputModeOn(side);
}
ImageChoiceLabel inputOutput = new ImageChoiceLabel(mc, this).setDesiredWidth(14).setDesiredHeight(14).addChoice("Output", "Side set to output mode", iconGuiElements, 80, 16).addChoice("Input", "Side set to input mode", iconGuiElements, 96, 16).addChoiceEvent((parent, newChoice) -> changeSettings());
String key = labelText + redstoneState;
if (input) {
inputOutput.setCurrentChoice("Input");
} else {
inputOutput.setCurrentChoice("Output");
}
inputOutputs.put(key, inputOutput);
TextField energyField = new TextField(mc, this).setTooltips("Amount of RF to input/output", "when redstone is " + redstoneState).setDesiredWidth(42).setDesiredHeight(14).addTextEvent((parent, newText) -> adjustEnergy((TextField) parent, 0));
energyField.setText(String.valueOf(rf));
Button sub100 = createEnergyOffsetButton(energyField, "-", -500);
Button add100 = createEnergyOffsetButton(energyField, "+", 500);
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(1)).addChild(inputOutput).addChild(sub100).addChild(energyField).addChild(add100);
energyValues.put(key, energyField);
return panel;
}
use of mcjty.lib.gui.widgets.Button in project RFTools by McJty.
the class GuiMatterTransmitter method initGui.
@Override
public void initGui() {
super.initGui();
int maxEnergyStored = tileEntity.getMaxEnergyStored();
energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setHorizontal().setDesiredHeight(12).setDesiredWidth(80).setMaxValue(maxEnergyStored).setShowText(false);
energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
TextField textField = new TextField(mc, this).setTooltips("Use this name to", "identify this transmitter", "in the dialer").addTextEvent((parent, 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((parent, 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(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(parent -> addPlayer());
delButton = new Button(mc, this).setText("Del").setDesiredHeight(13).setDesiredWidth(34).setTooltips("Remove the selected player", "from the access list").addButtonEvent(parent -> delPlayer());
Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(nameField).addChild(addButton).addChild(delButton).setDesiredHeight(16);
Panel 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(RFTools.MODID);
}
use of mcjty.lib.gui.widgets.Button in project RFTools 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(RFTools.instance, mc, this).setText(manualText).setArrowImage(iconGuiElements, 144, 0).setCraftingGridImage(iconGuiElements, 0, 192);
prevButton = new Button(mc, this).setText("<").addButtonEvent(parent -> {
// System.out.println("GuiRFToolsManual.buttonClicked: <");
textPage.prevPage();
window.setTextFocus(textPage);
});
pageLabel = new Label(mc, this).setText("0 / 0");
nextButton = new Button(mc, this).setText(">").addButtonEvent(parent -> {
// System.out.println("GuiRFToolsManual.buttonClicked: >");
textPage.nextPage();
window.setTextFocus(textPage);
});
Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredHeight(16).addChild(prevButton).addChild(pageLabel).addChild(nextButton);
Panel 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;
}
}
use of mcjty.lib.gui.widgets.Button in project RFTools by McJty.
the class GuiAdvancedPorter method createPanel.
private Panel createPanel(final TextField destination, final int i) {
return new Panel(mc, this).setLayout(new HorizontalLayout()).addChild(destination).addChild(new Button(mc, this).setText("Set").setDesiredWidth(30).setDesiredHeight(16).addButtonEvent(parent -> {
if (targets[i] != -1) {
RFToolsMessages.sendToServer(CommandHandler.CMD_SET_TARGET, Arguments.builder().value(targets[i]));
target = targets[i];
}
})).addChild(new Button(mc, this).setText("Clear").setDesiredWidth(40).setDesiredHeight(16).addButtonEvent(parent -> {
if (targets[i] != -1 && targets[i] == target) {
target = -1;
}
RFToolsMessages.sendToServer(CommandHandler.CMD_CLEAR_TARGET, Arguments.builder().value(i));
targets[i] = -1;
})).setDesiredHeight(16);
}
Aggregations