From 1c0b0886642a417131ed02ecbf1ef45f1fd0b5d4 Mon Sep 17 00:00:00 2001 From: ivanmilevtues Date: Sat, 10 Oct 2026 21:02:15 +0200 Subject: [PATCH] Record recent launches in LaunchHistory --- Bloxstrap/Integrations/LaunchHistory.cs | 47 +++++++++++++++++++++++++ Bloxstrap/LaunchHandler.cs | 2 ++ 2 files changed, 49 insertions(+) create mode 100644 Bloxstrap/Integrations/LaunchHistory.cs diff --git a/Bloxstrap/Integrations/LaunchHistory.cs b/Bloxstrap/Integrations/LaunchHistory.cs new file mode 100644 index 000000000..f77608253 --- /dev/null +++ b/Bloxstrap/Integrations/LaunchHistory.cs @@ -0,0 +1,47 @@ +using System.Text.Json; + +namespace Bloxstrap.Integrations +{ + /// + /// Keeps the last few launches (mode and time) next to Bloxstrap's own data, so the + /// settings window can show when Roblox or Studio was last opened. + /// + public static class LaunchHistory + { + private const int MaxEntries = 20; + + private static string FilePath => Path.Combine(Paths.Base, "LaunchHistory.json"); + + public record Entry(LaunchMode Mode, DateTime LaunchedAt); + + public static IReadOnlyList Load() + { + try + { + if (!File.Exists(FilePath)) + return Array.Empty(); + + return JsonSerializer.Deserialize>(File.ReadAllText(FilePath)) ?? new List(); + } + catch (Exception ex) + { + App.Logger.WriteException("LaunchHistory::Load", ex); + return Array.Empty(); + } + } + + public static void Record(LaunchMode mode) + { + var entries = Load().Prepend(new Entry(mode, DateTime.UtcNow)).Take(MaxEntries).ToList(); + + try + { + File.WriteAllText(FilePath, JsonSerializer.Serialize(entries)); + } + catch (Exception ex) + { + App.Logger.WriteException("LaunchHistory::Record", ex); + } + } + } +} diff --git a/Bloxstrap/LaunchHandler.cs b/Bloxstrap/LaunchHandler.cs index f21829f6a..342373c63 100644 --- a/Bloxstrap/LaunchHandler.cs +++ b/Bloxstrap/LaunchHandler.cs @@ -23,11 +23,13 @@ public static void ProcessNextAction(NextAction action, bool isUnfinishedInstall case NextAction.LaunchRoblox: App.Logger.WriteLine(LOG_IDENT, "Opening Roblox"); + Integrations.LaunchHistory.Record(LaunchMode.Player); LaunchRoblox(LaunchMode.Player); break; case NextAction.LaunchRobloxStudio: App.Logger.WriteLine(LOG_IDENT, "Opening Roblox Studio"); + Integrations.LaunchHistory.Record(LaunchMode.Studio); LaunchRoblox(LaunchMode.Studio); break;