private void _ShutdownErrorReporting() { // Remove event handlers first! AppDomain.CurrentDomain.UnhandledException -= _AppDomainUnhandledException; DispatcherUnhandledException -= _DispatcherUnhandledException; TaskScheduler.UnobservedTaskException -= _TaskSchedulerUnobservedTaskException; if (_uploader != null) { if (_uploader.HasPendingWork) { Splashscreen.ShowSplash("Waiting for uploader to finish ..."); string msg = ""; while (_uploader.HasPendingWork) { msg += "."; Splashscreen.SetMessage(msg); Thread.Sleep(250); } Splashscreen.HideSplash(); } _uploader.Close(); } _uploader = null; }
protected void _Init() { Splashscreen.SetMessage("Creating main window"); // Load options // - Position window if (Config.Root.HasSection("window")) { if (Config.Root.window.HasItem("state") && Config.Root.window.state == WindowState.Maximized.ToString()) { WindowState = WindowState.Maximized; } else { if (Config.Root.window.HasItem("pos_x") && Config.Root.window.pos_x != -1) { Left = Config.Root.window.pos_x; Top = Config.Root.window.pos_y; Width = Config.Root.window.size_x; Height = Config.Root.window.size_y; } else { WindowStartupLocation = WindowStartupLocation.CenterScreen; } } // - Position splitter if (Config.Root.window.HasItem("splitter")) { if (Config.Root.window.splitter != -1) { MainGrid.ColumnDefinitions[0].Width = new GridLength(Config.Root.window.splitter); } } } #if !DEVENV if (Config.Root.HasSection("update_check") && Config.Root.update_check.HasItem("check_for_updates") && Config.Root.update_check.check_for_updates) { Splashscreen.SetMessage("Checking for updates"); _RunUpdateChecker(true); } #endif _SetupMRU(); Splashscreen.SetMessage("Registering plugins"); ActionFactory.AddToMenu(actions_menu, Actions_Click); _SetStatusbar(); Details.Modified += Details_Modified; // Finally, update menu states _UpdateUIState(); // Close splash Splashscreen.HideSplash(); }
// - Second, init remain based on actual config instance internal static void Init() { Splashscreen.ShowSplash("Starting up..."); Application.Current.MainWindow = null; // Note version Log.Info("{0}, version {1}", APPNAME, APPVERSION); if (!Config.Root.HasSection("core")) { Config.Root.AddSection("core"); } // Pick suitable default language if setting is missing Splashscreen.SetMessage("Setting up language"); if (!Config.Root.core.HasItem("language")) { Config.Root.core.AddItem("language"); } if (string.IsNullOrEmpty(Config.Root.core.language)) { Config.Root.core.language = Thread.CurrentThread.CurrentUICulture.Name; } if (!LanguageHandler.LANG.LanguagesAvail.ToList().Contains(Config.Root.core.language)) { Config.Root.core.language = "en-US"; //Fallback to a language known } // Setup actual language for translations Splashscreen.SetMessage("Loading language resources"); LANGUAGE = Config.Root.core.language; LanguageHandler.LANG.SelectLanguage(LANGUAGE); Thread.CurrentThread.CurrentUICulture = new CultureInfo(LANGUAGE); // Create defaultpath setting if not set up yet Splashscreen.SetMessage("Setting up default savegame path"); if (!Config.Root.core.HasItem("defaultpath")) { Config.Root.core.AddItem("defaultpath"); } if (string.IsNullOrEmpty(Config.Root.core.defaultpath) || !Directory.Exists(Config.Root.core.defaultpath)) { string subpath = Path.Combine("FactoryGame", "Saved", "SaveGames"); string path = Environment.GetEnvironmentVariable("LOCALAPPDATA"); if (path != null) { path = Path.Combine(path, subpath); if (!Directory.Exists(path)) { path = null; } } if (path == null) { path = Environment.GetEnvironmentVariable("APPDATA"); if (path != null) { path = Path.Combine(path, "..", subpath); if (!Directory.Exists(path)) { path = null; } } } if (path == null) { path = Environment.GetEnvironmentVariable("USERPROFILE"); if (path != null) { path = Path.Combine(path, "ApplicationData", "Local", subpath); if (!Directory.Exists(path)) { path = null; } } } Config.Root.core.defaultpath = path; } // Read user id from registry, resp. create one if none was found in registry string id = null; try { using (RegistryKey key = Helpers.OpenRegKey(Registry.CurrentUser, "SOFTWARE/Epic Games/Unreal Engine/Identifiers")) { if (key != null) { id = key.GetValue("AccountId") as string; } } } catch { } if (id == null) { id = Environment.UserName + Environment.MachineName; } if (id != null) { // Create anonymous id on info found using (SHA256 sha = SHA256.Create()) { byte[] arr = Encoding.ASCII.GetBytes(id); USER_KEY = sha.ComputeHash(arr); USER_ID = BitConverter.ToString(USER_KEY).Replace("-", ""); } } // Setup export path if (!Config.Root.core.HasItem("exportpath")) { Config.Root.core.AddItem("exportpath", ""); } if (string.IsNullOrEmpty(Config.Root.core.exportpath) || !Directory.Exists(Config.Root.core.exportpath)) { Config.Root.core.exportpath = Path.Combine(APPPATH, EXPORTS); } EXPORTPATH = Config.Root.core.exportpath; // Create any missing config before continuing if (!Config.Root.HasSection("update_check")) { Config.Root.AddSection("update_check"); } if (!Config.Root.update_check.HasItem("check_for_updates")) { Config.Root.update_check.AddItem("check_for_updates", true); } if (!Config.Root.HasSection("deep_analysis")) { Config.Root.AddSection("deep_analysis"); } if (!Config.Root.deep_analysis.HasItem("enabled")) { Config.Root.deep_analysis.AddItem("enabled", false); } if (!Config.Root.HasSection("crash_reports")) { Config.Root.AddSection("crash_reports"); } if (!Config.Root.crash_reports.HasItem("enabled")) { Config.Root.crash_reports.AddItem("enabled", false); } if (!Config.Root.HasSection("incident_reports")) { Config.Root.AddSection("incident_reports"); } if (!Config.Root.incident_reports.HasItem("enabled")) { Config.Root.incident_reports.AddItem("enabled", false); } if (!Config.Root.HasSection("online_mapping")) { Config.Root.AddSection("online_mapping"); } if (!Config.Root.online_mapping.HasItem("enabled")) { Config.Root.online_mapping.AddItem("enabled", false); } }