This commit is contained in:
Kam committed 2026-02-21 03:04:19 -05:00
commit 185f06822a
11 files changed
+367 -112

No files matched your search

@@ -245,7 +245,9 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
for (int i = 0; i < conditions.size() && i < MAX_CONDITIONS; i++) {
AbilityCondition cond = conditions.get(i);
String condName = getConditionDisplayName(cond);
sw.addButton(new GuiNpcButton(COND_BASE + i * COND_STRIDE, L_LABEL_X, y, 140, 20, condName));
GuiNpcButton condBtn = new GuiNpcButton(COND_BASE + i * COND_STRIDE, L_LABEL_X, y, 140, 20, condName);
condBtn.hoverableText = cond.getConditionSummary();
sw.addButton(condBtn);
sw.addButton(new GuiNpcButton(COND_BASE + i * COND_STRIDE + 1, L_LABEL_X + 145, y, 40, 20, "gui.edit"));
sw.addButton(new GuiNpcButton(COND_BASE + i * COND_STRIDE + 2, L_LABEL_X + 190, y, 20, 20, "X"));
y += 22;
@@ -31,6 +31,7 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
private static final int BTN_NAMESPACE = 1;
private static final int BTN_CANCEL = 10;
private static final int BTN_DONE = 11;
private static final int TF_SEARCH = 12;
// Left panel
private static final int LEFT_WIDTH = 110;
@@ -39,6 +40,8 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
// Right panel
private static final int RIGHT_GAP = 5;
private String searchText = "";
private AbilityCondition condition;
private AbilityCondition result;
private String selectedTypeId;
@@ -158,11 +161,11 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
GuiNpcTextField.unfocus();
super.initGui();
int y = guiTop + 5;
int leftX = guiLeft + LEFT_MARGIN;
int btnY = guiTop + ySize - 26;
// Namespace filter button (full width at top)
addButton(new GuiNpcButton(BTN_NAMESPACE, guiLeft + LEFT_MARGIN, y, xSize - LEFT_MARGIN * 2, 20, getNamespaceFilterLabel()));
y += 24;
// Namespace filter button (above left scroll only)
addButton(new GuiNpcButton(BTN_NAMESPACE, leftX, guiTop + 5, LEFT_WIDTH, 20, getNamespaceFilterLabel()));
// Build filtered type list
filteredTypeIds = getFilteredTypes();
@@ -171,22 +174,28 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
for (String typeId : filteredTypeIds) {
Supplier<AbilityCondition> factory = AbilityController.Instance.getConditionType(typeId);
String displayName = factory != null ? I18n.format(factory.get().getName()) : typeId;
if (!searchText.isEmpty() && !displayName.toLowerCase().contains(searchText.toLowerCase())) continue;
scrollList.add(displayName);
displayNameToTypeId.put(displayName, typeId);
}
// Left panel: condition type scroll list
int scrollHeight = ySize - 58;
scroll = new GuiCustomScroll(this, 0);
scroll.guiLeft = guiLeft + LEFT_MARGIN;
scroll.guiTop = y;
// Left panel: condition type scroll list (between namespace button and search bar)
int scrollTop = guiTop + 29;
int scrollBottom = btnY - 24;
int scrollHeight = scrollBottom - scrollTop;
if (scroll == null) {
scroll = new GuiCustomScroll(this, 0);
}
scroll.guiLeft = leftX;
scroll.guiTop = scrollTop;
scroll.setSize(LEFT_WIDTH, scrollHeight);
scroll.setUnsortedList(scrollList);
// Pre-select current condition type in scroll
if (selectedTypeId != null) {
for (int i = 0; i < filteredTypeIds.length; i++) {
if (filteredTypeIds[i].equals(selectedTypeId)) {
for (int i = 0; i < scrollList.size(); i++) {
String typeId = displayNameToTypeId.get(scrollList.get(i));
if (typeId != null && typeId.equals(selectedTypeId)) {
scroll.selected = i;
break;
}
@@ -194,9 +203,16 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
}
addScroll(scroll);
// Right panel: condition config via FieldDef
int rightX = guiLeft + LEFT_MARGIN + LEFT_WIDTH + RIGHT_GAP;
// Search text field (below left scroll)
GuiNpcTextField searchField = new GuiNpcTextField(TF_SEARCH, this, fontRendererObj, leftX, scrollBottom + 2, LEFT_WIDTH, 20, searchText);
searchField.setHoverText("gui.search");
addTextField(searchField);
// Right panel: condition config via FieldDef (full height from top to buttons)
int rightX = leftX + LEFT_WIDTH + RIGHT_GAP;
int rightW = xSize - LEFT_MARGIN * 2 - LEFT_WIDTH - RIGHT_GAP;
int rightTop = guiTop + 5;
int rightHeight = btnY - rightTop - 4;
List<FieldDef> fields = new ArrayList<>();
if (condition != null) {
@@ -205,13 +221,17 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
builder = new AbilityFieldBuilder(this, fontRendererObj);
builder.startIds(DECLARATIVE_ID_START, CLEAR_ID_START, LABEL_ID_START);
builder.contentRight(rightW);
builder.startY(5);
builder.buildScrollWindow(fields, rightX, y, rightW, scrollHeight);
builder.buildScrollWindow(fields, rightX, rightTop, rightW, rightHeight);
// Bottom buttons
int btnY = guiTop + ySize - 26;
addButton(new GuiNpcButton(BTN_CANCEL, guiLeft + LEFT_MARGIN, btnY, 60, 20, "gui.cancel"));
addButton(new GuiNpcButton(BTN_DONE, guiLeft + xSize - LEFT_MARGIN - 60, btnY, 60, 20, "gui.done"));
addButton(new GuiNpcButton(BTN_CANCEL, leftX, btnY, 60, 20, "gui.cancel"));
GuiNpcButton doneBtn = new GuiNpcButton(BTN_DONE, guiLeft + xSize - LEFT_MARGIN - 60, btnY, 60, 20, "gui.done");
if (condition == null || !condition.isConfigured()) {
doneBtn.setEnabled(false);
}
addButton(doneBtn);
}
@Override
@@ -263,6 +283,14 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
@Override
public void unFocused(GuiNpcTextField textField) {
if (textField.id == TF_SEARCH) {
String newText = textField.getText();
if (!newText.equals(searchText)) {
searchText = newText;
initGui();
}
return;
}
if (textField.id < DECLARATIVE_ID_START) return;
if (builder != null && builder.handleTextFieldEvent(textField.id, textField)) {
initGui();
@@ -344,6 +344,9 @@ public class GuiFieldBuilder {
String translated = StatCollector.translateToLocal(def.getLabel());
int labelW = fontRenderer.getStringWidth(translated);
int fieldX = colLLabel + labelW + labelPadding;
// Clamp field width so it doesn't extend under the scrollbar
int maxW = contentRight - fieldX - 15;
if (maxW > 0 && fieldW > maxW) fieldW = maxW;
renderFieldAt(def, colLLabel, fieldX, fieldW, y);
}