Skip to content

Commit 8ab700d

Browse files
committed
Add Game Dir Invalid Detection
1 parent 87446d5 commit 8ab700d

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

ModAssistant/App.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ private async void Application_Startup(object sender, StartupEventArgs e)
6969
}
7070
}
7171

72+
Utils.CheckDirValid(BeatSaberInstallDirectory);
73+
7274
options.InstallType =
7375
BeatSaberInstallType = ModAssistant.Properties.Settings.Default.StoreType;
7476
options.SaveSelection =

ModAssistant/Classes/Utils.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,17 @@ public static string GetManualDir()
455455
return null;
456456
}
457457

458+
public static void CheckDirValid(string BeatSaberInstallDirectory) {
459+
for (int i = 0; i < BeatSaberInstallDirectory.Length; ++i)
460+
{
461+
if (((int)BeatSaberInstallDirectory[i]) > 127)
462+
{
463+
MessageBox.Show((string)Application.Current.FindResource("App:InstallDirInvalid"));
464+
break;
465+
}
466+
}
467+
}
468+
458469
public static string GetManualFile(string filter = "", string title = "Open File")
459470
{
460471
var dialog = new OpenFileDialog()

ModAssistant/Localisation/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<!-- App -->
99
<sys:String x:Key="App:InstallDirDialog:Title">Couldn't find your Beat Saber install folder!</sys:String>
1010
<sys:String x:Key="App:InstallDirDialog:OkCancel">Press OK to try again, or Cancel to close application.</sys:String>
11+
<sys:String x:Key="App:InstallDirInvalid">The game directory path contains special character(s) (such as Chinese or Japanese characters) that may cause problems. e.g., mods cannot work properly.</sys:String>
1112
<sys:String x:Key="App:InvalidArgument">Invalid argument! '{0}' requires an option.</sys:String>
1213
<sys:String x:Key="App:UnrecognizedArgument">Unrecognized argument. Closing Mod Assistant.</sys:String>
1314
<sys:String x:Key="App:UnhandledException">An unhandled exception just occurred</sys:String>

ModAssistant/Localisation/zh.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<!-- App -->
99
<sys:String x:Key="App:InstallDirDialog:Title">找不到您的Beat Saber安装路径!</sys:String>
1010
<sys:String x:Key="App:InstallDirDialog:OkCancel">点确定重试,或点取消关闭软件。</sys:String>
11+
<sys:String x:Key="App:InstallDirInvalid">游戏目录包含特殊字符(如汉字,日文等)!可能会造成例如mod无法正常运行等问题。</sys:String>
1112
<sys:String x:Key="App:InvalidArgument">无效参数!'{0}'需要一个选项。</sys:String>
1213
<sys:String x:Key="App:UnrecognizedArgument">无法识别的参数。关闭Mod Assistant。</sys:String>
1314
<sys:String x:Key="App:UnhandledException">刚刚发生了一个未处理的异常</sys:String>

ModAssistant/Pages/Options.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void UpdateHandlerStatus()
6161
private void SelectDirButton_Click(object sender, RoutedEventArgs e)
6262
{
6363
Utils.GetManualDir();
64+
Utils.CheckDirValid(InstallDirectory);
6465
DirectoryTextBlock.Text = InstallDirectory;
6566
GameTypeTextBlock.Text = InstallType;
6667
}

0 commit comments

Comments
 (0)