From db7b5c1382c7311ada27a61838abd35ccad3ed5d Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Wed, 27 Nov 2024 16:38:05 -0800 Subject: [PATCH 1/7] Skip WASM install for non-installed MSFS versions Fixes #1867 --- UI/MainForm.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UI/MainForm.cs b/UI/MainForm.cs index c2f78fa1c..30db4bfa8 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -2143,13 +2143,13 @@ private static void InstallWasmModule() } // Try updating the 2020 install - if (Is2020Different) + if (Is2020Different && !String.IsNullOrEmpty(updater.CommunityFolder)) { Update2020Successful = updater.InstallWasmModule(updater.CommunityFolder); } // Try updating the 2024 install - if (Is2024Different) + if (Is2024Different && !String.IsNullOrEmpty(updater.CommunityFolder2024)) { Update2024Successful = updater.InstallWasmModule(updater.CommunityFolder2024); } From bf84ab5c3d49572c3822db680ae590ac6d313751 Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Wed, 27 Nov 2024 16:39:07 -0800 Subject: [PATCH 2/7] Tweak an additional pace --- SimConnectMSFS/WasmModuleUpdater.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimConnectMSFS/WasmModuleUpdater.cs b/SimConnectMSFS/WasmModuleUpdater.cs index 0607f6bdc..f609551d5 100644 --- a/SimConnectMSFS/WasmModuleUpdater.cs +++ b/SimConnectMSFS/WasmModuleUpdater.cs @@ -188,7 +188,7 @@ public bool WasmModulesAreDifferent(string communityFolder) string installedWASM; string mobiflightWASM; - if (communityFolder == null) return true; + if (String.IsNullOrEmpty(communityFolder)) return true; string wasmModulePath = Path.Combine(communityFolder, @"mobiflight-event-module\modules\", WasmModuleName); if (!File.Exists(wasmModulePath)) From 03dc15623184f07eff0373eacf632b33569c4359 Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Thu, 28 Nov 2024 04:49:58 -0800 Subject: [PATCH 3/7] Add an info message for skipped installs --- UI/MainForm.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/UI/MainForm.cs b/UI/MainForm.cs index 30db4bfa8..7e8c44a6f 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -2143,16 +2143,31 @@ private static void InstallWasmModule() } // Try updating the 2020 install - if (Is2020Different && !String.IsNullOrEmpty(updater.CommunityFolder)) + if (!String.IsNullOrEmpty(updater.CommunityFolder)) { - Update2020Successful = updater.InstallWasmModule(updater.CommunityFolder); + if (Is2020Different) + { + Update2020Successful = updater.InstallWasmModule(updater.CommunityFolder); + } + } + else + { + Log.Instance.log("Skipping WASM install for MSFS2020 since no community folder was found. This likely means MSFS2020 is not installed.", LogSeverity.Info); } // Try updating the 2024 install - if (Is2024Different && !String.IsNullOrEmpty(updater.CommunityFolder2024)) + if (!String.IsNullOrEmpty(updater.CommunityFolder2024)) { - Update2024Successful = updater.InstallWasmModule(updater.CommunityFolder2024); + if (Is2024Different) + { + Update2024Successful = updater.InstallWasmModule(updater.CommunityFolder2024); + } } + else + { + Log.Instance.log("Skipping WASM install for MSFS2024 since no community folder was found. This likely means MSFS2024 is not installed.", LogSeverity.Info); + } + // If either update is successful then show the success dialog. if (Update2020Successful || Update2024Successful) From c32e2774fb19fb3fa1aec34e494ccdb8ba5c17ca Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Thu, 28 Nov 2024 05:28:49 -0800 Subject: [PATCH 4/7] Log a message if the install is up-to-date. --- UI/MainForm.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/UI/MainForm.cs b/UI/MainForm.cs index 7e8c44a6f..d8aa7cff6 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -2149,6 +2149,10 @@ private static void InstallWasmModule() { Update2020Successful = updater.InstallWasmModule(updater.CommunityFolder); } + else + { + Log.Instance.log("WASM install for MSFS2020 is already up-to-date.", LogSeverity.Info); + } } else { @@ -2162,6 +2166,10 @@ private static void InstallWasmModule() { Update2024Successful = updater.InstallWasmModule(updater.CommunityFolder2024); } + else + { + Log.Instance.log("WASM install for MSFS2024 is already up-to-date.", LogSeverity.Info); + } } else { From b86d1c7241645a134898f9b1ba0b2025eaea1278 Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Thu, 28 Nov 2024 05:35:28 -0800 Subject: [PATCH 5/7] Add successfull instal log message --- SimConnectMSFS/WasmModuleUpdater.cs | 1 - UI/MainForm.cs | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/SimConnectMSFS/WasmModuleUpdater.cs b/SimConnectMSFS/WasmModuleUpdater.cs index f609551d5..23f4e801d 100644 --- a/SimConnectMSFS/WasmModuleUpdater.cs +++ b/SimConnectMSFS/WasmModuleUpdater.cs @@ -140,7 +140,6 @@ public bool InstallWasmModule(string communityFolder) // Remove the old Wasm File DeleteOldWasmFile(communityFolder); - Log.Instance.log("WASM module has been installed successfully.", LogSeverity.Info); return true; } diff --git a/UI/MainForm.cs b/UI/MainForm.cs index d8aa7cff6..18aff15e5 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -2148,10 +2148,15 @@ private static void InstallWasmModule() if (Is2020Different) { Update2020Successful = updater.InstallWasmModule(updater.CommunityFolder); + + if (Update2020Successful) + { + Log.Instance.log("Successfully installed WASM module for MSFS2020.", LogSeverity.Info); + } } else { - Log.Instance.log("WASM install for MSFS2020 is already up-to-date.", LogSeverity.Info); + Log.Instance.log("WASM module for MSFS2020 is already up-to-date.", LogSeverity.Info); } } else @@ -2165,10 +2170,15 @@ private static void InstallWasmModule() if (Is2024Different) { Update2024Successful = updater.InstallWasmModule(updater.CommunityFolder2024); + + if (Update2024Successful) + { + Log.Instance.log("Successfully installed WASM module for MSFS2024.", LogSeverity.Info); + } } else { - Log.Instance.log("WASM install for MSFS2024 is already up-to-date.", LogSeverity.Info); + Log.Instance.log("WASM module for MSFS2024 is already up-to-date.", LogSeverity.Info); } } else From 650d08550e637a1ca3c3f698515dae7e8e0a6689 Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Sun, 1 Dec 2024 10:47:28 -0800 Subject: [PATCH 6/7] Address PR feedback --- UI/MainForm.cs | 89 ++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/UI/MainForm.cs b/UI/MainForm.cs index 18aff15e5..ec88ae898 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -2118,7 +2118,8 @@ private static void InstallWasmModule() bool Update2020Successful = false; bool Update2024Successful = false; - try { + try + { if (!updater.AutoDetectCommunityFolder()) { @@ -2142,50 +2143,9 @@ private static void InstallWasmModule() return; } - // Try updating the 2020 install - if (!String.IsNullOrEmpty(updater.CommunityFolder)) - { - if (Is2020Different) - { - Update2020Successful = updater.InstallWasmModule(updater.CommunityFolder); - - if (Update2020Successful) - { - Log.Instance.log("Successfully installed WASM module for MSFS2020.", LogSeverity.Info); - } - } - else - { - Log.Instance.log("WASM module for MSFS2020 is already up-to-date.", LogSeverity.Info); - } - } - else - { - Log.Instance.log("Skipping WASM install for MSFS2020 since no community folder was found. This likely means MSFS2020 is not installed.", LogSeverity.Info); - } - - // Try updating the 2024 install - if (!String.IsNullOrEmpty(updater.CommunityFolder2024)) - { - if (Is2024Different) - { - Update2024Successful = updater.InstallWasmModule(updater.CommunityFolder2024); - - if (Update2024Successful) - { - Log.Instance.log("Successfully installed WASM module for MSFS2024.", LogSeverity.Info); - } - } - else - { - Log.Instance.log("WASM module for MSFS2024 is already up-to-date.", LogSeverity.Info); - } - } - else - { - Log.Instance.log("Skipping WASM install for MSFS2024 since no community folder was found. This likely means MSFS2024 is not installed.", LogSeverity.Info); - } - + // Install for both versions + Update2020Successful = HandleWasmInstall(updater, Is2020Different, updater.CommunityFolder, "2020"); + Update2024Successful = HandleWasmInstall(updater, Is2024Different, updater.CommunityFolder2024, "2024"); // If either update is successful then show the success dialog. if (Update2020Successful || Update2024Successful) @@ -2197,7 +2157,8 @@ private static void InstallWasmModule() return; } - } catch (Exception ex) { + } + catch (Exception ex) { Log.Instance.log(ex.Message, LogSeverity.Error); } @@ -2208,6 +2169,42 @@ private static void InstallWasmModule() MessageBoxButtons.OK, MessageBoxIcon.Error); } + /// + /// Handles all the necessary and log messages for installing the WASM with different versions of MSFS. + /// + /// The WASM updater to use + /// True if the versions of WASM were different + /// The path to the community folder + /// The version of MSFS, either "2020" or "2024" + /// + private static bool HandleWasmInstall(WasmModuleUpdater updater, bool isDifferent, string communityFolder, string msfsVersion) + { + bool result = false; + + if (!String.IsNullOrEmpty(communityFolder)) + { + if (isDifferent) + { + result = updater.InstallWasmModule(communityFolder); + + if (result) + { + Log.Instance.log($"Successfully installed WASM module for MSFS{msfsVersion}.", LogSeverity.Info); + } + } + else + { + Log.Instance.log($"WASM module for MSFS{msfsVersion} is already up-to-date.", LogSeverity.Info); + } + } + else + { + Log.Instance.log($"Skipping WASM install for MSFS{msfsVersion} since no community folder was found. This likely means MSFS{msfsVersion} is not installed.", LogSeverity.Info); + } + + return result; + } + private void downloadLatestEventsToolStripMenuItem_Click(object sender, EventArgs e) { WasmModuleUpdater updater = new WasmModuleUpdater(); From 85caaefa26b2b9773092567ec29f74adacb828cd Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Sun, 1 Dec 2024 16:28:04 -0800 Subject: [PATCH 7/7] Early return best return --- UI/MainForm.cs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/UI/MainForm.cs b/UI/MainForm.cs index ec88ae898..4ffc1a5e7 100644 --- a/UI/MainForm.cs +++ b/UI/MainForm.cs @@ -2179,27 +2179,23 @@ private static void InstallWasmModule() /// private static bool HandleWasmInstall(WasmModuleUpdater updater, bool isDifferent, string communityFolder, string msfsVersion) { - bool result = false; - - if (!String.IsNullOrEmpty(communityFolder)) + if (String.IsNullOrEmpty(communityFolder)) { - if (isDifferent) - { - result = updater.InstallWasmModule(communityFolder); + Log.Instance.log($"Skipping WASM install for MSFS{msfsVersion} since no community folder was found. This likely means MSFS{msfsVersion} is not installed.", LogSeverity.Info); + return false; + } - if (result) - { - Log.Instance.log($"Successfully installed WASM module for MSFS{msfsVersion}.", LogSeverity.Info); - } - } - else - { - Log.Instance.log($"WASM module for MSFS{msfsVersion} is already up-to-date.", LogSeverity.Info); - } + if (!isDifferent) + { + Log.Instance.log($"WASM module for MSFS{msfsVersion} is already up-to-date.", LogSeverity.Info); + return false; } - else + + bool result = updater.InstallWasmModule(communityFolder); + + if (result) { - Log.Instance.log($"Skipping WASM install for MSFS{msfsVersion} since no community folder was found. This likely means MSFS{msfsVersion} is not installed.", LogSeverity.Info); + Log.Instance.log($"Successfully installed WASM module for MSFS{msfsVersion}.", LogSeverity.Info); } return result;