Reformat Code

This commit is contained in:
Kam committed 2026-02-18 05:13:51 -05:00
1 parent 21e920426e
commit 1de1c4e710
169 files changed
+3967 -1556

No files matched your search

@@ -2,12 +2,12 @@ package noppes.npcs.client.gui.builder;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.select.GuiAnimationSelection;
import noppes.npcs.client.gui.select.GuiSoundSelection;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.data.Animation;
import java.util.List;
import java.util.function.BooleanSupplier;
@@ -175,8 +175,8 @@ public class FieldDef {
}
public static FieldDef animSubGui(String label,
Supplier<Integer> idGetter, Consumer<Integer> idSetter,
Supplier<String> nameGetter, Consumer<String> nameSetter) {
Supplier<Integer> idGetter, Consumer<Integer> idSetter,
Supplier<String> nameGetter, Consumer<String> nameSetter) {
return subGuiField(label,
() -> new GuiAnimationSelection(idGetter.get(), nameGetter.get()),
gui -> {
@@ -202,7 +202,10 @@ public class FieldDef {
}
return "gui.none";
})
.clearable(() -> { idSetter.accept(-1); nameSetter.accept(""); });
.clearable(() -> {
idSetter.accept(-1);
nameSetter.accept("");
});
}
// ═══════════════════════════════════════════════════════════════════
@@ -264,21 +267,65 @@ public class FieldDef {
// GETTERS
// ═══════════════════════════════════════════════════════════════════
public String getLabel() { return label; }
public FieldType getType() { return type; }
public String getTab() { return tab; }
public boolean isVisible() { return visibleWhen.getAsBoolean(); }
public boolean isEnabled() { return enabledWhen.getAsBoolean(); }
public String getHoverText() { return hoverText; }
public float getMin() { return min; }
public float getMax() { return max; }
public boolean hasRange() { return min != Float.NEGATIVE_INFINITY || max != Float.POSITIVE_INFINITY; }
public Class<? extends Enum<?>> getEnumClass() { return enumClass; }
public String[] getStringEnumValues() { return stringEnumValues; }
public Supplier<SubGuiInterface> getSubGuiFactory() { return subGuiFactory; }
public Consumer<SubGuiInterface> getSubGuiResultHandler() { return subGuiResultHandler; }
public boolean hasClearAction() { return clearAction != null; }
public Runnable getClearAction() { return clearAction; }
public String getLabel() {
return label;
}
public FieldType getType() {
return type;
}
public String getTab() {
return tab;
}
public boolean isVisible() {
return visibleWhen.getAsBoolean();
}
public boolean isEnabled() {
return enabledWhen.getAsBoolean();
}
public String getHoverText() {
return hoverText;
}
public float getMin() {
return min;
}
public float getMax() {
return max;
}
public boolean hasRange() {
return min != Float.NEGATIVE_INFINITY || max != Float.POSITIVE_INFINITY;
}
public Class<? extends Enum<?>> getEnumClass() {
return enumClass;
}
public String[] getStringEnumValues() {
return stringEnumValues;
}
public Supplier<SubGuiInterface> getSubGuiFactory() {
return subGuiFactory;
}
public Consumer<SubGuiInterface> getSubGuiResultHandler() {
return subGuiResultHandler;
}
public boolean hasClearAction() {
return clearAction != null;
}
public Runnable getClearAction() {
return clearAction;
}
public Object getValue() {
return getter != null ? getter.get() : null;
@@ -305,8 +352,13 @@ public class FieldDef {
return buttonTextColorSupplier != null ? buttonTextColorSupplier.get() : null;
}
public FieldDef getLeftChild() { return leftChild; }
public FieldDef getRightChild() { return rightChild; }
public FieldDef getLeftChild() {
return leftChild;
}
public FieldDef getRightChild() {
return rightChild;
}
// ═══════════════════════════════════════════════════════════════════
// LIST MANIPULATION (for mod injection)
@@ -356,7 +408,7 @@ public class FieldDef {
*
* @param fields The field list to modify
* @param targetLabel The label of the field to modify
* @param condition The condition to replace
* @param condition The condition to replace
* @return true if the target was found and the condition was modified
*/
public static boolean modifyVisibility(List<FieldDef> fields, String targetLabel, BooleanSupplier condition) {
@@ -69,13 +69,32 @@ public class GuiFieldBuilder {
// CONFIG CHAINING
// ═══════════════════════════════════════════════════════════════════
public GuiFieldBuilder scrollWindowId(int id) { this.scrollWindowId = id; return this; }
public GuiFieldBuilder contentRight(int v) { this.contentRight = v; return this; }
public GuiFieldBuilder startIds(int widget, int clear, int label) {
this.widgetId = widget; this.clearId = clear; this.labelId = label; return this;
public GuiFieldBuilder scrollWindowId(int id) {
this.scrollWindowId = id;
return this;
}
public GuiFieldBuilder contentRight(int v) {
this.contentRight = v;
return this;
}
public GuiFieldBuilder startIds(int widget, int clear, int label) {
this.widgetId = widget;
this.clearId = clear;
this.labelId = label;
return this;
}
public GuiFieldBuilder startY(int y) {
this.startY = y;
return this;
}
public GuiFieldBuilder rowHeight(int h) {
this.rowHeight = h;
return this;
}
public GuiFieldBuilder startY(int y) { this.startY = y; return this; }
public GuiFieldBuilder rowHeight(int h) { this.rowHeight = h; return this; }
// ═══════════════════════════════════════════════════════════════════
// BUILD
@@ -98,6 +117,7 @@ public class GuiFieldBuilder {
/**
* Processes all fields and adds widgets to the scroll window.
*
* @return the final Y position after all fields
*/
protected int build(List<FieldDef> fields) {
@@ -173,8 +193,14 @@ public class GuiFieldBuilder {
}
private int lastHandledIndex = -1;
protected void setLastHandledIndex(int index) { this.lastHandledIndex = index; }
protected int getLastHandledIndex() { return lastHandledIndex; }
protected void setLastHandledIndex(int index) {
this.lastHandledIndex = index;
}
protected int getLastHandledIndex() {
return lastHandledIndex;
}
// ═══════════════════════════════════════════════════════════════════
// FIELD RENDERING
@@ -268,7 +294,10 @@ public class GuiFieldBuilder {
String curVal = def.getStringEnumValue();
int selected = 0;
for (int i = 0; i < values.length; i++) {
if (values[i].equals(curVal)) { selected = i; break; }
if (values[i].equals(curVal)) {
selected = i;
break;
}
}
GuiNpcButton btn = new GuiNpcButton(widgetId, fieldX, y, fieldW, 20, values, selected);
if (!def.isEnabled()) btn.setEnabled(false);
@@ -321,14 +350,21 @@ public class GuiFieldBuilder {
protected int getFullFieldWidth(FieldDef def) {
switch (def.getType()) {
case FLOAT:
case INT: return 60;
case STRING: return 200;
case BOOLEAN: return 50;
case LABEL: return 60;
case INT:
return 60;
case STRING:
return 200;
case BOOLEAN:
return 50;
case LABEL:
return 60;
case ENUM:
case STRING_ENUM: return 120;
case SUB_GUI: return def.hasClearAction() ? 175 : 200;
default: return 80;
case STRING_ENUM:
return 120;
case SUB_GUI:
return def.hasClearAction() ? 175 : 200;
default:
return 80;
}
}
@@ -410,7 +446,8 @@ public class GuiFieldBuilder {
def.setValue(newVal);
return true;
}
} catch (NumberFormatException ignored) {}
} catch (NumberFormatException ignored) {
}
return false;
case INT:
try {
@@ -421,7 +458,8 @@ public class GuiFieldBuilder {
def.setValue(newVal);
return true;
}
} catch (NumberFormatException ignored) {}
} catch (NumberFormatException ignored) {
}
return false;
case STRING:
String newVal = field.getText();
@@ -453,10 +491,27 @@ public class GuiFieldBuilder {
// GETTERS
// ═══════════════════════════════════════════════════════════════════
public Map<Integer, FieldDef> getButtonFieldMap() { return buttonFieldMap; }
public Map<Integer, FieldDef> getTextFieldMap() { return textFieldMap; }
public Map<Integer, FieldDef> getClearFieldMap() { return clearFieldMap; }
public GuiScrollWindow getScrollWindow() { return sw; }
public int getLastBuildY() { return lastBuildY; }
public int getNextLabelId() { return labelId; }
public Map<Integer, FieldDef> getButtonFieldMap() {
return buttonFieldMap;
}
public Map<Integer, FieldDef> getTextFieldMap() {
return textFieldMap;
}
public Map<Integer, FieldDef> getClearFieldMap() {
return clearFieldMap;
}
public GuiScrollWindow getScrollWindow() {
return sw;
}
public int getLastBuildY() {
return lastBuildY;
}
public int getNextLabelId() {
return labelId;
}
}