Skip to content

Commit

Permalink
fix theme editor attributes
Browse files Browse the repository at this point in the history
(cherry picked from commit 3e57c57)
  • Loading branch information
deirn committed Jul 22, 2024
1 parent 0d95015 commit b270174
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/mcp/mobius/waila/gui/screen/ThemeEditorScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class ThemeEditorScreen extends ConfigScreen {
private ITheme theme;

private ConfigListWidget options;
private CategoryEntry themeAttrCategory;

private ButtonEntry refreshButton;
private InputValue<String> idVal;
private CycleValue typeVal;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -170,7 +173,7 @@ private void addTypeProperties(ConfigListWidget options) {
value.setId(key);
attrValues.put(key, TypeUtil.uncheckedCast(value));

category.with(value);
themeAttrCategory.with(value);
});
}

Expand Down

0 comments on commit b270174

Please sign in to comment.