Skip to content

Commit

Permalink
Show a warning when trying to install mods for the wrong game version
Browse files Browse the repository at this point in the history
  • Loading branch information
qe201020335 committed Jun 13, 2023
1 parent f4e8209 commit 54ccc3e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ModAssistant/Localisation/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<sys:String x:Key="MainWindow:GameUpdateDialog:Line2">Please double check that the correct version is selected at the bottom left corner!</sys:String>
<sys:String x:Key="MainWindow:NoModSelected">No mod selected!</sys:String>
<sys:String x:Key="MainWindow:NoModInfoPage">{0} does not have an info page.</sys:String>
<sys:String x:Key="MainWindow:GameVersionMismatch" xml:space="preserve">The selected game version {0} is different from detected {1}!
Do you want to continue?</sys:String>
<sys:String x:Key="MainWindow:GameVersionMismatchTitle">Warning: Game Version Mismatch</sys:String>


<!-- Intro Page -->
<sys:String x:Key="Intro:Title">Intro</sys:String>
Expand Down
5 changes: 4 additions & 1 deletion ModAssistant/Localisation/zh.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<sys:String x:Key="MainWindow:GameUpdateDialog:Line2">请仔细检查左下角是否选择了正确的游戏版本!</sys:String>
<sys:String x:Key="MainWindow:NoModSelected">没有选择Mod!</sys:String>
<sys:String x:Key="MainWindow:NoModInfoPage">{0}没有信息页。</sys:String>
<sys:String x:Key="MainWindow:GameVersionMismatch" xml:space="preserve">您选择的游戏版本 {0} 与当前检测到的游戏版本 {1} 不匹配,是否要继续安装Mod?
警告:继续安装Mod可能会破坏你的游戏,Mod需要匹配游戏版本,否则会出错。</sys:String>
<sys:String x:Key="MainWindow:GameVersionMismatchTitle">警告:游戏版本不匹配</sys:String>

<!-- Intro Page -->
<sys:String x:Key="Intro:Title">简介</sys:String>
Expand Down Expand Up @@ -236,7 +239,7 @@
<sys:String x:Key="OneClick:DoneNotify">OneClick™ 安装完毕</sys:String>
<sys:String x:Key="OneClick:StartDownloadPlaylist">开始下载歌曲列表</sys:String>
<sys:String x:Key="OneClick:Done">执行完毕</sys:String>

<!-- Themes Class -->
<sys:String x:Key="Themes:ThemeNotFound">找不到主题,恢复为默认主题...</sys:String>
<sys:String x:Key="Themes:ThemeSet">主题设置为{0}.</sys:String>
Expand Down
19 changes: 18 additions & 1 deletion ModAssistant/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> VersionLoadStatus = new TaskCompletionSource<bool>();

Expand Down Expand Up @@ -123,6 +124,7 @@ private async void LoadVersionsAsync()
Dictionary<string, string[]> aliases = JsonSerializer.Deserialize<Dictionary<string, string[]>>(body);

string version = Utils.GetVersion();
GameVersionDetected = version;
if (!versions.Contains(version) && CheckAliases(versions, aliases, version) == string.Empty)
{
versions.Insert(0, version);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 54ccc3e

Please sign in to comment.