Skip to content

Add mod list sorting system#971

Draft
r6915ee wants to merge 1 commit intoCodenameCrew:mainfrom
r6915ee:feature/mod-sorting
Draft

Add mod list sorting system#971
r6915ee wants to merge 1 commit intoCodenameCrew:mainfrom
r6915ee:feature/mod-sorting

Conversation

@r6915ee
Copy link
Copy Markdown
Contributor

@r6915ee r6915ee commented May 1, 2026

The mods list can now be sorted in-engine with a cache to come with it.

From the commit message:

ModsFolder.getModsList now has an optional parameter to describe the various sorting
options. Excluding this option produces rather legacy behavior and should be
backwards-compatible.

Sorted mod lists get cached under a so-called "sort forge," which writes the key to use
in the cache. If a cache hit occurs, then ModsFolder.getModsList will use the hit.

Currently, there is support for ascending/descending order and two modes: clean and
alphabetical sorting. Clean mode provides legacy behavior using this new system, and
alphabetical sorting uses CoolUtil to sort the list.

ModSwitchMenu has been updated to use this new system, but really, the only noticeable
change should just be additional memory overhead.

The primary use case for this would be for extending the mods switch menu to support multiple sorting options, all while being performant in the long run, especially with larger mods lists. The caching in particular assists in this by avoiding the overuse of sorting, doing so only once.

The system should be able to add more sorting mechanisms easily, just by adding the mode to the main enumerator and adding support for the mode in ModSortingController. Of course, this does believe that the raw output of the sort is in ascending order, as descending order takes higher priority. These likely will need to come in succeeding pull requests, though, since (as of writing) I don't have any plans to add additional sorting modes in this pull request.

ModsFolder.getModsList now has an optional parameter to describe the
various sorting
options. Excluding this option produces rather legacy behavior and
should be
backwards-compatible.

Sorted mod lists get cached under a so-called "sort forge," which writes
the key to use
in the cache. If a cache hit occurs, then ModsFolder.getModsList will
use the hit.

Currently, there is support for ascending/descending order and two
modes: clean and
alphabetical sorting. Clean mode provides legacy behavior using this new
system, and
alphabetical sorting uses CoolUtil to sort the list.

ModSwitchMenu has been updated to use this new system, but really, the
only noticeable
change should just be additional memory overhead.
@r6915ee
Copy link
Copy Markdown
Contributor Author

r6915ee commented May 1, 2026

This is currently set as a draft pull request, because there's one tiny change I want to make, and that is to move the mode ID function over to the controller. However, it's likely going to come tomorrow where I'm at, since it's getting far too late as I'm writing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant