diff --git a/Dalamud/Game/NativeWrapper/AgentInterfacePtr.cs b/Dalamud/Game/NativeWrapper/AgentInterfacePtr.cs index b5a6375a9..b5e8938dd 100644 --- a/Dalamud/Game/NativeWrapper/AgentInterfacePtr.cs +++ b/Dalamud/Game/NativeWrapper/AgentInterfacePtr.cs @@ -81,7 +81,7 @@ public readonly unsafe struct AgentInterfacePtr(nint address) : IEquatable /// true when the addon was focused, false otherwise. - public readonly bool FocusAddon() => this.IsNull && this.Struct->FocusAddon(); + public readonly bool FocusAddon() => !this.IsNull && this.Struct->FocusAddon(); /// Determines whether the specified AgentInterfacePtr is equal to the current AgentInterfacePtr. /// The AgentInterfacePtr to compare with the current AgentInterfacePtr. diff --git a/Dalamud/Game/UnlockState/UnlockState.cs b/Dalamud/Game/UnlockState/UnlockState.cs index 939548803..5ccd7fadb 100644 --- a/Dalamud/Game/UnlockState/UnlockState.cs +++ b/Dalamud/Game/UnlockState/UnlockState.cs @@ -311,9 +311,12 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState } /// - public bool IsMcGuffinUnlocked(McGuffin row) + public bool IsLeveCompleted(Leve row) { - return PlayerState.Instance()->IsMcGuffinUnlocked(row.RowId); + if (!this.IsLoaded) + return false; + + return QuestManager.Instance()->IsLevequestComplete((ushort)row.RowId); } /// @@ -328,6 +331,15 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState return this.IsUnlockLinkUnlocked(row.UnlockLink); } + /// + public bool IsMcGuffinUnlocked(McGuffin row) + { + if (!this.IsLoaded) + return false; + + return PlayerState.Instance()->IsMcGuffinUnlocked(row.RowId); + } + /// public bool IsMountUnlocked(Mount row) { @@ -376,9 +388,21 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState return UIState.IsPublicContentUnlocked(row.RowId); } + /// + public bool IsQuestCompleted(Quest row) + { + if (!this.IsLoaded) + return false; + + return QuestManager.IsQuestComplete(row.RowId); + } + /// public bool IsRecipeUnlocked(Recipe row) { + if (!this.IsLoaded) + return false; + return this.recipeData.IsRecipeUnlocked(row); } @@ -509,6 +533,9 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState if (rowRef.TryGetValue(out var itemRow)) return this.IsItemUnlocked(itemRow); + if (rowRef.TryGetValue(out var leveRow)) + return this.IsLeveCompleted(leveRow); + if (rowRef.TryGetValue(out var mjiLandmarkRow)) return this.IsMJILandmarkUnlocked(mjiLandmarkRow); @@ -536,6 +563,9 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState if (rowRef.TryGetValue(out var publicContentRow)) return this.IsPublicContentUnlocked(publicContentRow); + if (rowRef.TryGetValue(out var questRow)) + return this.IsQuestCompleted(questRow); + if (rowRef.TryGetValue(out var recipeRow)) return this.IsRecipeUnlocked(recipeRow); @@ -596,6 +626,8 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState if (!this.IsLoaded) return; + Log.Verbose("Checking for new unlocks..."); + this.UpdateUnlocksForSheet(); this.UpdateUnlocksForSheet(); this.UpdateUnlocksForSheet(); @@ -629,6 +661,7 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState this.UpdateUnlocksForSheet(); this.UpdateUnlocksForSheet(); this.UpdateUnlocksForSheet(); + this.UpdateUnlocksForSheet(); this.UpdateUnlocksForSheet(); this.UpdateUnlocksForSheet(); this.UpdateUnlocksForSheet(); @@ -637,6 +670,7 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState // Not implemented: // - DescriptionPage: quite complex // - QuestAcceptAdditionCondition: ignored + // - Leve: AgentUpdateFlag.UnlocksUpdate is not set and the completed status can be unset again! // For some other day: // - FishingSpot @@ -676,7 +710,7 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState unlockedRowIds.Add(row.RowId); - Log.Verbose($"Unlock detected: {typeof(T).Name}#{row.RowId}"); + // Log.Verbose($"Unlock detected: {typeof(T).Name}#{row.RowId}"); foreach (var action in Delegate.EnumerateInvocationList(this.Unlock)) { @@ -796,7 +830,7 @@ internal class UnlockStatePluginScoped : IInternalDisposableService, IUnlockStat public bool IsItemUnlocked(Item row) => this.unlockStateService.IsItemUnlocked(row); /// - public bool IsMcGuffinUnlocked(McGuffin row) => this.unlockStateService.IsMcGuffinUnlocked(row); + public bool IsLeveCompleted(Leve row) => this.unlockStateService.IsLeveCompleted(row); /// public bool IsMJILandmarkUnlocked(MJILandmark row) => this.unlockStateService.IsMJILandmarkUnlocked(row); @@ -804,6 +838,9 @@ internal class UnlockStatePluginScoped : IInternalDisposableService, IUnlockStat /// public bool IsMKDLoreUnlocked(MKDLore row) => this.unlockStateService.IsMKDLoreUnlocked(row); + /// + public bool IsMcGuffinUnlocked(McGuffin row) => this.unlockStateService.IsMcGuffinUnlocked(row); + /// public bool IsMountUnlocked(Mount row) => this.unlockStateService.IsMountUnlocked(row); @@ -822,6 +859,9 @@ internal class UnlockStatePluginScoped : IInternalDisposableService, IUnlockStat /// public bool IsPublicContentUnlocked(PublicContentSheet row) => this.unlockStateService.IsPublicContentUnlocked(row); + /// + public bool IsQuestCompleted(Quest row) => this.unlockStateService.IsQuestCompleted(row); + /// public bool IsRecipeUnlocked(Recipe row) => this.unlockStateService.IsRecipeUnlocked(row); diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/UIColorWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/UIColorWidget.cs index dc1ab4e30..bc6e5376c 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/UIColorWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/UIColorWidget.cs @@ -3,11 +3,11 @@ using System.Numerics; using System.Text; using Dalamud.Bindings.ImGui; -using Dalamud.Interface.Utility.Raii; using Dalamud.Data; using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; using Dalamud.Interface.ImGuiSeStringRenderer.Internal; +using Dalamud.Interface.Utility.Raii; using Lumina.Excel.Sheets; diff --git a/Dalamud/Plugin/Services/IUnlockState.cs b/Dalamud/Plugin/Services/IUnlockState.cs index 6703ece2e..f51222ba1 100644 --- a/Dalamud/Plugin/Services/IUnlockState.cs +++ b/Dalamud/Plugin/Services/IUnlockState.cs @@ -205,6 +205,13 @@ public interface IUnlockState : IDalamudService /// if unlocked; otherwise, . bool IsItemUnlocked(Item row); + /// + /// Determines whether the specified Leve is completed. + /// + /// The Leve row to check. + /// if completed; otherwise, . + bool IsLeveCompleted(Leve row); + /// /// Determines whether the specified McGuffin is unlocked. /// @@ -268,6 +275,13 @@ public interface IUnlockState : IDalamudService /// if unlocked; otherwise, . bool IsPublicContentUnlocked(PublicContent row); + /// + /// Determines whether the specified Quest is completed. + /// + /// The Quest row to check. + /// if completed; otherwise, . + bool IsQuestCompleted(Quest row); + /// /// Determines whether the specified Recipe is unlocked. ///