diff --git a/Dalamud/Game/ClientState/Buddy/BuddyMember.cs b/Dalamud/Game/ClientState/Buddy/BuddyMember.cs
index 025de611d..393598d32 100644
--- a/Dalamud/Game/ClientState/Buddy/BuddyMember.cs
+++ b/Dalamud/Game/ClientState/Buddy/BuddyMember.cs
@@ -19,8 +19,14 @@ public interface IBuddyMember
///
/// Gets the object ID of this buddy.
///
+ [Obsolete("Renamed to EntityId")]
uint ObjectId { get; }
+ ///
+ /// Gets the entity ID of this buddy.
+ ///
+ uint EntityId { get; }
+
///
/// Gets the actor associated with this buddy.
///
@@ -83,6 +89,9 @@ internal unsafe class BuddyMember : IBuddyMember
///
public uint ObjectId => this.Struct->EntityId;
+ ///
+ public uint EntityId => this.Struct->EntityId;
+
///
public IGameObject? GameObject => this.objectTable.SearchById(this.ObjectId);
diff --git a/Dalamud/Game/ClientState/ClientState.cs b/Dalamud/Game/ClientState/ClientState.cs
index 407b54060..e92af21c3 100644
--- a/Dalamud/Game/ClientState/ClientState.cs
+++ b/Dalamud/Game/ClientState/ClientState.cs
@@ -15,8 +15,8 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Application.Network;
using FFXIVClientStructs.FFXIV.Client.Game;
-using FFXIVClientStructs.FFXIV.Client.Game.Event;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
+using FFXIVClientStructs.FFXIV.Client.Network;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
@@ -36,9 +36,9 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
private readonly GameLifecycle lifecycle;
private readonly ClientStateAddressResolver address;
- private readonly Hook setupTerritoryTypeHook;
+ private readonly Hook handleZoneInitPacketHook;
private readonly Hook uiModuleHandlePacketHook;
- private Hook onLogoutHook;
+ private readonly Hook setCurrentInstanceHook;
[ServiceManager.ServiceDependency]
private readonly Framework framework = Service.Get();
@@ -46,6 +46,12 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
[ServiceManager.ServiceDependency]
private readonly NetworkHandlers networkHandlers = Service.Get();
+ private Hook onLogoutHook;
+ private bool initialized;
+ private ushort territoryTypeId;
+ private bool isPvP;
+ private uint mapId;
+ private uint instance;
private bool lastConditionNone = true;
[ServiceManager.ServiceConstructor]
@@ -59,26 +65,37 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
this.ClientLanguage = (ClientLanguage)dalamud.StartInfo.Language;
- var setTerritoryTypeAddr = EventFramework.Addresses.SetTerritoryTypeId.Value;
- Log.Verbose($"SetupTerritoryType address {Util.DescribeAddress(setTerritoryTypeAddr)}");
-
- this.setupTerritoryTypeHook = Hook.FromAddress(setTerritoryTypeAddr, this.SetupTerritoryTypeDetour);
+ this.handleZoneInitPacketHook = Hook.FromAddress(this.AddressResolver.HandleZoneInitPacket, this.HandleZoneInitPacketDetour);
this.uiModuleHandlePacketHook = Hook.FromAddress((nint)UIModule.StaticVirtualTablePointer->HandlePacket, this.UIModuleHandlePacketDetour);
+ this.setCurrentInstanceHook = Hook.FromAddress(this.AddressResolver.SetCurrentInstance, this.SetCurrentInstanceDetour);
- this.framework.Update += this.FrameworkOnOnUpdateEvent;
this.networkHandlers.CfPop += this.NetworkHandlersOnCfPop;
- this.setupTerritoryTypeHook.Enable();
+ this.handleZoneInitPacketHook.Enable();
this.uiModuleHandlePacketHook.Enable();
+ this.setCurrentInstanceHook.Enable();
this.framework.RunOnTick(this.Setup);
}
private unsafe delegate void ProcessPacketPlayerSetupDelegate(nint a1, nint packet);
+ private unsafe delegate void HandleZoneInitPacketDelegate(nint a1, uint localPlayerEntityId, nint packet, byte type);
+
+ private unsafe delegate void SetCurrentInstanceDelegate(NetworkModuleProxy* thisPtr, short instanceId);
+
+ ///
+ public event Action ZoneInit;
+
///
public event Action? TerritoryChanged;
+ ///
+ public event Action? MapIdChanged;
+
+ ///
+ public event Action? InstanceChanged;
+
///
public event IClientState.ClassJobChangeDelegate? ClassJobChanged;
@@ -104,15 +121,65 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
public ClientLanguage ClientLanguage { get; }
///
- public ushort TerritoryType { get; private set; }
+ public ushort TerritoryType
+ {
+ get => this.territoryTypeId;
+ private set
+ {
+ if (this.territoryTypeId != value)
+ {
+ this.territoryTypeId = value;
+
+ if (this.initialized)
+ {
+ Log.Debug("TerritoryType changed: {0}", value);
+ this.TerritoryChanged?.InvokeSafely(value);
+ }
+
+ var rowRef = LuminaUtils.CreateRef(value);
+ if (rowRef.IsValid)
+ {
+ this.IsPvP = rowRef.Value.IsPvpZone;
+ }
+ }
+ }
+ }
///
- public unsafe uint MapId
+ public uint MapId
{
- get
+ get => this.mapId;
+ private set
{
- var agentMap = AgentMap.Instance();
- return agentMap != null ? agentMap->CurrentMapId : 0;
+ if (this.mapId != value)
+ {
+ this.mapId = value;
+
+ if (this.initialized)
+ {
+ Log.Debug("MapId changed: {0}", value);
+ this.MapIdChanged?.InvokeSafely(value);
+ }
+ }
+ }
+ }
+
+ ///
+ public uint Instance
+ {
+ get => this.instance;
+ private set
+ {
+ if (this.instance != value)
+ {
+ this.instance = value;
+
+ if (this.initialized)
+ {
+ Log.Debug("Instance changed: {0}", value);
+ this.InstanceChanged?.InvokeSafely(value);
+ }
+ }
}
}
@@ -133,7 +200,31 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
}
///
- public bool IsPvP { get; private set; }
+ public bool IsPvP
+ {
+ get => this.isPvP;
+ private set
+ {
+ if (this.isPvP != value)
+ {
+ this.isPvP = value;
+
+ if (this.initialized)
+ {
+ if (value)
+ {
+ Log.Debug("EnterPvP");
+ this.EnterPvP?.InvokeSafely();
+ }
+ else
+ {
+ Log.Debug("LeavePvP");
+ this.LeavePvP?.InvokeSafely();
+ }
+ }
+ }
+ }
+ }
///
public bool IsPvPExcludingDen => this.IsPvP && this.TerritoryType != 250;
@@ -172,11 +263,12 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
///
void IInternalDisposableService.DisposeService()
{
- this.setupTerritoryTypeHook.Dispose();
+ this.handleZoneInitPacketHook.Dispose();
this.uiModuleHandlePacketHook.Dispose();
this.onLogoutHook.Dispose();
+ this.setCurrentInstanceHook.Dispose();
- this.framework.Update -= this.FrameworkOnOnUpdateEvent;
+ this.framework.Update -= this.OnFrameworkUpdate;
this.networkHandlers.CfPop -= this.NetworkHandlersOnCfPop;
}
@@ -186,43 +278,28 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
this.onLogoutHook.Enable();
this.TerritoryType = (ushort)GameMain.Instance()->CurrentTerritoryTypeId;
+ this.MapId = AgentMap.Instance()->CurrentMapId;
+ this.Instance = UIState.Instance()->PublicInstance.InstanceId;
+
+ this.initialized = true;
+
+ this.framework.Update += this.OnFrameworkUpdate;
}
- private unsafe void SetupTerritoryTypeDetour(EventFramework* eventFramework, ushort territoryType)
+ private void HandleZoneInitPacketDetour(nint a1, uint localPlayerEntityId, nint packet, byte type)
{
- this.SetTerritoryType(territoryType);
- this.setupTerritoryTypeHook.Original(eventFramework, territoryType);
- }
+ this.handleZoneInitPacketHook.Original(a1, localPlayerEntityId, packet, type);
- private unsafe void SetTerritoryType(ushort territoryType)
- {
- if (this.TerritoryType == territoryType)
- return;
-
- Log.Debug("TerritoryType changed: {0}", territoryType);
-
- this.TerritoryType = territoryType;
- this.TerritoryChanged?.InvokeSafely(territoryType);
-
- var rowRef = LuminaUtils.CreateRef(territoryType);
- if (rowRef.IsValid)
+ try
{
- var isPvP = rowRef.Value.IsPvpZone;
- if (isPvP != this.IsPvP)
- {
- this.IsPvP = isPvP;
-
- if (this.IsPvP)
- {
- Log.Debug("EnterPvP");
- this.EnterPvP?.InvokeSafely();
- }
- else
- {
- Log.Debug("LeavePvP");
- this.LeavePvP?.InvokeSafely();
- }
- }
+ var eventArgs = ZoneInitEventArgs.Read(packet);
+ Log.Debug($"ZoneInit: {eventArgs}");
+ this.ZoneInit?.InvokeSafely(eventArgs);
+ this.TerritoryType = (ushort)eventArgs.TerritoryType.RowId;
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Exception during ZoneInit");
}
}
@@ -274,8 +351,16 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
}
}
- private void FrameworkOnOnUpdateEvent(IFramework framework1)
+ private unsafe void SetCurrentInstanceDetour(NetworkModuleProxy* thisPtr, short instanceId)
{
+ this.setCurrentInstanceHook.Original(thisPtr, instanceId);
+ this.Instance = (uint)instanceId;
+ }
+
+ private unsafe void OnFrameworkUpdate(IFramework framework)
+ {
+ this.MapId = AgentMap.Instance()->CurrentMapId;
+
var condition = Service.GetNullable();
var gameGui = Service.GetNullable();
var data = Service.GetNullable();
@@ -357,7 +442,10 @@ internal class ClientStatePluginScoped : IInternalDisposableService, IClientStat
///
internal ClientStatePluginScoped()
{
+ this.clientStateService.ZoneInit += this.ZoneInitForward;
this.clientStateService.TerritoryChanged += this.TerritoryChangedForward;
+ this.clientStateService.MapIdChanged += this.MapIdChangedForward;
+ this.clientStateService.InstanceChanged += this.InstanceChangedForward;
this.clientStateService.ClassJobChanged += this.ClassJobChangedForward;
this.clientStateService.LevelChanged += this.LevelChangedForward;
this.clientStateService.Login += this.LoginForward;
@@ -367,9 +455,18 @@ internal class ClientStatePluginScoped : IInternalDisposableService, IClientStat
this.clientStateService.CfPop += this.ContentFinderPopForward;
}
+ ///
+ public event Action ZoneInit;
+
///
public event Action? TerritoryChanged;
+ ///
+ public event Action? MapIdChanged;
+
+ ///
+ public event Action? InstanceChanged;
+
///
public event IClientState.ClassJobChangeDelegate? ClassJobChanged;
@@ -400,6 +497,9 @@ internal class ClientStatePluginScoped : IInternalDisposableService, IClientStat
///
public uint MapId => this.clientStateService.MapId;
+ ///
+ public uint Instance => this.clientStateService.Instance;
+
///
public IPlayerCharacter? LocalPlayer => this.clientStateService.LocalPlayer;
@@ -427,7 +527,10 @@ internal class ClientStatePluginScoped : IInternalDisposableService, IClientStat
///
void IInternalDisposableService.DisposeService()
{
+ this.clientStateService.ZoneInit -= this.ZoneInitForward;
this.clientStateService.TerritoryChanged -= this.TerritoryChangedForward;
+ this.clientStateService.MapIdChanged -= this.MapIdChangedForward;
+ this.clientStateService.InstanceChanged -= this.InstanceChangedForward;
this.clientStateService.ClassJobChanged -= this.ClassJobChangedForward;
this.clientStateService.LevelChanged -= this.LevelChangedForward;
this.clientStateService.Login -= this.LoginForward;
@@ -436,7 +539,12 @@ internal class ClientStatePluginScoped : IInternalDisposableService, IClientStat
this.clientStateService.LeavePvP -= this.ExitPvPForward;
this.clientStateService.CfPop -= this.ContentFinderPopForward;
+ this.ZoneInit = null;
this.TerritoryChanged = null;
+ this.MapIdChanged = null;
+ this.InstanceChanged = null;
+ this.ClassJobChanged = null;
+ this.LevelChanged = null;
this.Login = null;
this.Logout = null;
this.EnterPvP = null;
@@ -444,8 +552,14 @@ internal class ClientStatePluginScoped : IInternalDisposableService, IClientStat
this.CfPop = null;
}
+ private void ZoneInitForward(ZoneInitEventArgs eventArgs) => this.ZoneInit?.Invoke(eventArgs);
+
private void TerritoryChangedForward(ushort territoryId) => this.TerritoryChanged?.Invoke(territoryId);
+ private void MapIdChangedForward(uint mapId) => this.MapIdChanged?.Invoke(mapId);
+
+ private void InstanceChangedForward(uint instanceId) => this.InstanceChanged?.Invoke(instanceId);
+
private void ClassJobChangedForward(uint classJobId) => this.ClassJobChanged?.Invoke(classJobId);
private void LevelChangedForward(uint classJobId, uint level) => this.LevelChanged?.Invoke(classJobId, level);
diff --git a/Dalamud/Game/ClientState/ClientStateAddressResolver.cs b/Dalamud/Game/ClientState/ClientStateAddressResolver.cs
index 97bc5dae1..2fc859d09 100644
--- a/Dalamud/Game/ClientState/ClientStateAddressResolver.cs
+++ b/Dalamud/Game/ClientState/ClientStateAddressResolver.cs
@@ -10,19 +10,24 @@ internal sealed class ClientStateAddressResolver : BaseAddressResolver
///
/// Gets the address of the keyboard state.
///
- public IntPtr KeyboardState { get; private set; }
+ public nint KeyboardState { get; private set; }
///
/// Gets the address of the keyboard state index array which translates the VK enumeration to the key state.
///
- public IntPtr KeyboardStateIndexArray { get; private set; }
+ public nint KeyboardStateIndexArray { get; private set; }
// Functions
///
- /// Gets the address of the method which sets up the player.
+ /// Gets the address of the method that handles the ZoneInit packet.
///
- public IntPtr ProcessPacketPlayerSetup { get; private set; }
+ public nint HandleZoneInitPacket { get; private set; }
+
+ ///
+ /// Gets the address of the method that sets the current public instance.
+ ///
+ public nint SetCurrentInstance { get; private set; }
///
/// Scan for and setup any configured address pointers.
@@ -30,7 +35,8 @@ internal sealed class ClientStateAddressResolver : BaseAddressResolver
/// The signature scanner to facilitate setup.
protected override void Setup64Bit(ISigScanner sig)
{
- this.ProcessPacketPlayerSetup = sig.ScanText("40 53 48 83 EC 20 48 8D 0D ?? ?? ?? ?? 48 8B DA E8 ?? ?? ?? ?? 48 8B D3"); // not in cs struct
+ this.HandleZoneInitPacket = sig.ScanText("E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 44 0F B6 45");
+ this.SetCurrentInstance = sig.ScanText("E8 ?? ?? ?? ?? 0F B6 55 ?? 48 8D 0D ?? ?? ?? ?? C0 EA"); // NetworkModuleProxy.SetCurrentInstance
// These resolve to fixed offsets only, without the base address added in, so GetStaticAddressFromSig() can't be used.
// lea rcx, ds:1DB9F74h[rax*4] KeyboardState
diff --git a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs
index 4209100f0..829949c12 100644
--- a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs
+++ b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs
@@ -35,8 +35,14 @@ public interface IGameObject : IEquatable
///
/// Gets the data ID for linking to other respective game data.
///
+ [Obsolete("Renamed to BaseId")]
public uint DataId { get; }
+ ///
+ /// Gets the base ID for linking to other respective game data.
+ ///
+ public uint BaseId { get; }
+
///
/// Gets the ID of this GameObject's owner.
///
@@ -208,6 +214,9 @@ internal unsafe partial class GameObject : IGameObject
///
public uint DataId => this.Struct->BaseId;
+ ///
+ public uint BaseId => this.Struct->BaseId;
+
///
public uint OwnerId => this.Struct->OwnerId;
diff --git a/Dalamud/Game/ClientState/Party/PartyMember.cs b/Dalamud/Game/ClientState/Party/PartyMember.cs
index 65b752808..4c738d866 100644
--- a/Dalamud/Game/ClientState/Party/PartyMember.cs
+++ b/Dalamud/Game/ClientState/Party/PartyMember.cs
@@ -40,8 +40,14 @@ public interface IPartyMember
///
/// Gets the actor ID of this party member.
///
+ [Obsolete("Renamed to EntityId")]
uint ObjectId { get; }
+ ///
+ /// Gets the entity ID of this party member.
+ ///
+ uint EntityId { get; }
+
///
/// Gets the actor associated with this buddy.
///
@@ -115,87 +121,55 @@ internal unsafe class PartyMember : IPartyMember
this.Address = address;
}
- ///
- /// Gets the address of this party member in memory.
- ///
+ ///
public IntPtr Address { get; }
- ///
- /// Gets a list of buffs or debuffs applied to this party member.
- ///
+ ///
public StatusList Statuses => new(&this.Struct->StatusManager);
- ///
- /// Gets the position of the party member.
- ///
+ ///
public Vector3 Position => this.Struct->Position;
- ///
- /// Gets the content ID of the party member.
- ///
+ ///
public long ContentId => (long)this.Struct->ContentId;
- ///
- /// Gets the actor ID of this party member.
- ///
+ ///
public uint ObjectId => this.Struct->EntityId;
- ///
- /// Gets the actor associated with this buddy.
- ///
- ///
- /// This iterates the actor table, it should be used with care.
- ///
- public IGameObject? GameObject => Service.Get().SearchById(this.ObjectId);
+ ///
+ public uint EntityId => this.Struct->EntityId;
- ///
- /// Gets the current HP of this party member.
- ///
+ ///
+ public IGameObject? GameObject => Service.Get().SearchById(this.EntityId);
+
+ ///
public uint CurrentHP => this.Struct->CurrentHP;
- ///
- /// Gets the maximum HP of this party member.
- ///
+ ///
public uint MaxHP => this.Struct->MaxHP;
- ///
- /// Gets the current MP of this party member.
- ///
+ ///
public ushort CurrentMP => this.Struct->CurrentMP;
- ///
- /// Gets the maximum MP of this party member.
- ///
+ ///
public ushort MaxMP => this.Struct->MaxMP;
- ///
- /// Gets the territory this party member is located in.
- ///
+ ///
public RowRef Territory => LuminaUtils.CreateRef(this.Struct->TerritoryType);
- ///
- /// Gets the World this party member resides in.
- ///
+ ///
public RowRef World => LuminaUtils.CreateRef(this.Struct->HomeWorld);
- ///
- /// Gets the displayname of this party member.
- ///
+ ///
public SeString Name => SeString.Parse(this.Struct->Name);
- ///
- /// Gets the sex of this party member.
- ///
+ ///
public byte Sex => this.Struct->Sex;
- ///
- /// Gets the classjob of this party member.
- ///
+ ///
public RowRef ClassJob => LuminaUtils.CreateRef(this.Struct->ClassJob);
- ///
- /// Gets the level of this party member.
- ///
+ ///
public byte Level => this.Struct->Level;
private FFXIVClientStructs.FFXIV.Client.Game.Group.PartyMember* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Group.PartyMember*)this.Address;
diff --git a/Dalamud/Game/ClientState/ZoneInit.cs b/Dalamud/Game/ClientState/ZoneInit.cs
new file mode 100644
index 000000000..5c2213c90
--- /dev/null
+++ b/Dalamud/Game/ClientState/ZoneInit.cs
@@ -0,0 +1,90 @@
+using System.Linq;
+using System.Text;
+
+using Dalamud.Data;
+
+using Lumina.Excel.Sheets;
+
+namespace Dalamud.Game.ClientState;
+
+///
+/// Provides event data for when the game should initialize a zone.
+///
+public class ZoneInitEventArgs : EventArgs
+{
+ ///
+ /// Gets the territory type of the zone being entered.
+ ///
+ public TerritoryType TerritoryType { get; private set; }
+
+ ///
+ /// Gets the instance number of the zone, used when multiple copies of an area are active.
+ ///
+ public ushort Instance { get; private set; }
+
+ ///
+ /// Gets the associated content finder condition for the zone, if any.
+ ///
+ public ContentFinderCondition ContentFinderCondition { get; private set; }
+
+ ///
+ /// Gets the current weather in the zone upon entry.
+ ///
+ public Weather Weather { get; private set; }
+
+ ///
+ /// Gets the set of active festivals in the zone.
+ ///
+ public Festival[] ActiveFestivals { get; private set; } = [];
+
+ ///
+ /// Gets the phases corresponding to the active festivals.
+ ///
+ public ushort[] ActiveFestivalPhases { get; private set; } = [];
+
+ ///
+ /// Reads raw zone initialization data from a network packet and constructs the event arguments.
+ ///
+ /// A pointer to the raw packet data.
+ /// A populated from the packet.
+ public static unsafe ZoneInitEventArgs Read(nint packet)
+ {
+ var dataManager = Service.Get();
+ var eventArgs = new ZoneInitEventArgs();
+
+ var flags = *(byte*)(packet + 0x12);
+
+ eventArgs.TerritoryType = dataManager.GetExcelSheet().GetRow(*(ushort*)(packet + 0x02));
+ eventArgs.Instance = flags >= 0 ? (ushort)0 : *(ushort*)(packet + 0x04);
+ eventArgs.ContentFinderCondition = dataManager.GetExcelSheet().GetRow(*(ushort*)(packet + 0x06));
+ eventArgs.Weather = dataManager.GetExcelSheet().GetRow(*(byte*)(packet + 0x10));
+
+ const int NumFestivals = 4;
+ eventArgs.ActiveFestivals = new Festival[NumFestivals];
+ eventArgs.ActiveFestivalPhases = new ushort[NumFestivals];
+
+ // There are also 4 festival ids and phases for PlayerState at +0x3E and +0x46 respectively,
+ // but it's unclear why they exist as separate entries and why they would be different.
+ for (var i = 0; i < NumFestivals; i++)
+ {
+ eventArgs.ActiveFestivals[i] = dataManager.GetExcelSheet().GetRow(*(ushort*)(packet + 0x2E + (i * 2)));
+ eventArgs.ActiveFestivalPhases[i] = *(ushort*)(packet + 0x36 + (i * 2));
+ }
+
+ return eventArgs;
+ }
+
+ ///
+ public override string ToString()
+ {
+ var sb = new StringBuilder("ZoneInitEventArgs { ");
+ sb.Append($"TerritoryTypeId = {this.TerritoryType.RowId}, ");
+ sb.Append($"Instance = {this.Instance}, ");
+ sb.Append($"ContentFinderCondition = {this.ContentFinderCondition.RowId}, ");
+ sb.Append($"Weather = {this.Weather.RowId}, ");
+ sb.Append($"ActiveFestivals = [{string.Join(", ", this.ActiveFestivals.Select(f => f.RowId))}], ");
+ sb.Append($"ActiveFestivalPhases = [{string.Join(", ", this.ActiveFestivalPhases)}]");
+ sb.Append(" }");
+ return sb.ToString();
+ }
+}
diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/BuddyListWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/BuddyListWidget.cs
index 07ff2fdce..06dc1b11e 100644
--- a/Dalamud/Interface/Internal/Windows/Data/Widgets/BuddyListWidget.cs
+++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/BuddyListWidget.cs
@@ -40,7 +40,7 @@ internal class BuddyListWidget : IDataWindowWidget
}
else
{
- ImGui.Text($"[Companion] {member.Address.ToInt64():X} - {member.ObjectId} - {member.DataID}");
+ ImGui.Text($"[Companion] {member.Address.ToInt64():X} - {member.EntityId} - {member.DataID}");
if (this.resolveGameData)
{
var gameObject = member.GameObject;
@@ -64,7 +64,7 @@ internal class BuddyListWidget : IDataWindowWidget
}
else
{
- ImGui.Text($"[Pet] {member.Address.ToInt64():X} - {member.ObjectId} - {member.DataID}");
+ ImGui.Text($"[Pet] {member.Address.ToInt64():X} - {member.EntityId} - {member.DataID}");
if (this.resolveGameData)
{
var gameObject = member.GameObject;
@@ -91,7 +91,7 @@ internal class BuddyListWidget : IDataWindowWidget
for (var i = 0; i < count; i++)
{
var member = buddyList[i];
- ImGui.Text($"[BattleBuddy] [{i}] {member?.Address.ToInt64():X} - {member?.ObjectId} - {member?.DataID}");
+ ImGui.Text($"[BattleBuddy] [{i}] {member?.Address.ToInt64():X} - {member?.EntityId} - {member?.DataID}");
if (this.resolveGameData)
{
var gameObject = member?.GameObject;
diff --git a/Dalamud/Interface/Internal/Windows/Settings/SettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/SettingsEntry.cs
index 4cb239da3..3f53be07a 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/SettingsEntry.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/SettingsEntry.cs
@@ -1,14 +1,16 @@
-namespace Dalamud.Interface.Internal.Windows.Settings;
+using Dalamud.Utility.Internal;
+
+namespace Dalamud.Interface.Internal.Windows.Settings;
///
/// Basic, drawable settings entry.
///
-public abstract class SettingsEntry
+internal abstract class SettingsEntry
{
///
/// Gets or sets the public, searchable name of this settings entry.
///
- public string? Name { get; protected set; }
+ public LazyLoc Name { get; protected set; }
///
/// Gets or sets a value indicating whether this entry is valid.
diff --git a/Dalamud/Interface/Internal/Windows/Settings/SettingsTab.cs b/Dalamud/Interface/Internal/Windows/Settings/SettingsTab.cs
index bd4a702f5..e43e3c83a 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/SettingsTab.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/SettingsTab.cs
@@ -1,19 +1,19 @@
-using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.CodeAnalysis;
using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public abstract class SettingsTab : IDisposable
+internal abstract class SettingsTab : IDisposable
{
public abstract SettingsEntry[] Entries { get; }
public abstract string Title { get; }
- public bool IsOpen { get; set; } = false;
+ public abstract SettingsOpenKind Kind { get; }
- public virtual bool IsVisible { get; } = true;
+ public bool IsOpen { get; set; } = false;
public virtual void OnOpen()
{
diff --git a/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs
index 75cbeb836..581ef3746 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs
@@ -17,20 +17,19 @@ namespace Dalamud.Interface.Internal.Windows.Settings;
///
/// The window that allows for general configuration of Dalamud itself.
///
-internal class SettingsWindow : Window
+internal sealed class SettingsWindow : Window
{
private readonly SettingsTab[] tabs;
-
private string searchInput = string.Empty;
private bool isSearchInputPrefilled = false;
- private SettingsTab setActiveTab = null!;
+ private SettingsTab? setActiveTab;
///
/// Initializes a new instance of the class.
///
public SettingsWindow()
- : base(Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings2", ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar)
+ : base(Title, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar)
{
this.Size = new Vector2(740, 550);
this.SizeConstraints = new WindowSizeConstraints()
@@ -52,6 +51,10 @@ internal class SettingsWindow : Window
];
}
+ private static string Title => Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings2";
+
+ private SettingsTab? CurrentlyOpenTab => this.tabs.FirstOrDefault(tab => tab.IsOpen);
+
///
/// Open the settings window to the tab specified by .
///
@@ -59,7 +62,7 @@ internal class SettingsWindow : Window
public void OpenTo(SettingsOpenKind kind)
{
this.IsOpen = true;
- this.SetOpenTab(kind);
+ this.setActiveTab = this.tabs.Single(tab => tab.Kind == kind);
}
///
@@ -83,12 +86,19 @@ internal class SettingsWindow : Window
///
public override void OnOpen()
{
+ var localization = Service.Get();
+
foreach (var settingsTab in this.tabs)
{
settingsTab.Load();
}
- if (!this.isSearchInputPrefilled) this.searchInput = string.Empty;
+ if (!this.isSearchInputPrefilled)
+ {
+ this.searchInput = string.Empty;
+ }
+
+ localization.LocalizationChanged += this.OnLocalizationChanged;
base.OnOpen();
}
@@ -99,6 +109,7 @@ internal class SettingsWindow : Window
var configuration = Service.Get();
var interfaceManager = Service.Get();
var fontAtlasFactory = Service.Get();
+ var localization = Service.Get();
var scaleChanged = !Equals(ImGui.GetIO().FontGlobalScale, configuration.GlobalUiScale);
var rebuildFont = !Equals(fontAtlasFactory.DefaultFontSpec, configuration.DefaultFontSpec);
@@ -107,7 +118,7 @@ internal class SettingsWindow : Window
ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale;
if (scaleChanged)
{
- Service.Get().InvokeGlobalScaleChanged();
+ interfaceManager.InvokeGlobalScaleChanged();
}
fontAtlasFactory.DefaultFontSpecOverride = null;
@@ -115,7 +126,7 @@ internal class SettingsWindow : Window
if (rebuildFont)
{
interfaceManager.RebuildFonts();
- Service.Get().InvokeFontChanged();
+ interfaceManager.InvokeFontChanged();
}
foreach (var settingsTab in this.tabs)
@@ -133,98 +144,29 @@ internal class SettingsWindow : Window
this.isSearchInputPrefilled = false;
this.searchInput = string.Empty;
}
+
+ localization.LocalizationChanged -= this.OnLocalizationChanged;
}
///
public override void Draw()
{
+ ImGui.SetNextItemWidth(-1);
+ using (ImRaii.Disabled(this.CurrentlyOpenTab is SettingsTabAbout))
+ ImGui.InputTextWithHint("###searchInput"u8, Loc.Localize("DalamudSettingsSearchPlaceholder", "Search for settings..."), ref this.searchInput, 100, ImGuiInputTextFlags.AutoSelectAll);
+ ImGui.Spacing();
+
var windowSize = ImGui.GetWindowSize();
- if (ImGui.BeginTabBar("###settingsTabs"u8))
+ using (var tabBar = ImRaii.TabBar("###settingsTabs"u8))
{
- if (string.IsNullOrEmpty(this.searchInput))
+ if (tabBar)
{
- foreach (var settingsTab in this.tabs.Where(x => x.IsVisible))
- {
- var flags = ImGuiTabItemFlags.NoCloseWithMiddleMouseButton;
- if (this.setActiveTab == settingsTab)
- {
- flags |= ImGuiTabItemFlags.SetSelected;
- this.setActiveTab = null;
- }
-
- using var tab = ImRaii.TabItem(settingsTab.Title, flags);
- if (tab)
- {
- if (!settingsTab.IsOpen)
- {
- settingsTab.IsOpen = true;
- settingsTab.OnOpen();
- }
-
- // Don't add padding for the about tab(credits)
- {
- using var padding = ImRaii.PushStyle(
- ImGuiStyleVar.WindowPadding,
- new Vector2(2, 2),
- settingsTab is not SettingsTabAbout);
- using var borderColor = ImRaii.PushColor(
- ImGuiCol.Border,
- ImGui.GetColorU32(ImGuiCol.ChildBg));
- using var tabChild = ImRaii.Child(
- $"###settings_scrolling_{settingsTab.Title}",
- new Vector2(-1, -1),
- true);
- if (tabChild)
- settingsTab.Draw();
- }
-
- settingsTab.PostDraw();
- }
- else if (settingsTab.IsOpen)
- {
- settingsTab.IsOpen = false;
- settingsTab.OnClose();
- }
- }
+ if (string.IsNullOrEmpty(this.searchInput))
+ this.DrawTabs();
+ else
+ this.DrawSearchResults();
}
- else
- {
- if (ImGui.BeginTabItem("Search Results"u8))
- {
- var any = false;
-
- foreach (var settingsTab in this.tabs.Where(x => x.IsVisible))
- {
- var eligible = settingsTab.Entries.Where(x => !x.Name.IsNullOrEmpty() && x.Name.ToLowerInvariant().Contains(this.searchInput.ToLowerInvariant())).ToArray();
-
- if (!eligible.Any())
- continue;
-
- any = true;
-
- ImGui.TextColored(ImGuiColors.DalamudGrey, settingsTab.Title);
- ImGui.Dummy(new Vector2(5));
-
- foreach (var settingsTabEntry in eligible)
- {
- settingsTabEntry.Draw();
- ImGuiHelpers.ScaledDummy(3);
- }
-
- ImGui.Separator();
-
- ImGui.Dummy(new Vector2(10));
- }
-
- if (!any)
- ImGui.TextColored(ImGuiColors.DalamudGrey, "No results found..."u8);
-
- ImGui.EndTabItem();
- }
- }
-
- ImGui.EndTabBar();
}
ImGui.SetCursorPos(windowSize - ImGuiHelpers.ScaledVector2(70));
@@ -256,10 +198,88 @@ internal class SettingsWindow : Window
}
}
}
+ }
- ImGui.SetCursorPos(new Vector2(windowSize.X - 250, ImGui.GetTextLineHeightWithSpacing() + (ImGui.GetStyle().FramePadding.Y * 2)));
- ImGui.SetNextItemWidth(240);
- ImGui.InputTextWithHint("###searchInput"u8, "Search for settings..."u8, ref this.searchInput, 100);
+ private void DrawTabs()
+ {
+ foreach (var settingsTab in this.tabs)
+ {
+ var flags = ImGuiTabItemFlags.NoCloseWithMiddleMouseButton;
+
+ if (this.setActiveTab == settingsTab)
+ {
+ flags |= ImGuiTabItemFlags.SetSelected;
+ this.setActiveTab = null;
+ }
+
+ using var tab = ImRaii.TabItem(settingsTab.Title, flags);
+ if (tab)
+ {
+ if (!settingsTab.IsOpen)
+ {
+ settingsTab.IsOpen = true;
+ settingsTab.OnOpen();
+ }
+
+ // Don't add padding for the About tab (credits)
+ {
+ using var padding = ImRaii.PushStyle(
+ ImGuiStyleVar.WindowPadding,
+ new Vector2(2, 2),
+ settingsTab is not SettingsTabAbout);
+ using var borderColor = ImRaii.PushColor(
+ ImGuiCol.Border,
+ ImGui.GetColorU32(ImGuiCol.ChildBg));
+ using var tabChild = ImRaii.Child(
+ $"###settings_scrolling_{settingsTab.Title}",
+ new Vector2(-1, -1),
+ true);
+ if (tabChild)
+ settingsTab.Draw();
+ }
+
+ settingsTab.PostDraw();
+ }
+ else if (settingsTab.IsOpen)
+ {
+ settingsTab.IsOpen = false;
+ settingsTab.OnClose();
+ }
+ }
+ }
+
+ private void DrawSearchResults()
+ {
+ using var tab = ImRaii.TabItem(Loc.Localize("DalamudSettingsSearchResults", "Search Results"));
+ if (!tab) return;
+
+ var any = false;
+
+ foreach (var settingsTab in this.tabs)
+ {
+ var eligible = settingsTab.Entries.Where(x => !x.Name.Key.IsNullOrEmpty() && x.Name.ToString().Contains(this.searchInput, StringComparison.InvariantCultureIgnoreCase));
+
+ if (!eligible.Any())
+ continue;
+
+ any |= true;
+
+ ImGui.TextColored(ImGuiColors.DalamudGrey, settingsTab.Title);
+ ImGui.Dummy(new Vector2(5));
+
+ foreach (var settingsTabEntry in eligible)
+ {
+ settingsTabEntry.Draw();
+ ImGuiHelpers.ScaledDummy(3);
+ }
+
+ ImGui.Separator();
+
+ ImGui.Dummy(new Vector2(10));
+ }
+
+ if (!any)
+ ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsNoSearchResultsFound", "No results found..."));
}
private void Save()
@@ -301,17 +321,9 @@ internal class SettingsWindow : Window
Service.Get().RebuildFonts();
}
- private void SetOpenTab(SettingsOpenKind kind)
+ private void OnLocalizationChanged(string langCode)
{
- this.setActiveTab = kind switch
- {
- SettingsOpenKind.General => this.tabs[0],
- SettingsOpenKind.LookAndFeel => this.tabs[1],
- SettingsOpenKind.AutoUpdates => this.tabs[2],
- SettingsOpenKind.ServerInfoBar => this.tabs[3],
- SettingsOpenKind.Experimental => this.tabs[4],
- SettingsOpenKind.About => this.tabs[5],
- _ => throw new ArgumentOutOfRangeException(nameof(kind), kind, null),
- };
+ this.WindowName = Title;
+ this.setActiveTab = this.CurrentlyOpenTab;
}
}
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs
index 5b7fc7227..74b9b0fd7 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs
@@ -20,7 +20,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.UI;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class SettingsTabAbout : SettingsTab
+internal sealed class SettingsTabAbout : SettingsTab
{
private const float CreditFps = 60.0f;
private const string ThankYouText = "Thank you!";
@@ -209,10 +209,12 @@ Contribute at: https://github.com/goatcorp/Dalamud
.CreateFontAtlas(nameof(SettingsTabAbout), FontAtlasAutoRebuildMode.Async);
}
- public override SettingsEntry[] Entries { get; } = { };
-
public override string Title => Loc.Localize("DalamudAbout", "About");
+ public override SettingsOpenKind Kind => SettingsOpenKind.About;
+
+ public override SettingsEntry[] Entries { get; } = [];
+
///
public override unsafe void OnOpen()
{
@@ -287,7 +289,7 @@ Contribute at: https://github.com/goatcorp/Dalamud
var windowX = ImGui.GetWindowSize().X;
- foreach (var creditsLine in this.creditsText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
+ foreach (var creditsLine in this.creditsText.Split(["\r\n", "\r", "\n"], StringSplitOptions.None))
{
var lineLenX = ImGui.CalcTextSize(creditsLine).X;
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAutoUpdate.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAutoUpdate.cs
index b25cdb10b..6b99c5c24 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAutoUpdate.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAutoUpdate.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
@@ -18,7 +18,7 @@ using Dalamud.Plugin.Internal.Types;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class SettingsTabAutoUpdates : SettingsTab
+internal sealed class SettingsTabAutoUpdates : SettingsTab
{
private AutoUpdateBehavior behavior;
private bool updateDisabledPlugins;
@@ -31,6 +31,8 @@ public class SettingsTabAutoUpdates : SettingsTab
public override string Title => Loc.Localize("DalamudSettingsAutoUpdates", "Auto-Updates");
+ public override SettingsOpenKind Kind => SettingsOpenKind.AutoUpdates;
+
public override void Draw()
{
ImGui.TextColoredWrapped(ImGuiColors.DalamudWhite, Loc.Localize("DalamudSettingsAutoUpdateHint",
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs
index 7cd303587..4b055b35b 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs
@@ -14,17 +14,19 @@ using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class SettingsTabDtr : SettingsTab
+internal sealed class SettingsTabDtr : SettingsTab
{
private List? dtrOrder;
private List? dtrIgnore;
private int dtrSpacing;
private bool dtrSwapDirection;
- public override SettingsEntry[] Entries { get; } = Array.Empty();
-
public override string Title => Loc.Localize("DalamudSettingsServerInfoBar", "Server Info Bar");
+ public override SettingsOpenKind Kind => SettingsOpenKind.ServerInfoBar;
+
+ public override SettingsEntry[] Entries { get; } = [];
+
public override void Draw()
{
ImGui.TextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingServerInfoBarHint", "Plugins can put additional information into your server information bar(where world & time can be seen).\nYou can reorder and disable these here."));
@@ -125,8 +127,8 @@ public class SettingsTabDtr : SettingsTab
ImGui.GetIO().MousePos = moveMouseTo[moveMouseToIndex];
}
- configuration.DtrOrder = order.Concat(orderLeft).ToList();
- configuration.DtrIgnore = ignore.Concat(ignoreLeft).ToList();
+ configuration.DtrOrder = [.. order, .. orderLeft];
+ configuration.DtrIgnore = [.. ignore, .. ignoreLeft];
if (isOrderChange)
dtrBar.ApplySort();
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabExperimental.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabExperimental.cs
index d3b741142..4ba5bed94 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabExperimental.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabExperimental.cs
@@ -6,11 +6,11 @@ using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Internal.ReShadeHandling;
-using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
using Dalamud.Interface.Utility;
using Dalamud.Plugin.Internal;
using Dalamud.Utility;
+using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
@@ -18,33 +18,28 @@ namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
"StyleCop.CSharp.DocumentationRules",
"SA1600:Elements should be documented",
Justification = "Internals")]
-public class SettingsTabExperimental : SettingsTab
+internal sealed class SettingsTabExperimental : SettingsTab
{
+ public override string Title => Loc.Localize("DalamudSettingsExperimental", "Experimental");
+
+ public override SettingsOpenKind Kind => SettingsOpenKind.Experimental;
+
public override SettingsEntry[] Entries { get; } =
[
new SettingsEntry(
- Loc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"),
- string.Format(
- Loc.Localize(
- "DalamudSettingsPluginTestHint",
- "Receive testing prereleases for selected plugins.\nTo opt-in to testing builds for a plugin, you have to right click it in the \"{0}\" tab of the plugin installer and select \"{1}\"."),
- PluginCategoryManager.Locs.Group_Installed,
- PluginInstallerWindow.Locs.PluginContext_TestingOptIn),
+ LazyLoc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"),
+ LazyLoc.Localize("DalamudSettingsPluginTestHint", "Receive testing prereleases for selected plugins.\nTo opt-in to testing builds for a plugin, you have to right click it in the \"Installed Plugins\" tab of the plugin installer and select \"Receive plugin testing versions\"."),
c => c.DoPluginTest,
(v, c) => c.DoPluginTest = v),
new HintSettingsEntry(
- Loc.Localize(
- "DalamudSettingsPluginTestWarning",
- "Testing plugins may contain bugs or crash your game. Please only enable this if you are aware of the risks."),
+ LazyLoc.Localize("DalamudSettingsPluginTestWarning", "Testing plugins may contain bugs or crash your game. Please only enable this if you are aware of the risks."),
ImGuiColors.DalamudRed),
new GapSettingsEntry(5),
new ButtonSettingsEntry(
- Loc.Localize("DalamudSettingsClearHidden", "Clear hidden plugins"),
- Loc.Localize(
- "DalamudSettingsClearHiddenHint",
- "Restore plugins you have previously hidden from the plugin installer."),
+ LazyLoc.Localize("DalamudSettingsClearHidden", "Clear hidden plugins"),
+ LazyLoc.Localize("DalamudSettingsClearHiddenHint", "Restore plugins you have previously hidden from the plugin installer."),
() =>
{
Service.Get().HiddenPluginInternalName.Clear();
@@ -56,23 +51,16 @@ public class SettingsTabExperimental : SettingsTab
new DevPluginsSettingsEntry(),
new SettingsEntry(
- Loc.Localize(
- "DalamudSettingEnableImGuiAsserts",
- "Enable ImGui asserts"),
- Loc.Localize(
- "DalamudSettingEnableImGuiAssertsHint",
+ LazyLoc.Localize("DalamudSettingEnableImGuiAsserts", "Enable ImGui asserts"),
+ LazyLoc.Localize("DalamudSettingEnableImGuiAssertsHint",
"If this setting is enabled, a window containing further details will be shown when an internal assertion in ImGui fails.\nWe recommend enabling this when developing plugins. " +
"This setting does not persist and will reset when the game restarts.\nUse the setting below to enable it at startup."),
c => Service.Get().ShowAsserts,
(v, _) => Service.Get().ShowAsserts = v),
new SettingsEntry(
- Loc.Localize(
- "DalamudSettingEnableImGuiAssertsAtStartup",
- "Always enable ImGui asserts at startup"),
- Loc.Localize(
- "DalamudSettingEnableImGuiAssertsAtStartupHint",
- "This will enable ImGui asserts every time the game starts."),
+ LazyLoc.Localize("DalamudSettingEnableImGuiAssertsAtStartup", "Always enable ImGui asserts at startup"),
+ LazyLoc.Localize("DalamudSettingEnableImGuiAssertsAtStartupHint", "This will enable ImGui asserts every time the game starts."),
c => c.ImGuiAssertsEnabledAtStartup ?? false,
(v, c) => c.ImGuiAssertsEnabledAtStartup = v),
@@ -83,10 +71,8 @@ public class SettingsTabExperimental : SettingsTab
new GapSettingsEntry(5, true),
new EnumSettingsEntry(
- Loc.Localize("DalamudSettingsReShadeHandlingMode", "ReShade handling mode"),
- Loc.Localize(
- "DalamudSettingsReShadeHandlingModeHint",
- "You may try different options to work around problems you may encounter.\nRestart is required for changes to take effect."),
+ LazyLoc.Localize("DalamudSettingsReShadeHandlingMode", "ReShade handling mode"),
+ LazyLoc.Localize("DalamudSettingsReShadeHandlingModeHint", "You may try different options to work around problems you may encounter.\nRestart is required for changes to take effect."),
c => c.ReShadeHandlingMode,
(v, c) => c.ReShadeHandlingMode = v,
fallbackValue: ReShadeHandlingMode.Default,
@@ -146,8 +132,6 @@ public class SettingsTabExperimental : SettingsTab
*/
];
- public override string Title => Loc.Localize("DalamudSettingsExperimental", "Experimental");
-
public override void Draw()
{
base.Draw();
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabGeneral.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabGeneral.cs
index 5e3648ac6..0daa52630 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabGeneral.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabGeneral.cs
@@ -1,23 +1,29 @@
-using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.CodeAnalysis;
using CheapLoc;
+
using Dalamud.Game.Text;
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
+using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class SettingsTabGeneral : SettingsTab
+internal sealed class SettingsTabGeneral : SettingsTab
{
+ public override string Title => Loc.Localize("DalamudSettingsGeneral", "General");
+
+ public override SettingsOpenKind Kind => SettingsOpenKind.General;
+
public override SettingsEntry[] Entries { get; } =
- {
+ [
new LanguageChooserSettingsEntry(),
new GapSettingsEntry(5),
new EnumSettingsEntry(
- Loc.Localize("DalamudSettingsChannel", "Dalamud Chat Channel"),
- Loc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."),
+ LazyLoc.Localize("DalamudSettingsChannel", "Dalamud Chat Channel"),
+ LazyLoc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."),
c => c.GeneralChatType,
(v, c) => c.GeneralChatType = v,
warning: v =>
@@ -33,49 +39,47 @@ public class SettingsTabGeneral : SettingsTab
new GapSettingsEntry(5),
new SettingsEntry(
- Loc.Localize("DalamudSettingsWaitForPluginsOnStartup", "Wait for plugins before game loads"),
- Loc.Localize("DalamudSettingsWaitForPluginsOnStartupHint", "Do not let the game load, until plugins are loaded."),
+ LazyLoc.Localize("DalamudSettingsWaitForPluginsOnStartup", "Wait for plugins before game loads"),
+ LazyLoc.Localize("DalamudSettingsWaitForPluginsOnStartupHint", "Do not let the game load, until plugins are loaded."),
c => c.IsResumeGameAfterPluginLoad,
(v, c) => c.IsResumeGameAfterPluginLoad = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingsFlash", "Flash FFXIV window on duty pop"),
- Loc.Localize("DalamudSettingsFlashHint", "Flash the FFXIV window in your task bar when a duty is ready."),
+ LazyLoc.Localize("DalamudSettingsFlash", "Flash FFXIV window on duty pop"),
+ LazyLoc.Localize("DalamudSettingsFlashHint", "Flash the FFXIV window in your task bar when a duty is ready."),
c => c.DutyFinderTaskbarFlash,
(v, c) => c.DutyFinderTaskbarFlash = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingsDutyFinderMessage", "Chatlog message on duty pop"),
- Loc.Localize("DalamudSettingsDutyFinderMessageHint", "Send a message in FFXIV chat when a duty is ready."),
+ LazyLoc.Localize("DalamudSettingsDutyFinderMessage", "Chatlog message on duty pop"),
+ LazyLoc.Localize("DalamudSettingsDutyFinderMessageHint", "Send a message in FFXIV chat when a duty is ready."),
c => c.DutyFinderChatMessage,
(v, c) => c.DutyFinderChatMessage = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingsPrintDalamudWelcomeMsg", "Display Dalamud's welcome message"),
- Loc.Localize("DalamudSettingsPrintDalamudWelcomeMsgHint", "Display Dalamud's welcome message in FFXIV chat when logging in with a character."),
+ LazyLoc.Localize("DalamudSettingsPrintDalamudWelcomeMsg", "Display Dalamud's welcome message"),
+ LazyLoc.Localize("DalamudSettingsPrintDalamudWelcomeMsgHint", "Display Dalamud's welcome message in FFXIV chat when logging in with a character."),
c => c.PrintDalamudWelcomeMsg,
(v, c) => c.PrintDalamudWelcomeMsg = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsg", "Display loaded plugins in the welcome message"),
- Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsgHint", "Display loaded plugins in FFXIV chat when logging in with a character."),
+ LazyLoc.Localize("DalamudSettingsPrintPluginsWelcomeMsg", "Display loaded plugins in the welcome message"),
+ LazyLoc.Localize("DalamudSettingsPrintPluginsWelcomeMsgHint", "Display loaded plugins in FFXIV chat when logging in with a character."),
c => c.PrintPluginsWelcomeMsg,
(v, c) => c.PrintPluginsWelcomeMsg = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingsSystemMenu", "Dalamud buttons in system menu"),
- Loc.Localize("DalamudSettingsSystemMenuMsgHint", "Add buttons for Dalamud plugins and settings to the system menu."),
+ LazyLoc.Localize("DalamudSettingsSystemMenu", "Dalamud buttons in system menu"),
+ LazyLoc.Localize("DalamudSettingsSystemMenuMsgHint", "Add buttons for Dalamud plugins and settings to the system menu."),
c => c.DoButtonsSystemMenu,
(v, c) => c.DoButtonsSystemMenu = v),
new GapSettingsEntry(5),
new SettingsEntry(
- Loc.Localize("DalamudSettingDoMbCollect", "Anonymously upload market board data"),
- Loc.Localize("DalamudSettingDoMbCollectHint", "Anonymously provide data about in-game economics to Universalis when browsing the market board. This data can't be tied to you in any way and everyone benefits!"),
+ LazyLoc.Localize("DalamudSettingDoMbCollect", "Anonymously upload market board data"),
+ LazyLoc.Localize("DalamudSettingDoMbCollectHint", "Anonymously provide data about in-game economics to Universalis when browsing the market board. This data can't be tied to you in any way and everyone benefits!"),
c => c.IsMbCollect,
(v, c) => c.IsMbCollect = v),
- };
-
- public override string Title => Loc.Localize("DalamudSettingsGeneral", "General");
+ ];
}
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
index b6aa11db4..9b2c418b6 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
@@ -7,54 +7,58 @@ using CheapLoc;
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Game;
-using Dalamud.Game.Text;
using Dalamud.Interface.Colors;
using Dalamud.Interface.FontIdentifier;
using Dalamud.Interface.GameFonts;
using Dalamud.Interface.ImGuiFontChooserDialog;
using Dalamud.Interface.ImGuiNotification.Internal;
-using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
using Dalamud.Interface.ManagedFontAtlas.Internals;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
+using Dalamud.Utility.Internal;
+
using Serilog;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class SettingsTabLook : SettingsTab
+internal sealed class SettingsTabLook : SettingsTab
{
private static readonly (string, float)[] GlobalUiScalePresets =
- {
+ [
("80%##DalamudSettingsGlobalUiScaleReset96", 0.8f),
("100%##DalamudSettingsGlobalUiScaleReset12", 1f),
("117%##DalamudSettingsGlobalUiScaleReset14", 14 / 12f),
("150%##DalamudSettingsGlobalUiScaleReset18", 1.5f),
("200%##DalamudSettingsGlobalUiScaleReset24", 2f),
("300%##DalamudSettingsGlobalUiScaleReset36", 3f),
- };
+ ];
private float globalUiScale;
private IFontSpec defaultFontSpec = null!;
+ public override string Title => Loc.Localize("DalamudSettingsVisual", "Look & Feel");
+
+ public override SettingsOpenKind Kind => SettingsOpenKind.LookAndFeel;
+
public override SettingsEntry[] Entries { get; } =
[
new GapSettingsEntry(5, true),
new ButtonSettingsEntry(
- Loc.Localize("DalamudSettingsOpenStyleEditor", "Open Style Editor"),
- Loc.Localize("DalamudSettingsStyleEditorHint", "Modify the look & feel of Dalamud windows."),
+ LazyLoc.Localize("DalamudSettingsOpenStyleEditor", "Open Style Editor"),
+ LazyLoc.Localize("DalamudSettingsStyleEditorHint", "Modify the look & feel of Dalamud windows."),
() => Service.Get().OpenStyleEditor()),
new ButtonSettingsEntry(
- Loc.Localize("DalamudSettingsOpenNotificationEditor", "Modify Notification Position"),
- Loc.Localize("DalamudSettingsNotificationEditorHint", "Choose where Dalamud notifications appear on the screen."),
+ LazyLoc.Localize("DalamudSettingsOpenNotificationEditor", "Modify Notification Position"),
+ LazyLoc.Localize("DalamudSettingsNotificationEditorHint", "Choose where Dalamud notifications appear on the screen."),
() => Service.Get().StartPositionChooser()),
new SettingsEntry(
- Loc.Localize("DalamudSettingsUseDarkMode", "Use Windows immersive/dark mode"),
- Loc.Localize("DalamudSettingsUseDarkModeHint", "This will cause the FFXIV window title bar to follow your preferred Windows color settings, and switch to dark mode if enabled."),
+ LazyLoc.Localize("DalamudSettingsUseDarkMode", "Use Windows immersive/dark mode"),
+ LazyLoc.Localize("DalamudSettingsUseDarkModeHint", "This will cause the FFXIV window title bar to follow your preferred Windows color settings, and switch to dark mode if enabled."),
c => c.WindowIsImmersive,
(v, c) => c.WindowIsImmersive = v,
b =>
@@ -72,91 +76,87 @@ public class SettingsTabLook : SettingsTab
new GapSettingsEntry(5, true),
- new HintSettingsEntry(Loc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below.")),
+ new HintSettingsEntry(LazyLoc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below.")),
new GapSettingsEntry(3),
new SettingsEntry(
- Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"),
- Loc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay."),
+ LazyLoc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"),
+ LazyLoc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay."),
c => c.ToggleUiHide,
(v, c) => c.ToggleUiHide = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingToggleUiHideDuringCutscenes", "Hide plugin UI during cutscenes"),
- Loc.Localize("DalamudSettingToggleUiHideDuringCutscenesHint", "Hide any open windows by plugins during cutscenes."),
+ LazyLoc.Localize("DalamudSettingToggleUiHideDuringCutscenes", "Hide plugin UI during cutscenes"),
+ LazyLoc.Localize("DalamudSettingToggleUiHideDuringCutscenesHint", "Hide any open windows by plugins during cutscenes."),
c => c.ToggleUiHideDuringCutscenes,
(v, c) => c.ToggleUiHideDuringCutscenes = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingToggleUiHideDuringGpose", "Hide plugin UI while gpose is active"),
- Loc.Localize("DalamudSettingToggleUiHideDuringGposeHint", "Hide any open windows by plugins while gpose is active."),
+ LazyLoc.Localize("DalamudSettingToggleUiHideDuringGpose", "Hide plugin UI while gpose is active"),
+ LazyLoc.Localize("DalamudSettingToggleUiHideDuringGposeHint", "Hide any open windows by plugins while gpose is active."),
c => c.ToggleUiHideDuringGpose,
(v, c) => c.ToggleUiHideDuringGpose = v),
new GapSettingsEntry(5, true),
new SettingsEntry(
- Loc.Localize("DalamudSettingToggleFocusManagement", "Use escape to close Dalamud windows"),
- Loc.Localize("DalamudSettingToggleFocusManagementHint", "This will cause Dalamud windows to behave like in-game windows when pressing escape.\nThey will close one after another until all are closed. May not work for all plugins."),
+ LazyLoc.Localize("DalamudSettingToggleFocusManagement", "Use escape to close Dalamud windows"),
+ LazyLoc.Localize("DalamudSettingToggleFocusManagementHint", "This will cause Dalamud windows to behave like in-game windows when pressing escape.\nThey will close one after another until all are closed. May not work for all plugins."),
c => c.IsFocusManagementEnabled,
(v, c) => c.IsFocusManagementEnabled = v),
// This is applied every frame in InterfaceManager::CheckViewportState()
new SettingsEntry(
- Loc.Localize("DalamudSettingToggleViewports", "Enable multi-monitor windows"),
- Loc.Localize("DalamudSettingToggleViewportsHint", "This will allow you move plugin windows onto other monitors.\nWill only work in Borderless Window or Windowed mode."),
+ LazyLoc.Localize("DalamudSettingToggleViewports", "Enable multi-monitor windows"),
+ LazyLoc.Localize("DalamudSettingToggleViewportsHint", "This will allow you move plugin windows onto other monitors.\nWill only work in Borderless Window or Windowed mode."),
c => !c.IsDisableViewport,
(v, c) => c.IsDisableViewport = !v),
new SettingsEntry(
- Loc.Localize("DalamudSettingToggleDocking", "Enable window docking"),
- Loc.Localize("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows."),
+ LazyLoc.Localize("DalamudSettingToggleDocking", "Enable window docking"),
+ LazyLoc.Localize("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows."),
c => c.IsDocking,
(v, c) => c.IsDocking = v),
new SettingsEntry(
- Loc.Localize(
- "DalamudSettingEnablePluginUIAdditionalOptions",
- "Add a button to the title bar of plugin windows to open additional options"),
- Loc.Localize(
- "DalamudSettingEnablePluginUIAdditionalOptionsHint",
- "This will allow you to pin certain plugin windows, make them clickthrough or adjust their opacity.\nThis may not be supported by all of your plugins. Contact the plugin author if you want them to support this feature."),
+ LazyLoc.Localize("DalamudSettingEnablePluginUIAdditionalOptions", "Add a button to the title bar of plugin windows to open additional options"),
+ LazyLoc.Localize("DalamudSettingEnablePluginUIAdditionalOptionsHint", "This will allow you to pin certain plugin windows, make them clickthrough or adjust their opacity.\nThis may not be supported by all of your plugins. Contact the plugin author if you want them to support this feature."),
c => c.EnablePluginUiAdditionalOptions,
(v, c) => c.EnablePluginUiAdditionalOptions = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingEnablePluginUISoundEffects", "Enable sound effects for plugin windows"),
- Loc.Localize("DalamudSettingEnablePluginUISoundEffectsHint", "This will allow you to enable or disable sound effects generated by plugin user interfaces.\nThis is affected by your in-game `System Sounds` volume settings."),
+ LazyLoc.Localize("DalamudSettingEnablePluginUISoundEffects", "Enable sound effects for plugin windows"),
+ LazyLoc.Localize("DalamudSettingEnablePluginUISoundEffectsHint", "This will allow you to enable or disable sound effects generated by plugin user interfaces.\nThis is affected by your in-game `System Sounds` volume settings."),
c => c.EnablePluginUISoundEffects,
(v, c) => c.EnablePluginUISoundEffects = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingToggleGamepadNavigation", "Control plugins via gamepad"),
- Loc.Localize("DalamudSettingToggleGamepadNavigationHint", "This will allow you to toggle between game and plugin navigation via L1+L3.\nToggle the PluginInstaller window via R3 if ImGui navigation is enabled."),
+ LazyLoc.Localize("DalamudSettingToggleGamepadNavigation", "Control plugins via gamepad"),
+ LazyLoc.Localize("DalamudSettingToggleGamepadNavigationHint", "This will allow you to toggle between game and plugin navigation via L1+L3.\nToggle the PluginInstaller window via R3 if ImGui navigation is enabled."),
c => c.IsGamepadNavigationEnabled,
(v, c) => c.IsGamepadNavigationEnabled = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingToggleTsm", "Show title screen menu"),
- Loc.Localize("DalamudSettingToggleTsmHint", "This will allow you to access certain Dalamud and Plugin functionality from the title screen.\nDisabling this will also hide the Dalamud version text on the title screen."),
+ LazyLoc.Localize("DalamudSettingToggleTsm", "Show title screen menu"),
+ LazyLoc.Localize("DalamudSettingToggleTsmHint", "This will allow you to access certain Dalamud and Plugin functionality from the title screen.\nDisabling this will also hide the Dalamud version text on the title screen."),
c => c.ShowTsm,
(v, c) => c.ShowTsm = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"),
- Loc.Localize("DalamudSettingInstallerOpenDefaultHint", "This will allow you to open the Plugin Installer to the \"Installed Plugins\" tab by default, instead of the \"Available Plugins\" tab."),
+ LazyLoc.Localize("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"),
+ LazyLoc.Localize("DalamudSettingInstallerOpenDefaultHint", "This will allow you to open the Plugin Installer to the \"Installed Plugins\" tab by default, instead of the \"Available Plugins\" tab."),
c => c.PluginInstallerOpen == PluginInstallerOpenKind.InstalledPlugins,
(v, c) => c.PluginInstallerOpen = v ? PluginInstallerOpenKind.InstalledPlugins : PluginInstallerOpenKind.AllPlugins),
new SettingsEntry(
- Loc.Localize("DalamudSettingReducedMotion", "Reduce motions"),
- Loc.Localize("DalamudSettingReducedMotionHint", "This will suppress certain animations from Dalamud, such as the notification popup."),
+ LazyLoc.Localize("DalamudSettingReducedMotion", "Reduce motions"),
+ LazyLoc.Localize("DalamudSettingReducedMotionHint", "This will suppress certain animations from Dalamud, such as the notification popup."),
c => c.ReduceMotions ?? false,
(v, c) => c.ReduceMotions = v),
new SettingsEntry(
- Loc.Localize("DalamudSettingImeStateIndicatorOpacity", "IME State Indicator Opacity (CJK only)"),
- Loc.Localize("DalamudSettingImeStateIndicatorOpacityHint", "When any of CJK IMEs is in use, the state of IME will be shown with the opacity specified here."),
+ LazyLoc.Localize("DalamudSettingImeStateIndicatorOpacity", "IME State Indicator Opacity (CJK only)"),
+ LazyLoc.Localize("DalamudSettingImeStateIndicatorOpacityHint", "When any of CJK IMEs is in use, the state of IME will be shown with the opacity specified here."),
c => c.ImeStateIndicatorOpacity,
(v, c) => c.ImeStateIndicatorOpacity = v)
{
@@ -176,8 +176,6 @@ public class SettingsTabLook : SettingsTab
}
];
- public override string Title => Loc.Localize("DalamudSettingsVisual", "Look & Feel");
-
public override void Draw()
{
var interfaceManager = Service.Get();
@@ -212,7 +210,7 @@ public class SettingsTabLook : SettingsTab
var p = stackalloc byte[len];
Encoding.UTF8.GetBytes(buildingFonts, new(p, len));
ImGui.Text(
- new ReadOnlySpan(p, len)[..((len + ((Environment.TickCount / 200) % 3)) - 2)]);
+ new ReadOnlySpan(p, len)[..(len + (Environment.TickCount / 200 % 3) - 2)]);
}
}
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ButtonSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ButtonSettingsEntry.cs
index b53411c7c..7d72464ac 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ButtonSettingsEntry.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ButtonSettingsEntry.cs
@@ -1,18 +1,18 @@
-using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.CodeAnalysis;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Colors;
-using Dalamud.Interface.Utility;
+using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class ButtonSettingsEntry : SettingsEntry
+internal sealed class ButtonSettingsEntry : SettingsEntry
{
- private readonly string description;
+ private readonly LazyLoc description;
private readonly Action runs;
- public ButtonSettingsEntry(string name, string description, Action runs)
+ public ButtonSettingsEntry(LazyLoc name, LazyLoc description, Action runs)
{
this.description = description;
this.runs = runs;
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/DevPluginsSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/DevPluginsSettingsEntry.cs
index 2e569b565..dd17a946a 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/DevPluginsSettingsEntry.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/DevPluginsSettingsEntry.cs
@@ -6,6 +6,7 @@ using System.Numerics;
using System.Threading.Tasks;
using CheapLoc;
+
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration;
using Dalamud.Configuration.Internal;
@@ -15,13 +16,14 @@ using Dalamud.Interface.ImGuiFileDialog;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Plugin.Internal;
+using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class DevPluginsSettingsEntry : SettingsEntry
+internal sealed class DevPluginsSettingsEntry : SettingsEntry
{
- private List devPluginLocations = new();
+ private List devPluginLocations = [];
private bool devPluginLocationsChanged;
private string devPluginTempLocation = string.Empty;
private string devPluginLocationAddError = string.Empty;
@@ -29,25 +31,25 @@ public class DevPluginsSettingsEntry : SettingsEntry
public DevPluginsSettingsEntry()
{
- this.Name = Loc.Localize("DalamudSettingsDevPluginLocation", "Dev Plugin Locations");
+ this.Name = LazyLoc.Localize("DalamudSettingsDevPluginLocation", "Dev Plugin Locations");
}
public override void OnClose()
{
this.devPluginLocations =
- Service.Get().DevPluginLoadLocations.Select(x => x.Clone()).ToList();
+ [.. Service.Get().DevPluginLoadLocations.Select(x => x.Clone())];
}
public override void Load()
{
this.devPluginLocations =
- Service.Get().DevPluginLoadLocations.Select(x => x.Clone()).ToList();
+ [.. Service.Get().DevPluginLoadLocations.Select(x => x.Clone())];
this.devPluginLocationsChanged = false;
}
public override void Save()
{
- Service.Get().DevPluginLoadLocations = this.devPluginLocations.Select(x => x.Clone()).ToList();
+ Service.Get().DevPluginLoadLocations = [.. this.devPluginLocations.Select(x => x.Clone())];
if (this.devPluginLocationsChanged)
{
@@ -59,7 +61,9 @@ public class DevPluginsSettingsEntry : SettingsEntry
public override void Draw()
{
using var id = ImRaii.PushId("devPluginLocation"u8);
+
ImGui.Text(this.Name);
+
if (this.devPluginLocationsChanged)
{
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen))
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/EnumSettingsEntry{T}.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/EnumSettingsEntry{T}.cs
index 03123ad95..8fb91940e 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/EnumSettingsEntry{T}.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/EnumSettingsEntry{T}.cs
@@ -1,12 +1,15 @@
-using System.Diagnostics;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using CheapLoc;
+
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
+using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
@@ -23,8 +26,8 @@ internal sealed class EnumSettingsEntry : SettingsEntry
private T valueBacking;
public EnumSettingsEntry(
- string name,
- string description,
+ LazyLoc name,
+ LazyLoc description,
LoadSettingDelegate load,
SaveSettingDelegate save,
Action? change = null,
@@ -61,7 +64,7 @@ internal sealed class EnumSettingsEntry : SettingsEntry
}
}
- public string Description { get; }
+ public LazyLoc Description { get; }
public Action>? CustomDraw { get; init; }
@@ -79,7 +82,10 @@ internal sealed class EnumSettingsEntry : SettingsEntry
public override void Draw()
{
- Debug.Assert(this.Name != null, "this.Name != null");
+ var name = this.Name.ToString();
+ var description = this.Description.ToString();
+
+ Debug.Assert(!string.IsNullOrWhiteSpace(name), "Name is empty");
if (this.CustomDraw is not null)
{
@@ -87,7 +93,7 @@ internal sealed class EnumSettingsEntry : SettingsEntry
}
else
{
- ImGui.TextWrapped(this.Name);
+ ImGui.TextWrapped(name);
var idx = this.valueBacking;
var values = Enum.GetValues();
@@ -117,13 +123,14 @@ internal sealed class EnumSettingsEntry : SettingsEntry
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
{
var desc = this.FriendlyEnumDescriptionGetter(this.valueBacking);
+
if (!string.IsNullOrWhiteSpace(desc))
{
ImGui.TextWrapped(desc);
ImGuiHelpers.ScaledDummy(2);
}
- ImGui.TextWrapped(this.Description);
+ ImGui.TextWrapped(description);
}
if (this.CheckValidity != null)
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/GapSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/GapSettingsEntry.cs
index 88982b825..c220ea684 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/GapSettingsEntry.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/GapSettingsEntry.cs
@@ -1,4 +1,4 @@
-using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.CodeAnalysis;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Utility;
@@ -6,7 +6,7 @@ using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public sealed class GapSettingsEntry : SettingsEntry
+internal sealed class GapSettingsEntry : SettingsEntry
{
private readonly float size;
private readonly bool hr;
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/HintSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/HintSettingsEntry.cs
index 1937adc57..7159effdf 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/HintSettingsEntry.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/HintSettingsEntry.cs
@@ -3,16 +3,17 @@ using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Colors;
+using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class HintSettingsEntry : SettingsEntry
+internal sealed class HintSettingsEntry : SettingsEntry
{
- private readonly string text;
+ private readonly LazyLoc text;
private readonly Vector4 color;
- public HintSettingsEntry(string text, Vector4? color = null)
+ public HintSettingsEntry(LazyLoc text, Vector4? color = null)
{
this.text = text;
this.color = color ?? ImGuiColors.DalamudGrey;
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/LanguageChooserSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/LanguageChooserSettingsEntry.cs
index 4e328720b..9459413df 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/LanguageChooserSettingsEntry.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/LanguageChooserSettingsEntry.cs
@@ -3,15 +3,16 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using CheapLoc;
+
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
-using Dalamud.Interface.Utility;
+using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public sealed class LanguageChooserSettingsEntry : SettingsEntry
+internal sealed class LanguageChooserSettingsEntry : SettingsEntry
{
private readonly string[] languages;
private readonly string[] locLanguages;
@@ -20,9 +21,9 @@ public sealed class LanguageChooserSettingsEntry : SettingsEntry
public LanguageChooserSettingsEntry()
{
- this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();
+ this.languages = [.. Localization.ApplicableLangCodes.Prepend("en")];
- this.Name = Loc.Localize("DalamudSettingsLanguage", "Language");
+ this.Name = LazyLoc.Localize("DalamudSettingsLanguage", "Language");
this.IsValid = true;
this.IsVisible = true;
@@ -46,7 +47,7 @@ public sealed class LanguageChooserSettingsEntry : SettingsEntry
}
}
- this.locLanguages = locLanguagesList.ToArray();
+ this.locLanguages = [.. locLanguagesList];
}
catch (Exception)
{
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/SettingsEntry{T}.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/SettingsEntry{T}.cs
index 2349d0d7a..e901550da 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/SettingsEntry{T}.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/SettingsEntry{T}.cs
@@ -1,12 +1,12 @@
-using System.Diagnostics;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
-using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
+using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
@@ -20,8 +20,8 @@ internal sealed class SettingsEntry : SettingsEntry
private object? valueBacking;
public SettingsEntry(
- string name,
- string description,
+ LazyLoc name,
+ LazyLoc description,
LoadSettingDelegate load,
SaveSettingDelegate save,
Action? change = null,
@@ -55,7 +55,7 @@ internal sealed class SettingsEntry : SettingsEntry
}
}
- public string Description { get; }
+ public LazyLoc Description { get; }
public Action>? CustomDraw { get; init; }
@@ -69,7 +69,10 @@ internal sealed class SettingsEntry : SettingsEntry
public override void Draw()
{
- Debug.Assert(this.Name != null, "this.Name != null");
+ var name = this.Name.ToString();
+ var description = this.Description.ToString();
+
+ Debug.Assert(!string.IsNullOrWhiteSpace(name), "Name is empty");
var type = typeof(T);
@@ -79,7 +82,7 @@ internal sealed class SettingsEntry : SettingsEntry
}
else if (type == typeof(DirectoryInfo))
{
- ImGui.TextWrapped(this.Name);
+ ImGui.TextWrapped(name);
var value = this.Value as DirectoryInfo;
var nativeBuffer = value?.FullName ?? string.Empty;
@@ -91,7 +94,7 @@ internal sealed class SettingsEntry : SettingsEntry
}
else if (type == typeof(string))
{
- ImGui.TextWrapped(this.Name);
+ ImGui.TextWrapped(name);
var nativeBuffer = this.Value as string ?? string.Empty;
@@ -104,16 +107,19 @@ internal sealed class SettingsEntry : SettingsEntry
{
var nativeValue = this.Value as bool? ?? false;
- if (ImGui.Checkbox($"{this.Name}###{this.Id.ToString()}", ref nativeValue))
+ if (ImGui.Checkbox($"{name}###{this.Id.ToString()}", ref nativeValue))
{
this.valueBacking = nativeValue;
this.change?.Invoke(this.Value);
}
}
- using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
+ if (!string.IsNullOrWhiteSpace(description))
{
- ImGui.TextWrapped(this.Description);
+ using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
+ {
+ ImGui.TextWrapped(this.Description);
+ }
}
if (this.CheckValidity != null)
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs
index cfcf6b3ac..5737b44db 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs
@@ -18,9 +18,9 @@ using Dalamud.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
-public class ThirdRepoSettingsEntry : SettingsEntry
+internal class ThirdRepoSettingsEntry : SettingsEntry
{
- private List thirdRepoList = new();
+ private List thirdRepoList = [];
private bool thirdRepoListChanged;
private string thirdRepoTempUrl = string.Empty;
private string thirdRepoAddError = string.Empty;
@@ -34,20 +34,20 @@ public class ThirdRepoSettingsEntry : SettingsEntry
public override void OnClose()
{
this.thirdRepoList =
- Service.Get().ThirdRepoList.Select(x => x.Clone()).ToList();
+ [.. Service.Get().ThirdRepoList.Select(x => x.Clone())];
}
public override void Load()
{
this.thirdRepoList =
- Service.Get().ThirdRepoList.Select(x => x.Clone()).ToList();
+ [.. Service.Get().ThirdRepoList.Select(x => x.Clone())];
this.thirdRepoListChanged = false;
}
public override void Save()
{
Service.Get().ThirdRepoList =
- this.thirdRepoList.Select(x => x.Clone()).ToList();
+ [.. this.thirdRepoList.Select(x => x.Clone())];
if (this.thirdRepoListChanged)
{
diff --git a/Dalamud/IoC/Internal/ServiceContainer.cs b/Dalamud/IoC/Internal/ServiceContainer.cs
index 6745155f6..31d16e02e 100644
--- a/Dalamud/IoC/Internal/ServiceContainer.cs
+++ b/Dalamud/IoC/Internal/ServiceContainer.cs
@@ -112,27 +112,15 @@ internal class ServiceContainer : IServiceProvider, IServiceType
errorStep = "property injection";
await this.InjectProperties(instance, scopedObjects, scope);
+ // Invoke ctor from a separate thread (LongRunning will spawn a new one)
+ // so that it does not count towards thread pool active threads cap.
+ // Plugin ctor can block to wait for Tasks, as we currently do not support asynchronous plugin init.
errorStep = "ctor invocation";
- var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
- var thr = new Thread(
- () =>
- {
- try
- {
- ctor.Invoke(instance, resolvedParams);
- }
- catch (Exception e)
- {
- tcs.SetException(e);
- return;
- }
-
- tcs.SetResult();
- });
-
- thr.Start();
- await tcs.Task.ConfigureAwait(false);
- thr.Join();
+ await Task.Factory.StartNew(
+ () => ctor.Invoke(instance, resolvedParams),
+ CancellationToken.None,
+ TaskCreationOptions.LongRunning,
+ TaskScheduler.Default).ConfigureAwait(false);
return instance;
}
diff --git a/Dalamud/Localization.cs b/Dalamud/Localization.cs
index 1e72c3075..0a7086e73 100644
--- a/Dalamud/Localization.cs
+++ b/Dalamud/Localization.cs
@@ -112,11 +112,14 @@ public class Localization : IServiceType
}
///
- /// Set up the UI language with "fallbacks"(original English text).
+ /// Set up the UI language with "fallbacks" (original English text).
///
public void SetupWithFallbacks()
{
this.DalamudLanguageCultureInfo = CultureInfo.InvariantCulture;
+
+ Loc.SetupWithFallbacks(this.assembly);
+
foreach (var d in Delegate.EnumerateInvocationList(this.LocalizationChanged))
{
try
@@ -128,8 +131,6 @@ public class Localization : IServiceType
Log.Error(ex, "Exception during raise of {handler}", d.Method);
}
}
-
- Loc.SetupWithFallbacks(this.assembly);
}
///
@@ -145,6 +146,17 @@ public class Localization : IServiceType
}
this.DalamudLanguageCultureInfo = GetCultureInfoFromLangCode(langCode);
+
+ try
+ {
+ Loc.Setup(this.ReadLocData(langCode), this.assembly);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Could not load loc {0}. Setting up fallbacks.", langCode);
+ this.SetupWithFallbacks();
+ }
+
foreach (var d in Delegate.EnumerateInvocationList(this.LocalizationChanged))
{
try
@@ -156,16 +168,6 @@ public class Localization : IServiceType
Log.Error(ex, "Exception during raise of {handler}", d.Method);
}
}
-
- try
- {
- Loc.Setup(this.ReadLocData(langCode), this.assembly);
- }
- catch (Exception ex)
- {
- Log.Error(ex, "Could not load loc {0}. Setting up fallbacks.", langCode);
- this.SetupWithFallbacks();
- }
}
///
diff --git a/Dalamud/Plugin/Services/IClientState.cs b/Dalamud/Plugin/Services/IClientState.cs
index 60d8a17e2..0342ea77c 100644
--- a/Dalamud/Plugin/Services/IClientState.cs
+++ b/Dalamud/Plugin/Services/IClientState.cs
@@ -1,4 +1,5 @@
using Dalamud.Game;
+using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.SubKinds;
@@ -29,11 +30,26 @@ public interface IClientState
/// The success/failure code.
public delegate void LogoutDelegate(int type, int code);
+ ///
+ /// Event that gets fired when the game initializes a zone.
+ ///
+ public event Action ZoneInit;
+
///
/// Event that gets fired when the current Territory changes.
///
public event Action TerritoryChanged;
+ ///
+ /// Event that gets fired when the current Map changes.
+ ///
+ public event Action MapIdChanged;
+
+ ///
+ /// Event that gets fired when the current zone Instance changes.
+ ///
+ public event Action InstanceChanged;
+
///
/// Event that fires when a characters ClassJob changed.
///
@@ -85,6 +101,11 @@ public interface IClientState
///
public uint MapId { get; }
+ ///
+ /// Gets the instance number of the current zone, used when multiple copies of an area are active.
+ ///
+ public uint Instance { get; }
+
///
/// Gets the local player character, if one is present.
///
diff --git a/Dalamud/Utility/Internal/LazyLoc.cs b/Dalamud/Utility/Internal/LazyLoc.cs
new file mode 100644
index 000000000..08ea6bd95
--- /dev/null
+++ b/Dalamud/Utility/Internal/LazyLoc.cs
@@ -0,0 +1,31 @@
+using CheapLoc;
+
+using Dalamud.Bindings.ImGui;
+
+namespace Dalamud.Utility.Internal;
+
+///
+/// Represents a lazily localized string, consisting of a localization key and a fallback value.
+///
+/// The localization key used to retrieve the localized value.
+/// The fallback text to use if the localization key is not found.
+internal readonly record struct LazyLoc(string Key, string Fallback)
+{
+ public static implicit operator ImU8String(LazyLoc locRef)
+ => new(locRef.ToString());
+
+ ///
+ /// Creates a new instance of with the specified localization key and fallback text.
+ ///
+ /// The localization key used to retrieve the localized value.
+ /// The fallback text to use if the localization key is not found.
+ /// A instance representing the localized value.
+ public static LazyLoc Localize(string key, string fallback)
+ => new(key, fallback);
+
+ ///
+ public override string ToString()
+ {
+ return Loc.Localize(this.Key, this.Fallback);
+ }
+}
diff --git a/Dalamud/Utility/Util.cs b/Dalamud/Utility/Util.cs
index a1c2eb6b2..ff06618ab 100644
--- a/Dalamud/Utility/Util.cs
+++ b/Dalamud/Utility/Util.cs
@@ -753,7 +753,7 @@ public static partial class Util
$"{actor.Address.ToInt64():X}:{actor.GameObjectId:X}[{tag}] - {actor.ObjectKind} - {actor.Name} - X{actor.Position.X} Y{actor.Position.Y} Z{actor.Position.Z} D{actor.YalmDistanceX} R{actor.Rotation} - Target: {actor.TargetObjectId:X}\n";
if (actor is Npc npc)
- actorString += $" DataId: {npc.DataId} NameId:{npc.NameId}\n";
+ actorString += $" BaseId: {npc.BaseId} NameId:{npc.NameId}\n";
if (actor is ICharacter chara)
{
@@ -787,7 +787,7 @@ public static partial class Util
$"{actor.Address.ToInt64():X}:{actor.GameObjectId:X}[{tag}] - {actor.ObjectKind} - {actor.Name} - X{actor.Position.X} Y{actor.Position.Y} Z{actor.Position.Z} D{actor.YalmDistanceX} R{actor.Rotation} - Target: {actor.TargetObjectId:X}\n";
if (actor is Npc npc)
- actorString += $" DataId: {npc.DataId} NameId:{npc.NameId}\n";
+ actorString += $" BaseId: {npc.BaseId} NameId:{npc.NameId}\n";
if (actor is Character chara)
{
diff --git a/imgui/Dalamud.Bindings.ImGui/ImU8String.cs b/imgui/Dalamud.Bindings.ImGui/ImU8String.cs
index 17756ae61..a62152c39 100644
--- a/imgui/Dalamud.Bindings.ImGui/ImU8String.cs
+++ b/imgui/Dalamud.Bindings.ImGui/ImU8String.cs
@@ -301,7 +301,7 @@ public ref struct ImU8String
{
var startingPos = this.Length;
this.AppendFormatted(value, format);
- FixAlignment(startingPos, alignment);
+ this.FixAlignment(startingPos, alignment);
}
public void AppendFormatted(ReadOnlySpan value) => this.AppendFormatted(value, null);
@@ -322,7 +322,7 @@ public ref struct ImU8String
{
var startingPos = this.Length;
this.AppendFormatted(value, format);
- FixAlignment(startingPos, alignment);
+ this.FixAlignment(startingPos, alignment);
}
public void AppendFormatted(object? value) => this.AppendFormatted