From a6e4e80801df6d6999e2375e3bb7649acefd22a9 Mon Sep 17 00:00:00 2001 From: Sky Z Date: Tue, 13 Jun 2023 14:22:44 -0400 Subject: [PATCH] Show a warning when trying to install mods for the wrong game version --- ModAssistant/Localisation/en.xaml | 4 ++++ ModAssistant/Localisation/zh.xaml | 5 ++++- ModAssistant/MainWindow.xaml.cs | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ModAssistant/Localisation/en.xaml b/ModAssistant/Localisation/en.xaml index 1065fa37..70c9208b 100644 --- a/ModAssistant/Localisation/en.xaml +++ b/ModAssistant/Localisation/en.xaml @@ -30,6 +30,10 @@ Please double check that the correct version is selected at the bottom left corner! No mod selected! {0} does not have an info page. + The selected game version {0} is different from detected {1}! +Do you want to continue? + Warning: Game Version Mismatch + Intro diff --git a/ModAssistant/Localisation/zh.xaml b/ModAssistant/Localisation/zh.xaml index d1571bee..885c43dc 100644 --- a/ModAssistant/Localisation/zh.xaml +++ b/ModAssistant/Localisation/zh.xaml @@ -30,6 +30,9 @@ 请仔细检查左下角是否选择了正确的游戏版本! 没有选择Mod! {0}没有信息页。 + 您选择的游戏版本 {0} 与当前检测到的游戏版本 {1} 不匹配,是否要继续安装Mod? +警告:继续安装Mod可能会破坏你的游戏,Mod需要匹配游戏版本,否则会出错。 + 警告:游戏版本不匹配 简介 @@ -236,7 +239,7 @@ OneClick™ 安装完毕 开始下载歌曲列表 执行完毕 - + 找不到主题,恢复为默认主题... 主题设置为{0}. diff --git a/ModAssistant/MainWindow.xaml.cs b/ModAssistant/MainWindow.xaml.cs index 1a6c2ec9..6c7d1122 100644 --- a/ModAssistant/MainWindow.xaml.cs +++ b/ModAssistant/MainWindow.xaml.cs @@ -19,6 +19,7 @@ public partial class MainWindow : Window public static bool ModsOpened = false; public static bool ModsLoading = false; public static string GameVersion; + public static string GameVersionDetected; // the real game version detected from the game public static string GameVersionOverride; public TaskCompletionSource VersionLoadStatus = new TaskCompletionSource(); @@ -123,6 +124,7 @@ private async void LoadVersionsAsync() Dictionary aliases = JsonSerializer.Deserialize>(body); string version = Utils.GetVersion(); + GameVersionDetected = version; if (!versions.Contains(version) && CheckAliases(versions, aliases, version) == string.Empty) { versions.Insert(0, version); @@ -275,7 +277,22 @@ private void OptionsButton_Click(object sender, RoutedEventArgs e) private void InstallButton_Click(object sender, RoutedEventArgs e) { - Mods.Instance.InstallMods(); + if (string.IsNullOrEmpty(GameVersionOverride) // game version not listed in aliases at all + && GameVersion != GameVersionDetected) // and the user manually selected a version + { + // show a waring about the version mismatch + var result = MessageBox.Show(String.Format((string) Application.Current.FindResource("MainWindow:GameVersionMismatch"), GameVersion, GameVersionDetected), + (string)Application.Current.FindResource("MainWindow:GameVersionMismatchTitle"), MessageBoxButton.OKCancel); + + if (result == MessageBoxResult.OK) + { + Mods.Instance.InstallMods(); + } + } + else + { + Mods.Instance.InstallMods(); + } } private void InfoButton_Click(object sender, RoutedEventArgs e)