@@ -67,7 +67,7 @@ public class MoulConfigEditor<T extends Config> extends GuiElement {
6767 @ Setter
6868 private SearchFunction searchFunction = GuiOptionEditor ::fulfillsSearch ;
6969
70- private LinkedHashMap <String , ProcessedCategory > currentlyVisibleCategories ;
70+ private LinkedHashMap <String , ? extends ProcessedCategory > currentlyVisibleCategories ;
7171 private Set <ProcessedOption > currentlyVisibleOptions ;
7272 private Map <String , Set <String >> childCategoryLookup = new HashMap <>();
7373 private List <ProcessedOption > allOptions = new ArrayList <>();
@@ -76,10 +76,10 @@ public MoulConfigEditor(MoulConfigProcessor<T> processedConfig) {
7676 processedConfig .requireFinalized ();
7777 this .openedMillis = System .currentTimeMillis ();
7878 this .processedConfig = processedConfig ;
79- for (Map .Entry <String , ProcessedCategory > category : processedConfig .getAllCategories ().entrySet ()) {
80- allOptions .addAll (category .getValue ().options );
81- if (category .getValue ().parent != null ) {
82- childCategoryLookup .computeIfAbsent (category .getValue ().parent , ignored -> new HashSet <>())
79+ for (Map .Entry <String , ? extends ProcessedCategory > category : processedConfig .getAllCategories ().entrySet ()) {
80+ allOptions .addAll (category .getValue ().getOptions () );
81+ if (category .getValue ().getParentCategoryId () != null ) {
82+ childCategoryLookup .computeIfAbsent (category .getValue ().getParentCategoryId () , ignored -> new HashSet <>())
8383 .add (category .getKey ());
8484 }
8585 }
@@ -91,7 +91,7 @@ public MoulConfigEditor(MoulConfigProcessor<T> processedConfig) {
9191 }
9292
9393 private List <ProcessedOption > getOptionsInCategory (ProcessedCategory cat ) {
94- List <ProcessedOption > options = new ArrayList <>(cat .options );
94+ List <ProcessedOption > options = new ArrayList <>(cat .getOptions () );
9595 options .removeIf (it -> !currentlyVisibleOptions .contains (it ));
9696 return options ;
9797 }
@@ -107,7 +107,7 @@ public boolean scrollOptionIntoView(ProcessedOption searchedOption, int timeToRe
107107 // Recursively expand accordions this option is in
108108 var accordionP = searchedOption ;
109109 while (accordionP .getAccordionId () >= 0 ) {
110- accordionP = processedCategory .accordionAnchors .get (accordionP .getAccordionId ());
110+ accordionP = processedCategory .getAccordionAnchors () .get (accordionP .getAccordionId ());
111111 ((GuiOptionEditorAccordion ) accordionP .getEditor ()).setToggled (true );
112112 }
113113
@@ -169,7 +169,7 @@ private void propagateSearchinessForAccordions(Set<ProcessedOption> options, Set
169169
170170 for (ProcessedOption option : lastRound ) {
171171 if (option .getAccordionId () >= 0 && upwards ) {
172- for (ProcessedOption accordion : option .getCategory ().options ) {
172+ for (ProcessedOption accordion : option .getCategory ().getOptions () ) {
173173 if (accordion == option ) continue ;
174174 if (!(accordion .getEditor () instanceof GuiOptionEditorAccordion )) continue ;
175175 if (((GuiOptionEditorAccordion ) accordion .getEditor ()).getAccordionId () == option .getAccordionId ()) {
@@ -179,7 +179,7 @@ private void propagateSearchinessForAccordions(Set<ProcessedOption> options, Set
179179 }
180180 if (option .getEditor () instanceof GuiOptionEditorAccordion && !upwards ) {
181181 int parentId = ((GuiOptionEditorAccordion ) option .getEditor ()).getAccordionId ();
182- for (ProcessedOption potentialChild : option .getCategory ().options ) {
182+ for (ProcessedOption potentialChild : option .getCategory ().getOptions () ) {
183183 if (potentialChild .getAccordionId () == parentId ) {
184184 nextRound .add (potentialChild );
185185 }
@@ -201,7 +201,7 @@ public void updateSearchResults(boolean recalculateOptionUniverse) {
201201 if (recalculateOptionUniverse ) {
202202 allOptions .clear ();
203203 for (ProcessedCategory category : processedConfig .getAllCategories ().values ()) {
204- allOptions .addAll (category .options );
204+ allOptions .addAll (category .getOptions () );
205205 }
206206 }
207207 String toSearch = searchFieldContent .get ().trim ().toLowerCase (Locale .ROOT );
@@ -214,14 +214,15 @@ public void updateSearchResults(boolean recalculateOptionUniverse) {
214214 HashSet <ProcessedCategory > directlyMatchedCategories = new HashSet <>(processedConfig .getAllCategories ().values ());
215215 if (!processedConfig .getConfigObject ().shouldSearchCategoryNames ()) directlyMatchedCategories .clear ();
216216 for (String word : toSearch .split (" +" )) {
217- directlyMatchedCategories .removeIf (it -> ContextAware .wrapErrorWithContext (it .reflectField ,
218- () -> !(it .name .toLowerCase (Locale .ROOT ).contains (word ) || it .desc .toLowerCase (Locale .ROOT ).contains (word ))));
217+ directlyMatchedCategories .removeIf (it -> ContextAware .wrapErrorWithContext (it ,
218+ () -> !(it .getDisplayName ().toLowerCase (Locale .ROOT ).contains (word )
219+ || it .getDescription ().toLowerCase (Locale .ROOT ).contains (word ))));
219220 }
220221
221222 Set <ProcessedOption > matchingOptionsAndDependencies = new HashSet <>();
222223
223224 var childCategoriesOfDirectlyMatched = directlyMatchedCategories .stream ()
224- .flatMap (it -> childCategoryLookup .getOrDefault (it .name , Collections .emptySet ()).stream ())
225+ .flatMap (it -> childCategoryLookup .getOrDefault (it .getIdentifier () , Collections .emptySet ()).stream ())
225226 .map (processedConfig .getAllCategories ()::get )
226227 .filter (Objects ::nonNull )
227228 .collect (Collectors .toList ());
@@ -230,18 +231,21 @@ public void updateSearchResults(boolean recalculateOptionUniverse) {
230231 // No search propagation needed if category is matched.
231232 // Add them directly to the final visible option set.
232233 for (ProcessedCategory directCategory : directlyMatchedCategories ) {
233- matchingOptionsAndDependencies .addAll (directCategory .options );
234- directCategory .options .forEach (matchingOptions ::remove );
234+ matchingOptionsAndDependencies .addAll (directCategory .getOptions () );
235+ directCategory .getOptions () .forEach (matchingOptions ::remove );
235236 }
236237
237238 propagateSearchinessForAccordions (matchingOptionsAndDependencies , matchingOptions , true );
238239 propagateSearchinessForAccordions (matchingOptionsAndDependencies , matchingOptions , false );
239240
240241 currentlyVisibleOptions = matchingOptionsAndDependencies ;
241242
242- Set <ProcessedCategory > visibleCategories = matchingOptionsAndDependencies .stream ().map (it -> it .getCategory ()).collect (Collectors .toSet ());
243+ Set <ProcessedCategory > visibleCategories = matchingOptionsAndDependencies
244+ .stream ()
245+ .map (ProcessedOption ::getCategory ).collect (Collectors .toSet ());
243246 Set <ProcessedCategory > parentCategories = visibleCategories .stream ()
244- .filter (it -> it .parent != null ).map (it -> processedConfig .getAllCategories ().get (it .parent ))
247+ .filter (it -> it .getParentCategoryId () != null )
248+ .map (it -> processedConfig .getAllCategories ().get (it .getParentCategoryId ()))
245249 .filter (Objects ::nonNull ).collect (Collectors .toSet ());
246250 visibleCategories .addAll (parentCategories );
247251 LinkedHashMap <String , ProcessedCategory > matchingCategories = new LinkedHashMap <>(processedConfig .getAllCategories ());
@@ -254,21 +258,21 @@ public void updateSearchResults(boolean recalculateOptionUniverse) {
254258 }
255259
256260 public LinkedHashMap <String , ProcessedCategory > getCurrentlyVisibleCategories () {
257- var newHashes = new LinkedHashMap <>(currentlyVisibleCategories );
261+ var newHashes = new LinkedHashMap <String , ProcessedCategory >(currentlyVisibleCategories );
258262 newHashes .entrySet ().removeIf (it -> {
259- if (it .getValue ().parent == null ) return false ;
263+ if (it .getValue ().getParentCategoryId () == null ) return false ;
260264 if (!showSubcategories ) return true ;
261- if (it .getValue ().parent .equals (getSelectedCategory ())) return false ;
265+ if (it .getValue ().getParentCategoryId () .equals (getSelectedCategory ())) return false ;
262266 var processedCategory = currentlyVisibleCategories .get (getSelectedCategory ());
263267 if (processedCategory == null ) return true ;
264268 //noinspection RedundantIfStatement
265- if (it .getValue ().parent .equals (processedCategory .parent )) return false ;
269+ if (it .getValue ().getParentCategoryId () .equals (processedCategory .getParentCategoryId () )) return false ;
266270 return true ;
267271 });
268272 return newHashes ;
269273 }
270274
271- public LinkedHashMap <String , ProcessedCategory > getCurrentlySearchedCategories () {
275+ public LinkedHashMap <String , ? extends ProcessedCategory > getCurrentlySearchedCategories () {
272276 return currentlyVisibleCategories ;
273277 }
274278
@@ -378,7 +382,7 @@ public void render() {
378382 var catName = processedConfig .getConfigObject ().formatCategoryName (entry .getValue (), isSelected );
379383 var align = processedConfig .getConfigObject ().alignCategory (entry .getValue (), isSelected );
380384 var textLength = ifr .getStringWidth (catName );
381- var isIndented = childCategories != null || entry .getValue ().parent != null ;
385+ var isIndented = childCategories != null || entry .getValue ().getParentCategoryId () != null ;
382386 if (textLength > ((isIndented ) ? 90 : 100 )) {
383387 context .drawStringCenteredScaledMaxWidth (catName ,
384388 ifr , x + 75 + (isIndented ? 5 : 0 ), y + 70 + catY , false , (isIndented ? 90 : 100 ), -1
@@ -477,7 +481,7 @@ public void render() {
477481 ProcessedCategory cat = currentConfigEditing .get (getSelectedCategory ());
478482
479483 context .drawStringScaledMaxWidth (
480- cat .desc ,
484+ cat .getDescription () ,
481485 ifr , innerLeft + 1 , y + 40 , true , innerRight - innerLeft - rightStuffLen - 10 , 0xb0b0b0
482486 );
483487 }
@@ -865,7 +869,7 @@ public boolean mouseInput(int mouseX, int mouseY, MouseEvent mouseEvent) {
865869 if (mouseX >= x + 5 && mouseX <= x + 145 &&
866870 mouseY >= y + 70 + catY - 7 && mouseY <= y + 70 + catY + 7 ) {
867871 if (entry .getKey ().equals (getSelectedCategory ())) {
868- if (entry .getValue ().parent == null )
872+ if (entry .getValue ().getParentCategoryId () == null )
869873 showSubcategories = !showSubcategories ;
870874 } else {
871875 showSubcategories = true ;
0 commit comments