use of mcjty.lib.gui.widgets.Button in project RFToolsDimensions by McJty.
the class GuiEssencePainter method initGui.
@Override
public void initGui() {
super.initGui();
extractButton = new Button(mc, this).setText("Extract").setLayoutHint(new PositionalLayout.PositionalHint(13, 164, 60, 16)).addButtonEvent(parent -> {
extractDimlets();
}).setTooltips("Extract the dimlets out of", "a realized dimension tab");
storeButton = new Button(mc, this).setText("Store").setLayoutHint(new PositionalLayout.PositionalHint(13, 182, 60, 16)).addButtonEvent(parent -> {
storeDimlets();
}).setTooltips("Store dimlets in a", "empty dimension tab");
nameField = new TextField(mc, this).addTextEvent((parent, newText) -> {
storeName(newText);
}).setLayoutHint(new PositionalLayout.PositionalHint(13, 200, 60, 16));
validateField = new Label(mc, this).setText("Val");
validateField.setTooltips("Hover here for errors...");
validateField.setLayoutHint(new PositionalLayout.PositionalHint(35, 142, 38, 16));
setNameFromDimensionTab();
Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(extractButton).addChild(storeButton).addChild(nameField).addChild(validateField);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
window = new Window(this, toplevel);
}
use of mcjty.lib.gui.widgets.Button in project RFTools by McJty.
the class GuiStorageScanner method initGui.
@Override
public void initGui() {
super.initGui();
int maxEnergyStored = tileEntity.getMaxEnergyStored();
energyBar = new EnergyBar(mc, this).setFilledRectThickness(1).setVertical().setDesiredWidth(10).setDesiredHeight(50).setMaxValue(maxEnergyStored).setShowText(false);
energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
openViewButton = new ToggleButton(mc, this).setCheckMarker(false).setText("V").setTooltips("Toggle wide storage list");
openViewButton.setPressed(tileEntity.isOpenWideView());
openViewButton.addButtonEvent(widget -> toggleView());
upButton = new Button(mc, this).setText("U").setTooltips("Move inventory up").addButtonEvent(widget -> moveUp());
topButton = new Button(mc, this).setText("T").setTooltips("Move inventory to the top").addButtonEvent(widget -> moveTop());
downButton = new Button(mc, this).setText("D").setTooltips("Move inventory down").addButtonEvent(widget -> moveDown());
bottomButton = new Button(mc, this).setText("B").setTooltips("Move inventory to the bottom").addButtonEvent(widget -> moveBottom());
removeButton = new Button(mc, this).setText("R").setTooltips("Remove inventory from list").addButtonEvent(widget -> removeFromList());
Panel energyPanel = new Panel(mc, this).setLayout(new VerticalLayout().setVerticalMargin(0).setSpacing(1)).setDesiredWidth(10);
energyPanel.addChild(openViewButton).addChild(energyBar).addChild(topButton).addChild(upButton).addChild(downButton).addChild(bottomButton).addChild(new Label(mc, this).setText(" ")).addChild(removeButton);
exportToStarred = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(12, 223, 13, 13)).addChoiceEvent((parent, newChoice) -> changeExportMode());
exportToStarred.addChoice("No", "Export to current container", guielements, 131, 19);
exportToStarred.addChoice("Yes", "Export to first routable container", guielements, 115, 19);
storagePanel = makeStoragePanel(energyPanel);
itemPanel = makeItemPanel();
Button scanButton = new Button(mc, this).setText("Scan").setDesiredWidth(50).setDesiredHeight(14).addButtonEvent(parent -> RFToolsMessages.INSTANCE.sendToServer(new PacketGetInfoFromServer(RFTools.MODID, new InventoriesInfoPacketServer(tileEntity.getDimension(), tileEntity.getStorageScannerPos(), true))));
if (RFTools.instance.xnet) {
if (StorageScannerConfiguration.xnetRequired) {
scanButton.setTooltips("Do a scan of all", "storage units connected", "with an active XNet channel");
} else {
scanButton.setTooltips("Do a scan of all", "storage units in radius", "Use 'xnet' radius to", "restrict to XNet only");
}
} else {
scanButton.setTooltips("Do a scan of all", "storage units in radius");
}
radiusLabel = new ScrollableLabel(mc, this).addValueEvent((parent, newValue) -> changeRadius(newValue)).setRealMinimum(RFTools.instance.xnet ? 0 : 1).setRealMaximum(20);
radiusLabel.setRealValue(tileEntity.getRadius());
visibleRadiusLabel = new Label(mc, this);
visibleRadiusLabel.setDesiredWidth(40);
searchField = new TextField(mc, this).addTextEvent((parent, newText) -> {
storageList.clearHilightedRows();
fromServer_foundInventories.clear();
startSearch(newText);
});
Panel searchPanel = new Panel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 142, 256 - 11, 18)).setLayout(new HorizontalLayout()).setDesiredHeight(18).addChild(new Label(mc, this).setText("Search:")).addChild(searchField);
Slider radiusSlider = new Slider(mc, this).setHorizontal().setTooltips("Radius of scan").setMinimumKnobSize(12).setDesiredHeight(14).setScrollable(radiusLabel);
Panel scanPanel = new Panel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 162, 74, 54)).setFilledRectThickness(-2).setFilledBackground(StyleConfig.colorListBackground).setLayout(new VerticalLayout().setVerticalMargin(6).setSpacing(1)).addChild(scanButton);
if (!(RFTools.instance.xnet && StorageScannerConfiguration.xnetRequired)) {
scanPanel.addChild(radiusSlider);
}
scanPanel.addChild(visibleRadiusLabel);
if (tileEntity.isDummy()) {
scanButton.setEnabled(false);
radiusLabel.setVisible(false);
radiusSlider.setVisible(false);
}
Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(storagePanel).addChild(itemPanel).addChild(searchPanel).addChild(scanPanel).addChild(exportToStarred);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
window = new Window(this, toplevel);
Keyboard.enableRepeatEvents(true);
fromServer_foundInventories.clear();
fromServer_inventory.clear();
if (tileEntity.isDummy()) {
fromServer_inventories.clear();
} else {
tileEntity.requestRfFromServer(RFTools.MODID);
}
BlockPos pos = tileEntity.getCraftingGridContainerPos();
craftingGrid.initGui(modBase, network, mc, this, pos, tileEntity.getCraftingGridProvider(), guiLeft, guiTop, xSize, ySize);
sendServerCommand(RFTools.MODID, CommandHandler.CMD_REQUEST_GRID_SYNC, Arguments.builder().value(pos).build());
if (StorageScannerConfiguration.hilightStarredOnGuiOpen) {
storageList.setSelected(0);
}
init = true;
}
use of mcjty.lib.gui.widgets.Button in project RFToolsControl by McJty.
the class GuiProgrammer method validateProgram.
private void validateProgram() {
Panel panel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
panel.setBounds(new Rectangle(60, 10, 200, 130));
Window modalWindow = getWindowManager().createModalWindow(panel);
WidgetList errorList = new WidgetList(mc, this);
errorList.addSelectionEvent(new SelectionEvent() {
@Override
public void select(Widget parent, int index) {
}
@Override
public void doubleClick(Widget parent, int index) {
if (errorList.getSelected() != -1) {
Widget<?> child = errorList.getChild(errorList.getSelected());
GridPos pos = (GridPos) child.getUserObject();
if (pos != null) {
window.setTextFocus(getHolder(pos.getX(), pos.getY()));
}
}
getWindowManager().closeWindow(modalWindow);
}
});
panel.addChild(errorList);
panel.addChild(new Button(mc, this).addButtonEvent(w -> {
getWindowManager().closeWindow(modalWindow);
}).setText("Close"));
ProgramCardInstance instance = makeGridInstance(false);
List<Pair<GridPos, String>> errors = ProgramValidator.validate(instance);
for (Pair<GridPos, String> entry : errors) {
GridPos p = entry.getKey();
errorList.addChild(new Label(mc, this).setColor(0xffff0000).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setText(entry.getValue()).setUserObject(p));
}
}
use of mcjty.lib.gui.widgets.Button in project RFToolsControl by McJty.
the class GuiProgrammer method openValueEditor.
private void openValueEditor(IIcon icon, IconHolder iconHolder, ParameterDescription parameter, TextField field, boolean constantOnly) {
ParameterEditor editor = ParameterEditors.getEditor(parameter.getType());
Panel editPanel;
if (editor != null) {
editPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setFilledRectThickness(1);
Map<String, Object> data = icon.getData() == null ? Collections.emptyMap() : icon.getData();
editor.build(mc, this, editPanel, o -> {
icon.addData(parameter.getName(), o);
field.setText(ParameterTypeTools.stringRepresentation(parameter.getType(), o));
});
editor.writeValue((ParameterValue) data.get(parameter.getName()));
if (constantOnly) {
editor.constantOnly();
}
} else {
return;
}
Panel panel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
panel.setBounds(new Rectangle(50, 25, 200, 60 + editor.getHeight()));
Window modalWindow = getWindowManager().createModalWindow(panel);
panel.addChild(new Label(mc, this).setText(StringUtils.capitalize(parameter.getName()) + ":"));
panel.addChild(editPanel);
panel.addChild(new Button(mc, this).addButtonEvent(w -> {
getWindowManager().closeWindow(modalWindow);
window.setTextFocus(iconHolder);
}).setText("Close"));
editor.initialFocus(modalWindow);
editor.setOnClose(() -> window.setTextFocus(iconHolder));
}
use of mcjty.lib.gui.widgets.Button in project RFToolsControl by McJty.
the class GuiProcessor method updateVariableList.
private void updateVariableList() {
variableList.removeChildren();
int setupMode = getSetupMode();
int varAlloc = 0;
if (setupMode != -1) {
CardInfo cardInfo = tileEntity.getCardInfo(setupMode);
varAlloc = cardInfo.getVarAllocation();
}
variableList.setPropagateEventsToChildren(setupMode == -1);
int index = 0;
for (int i = 0; i < tileEntity.getMaxvars(); i++) {
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredWidth(40);
if (setupMode != -1) {
boolean allocated = ((varAlloc >> i) & 1) != 0;
int fill = allocated ? 0x7700ff00 : (tileEntity.isVarAllocated(-1, i) ? 0x77660000 : 0x77444444);
panel.setFilledBackground(fill);
if (allocated) {
panel.addChild(new Label(mc, this).setColor(0xffffffff).setText(String.valueOf(index)).setDesiredWidth(26).setUserObject("allowed"));
index++;
} else {
panel.addChild(new Label(mc, this).setText("/").setDesiredWidth(26).setUserObject("allowed"));
}
} else {
panel.addChild(new Label(mc, this).setText(String.valueOf(i)).setDesiredWidth(26).setUserObject("allowed"));
}
int finalI = i;
panel.addChild(new Button(mc, this).addButtonEvent(w -> openValueEditor(finalI)).setText("...").setUserObject("allowed"));
panel.setUserObject("allowed");
variableList.addChild(panel);
}
}
Aggregations