Skip to content

Commit

Permalink
Ver 0.12.1-RC1: Performance Optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiroiame-Kusu committed May 8, 2024
1 parent ba0ef9c commit 8735386
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 76 deletions.
4 changes: 2 additions & 2 deletions Hakuu/Universal/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ internal static class Global
/// <summary>
/// 版本号
/// </summary>
public const string VERSION = "v0.12.0-RC1";
public const string VERSION = "v0.12.1-RC1";
//public static readonly string VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion.ToString();

/// <summary>
/// 分支
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Hakuu/Universal/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("0.12.0.1")]
[assembly: AssemblyFileVersion("0.12.0-RC1")]
[assembly: AssemblyVersion("0.12.1.0")]
[assembly: AssemblyFileVersion("0.12.1-RC1")]
Binary file modified Hakuu/Universal/Sources/net472/Updater.exe
Binary file not shown.
5 changes: 3 additions & 2 deletions Hakuu/Universal/Utils/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ public static void CheckVersion()
if (!Global.Settings.Hakuu.EnableGetUpdate)
{
return;
}else if(Global.BRANCH.Equals("Preview")){
}else if(!Global.BRANCH.Equals("Release")){
return;
}
try
{
JObject? jsonObject = (JsonConvert.DeserializeObject<JObject>(Net.Get("https://api.github.com/repos/Shiroiame-Kusu/Hakuu/releases/latest", "application/vnd.github.v3+json", "Hakuu").Await().Content.ReadAsStringAsync().Await()));
JObject? jsonObject = JsonConvert.DeserializeObject<JObject>(Net.Get("https://api.github.com/repos/Shiroiame-Kusu/Hakuu/releases/latest", "application/vnd.github.v3+json", "Hakuu").Await().Content.ReadAsStringAsync().Await());

if (jsonObject is null)
{
return;
Expand Down
5 changes: 5 additions & 0 deletions Hakuu/WPF/Windows/Catalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ public static class Settings
public static Pages.Settings.Hakuu? Hakuu { get; set; }
public static Pages.Settings.Container? Container { get; set; }
}
public static class WaitForUpdate
{
public static bool Server_Panel = false;
public static bool Server_Container = false;
}
}
}
46 changes: 22 additions & 24 deletions Hakuu/WPF/Windows/Pages/Server/Container.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,30 @@ public Container()
Navigation.Frame = null;
}
Catalog.Server.Container = this;
Task.Run(() => {
while (true)
{
string? ServerType = null;
try
{
ServerType = Global.Settings.Server.Path.Substring(Global.Settings.Server.Path.Length - 3);
}
catch
{
if (Catalog.WaitForUpdate.Server_Container) {
ContainerUpdater(Global.Settings.Server.Path.Substring(Global.Settings.Server.Path.Length - 3));
}
}
public void ContainerUpdater(string ServerType)
{
if (!string.IsNullOrEmpty(ServerType))
{

}
switch (ServerType)
{
case "jar":
Dispatcher.InvokeAsync(() => { MinecraftProperties.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.InvokeAsync(() => { PlayerList.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);
break;
default:
Dispatcher.InvokeAsync(() => { MinecraftProperties.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
Dispatcher.InvokeAsync(() => { PlayerList.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
break;
}
System.Threading.Thread.Sleep(500);
switch (ServerType)
{
case "jar":
Dispatcher.Invoke(() => { this.MinecraftProperties.Visibility = Visibility.Visible; });
Dispatcher.Invoke(() => { this.PlayerList.Visibility = Visibility.Visible; });
break;
default:
Dispatcher.Invoke(() => { this.MinecraftProperties.Visibility = Visibility.Collapsed; });
Dispatcher.Invoke(() => { this.PlayerList.Visibility = Visibility.Collapsed; });
break;
}
});


}
Catalog.WaitForUpdate.Server_Container = false;
}
}
}
62 changes: 19 additions & 43 deletions Hakuu/WPF/Windows/Pages/Server/Panel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,6 @@ public partial class Panel : UiPage
public Panel()
{
InitializeComponent();
if (!IsBackgroundTaskRunning)
{
IsBackgroundTaskRunning = true;
Task.Run(() => {

while (true)
{

string? ServerType = null;
if (!ServerManager.Status)
{
try
{
ServerType = Global.Settings.Server.Path.Substring(Global.Settings.Server.Path.Length - 3);
}
catch
{

}
if(ServerType != OldServerType)
{
switch (ServerType)
{
case "jar":
Dispatcher.InvokeAsync(() => { MEMSettings.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);

break;
default:
Dispatcher.InvokeAsync(() => { MEMSettings.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
break;
}
OldServerType = ServerType;
}

}

System.Threading.Thread.Sleep(500);
}
});
}




AutoJVMOptimization.IsChecked = Global.Settings.Server.AutoJVMOptimization;
_updateInfoTimer.Elapsed += (_, _) => UpdateInfos();
Expand All @@ -81,6 +38,10 @@ public Panel()
);
}
Catalog.Server.Panel = this;
if (Catalog.WaitForUpdate.Server_Panel)
{
PageUpdater(Global.Settings.Server.Path.Substring(Global.Settings.Server.Path.Length - 3));
}
}

private void Start_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -267,5 +228,20 @@ private void MaxRAM_TextChanged(object sender, TextChangedEventArgs e)
{
Global.Settings.Server.MaxRAM = MaxRAM.Text;
}
public void PageUpdater(string ServerType)
{

switch (ServerType)
{
case "jar":
this.Dispatcher.InvokeAsync(() => { this.MEMSettings.Visibility = Visibility.Visible; }, System.Windows.Threading.DispatcherPriority.Background);

break;
default:
this.Dispatcher.InvokeAsync(() => { this.MEMSettings.Visibility = Visibility.Collapsed; }, System.Windows.Threading.DispatcherPriority.Background);
break;
}
Catalog.WaitForUpdate.Server_Panel = false;
}
}
}
6 changes: 4 additions & 2 deletions Hakuu/WPF/Windows/Pages/Settings/Server.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
<TextBox
Name="Path"
IsReadOnly="True"
ToolTip="服务端的启动路径" />
ToolTip="服务端的启动路径"
TextChanged="Path_TextChanged"/>
<ui:Button
x:Name="Select"
Grid.Column="1"
Expand All @@ -52,7 +53,8 @@
<TextBox
Name="JavaSEPath"
IsReadOnly="True"
ToolTip="Java环境路径" />
ToolTip="Java环境路径"
/>
<ui:Button
x:Name="SelectJava"
Grid.Column="1"
Expand Down
29 changes: 28 additions & 1 deletion Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Microsoft.Win32;
using Hakuu.Core.Server;
using Hakuu.Utils;
using Microsoft.Win32;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -89,6 +92,7 @@ private void Select_Click(object sender, RoutedEventArgs e)
{
Path.Text = dialog.FileName;
Global.Settings.Server.Path = dialog.FileName;
PathChangeHandler();
if (Catalog.Server.Plugins != null) { Catalog.Server.Plugins.Load(); }
}
}
Expand All @@ -106,6 +110,29 @@ private void SelectJava_Click(object sender, RoutedEventArgs e)
Global.Settings.Server.JavaPath = dialog.FileName;
if (Catalog.Server.Plugins != null) { Catalog.Server.Plugins.Load(); }
}
}
private void Path_TextChanged(object sender, TextChangedEventArgs e) { }

private void PathChangeHandler()
{
if (!string.IsNullOrEmpty(Global.Settings.Server.Path)) {
try
{
Catalog.Server.Container.ContainerUpdater(Global.Settings.Server.Path.Substring(Global.Settings.Server.Path.Length - 3));

Check warning on line 121 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 121 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 121 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 121 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 121 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 121 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 121 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 121 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.
Catalog.Server.Panel.PageUpdater(Global.Settings.Server.Path.Substring(Global.Settings.Server.Path.Length - 3));

Check warning on line 122 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 122 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 122 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 122 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 122 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 122 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 122 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.

Check warning on line 122 in Hakuu/WPF/Windows/Pages/Settings/Server.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows (WPF)

Dereference of a possibly null reference.


}
catch(Exception ex)
{
Catalog.WaitForUpdate.Server_Panel = true;
Catalog.WaitForUpdate.Server_Container = true;
CrashInterception.ShowException(ex);
}
}



}
}
}

0 comments on commit 8735386

Please sign in to comment.