Repository navigation
Record recent launches in LaunchHistory #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| using System.Text.Json; | ||
|
|
||
| namespace Bloxstrap.Integrations | ||
| { | ||
| /// <summary> | ||
| /// 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. | ||
| /// </summary> | ||
| 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<Entry> Load() | ||
| { | ||
| try | ||
| { | ||
| if (!File.Exists(FilePath)) | ||
| return Array.Empty<Entry>(); | ||
|
|
||
| return JsonSerializer.Deserialize<List<Entry>>(File.ReadAllText(FilePath)) ?? new List<Entry>(); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| App.Logger.WriteException("LaunchHistory::Load", ex); | ||
| return Array.Empty<Entry>(); | ||
| } | ||
| } | ||
|
|
||
| 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)); | ||
|
Comment on lines
+35
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| } | ||
| catch (Exception ex) | ||
| { | ||
| App.Logger.WriteException("LaunchHistory::Record", ex); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The history hook exists only in Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This records the launch before Useful? React with 👍 / 👎. |
||
| LaunchRoblox(LaunchMode.Player); | ||
| break; | ||
|
|
||
| case NextAction.LaunchRobloxStudio: | ||
| App.Logger.WriteLine(LOG_IDENT, "Opening Roblox Studio"); | ||
| Integrations.LaunchHistory.Record(LaunchMode.Studio); | ||
| LaunchRoblox(LaunchMode.Studio); | ||
| break; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When uninstalling with “Keep my settings and mods” disabled,
Installer.DoUninstall(false)deletes the known settings, state, logs, and modifications but never deletes this new file. For installations with more than three top-level files, line 317 ofInstaller.csalso prevents removal of the entire base directory, soLaunchHistory.jsonand its usage timestamps remain after uninstall; add it to the non-keep-data cleanup sequence.Useful? React with 👍 / 👎.