Skip to content

Show a warning when trying to install mods for the wrong game version #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ModAssistant/Localisation/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<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})!
Installing mismatched Mods may break your game! Do you want to continue?</sys:String>
<sys:String x:Key="MainWindow:GameVersionMismatchTitle">Warning: Game Version Mismatch</sys:String>
<sys:String x:Key="MainWindow:GameVersionUnknown">Unknown</sys:String>


<!-- Intro Page -->
<sys:String x:Key="Intro:Title">Intro</sys:String>
Expand Down Expand Up @@ -120,7 +125,7 @@
<Hyperlink local:HyperlinkExtensions.IsExternal="True" NavigateUri="https://bs.assistant.moe/Donate/">
donation page
</Hyperlink>
or the
or the
<Hyperlink local:HyperlinkExtensions.IsExternal="True" NavigateUri="https://www.patreon.com/beatsabermods">
BSMG Patreon
</Hyperlink>
Expand Down
7 changes: 6 additions & 1 deletion ModAssistant/Localisation/zh.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<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>
<sys:String x:Key="MainWindow:GameVersionUnknown">未知</sys:String>


<!-- Intro Page -->
<sys:String x:Key="Intro:Title">简介</sys:String>
Expand Down Expand Up @@ -236,7 +241,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
26 changes: 25 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 game version detected from the game files, will be empty if not known by BeatMods
public static string GameVersionOverride;
public TaskCompletionSource<bool> VersionLoadStatus = new TaskCompletionSource<bool>();

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

string version = await Utils.GetVersion();
GameVersionDetected = version;
if (!versions.Contains(version) && CheckAliases(versions, aliases, version) == string.Empty)
{
versions.Insert(0, version);
Expand Down Expand Up @@ -270,7 +272,29 @@ 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, i.e. not a known version by BeatMods
&& GameVersion != GameVersionDetected) // and the user manually selected a version
{

string detected = string.IsNullOrEmpty(GameVersionDetected)
? (string)Application.Current.FindResource("MainWindow:GameVersionUnknown")
: GameVersionDetected;

// show a waring about the version mismatch
var result = MessageBox.Show(
string.Format((string)Application.Current.FindResource("MainWindow:GameVersionMismatch"), GameVersion, detected),
(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