Skip to content

Commit 9c5a47a

Browse files
committed
Show a warning when trying to install mods for the wrong game version
1 parent b36e614 commit 9c5a47a

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

ModAssistant/Localisation/en.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
<sys:String x:Key="MainWindow:GameUpdateDialog:Line2">Please double check that the correct version is selected at the bottom left corner!</sys:String>
3131
<sys:String x:Key="MainWindow:NoModSelected">No mod selected!</sys:String>
3232
<sys:String x:Key="MainWindow:NoModInfoPage">{0} does not have an info page.</sys:String>
33+
<sys:String x:Key="MainWindow:GameVersionMismatch" xml:space="preserve">The selected game version {0} is different from detected {1}!
34+
Do you want to continue?</sys:String>
35+
<sys:String x:Key="MainWindow:GameVersionMismatchTitle">Warning: Game Version Mismatch</sys:String>
36+
3337

3438
<!-- Intro Page -->
3539
<sys:String x:Key="Intro:Title">Intro</sys:String>

ModAssistant/Localisation/zh.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<sys:String x:Key="MainWindow:GameUpdateDialog:Line2">请仔细检查左下角是否选择了正确的游戏版本!</sys:String>
3131
<sys:String x:Key="MainWindow:NoModSelected">没有选择Mod!</sys:String>
3232
<sys:String x:Key="MainWindow:NoModInfoPage">{0}没有信息页。</sys:String>
33+
<sys:String x:Key="MainWindow:GameVersionMismatch" xml:space="preserve">您选择的游戏版本 {0} 与当前检测到的游戏版本 {1} 不匹配,是否要继续安装Mod?
34+
警告:继续安装Mod可能会破坏你的游戏,Mod需要匹配游戏版本,否则会出错。</sys:String>
35+
<sys:String x:Key="MainWindow:GameVersionMismatchTitle">警告:游戏版本不匹配</sys:String>
3336

3437
<!-- Intro Page -->
3538
<sys:String x:Key="Intro:Title">简介</sys:String>
@@ -236,7 +239,7 @@
236239
<sys:String x:Key="OneClick:DoneNotify">OneClick™ 安装完毕</sys:String>
237240
<sys:String x:Key="OneClick:StartDownloadPlaylist">开始下载歌曲列表</sys:String>
238241
<sys:String x:Key="OneClick:Done">执行完毕</sys:String>
239-
242+
240243
<!-- Themes Class -->
241244
<sys:String x:Key="Themes:ThemeNotFound">找不到主题,恢复为默认主题...</sys:String>
242245
<sys:String x:Key="Themes:ThemeSet">主题设置为{0}.</sys:String>

ModAssistant/MainWindow.xaml.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public partial class MainWindow : Window
1919
public static bool ModsOpened = false;
2020
public static bool ModsLoading = false;
2121
public static string GameVersion;
22+
public static string GameVersionDetected; // the actual game version detected from the game, will be empty if not known by BeatMods
2223
public static string GameVersionOverride;
2324
public TaskCompletionSource<bool> VersionLoadStatus = new TaskCompletionSource<bool>();
2425

@@ -118,6 +119,7 @@ private async void LoadVersionsAsync()
118119
var aliases = await Utils.GetAliasDictionary();
119120

120121
string version = await Utils.GetVersion();
122+
GameVersionDetected = version;
121123
if (!versions.Contains(version) && CheckAliases(versions, aliases, version) == string.Empty)
122124
{
123125
versions.Insert(0, version);
@@ -270,7 +272,22 @@ private void OptionsButton_Click(object sender, RoutedEventArgs e)
270272

271273
private void InstallButton_Click(object sender, RoutedEventArgs e)
272274
{
273-
Mods.Instance.InstallMods();
275+
if (string.IsNullOrEmpty(GameVersionOverride) // game version not listed in aliases at all
276+
&& GameVersion != GameVersionDetected) // and the user manually selected a version
277+
{
278+
// show a waring about the version mismatch
279+
var result = MessageBox.Show(String.Format((string) Application.Current.FindResource("MainWindow:GameVersionMismatch"), GameVersion, GameVersionDetected),
280+
(string)Application.Current.FindResource("MainWindow:GameVersionMismatchTitle"), MessageBoxButton.OKCancel);
281+
282+
if (result == MessageBoxResult.OK)
283+
{
284+
Mods.Instance.InstallMods();
285+
}
286+
}
287+
else
288+
{
289+
Mods.Instance.InstallMods();
290+
}
274291
}
275292

276293
private void InfoButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)