use of mcjty.rftoolscontrol.api.parameters.ParameterValue in project RFToolsControl by McJty.
the class GuiProgrammer method makeGridInstance.
private ProgramCardInstance makeGridInstance(boolean selectionOnly) {
ProgramCardInstance instance = ProgramCardInstance.newInstance();
for (int x = 0; x < GRID_WIDTH; x++) {
for (int y = 0; y < GRID_HEIGHT; y++) {
IconHolder holder = getHolder(x, y);
IIcon icon = holder.getIcon();
if (icon != null) {
if (selectionOnly && !icon.hasOverlay("S")) {
continue;
}
String operandId = icon.getID();
GridInstance.Builder builder = GridInstance.builder(operandId);
for (Connection connection : Connection.values()) {
if (icon.hasOverlay(connection.getId())) {
if (connection.isPrimary()) {
builder.primaryConnection(connection);
} else {
builder.secondaryConnection(connection);
}
}
}
Opcode opcode = Opcodes.OPCODES.get(operandId);
Map<String, Object> data = icon.getData();
for (ParameterDescription description : opcode.getParameters()) {
ParameterValue value = data == null ? null : (ParameterValue) data.get(description.getName());
if (value == null) {
value = ParameterValue.constant(null);
}
Parameter parameter = Parameter.builder().type(description.getType()).value(value).build();
builder.parameter(parameter);
}
instance.putGridInstance(x, y, builder.build());
}
}
}
return instance;
}
use of mcjty.rftoolscontrol.api.parameters.ParameterValue in project RFToolsControl by McJty.
the class GuiProgrammer method getIconTooltipGrid.
private List<String> getIconTooltipGrid(int x, int y) {
IconHolder holder = getHolder(x, y);
IIcon icon = holder.getIcon();
if (icon != null) {
Opcode opcode = Opcodes.OPCODES.get(icon.getID());
List<String> description = opcode.getDescription();
List<String> tooltips = new ArrayList<>();
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
tooltips.add(description.get(0) + TextFormatting.WHITE + " [" + x + "," + y + "]");
Map<String, Object> data = icon.getData() == null ? Collections.emptyMap() : icon.getData();
for (ParameterDescription parameter : opcode.getParameters()) {
String name = parameter.getName();
ParameterValue value = (ParameterValue) data.get(name);
if (value != null) {
tooltips.add(TextFormatting.BLUE + "Par " + name + ": " + ParameterTypeTools.stringRepresentation(parameter.getType(), value));
} else {
tooltips.add(TextFormatting.BLUE + "Par " + name + ": NULL");
}
}
} else {
tooltips.add(description.get(0));
tooltips.add("<Shift for more info>");
}
return tooltips;
}
return Collections.emptyList();
}
use of mcjty.rftoolscontrol.api.parameters.ParameterValue in project RFToolsControl by McJty.
the class GuiProgrammer method setEditorPanel.
private void setEditorPanel(IconHolder iconHolder, IIcon icon) {
String id = icon.getID();
Opcode opcode = Opcodes.OPCODES.get(id);
Map<String, Object> data = icon.getData() == null ? Collections.emptyMap() : icon.getData();
clearEditorPanel();
for (ParameterDescription parameter : opcode.getParameters()) {
String name = parameter.getName();
ParameterValue value = (ParameterValue) data.get(name);
Panel panel;
if (value != null) {
panel = createValuePanel(parameter, icon, iconHolder, ParameterTypeTools.stringRepresentation(parameter.getType(), value), opcode.isEvent());
} else {
panel = createValuePanel(parameter, icon, iconHolder, "", opcode.isEvent());
}
editorList.addChild(panel);
}
}
Aggregations