Skip to content

Commit 4f3da58

Browse files
committed
v3.6.7.3
1 parent d7cc491 commit 4f3da58

19 files changed

+216
-77
lines changed

MSL/MainWindow.xaml.cs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

MSL/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@
4949
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
5050
//通过使用 "*",如下所示:
5151
// [assembly: AssemblyVersion("1.0.*")]
52-
[assembly: AssemblyVersion("3.6.7.2")]
53-
[assembly: AssemblyFileVersion("3.6.7.2")]
52+
[assembly: AssemblyVersion("3.6.7.3")]
53+
[assembly: AssemblyFileVersion("3.6.7.3")]

MSL/controls/dialogs/DownloadDialog.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Downloader;
22
using MSL.langs;
3+
using MSL.utils;
34
using System;
45
using System.ComponentModel;
56
using System.IO;
@@ -179,7 +180,7 @@ private string DownloadUA()
179180
{
180181
if (headerMode == 1)
181182
{
182-
return "MSLTeam-MSL/" + MainWindow.MSLVersion + " (Downloader)";
183+
return "MSLTeam-MSL/" + ConfigStore.MSLVersion + " (Downloader)";
183184
}
184185
else if (headerMode == 2)
185186
{

MSL/controls/dialogs/MessageDialog.xaml.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public partial class MessageDialog
1414
public event DeleControl CloseDialog;
1515
public bool _dialogReturn;
1616

17-
public MessageDialog(string dialogText, string dialogTitle, bool showPrimaryBtn, string closeBtnContext, string primaryBtnContext, UIElement uIElement = null)
17+
public MessageDialog(string dialogText, string dialogTitle, bool showPrimaryBtn, string closeBtnContext, string primaryBtnContext, UIElement uIElement = null, bool isDangerPrimaryBtn = false)
1818
{
1919
InitializeComponent();
2020
Margin = new Thickness(50);
@@ -26,16 +26,30 @@ public MessageDialog(string dialogText, string dialogTitle, bool showPrimaryBtn,
2626
}
2727
else
2828
{
29-
if (closeBtnContext == "否")
29+
switch (closeBtnContext)
3030
{
31-
closeBtnContext = LanguageManager.Instance["No"];
31+
case "NO":
32+
closeBtnContext = LanguageManager.Instance["No"];
33+
break;
34+
case "CANCEL":
35+
closeBtnContext = LanguageManager.Instance["Cancel"];
36+
break;
3237
}
33-
if (primaryBtnContext == "是")
38+
switch (primaryBtnContext)
3439
{
35-
primaryBtnContext = LanguageManager.Instance["Yes"];
40+
case "YES":
41+
primaryBtnContext = LanguageManager.Instance["Yes"];
42+
break;
43+
case "CONFIRM":
44+
primaryBtnContext = LanguageManager.Instance["Confirm"];
45+
break;
3646
}
3747
CloseBtn.Content = closeBtnContext;
3848
PrimaryBtn.Content = primaryBtnContext;
49+
if (isDangerPrimaryBtn)
50+
{
51+
PrimaryBtn.Style = (Style)FindResource("ButtonDanger");
52+
}
3953
}
4054
if (uIElement != null)
4155
{

MSL/forms/ServerRunner.xaml.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ private async Task<bool> LoadingInfoEvent()
372372

373373
private void LoadedInfoEvent()
374374
{
375-
systemInfoBtn.IsChecked = MainWindow.getServerInfo;
376-
recordPlayInfo = MainWindow.getPlayerInfo;
375+
systemInfoBtn.IsChecked = ConfigStore.GetServerInfo;
376+
recordPlayInfo = ConfigStore.GetPlayerInfo;
377377
playerInfoBtn.IsChecked = recordPlayInfo;
378378
LoadSettings();
379379
if (systemInfoBtn.IsChecked == true)
@@ -1205,7 +1205,7 @@ private void ChangeControlsState(bool isEnable = true)
12051205
localServerIPLab.Content = "获取中";
12061206
Growl.Info("开服中,请稍等……");
12071207
outlog.Document.Blocks.Clear();
1208-
PrintLog("正在开启服务器,请稍等...", Brushes.Green);
1208+
PrintLog("正在开启服务器,请稍等...", ConfigStore.LogColor.INFO);
12091209
if (conptyWindow == null)
12101210
{
12111211
MCSLogHandler._logProcessTimer.IsEnabled = true;
@@ -1668,7 +1668,7 @@ private void LogHandleInfo(string msg)
16681668
getServerInfoLine = 101;
16691669
Dispatcher.InvokeAsync(() =>
16701670
{
1671-
PrintLog("已成功开启服务器!你可以输入stop来关闭服务器!\r\n服务器本地IP通常为:127.0.0.1,想要远程进入服务器,需要开通公网IP或使用内网映射,详情查看开服器的内网映射界面。\r\n若控制台输出乱码日志,请去更多功能界面修改“输出编码”。", Brushes.Green);
1671+
PrintLog("已成功开启服务器!你可以输入stop来关闭服务器!\r\n服务器本地IP通常为:127.0.0.1,想要远程进入服务器,需要开通公网IP或使用内网映射,详情查看开服器的内网映射界面。\r\n若控制台输出乱码日志,请去更多功能界面修改“输出编码”。", ConfigStore.LogColor.INFO);
16721672
Growl.Success(string.Format("服务器 {0} 已成功开启!", Rservername));
16731673
serverStateLab.Content = "已开服";
16741674
if (conptyWindow != null)
@@ -1682,7 +1682,7 @@ private void LogHandleInfo(string msg)
16821682
{
16831683
Dispatcher.InvokeAsync(() =>
16841684
{
1685-
PrintLog("正在关闭服务器!", Brushes.Green);
1685+
PrintLog("正在关闭服务器!", ConfigStore.LogColor.INFO);
16861686
});
16871687

16881688
}
@@ -1896,6 +1896,7 @@ private void RemovePlayerFromList(string playerName)
18961896
(@"Error loading plugin '([^']+)'", "*无法加载插件!\n\t插件名称:{0}\n"),
18971897
(@"Error occurred while enabling (\S+) ", "*在启用 {0} 时发生了错误\n"),
18981898
(@"Encountered an unexpected exception", "*服务器出现意外崩溃,可能是由于模组冲突,请检查您的模组列表(如果使用的是整合包,请使用整合包制作方提供的Server专用包开服)\n"),
1899+
(@"net.minecraft.client.Main", "*您使用的似乎是客户端核心,无法开服,请使用正确的服务端核心再试!\n"),
18991900
};
19001901

19011902
private void ProblemSystemShow(string msg)
@@ -3090,7 +3091,7 @@ private async Task LoadJavaInfo()
30903091

30913092
for (int i = 0; i <= 10; i++)
30923093
{
3093-
if (MainWindow.ServerLink == null)
3094+
if (ConfigStore.ServerLink == null)
30943095
{
30953096
Thread.Sleep(1000);
30963097
}

MSL/langs/Lang.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MSL/langs/Lang.en-US.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,4 +637,7 @@ Update log:</value>
637637
<data name="Open" xml:space="preserve">
638638
<value>Open</value>
639639
</data>
640+
<data name="Confirm" xml:space="preserve">
641+
<value>Confirm</value>
642+
</data>
640643
</root>

MSL/langs/Lang.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@
129129
<data name="Collapse" xml:space="preserve">
130130
<value>收起</value>
131131
</data>
132+
<data name="Confirm" xml:space="preserve">
133+
<value>确定</value>
134+
</data>
132135
<data name="Disabled" xml:space="preserve">
133136
<value>已禁用</value>
134137
</data>

MSL/pages/About.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using MSL.langs;
2+
using MSL.utils;
23
using System.Windows.Controls;
34

45
namespace MSL.pages
@@ -15,7 +16,7 @@ public About()
1516

1617
private void Page_Loaded(object sender, System.Windows.RoutedEventArgs e)
1718
{
18-
AbortSoftwareCard.Title = string.Format(LanguageManager.Instance["Page_About_AboutMSL"], MainWindow.MSLVersion.ToString());
19+
AbortSoftwareCard.Title = string.Format(LanguageManager.Instance["Page_About_AboutMSL"], ConfigStore.MSLVersion.ToString());
1920
}
2021
}
2122
}

MSL/pages/Home.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private async void Page_Loaded(object sender, RoutedEventArgs e)
5050
isInit = true;
5151
}
5252
}
53-
else if (MainWindow.ServerLink != null && !cancellationToken.IsCancellationRequested)
53+
else if (ConfigStore.ServerLink != null && !cancellationToken.IsCancellationRequested)
5454
{
5555
await GetNotice();
5656
}
@@ -69,13 +69,13 @@ private async Task<bool> WaitForServerConnection(int timeoutSeconds, Cancellatio
6969
{
7070
for (int i = 0; i < timeoutSeconds && !cancellationToken.IsCancellationRequested; i++)
7171
{
72-
if (MainWindow.ServerLink != null)
72+
if (ConfigStore.ServerLink != null)
7373
{
7474
return true;
7575
}
7676
await Task.Delay(1000, cancellationToken);
7777
}
78-
return MainWindow.ServerLink != null;
78+
return ConfigStore.ServerLink != null;
7979
}
8080

8181
private async Task GetNotice(bool firstLoad = false)

0 commit comments

Comments
 (0)