Преглед изворни кода

Fix being able to interact with entries in sub-category when it is closed.

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel пре 5 година
родитељ
комит
503596cf08

+ 1 - 1
gradle.properties

@@ -2,6 +2,6 @@ minecraft_version=20w12a
 yarn_mappings=20w12a+build.3
 loader_version=0.7.8+build.186
 fabric_version=0.5.4+build.310-1.16
-mod_version=3.3-unstable
+mod_version=3.3.1-unstable
 modmenu_version=1.11.0+build.2
 nec_version=1.2.3+1.15.1

+ 6 - 0
src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java

@@ -20,6 +20,7 @@ import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 import java.util.function.Consumer;
@@ -136,6 +137,11 @@ public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends Base
     
     @Override
     public List<? extends Element> children() {
+        if (!expanded) {
+            List<Element> elements = new ArrayList<>(widgets);
+            elements.removeAll(cells);
+            return elements;
+        }
         return widgets;
     }
     

+ 9 - 1
src/main/java/me/shedaniel/clothconfig2/gui/entries/MultiElementListEntry.java

@@ -15,6 +15,7 @@ import net.minecraft.sound.SoundEvents;
 import net.minecraft.util.Identifier;
 import org.jetbrains.annotations.ApiStatus;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
@@ -115,9 +116,16 @@ public class MultiElementListEntry<T> extends TooltipListEntry<T> {
         return 24;
     }
     
+    @Override
+    public void updateSelected(boolean isSelected) {
+        for (AbstractConfigListEntry<?> entry : entries) {
+            entry.updateSelected(expanded && isSelected && getFocused() == entry);
+        }
+    }
+    
     @Override
     public List<? extends Element> children() {
-        return children;
+        return expanded ? children : Collections.singletonList(widget);
     }
     
     @Override

+ 2 - 1
src/main/java/me/shedaniel/clothconfig2/gui/entries/SubCategoryListEntry.java

@@ -14,6 +14,7 @@ import net.minecraft.client.sound.PositionedSoundInstance;
 import net.minecraft.sound.SoundEvents;
 import net.minecraft.util.Identifier;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 
@@ -119,7 +120,7 @@ public class SubCategoryListEntry extends TooltipListEntry<List<AbstractConfigLi
     
     @Override
     public List<? extends Element> children() {
-        return children;
+        return expanded ? children : Collections.singletonList(widget);
     }
     
     @Override