use of mcjty.lib.gui.Window 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.Window in project RFToolsControl by McJty.
the class GuiProgrammer method initGui.
@Override
public void initGui() {
super.initGui();
// --- Main window ---
Panel editorPanel = setupEditorPanel();
Panel controlPanel = setupControlPanel();
Panel gridPanel = setupGridPanel();
Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(mainBackground).addChild(editorPanel).addChild(controlPanel).addChild(gridPanel);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
window = new Window(this, toplevel).addFocusEvent((parent, focused) -> selectIcon(parent, focused));
// --- Side window ---
Panel listPanel = setupListPanel();
Panel sidePanel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(sideBackground).addChild(listPanel);
sidePanel.setBounds(new Rectangle(guiLeft - SIDEWIDTH, guiTop, SIDEWIDTH, ySize));
sideWindow = new Window(this, sidePanel);
loadProgram(ProgrammerContainer.SLOT_DUMMY);
clearCategoryLabels();
}
use of mcjty.lib.gui.Window 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.Window in project RFToolsControl by McJty.
the class GuiProcessor method initGui.
@Override
public void initGui() {
super.initGui();
// --- Main window ---
Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(mainBackground);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
int maxEnergyStored = tileEntity.getMaxEnergyStored();
energyBar = new EnergyBar(mc, this).setVertical().setMaxValue(maxEnergyStored).setLayoutHint(new PositionalLayout.PositionalHint(122, 4, 70, 10)).setShowText(false).setHorizontal();
energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
toplevel.addChild(energyBar);
exclusive = new ToggleButton(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(122, 16, 40, 15)).setCheckMarker(true).setText("Excl.").setTooltips(TextFormatting.YELLOW + "Exclusive mode", "If pressed then programs on", "card X can only run on core X");
exclusive.setPressed(tileEntity.isExclusive());
exclusive.addButtonEvent(parent -> {
tileEntity.setExclusive(exclusive.isPressed());
sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_SETEXCLUSIVE, new Argument("v", exclusive.isPressed()));
});
toplevel.addChild(exclusive);
hudMode = new ChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(122 + 40 + 1, 16, 28, 15)).addChoices("Off", "Log", "Db", "Gfx").setChoiceTooltip("Off", "No overhead log").setChoiceTooltip("Log", "Show the normal log").setChoiceTooltip("Db", "Show a debug display").setChoiceTooltip("Gfx", "Graphics display");
switch(tileEntity.getShowHud()) {
case HUD_OFF:
hudMode.setChoice("Off");
break;
case HUD_LOG:
hudMode.setChoice("Log");
break;
case HUD_DB:
hudMode.setChoice("Db");
break;
case HUD_GFX:
hudMode.setChoice("Gfx");
break;
}
hudMode.addChoiceEvent((parent, newChoice) -> {
String choice = hudMode.getCurrentChoice();
int m = HUD_OFF;
if ("Off".equals(choice)) {
m = HUD_OFF;
} else if ("Log".equals(choice)) {
m = HUD_LOG;
} else if ("Db".equals(choice)) {
m = HUD_DB;
} else {
m = HUD_GFX;
}
sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_SETHUDMODE, new Argument("v", m));
});
toplevel.addChild(hudMode);
setupLogWindow(toplevel);
for (int i = 0; i < ProcessorTileEntity.CARD_SLOTS; i++) {
setupButtons[i] = new ToggleButton(mc, this).addButtonEvent(this::setupMode).setTooltips(TextFormatting.YELLOW + "Resource allocation", "Setup item and variable", "allocation for this card").setLayoutHint(new PositionalLayout.PositionalHint(11 + i * 18, 6, 15, 7)).setUserObject("allowed");
toplevel.addChild(setupButtons[i]);
}
window = new Window(this, toplevel);
// --- Side window ---
Panel listPanel = setupVariableListPanel();
Panel sidePanel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(sideBackground).addChild(listPanel);
sidePanel.setBounds(new Rectangle(guiLeft - SIDEWIDTH, guiTop, SIDEWIDTH, ySize));
sideWindow = new Window(this, sidePanel);
}
use of mcjty.lib.gui.Window in project RFToolsControl by McJty.
the class GuiCraftingStation method initGui.
@Override
public void initGui() {
super.initGui();
Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(mainBackground);
initRecipeList(toplevel);
initProgressList(toplevel);
initButtons(toplevel);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, WIDTH, HEIGHT));
window = new Window(this, toplevel);
}
Aggregations