From ffd2e6607c51d21cb0013ffbe94519e00828c910 Mon Sep 17 00:00:00 2001 From: deirn Date: Mon, 22 Jul 2024 09:20:38 +0700 Subject: [PATCH] fix theme editor attributes (cherry picked from commit 3e57c578fdd870add8e7a4878c66a8a7f0e558c6) --- .../mobius/waila/gui/screen/ThemeEditorScreen.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/mcp/mobius/waila/gui/screen/ThemeEditorScreen.java b/src/main/java/mcp/mobius/waila/gui/screen/ThemeEditorScreen.java index a8efca3ed..c8b6a8fab 100644 --- a/src/main/java/mcp/mobius/waila/gui/screen/ThemeEditorScreen.java +++ b/src/main/java/mcp/mobius/waila/gui/screen/ThemeEditorScreen.java @@ -40,6 +40,8 @@ class ThemeEditorScreen extends ConfigScreen { private ITheme theme; private ConfigListWidget options; + private CategoryEntry themeAttrCategory; + private ButtonEntry refreshButton; private InputValue idVal; private CycleValue typeVal; @@ -96,7 +98,8 @@ public void setValue(String value) { if (options.save(true)) { super.setValue(value); type = Registrar.get().themeTypes.get(new ResourceLocation(value)); - options.children().removeIf(it -> it.category == typeVal.category); + themeAttrCategory.clear(options); + options.children().remove(themeAttrCategory); addTypeProperties(options); options.init(); options.setFocused(this); @@ -140,8 +143,8 @@ public void setValue(String value) { } private void addTypeProperties(ConfigListWidget options) { - var category = new CategoryEntry(Tl.Config.OverlayThemeEditor.ATTRIBUTES); - options.add(options.children().size() - (edit ? 2 : 0), category); + themeAttrCategory = new CategoryEntry(Tl.Config.OverlayThemeEditor.ATTRIBUTES); + options.add(options.children().size() - (edit ? 2 : 0), themeAttrCategory); attrValues.clear(); type2attr.computeIfAbsent(type, t -> new HashMap<>(t.properties.size())); @@ -170,7 +173,7 @@ private void addTypeProperties(ConfigListWidget options) { value.setId(key); attrValues.put(key, TypeUtil.uncheckedCast(value)); - category.with(value); + themeAttrCategory.with(value); }); }