From de82349e5eeee80ad9475a2b2457c118b8f94b61 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 13 Aug 2024 21:44:43 +0100 Subject: [PATCH] Clean up sloppiness in notification area icon --- Bloxstrap/Bootstrapper.cs | 10 +++++++++ Bloxstrap/Integrations/ActivityWatcher.cs | 10 +++------ Bloxstrap/Resources/Strings.Designer.cs | 26 +++++++++++++++++++---- Bloxstrap/Resources/Strings.resx | 13 ++++++++---- Bloxstrap/UI/NotifyIconWrapper.cs | 8 ++++++- 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 97b7dbb..906f3c9 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -337,6 +337,16 @@ namespace Bloxstrap App.NotifyIcon?.SetActivityWatcher(activityWatcher); + if (App.Settings.Prop.UseDisableAppPatch) + { + activityWatcher.OnAppClose += (_, _) => + { + App.Logger.WriteLine(LOG_IDENT, "Received desktop app exit, closing Roblox"); + using var process = Process.GetProcessById(gameClientPid); + process.CloseMainWindow(); + }; + } + if (App.Settings.Prop.UseDiscordRichPresence) { App.Logger.WriteLine(LOG_IDENT, "Using Discord Rich Presence"); diff --git a/Bloxstrap/Integrations/ActivityWatcher.cs b/Bloxstrap/Integrations/ActivityWatcher.cs index 0355a78..e15cd2d 100644 --- a/Bloxstrap/Integrations/ActivityWatcher.cs +++ b/Bloxstrap/Integrations/ActivityWatcher.cs @@ -27,6 +27,7 @@ public event EventHandler? OnLogEntry; public event EventHandler? OnGameJoin; public event EventHandler? OnGameLeave; + public event EventHandler? OnAppClose; public event EventHandler? OnRPCMessage; private readonly Dictionary GeolocationCache = new(); @@ -135,13 +136,8 @@ else if (_logEntriesRead % 100 == 0) App.Logger.WriteLine(LOG_IDENT, $"Read {_logEntriesRead} log entries"); - - if (App.Settings.Prop.UseDisableAppPatch && entry.Contains(GameLeavingEntry)) - { - App.Logger.WriteLine(LOG_IDENT, "Received desktop app exit, closing Roblox"); - using var process = Process.GetProcessById(_gameClientPid); - process.CloseMainWindow(); - } + if (entry.Contains(GameLeavingEntry)) + OnAppClose?.Invoke(this, new EventArgs()); if (!ActivityInGame && ActivityPlaceId == 0) { diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 4e7f870..1313ad5 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -666,7 +666,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Located at {0} + /// Looks up a localized string similar to Location: {0} ///Click for more information. /// public static string ContextMenu_ServerInformation_Notification_Text { @@ -676,11 +676,29 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Connected to {0} server. + /// Looks up a localized string similar to Connected to private server. /// - public static string ContextMenu_ServerInformation_Notification_Title { + public static string ContextMenu_ServerInformation_Notification_Title_Private { get { - return ResourceManager.GetString("ContextMenu.ServerInformation.Notification.Title", resourceCulture); + return ResourceManager.GetString("ContextMenu.ServerInformation.Notification.Title.Private", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Connected to public server. + /// + public static string ContextMenu_ServerInformation_Notification_Title_Public { + get { + return ResourceManager.GetString("ContextMenu.ServerInformation.Notification.Title.Public", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Connected to reserved server. + /// + public static string ContextMenu_ServerInformation_Notification_Title_Reserved { + get { + return ResourceManager.GetString("ContextMenu.ServerInformation.Notification.Title.Reserved", resourceCulture); } } diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 76b07ff..bd11ab2 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -287,12 +287,11 @@ Your ReShade configuration files will still be saved, and you can locate them by Location - Located at {0} + Location: {0} Click for more information - - Connected to {0} server - Enums.ServerType fills in {0} and is dynamically converted to lowercase when inserted here + + Connected to public server Server information @@ -1114,4 +1113,10 @@ If not, then please report this exception to the maintainers of this fork. Do NO Create shortcuts for quick access to specific functions. These will all be placed on the Desktop. + + Connected to private server + + + Connected to reserved server + \ No newline at end of file diff --git a/Bloxstrap/UI/NotifyIconWrapper.cs b/Bloxstrap/UI/NotifyIconWrapper.cs index 315acfb..e05f573 100644 --- a/Bloxstrap/UI/NotifyIconWrapper.cs +++ b/Bloxstrap/UI/NotifyIconWrapper.cs @@ -87,9 +87,15 @@ namespace Bloxstrap.UI public async void OnGameJoin() { string serverLocation = await _activityWatcher!.GetServerLocation(); + string title = _activityWatcher.ActivityServerType switch + { + ServerType.Public => Resources.Strings.ContextMenu_ServerInformation_Notification_Title_Public, + ServerType.Private => Resources.Strings.ContextMenu_ServerInformation_Notification_Title_Private, + ServerType.Reserved => Resources.Strings.ContextMenu_ServerInformation_Notification_Title_Reserved + }; ShowAlert( - String.Format(Resources.Strings.ContextMenu_ServerInformation_Notification_Title, _activityWatcher.ActivityServerType.ToTranslatedString().ToLower()), + title, String.Format(Resources.Strings.ContextMenu_ServerInformation_Notification_Text, serverLocation), 10, (_, _) => _menuContainer?.ShowServerInformationWindow()