Skip to content

Commit bdeb29e

Browse files
author
WGzeyu
authored
Merge pull request #12 from qe201020335/warning_cn
在游戏版本不同的情况下尝试安装mod会显示警告
2 parents d121c89 + 8b17298 commit bdeb29e

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
@@ -35,6 +35,10 @@
3535
<sys:String x:Key="MainWindow:GameUpdateDialog:Line2">Please double check that the correct version is selected at the bottom left corner!</sys:String>
3636
<sys:String x:Key="MainWindow:NoModSelected">No mod selected!</sys:String>
3737
<sys:String x:Key="MainWindow:NoModInfoPage">{0} does not have an info page.</sys:String>
38+
<sys:String x:Key="MainWindow:GameVersionMismatch" xml:space="preserve">The selected game version {0} is different from detected {1}!
39+
Do you want to continue?</sys:String>
40+
<sys:String x:Key="MainWindow:GameVersionMismatchTitle">Warning: Game Version Mismatch</sys:String>
41+
3842

3943
<!-- Intro Page -->
4044
<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
@@ -38,6 +38,9 @@ OneClick源</sys:String>
3838
<sys:String x:Key="MainWindow:GameUpdateDialog:Line2">请确保左下角选择的版本与实际版本(地板脚印上有)相同才能安装Mod,否则会破坏你的游戏!</sys:String>
3939
<sys:String x:Key="MainWindow:NoModSelected">没有选择Mod!</sys:String>
4040
<sys:String x:Key="MainWindow:NoModInfoPage">{0}没有信息页。</sys:String>
41+
<sys:String x:Key="MainWindow:GameVersionMismatch" xml:space="preserve">您选择的游戏版本 {0} 与当前检测到的游戏版本 {1} 不匹配,是否要继续安装Mod?
42+
警告:继续安装Mod可能会破坏你的游戏,Mod需要匹配游戏版本,否则会出错。</sys:String>
43+
<sys:String x:Key="MainWindow:GameVersionMismatchTitle">警告:游戏版本不匹配</sys:String>
4144

4245
<!-- Intro Page -->
4346
<sys:String x:Key="Intro:Title">简介</sys:String>
@@ -270,7 +273,7 @@ OneClick窗口显示方式切换:</sys:String>
270273
<sys:String x:Key="OneClick:DoneNotify">OneClick™ 安装完毕</sys:String>
271274
<sys:String x:Key="OneClick:StartDownloadPlaylist">开始下载歌曲列表</sys:String>
272275
<sys:String x:Key="OneClick:Done">执行完毕</sys:String>
273-
276+
274277
<!-- Themes Class -->
275278
<sys:String x:Key="Themes:ThemeNotFound">找不到主题,恢复为默认主题...</sys:String>
276279
<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
@@ -20,6 +20,7 @@ public partial class MainWindow : Window
2020
public static bool ModsOpened = false;
2121
public static bool ModsLoading = false;
2222
public static string GameVersion;
23+
public static string GameVersionDetected; // the real game version detected from the game
2324
public static string GameVersionOverride;
2425
public TaskCompletionSource<bool> VersionLoadStatus = new TaskCompletionSource<bool>();
2526
public static string[] serverList = { "国际源@BeatMods", "国内源@WGzeyu", "包子源@BeatTop" };
@@ -129,6 +130,7 @@ private async void LoadVersionsAsync()
129130
Dictionary<string, string[]> aliases = JsonSerializer.Deserialize<Dictionary<string, string[]>>(body);
130131

131132
string version = Utils.GetVersion();
133+
GameVersionDetected = version;
132134
if (!versions.Contains(version) && CheckAliases(versions, aliases, version) == string.Empty)
133135
{
134136
versions.Insert(0, version);
@@ -281,7 +283,22 @@ private void OptionsButton_Click(object sender, RoutedEventArgs e)
281283

282284
private void InstallButton_Click(object sender, RoutedEventArgs e)
283285
{
284-
Mods.Instance.InstallMods();
286+
if (string.IsNullOrEmpty(GameVersionOverride) // game version not listed in aliases at all
287+
&& GameVersion != GameVersionDetected) // and the user manually selected a version
288+
{
289+
// show a waring about the version mismatch
290+
var result = MessageBox.Show(String.Format((string) Application.Current.FindResource("MainWindow:GameVersionMismatch"), GameVersion, GameVersionDetected),
291+
(string)Application.Current.FindResource("MainWindow:GameVersionMismatchTitle"), MessageBoxButton.OKCancel);
292+
293+
if (result == MessageBoxResult.OK)
294+
{
295+
Mods.Instance.InstallMods();
296+
}
297+
}
298+
else
299+
{
300+
Mods.Instance.InstallMods();
301+
}
285302
}
286303

287304
private void InfoButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)