@@ -37,15 +37,9 @@ public partial class MainWindow : HandyControl.Controls.Window
3737 new CreateServer ( )
3838 } ;
3939 public static event DeleControl AutoOpenServer ;
40- public static bool getServerInfo = false ;
41- public static bool getPlayerInfo = false ;
40+
4241 public static bool LoadingCompleted = false ;
43- public static string ServerLink { get ; set ; }
44- public static Version MSLVersion { get ; set ; }
45- // public static bool IsOldVersion { get; set; } 旧版本会加一个叹号提示(现在暂没使用此功能),后续可能会用上此字段
46- public static string DeviceID { get ; set ; }
47-
48-
42+
4943 public MainWindow ( )
5044 {
5145 InitializeComponent ( ) ;
@@ -63,22 +57,22 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
6357 Topmost = true ;
6458 Focus ( ) ;
6559 Topmost = false ;
66- MSLVersion = System . Reflection . Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ;
60+ ConfigStore . MSLVersion = System . Reflection . Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ;
6761 try
6862 {
6963 JObject jsonObject = JObject . Parse ( File . ReadAllText ( @"MSL\config.json" , Encoding . UTF8 ) ) ;
70- DeviceID = Functions . GetDeviceID ( ) ;
71- if ( jsonObject [ "eula" ] == null || jsonObject [ "eula" ] . ToString ( ) != DeviceID . Substring ( 0 , 5 ) )
64+ ConfigStore . DeviceID = Functions . GetDeviceID ( ) ;
65+ if ( jsonObject [ "eula" ] == null || jsonObject [ "eula" ] . ToString ( ) != ConfigStore . DeviceID . Substring ( 0 , 5 ) )
7266 {
7367 if ( await EulaEvent ( ) )
7468 {
7569 if ( jsonObject [ "eula" ] == null )
7670 {
77- jsonObject . Add ( "eula" , DeviceID . Substring ( 0 , 5 ) ) ;
71+ jsonObject . Add ( "eula" , ConfigStore . DeviceID . Substring ( 0 , 5 ) ) ;
7872 }
7973 else
8074 {
81- jsonObject [ "eula" ] = DeviceID . Substring ( 0 , 5 ) ;
75+ jsonObject [ "eula" ] = ConfigStore . DeviceID . Substring ( 0 , 5 ) ;
8276 }
8377 string convertString = Convert . ToString ( jsonObject ) ;
8478 File . WriteAllText ( @"MSL\config.json" , convertString , Encoding . UTF8 ) ;
@@ -280,11 +274,11 @@ await Task.Run(() =>
280274 jobject . Add ( "autoGetServerInfo" , true ) ;
281275 string convertString = Convert . ToString ( jobject ) ;
282276 File . WriteAllText ( @"MSL\config.json" , convertString , Encoding . UTF8 ) ;
283- getServerInfo = true ;
277+ ConfigStore . GetServerInfo = true ;
284278 }
285279 else if ( ( bool ) jsonObject [ "autoGetServerInfo" ] == true )
286280 {
287- getServerInfo = true ;
281+ ConfigStore . GetServerInfo = true ;
288282 }
289283 if ( jsonObject [ "autoGetPlayerInfo" ] == null )
290284 {
@@ -293,11 +287,26 @@ await Task.Run(() =>
293287 jobject . Add ( "autoGetPlayerInfo" , true ) ;
294288 string convertString = Convert . ToString ( jobject ) ;
295289 File . WriteAllText ( @"MSL\config.json" , convertString , Encoding . UTF8 ) ;
296- getPlayerInfo = true ;
290+ ConfigStore . GetPlayerInfo = true ;
297291 }
298292 else if ( ( bool ) jsonObject [ "autoGetPlayerInfo" ] == true )
299293 {
300- getPlayerInfo = true ;
294+ ConfigStore . GetPlayerInfo = true ;
295+ }
296+
297+ var logColorConf = ( JObject ) Config . Read ( "LogColor" ) ;
298+ if ( logColorConf != null )
299+ {
300+ var brushConverter = new BrushConverter ( ) ;
301+
302+ if ( logColorConf [ "INFO" ] != null )
303+ ConfigStore . LogColor . INFO = ( SolidColorBrush ) brushConverter . ConvertFromString ( logColorConf [ "INFO" ] . ToString ( ) ) ;
304+
305+ if ( logColorConf [ "WARN" ] != null )
306+ ConfigStore . LogColor . WARN = ( SolidColorBrush ) brushConverter . ConvertFromString ( logColorConf [ "WARN" ] . ToString ( ) ) ;
307+
308+ if ( logColorConf [ "ERROR" ] != null )
309+ ConfigStore . LogColor . ERROR = ( SolidColorBrush ) brushConverter . ConvertFromString ( logColorConf [ "ERROR" ] . ToString ( ) ) ;
301310 }
302311 //Logger.LogInfo("读取自动化功能配置成功(自动打开显示占用、记录玩家功能)!");
303312 }
@@ -411,9 +420,9 @@ private async Task OnlineService(JObject jsonObject, bool downloadTermDll)
411420 try
412421 {
413422 _ = HttpService . GetContentAsync ( "https://msl-api.oss-cn-hangzhou.aliyuncs.com/" ) ;
414- ServerLink = "mslmc.cn/v3/" ;
423+ ConfigStore . ServerLink = "mslmc.cn/v3/" ;
415424 //Logger.LogInfo("连接到api:" + "https://api." + _link);
416- if ( ( ( int ) JObject . Parse ( ( await HttpService . GetContentAsync ( "https://api." + ServerLink , headers => { headers . Add ( "DeviceID" , DeviceID ) ; } , 1 ) ) . ToString ( ) ) [ "code" ] ) == 200 )
425+ if ( ( ( int ) JObject . Parse ( ( await HttpService . GetContentAsync ( "https://api." + ConfigStore . ServerLink , headers => { headers . Add ( "DeviceID" , ConfigStore . DeviceID ) ; } , 1 ) ) . ToString ( ) ) [ "code" ] ) == 200 )
417426 {
418427 // 检查更新
419428 await CheckUpdate ( jsonObject ) ;
0 commit comments