use of mcjty.rftoolscontrol.logic.editors.ParameterEditor 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.rftoolscontrol.logic.editors.ParameterEditor in project RFToolsControl by McJty.
the class GuiProcessor method openValueEditor.
private void openValueEditor(int varIdx) {
if (fromServer_vars == null || varIdx > fromServer_vars.size()) {
return;
}
if (fromServer_vars.get(varIdx) == null) {
GuiTools.showMessage(mc, this, getWindowManager(), 50, 50, "Variable is not defined!");
return;
}
Parameter parameter = fromServer_vars.get(varIdx);
if (parameter == null) {
GuiTools.showMessage(mc, this, getWindowManager(), 50, 50, "Variable is not defined!");
return;
}
ParameterType type = parameter.getParameterType();
ParameterEditor editor = ParameterEditors.getEditor(type);
Panel editPanel;
if (editor != null) {
editPanel = new Panel(mc, this).setLayout(new PositionalLayout()).setFilledRectThickness(1);
editor.build(mc, this, editPanel, o -> {
NBTTagCompound tag = new NBTTagCompound();
ParameterTypeTools.writeToNBT(tag, type, o);
RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketVariableToServer(tileEntity.getPos(), varIdx, tag));
});
editor.writeValue(parameter.getParameterValue());
editor.constantOnly();
} else {
return;
}
Panel panel = new Panel(mc, this).setLayout(new VerticalLayout()).setFilledBackground(0xff666666, 0xffaaaaaa).setFilledRectThickness(1);
panel.setBounds(new Rectangle(50, 50, 200, 60 + editor.getHeight()));
Window modalWindow = getWindowManager().createModalWindow(panel);
panel.addChild(new Label(mc, this).setText("Var " + varIdx + ":"));
panel.addChild(editPanel);
panel.addChild(new Button(mc, this).addButtonEvent(w -> {
getWindowManager().closeWindow(modalWindow);
}).setText("Close"));
}
Aggregations