From 05b740802859461c92da3f10cf330e7329b9f5dd Mon Sep 17 00:00:00 2001 From: GyroPlatter Date: Sat, 25 Oct 2025 11:44:03 -0400 Subject: [PATCH] ListBox: Show full build for internal installs, simplified for public --- Falcon BMS Alternative Launcher/AppRegInfo.cs | 58 +++++++++++++++++-- .../Windows/MainWindow.xaml.cs | 8 ++- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/Falcon BMS Alternative Launcher/AppRegInfo.cs b/Falcon BMS Alternative Launcher/AppRegInfo.cs index af3b1a1..58b1c29 100644 --- a/Falcon BMS Alternative Launcher/AppRegInfo.cs +++ b/Falcon BMS Alternative Launcher/AppRegInfo.cs @@ -37,6 +37,7 @@ public class AppRegInfo private MainWindow mainWindow; public string theaterOwnConfig = ""; + private string currentExeFourPartVersion = ""; // Method public string GetInstallDir() { return installDir; } @@ -78,7 +79,7 @@ public AppRegInfo(MainWindow window) var foundVersions = new List(10); foreach (string version in availableBMSVersions) { - if (Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Benchmark Sims\\" + version, writable:false) == null) + if (Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Benchmark Sims\\" + version, writable: false) == null) continue; if (BMSExists(version)) @@ -90,11 +91,52 @@ public AppRegInfo(MainWindow window) return; } - // Sort order: most recent releases on top. + // Sort order: most recent releases on top (by the registry-key strings). foundVersions.Sort((a, b) => { return -1 * String.CompareOrdinal(a, b); }); - // Data-bind the list to the UI control. - mainWindow.ListBox_BMS.ItemsSource = foundVersions; + // Build the display list in the SAME order (Key = real key, Value = pretty label) + var sortedItems = new List>(foundVersions.Count); + foreach (var v in foundVersions) + { + // Ensure exeDir is set for this version + BMSExists(v); + + // Read the real version parts from the EXE + int major = 0, minor = 0, build = 0, patch = 0; + try + { + var vi = FileVersionInfo.GetVersionInfo(exeDir); + major = vi.FileMajorPart; // ex: 4 + minor = vi.FileMinorPart; // ex: 38 + build = vi.FileBuildPart; // ex: 1 + patch = vi.FilePrivatePart; // ex: 3236 + } + catch + { + // If anything goes wrong, leave zeros + } + + bool isInternal = v.EndsWith("(Internal)", StringComparison.Ordinal); + + string label; + if (isInternal) + { + // Internal: {major}.{minor}.{build} Build {patch} (Internal) + label = $"Falcon BMS {major}.{minor}.{build} (Internal Build {patch})"; + } + else + { + // Non-Internal: {major}.{minor}.{build} + label = $"Falcon BMS {major}.{minor}.{build}"; + } + + sortedItems.Add(new KeyValuePair(v, label)); + } + + // Bind pretty labels but keep real keys via SelectedValue + mainWindow.ListBox_BMS.ItemsSource = sortedItems; + mainWindow.ListBox_BMS.DisplayMemberPath = "Value"; + mainWindow.ListBox_BMS.SelectedValuePath = "Key"; string selectedVersion = null; @@ -105,7 +147,8 @@ public AppRegInfo(MainWindow window) if (idx >= 0) { selectedVersion = Properties.Settings.Default.BMS_Version; - mainWindow.ListBox_BMS.SelectedIndex = idx; + // Select by value (real registry key) + mainWindow.ListBox_BMS.SelectedValue = selectedVersion; } } @@ -113,7 +156,8 @@ public AppRegInfo(MainWindow window) if (string.IsNullOrEmpty(selectedVersion)) { selectedVersion = foundVersions[0]; - mainWindow.ListBox_BMS.SelectedIndex = 0; + // Select by value (real registry key) + mainWindow.ListBox_BMS.SelectedValue = selectedVersion; } UpdateSelectedBMSVersion(selectedVersion); @@ -180,6 +224,8 @@ public bool BMSExists(string version) int build = exe_version_info.FileBuildPart; int patch = exe_version_info.FilePrivatePart; + currentExeFourPartVersion = $"{major}.{minor}.{build}.{patch}"; + this.has16kTerrainTilesInNeedOfProcessing = false; if (major == 4 && minor == 38 && build == 1 && patch >= 3099) ScanFor16K(); diff --git a/Falcon BMS Alternative Launcher/Windows/MainWindow.xaml.cs b/Falcon BMS Alternative Launcher/Windows/MainWindow.xaml.cs index 2029a83..7f50de4 100644 --- a/Falcon BMS Alternative Launcher/Windows/MainWindow.xaml.cs +++ b/Falcon BMS Alternative Launcher/Windows/MainWindow.xaml.cs @@ -821,8 +821,10 @@ private void ListBox_BMS_SelectionChanged(object sender, SelectionChangedEventAr if (this.ListBox_BMS.SelectedIndex < 0) return; - string newVersion = this.ListBox_BMS.SelectedItem.ToString(); - Properties.Settings.Default.BMS_Version = newVersion; + var version = ListBox_BMS.SelectedValue as string; // real registry key, e.g. "Falcon BMS 4.38" + if (string.IsNullOrEmpty(version)) return; + + Properties.Settings.Default.BMS_Version = version; //// Don't lose user's recent changes! //if (deviceControl != null) @@ -831,7 +833,7 @@ private void ListBox_BMS_SelectionChanged(object sender, SelectionChangedEventAr // appReg.getOverrideWriter().SaveKeyMapping(inGameAxis, deviceControl); //} - appReg.UpdateSelectedBMSVersion(newVersion); + appReg.UpdateSelectedBMSVersion(version); ReloadDevicesAndXmlMappings(); ReloadKeyfilesTheatersAndUpdateUI();