Skip to content

Commit

Permalink
Sort Mod Options Alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
notTamion committed Sep 29, 2024
1 parent fe11db0 commit 6df595c
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Celeste.Mod.mm/Mod/UI/OuiModOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public static TextMenu CreateMenu(bool inGame, EventInstance snapshot) {

// reorder Mod Options according to the modoptionsorder.txt file.
List<EverestModule> modules = new List<EverestModule>(Everest._Modules);
// sort by Mod names and move everest to the beginning
EverestModule everest = modules[0];
modules.RemoveAt(0);
modules = modules.OrderBy(module => module.Metadata.Name).ToList();
modules.Insert(0, everest);
if (Everest.Loader._ModOptionsOrder != null && Everest.Loader._ModOptionsOrder.Count > 0) {
foreach (string modName in Everest.Loader._ModOptionsOrder) {
if (modName.Equals("Everest", StringComparison.InvariantCultureIgnoreCase)) {
Expand Down Expand Up @@ -202,15 +207,15 @@ static public Action AddSearchBox(TextMenu menu, Overworld overworld = null) {
string searchTarget = textBox.Text.ToLower();
List<TextMenu.Item> menuItems = ((patch_TextMenu) menu).Items;
bool searchNextPredicate(TextMenu.Item item) {
if (!item.Visible || !item.Selectable || item.Disabled)
return false;
int index = menu.IndexOf(item);
if (index > 0 && (menu as patch_TextMenu).Items[index - 1] is patch_TextMenu.patch_SubHeader subHeader) {
if (subHeader.Title != null && subHeader.Title.ToLower().Contains(searchTarget)) {
return true;
}
}
bool searchNextPredicate(TextMenu.Item item) {
if (!item.Visible || !item.Selectable || item.Disabled)
return false;
int index = menu.IndexOf(item);
if (index > 0 && (menu as patch_TextMenu).Items[index - 1] is patch_TextMenu.patch_SubHeader subHeader) {
if (subHeader.Title != null && subHeader.Title.ToLower().Contains(searchTarget)) {
return true;
}
}
string searchLabel = ((patch_TextMenu.patch_Item) item).SearchLabel();
return searchLabel != null && searchLabel.ToLower().Contains(searchTarget);
}
Expand Down

0 comments on commit 6df595c

Please sign in to comment.