From b425bb3e4965771322d6b8a4146f71a0d266f571 Mon Sep 17 00:00:00 2001 From: goat Date: Sun, 30 Jun 2024 00:58:04 +0200 Subject: [PATCH] fix a million warnings --- .../ClientState/Aetherytes/AetheryteEntry.cs | 93 +++--- Dalamud/Game/ClientState/Buddy/BuddyMember.cs | 108 +++---- Dalamud/Game/ClientState/Fates/Fate.cs | 257 ++++++++------- .../Objects/SubKinds/PlayerCharacter.cs | 36 +-- .../ClientState/Objects/Types/BattleChara.cs | 96 +++--- .../Objects/{SubKinds => Types}/BattleNpc.cs | 22 +- .../ClientState/Objects/Types/Character.cs | 170 +++++----- .../ClientState/Objects/Types/GameObject.cs | 233 +++++++------- Dalamud/Game/ClientState/Party/PartyMember.cs | 178 +++++------ Dalamud/Game/Command/CommandInfo.cs | 50 +-- Dalamud/Game/Command/CommandManager.cs | 16 +- Dalamud/Game/Gui/ContextMenu/ContextMenu.cs | 24 +- Dalamud/Game/Gui/ContextMenu/MenuArgs.cs | 82 ++--- Dalamud/Game/Gui/ContextMenu/MenuItem.cs | 104 +++--- .../Gui/ContextMenu/MenuItemClickedArgs.cs | 38 +-- .../Game/Gui/ContextMenu/MenuOpenedArgs.cs | 24 +- .../PartyFinder/Types/PartyFinderListing.cs | 300 +++++++++--------- .../Types/PartyFinderListingEventArgs.cs | 32 +- .../UniversalisMarketBoardUploader.cs | 2 + .../Structures/MarketBoardCurrentOfferings.cs | 36 +-- .../Internal/Windows/ChangelogWindow.cs | 2 + .../FileSystemSharedImmediateTexture.cs | 7 +- .../TitleScreenMenu/TitleScreenMenuEntry.cs | 116 +++---- Dalamud/Plugin/Internal/PluginValidator.cs | 4 +- Dalamud/Plugin/Services/IFateTable.cs | 14 +- Dalamud/Plugin/Services/ITextureProvider.cs | 2 +- 26 files changed, 1027 insertions(+), 1019 deletions(-) rename Dalamud/Game/ClientState/Objects/{SubKinds => Types}/BattleNpc.cs (100%) diff --git a/Dalamud/Game/ClientState/Aetherytes/AetheryteEntry.cs b/Dalamud/Game/ClientState/Aetherytes/AetheryteEntry.cs index f723d7266..058d6c0c2 100644 --- a/Dalamud/Game/ClientState/Aetherytes/AetheryteEntry.cs +++ b/Dalamud/Game/ClientState/Aetherytes/AetheryteEntry.cs @@ -3,53 +3,6 @@ using FFXIVClientStructs.FFXIV.Client.Game.UI; namespace Dalamud.Game.ClientState.Aetherytes; -/// -/// Class representing an aetheryte entry available to the game. -/// -internal sealed class AetheryteEntry : IAetheryteEntry -{ - private readonly TeleportInfo data; - - /// - /// Initializes a new instance of the class. - /// - /// Data read from the Aetheryte List. - internal AetheryteEntry(TeleportInfo data) - { - this.data = data; - } - - /// - public uint AetheryteId => this.data.AetheryteId; - - /// - public uint TerritoryId => this.data.TerritoryId; - - /// - public byte SubIndex => this.data.SubIndex; - - /// - public byte Ward => this.data.Ward; - - /// - public byte Plot => this.data.Plot; - - /// - public uint GilCost => this.data.GilCost; - - /// - public bool IsFavourite => this.data.IsFavourite != 0; - - /// - public bool IsSharedHouse => this.data.IsSharedHouse; - - /// - public bool IsApartment => this.data.IsApartment; - - /// - public ExcelResolver AetheryteData => new(this.AetheryteId); -} - /// /// Interface representing an aetheryte entry available to the game. /// @@ -106,3 +59,49 @@ public interface IAetheryteEntry ExcelResolver AetheryteData { get; } } +/// +/// Class representing an aetheryte entry available to the game. +/// +internal sealed class AetheryteEntry : IAetheryteEntry +{ + private readonly TeleportInfo data; + + /// + /// Initializes a new instance of the class. + /// + /// Data read from the Aetheryte List. + internal AetheryteEntry(TeleportInfo data) + { + this.data = data; + } + + /// + public uint AetheryteId => this.data.AetheryteId; + + /// + public uint TerritoryId => this.data.TerritoryId; + + /// + public byte SubIndex => this.data.SubIndex; + + /// + public byte Ward => this.data.Ward; + + /// + public byte Plot => this.data.Plot; + + /// + public uint GilCost => this.data.GilCost; + + /// + public bool IsFavourite => this.data.IsFavourite != 0; + + /// + public bool IsSharedHouse => this.data.IsSharedHouse; + + /// + public bool IsApartment => this.data.IsApartment; + + /// + public ExcelResolver AetheryteData => new(this.AetheryteId); +} diff --git a/Dalamud/Game/ClientState/Buddy/BuddyMember.cs b/Dalamud/Game/ClientState/Buddy/BuddyMember.cs index 1fdb794cc..a650a7b44 100644 --- a/Dalamud/Game/ClientState/Buddy/BuddyMember.cs +++ b/Dalamud/Game/ClientState/Buddy/BuddyMember.cs @@ -4,6 +4,60 @@ using Dalamud.Game.ClientState.Resolvers; namespace Dalamud.Game.ClientState.Buddy; +/// +/// Interface representing represents a buddy such as the chocobo companion, summoned pets, squadron groups and trust parties. +/// +public interface IBuddyMember +{ + /// + /// Gets the address of the buddy in memory. + /// + IntPtr Address { get; } + + /// + /// Gets the object ID of this buddy. + /// + uint ObjectId { get; } + + /// + /// Gets the actor associated with this buddy. + /// + /// + /// This iterates the actor table, it should be used with care. + /// + IGameObject? GameObject { get; } + + /// + /// Gets the current health of this buddy. + /// + uint CurrentHP { get; } + + /// + /// Gets the maximum health of this buddy. + /// + uint MaxHP { get; } + + /// + /// Gets the data ID of this buddy. + /// + uint DataID { get; } + + /// + /// Gets the Mount data related to this buddy. It should only be used with companion buddies. + /// + ExcelResolver MountData { get; } + + /// + /// Gets the Pet data related to this buddy. It should only be used with pet buddies. + /// + ExcelResolver PetData { get; } + + /// + /// Gets the Trust data related to this buddy. It should only be used with battle buddies. + /// + ExcelResolver TrustData { get; } +} + /// /// This class represents a buddy such as the chocobo companion, summoned pets, squadron groups and trust parties. /// @@ -50,57 +104,3 @@ internal unsafe class BuddyMember : IBuddyMember private FFXIVClientStructs.FFXIV.Client.Game.UI.Buddy.BuddyMember* Struct => (FFXIVClientStructs.FFXIV.Client.Game.UI.Buddy.BuddyMember*)this.Address; } - -/// -/// Interface representing represents a buddy such as the chocobo companion, summoned pets, squadron groups and trust parties. -/// -public interface IBuddyMember -{ - /// - /// Gets the address of the buddy in memory. - /// - IntPtr Address { get; } - - /// - /// Gets the object ID of this buddy. - /// - unsafe uint ObjectId { get; } - - /// - /// Gets the actor associated with this buddy. - /// - /// - /// This iterates the actor table, it should be used with care. - /// - IGameObject? GameObject { get; } - - /// - /// Gets the current health of this buddy. - /// - unsafe uint CurrentHP { get; } - - /// - /// Gets the maximum health of this buddy. - /// - unsafe uint MaxHP { get; } - - /// - /// Gets the data ID of this buddy. - /// - unsafe uint DataID { get; } - - /// - /// Gets the Mount data related to this buddy. It should only be used with companion buddies. - /// - ExcelResolver MountData { get; } - - /// - /// Gets the Pet data related to this buddy. It should only be used with pet buddies. - /// - ExcelResolver PetData { get; } - - /// - /// Gets the Trust data related to this buddy. It should only be used with battle buddies. - /// - ExcelResolver TrustData { get; } -} diff --git a/Dalamud/Game/ClientState/Fates/Fate.cs b/Dalamud/Game/ClientState/Fates/Fate.cs index bb64c0023..2d32cc04c 100644 --- a/Dalamud/Game/ClientState/Fates/Fate.cs +++ b/Dalamud/Game/ClientState/Fates/Fate.cs @@ -7,135 +7,6 @@ using Dalamud.Memory; namespace Dalamud.Game.ClientState.Fates; -/// -/// This class represents an FFXIV Fate. -/// -internal unsafe partial class Fate -{ - /// - /// Initializes a new instance of the class. - /// - /// The address of this fate in memory. - internal Fate(IntPtr address) - { - this.Address = address; - } - - /// - public IntPtr Address { get; } - - private FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext*)this.Address; - - public static bool operator ==(Fate fate1, Fate fate2) - { - if (fate1 is null || fate2 is null) - return Equals(fate1, fate2); - - return fate1.Equals(fate2); - } - - public static bool operator !=(Fate fate1, Fate fate2) => !(fate1 == fate2); - - /// - /// Gets a value indicating whether this Fate is still valid in memory. - /// - /// The fate to check. - /// True or false. - public static bool IsValid(Fate fate) - { - var clientState = Service.GetNullable(); - - if (fate == null || clientState == null) - return false; - - if (clientState.LocalContentId == 0) - return false; - - return true; - } - - /// - /// Gets a value indicating whether this actor is still valid in memory. - /// - /// True or false. - public bool IsValid() => IsValid(this); - - /// - bool IEquatable.Equals(IFate other) => this.FateId == other?.FateId; - - /// - public override bool Equals(object obj) => ((IEquatable)this).Equals(obj as IFate); - - /// - public override int GetHashCode() => this.FateId.GetHashCode(); -} - -/// -/// This class represents an FFXIV Fate. -/// -internal unsafe partial class Fate : IFate -{ - /// - public ushort FateId => this.Struct->FateId; - - /// - public Lumina.Excel.GeneratedSheets.Fate GameData => Service.Get().GetExcelSheet().GetRow(this.FateId); - - /// - public int StartTimeEpoch => this.Struct->StartTimeEpoch; - - /// - public short Duration => this.Struct->Duration; - - /// - public long TimeRemaining => this.StartTimeEpoch + this.Duration - DateTimeOffset.Now.ToUnixTimeSeconds(); - - /// - public SeString Name => MemoryHelper.ReadSeString(&this.Struct->Name); - - /// - public SeString Description => MemoryHelper.ReadSeString(&this.Struct->Description); - - /// - public SeString Objective => MemoryHelper.ReadSeString(&this.Struct->Objective); - - /// - public FateState State => (FateState)this.Struct->State; - - /// - public byte HandInCount => this.Struct->HandInCount; - - - /// - public byte Progress => this.Struct->Progress; - - /// - public bool HasExpBonus => this.Struct->IsExpBonus; - - /// - public uint IconId => this.Struct->IconId; - - /// - public byte Level => this.Struct->Level; - - /// - public byte MaxLevel => this.Struct->MaxLevel; - - /// - public Vector3 Position => this.Struct->Location; - - /// - public float Radius => this.Struct->Radius; - - /// - public uint MapIconId => this.Struct->MapIconId; - - /// - /// Gets the territory this is located in. - /// - public ExcelResolver TerritoryType => new(this.Struct->TerritoryId); -} - /// /// Interface representing an fate entry that can be seen in the current area. /// @@ -241,3 +112,131 @@ public interface IFate : IEquatable /// IntPtr Address { get; } } + +/// +/// This class represents an FFXIV Fate. +/// +internal unsafe partial class Fate +{ + /// + /// Initializes a new instance of the class. + /// + /// The address of this fate in memory. + internal Fate(IntPtr address) + { + this.Address = address; + } + + /// + public IntPtr Address { get; } + + private FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext*)this.Address; + + public static bool operator ==(Fate fate1, Fate fate2) + { + if (fate1 is null || fate2 is null) + return Equals(fate1, fate2); + + return fate1.Equals(fate2); + } + + public static bool operator !=(Fate fate1, Fate fate2) => !(fate1 == fate2); + + /// + /// Gets a value indicating whether this Fate is still valid in memory. + /// + /// The fate to check. + /// True or false. + public static bool IsValid(Fate fate) + { + var clientState = Service.GetNullable(); + + if (fate == null || clientState == null) + return false; + + if (clientState.LocalContentId == 0) + return false; + + return true; + } + + /// + /// Gets a value indicating whether this actor is still valid in memory. + /// + /// True or false. + public bool IsValid() => IsValid(this); + + /// + bool IEquatable.Equals(IFate other) => this.FateId == other?.FateId; + + /// + public override bool Equals(object obj) => ((IEquatable)this).Equals(obj as IFate); + + /// + public override int GetHashCode() => this.FateId.GetHashCode(); +} + +/// +/// This class represents an FFXIV Fate. +/// +internal unsafe partial class Fate : IFate +{ + /// + public ushort FateId => this.Struct->FateId; + + /// + public Lumina.Excel.GeneratedSheets.Fate GameData => Service.Get().GetExcelSheet().GetRow(this.FateId); + + /// + public int StartTimeEpoch => this.Struct->StartTimeEpoch; + + /// + public short Duration => this.Struct->Duration; + + /// + public long TimeRemaining => this.StartTimeEpoch + this.Duration - DateTimeOffset.Now.ToUnixTimeSeconds(); + + /// + public SeString Name => MemoryHelper.ReadSeString(&this.Struct->Name); + + /// + public SeString Description => MemoryHelper.ReadSeString(&this.Struct->Description); + + /// + public SeString Objective => MemoryHelper.ReadSeString(&this.Struct->Objective); + + /// + public FateState State => (FateState)this.Struct->State; + + /// + public byte HandInCount => this.Struct->HandInCount; + + /// + public byte Progress => this.Struct->Progress; + + /// + public bool HasExpBonus => this.Struct->IsExpBonus; + + /// + public uint IconId => this.Struct->IconId; + + /// + public byte Level => this.Struct->Level; + + /// + public byte MaxLevel => this.Struct->MaxLevel; + + /// + public Vector3 Position => this.Struct->Location; + + /// + public float Radius => this.Struct->Radius; + + /// + public uint MapIconId => this.Struct->MapIconId; + + /// + /// Gets the territory this is located in. + /// + public ExcelResolver TerritoryType => new(this.Struct->TerritoryId); +} diff --git a/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs b/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs index ed7bcc1df..87fbf39c3 100644 --- a/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs +++ b/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs @@ -10,6 +10,22 @@ using Lumina.Excel.GeneratedSheets; namespace Dalamud.Game.ClientState.Objects.SubKinds; +/// +/// Interface representing a player character. +/// +public interface IPlayerCharacter : IBattleChara +{ + /// + /// Gets the current world of the character. + /// + ExcelResolver CurrentWorld { get; } + + /// + /// Gets the home world of the character. + /// + ExcelResolver HomeWorld { get; } +} + /// /// This class represents a player character. /// @@ -26,29 +42,13 @@ internal unsafe class PlayerCharacter : BattleChara, IPlayerCharacter } /// - public ExcelResolver CurrentWorld => new(this.Struct->CurrentWorld); + public ExcelResolver CurrentWorld => new(this.Struct->CurrentWorld); /// - public ExcelResolver HomeWorld => new(this.Struct->HomeWorld); + public ExcelResolver HomeWorld => new(this.Struct->HomeWorld); /// /// Gets the target actor ID of the PlayerCharacter. /// public override ulong TargetObjectId => this.Struct->LookAt.Controller.Params[0].TargetParam.TargetId; } - -/// -/// Interface representing a player character. -/// -public interface IPlayerCharacter : IBattleChara -{ - /// - /// Gets the current world of the character. - /// - unsafe ExcelResolver CurrentWorld { get; } - - /// - /// Gets the home world of the character. - /// - unsafe ExcelResolver HomeWorld { get; } -} diff --git a/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs b/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs index fbb10561e..efd8b5b3b 100644 --- a/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs +++ b/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs @@ -3,54 +3,6 @@ using Dalamud.Utility; namespace Dalamud.Game.ClientState.Objects.Types; -/// -/// This class represents the battle characters. -/// -internal unsafe class BattleChara : Character, IBattleChara -{ - /// - /// Initializes a new instance of the class. - /// This represents a battle character. - /// - /// The address of this character in memory. - internal BattleChara(IntPtr address) - : base(address) - { - } - - /// - public StatusList StatusList => new(this.Struct->GetStatusManager()); - - /// - public bool IsCasting => this.Struct->GetCastInfo()->IsCasting > 0; - - /// - public bool IsCastInterruptible => this.Struct->GetCastInfo()->Interruptible > 0; - - /// - public byte CastActionType => (byte)this.Struct->GetCastInfo()->ActionType; - - /// - public uint CastActionId => this.Struct->GetCastInfo()->ActionId; - - /// - public ulong CastTargetObjectId => this.Struct->GetCastInfo()->TargetId; - - /// - public float CurrentCastTime => this.Struct->GetCastInfo()->CurrentCastTime; - - /// - public float BaseCastTime => this.Struct->GetCastInfo()->BaseCastTime; - - /// - public float TotalCastTime => this.Struct->GetCastInfo()->TotalCastTime; - - /// - /// Gets the underlying structure. - /// - protected internal new FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara*)this.Address; -} - /// /// Interface representing a battle character. /// @@ -105,3 +57,51 @@ public interface IBattleChara : ICharacter /// public float TotalCastTime { get; } } + +/// +/// This class represents the battle characters. +/// +internal unsafe class BattleChara : Character, IBattleChara +{ + /// + /// Initializes a new instance of the class. + /// This represents a battle character. + /// + /// The address of this character in memory. + internal BattleChara(IntPtr address) + : base(address) + { + } + + /// + public StatusList StatusList => new(this.Struct->GetStatusManager()); + + /// + public bool IsCasting => this.Struct->GetCastInfo()->IsCasting > 0; + + /// + public bool IsCastInterruptible => this.Struct->GetCastInfo()->Interruptible > 0; + + /// + public byte CastActionType => (byte)this.Struct->GetCastInfo()->ActionType; + + /// + public uint CastActionId => this.Struct->GetCastInfo()->ActionId; + + /// + public ulong CastTargetObjectId => this.Struct->GetCastInfo()->TargetId; + + /// + public float CurrentCastTime => this.Struct->GetCastInfo()->CurrentCastTime; + + /// + public float BaseCastTime => this.Struct->GetCastInfo()->BaseCastTime; + + /// + public float TotalCastTime => this.Struct->GetCastInfo()->TotalCastTime; + + /// + /// Gets the underlying structure. + /// + protected internal new FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara*)this.Address; +} diff --git a/Dalamud/Game/ClientState/Objects/SubKinds/BattleNpc.cs b/Dalamud/Game/ClientState/Objects/Types/BattleNpc.cs similarity index 100% rename from Dalamud/Game/ClientState/Objects/SubKinds/BattleNpc.cs rename to Dalamud/Game/ClientState/Objects/Types/BattleNpc.cs index 82b3262e6..e9582913c 100644 --- a/Dalamud/Game/ClientState/Objects/SubKinds/BattleNpc.cs +++ b/Dalamud/Game/ClientState/Objects/Types/BattleNpc.cs @@ -2,6 +2,17 @@ using Dalamud.Game.ClientState.Objects.Enums; namespace Dalamud.Game.ClientState.Objects.Types; +/// +/// A interface that represents a battle NPC. +/// +public interface IBattleNpc : IBattleChara +{ + /// + /// Gets the BattleNpc of this BattleNpc. + /// + BattleNpcSubKind BattleNpcKind { get; } +} + /// /// This class represents a battle NPC. /// @@ -25,14 +36,3 @@ internal unsafe class BattleNpc : BattleChara, IBattleNpc /// public override ulong TargetObjectId => this.Struct->Character.TargetId; } - -/// -/// A interface that represents a battle NPC. -/// -public interface IBattleNpc : IBattleChara -{ - /// - /// Gets the BattleNpc of this BattleNpc. - /// - BattleNpcSubKind BattleNpcKind { get; } -} diff --git a/Dalamud/Game/ClientState/Objects/Types/Character.cs b/Dalamud/Game/ClientState/Objects/Types/Character.cs index 7f025118c..67f8c8b62 100644 --- a/Dalamud/Game/ClientState/Objects/Types/Character.cs +++ b/Dalamud/Game/ClientState/Objects/Types/Character.cs @@ -8,91 +8,6 @@ using Lumina.Excel.GeneratedSheets; namespace Dalamud.Game.ClientState.Objects.Types; -/// -/// This class represents the base for non-static entities. -/// -internal unsafe class Character : GameObject, ICharacter -{ - /// - /// Initializes a new instance of the class. - /// This represents a non-static entity. - /// - /// The address of this character in memory. - internal Character(IntPtr address) - : base(address) - { - } - - /// - public uint CurrentHp => this.Struct->CharacterData.Health; - - /// - public uint MaxHp => this.Struct->CharacterData.MaxHealth; - - /// - public uint CurrentMp => this.Struct->CharacterData.Mana; - - /// - public uint MaxMp => this.Struct->CharacterData.MaxMana; - - /// - public uint CurrentGp => this.Struct->CharacterData.GatheringPoints; - - /// - public uint MaxGp => this.Struct->CharacterData.MaxGatheringPoints; - - /// - public uint CurrentCp => this.Struct->CharacterData.CraftingPoints; - - /// - public uint MaxCp => this.Struct->CharacterData.MaxCraftingPoints; - - /// - public byte ShieldPercentage => this.Struct->CharacterData.ShieldValue; - - /// - public ExcelResolver ClassJob => new(this.Struct->CharacterData.ClassJob); - - /// - public byte Level => this.Struct->CharacterData.Level; - - /// - public byte[] Customize => this.Struct->DrawData.CustomizeData.Data.ToArray(); - - /// - public SeString CompanyTag => MemoryHelper.ReadSeString((nint)Unsafe.AsPointer(ref this.Struct->FreeCompanyTag[0]), 6); - - /// - /// Gets the target object ID of the character. - /// - public override ulong TargetObjectId => this.Struct->TargetId; - - /// - public uint NameId => this.Struct->NameId; - - /// - public ExcelResolver OnlineStatus => new(this.Struct->CharacterData.OnlineStatus); - - /// - /// Gets the status flags. - /// - public StatusFlags StatusFlags => - (this.Struct->IsHostile ? StatusFlags.Hostile : StatusFlags.None) | - (this.Struct->InCombat ? StatusFlags.InCombat : StatusFlags.None) | - (this.Struct->IsWeaponDrawn ? StatusFlags.WeaponOut : StatusFlags.None) | - (this.Struct->IsOffhandDrawn ? StatusFlags.OffhandOut : StatusFlags.None) | - (this.Struct->IsPartyMember ? StatusFlags.PartyMember : StatusFlags.None) | - (this.Struct->IsAllianceMember ? StatusFlags.AllianceMember : StatusFlags.None) | - (this.Struct->IsFriend ? StatusFlags.Friend : StatusFlags.None) | - (this.Struct->IsCasting ? StatusFlags.IsCasting : StatusFlags.None); - - /// - /// Gets the underlying structure. - /// - protected internal new FFXIVClientStructs.FFXIV.Client.Game.Character.Character* Struct => - (FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)this.Address; -} - /// /// Interface representing a character. /// @@ -179,3 +94,88 @@ public interface ICharacter : IGameObject /// public StatusFlags StatusFlags { get; } } + +/// +/// This class represents the base for non-static entities. +/// +internal unsafe class Character : GameObject, ICharacter +{ + /// + /// Initializes a new instance of the class. + /// This represents a non-static entity. + /// + /// The address of this character in memory. + internal Character(IntPtr address) + : base(address) + { + } + + /// + public uint CurrentHp => this.Struct->CharacterData.Health; + + /// + public uint MaxHp => this.Struct->CharacterData.MaxHealth; + + /// + public uint CurrentMp => this.Struct->CharacterData.Mana; + + /// + public uint MaxMp => this.Struct->CharacterData.MaxMana; + + /// + public uint CurrentGp => this.Struct->CharacterData.GatheringPoints; + + /// + public uint MaxGp => this.Struct->CharacterData.MaxGatheringPoints; + + /// + public uint CurrentCp => this.Struct->CharacterData.CraftingPoints; + + /// + public uint MaxCp => this.Struct->CharacterData.MaxCraftingPoints; + + /// + public byte ShieldPercentage => this.Struct->CharacterData.ShieldValue; + + /// + public ExcelResolver ClassJob => new(this.Struct->CharacterData.ClassJob); + + /// + public byte Level => this.Struct->CharacterData.Level; + + /// + public byte[] Customize => this.Struct->DrawData.CustomizeData.Data.ToArray(); + + /// + public SeString CompanyTag => MemoryHelper.ReadSeString((nint)Unsafe.AsPointer(ref this.Struct->FreeCompanyTag[0]), 6); + + /// + /// Gets the target object ID of the character. + /// + public override ulong TargetObjectId => this.Struct->TargetId; + + /// + public uint NameId => this.Struct->NameId; + + /// + public ExcelResolver OnlineStatus => new(this.Struct->CharacterData.OnlineStatus); + + /// + /// Gets the status flags. + /// + public StatusFlags StatusFlags => + (this.Struct->IsHostile ? StatusFlags.Hostile : StatusFlags.None) | + (this.Struct->InCombat ? StatusFlags.InCombat : StatusFlags.None) | + (this.Struct->IsWeaponDrawn ? StatusFlags.WeaponOut : StatusFlags.None) | + (this.Struct->IsOffhandDrawn ? StatusFlags.OffhandOut : StatusFlags.None) | + (this.Struct->IsPartyMember ? StatusFlags.PartyMember : StatusFlags.None) | + (this.Struct->IsAllianceMember ? StatusFlags.AllianceMember : StatusFlags.None) | + (this.Struct->IsFriend ? StatusFlags.Friend : StatusFlags.None) | + (this.Struct->IsCasting ? StatusFlags.IsCasting : StatusFlags.None); + + /// + /// Gets the underlying structure. + /// + protected internal new FFXIVClientStructs.FFXIV.Client.Game.Character.Character* Struct => + (FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)this.Address; +} diff --git a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs index 083fbbcc3..f9fd87bf4 100644 --- a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs +++ b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs @@ -7,6 +7,119 @@ using Dalamud.Memory; namespace Dalamud.Game.ClientState.Objects.Types; +/// +/// Interface representing a game object. +/// +public interface IGameObject : IEquatable +{ + /// + /// Gets the name of this . + /// + public SeString Name { get; } + + /// + /// Gets the GameObjectID for this GameObject. The Game Object ID is a globally unique identifier that points to + /// this specific object. This ID is used to reference specific objects on the local client (e.g. for targeting). + /// + /// Not to be confused with . + /// + public ulong GameObjectId { get; } + + /// + /// Gets the Entity ID for this GameObject. Entity IDs are assigned to networked GameObjects. + /// + /// A value of 0xE000_0000 indicates that this entity is not networked and has specific interactivity rules. + /// + public uint EntityId { get; } + + /// + /// Gets the data ID for linking to other respective game data. + /// + public uint DataId { get; } + + /// + /// Gets the ID of this GameObject's owner. + /// + public uint OwnerId { get; } + + /// + /// Gets the index of this object in the object table. + /// + public ushort ObjectIndex { get; } + + /// + /// Gets the entity kind of this . + /// See the ObjectKind enum for possible values. + /// + public ObjectKind ObjectKind { get; } + + /// + /// Gets the sub kind of this Actor. + /// + public byte SubKind { get; } + + /// + /// Gets the X distance from the local player in yalms. + /// + public byte YalmDistanceX { get; } + + /// + /// Gets the Y distance from the local player in yalms. + /// + public byte YalmDistanceZ { get; } + + /// + /// Gets a value indicating whether the object is dead or alive. + /// + public bool IsDead { get; } + + /// + /// Gets a value indicating whether the object is targetable. + /// + public bool IsTargetable { get; } + + /// + /// Gets the position of this . + /// + public Vector3 Position { get; } + + /// + /// Gets the rotation of this . + /// This ranges from -pi to pi radians. + /// + public float Rotation { get; } + + /// + /// Gets the hitbox radius of this . + /// + public float HitboxRadius { get; } + + /// + /// Gets the current target of the game object. + /// + public ulong TargetObjectId { get; } + + /// + /// Gets the target object of the game object. + /// + /// + /// This iterates the actor table, it should be used with care. + /// + // TODO: Fix for non-networked GameObjects + public IGameObject? TargetObject { get; } + + /// + /// Gets the address of the game object in memory. + /// + public IntPtr Address { get; } + + /// + /// Gets a value indicating whether this actor is still valid in memory. + /// + /// True or false. + public bool IsValid(); +} + /// /// This class represents a GameObject in FFXIV. /// @@ -22,15 +135,10 @@ internal partial class GameObject } /// - /// Gets the address of the game object in memory. + /// Gets or sets the address of the game object in memory. /// public IntPtr Address { get; internal set; } - /// - /// Gets the Dalamud instance. - /// - private protected Dalamud Dalamud { get; } - /// /// This allows you to if (obj) {...} to check for validity. /// @@ -148,116 +256,3 @@ internal unsafe partial class GameObject : IGameObject /// public override string ToString() => $"{this.GameObjectId:X}({this.Name.TextValue} - {this.ObjectKind}) at {this.Address:X}"; } - -/// -/// Interface representing a game object. -/// -public interface IGameObject : IEquatable -{ - /// - /// Gets the name of this . - /// - public SeString Name { get; } - - /// - /// Gets the GameObjectID for this GameObject. The Game Object ID is a globally unique identifier that points to - /// this specific object. This ID is used to reference specific objects on the local client (e.g. for targeting). - /// - /// Not to be confused with . - /// - public ulong GameObjectId { get; } - - /// - /// Gets the Entity ID for this GameObject. Entity IDs are assigned to networked GameObjects. - /// - /// A value of 0xE000_0000 indicates that this entity is not networked and has specific interactivity rules. - /// - public uint EntityId { get; } - - /// - /// Gets the data ID for linking to other respective game data. - /// - public uint DataId { get; } - - /// - /// Gets the ID of this GameObject's owner. - /// - public uint OwnerId { get; } - - /// - /// Gets the index of this object in the object table. - /// - public ushort ObjectIndex { get; } - - /// - /// Gets the entity kind of this . - /// See the ObjectKind enum for possible values. - /// - public ObjectKind ObjectKind { get; } - - /// - /// Gets the sub kind of this Actor. - /// - public byte SubKind { get; } - - /// - /// Gets the X distance from the local player in yalms. - /// - public byte YalmDistanceX { get; } - - /// - /// Gets the Y distance from the local player in yalms. - /// - public byte YalmDistanceZ { get; } - - /// - /// Gets a value indicating whether the object is dead or alive. - /// - public bool IsDead { get; } - - /// - /// Gets a value indicating whether the object is targetable. - /// - public bool IsTargetable { get; } - - /// - /// Gets the position of this . - /// - public Vector3 Position { get; } - - /// - /// Gets the rotation of this . - /// This ranges from -pi to pi radians. - /// - public float Rotation { get; } - - /// - /// Gets the hitbox radius of this . - /// - public float HitboxRadius { get; } - - /// - /// Gets the current target of the game object. - /// - public ulong TargetObjectId { get; } - - /// - /// Gets the target object of the game object. - /// - /// - /// This iterates the actor table, it should be used with care. - /// - // TODO: Fix for non-networked GameObjects - public IGameObject? TargetObject { get; } - - /// - /// Gets the address of the game object in memory. - /// - public IntPtr Address { get; } - - /// - /// Gets a value indicating whether this actor is still valid in memory. - /// - /// True or false. - public bool IsValid(); -} diff --git a/Dalamud/Game/ClientState/Party/PartyMember.cs b/Dalamud/Game/ClientState/Party/PartyMember.cs index 27a872eb3..34cd31dec 100644 --- a/Dalamud/Game/ClientState/Party/PartyMember.cs +++ b/Dalamud/Game/ClientState/Party/PartyMember.cs @@ -10,6 +10,95 @@ using Dalamud.Memory; namespace Dalamud.Game.ClientState.Party; +/// +/// Interface representing a party member. +/// +public interface IPartyMember +{ + /// + /// Gets the address of this party member in memory. + /// + IntPtr Address { get; } + + /// + /// Gets a list of buffs or debuffs applied to this party member. + /// + StatusList Statuses { get; } + + /// + /// Gets the position of the party member. + /// + Vector3 Position { get; } + + /// + /// Gets the content ID of the party member. + /// + long ContentId { get; } + + /// + /// Gets the actor ID of this party member. + /// + uint ObjectId { get; } + + /// + /// Gets the actor associated with this buddy. + /// + /// + /// This iterates the actor table, it should be used with care. + /// + IGameObject? GameObject { get; } + + /// + /// Gets the current HP of this party member. + /// + uint CurrentHP { get; } + + /// + /// Gets the maximum HP of this party member. + /// + uint MaxHP { get; } + + /// + /// Gets the current MP of this party member. + /// + ushort CurrentMP { get; } + + /// + /// Gets the maximum MP of this party member. + /// + ushort MaxMP { get; } + + /// + /// Gets the territory this party member is located in. + /// + ExcelResolver Territory { get; } + + /// + /// Gets the World this party member resides in. + /// + ExcelResolver World { get; } + + /// + /// Gets the displayname of this party member. + /// + SeString Name { get; } + + /// + /// Gets the sex of this party member. + /// + byte Sex { get; } + + /// + /// Gets the classjob of this party member. + /// + ExcelResolver ClassJob { get; } + + /// + /// Gets the level of this party member. + /// + byte Level { get; } +} + /// /// This class represents a party member in the group manager. /// @@ -109,92 +198,3 @@ internal unsafe class PartyMember : IPartyMember private FFXIVClientStructs.FFXIV.Client.Game.Group.PartyMember* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Group.PartyMember*)this.Address; } - -/// -/// Interface representing a party member. -/// -public interface IPartyMember -{ - /// - /// Gets the address of this party member in memory. - /// - IntPtr Address { get; } - - /// - /// Gets a list of buffs or debuffs applied to this party member. - /// - StatusList Statuses { get; } - - /// - /// Gets the position of the party member. - /// - Vector3 Position { get; } - - /// - /// Gets the content ID of the party member. - /// - long ContentId { get; } - - /// - /// Gets the actor ID of this party member. - /// - uint ObjectId { get; } - - /// - /// Gets the actor associated with this buddy. - /// - /// - /// This iterates the actor table, it should be used with care. - /// - IGameObject? GameObject { get; } - - /// - /// Gets the current HP of this party member. - /// - uint CurrentHP { get; } - - /// - /// Gets the maximum HP of this party member. - /// - uint MaxHP { get; } - - /// - /// Gets the current MP of this party member. - /// - ushort CurrentMP { get; } - - /// - /// Gets the maximum MP of this party member. - /// - ushort MaxMP { get; } - - /// - /// Gets the territory this party member is located in. - /// - ExcelResolver Territory { get; } - - /// - /// Gets the World this party member resides in. - /// - ExcelResolver World { get; } - - /// - /// Gets the displayname of this party member. - /// - SeString Name { get; } - - /// - /// Gets the sex of this party member. - /// - byte Sex { get; } - - /// - /// Gets the classjob of this party member. - /// - ExcelResolver ClassJob { get; } - - /// - /// Gets the level of this party member. - /// - byte Level { get; } -} diff --git a/Dalamud/Game/Command/CommandInfo.cs b/Dalamud/Game/Command/CommandInfo.cs index 32413b510..8aed817d0 100644 --- a/Dalamud/Game/Command/CommandInfo.cs +++ b/Dalamud/Game/Command/CommandInfo.cs @@ -1,30 +1,5 @@ namespace Dalamud.Game.Command; -/// -/// This class describes a registered command. -/// -public sealed class CommandInfo : IReadOnlyCommandInfo -{ - /// - /// Initializes a new instance of the class. - /// Create a new CommandInfo with the provided handler. - /// - /// The method to call when the command is run. - public CommandInfo(IReadOnlyCommandInfo.HandlerDelegate handler) - { - this.Handler = handler; - } - - /// - public IReadOnlyCommandInfo.HandlerDelegate Handler { get; } - - /// - public string HelpMessage { get; set; } = string.Empty; - - /// - public bool ShowInHelp { get; set; } = true; -} - /// /// Interface representing a registered command. /// @@ -52,3 +27,28 @@ public interface IReadOnlyCommandInfo /// bool ShowInHelp { get; } } + +/// +/// This class describes a registered command. +/// +public sealed class CommandInfo : IReadOnlyCommandInfo +{ + /// + /// Initializes a new instance of the class. + /// Create a new CommandInfo with the provided handler. + /// + /// The method to call when the command is run. + public CommandInfo(IReadOnlyCommandInfo.HandlerDelegate handler) + { + this.Handler = handler; + } + + /// + public IReadOnlyCommandInfo.HandlerDelegate Handler { get; } + + /// + public string HelpMessage { get; set; } = string.Empty; + + /// + public bool ShowInHelp { get; set; } = true; +} diff --git a/Dalamud/Game/Command/CommandManager.cs b/Dalamud/Game/Command/CommandManager.cs index dd0a8346d..aa6798171 100644 --- a/Dalamud/Game/Command/CommandManager.cs +++ b/Dalamud/Game/Command/CommandManager.cs @@ -114,22 +114,28 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag } } - /// - public bool AddHandler(string command, CommandInfo info, string loaderAssemblyName = "") + /// + /// Add a command handler, which you can use to add your own custom commands to the in-game chat. + /// + /// The command to register. + /// A object describing the command. + /// Assembly name of the plugin that added this command. + /// If adding was successful. + public bool AddHandler(string command, CommandInfo info, string loaderAssemblyName) { if (info == null) throw new ArgumentNullException(nameof(info), "Command handler is null."); if (!this.commandMap.TryAdd(command, info)) { - Log.Error("Command {CommandName} is already registered.", command); + Log.Error("Command {CommandName} is already registered", command); return false; } if (!this.commandAssemblyNameMap.TryAdd((command, info), loaderAssemblyName)) { this.commandMap.Remove(command, out _); - Log.Error("Command {CommandName} is already registered in the assembly name map.", command); + Log.Error("Command {CommandName} is already registered in the assembly name map", command); return false; } @@ -178,7 +184,7 @@ internal sealed class CommandManager : IInternalDisposableService, ICommandManag /// /// The name of the assembly. /// A list of commands and their associated activation string. - public List> GetHandlersByAssemblyName(string assemblyName) + public List> GetHandlersByAssemblyName(string assemblyName) { return this.commandAssemblyNameMap.Where(c => c.Value == assemblyName).ToList(); } diff --git a/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs b/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs index 55c0b178b..6d146b265 100644 --- a/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs +++ b/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs @@ -111,6 +111,19 @@ internal sealed unsafe class ContextMenu : IInternalDisposableService, IContextM } } + /// + /// Gets the name with the given prefix. + /// + /// The menu item to prefix. + /// The prefixed name. + internal SeString GetPrefixedName(IMenuItem menuItem) => + menuItem.Prefix is { } prefix + ? new SeStringBuilder() + .AddUiForeground($"{prefix.ToIconString()} ", menuItem.PrefixColor) + .Append(menuItem.Name) + .Build() + : menuItem.Name; + private AtkValue* ExpandContextMenuArray(Span oldValues, int newSize) { // if the array has enough room, don't reallocate @@ -253,17 +266,6 @@ internal sealed unsafe class ContextMenu : IInternalDisposableService, IContextM offsetData[sizeHeaderIdx].UInt += (uint)items.Count; } - - /// - /// Gets the name with the given prefix. - /// - internal SeString GetPrefixedName(IMenuItem menuItem) => - menuItem.Prefix is { } prefix - ? new SeStringBuilder() - .AddUiForeground($"{prefix.ToIconString()} ", menuItem.PrefixColor) - .Append(menuItem.Name) - .Build() - : menuItem.Name; private void SetupContextMenu(IReadOnlyList items, ref int valueCount, ref AtkValue* values) { diff --git a/Dalamud/Game/Gui/ContextMenu/MenuArgs.cs b/Dalamud/Game/Gui/ContextMenu/MenuArgs.cs index bd6d2ef68..39fd1c52c 100644 --- a/Dalamud/Game/Gui/ContextMenu/MenuArgs.cs +++ b/Dalamud/Game/Gui/ContextMenu/MenuArgs.cs @@ -8,6 +8,47 @@ using FFXIVClientStructs.FFXIV.Component.GUI; namespace Dalamud.Game.Gui.ContextMenu; +/// +/// Interface representing a context menus args. +/// +public interface IMenuArgs +{ + /// + /// Gets a list of AtkEventInterface pointers associated with the context menu. + /// Only available with . + /// Almost always an agent pointer. You can use this to find out what type of context menu it is. + /// + /// Thrown when the context menu is not a . + public IReadOnlySet EventInterfaces { get; } + + /// + /// Gets the name of the addon that opened the context menu. + /// + public string? AddonName { get; } + + /// + /// Gets the memory pointer of the addon that opened the context menu. + /// + public nint AddonPtr { get; } + + /// + /// Gets the memory pointer of the agent that opened the context menu. + /// + public nint AgentPtr { get; } + + /// + /// Gets the type of the context menu. + /// + public ContextMenuType MenuType { get; } + + /// + /// Gets the target info of the context menu. The actual type depends on . + /// signifies a . + /// signifies a . + /// + public MenuTarget Target { get; } +} + /// /// Base class for menu args. /// @@ -68,44 +109,3 @@ internal abstract unsafe class MenuArgs : IMenuArgs } } } - -/// -/// Interface representing a context menus args. -/// -public interface IMenuArgs -{ - /// - /// Gets a list of AtkEventInterface pointers associated with the context menu. - /// Only available with . - /// Almost always an agent pointer. You can use this to find out what type of context menu it is. - /// - /// Thrown when the context menu is not a . - public IReadOnlySet EventInterfaces { get; } - - /// - /// Gets the name of the addon that opened the context menu. - /// - public string? AddonName { get; } - - /// - /// Gets the memory pointer of the addon that opened the context menu. - /// - public nint AddonPtr { get; } - - /// - /// Gets the memory pointer of the agent that opened the context menu. - /// - public nint AgentPtr { get; } - - /// - /// Gets the type of the context menu. - /// - public ContextMenuType MenuType { get; } - - /// - /// Gets the target info of the context menu. The actual type depends on . - /// signifies a . - /// signifies a . - /// - public MenuTarget Target { get; } -} diff --git a/Dalamud/Game/Gui/ContextMenu/MenuItem.cs b/Dalamud/Game/Gui/ContextMenu/MenuItem.cs index 22b7068f2..9b7cc2bc1 100644 --- a/Dalamud/Game/Gui/ContextMenu/MenuItem.cs +++ b/Dalamud/Game/Gui/ContextMenu/MenuItem.cs @@ -5,58 +5,6 @@ using Lumina.Excel.GeneratedSheets; namespace Dalamud.Game.Gui.ContextMenu; -/// -/// A menu item that can be added to a context menu. -/// -public sealed record MenuItem : IMenuItem -{ - /// - public SeString Name { get; set; } = SeString.Empty; - - /// - public SeIconChar? Prefix { get; set; } - - /// - public char? PrefixChar - { - set - { - if (value is { } prefix) - { - if (!char.IsAsciiLetterUpper(prefix)) - throw new ArgumentException("Prefix must be an uppercase letter", nameof(value)); - - this.Prefix = SeIconChar.BoxedLetterA + prefix - 'A'; - } - else - { - this.Prefix = null; - } - } - } - - /// - public ushort PrefixColor { get; set; } - - /// - public bool UseDefaultPrefix { get; set; } - - /// - public Action? OnClicked { get; set; } - - /// - public int Priority { get; set; } - - /// - public bool IsEnabled { get; set; } = true; - - /// - public bool IsSubmenu { get; set; } - - /// - public bool IsReturn { get; set; } -} - /// /// Interface representing a menu item to be added to a context menu. /// @@ -129,3 +77,55 @@ public interface IMenuItem /// bool IsReturn { get; set; } } + +/// +/// A menu item that can be added to a context menu. +/// +public sealed record MenuItem : IMenuItem +{ + /// + public SeString Name { get; set; } = SeString.Empty; + + /// + public SeIconChar? Prefix { get; set; } + + /// + public char? PrefixChar + { + set + { + if (value is { } prefix) + { + if (!char.IsAsciiLetterUpper(prefix)) + throw new ArgumentException("Prefix must be an uppercase letter", nameof(value)); + + this.Prefix = SeIconChar.BoxedLetterA + prefix - 'A'; + } + else + { + this.Prefix = null; + } + } + } + + /// + public ushort PrefixColor { get; set; } + + /// + public bool UseDefaultPrefix { get; set; } + + /// + public Action? OnClicked { get; set; } + + /// + public int Priority { get; set; } + + /// + public bool IsEnabled { get; set; } = true; + + /// + public bool IsSubmenu { get; set; } + + /// + public bool IsReturn { get; set; } +} diff --git a/Dalamud/Game/Gui/ContextMenu/MenuItemClickedArgs.cs b/Dalamud/Game/Gui/ContextMenu/MenuItemClickedArgs.cs index 03ff486ef..79c069562 100644 --- a/Dalamud/Game/Gui/ContextMenu/MenuItemClickedArgs.cs +++ b/Dalamud/Game/Gui/ContextMenu/MenuItemClickedArgs.cs @@ -7,6 +7,25 @@ using FFXIVClientStructs.FFXIV.Component.GUI; namespace Dalamud.Game.Gui.ContextMenu; +/// +/// An interface representing the callback args used when a menu item is clicked. +/// +public interface IMenuItemClickedArgs : IMenuArgs +{ + /// + /// Opens a submenu with the given name and items. + /// + /// The name of the submenu, displayed at the top. + /// The items to display in the submenu. + void OpenSubmenu(SeString name, IReadOnlyList items); + + /// + /// Opens a submenu with the given items. + /// + /// The items to display in the submenu. + void OpenSubmenu(IReadOnlyList items); +} + /// /// Callback args used when a menu item is clicked. /// @@ -36,22 +55,3 @@ internal sealed unsafe class MenuItemClickedArgs : MenuArgs, IMenuItemClickedArg public void OpenSubmenu(IReadOnlyList items) => this.OnOpenSubmenu(null, items); } - -/// -/// An interface representing the callback args used when a menu item is clicked. -/// -public interface IMenuItemClickedArgs : IMenuArgs -{ - /// - /// Opens a submenu with the given name and items. - /// - /// The name of the submenu, displayed at the top. - /// The items to display in the submenu. - void OpenSubmenu(SeString name, IReadOnlyList items); - - /// - /// Opens a submenu with the given items. - /// - /// The items to display in the submenu. - void OpenSubmenu(IReadOnlyList items); -} diff --git a/Dalamud/Game/Gui/ContextMenu/MenuOpenedArgs.cs b/Dalamud/Game/Gui/ContextMenu/MenuOpenedArgs.cs index ca990cfd8..074496245 100644 --- a/Dalamud/Game/Gui/ContextMenu/MenuOpenedArgs.cs +++ b/Dalamud/Game/Gui/ContextMenu/MenuOpenedArgs.cs @@ -5,6 +5,18 @@ using FFXIVClientStructs.FFXIV.Component.GUI; namespace Dalamud.Game.Gui.ContextMenu; +/// +/// An interface representing the callback args used when a menu item is opened. +/// +public interface IMenuOpenedArgs : IMenuArgs +{ + /// + /// Adds a custom menu item to the context menu. + /// + /// The menu item to add. + void AddMenuItem(MenuItem item); +} + /// /// Callback args used when a menu item is opened. /// @@ -30,15 +42,3 @@ internal sealed unsafe class MenuOpenedArgs : MenuArgs, IMenuOpenedArgs public void AddMenuItem(MenuItem item) => this.OnAddMenuItem(item); } - -/// -/// An interface representing the callback args used when a menu item is opened. -/// -public interface IMenuOpenedArgs : IMenuArgs -{ - /// - /// Adds a custom menu item to the context menu. - /// - /// The menu item to add. - void AddMenuItem(MenuItem item); -} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListing.cs b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListing.cs index abcc187fd..fb8d4b900 100644 --- a/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListing.cs +++ b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListing.cs @@ -9,156 +9,6 @@ using Lumina.Excel.GeneratedSheets; namespace Dalamud.Game.Gui.PartyFinder.Types; -/// -/// A single listing in party finder. -/// -internal class PartyFinderListing : IPartyFinderListing -{ - private readonly byte objective; - private readonly byte conditions; - private readonly byte dutyFinderSettings; - private readonly byte lootRules; - private readonly byte searchArea; - private readonly PartyFinderSlot[] slots; - private readonly byte[] jobsPresent; - - /// - /// Initializes a new instance of the class. - /// - /// The interop listing data. - internal PartyFinderListing(PartyFinderPacketListing listing) - { - var dataManager = Service.Get(); - - this.objective = listing.Objective; - this.conditions = listing.Conditions; - this.dutyFinderSettings = listing.DutyFinderSettings; - this.lootRules = listing.LootRules; - this.searchArea = listing.SearchArea; - this.slots = listing.Slots.Select(accepting => new PartyFinderSlot(accepting)).ToArray(); - this.jobsPresent = listing.JobsPresent; - - this.Id = listing.Id; - this.ContentIdLower = listing.ContentIdLower; - this.Name = SeString.Parse(listing.Name.TakeWhile(b => b != 0).ToArray()); - this.Description = SeString.Parse(listing.Description.TakeWhile(b => b != 0).ToArray()); - this.World = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.World)); - this.HomeWorld = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.HomeWorld)); - this.CurrentWorld = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.CurrentWorld)); - this.Category = (DutyCategory)listing.Category; - this.RawDuty = listing.Duty; - this.Duty = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.Duty)); - this.DutyType = (DutyType)listing.DutyType; - this.BeginnersWelcome = listing.BeginnersWelcome == 1; - this.SecondsRemaining = listing.SecondsRemaining; - this.MinimumItemLevel = listing.MinimumItemLevel; - this.Parties = listing.NumParties; - this.SlotsAvailable = listing.NumSlots; - this.LastPatchHotfixTimestamp = listing.LastPatchHotfixTimestamp; - this.JobsPresent = listing.JobsPresent - .Select(id => new Lazy( - () => id == 0 - ? null - : dataManager.GetExcelSheet().GetRow(id))) - .ToArray(); - } - - /// - public uint Id { get; } - - /// - public uint ContentIdLower { get; } - - /// - public SeString Name { get; } - - /// - public SeString Description { get; } - - /// - public Lazy World { get; } - - /// - public Lazy HomeWorld { get; } - - /// - public Lazy CurrentWorld { get; } - - /// - public DutyCategory Category { get; } - - /// - public ushort RawDuty { get; } - - /// - public Lazy Duty { get; } - - /// - public DutyType DutyType { get; } - - /// - public bool BeginnersWelcome { get; } - - /// - public ushort SecondsRemaining { get; } - - /// - public ushort MinimumItemLevel { get; } - - /// - public byte Parties { get; } - - /// - public byte SlotsAvailable { get; } - - /// - public uint LastPatchHotfixTimestamp { get; } - - /// - public IReadOnlyCollection Slots => this.slots; - - /// - public ObjectiveFlags Objective => (ObjectiveFlags)this.objective; - - /// - public ConditionFlags Conditions => (ConditionFlags)this.conditions; - - /// - public DutyFinderSettingsFlags DutyFinderSettings => (DutyFinderSettingsFlags)this.dutyFinderSettings; - - /// - public LootRuleFlags LootRules => (LootRuleFlags)this.lootRules; - - /// - public SearchAreaFlags SearchArea => (SearchAreaFlags)this.searchArea; - - /// - public IReadOnlyCollection RawJobsPresent => this.jobsPresent; - - /// - public IReadOnlyCollection> JobsPresent { get; } - - #region Indexers - - /// - public bool this[ObjectiveFlags flag] => this.objective == 0 || (this.objective & (uint)flag) > 0; - - /// - public bool this[ConditionFlags flag] => this.conditions == 0 || (this.conditions & (uint)flag) > 0; - - /// - public bool this[DutyFinderSettingsFlags flag] => this.dutyFinderSettings == 0 || (this.dutyFinderSettings & (uint)flag) > 0; - - /// - public bool this[LootRuleFlags flag] => this.lootRules == 0 || (this.lootRules & (uint)flag) > 0; - - /// - public bool this[SearchAreaFlags flag] => this.searchArea == 0 || (this.searchArea & (uint)flag) > 0; - - #endregion - -} - /// /// A interface representing a single listing in party finder. /// @@ -327,3 +177,153 @@ public interface IPartyFinderListing /// A value indicating whether the flag is present. bool this[SearchAreaFlags flag] { get; } } + +/// +/// A single listing in party finder. +/// +internal class PartyFinderListing : IPartyFinderListing +{ + private readonly byte objective; + private readonly byte conditions; + private readonly byte dutyFinderSettings; + private readonly byte lootRules; + private readonly byte searchArea; + private readonly PartyFinderSlot[] slots; + private readonly byte[] jobsPresent; + + /// + /// Initializes a new instance of the class. + /// + /// The interop listing data. + internal PartyFinderListing(PartyFinderPacketListing listing) + { + var dataManager = Service.Get(); + + this.objective = listing.Objective; + this.conditions = listing.Conditions; + this.dutyFinderSettings = listing.DutyFinderSettings; + this.lootRules = listing.LootRules; + this.searchArea = listing.SearchArea; + this.slots = listing.Slots.Select(accepting => new PartyFinderSlot(accepting)).ToArray(); + this.jobsPresent = listing.JobsPresent; + + this.Id = listing.Id; + this.ContentIdLower = listing.ContentIdLower; + this.Name = SeString.Parse(listing.Name.TakeWhile(b => b != 0).ToArray()); + this.Description = SeString.Parse(listing.Description.TakeWhile(b => b != 0).ToArray()); + this.World = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.World)); + this.HomeWorld = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.HomeWorld)); + this.CurrentWorld = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.CurrentWorld)); + this.Category = (DutyCategory)listing.Category; + this.RawDuty = listing.Duty; + this.Duty = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.Duty)); + this.DutyType = (DutyType)listing.DutyType; + this.BeginnersWelcome = listing.BeginnersWelcome == 1; + this.SecondsRemaining = listing.SecondsRemaining; + this.MinimumItemLevel = listing.MinimumItemLevel; + this.Parties = listing.NumParties; + this.SlotsAvailable = listing.NumSlots; + this.LastPatchHotfixTimestamp = listing.LastPatchHotfixTimestamp; + this.JobsPresent = listing.JobsPresent + .Select(id => new Lazy( + () => id == 0 + ? null + : dataManager.GetExcelSheet().GetRow(id))) + .ToArray(); + } + + /// + public uint Id { get; } + + /// + public uint ContentIdLower { get; } + + /// + public SeString Name { get; } + + /// + public SeString Description { get; } + + /// + public Lazy World { get; } + + /// + public Lazy HomeWorld { get; } + + /// + public Lazy CurrentWorld { get; } + + /// + public DutyCategory Category { get; } + + /// + public ushort RawDuty { get; } + + /// + public Lazy Duty { get; } + + /// + public DutyType DutyType { get; } + + /// + public bool BeginnersWelcome { get; } + + /// + public ushort SecondsRemaining { get; } + + /// + public ushort MinimumItemLevel { get; } + + /// + public byte Parties { get; } + + /// + public byte SlotsAvailable { get; } + + /// + public uint LastPatchHotfixTimestamp { get; } + + /// + public IReadOnlyCollection Slots => this.slots; + + /// + public ObjectiveFlags Objective => (ObjectiveFlags)this.objective; + + /// + public ConditionFlags Conditions => (ConditionFlags)this.conditions; + + /// + public DutyFinderSettingsFlags DutyFinderSettings => (DutyFinderSettingsFlags)this.dutyFinderSettings; + + /// + public LootRuleFlags LootRules => (LootRuleFlags)this.lootRules; + + /// + public SearchAreaFlags SearchArea => (SearchAreaFlags)this.searchArea; + + /// + public IReadOnlyCollection RawJobsPresent => this.jobsPresent; + + /// + public IReadOnlyCollection> JobsPresent { get; } + + #region Indexers + + /// + public bool this[ObjectiveFlags flag] => this.objective == 0 || (this.objective & (uint)flag) > 0; + + /// + public bool this[ConditionFlags flag] => this.conditions == 0 || (this.conditions & (uint)flag) > 0; + + /// + public bool this[DutyFinderSettingsFlags flag] => this.dutyFinderSettings == 0 || (this.dutyFinderSettings & (uint)flag) > 0; + + /// + public bool this[LootRuleFlags flag] => this.lootRules == 0 || (this.lootRules & (uint)flag) > 0; + + /// + public bool this[SearchAreaFlags flag] => this.searchArea == 0 || (this.searchArea & (uint)flag) > 0; + + #endregion + +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListingEventArgs.cs b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListingEventArgs.cs index b366c6105..87f672a5b 100644 --- a/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListingEventArgs.cs +++ b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListingEventArgs.cs @@ -1,5 +1,21 @@ namespace Dalamud.Game.Gui.PartyFinder.Types; +/// +/// A interface representing additional arguments passed by the game. +/// +public interface IPartyFinderListingEventArgs +{ + /// + /// Gets the batch number. + /// + int BatchNumber { get; } + + /// + /// Gets or sets a value indicating whether the listing is visible. + /// + bool Visible { get; set; } +} + /// /// This class represents additional arguments passed by the game. /// @@ -20,19 +36,3 @@ internal class PartyFinderListingEventArgs : IPartyFinderListingEventArgs /// public bool Visible { get; set; } = true; } - -/// -/// A interface representing additional arguments passed by the game. -/// -public interface IPartyFinderListingEventArgs -{ - /// - /// Gets the batch number. - /// - int BatchNumber { get; } - - /// - /// Gets or sets a value indicating whether the listing is visible. - /// - bool Visible { get; set; } -} diff --git a/Dalamud/Game/Network/Internal/MarketBoardUploaders/Universalis/UniversalisMarketBoardUploader.cs b/Dalamud/Game/Network/Internal/MarketBoardUploaders/Universalis/UniversalisMarketBoardUploader.cs index 4fe701c48..15f192bff 100644 --- a/Dalamud/Game/Network/Internal/MarketBoardUploaders/Universalis/UniversalisMarketBoardUploader.cs +++ b/Dalamud/Game/Network/Internal/MarketBoardUploaders/Universalis/UniversalisMarketBoardUploader.cs @@ -54,6 +54,7 @@ internal class UniversalisMarketBoardUploader : IMarketBoardUploader foreach (var marketBoardItemListing in request.Listings) { +#pragma warning disable CS0618 // Type or member is obsolete var universalisListing = new UniversalisItemListingsEntry { ListingId = marketBoardItemListing.ListingId.ToString(), @@ -70,6 +71,7 @@ internal class UniversalisMarketBoardUploader : IMarketBoardUploader RetainerCity = marketBoardItemListing.RetainerCityId, Materia = new List(), }; +#pragma warning restore CS0618 // Type or member is obsolete foreach (var itemMateria in marketBoardItemListing.Materia) { diff --git a/Dalamud/Game/Network/Structures/MarketBoardCurrentOfferings.cs b/Dalamud/Game/Network/Structures/MarketBoardCurrentOfferings.cs index 96fafe6b6..1281a6237 100644 --- a/Dalamud/Game/Network/Structures/MarketBoardCurrentOfferings.cs +++ b/Dalamud/Game/Network/Structures/MarketBoardCurrentOfferings.cs @@ -138,12 +138,6 @@ public class MarketBoardCurrentOfferings : IMarketBoardCurrentOfferings /// public uint ItemQuantity { get; internal set; } - /// - /// Gets the time this offering was last reviewed. - /// - [Obsolete("Universalis Compatibility, contains a fake value", false)] - internal DateTime LastReviewTime { get; set; } = DateTime.UtcNow; - /// /// Gets the listing ID. /// @@ -164,12 +158,6 @@ public class MarketBoardCurrentOfferings : IMarketBoardCurrentOfferings /// public bool OnMannequin { get; internal set; } - /// - /// Gets the player name. - /// - [Obsolete("Universalis Compatibility, contains a fake value", false)] - internal string PlayerName { get; set; } = string.Empty; - /// /// Gets the price per unit. /// @@ -195,12 +183,6 @@ public class MarketBoardCurrentOfferings : IMarketBoardCurrentOfferings /// public ulong RetainerOwnerId { get; internal set; } - /// - /// Gets the stain or applied dye of the item. - /// - [Obsolete("Universalis Compatibility, use Stain1Id and Stain2Id", false)] - internal int StainId => (this.Stain2Id << 8) | this.Stain1Id; - /// /// Gets the first stain or applied dye of the item. /// @@ -215,6 +197,24 @@ public class MarketBoardCurrentOfferings : IMarketBoardCurrentOfferings /// Gets the total tax. /// public uint TotalTax { get; internal set; } + + /// + /// Gets or sets the time this offering was last reviewed. + /// + [Obsolete("Universalis Compatibility, contains a fake value", false)] + internal DateTime LastReviewTime { get; set; } = DateTime.UtcNow; + + /// + /// Gets the stain or applied dye of the item. + /// + [Obsolete("Universalis Compatibility, use Stain1Id and Stain2Id", false)] + internal int StainId => (this.Stain2Id << 8) | this.Stain1Id; + + /// + /// Gets or sets the player name. + /// + [Obsolete("Universalis Compatibility, contains a fake value", false)] + internal string PlayerName { get; set; } = string.Empty; /// /// This represents the materia slotted to an . diff --git a/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs b/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs index 5dc24f34a..aef68a896 100644 --- a/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs +++ b/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs @@ -97,6 +97,8 @@ internal sealed class ChangelogWindow : Window, IDisposable /// TSM window. /// An instance of . /// An instance of . + /// An instance of . + /// An instance of . public ChangelogWindow( TitleScreenMenuWindow tsmWindow, FontAtlasFactory fontAtlasFactory, diff --git a/Dalamud/Interface/Textures/Internal/SharedImmediateTextures/FileSystemSharedImmediateTexture.cs b/Dalamud/Interface/Textures/Internal/SharedImmediateTextures/FileSystemSharedImmediateTexture.cs index a0203cef0..7e5882b51 100644 --- a/Dalamud/Interface/Textures/Internal/SharedImmediateTextures/FileSystemSharedImmediateTexture.cs +++ b/Dalamud/Interface/Textures/Internal/SharedImmediateTextures/FileSystemSharedImmediateTexture.cs @@ -1,7 +1,7 @@ +using System.IO; using System.Threading; using System.Threading.Tasks; -using Dalamud.Interface.Internal; using Dalamud.Interface.Textures.TextureWraps; namespace Dalamud.Interface.Textures.Internal.SharedImmediateTextures; @@ -19,7 +19,10 @@ internal sealed class FileSystemSharedImmediateTexture : SharedImmediateTexture /// Creates a new placeholder instance of . /// The path. /// The new instance. - /// Only to be used from . + /// + /// Only to be used from or + /// . + /// public static SharedImmediateTexture CreatePlaceholder(string path) => new FileSystemSharedImmediateTexture(path); /// diff --git a/Dalamud/Interface/TitleScreenMenu/TitleScreenMenuEntry.cs b/Dalamud/Interface/TitleScreenMenu/TitleScreenMenuEntry.cs index 02f9e8f3d..2acb275ad 100644 --- a/Dalamud/Interface/TitleScreenMenu/TitleScreenMenuEntry.cs +++ b/Dalamud/Interface/TitleScreenMenu/TitleScreenMenuEntry.cs @@ -9,6 +9,64 @@ using Dalamud.Interface.Textures.TextureWraps; namespace Dalamud.Interface; +/// +/// A interface representing an entry in the title screen menu. +/// +public interface ITitleScreenMenuEntry : IReadOnlyTitleScreenMenuEntry, IComparable +{ + /// + /// Gets or sets a value indicating whether or not this entry is internal. + /// + bool IsInternal { get; set; } + + /// + /// Gets the calling assembly of this entry. + /// + Assembly? CallingAssembly { get; init; } + + /// + /// Gets the internal ID of this entry. + /// + Guid Id { get; init; } + + /// + /// Gets the keys that have to be pressed to show the menu. + /// + IReadOnlySet ShowConditionKeys { get; init; } + + /// + /// Determines the displaying condition of this menu entry is met. + /// + /// True if met. + bool IsShowConditionSatisfied(); + + /// + /// Trigger the action associated with this entry. + /// + void Trigger(); +} + +/// +/// A interface representing a read only entry in the title screen menu. +/// +public interface IReadOnlyTitleScreenMenuEntry +{ + /// + /// Gets the priority of this entry. + /// + ulong Priority { get; } + + /// + /// Gets the name of this entry. + /// + string Name { get; } + + /// + /// Gets the texture of this entry. + /// + IDalamudTextureWrap Texture { get; } +} + /// /// Class representing an entry in the title screen menu. /// @@ -103,61 +161,3 @@ public class TitleScreenMenuEntry : ITitleScreenMenuEntry this.onTriggered(); } } - -/// -/// A interface representing an entry in the title screen menu. -/// -public interface ITitleScreenMenuEntry : IReadOnlyTitleScreenMenuEntry, IComparable -{ - /// - /// Gets or sets a value indicating whether or not this entry is internal. - /// - bool IsInternal { get; set; } - - /// - /// Gets the calling assembly of this entry. - /// - Assembly? CallingAssembly { get; init; } - - /// - /// Gets the internal ID of this entry. - /// - Guid Id { get; init; } - - /// - /// Gets the keys that have to be pressed to show the menu. - /// - IReadOnlySet ShowConditionKeys { get; init; } - - /// - /// Determines the displaying condition of this menu entry is met. - /// - /// True if met. - bool IsShowConditionSatisfied(); - - /// - /// Trigger the action associated with this entry. - /// - void Trigger(); -} - -/// -/// A interface representing a read only entry in the title screen menu. -/// -public interface IReadOnlyTitleScreenMenuEntry -{ - /// - /// Gets the priority of this entry. - /// - ulong Priority { get; } - - /// - /// Gets the name of this entry. - /// - string Name { get; } - - /// - /// Gets the texture of this entry. - /// - IDalamudTextureWrap Texture { get; } -} diff --git a/Dalamud/Plugin/Internal/PluginValidator.cs b/Dalamud/Plugin/Internal/PluginValidator.cs index b7d403b01..b2cbe5520 100644 --- a/Dalamud/Plugin/Internal/PluginValidator.cs +++ b/Dalamud/Plugin/Internal/PluginValidator.cs @@ -72,9 +72,9 @@ internal static class PluginValidator var cmdManager = Service.Get(); - foreach (var cmd in cmdManager.GetHandlersByAssemblyName(plugin.InternalName).Where(c => c.Key.Item2.ShowInHelp)) + foreach (var cmd in cmdManager.GetHandlersByAssemblyName(plugin.InternalName).Where(c => c.Key.CommandInfo.ShowInHelp)) { - if (string.IsNullOrEmpty(cmd.Key.Item2.HelpMessage)) + if (string.IsNullOrEmpty(cmd.Key.CommandInfo.HelpMessage)) problems.Add(new CommandWithoutHelpTextProblem(cmd.Value)); } diff --git a/Dalamud/Plugin/Services/IFateTable.cs b/Dalamud/Plugin/Services/IFateTable.cs index 43bbbc9a1..d10141050 100644 --- a/Dalamud/Plugin/Services/IFateTable.cs +++ b/Dalamud/Plugin/Services/IFateTable.cs @@ -18,13 +18,6 @@ public interface IFateTable : IReadOnlyCollection /// Gets the amount of currently active Fates. /// public int Length { get; } - - /// - /// Gets a value indicating whether this Fate is still valid in memory. - /// - /// The fate to check. - /// True or false. - public bool IsValid(IFate fate); /// /// Get an actor at the specified spawn index. @@ -33,6 +26,13 @@ public interface IFateTable : IReadOnlyCollection /// A at the specified spawn index. public IFate? this[int index] { get; } + /// + /// Gets a value indicating whether this Fate is still valid in memory. + /// + /// The fate to check. + /// True or false. + public bool IsValid(IFate fate); + /// /// Gets the address of the Fate at the specified index of the fate table. /// wo diff --git a/Dalamud/Plugin/Services/ITextureProvider.cs b/Dalamud/Plugin/Services/ITextureProvider.cs index 7541f8f3b..65db7db81 100644 --- a/Dalamud/Plugin/Services/ITextureProvider.cs +++ b/Dalamud/Plugin/Services/ITextureProvider.cs @@ -175,7 +175,7 @@ public interface ITextureProvider /// /// The following functions support the files of the container types pointed by yielded values. ///
    - ///
  • + ///
  • and
  • ///
  • ///
  • ///