Sort selector lists alphabetically

This commit is contained in:
Jarrod Doyle 2024-08-18 14:01:09 +01:00
parent 6db4d75a37
commit dbabe1527c
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 6 additions and 4 deletions

View File

@ -60,7 +60,8 @@ public partial class MissionSelector : Control
_LoadButton.Disabled = true; _LoadButton.Disabled = true;
_Campaigns.AddItem("Original Missions"); _Campaigns.AddItem("Original Missions");
foreach (var c in Directory.GetDirectories(_installPaths.fmsPath)) var paths = Directory.GetDirectories(_installPaths.fmsPath);
foreach (var c in paths.OrderBy(s => s))
{ {
_Campaigns.AddItem(c.TrimPrefix(_installPaths.fmsPath)); _Campaigns.AddItem(c.TrimPrefix(_installPaths.fmsPath));
} }
@ -82,8 +83,8 @@ public partial class MissionSelector : Control
} }
string[] extensions = { "mis", "cow" }; string[] extensions = { "mis", "cow" };
campaignPath = idx == 0 ? _installPaths.omsPath : _installPaths.fmsPath + _Campaigns.GetItemText((int)idx); var paths = Directory.GetFiles(campaignPath);
foreach (var f in Directory.GetFiles(campaignPath)) foreach (var f in paths.OrderBy(s => s))
{ {
if (extensions.Contains(f.GetExtension().ToLower())) if (extensions.Contains(f.GetExtension().ToLower()))
{ {

View File

@ -59,7 +59,8 @@ public partial class ModelSelector : Control
_Models.Clear(); _Models.Clear();
_LoadButton.Disabled = true; _LoadButton.Disabled = true;
foreach (var m in Directory.GetFiles(_extractedObjectsPath, "*.bin", SearchOption.AllDirectories)) var paths = Directory.GetFiles(_extractedObjectsPath, "*.bin", SearchOption.AllDirectories);
foreach (var m in paths.OrderBy(s => s))
{ {
_Models.AddItem(m.TrimPrefix(_extractedObjectsPath)); _Models.AddItem(m.TrimPrefix(_extractedObjectsPath));
} }