Skip to content

Commit ca5fa78

Browse files
Improve/app startup time (#65)
2 parents e69de25 + 82e60fd commit ca5fa78

5 files changed

Lines changed: 14 additions & 2 deletions

File tree

PocketMC.Desktop/App.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ protected override async void OnStartup(StartupEventArgs e)
8787

8888
var updateWindow = Services.GetRequiredService<PocketMC.Desktop.Features.Shell.StartupUpdateWindow>();
8989
updateWindow.StartUpdateCheck();
90+
PocketMC.Desktop.Program.Splash?.Close(TimeSpan.Zero);
9091
updateWindow.ShowDialog();
9192

9293
if (!updateWindow.ShouldContinueToApp)
@@ -107,10 +108,12 @@ protected override async void OnStartup(StartupEventArgs e)
107108

108109
if (startupOptions.ShouldStartMinimizedToTray)
109110
{
111+
PocketMC.Desktop.Program.Splash?.Close(TimeSpan.Zero);
110112
mainWindow.ShowMinimizedToTray();
111113
}
112114
else
113115
{
116+
PocketMC.Desktop.Program.Splash?.Close(TimeSpan.Zero);
114117
mainWindow.Show();
115118
}
116119

PocketMC.Desktop/Assets/splash.png

101 KB
Loading

PocketMC.Desktop/PocketMC.Desktop.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
<UseWPF>true</UseWPF>
66
<ApplicationIcon>icon.ico</ApplicationIcon>
77
<StartupObject>PocketMC.Desktop.Program</StartupObject>
8+
<PublishReadyToRun>true</PublishReadyToRun>
89
<NoWarn>$(NoWarn);CS0105</NoWarn>
910
</PropertyGroup>
1011

1112
<ItemGroup>
1213
<EmbeddedResource Include="$(MSBuildProjectDirectory)\..\pocketmc.yml" LogicalName="PocketMC.Desktop.pocketmc.yml" />
1314
<Resource Include="icon.ico" />
1415
<Resource Include="Assets\dark_dirt.png" />
15-
<Resource Include="Assets\logo.png" />
16+
<SplashScreen Include="Assets\logo.png" />
1617
<Resource Include="Assets\logo_highres.png" />
18+
<Resource Include="Assets\splash.png" />
1719
<Content Include="Assets\default_wallpaper.png" CopyToOutputDirectory="PreserveNewest" />
1820
<Content Include="Assets\WhatsNew.txt" CopyToOutputDirectory="PreserveNewest" />
1921
<Content Include="Features\RemoteControl\Web\**\*.*" CopyToOutputDirectory="PreserveNewest" />

PocketMC.Desktop/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace PocketMC.Desktop;
88

99
public static class Program
1010
{
11+
public static System.Windows.SplashScreen? Splash { get; private set; }
12+
1113
private const ShortcutLocation ShortcutRefreshLocations = ShortcutLocation.Desktop | ShortcutLocation.StartMenuRoot;
1214

1315
[System.Runtime.InteropServices.DllImport("Shell32.dll")]
@@ -68,6 +70,11 @@ public static void Main(string[] args)
6870

6971
try
7072
{
73+
// Show splash screen manually because we have a custom Main method
74+
// Use autoClose: false so we can close it instantly with 0ms fade later
75+
Splash = new System.Windows.SplashScreen("assets/splash.png");
76+
Splash.Show(false, topMost: true);
77+
7178
// Normal WPF startup
7279
var app = new App();
7380
app.InitializeComponent();

pocketmc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: 1.9.6
2-
channel: beta
2+
channel:
33
auth_proxies:
44
- "https://pocket-mc-proxy-20d5.onrender.com"
55
- "https://pocket-mc-proxy-n2qx.onrender.com"

0 commit comments

Comments
 (0)