From f69915dcb3079ca49bd2a9f57c30a634f96d7a9a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 4 Aug 2024 12:38:38 +0200 Subject: [PATCH] Remove some warnings. --- Glamourer/Gui/DesignQuickBar.cs | 5 ++++- Glamourer/Interop/ObjectManager.cs | 2 +- Glamourer/Unlocks/CustomizeUnlockManager.cs | 16 +++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index c3829fa..31ca45e 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -70,6 +70,9 @@ public sealed class DesignQuickBar : Window, IDisposable IsOpen = _config.Ephemeral.ShowDesignQuickBar && _config.QdbButtons != 0; } + public override bool DrawConditions() + => _objects.Player.Valid; + public override void PreDraw() { Flags = GetFlags; @@ -112,7 +115,7 @@ public sealed class DesignQuickBar : Window, IDisposable ImGui.SameLine(); DrawApplyButton(buttonSize); } - + DrawRevertButton(buttonSize); DrawRevertEquipButton(buttonSize); DrawRevertCustomizeButton(buttonSize); diff --git a/Glamourer/Interop/ObjectManager.cs b/Glamourer/Interop/ObjectManager.cs index f8f5813..b185f4a 100644 --- a/Glamourer/Interop/ObjectManager.cs +++ b/Glamourer/Interop/ObjectManager.cs @@ -40,7 +40,7 @@ public class ObjectManager( return false; _identifierUpdate = LastUpdate; - World = (ushort)(this[0].Valid ? this[0].HomeWorld : 0); + World = (ushort)(Player.Valid ? Player.HomeWorld : 0); _identifiers.Clear(); _allWorldIdentifiers.Clear(); _nonOwnedIdentifiers.Clear(); diff --git a/Glamourer/Unlocks/CustomizeUnlockManager.cs b/Glamourer/Unlocks/CustomizeUnlockManager.cs index a204a1c..801f211 100644 --- a/Glamourer/Unlocks/CustomizeUnlockManager.cs +++ b/Glamourer/Unlocks/CustomizeUnlockManager.cs @@ -6,6 +6,7 @@ using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.UI; using Glamourer.GameData; using Glamourer.Events; +using Glamourer.Interop; using Glamourer.Services; using Lumina.Excel.GeneratedSheets; using Penumbra.GameData; @@ -15,10 +16,10 @@ namespace Glamourer.Unlocks; public class CustomizeUnlockManager : IDisposable, ISavable { - private readonly SaveService _saveService; - private readonly IClientState _clientState; - private readonly ObjectUnlocked _event; - + private readonly SaveService _saveService; + private readonly IClientState _clientState; + private readonly ObjectUnlocked _event; + private readonly ObjectManager _objects; private readonly Dictionary _unlocked = new(); public readonly IReadOnlyDictionary Unlockable; @@ -27,12 +28,13 @@ public class CustomizeUnlockManager : IDisposable, ISavable => _unlocked; public CustomizeUnlockManager(SaveService saveService, CustomizeService customizations, IDataManager gameData, - IClientState clientState, ObjectUnlocked @event, IGameInteropProvider interop) + IClientState clientState, ObjectUnlocked @event, IGameInteropProvider interop, ObjectManager objects) { interop.InitializeFromAttributes(this); _saveService = saveService; _clientState = clientState; _event = @event; + _objects = objects; Unlockable = CreateUnlockableCustomizations(customizations, gameData); Load(); _setUnlockLinkValueHook.Enable(); @@ -94,7 +96,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable /// Scan and update all unlockable customizations for their current game state. public unsafe void Scan() { - if (_clientState.LocalPlayer == null) + if (!_objects.Player.Valid) return; Glamourer.Log.Debug("[UnlockManager] Scanning for new unlocked customizations."); @@ -128,7 +130,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable } private delegate void SetUnlockLinkValueDelegate(nint uiState, uint data, byte value); - + [Signature(Sigs.SetUnlockLinkValue, DetourName = nameof(SetUnlockLinkValueDetour))] private readonly Hook _setUnlockLinkValueHook = null!;