From 83856acaecec6eac5eb32545697c5ea7200343d6 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 25 Jul 2023 19:39:31 +0100 Subject: [PATCH] RobloxActivity -> Integrations.ActivityWatcher --- Bloxstrap/Bootstrapper.cs | 2 +- Bloxstrap/Integrations/DiscordRichPresence.cs | 4 ++-- Bloxstrap/{ => Integrations}/RobloxActivity.cs | 16 ++++++++-------- .../UI/Elements/ContextMenu/LogTracer.xaml.cs | 3 ++- .../Elements/ContextMenu/MenuContainer.xaml.cs | 4 ++-- .../ContextMenu/ServerInformation.xaml.cs | 3 ++- Bloxstrap/UI/NotifyIconWrapper.cs | 4 ++-- .../ViewModels/ContextMenu/LogTracerViewModel.cs | 6 ++++-- .../ContextMenu/ServerInformationViewModel.cs | 6 +++--- 9 files changed, 26 insertions(+), 22 deletions(-) rename Bloxstrap/{ => Integrations}/RobloxActivity.cs (96%) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 398f6e5..24f9db2 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -236,7 +236,7 @@ namespace Bloxstrap } List autocloseProcesses = new(); - RobloxActivity? activityWatcher = null; + ActivityWatcher? activityWatcher = null; DiscordRichPresence? richPresence = null; App.Logger.WriteLine(LOG_IDENT, $"Started Roblox (PID {gameClientPid})"); diff --git a/Bloxstrap/Integrations/DiscordRichPresence.cs b/Bloxstrap/Integrations/DiscordRichPresence.cs index 4c0bcb6..a2f0b0a 100644 --- a/Bloxstrap/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Integrations/DiscordRichPresence.cs @@ -5,7 +5,7 @@ namespace Bloxstrap.Integrations public class DiscordRichPresence : IDisposable { private readonly DiscordRpcClient _rpcClient = new("1005469189907173486"); - private readonly RobloxActivity _activityWatcher; + private readonly ActivityWatcher _activityWatcher; private RichPresence? _currentPresence; private bool _visible = true; @@ -13,7 +13,7 @@ namespace Bloxstrap.Integrations private long _currentUniverseId; private DateTime? _timeStartedUniverse; - public DiscordRichPresence(RobloxActivity activityWatcher) + public DiscordRichPresence(ActivityWatcher activityWatcher) { const string LOG_IDENT = "DiscordRichPresence::"; diff --git a/Bloxstrap/RobloxActivity.cs b/Bloxstrap/Integrations/RobloxActivity.cs similarity index 96% rename from Bloxstrap/RobloxActivity.cs rename to Bloxstrap/Integrations/RobloxActivity.cs index b30046b..88504d2 100644 --- a/Bloxstrap/RobloxActivity.cs +++ b/Bloxstrap/Integrations/RobloxActivity.cs @@ -1,6 +1,6 @@ -namespace Bloxstrap +namespace Bloxstrap.Integrations { - public class RobloxActivity : IDisposable + public class ActivityWatcher : IDisposable { // i'm thinking the functionality for parsing roblox logs could be broadened for more features than just rich presence, // like checking the ping and region of the current connected server. maybe that's something to add? @@ -44,7 +44,7 @@ public async void StartWatcher() { - const string LOG_IDENT = "RobloxActivity::StartWatcher"; + const string LOG_IDENT = "ActivityWatcher::StartWatcher"; // okay, here's the process: // @@ -118,8 +118,8 @@ private void ExamineLogEntry(string entry) { - const string LOG_IDENT = "RobloxActivity::ExamineLogEntry"; - + const string LOG_IDENT = "ActivityWatcher::ExamineLogEntry"; + OnLogEntry?.Invoke(this, entry); _logEntriesRead += 1; @@ -253,7 +253,7 @@ return; } - if (String.IsNullOrEmpty(message.Command)) + if (string.IsNullOrEmpty(message.Command)) { App.Logger.WriteLine(LOG_IDENT, "Failed to parse message! (Command is empty)"); return; @@ -266,7 +266,7 @@ public async Task GetServerLocation() { - const string LOG_IDENT = "RobloxActivity::GetServerLocation"; + const string LOG_IDENT = "ActivityWatcher::GetServerLocation"; if (GeolcationCache.ContainsKey(ActivityMachineAddress)) return GeolcationCache[ActivityMachineAddress]; @@ -291,7 +291,7 @@ locationRegion = locationRegion.ReplaceLineEndings(""); locationCountry = locationCountry.ReplaceLineEndings(""); - if (String.IsNullOrEmpty(locationCountry)) + if (string.IsNullOrEmpty(locationCountry)) location = "N/A"; else if (locationCity == locationRegion) location = $"{locationRegion}, {locationCountry}"; diff --git a/Bloxstrap/UI/Elements/ContextMenu/LogTracer.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/LogTracer.xaml.cs index 5ff2de3..f1cdc5a 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/LogTracer.xaml.cs +++ b/Bloxstrap/UI/Elements/ContextMenu/LogTracer.xaml.cs @@ -1,6 +1,7 @@ using System.Windows; using System.Windows.Controls; +using Bloxstrap.Integrations; using Bloxstrap.UI.ViewModels.ContextMenu; namespace Bloxstrap.UI.Elements.ContextMenu @@ -12,7 +13,7 @@ namespace Bloxstrap.UI.Elements.ContextMenu { private bool _autoscroll = true; - public LogTracer(RobloxActivity activityWatcher) + public LogTracer(ActivityWatcher activityWatcher) { DataContext = new LogTracerViewModel(this, activityWatcher); InitializeComponent(); diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs index 91fd8c6..3f9eea9 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs +++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs @@ -24,13 +24,13 @@ namespace Bloxstrap.UI.Elements.ContextMenu { // i wouldve gladly done this as mvvm but turns out that data binding just does not work with menuitems for some reason so idk this sucks - private readonly RobloxActivity? _activityWatcher; + private readonly ActivityWatcher? _activityWatcher; private readonly DiscordRichPresence? _richPresenceHandler; private LogTracer? _logTracerWindow; private ServerInformation? _serverInformationWindow; - public MenuContainer(RobloxActivity? activityWatcher, DiscordRichPresence? richPresenceHandler) + public MenuContainer(ActivityWatcher? activityWatcher, DiscordRichPresence? richPresenceHandler) { InitializeComponent(); diff --git a/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml.cs index 1ef8536..5d46d85 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml.cs +++ b/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml.cs @@ -12,6 +12,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using Bloxstrap.Integrations; using Bloxstrap.UI.ViewModels.ContextMenu; namespace Bloxstrap.UI.Elements.ContextMenu @@ -21,7 +22,7 @@ namespace Bloxstrap.UI.Elements.ContextMenu /// public partial class ServerInformation { - public ServerInformation(RobloxActivity activityWatcher) + public ServerInformation(ActivityWatcher activityWatcher) { DataContext = new ServerInformationViewModel(this, activityWatcher); InitializeComponent(); diff --git a/Bloxstrap/UI/NotifyIconWrapper.cs b/Bloxstrap/UI/NotifyIconWrapper.cs index e9d254b..f4bd566 100644 --- a/Bloxstrap/UI/NotifyIconWrapper.cs +++ b/Bloxstrap/UI/NotifyIconWrapper.cs @@ -14,7 +14,7 @@ namespace Bloxstrap.UI private readonly System.Windows.Forms.NotifyIcon _notifyIcon; private MenuContainer? _menuContainer; - private RobloxActivity? _activityWatcher; + private ActivityWatcher? _activityWatcher; private DiscordRichPresence? _richPresenceHandler; EventHandler? _alertClickHandler; @@ -42,7 +42,7 @@ namespace Bloxstrap.UI _richPresenceHandler = richPresenceHandler; } - public void SetActivityWatcher(RobloxActivity activityWatcher) + public void SetActivityWatcher(ActivityWatcher activityWatcher) { if (_activityWatcher is not null) return; diff --git a/Bloxstrap/UI/ViewModels/ContextMenu/LogTracerViewModel.cs b/Bloxstrap/UI/ViewModels/ContextMenu/LogTracerViewModel.cs index cb398b1..48c57c0 100644 --- a/Bloxstrap/UI/ViewModels/ContextMenu/LogTracerViewModel.cs +++ b/Bloxstrap/UI/ViewModels/ContextMenu/LogTracerViewModel.cs @@ -3,12 +3,14 @@ using System.Windows.Input; using CommunityToolkit.Mvvm.Input; +using Bloxstrap.Integrations; + namespace Bloxstrap.UI.ViewModels.ContextMenu { internal class LogTracerViewModel : NotifyPropertyChangedViewModel { private readonly Window _window; - private readonly RobloxActivity _activityWatcher; + private readonly ActivityWatcher _activityWatcher; private int _lineNumber = 1; public ICommand CloseWindowCommand => new RelayCommand(_window.Close); @@ -17,7 +19,7 @@ namespace Bloxstrap.UI.ViewModels.ContextMenu public string LogFilename => Path.GetFileName(_activityWatcher.LogLocation); public string LogContents { get; private set; } = ""; - public LogTracerViewModel(Window window, RobloxActivity activityWatcher) + public LogTracerViewModel(Window window, ActivityWatcher activityWatcher) { _window = window; _activityWatcher = activityWatcher; diff --git a/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs index 7be5a92..576d828 100644 --- a/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs +++ b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs @@ -1,6 +1,6 @@ using System.Windows; using System.Windows.Input; - +using Bloxstrap.Integrations; using CommunityToolkit.Mvvm.Input; namespace Bloxstrap.UI.ViewModels.ContextMenu @@ -8,7 +8,7 @@ namespace Bloxstrap.UI.ViewModels.ContextMenu internal class ServerInformationViewModel : NotifyPropertyChangedViewModel { private readonly Window _window; - private readonly RobloxActivity _activityWatcher; + private readonly ActivityWatcher _activityWatcher; public string InstanceId => _activityWatcher.ActivityJobId; public string ServerType => $"{_activityWatcher.ActivityServerType} server"; @@ -18,7 +18,7 @@ namespace Bloxstrap.UI.ViewModels.ContextMenu public ICommand CopyInstanceIdCommand => new RelayCommand(CopyInstanceId); public ICommand CloseWindowCommand => new RelayCommand(_window.Close); - public ServerInformationViewModel(Window window, RobloxActivity activityWatcher) + public ServerInformationViewModel(Window window, ActivityWatcher activityWatcher) { _window = window; _activityWatcher = activityWatcher;