From f1dfaa92c90dad8e779fc4fe4132adeae20bd696 Mon Sep 17 00:00:00 2001 From: goat Date: Tue, 13 Jun 2023 22:22:04 +0200 Subject: [PATCH] chore: ClientState => IClientState --- .editorconfig | 2 +- .../ClientState/Aetherytes/AetheryteList.cs | 2 + Dalamud/Game/ClientState/ClientState.cs | 58 ++++------ .../Text/SeStringHandling/BitmapFontIcon.cs | 100 +++++++++--------- Dalamud/Plugin/Services/IClientState.cs | 76 +++++++++++++ 5 files changed, 147 insertions(+), 91 deletions(-) create mode 100644 Dalamud/Plugin/Services/IClientState.cs diff --git a/.editorconfig b/.editorconfig index 1b1377fca..829de8f05 100644 --- a/.editorconfig +++ b/.editorconfig @@ -26,7 +26,7 @@ csharp_style_var_for_built_in_types = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion dotnet_code_quality_unused_parameters = non_public dotnet_naming_rule.event_rule.severity = warning -dotnet_naming_rule.event_rule.style = on_upper_camel_case_style +dotnet_naming_rule.event_rule.style = upper_camel_case_style dotnet_naming_rule.event_rule.symbols = event_symbols dotnet_naming_rule.private_constants_rule.severity = warning dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style diff --git a/Dalamud/Game/ClientState/Aetherytes/AetheryteList.cs b/Dalamud/Game/ClientState/Aetherytes/AetheryteList.cs index bbd94e505..17b468d70 100644 --- a/Dalamud/Game/ClientState/Aetherytes/AetheryteList.cs +++ b/Dalamud/Game/ClientState/Aetherytes/AetheryteList.cs @@ -15,7 +15,9 @@ namespace Dalamud.Game.ClientState.Aetherytes; [PluginInterface] [InterfaceVersion("1.0")] [ServiceManager.BlockingEarlyLoadedService] +#pragma warning disable SA1015 [ResolveVia] +#pragma warning restore SA1015 public sealed unsafe partial class AetheryteList : IServiceType, IAetheryteList { [ServiceManager.ServiceDependency] diff --git a/Dalamud/Game/ClientState/ClientState.cs b/Dalamud/Game/ClientState/ClientState.cs index 1f72d853f..fed0ec3c4 100644 --- a/Dalamud/Game/ClientState/ClientState.cs +++ b/Dalamud/Game/ClientState/ClientState.cs @@ -9,6 +9,7 @@ using Dalamud.Game.Network.Internal; using Dalamud.Hooking; using Dalamud.IoC; using Dalamud.IoC.Internal; +using Dalamud.Plugin.Services; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game; using Serilog; @@ -21,7 +22,10 @@ namespace Dalamud.Game.ClientState; [PluginInterface] [InterfaceVersion("1.0")] [ServiceManager.BlockingEarlyLoadedService] -public sealed class ClientState : IDisposable, IServiceType +#pragma warning disable SA1015 +[ResolveVia] +#pragma warning restore SA1015 +public sealed class ClientState : IDisposable, IServiceType, IClientState { private readonly GameLifecycle lifecycle; private readonly ClientStateAddressResolver address; @@ -59,69 +63,43 @@ public sealed class ClientState : IDisposable, IServiceType [UnmanagedFunctionPointer(CallingConvention.ThisCall)] private delegate IntPtr SetupTerritoryTypeDelegate(IntPtr manager, ushort terriType); - /// - /// Event that gets fired when the current Territory changes. - /// + /// public event EventHandler TerritoryChanged; - /// - /// Event that fires when a character is logging in, and the local character object is available. - /// + /// public event EventHandler Login; - /// - /// Event that fires when a character is logging out. - /// + /// public event EventHandler Logout; - /// - /// Event that fires when a character is entering PvP. - /// + /// public event Action EnterPvP; - /// - /// Event that fires when a character is leaving PvP. - /// + /// public event Action LeavePvP; - /// - /// Event that gets fired when a duty is ready. - /// + /// public event EventHandler CfPop; - /// - /// Gets the language of the client. - /// + /// public ClientLanguage ClientLanguage { get; } - /// - /// Gets the current Territory the player resides in. - /// + /// public ushort TerritoryType { get; private set; } - /// - /// Gets the local player character, if one is present. - /// + /// public PlayerCharacter? LocalPlayer => Service.GetNullable()?[0] as PlayerCharacter; - /// - /// Gets the content ID of the local character. - /// + /// public ulong LocalContentId => (ulong)Marshal.ReadInt64(this.address.LocalContentId); - /// - /// Gets a value indicating whether a character is logged in. - /// + /// public bool IsLoggedIn { get; private set; } - /// - /// Gets a value indicating whether or not the user is playing PvP. - /// + /// public bool IsPvP { get; private set; } - /// - /// Gets a value indicating whether or not the user is playing PvP, excluding the Wolves' Den. - /// + /// public bool IsPvPExcludingDen { get; private set; } /// diff --git a/Dalamud/Game/Text/SeStringHandling/BitmapFontIcon.cs b/Dalamud/Game/Text/SeStringHandling/BitmapFontIcon.cs index ea181238a..cb87fc343 100644 --- a/Dalamud/Game/Text/SeStringHandling/BitmapFontIcon.cs +++ b/Dalamud/Game/Text/SeStringHandling/BitmapFontIcon.cs @@ -462,252 +462,252 @@ public enum BitmapFontIcon : uint /// /// The Physical Damage icon. - /// + /// DamagePhysical = 117, /// /// The Magical Damage icon. - /// + /// DamageMagical = 118, /// /// The Special Damage icon. - /// + /// DamageSpecial = 119, /// /// A gold star icon with an orange exclamation mark. - /// + /// GoldStarProblem = 120, /// /// A blue star icon. - /// + /// BlueStar = 121, /// /// A blue star icon with an orange exclamation mark. - /// + /// BlueStarProblem = 121, /// /// The Disconnecting icon. - /// + /// Disconnecting = 124, /// /// The Do Not Disturb icon. - /// + /// DoNotDisturb = 125, /// /// The Meteor icon. - /// + /// Meteor = 126, /// /// The Role Playing icon. - /// + /// RolePlaying = 127, /// /// The Gladiator icon. - /// + /// Gladiator = 128, /// /// The Pugilist icon. - /// + /// Pugilist = 129, /// /// The Marauder icon. - /// + /// Marauder = 130, /// /// The Lancer icon. - /// + /// Lancer = 131, /// /// The Archer icon. - /// + /// Archer = 132, /// /// The Conjurer icon. - /// + /// Conjurer = 133, /// /// The Thaumaturge icon. - /// + /// Thaumaturge = 134, /// /// The Carpenter icon. - /// + /// Carpenter = 135, /// /// The Blacksmith icon. - /// + /// Blacksmith = 136, /// /// The Armorer icon. - /// + /// Armorer = 137, /// /// The Goldsmith icon. - /// + /// Goldsmith = 138, /// /// The Leatherworker icon. - /// + /// Leatherworker = 139, /// /// The Weaver icon. - /// + /// Weaver = 140, /// /// The Alchemist icon. - /// + /// Alchemist = 131, /// /// The Culinarian icon. - /// + /// Culinarian = 132, /// /// The Miner icon. - /// + /// Miner = 143, /// /// The Botanist icon. - /// + /// Botanist = 144, /// /// The Fisher icon. - /// + /// Fisher = 145, /// /// The Paladin icon. - /// + /// Paladin = 146, /// /// The Monk icon. - /// + /// Monk = 147, /// /// The Warrior icon. - /// + /// Warrior = 148, /// /// The Dragoon icon. - /// + /// Dragoon = 149, /// /// The Bard icon. - /// + /// Bard = 150, /// /// The White Mage icon. - /// + /// WhiteMage = 151, /// /// The Black Mage icon. - /// + /// BlackMage = 152, /// /// The Arcanist icon. - /// + /// Arcanist = 153, /// /// The Summoner icon. - /// + /// Summoner = 154, /// /// The Scholar icon. - /// + /// Scholar = 155, /// /// The Rogue icon. - /// + /// Rogue = 156, /// /// The Ninja icon. - /// + /// Ninja = 157, /// /// The Machinist icon. - /// + /// Machinist = 158, /// /// The Dark Knight icon. - /// + /// DarkKnight = 159, /// /// The Astrologian icon. - /// + /// Astrologian = 160, /// /// The Samurai icon. - /// + /// Samurai = 161, /// /// The Red Mage icon. - /// + /// RedMage = 162, /// /// The Blue Mage icon. - /// + /// BlueMage = 163, /// /// The Gunbreaker icon. - /// + /// Gunbreaker = 164, /// /// The Dancer icon. - /// + /// Dancer = 165, /// /// The Reaper icon. - /// + /// Reaper = 166, /// /// The Sage icon. - /// + /// Sage = 167, /// diff --git a/Dalamud/Plugin/Services/IClientState.cs b/Dalamud/Plugin/Services/IClientState.cs new file mode 100644 index 000000000..d66db9cc9 --- /dev/null +++ b/Dalamud/Plugin/Services/IClientState.cs @@ -0,0 +1,76 @@ +using System; + +using Dalamud.Game.ClientState.Objects.SubKinds; + +namespace Dalamud.Plugin.Services; + +/// +/// This class represents the state of the game client at the time of access. +/// +public interface IClientState +{ + /// + /// Event that gets fired when the current Territory changes. + /// + public event EventHandler TerritoryChanged; + + /// + /// Event that fires when a character is logging in, and the local character object is available. + /// + public event EventHandler Login; + + /// + /// Event that fires when a character is logging out. + /// + public event EventHandler Logout; + + /// + /// Event that fires when a character is entering PvP. + /// + public event Action EnterPvP; + + /// + /// Event that fires when a character is leaving PvP. + /// + public event Action LeavePvP; + + /// + /// Event that gets fired when a duty is ready. + /// + public event EventHandler CfPop; + + /// + /// Gets the language of the client. + /// + public ClientLanguage ClientLanguage { get; } + + /// + /// Gets the current Territory the player resides in. + /// + public ushort TerritoryType { get; } + + /// + /// Gets the local player character, if one is present. + /// + public PlayerCharacter? LocalPlayer { get; } + + /// + /// Gets the content ID of the local character. + /// + public ulong LocalContentId { get; } + + /// + /// Gets a value indicating whether a character is logged in. + /// + public bool IsLoggedIn { get; } + + /// + /// Gets a value indicating whether or not the user is playing PvP. + /// + public bool IsPvP { get; } + + /// + /// Gets a value indicating whether or not the user is playing PvP, excluding the Wolves' Den. + /// + public bool IsPvPExcludingDen { get; } +}