mirror of
https://github.com/sp-tarkov/patcher.git
synced 2025-02-13 06:10:47 -05:00
64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
using Avalonia.Markup.Xaml;
|
|
using PatchClient.ViewModels;
|
|
using PatchClient.Views;
|
|
using ReactiveUI;
|
|
using System.Reactive;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using PatcherUtils.Model;
|
|
|
|
namespace PatchClient
|
|
{
|
|
public class App : Application
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
|
RxApp.DefaultExceptionHandler = Observer.Create<Exception>((exception) =>
|
|
{
|
|
PatchLogger.LogException(exception);
|
|
});
|
|
}
|
|
|
|
public override void OnFrameworkInitializationCompleted()
|
|
{
|
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
{
|
|
bool autoClose = false;
|
|
bool debugOutput = false;
|
|
|
|
if (desktop.Args != null && desktop.Args.Length >= 1)
|
|
{
|
|
autoClose = desktop.Args.Any(x => x.ToLower() == "autoclose");
|
|
debugOutput = desktop.Args.Any(x => x.ToLower() == "debug");
|
|
}
|
|
|
|
if (debugOutput)
|
|
{
|
|
PatchLogger.LogInfo("Running in debug mode");
|
|
}
|
|
|
|
if (autoClose)
|
|
{
|
|
PatchLogger.LogInfo("Running with autoclose");
|
|
}
|
|
|
|
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
|
|
|
PatchLogger.LogInfo($"Patch Client v{version?.ToString() ?? "N/A"}");
|
|
|
|
desktop.MainWindow = new MainWindow
|
|
{
|
|
DataContext = new MainWindowViewModel(autoClose, debugOutput),
|
|
};
|
|
}
|
|
|
|
base.OnFrameworkInitializationCompleted();
|
|
}
|
|
}
|
|
}
|