@@ -7,7 +7,7 @@ namespace MaiChartManager;
77
88public partial class StaticSettings
99{
10- public readonly string tempPath = Path . Combine ( Path . GetTempPath ( ) , "MaiChartManager" ) ;
10+ public static readonly string tempPath = Path . Combine ( Path . GetTempPath ( ) , "MaiChartManager" ) ;
1111 public static readonly string appData = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , "MaiChartManager" ) ;
1212
1313 public static Config Config { get ; set ; } = new ( ) ;
@@ -18,8 +18,11 @@ public partial class StaticSettings
1818 public StaticSettings ( ILogger < StaticSettings > logger )
1919 {
2020 _logger = logger ;
21- Directory . CreateDirectory ( tempPath ) ;
22- if ( string . IsNullOrEmpty ( GamePath ) ) return ;
21+ if ( string . IsNullOrEmpty ( GamePath ) )
22+ {
23+ throw new ArgumentException ( "未指定游戏目录" ) ;
24+ }
25+
2326 AssetDir = "A500" ;
2427 ScanMusicList ( ) ;
2528 ScanGenre ( ) ;
@@ -165,8 +168,20 @@ public void ScanSoundData()
165168
166169 private void GetGameVersion ( )
167170 {
168- var xmlDoc = new XmlDocument ( ) ;
169- xmlDoc . Load ( Path . Combine ( StreamingAssets , @"A000/DataConfig.xml" ) ) ;
170- int . TryParse ( xmlDoc . SelectSingleNode ( "/DataConfig/version/minor" ) ? . InnerText , out gameVersion ) ;
171+ try
172+ {
173+ var xmlDoc = new XmlDocument ( ) ;
174+ xmlDoc . Load ( Path . Combine ( StreamingAssets , @"A000/DataConfig.xml" ) ) ;
175+ if ( ! int . TryParse ( xmlDoc . SelectSingleNode ( "/DataConfig/version/minor" ) ? . InnerText , out gameVersion ) )
176+ {
177+ MessageBox . Show ( "无法获取游戏版本号,解析数据失败" , "提示" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
178+ }
179+ }
180+ catch ( Exception e )
181+ {
182+ _logger . LogError ( e , "Get game version failed." ) ;
183+ SentrySdk . CaptureEvent ( new SentryEvent ( e ) { Message = @"无法获取游戏版本号,可能是因为 A000\DataConfig.xml 找不到或者有错误" } ) ;
184+ MessageBox . Show ( @"无法获取游戏版本号,可能是因为 A000\DataConfig.xml 找不到或者有错误" , "提示" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
185+ }
171186 }
172187}
0 commit comments