From f768f0a1bb8d7966a814851c238451d1af5a5a9f Mon Sep 17 00:00:00 2001 From: bluepilledgreat <97983689+bluepilledgreat@users.noreply.github.com> Date: Fri, 27 Dec 2024 17:13:21 +0000 Subject: [PATCH] make startup more verbose --- Bloxstrap/App.xaml.cs | 7 +++++++ Bloxstrap/LaunchHandler.cs | 28 ++++++++++++++++++++++++++++ Bloxstrap/LaunchSettings.cs | 29 ++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 4fd8b793..50831213 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -291,15 +291,21 @@ protected override void OnStartup(StartupEventArgs e) if (installLocation is null) { Logger.Initialize(true); + Logger.WriteLine(LOG_IDENT, "Not installed, launching the installer"); LaunchHandler.LaunchInstaller(); } else { Paths.Initialize(installLocation); + Logger.WriteLine(LOG_IDENT, "Entering main logic"); + // ensure executable is in the install directory if (Paths.Process != Paths.Application && !File.Exists(Paths.Application)) + { + Logger.WriteLine(LOG_IDENT, "Copying to install directory"); File.Copy(Paths.Process, Paths.Application); + } Logger.Initialize(LaunchSettings.UninstallFlag.Active); @@ -328,6 +334,7 @@ protected override void OnStartup(StartupEventArgs e) } // you must *explicitly* call terminate when everything is done, it won't be called implicitly + Logger.WriteLine(LOG_IDENT, "Startup finished"); } } } diff --git a/Bloxstrap/LaunchHandler.cs b/Bloxstrap/LaunchHandler.cs index f76629b8..2dda0c92 100644 --- a/Bloxstrap/LaunchHandler.cs +++ b/Bloxstrap/LaunchHandler.cs @@ -11,21 +11,27 @@ public static class LaunchHandler { public static void ProcessNextAction(NextAction action, bool isUnfinishedInstall = false) { + const string LOG_IDENT = "LaunchHandler::ProcessNextAction"; + switch (action) { case NextAction.LaunchSettings: + App.Logger.WriteLine(LOG_IDENT, "Opening settings"); LaunchSettings(); break; case NextAction.LaunchRoblox: + App.Logger.WriteLine(LOG_IDENT, "Opening Roblox"); LaunchRoblox(LaunchMode.Player); break; case NextAction.LaunchRobloxStudio: + App.Logger.WriteLine(LOG_IDENT, "Opening Roblox Studio"); LaunchRoblox(LaunchMode.Studio); break; default: + App.Logger.WriteLine(LOG_IDENT, "Closing"); App.Terminate(isUnfinishedInstall ? ErrorCode.ERROR_INSTALL_USEREXIT : ErrorCode.ERROR_SUCCESS); break; } @@ -33,20 +39,40 @@ public static void ProcessNextAction(NextAction action, bool isUnfinishedInstall public static void ProcessLaunchArgs() { + const string LOG_IDENT = "LaunchHandler::ProcessLaunchArgs"; + // this order is specific if (App.LaunchSettings.UninstallFlag.Active) + { + App.Logger.WriteLine(LOG_IDENT, "Opening uninstaller"); LaunchUninstaller(); + } else if (App.LaunchSettings.MenuFlag.Active) + { + App.Logger.WriteLine(LOG_IDENT, "Opening settings"); LaunchSettings(); + } else if (App.LaunchSettings.WatcherFlag.Active) + { + App.Logger.WriteLine(LOG_IDENT, "Opening watcher"); LaunchWatcher(); + } else if (App.LaunchSettings.RobloxLaunchMode != LaunchMode.None) + { + App.Logger.WriteLine(LOG_IDENT, $"Opening bootstrapper ({App.LaunchSettings.RobloxLaunchMode})"); LaunchRoblox(App.LaunchSettings.RobloxLaunchMode); + } else if (!App.LaunchSettings.QuietFlag.Active) + { + App.Logger.WriteLine(LOG_IDENT, "Opening menu"); LaunchMenu(); + } else + { + App.Logger.WriteLine(LOG_IDENT, "Closing - quiet flag active"); App.Terminate(); + } } public static void LaunchInstaller() @@ -235,6 +261,8 @@ public static void LaunchRoblox(LaunchMode launchMode) }); dialog?.ShowBootstrapper(); + + App.Logger.WriteLine(LOG_IDENT, "Exiting"); } public static void LaunchWatcher() diff --git a/Bloxstrap/LaunchSettings.cs b/Bloxstrap/LaunchSettings.cs index 37901487..f2ae908c 100644 --- a/Bloxstrap/LaunchSettings.cs +++ b/Bloxstrap/LaunchSettings.cs @@ -72,6 +72,8 @@ public LaunchSettings(string[] args) _flagMap.Add(identifier, flag); } + int startIdx = 0; + // infer roblox launch uris if (Args.Length >= 1) { @@ -80,23 +82,31 @@ public LaunchSettings(string[] args) if (arg.StartsWith("roblox:", StringComparison.OrdinalIgnoreCase) || arg.StartsWith("roblox-player:", StringComparison.OrdinalIgnoreCase)) { + App.Logger.WriteLine(LOG_IDENT, "Got Roblox player argument"); RobloxLaunchMode = LaunchMode.Player; RobloxLaunchArgs = arg; + startIdx = 1; } } // parse - for (int i = 0; i < Args.Length; i++) + for (int i = startIdx; i < Args.Length; i++) { string arg = Args[i]; if (!arg.StartsWith('-')) + { + App.Logger.WriteLine(LOG_IDENT, $"Invalid argument: {arg}"); continue; + } string identifier = arg[1..]; if (!_flagMap.TryGetValue(identifier, out LaunchFlag? flag) || flag is null) + { + App.Logger.WriteLine(LOG_IDENT, $"Unknown argument: {identifier}"); continue; + } flag.Active = true; @@ -119,31 +129,48 @@ public LaunchSettings(string[] args) private void ParsePlayer(string? data) { + const string LOG_IDENT = "LaunchSettings::ParsePlayer"; + RobloxLaunchMode = LaunchMode.Player; if (!String.IsNullOrEmpty(data)) + { + App.Logger.WriteLine(LOG_IDENT, "Got Roblox launch arguments"); RobloxLaunchArgs = data; + } + else + { + App.Logger.WriteLine(LOG_IDENT, "No Roblox launch arguments were provided"); + } } private void ParseStudio(string? data) { + const string LOG_IDENT = "LaunchSettings::ParseStudio"; + RobloxLaunchMode = LaunchMode.Studio; if (String.IsNullOrEmpty(data)) + { + App.Logger.WriteLine(LOG_IDENT, "No Roblox launch arguments were provided"); return; + } if (data.StartsWith("roblox-studio:")) { + App.Logger.WriteLine(LOG_IDENT, "Got Roblox Studio launch arguments"); RobloxLaunchArgs = data; } else if (data.StartsWith("roblox-studio-auth:")) { + App.Logger.WriteLine(LOG_IDENT, "Got Roblox Studio Auth launch arguments"); RobloxLaunchMode = LaunchMode.StudioAuth; RobloxLaunchArgs = data; } else { // likely a local path + App.Logger.WriteLine(LOG_IDENT, "Got Roblox Studio local place file"); RobloxLaunchArgs = $"-task EditFile -localPlaceFile \"{data}\""; } }