mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 09:12:22 +00:00
Manual Positioning
This commit is contained in:
1 parent
48f7380913
commit
578a6ec43a
4 files changed
+37
-4
No files matched your search
@@ -76,13 +76,22 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe
|
||||
|
||||
y += 27;
|
||||
|
||||
// Labels and text fields for editing the selected association's ordering data.
|
||||
addLabel(new GuiNpcLabel(50, "magic.index", guiLeft + 5, y + 5));
|
||||
String index = "gui.unused";
|
||||
String priority = "gui.unused";
|
||||
if(cycle.layout == EnumDiagramLayout.MANUAL) {
|
||||
index = "X";
|
||||
priority = "Y";
|
||||
} else if(cycle.layout.isManual()) {
|
||||
index = "magic.index";
|
||||
priority = "magic.priority";
|
||||
}
|
||||
|
||||
addLabel(new GuiNpcLabel(50, index, guiLeft + 5, y + 5));
|
||||
indexField = new GuiNpcTextField(91, this, fontRendererObj, guiLeft + 100, y, 45, 20, "");
|
||||
indexField.setIntegersOnly();
|
||||
addTextField(indexField);
|
||||
|
||||
addLabel(new GuiNpcLabel(51, "magic.priority", guiLeft + 150, y + 5));
|
||||
addLabel(new GuiNpcLabel(51, priority, guiLeft + 150, y + 5));
|
||||
priorityField = new GuiNpcTextField(92, this, fontRendererObj, guiLeft + 250, y, 45, 20, "");
|
||||
priorityField.setIntegersOnly();
|
||||
addTextField(priorityField);
|
||||
@@ -90,6 +99,13 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe
|
||||
indexField.enabled = false;
|
||||
priorityField.enabled = false;
|
||||
|
||||
if (selectedAssociation != null && associationMap.containsKey(selectedAssociation)) {
|
||||
indexField.enabled = true;
|
||||
priorityField.enabled = true;
|
||||
indexField.setText(associationMap.get(selectedAssociation).index + "");
|
||||
priorityField.setText(associationMap.get(selectedAssociation).priority + "");
|
||||
}
|
||||
|
||||
y += 27;
|
||||
|
||||
// --- Association Management ---
|
||||
@@ -133,6 +149,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe
|
||||
// Layout button: update cycle layout.
|
||||
if (button.id == 13) {
|
||||
cycle.layout = EnumDiagramLayout.values()[((GuiNpcButton) button).getValue()];
|
||||
initGui();
|
||||
}
|
||||
// Add single association
|
||||
if (button.id == 60 && allMagic.hasSelected() && !associationMap.containsKey(allMagic.getSelected())
|
||||
|
||||
@@ -179,6 +179,9 @@ public abstract class GuiDiagram extends Gui {
|
||||
case TREE_MANUAL:
|
||||
cachedPositions = calculateTreeManualPositions();
|
||||
break;
|
||||
case MANUAL:
|
||||
cachedPositions = calculateManualPositions();
|
||||
break;
|
||||
default:
|
||||
cachedPositions = calculateCircularPositions();
|
||||
break;
|
||||
@@ -186,6 +189,16 @@ public abstract class GuiDiagram extends Gui {
|
||||
return cachedPositions;
|
||||
}
|
||||
|
||||
protected Map<Integer, Point> calculateManualPositions() {
|
||||
Map<Integer, Point> positions = new HashMap<>();
|
||||
int centerX = x + width / 2;
|
||||
int centerY = y + height / 2;
|
||||
for (DiagramIcon icon : getIcons()) {
|
||||
positions.put(icon.id, new Point(centerX + icon.index, centerY + icon.priority));
|
||||
}
|
||||
return positions;
|
||||
}
|
||||
|
||||
// --- Standard Layout Methods ---
|
||||
|
||||
// Circular: use the full available radius so that outer icons are flush with bounds.
|
||||
|
||||
@@ -10,7 +10,8 @@ public enum EnumDiagramLayout {
|
||||
CIRCULAR_MANUAL("diagram.circular_manual"),
|
||||
SQUARE_MANUAL("diagram.square_manual"),
|
||||
TREE_MANUAL("diagram.tree_manual"),
|
||||
CHART("diagram.chart");
|
||||
CHART("diagram.chart"),
|
||||
MANUAL("diagram.manual");
|
||||
|
||||
private String lang;
|
||||
|
||||
|
||||
Reference in new issue
Block a user