public static void CreateAndRun(bool forceSoftwareRenderingMode) { FilesStorage.Initialize(EntryPoint.ApplicationDataDirectory); if (!AppArguments.GetBool(AppFlag.DisableLogging)) { var logFilename = EntryPoint.GetLogName("Main Log"); Logging.Initialize(FilesStorage.Instance.GetFilename("Logs", logFilename), AppArguments.GetBool(AppFlag.OptimizeLogging)); Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})"); } if (AppArguments.GetBool(AppFlag.DisableSaving)) { ValuesStorage.Initialize(); CacheStorage.Initialize(); AuthenticationStorage.Initialize(); } else { ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"), InternalUtils.GetValuesStorageEncryptionKey(), AppArguments.GetBool(AppFlag.DisableValuesCompression)); CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); AuthenticationStorage.Initialize(FilesStorage.Instance.GetFilename("Authentication.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); if (MathUtils.Random(0, 10) == 0) { LazierCached.Purge(); } FatalErrorHandler.FatalError += OnFatalError; } if (AppArguments.GetBool(AppFlag.NoProxy, true)) { WebRequest.DefaultWebProxy = null; } NonfatalError.Initialize(); LocaleHelper.InitializeAsync().Wait(); var softwareRenderingModeWasEnabled = IsSoftwareRenderingModeEnabled(); if (forceSoftwareRenderingMode) { ValuesStorage.Set(AppAppearanceManager.KeySoftwareRendering, true); } if (IsSoftwareRenderingModeEnabled()) { SwitchToSoftwareRendering(); } var app = new App(); // Some sort of safe mode if (forceSoftwareRenderingMode && !softwareRenderingModeWasEnabled) { Toast.Show("Safe mode", "Failed to start the last time, now CM uses software rendering", () => { if (ModernDialog.ShowMessage( "Would you like to switch back to hardware rendering? You can always do that in Settings/Appearance. App will be restarted.", "Switch back", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ValuesStorage.Set(AppAppearanceManager.KeySoftwareRendering, false); Storage.SaveBeforeExit(); // Just in case WindowsHelper.RestartCurrentApplication(); } }); } app.Run(); }
public static void CreateAndRun(bool forceSoftwareRenderingMode) { FilesStorage.Initialize(EntryPoint.ApplicationDataDirectory); if (!AppArguments.GetBool(AppFlag.DisableLogging)) { var logFilename = EntryPoint.GetLogName("Main Log"); Logging.Initialize(FilesStorage.Instance.GetFilename("Logs", logFilename), AppArguments.GetBool(AppFlag.OptimizeLogging)); Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})"); } if (AppArguments.GetBool(AppFlag.DisableSaving)) { ValuesStorage.Initialize(); CacheStorage.Initialize(); AuthenticationStorage.Initialize(); } else { ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"), InternalUtils.GetValuesStorageEncryptionKey(), AppArguments.GetBool(AppFlag.DisableValuesCompression)); CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); AuthenticationStorage.Initialize(FilesStorage.Instance.GetFilename("Authentication.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); if (MathUtils.Random(0, 10) == 0) { LazierCached.Purge(); } FatalErrorHandler.FatalError += OnFatalError; } if (AppArguments.GetBool(AppFlag.NoProxy, true)) { WebRequest.DefaultWebProxy = null; } NonfatalError.Initialize(); LocaleHelper.InitializeAsync().Wait(); var softwareRenderingModeWasEnabled = IsSoftwareRenderingModeEnabled(); if (forceSoftwareRenderingMode) { ValuesStorage.Set(AppAppearanceManager.KeySoftwareRendering, true); } if (IsSoftwareRenderingModeEnabled()) { SwitchToSoftwareRendering(); } var app = new App(); // Some sort of safe mode if (forceSoftwareRenderingMode && !softwareRenderingModeWasEnabled) { Toast.Show("Safe mode", "Failed to start the last time, now CM uses software rendering", () => { if (MessageDialog.Show( "Would you like to switch back to hardware rendering? You can always do that in Settings/Appearance. App will be restarted.", "Switch back", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ValuesStorage.Set(AppAppearanceManager.KeySoftwareRendering, false); Storage.SaveBeforeExit(); // Just in case WindowsHelper.RestartCurrentApplication(); } }); } var move = AppArguments.Get(AppFlag.MoveApp); if (move != null && File.Exists(move)) { for (var i = 0; i < 10; i++) { if (FileUtils.TryToDelete(move) || !File.Exists(move)) { break; } Thread.Sleep(100); } Toast.Show("App moved", $"App moved from AC root folder, now Oculus Rift should work better", () => { var originalRemoved = File.Exists(move) ? "failed to remove original file" : "original file removed"; if (MessageDialog.Show( $"New location is “{MainExecutingFile.Location}”, {originalRemoved}. Please don’t forget to recreate any shortcuts you might have created.", "Content Manager is moved", new MessageDialogButton { [MessageBoxResult.Yes] = "View new location", [MessageBoxResult.No] = UiStrings.Ok }) == MessageBoxResult.Yes) { WindowsHelper.ViewFile(MainExecutingFile.Location); } }); } app.Run(); }