chore: convert Dalamud to file-scoped namespaces

This commit is contained in:
goat 2022-10-29 15:23:22 +02:00
parent b093323acc
commit 987ff8dc8f
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
368 changed files with 55081 additions and 55450 deletions

View file

@ -1,72 +1,71 @@
using Dalamud.Game.ClientState.Resolvers;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
namespace Dalamud.Game.ClientState.Aetherytes
namespace Dalamud.Game.ClientState.Aetherytes;
/// <summary>
/// This class represents an entry in the Aetheryte list.
/// </summary>
public sealed class AetheryteEntry
{
private readonly TeleportInfo data;
/// <summary>
/// This class represents an entry in the Aetheryte list.
/// Initializes a new instance of the <see cref="AetheryteEntry"/> class.
/// </summary>
public sealed class AetheryteEntry
/// <param name="data">Data read from the Aetheryte List.</param>
internal AetheryteEntry(TeleportInfo data)
{
private readonly TeleportInfo data;
/// <summary>
/// Initializes a new instance of the <see cref="AetheryteEntry"/> class.
/// </summary>
/// <param name="data">Data read from the Aetheryte List.</param>
internal AetheryteEntry(TeleportInfo data)
{
this.data = data;
}
/// <summary>
/// Gets the Aetheryte ID.
/// </summary>
public uint AetheryteId => this.data.AetheryteId;
/// <summary>
/// Gets the Territory ID.
/// </summary>
public uint TerritoryId => this.data.TerritoryId;
/// <summary>
/// Gets the SubIndex used when there can be multiple Aetherytes with the same ID (Private/Shared Estates etc.).
/// </summary>
public byte SubIndex => this.data.SubIndex;
/// <summary>
/// Gets the Ward. Zero if not a Shared Estate.
/// </summary>
public byte Ward => this.data.Ward;
/// <summary>
/// Gets the Plot. Zero if not a Shared Estate.
/// </summary>
public byte Plot => this.data.Plot;
/// <summary>
/// Gets the Cost in Gil to Teleport to this location.
/// </summary>
public uint GilCost => this.data.GilCost;
/// <summary>
/// Gets a value indicating whether the LocalPlayer has set this Aetheryte as Favorite or not.
/// </summary>
public bool IsFavourite => this.data.IsFavourite != 0;
/// <summary>
/// Gets a value indicating whether this Aetheryte is a Shared Estate or not.
/// </summary>
public bool IsSharedHouse => this.data.IsSharedHouse;
/// <summary>
/// Gets a value indicating whether this Aetheryte is an Appartment or not.
/// </summary>
public bool IsAppartment => this.data.IsAppartment;
/// <summary>
/// Gets the Aetheryte data related to this aetheryte.
/// </summary>
public ExcelResolver<Lumina.Excel.GeneratedSheets.Aetheryte> AetheryteData => new(this.AetheryteId);
this.data = data;
}
/// <summary>
/// Gets the Aetheryte ID.
/// </summary>
public uint AetheryteId => this.data.AetheryteId;
/// <summary>
/// Gets the Territory ID.
/// </summary>
public uint TerritoryId => this.data.TerritoryId;
/// <summary>
/// Gets the SubIndex used when there can be multiple Aetherytes with the same ID (Private/Shared Estates etc.).
/// </summary>
public byte SubIndex => this.data.SubIndex;
/// <summary>
/// Gets the Ward. Zero if not a Shared Estate.
/// </summary>
public byte Ward => this.data.Ward;
/// <summary>
/// Gets the Plot. Zero if not a Shared Estate.
/// </summary>
public byte Plot => this.data.Plot;
/// <summary>
/// Gets the Cost in Gil to Teleport to this location.
/// </summary>
public uint GilCost => this.data.GilCost;
/// <summary>
/// Gets a value indicating whether the LocalPlayer has set this Aetheryte as Favorite or not.
/// </summary>
public bool IsFavourite => this.data.IsFavourite != 0;
/// <summary>
/// Gets a value indicating whether this Aetheryte is a Shared Estate or not.
/// </summary>
public bool IsSharedHouse => this.data.IsSharedHouse;
/// <summary>
/// Gets a value indicating whether this Aetheryte is an Appartment or not.
/// </summary>
public bool IsAppartment => this.data.IsAppartment;
/// <summary>
/// Gets the Aetheryte data related to this aetheryte.
/// </summary>
public ExcelResolver<Lumina.Excel.GeneratedSheets.Aetheryte> AetheryteData => new(this.AetheryteId);
}

View file

@ -7,105 +7,104 @@ using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Serilog;
namespace Dalamud.Game.ClientState.Aetherytes
namespace Dalamud.Game.ClientState.Aetherytes;
/// <summary>
/// This collection represents the list of available Aetherytes in the Teleport window.
/// </summary>
[PluginInterface]
[InterfaceVersion("1.0")]
[ServiceManager.BlockingEarlyLoadedService]
public sealed partial class AetheryteList : IServiceType
{
/// <summary>
/// This collection represents the list of available Aetherytes in the Teleport window.
/// </summary>
[PluginInterface]
[InterfaceVersion("1.0")]
[ServiceManager.BlockingEarlyLoadedService]
public sealed partial class AetheryteList : IServiceType
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();
private readonly ClientStateAddressResolver address;
private readonly UpdateAetheryteListDelegate updateAetheryteListFunc;
[ServiceManager.ServiceConstructor]
private AetheryteList()
{
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();
private readonly ClientStateAddressResolver address;
private readonly UpdateAetheryteListDelegate updateAetheryteListFunc;
this.address = this.clientState.AddressResolver;
this.updateAetheryteListFunc = Marshal.GetDelegateForFunctionPointer<UpdateAetheryteListDelegate>(this.address.UpdateAetheryteList);
[ServiceManager.ServiceConstructor]
private AetheryteList()
Log.Verbose($"Teleport address 0x{this.address.Telepo.ToInt64():X}");
}
private delegate void UpdateAetheryteListDelegate(IntPtr telepo, byte arg1);
/// <summary>
/// Gets the amount of Aetherytes the local player has unlocked.
/// </summary>
public unsafe int Length
{
get
{
this.address = this.clientState.AddressResolver;
this.updateAetheryteListFunc = Marshal.GetDelegateForFunctionPointer<UpdateAetheryteListDelegate>(this.address.UpdateAetheryteList);
Log.Verbose($"Teleport address 0x{this.address.Telepo.ToInt64():X}");
}
private delegate void UpdateAetheryteListDelegate(IntPtr telepo, byte arg1);
/// <summary>
/// Gets the amount of Aetherytes the local player has unlocked.
/// </summary>
public unsafe int Length
{
get
{
if (this.clientState.LocalPlayer == null)
return 0;
this.Update();
if (TelepoStruct->TeleportList.First == TelepoStruct->TeleportList.Last)
return 0;
return (int)TelepoStruct->TeleportList.Size();
}
}
private unsafe FFXIVClientStructs.FFXIV.Client.Game.UI.Telepo* TelepoStruct => (FFXIVClientStructs.FFXIV.Client.Game.UI.Telepo*)this.address.Telepo;
/// <summary>
/// Gets a Aetheryte Entry at the specified index.
/// </summary>
/// <param name="index">Index.</param>
/// <returns>A <see cref="AetheryteEntry"/> at the specified index.</returns>
public unsafe AetheryteEntry? this[int index]
{
get
{
if (index < 0 || index >= this.Length)
{
return null;
}
if (this.clientState.LocalPlayer == null)
return null;
return new AetheryteEntry(TelepoStruct->TeleportList.Get((ulong)index));
}
}
private void Update()
{
// this is very very important as otherwise it crashes
if (this.clientState.LocalPlayer == null)
return;
return 0;
this.updateAetheryteListFunc(this.address.Telepo, 0);
this.Update();
if (TelepoStruct->TeleportList.First == TelepoStruct->TeleportList.Last)
return 0;
return (int)TelepoStruct->TeleportList.Size();
}
}
private unsafe FFXIVClientStructs.FFXIV.Client.Game.UI.Telepo* TelepoStruct => (FFXIVClientStructs.FFXIV.Client.Game.UI.Telepo*)this.address.Telepo;
/// <summary>
/// This collection represents the list of available Aetherytes in the Teleport window.
/// Gets a Aetheryte Entry at the specified index.
/// </summary>
public sealed partial class AetheryteList : IReadOnlyCollection<AetheryteEntry>
/// <param name="index">Index.</param>
/// <returns>A <see cref="AetheryteEntry"/> at the specified index.</returns>
public unsafe AetheryteEntry? this[int index]
{
/// <inheritdoc/>
public int Count => this.Length;
/// <inheritdoc/>
public IEnumerator<AetheryteEntry> GetEnumerator()
get
{
for (var i = 0; i < this.Length; i++)
if (index < 0 || index >= this.Length)
{
yield return this[i];
return null;
}
}
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
if (this.clientState.LocalPlayer == null)
return null;
return new AetheryteEntry(TelepoStruct->TeleportList.Get((ulong)index));
}
}
private void Update()
{
// this is very very important as otherwise it crashes
if (this.clientState.LocalPlayer == null)
return;
this.updateAetheryteListFunc(this.address.Telepo, 0);
}
}
/// <summary>
/// This collection represents the list of available Aetherytes in the Teleport window.
/// </summary>
public sealed partial class AetheryteList : IReadOnlyCollection<AetheryteEntry>
{
/// <inheritdoc/>
public int Count => this.Length;
/// <inheritdoc/>
public IEnumerator<AetheryteEntry> GetEnumerator()
{
for (var i = 0; i < this.Length; i++)
{
yield return this[i];
}
}
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}