Skip to content

Commit 215e598

Browse files
committed
Show a warning when trying to install mods for the wrong game version
1 parent db77363 commit 215e598

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

ModAssistant/Localisation/en.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
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+
Installing mismatched Mods may break your game! Do you want to continue?</sys:String>
35+
<sys:String x:Key="MainWindow:GameVersionMismatchTitle">Warning: Game Version Mismatch</sys:String>
36+
<sys:String x:Key="MainWindow:GameVersionUnknown">Unknown</sys:String>
37+
3338

3439
<!-- Intro Page -->
3540
<sys:String x:Key="Intro:Title">Intro</sys:String>
@@ -120,7 +125,7 @@
120125
<Hyperlink local:HyperlinkExtensions.IsExternal="True" NavigateUri="https://bs.assistant.moe/Donate/">
121126
donation page
122127
</Hyperlink>
123-
or the
128+
or the
124129
<Hyperlink local:HyperlinkExtensions.IsExternal="True" NavigateUri="https://www.patreon.com/beatsabermods">
125130
BSMG Patreon
126131
</Hyperlink>

ModAssistant/Localisation/zh.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
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>
36+
<sys:String x:Key="MainWindow:GameVersionUnknown">未知</sys:String>
37+
3338

3439
<!-- Intro Page -->
3540
<sys:String x:Key="Intro:Title">简介</sys:String>
@@ -236,7 +241,7 @@
236241
<sys:String x:Key="OneClick:DoneNotify">OneClick™ 安装完毕</sys:String>
237242
<sys:String x:Key="OneClick:StartDownloadPlaylist">开始下载歌曲列表</sys:String>
238243
<sys:String x:Key="OneClick:Done">执行完毕</sys:String>
239-
244+
240245
<!-- Themes Class -->
241246
<sys:String x:Key="Themes:ThemeNotFound">找不到主题,恢复为默认主题...</sys:String>
242247
<sys:String x:Key="Themes:ThemeSet">主题设置为{0}.</sys:String>

ModAssistant/MainWindow.xaml.cs

Lines changed: 25 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 game version detected from the game files, 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,29 @@ 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, i.e. not a known version by BeatMods
276+
&& GameVersion != GameVersionDetected) // and the user manually selected a version
277+
{
278+
279+
string detected = string.IsNullOrEmpty(GameVersionDetected)
280+
? (string)Application.Current.FindResource("MainWindow:GameVersionUnknown")
281+
: GameVersionDetected;
282+
283+
// show a waring about the version mismatch
284+
var result = MessageBox.Show(
285+
string.Format((string)Application.Current.FindResource("MainWindow:GameVersionMismatch"), GameVersion, detected),
286+
(string)Application.Current.FindResource("MainWindow:GameVersionMismatchTitle"),
287+
MessageBoxButton.OKCancel);
288+
289+
if (result == MessageBoxResult.OK)
290+
{
291+
Mods.Instance.InstallMods();
292+
}
293+
}
294+
else
295+
{
296+
Mods.Instance.InstallMods();
297+
}
274298
}
275299

276300
private void InfoButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)