Add mod list sorting system#971
Draft
r6915ee wants to merge 1 commit intoCodenameCrew:mainfrom
Draft
Conversation
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.
Contributor
Author
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The mods list can now be sorted in-engine with a cache to come with it.
From the commit message:
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.