use of mcjty.lib.gui.icons.IIcon in project RFToolsControl by McJty.
the class GuiProgrammer method tryConnectToThis.
private void tryConnectToThis(int x, int y, IIcon icon, Connection connection) {
if (x < 0 || x >= GRID_WIDTH) {
return;
}
if (y < 0 || y >= GRID_HEIGHT) {
return;
}
IconHolder holder = getHolder(x, y);
IIcon sourceIcon = holder.getIcon();
if (sourceIcon != null) {
Opcode opcode = Opcodes.OPCODES.get(sourceIcon.getID());
if (opcode.getOpcodeOutput() == OpcodeOutput.NONE) {
return;
} else if (opcode.getOpcodeOutput() == OpcodeOutput.SINGLE) {
int cnt = countConnections(sourceIcon);
if (cnt == 0) {
sourceIcon.addOverlay(CONNECTION_ICONS.get(connection));
}
} else if (opcode.getOpcodeOutput() == OpcodeOutput.YESNO) {
int cnt = countPrimaryConnections(sourceIcon);
if (cnt == 0) {
sourceIcon.addOverlay(CONNECTION_ICONS.get(connection));
} else {
cnt = countSecondaryConnections(sourceIcon);
if (cnt == 0) {
sourceIcon.addOverlay(CONNECTION_ICONS.get(connection.getOpposite()));
}
}
}
}
}
use of mcjty.lib.gui.icons.IIcon in project RFToolsControl by McJty.
the class GuiProgrammer method selectSequence.
private void selectSequence(GridPos pos, Set<GridPos> done, boolean select) {
if (!checkValidGridPos(pos)) {
return;
}
if (done.contains(pos)) {
return;
}
IIcon icon = getHolder(pos.getX(), pos.getY()).getIcon();
if (icon == null) {
return;
}
icon.removeOverlay("S");
if (select) {
icon.addOverlay(selectionIcon);
}
done.add(pos);
selectSequence(pos.up(), done, select);
selectSequence(pos.down(), done, select);
selectSequence(pos.left(), done, select);
selectSequence(pos.right(), done, select);
}
use of mcjty.lib.gui.icons.IIcon in project RFToolsControl by McJty.
the class GuiProgrammer method createValuePanel.
private Panel createValuePanel(ParameterDescription parameter, IIcon icon, IconHolder iconHolder, String tempDefault, boolean constantOnly) {
Label<?> label = (Label<?>) new Label(mc, this).setText(StringUtils.capitalize(parameter.getName()) + ":").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredHeight(13).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 53, 13));
List<String> description = new ArrayList<>(parameter.getDescription());
if (parameter.isOptional()) {
description.set(description.size() - 1, description.get(description.size() - 1) + TextFormatting.GOLD + " [Optional]");
}
if (tempDefault != null && !tempDefault.isEmpty()) {
description.add(TextFormatting.BLUE + tempDefault);
}
String[] tooltips = description.toArray(new String[description.size()]);
TextField field = new TextField(mc, this).setText(tempDefault).setTooltips(tooltips).setDesiredHeight(13).setEditable(false).setLayoutHint(new PositionalLayout.PositionalHint(0, 12, 68, 13));
Button button = new Button(mc, this).setText("...").setDesiredHeight(13).setTooltips(tooltips).addButtonEvent(w -> openValueEditor(icon, iconHolder, parameter, field, constantOnly)).setLayoutHint(new PositionalLayout.PositionalHint(58, 0, 11, 13));
return new Panel(mc, this).setLayout(new PositionalLayout()).addChild(label).addChild(field).addChild(button).setDesiredWidth(68);
}
Aggregations