private static LauncherErrorCode RunSingleInstance(bool shouldStartHidden) { try { // Only needed for Stride up to 2.x (and possibly 3.0): setup the StrideDir to make sure that it is passed to the underlying process (msbuild...etc.) Environment.SetEnvironmentVariable("SiliconStudioStrideDir", AppDomain.CurrentDomain.BaseDirectory); Environment.SetEnvironmentVariable("StrideDir", AppDomain.CurrentDomain.BaseDirectory); // We need to do that before starting recording metrics // TODO: we do not display Privacy Policy anymore from launcher, because it's either accepted from installer or shown again when a new version of GS with new Privacy Policy starts. Might want to reconsider that after the 2.0 free period PrivacyPolicyHelper.RestartApplication = SelfUpdater.RestartApplication; PrivacyPolicyHelper.EnsurePrivacyPolicyStride40(); // Install Metrics for the launcher using (Metrics = new MetricsClient(CommonApps.StrideLauncherAppId)) { // HACK: force resolve the presentation assembly prior to initializing the app. This is to fix an issue with XAML themes. // see issue PDX-2899 var txt = new Core.Presentation.Controls.TextBox(); GC.KeepAlive(txt); // prevent aggressive optimization from removing the line where we create the dummy TextBox. var instance = new LauncherInstance(); return(instance.Run(shouldStartHidden)); } } catch (Exception exception) { CrashReportHelper.HandleException(Dispatcher.CurrentDispatcher, exception); return(LauncherErrorCode.ErrorWhileRunningServer); } }
public void SaveSettings() { int oldPriv; int newPriv; switch (openId) { case 0: //Needed this way due to Toggle not having an OnClick and if toggle off it will fire an on value changed event which would close the whole popup firstCheck = false; MainAcceptToggle.isOn = false; firstCheck = false; MainScreen.SetActive(true); SettingsScreen.SetActive(false); InfoScreen.SetActive(false); AdsScreen.SetActive(false); break; case 1: oldPriv = Spil.Instance.GetPrivValue(); newPriv = SavePrivValue(); if (oldPriv != newPriv) { ShowInfoScreen(); } else { Destroy(PrivacyPolicyObject); Instance = null; } Spil.Instance.TrackPrivacyPolicyChanged(withPersonalisedAds, withPersonalisedContent, "GeneralSettingsScreen", false); break; case 2: oldPriv = Spil.Instance.GetPrivValue(); newPriv = SavePrivValue(); if (oldPriv != newPriv) { ShowInfoScreen(); } else { Destroy(PrivacyPolicyObject); Instance = null; } Spil.Instance.TrackPrivacyPolicyChanged(withPersonalisedAds, withPersonalisedContent, "AdsSettingsScreen", false); break; } }
void Awake() { if (Instance == null) { Instance = FindObjectOfType <PrivacyPolicyHelper>(); if (Instance == null) { throw new NullReferenceException("Could not find a gameobject in the scene named \"PrivacyPolicy\"."); } } SetupScreens(); }
private static LauncherErrorCode Uninstall() { try { // Kill all running processes var path = new UFile(Assembly.GetEntryAssembly().Location).GetFullDirectory().ToWindowsPath(); if (!UninstallHelper.CloseProcessesInPath(DisplayMessage, "Stride", path)) { return(LauncherErrorCode.UninstallCancelled); // User cancelled } // Uninstall packages (they might have uninstall actions) var store = new NugetStore(path); foreach (var package in store.MainPackageIds.SelectMany(store.GetLocalPackages).FilterStrideMainPackages().ToList()) { store.UninstallPackage(package, null).Wait(); } foreach (var remainingFiles in Directory.GetFiles(path, "*.lock").Concat(Directory.GetFiles(path, "*.old"))) { try { File.Delete(remainingFiles); } catch (Exception e) { e.Ignore(); } } PrivacyPolicyHelper.RevokeAllPrivacyPolicy(); return(LauncherErrorCode.Success); } catch (Exception) { return(LauncherErrorCode.ErrorWhileUninstalling); } }
public void PrivacyPolicyAccepted() { if (firstCheck) { SavePrivValue(); #if UNITY_EDITOR PlayerPrefs.SetInt(Spil.Instance.GetSpilUserId() + "-unityPrivacyPolicyStatus", 1); #else PlayerPrefs.SetInt("unityPrivacyPolicyStatus", 1); #endif Destroy(PrivacyPolicyObject); Instance = null; SpilUnityImplementationBase.firePrivacyPolicyStatus(true); Spil.Instance.TrackPrivacyPolicyChanged(withPersonalisedAds, withPersonalisedContent, "StartScreen", true); } else { firstCheck = true; } }
public static void Main() { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; EditorPath.EditorTitle = XenkoGameStudio.EditorName; if (IntPtr.Size == 4) { MessageBox.Show("Xenko GameStudio requires a 64bit OS to run.", "Xenko", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); } PrivacyPolicyHelper.RestartApplication = RestartApplication; PrivacyPolicyHelper.EnsurePrivacyPolicyXenko30(); // Set the XenkoDir environment variable var installDir = DirectoryHelper.GetInstallationDirectory("Xenko"); Environment.SetEnvironmentVariable("XenkoDir", installDir); // We use MRU of the current version only when we're trying to reload last session. var mru = new MostRecentlyUsedFileCollection(InternalSettings.LoadProfileCopy, InternalSettings.MostRecentlyUsedSessions, InternalSettings.WriteFile, XenkoGameStudio.EditorVersionMajor, false); mru.LoadFromSettings(); EditorSettings.Initialize(); Thread.CurrentThread.Name = "Main thread"; // Install Metrics for the editor using (XenkoGameStudio.MetricsClient = new MetricsClient(CommonApps.XenkoEditorAppId)) { try { // Environment.GetCommandLineArgs correctly process arguments regarding the presence of '\' and '"' var args = Environment.GetCommandLineArgs().Skip(1).ToList(); var startupSessionPath = XenkoEditorSettings.StartupSession.GetValue(); var lastSessionPath = EditorSettings.ReloadLastSession.GetValue() ? mru.MostRecentlyUsedFiles.FirstOrDefault() : null; var initialSessionPath = !UPath.IsNullOrEmpty(startupSessionPath) ? startupSessionPath : lastSessionPath?.FilePath; // Handle arguments for (var i = 0; i < args.Count; i++) { if (args[i] == "/LauncherWindowHandle") { windowHandle = new IntPtr(long.Parse(args[++i])); } else if (args[i] == "/NewProject") { initialSessionPath = null; } else if (args[i] == "/DebugEditorGraphics") { EmbeddedGame.DebugMode = true; } else if (args[i] == "/RenderDoc") { // TODO: RenderDoc is not working here (when not in debug) GameStudioPreviewService.DisablePreview = true; renderDocManager = new RenderDocManager(); } else if (args[i] == "/Reattach") { var debuggerProcessId = int.Parse(args[++i]); if (!System.Diagnostics.Debugger.IsAttached) { using (var debugger = VisualStudioDebugger.GetByProcess(debuggerProcessId)) { debugger?.Attach(); } } } else if (args[i] == "/RecordEffects") { GameStudioBuilderService.GlobalEffectLogPath = args[++i]; } else { initialSessionPath = args[i]; } } RuntimeHelpers.RunModuleConstructor(typeof(Asset).Module.ModuleHandle); //listen to logger for crash report GlobalLogger.GlobalMessageLogged += GlobalLoggerOnGlobalMessageLogged; mainDispatcher = Dispatcher.CurrentDispatcher; mainDispatcher.InvokeAsync(() => Startup(initialSessionPath)); using (new WindowManager(mainDispatcher)) { app = new App { ShutdownMode = ShutdownMode.OnExplicitShutdown }; app.Activated += (sender, eventArgs) => { XenkoGameStudio.MetricsClient?.SetActiveState(true); }; app.Deactivated += (sender, eventArgs) => { XenkoGameStudio.MetricsClient?.SetActiveState(false); }; app.InitializeComponent(); app.Run(); } renderDocManager?.Shutdown(); } catch (Exception e) { HandleException(e, 0); } } }
public static void Main() { // wait, are we already running? int waitToClose = 16; while (Process.GetProcessesByName("Focus.GameStudio").Length > 1) { if (waitToClose-- <= 0) { MessageBox.Show("Focus GameStudio is already running! Only one instance is possible at a time.", "Focus", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); } Thread.Sleep(250); } AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; EditorPath.EditorTitle = XenkoGameStudio.EditorName; if (IntPtr.Size == 4) { MessageBox.Show(EngineName + " " + GameStudioName + " requires a 64bit OS to run.", "Focus", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); } PrivacyPolicyHelper.RestartApplication = RestartApplication; PrivacyPolicyHelper.EnsurePrivacyPolicyXenko30(); // We use MRU of the current version only when we're trying to reload last session. var mru = new MostRecentlyUsedFileCollection(InternalSettings.LoadProfileCopy, InternalSettings.MostRecentlyUsedSessions, InternalSettings.WriteFile); mru.LoadFromSettings(); EditorSettings.Initialize(); Thread.CurrentThread.Name = "EditorGameThread (GameStudio)"; EntityManager.EnforceThreads = false; try { // Environment.GetCommandLineArgs correctly process arguments regarding the presence of '\' and '"' var args = Environment.GetCommandLineArgs().Skip(1).ToList(); var startupSessionPath = XenkoEditorSettings.StartupSession.GetValue(); var lastSessionPath = EditorSettings.ReloadLastSession.GetValue() ? mru.MostRecentlyUsedFiles.FirstOrDefault() : null; var initialSessionPath = !UPath.IsNullOrEmpty(startupSessionPath) ? startupSessionPath : lastSessionPath?.FilePath; // Handle arguments for (var i = 0; i < args.Count; i++) { if (args[i] == "/LauncherWindowHandle") { windowHandle = new IntPtr(long.Parse(args[++i])); } else if (args[i] == "/NewProject") { initialSessionPath = null; } else if (args[i] == "/DebugEditorGraphics") { EmbeddedGame.DebugMode = true; } else if (args[i] == "/RenderDoc") { // TODO: RenderDoc is not working here (when not in debug) GameStudioPreviewService.DisablePreview = true; renderDocManager = new RenderDocManager(); } else if (args[i] == "/Reattach") { var debuggerProcessId = int.Parse(args[++i]); if (!System.Diagnostics.Debugger.IsAttached) { using (var debugger = VisualStudioDebugger.GetByProcess(debuggerProcessId)) { debugger?.Attach(); } } } else if (args[i] == "/RecordEffects") { GameStudioBuilderService.GlobalEffectLogPath = args[++i]; } else { initialSessionPath = args[i]; } } RuntimeHelpers.RunModuleConstructor(typeof(Asset).Module.ModuleHandle); //listen to logger for crash report GlobalLogger.GlobalMessageLogged += GlobalLoggerOnGlobalMessageLogged; mainDispatcher = Dispatcher.CurrentDispatcher; mainDispatcher.InvokeAsync(() => Startup(initialSessionPath)); using (new WindowManager(mainDispatcher)) { app = new App { ShutdownMode = ShutdownMode.OnExplicitShutdown }; app.InitializeComponent(); app.Run(); } renderDocManager?.Shutdown(); } catch (Exception e) { HandleException(e, 0); } }