using SpaceEngineersBlueprintEditor.SpaceEngineersCore; using SpaceEngineersBlueprintEditor.Utilities; using SpaceEngineersBlueprintEditor.Views; using XFEExtension.NetCore.StringExtension; using XFEExtension.NetCore.WinUIHelper.Interface.Services; using XFEExtension.NetCore.WinUIHelper.Utilities; using RuntimeGameAssemblyLoader = SpaceEngineersBlueprintEditor.GameAssemblyLoader.GameAssemblyLoader; namespace SpaceEngineersBlueprintEditor; /// /// Provides application-specific behavior to supplement the default Application class. /// public partial class App : Application { public static MainWindow MainWindow { get; set; } = null!; public App() { var gameRootPath = RuntimeGameAssemblyLoader.Initialize(SystemProfile.GameRootPath); if (!gameRootPath.IsNullOrEmpty() && !string.Equals(SystemProfile.GameRootPath, gameRootPath, StringComparison.OrdinalIgnoreCase)) SystemProfile.GameRootPath = gameRootPath; this.InitializeComponent(); PageManager.RegisterPage(typeof(AppShellPage)); PageManager.RegisterPage(typeof(MainPage)); PageManager.RegisterPage(typeof(BlueprintEditPage)); PageManager.RegisterPage(typeof(BlueprintsViewPage)); PageManager.RegisterPage(typeof(GameDefinitionsViewPage)); PageManager.RegisterPage(typeof(BlueprintDetailPage)); PageManager.RegisterPage(typeof(SettingPage)); Task.Run(BlueprintsManager.LoadBlueprintsAsync); Task.Run(() => { try { RuntimeGameAssemblyLoader.EnsureInitialized(SystemProfile.GameRootPath); Initializer.Initialize(SpaceEngineersPath.SpaceEngineerContentPath, SpaceEngineersPath.UserGameDataRoot); } catch (Exception ex) { ServiceManager.GetGlobalService()?.ShowMessage($"{"Error_LoadingDefinitions".GetLocalized()}: {ex.Message}", "Error_LoadingDefinitions_Title".GetLocalized(), InfoBarSeverity.Error); } }); UnhandledException += App_UnhandledException; } private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) { if (ServiceManager.GetGlobalService() is IMessageService messageService) { messageService.ShowMessage(e.Message, "Error".GetLocalized(), InfoBarSeverity.Error); e.Handled = true; } } /// /// Invoked when the application is launched. /// /// Details about the launch request and process. protected override void OnLaunched(LaunchActivatedEventArgs args) { MainWindow = new MainWindow(); MainWindow.Content = new AppShellPage(); MainWindow.Activate(); } }