forked from ozkl/doomgeneric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.axaml.cs
40 lines (35 loc) · 1.24 KB
/
App.axaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Logging;
using Avalonia.Markup.Xaml;
using AvaloniaPlayer.Doom;
using InteropDoom;
namespace AvaloniaPlayer;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public static new App Current => (App)Application.Current!;
internal static AvaloniaDoomEngine DoomEngine { get; } = new();
public MainWindow MainWindow { get; private set; } = null!;
public override void OnFrameworkInitializationCompleted()
{
DoomRuntime.Engine = DoomEngine;
DoomEngine.Exit += (code) =>
{
UIThread.Post(() =>
{
Logger.TryGet(code != 0 ? LogEventLevel.Error : LogEventLevel.Information, "DOOM")
?.Log(this, $"Doom exited with code {code}, quitting");
MainWindow.Close();
});
};
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = MainWindow = new MainWindow();
DoomEngine.WindowTitleChanged += (title) => UIThread.Post(() => MainWindow.Title = title);
}
base.OnFrameworkInitializationCompleted();
}
}