diff --git a/Glamourer.GameData/Customization/CmpFile.cs b/Glamourer.GameData/Customization/CmpFile.cs index 15d1570..6ed5ecb 100644 --- a/Glamourer.GameData/Customization/CmpFile.cs +++ b/Glamourer.GameData/Customization/CmpFile.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using Dalamud.Data; using Dalamud.Logging; +using Dalamud.Plugin.Services; namespace Glamourer.Customization; @@ -20,7 +20,7 @@ internal class CmpFile public bool Valid => _file != null; - public CmpFile(DataManager gameData) + public CmpFile(IDataManager gameData) { try { diff --git a/Glamourer.GameData/Customization/CustomizationManager.cs b/Glamourer.GameData/Customization/CustomizationManager.cs index 6f2460d..dc73279 100644 --- a/Glamourer.GameData/Customization/CustomizationManager.cs +++ b/Glamourer.GameData/Customization/CustomizationManager.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; -using Dalamud.Data; -using Dalamud.Plugin; +using Dalamud.Plugin.Services; using Penumbra.GameData.Enums; namespace Glamourer.Customization; @@ -12,9 +11,9 @@ public class CustomizationManager : ICustomizationManager private CustomizationManager() { } - public static ICustomizationManager Create(DalamudPluginInterface pi, DataManager gameData) + public static ICustomizationManager Create(ITextureProvider textures, IDataManager gameData) { - _options ??= new CustomizationOptions(pi, gameData); + _options ??= new CustomizationOptions(textures, gameData); return new CustomizationManager(); } diff --git a/Glamourer.GameData/Customization/CustomizationOptions.cs b/Glamourer.GameData/Customization/CustomizationOptions.cs index f265d9a..83605d4 100644 --- a/Glamourer.GameData/Customization/CustomizationOptions.cs +++ b/Glamourer.GameData/Customization/CustomizationOptions.cs @@ -3,8 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using Dalamud; -using Dalamud.Data; -using Dalamud.Plugin; +using Dalamud.Plugin.Services; using Dalamud.Utility; using Lumina.Excel; using Lumina.Excel.GeneratedSheets; @@ -36,7 +35,7 @@ public partial class CustomizationOptions // Get specific icons. internal ImGuiScene.TextureWrap GetIcon(uint id) - => _icons.LoadIcon(id); + => _icons.LoadIcon(id)!; private readonly IconStorage _icons; @@ -62,10 +61,10 @@ public partial class CustomizationOptions public string GetName(CustomName name) => _names[(int)name]; - internal CustomizationOptions(DalamudPluginInterface pi, DataManager gameData) + internal CustomizationOptions(ITextureProvider textures, IDataManager gameData) { var tmp = new TemporaryData(gameData, this); - _icons = new IconStorage(pi, gameData, _customizationSets.Length * 50); + _icons = new IconStorage(textures, gameData); SetNames(gameData, tmp); foreach (var race in Clans) { @@ -78,7 +77,7 @@ public partial class CustomizationOptions // Obtain localized names of customization options and race names from the game data. private readonly string[] _names = new string[Enum.GetValues().Length]; - private void SetNames(DataManager gameData, TemporaryData tmp) + private void SetNames(IDataManager gameData, TemporaryData tmp) { var subRace = gameData.GetExcelSheet()!; @@ -180,7 +179,7 @@ public partial class CustomizationOptions } - public TemporaryData(DataManager gameData, CustomizationOptions options) + public TemporaryData(IDataManager gameData, CustomizationOptions options) { _options = options; _cmpFile = new CmpFile(gameData); diff --git a/Glamourer.GameData/GameData.cs b/Glamourer.GameData/GameData.cs index 0436662..28986d8 100644 --- a/Glamourer.GameData/GameData.cs +++ b/Glamourer.GameData/GameData.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using Dalamud; -using Dalamud.Data; +using Dalamud.Plugin.Services; using Glamourer.Structs; using Lumina.Excel.GeneratedSheets; @@ -12,7 +12,7 @@ public static class GameData private static Dictionary? _jobs; private static Dictionary? _jobGroups; - public static IReadOnlyDictionary Jobs(DataManager dataManager) + public static IReadOnlyDictionary Jobs(IDataManager dataManager) { if (_jobs != null) return _jobs; @@ -22,7 +22,7 @@ public static class GameData return _jobs; } - public static IReadOnlyDictionary JobGroups(DataManager dataManager) + public static IReadOnlyDictionary JobGroups(IDataManager dataManager) { if (_jobGroups != null) return _jobGroups; diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index c4e8361..dd50581 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Numerics; -using Dalamud.Data; using Dalamud.Interface; +using Dalamud.Plugin.Services; using Glamourer.Designs; using Glamourer.Services; using Glamourer.Structs; @@ -34,7 +34,7 @@ public class EquipmentDrawer private float _requiredComboWidthUnscaled; private float _requiredComboWidth; - public EquipmentDrawer(DataManager gameData, ItemManager items, CodeService codes, TextureService textures, Configuration config) + public EquipmentDrawer(IDataManager gameData, ItemManager items, CodeService codes, TextureService textures, Configuration config) { _items = items; _codes = codes; diff --git a/Glamourer/Gui/Equipment/ItemCombo.cs b/Glamourer/Gui/Equipment/ItemCombo.cs index d3d51ea..1a2f1c2 100644 --- a/Glamourer/Gui/Equipment/ItemCombo.cs +++ b/Glamourer/Gui/Equipment/ItemCombo.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using Dalamud.Data; +using Dalamud.Plugin.Services; using Glamourer.Services; using ImGuiNET; using Lumina.Excel.GeneratedSheets; @@ -19,7 +19,7 @@ public sealed class ItemCombo : FilterComboCache private ItemId _currentItem; private float _innerWidth; - public ItemCombo(DataManager gameData, ItemManager items, EquipSlot slot) + public ItemCombo(IDataManager gameData, ItemManager items, EquipSlot slot) : base(() => GetItems(items, slot)) { Label = GetLabel(gameData, slot); @@ -71,7 +71,7 @@ public sealed class ItemCombo : FilterComboCache protected override string ToString(EquipItem obj) => obj.Name; - private static string GetLabel(DataManager gameData, EquipSlot slot) + private static string GetLabel(IDataManager gameData, EquipSlot slot) { var sheet = gameData.GetExcelSheet()!; diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs index 8c3b2e7..334b78a 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorSelector.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Numerics; -using Dalamud.Game.ClientState.Objects; using Dalamud.Interface; using Glamourer.Interop; using Glamourer.Interop.Structs; @@ -19,14 +18,12 @@ public class ActorSelector private readonly Configuration _config; private readonly ObjectManager _objects; private readonly ActorService _actors; - private readonly TargetManager _targets; private ActorIdentifier _identifier = ActorIdentifier.Invalid; - public ActorSelector(ObjectManager objects, TargetManager targets, ActorService actors, Configuration config) + public ActorSelector(ObjectManager objects, ActorService actors, Configuration config) { _objects = objects; - _targets = targets; _actors = actors; _config = config; } diff --git a/Glamourer/Gui/Tabs/DebugTab.cs b/Glamourer/Gui/Tabs/DebugTab.cs index d3c8d3a..66d19fd 100644 --- a/Glamourer/Gui/Tabs/DebugTab.cs +++ b/Glamourer/Gui/Tabs/DebugTab.cs @@ -5,7 +5,6 @@ using System.IO; using System.Linq; using System.Numerics; using System.Text; -using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Interface; using Dalamud.Plugin; @@ -46,7 +45,6 @@ public unsafe class DebugTab : ITab private readonly MetaService _metaService; private readonly InventoryService _inventoryService; private readonly PenumbraService _penumbra; - private readonly ObjectTable _objects; private readonly ObjectManager _objectManager; private readonly GlamourerIpc _ipc; private readonly CodeService _code; @@ -74,8 +72,7 @@ public unsafe class DebugTab : ITab public bool IsVisible => _config.DebugMode; - public DebugTab(ChangeCustomizeService changeCustomizeService, VisorService visorService, ObjectTable objects, - UpdateSlotService updateSlotService, WeaponService weaponService, PenumbraService penumbra, + public DebugTab(ChangeCustomizeService changeCustomizeService, VisorService visorService, UpdateSlotService updateSlotService, WeaponService weaponService, PenumbraService penumbra, ActorService actors, ItemManager items, CustomizationService customization, ObjectManager objectManager, DesignFileSystem designFileSystem, DesignManager designManager, StateManager state, Configuration config, PenumbraChangedItemTooltip penumbraTooltip, MetaService metaService, GlamourerIpc ipc, DalamudPluginInterface pluginInterface, @@ -85,7 +82,6 @@ public unsafe class DebugTab : ITab { _changeCustomizeService = changeCustomizeService; _visorService = visorService; - _objects = objects; _updateSlotService = updateSlotService; _weaponService = weaponService; _penumbra = penumbra; @@ -151,7 +147,7 @@ public unsafe class DebugTab : ITab return; ImGui.InputInt("Game Object Index", ref _gameObjectIndex, 0, 0); - var actor = (Actor)_objects.GetObjectAddress(_gameObjectIndex); + var actor = (Actor)_objectManager.Objects.GetObjectAddress(_gameObjectIndex); var model = actor.Model; using var table = ImRaii.Table("##evaluationTable", 4, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); ImGui.TableNextColumn(); @@ -433,7 +429,7 @@ public unsafe class DebugTab : ITab ? *(Penumbra.GameData.Structs.CustomizeData*)&actor.AsCharacter->DrawData.CustomizeData : new Penumbra.GameData.Structs.CustomizeData()); var modelCustomize = new Customize(model.IsHuman - ? *(Penumbra.GameData.Structs.CustomizeData*)model.AsHuman->CustomizeData + ? *(Penumbra.GameData.Structs.CustomizeData*)model.AsHuman->Customize.Data : new Penumbra.GameData.Structs.CustomizeData()); foreach (var type in Enum.GetValues()) { @@ -526,7 +522,7 @@ public unsafe class DebugTab : ITab using (var disabled = ImRaii.Disabled(!_penumbra.Available)) { if (ImGui.SmallButton("Redraw")) - _penumbra.RedrawObject(_objects.GetObjectAddress(_gameObjectIndex), RedrawType.Redraw); + _penumbra.RedrawObject(_objectManager.Objects.GetObjectAddress(_gameObjectIndex), RedrawType.Redraw); } ImGuiUtil.DrawTableColumn("Last Tooltip Date"); @@ -1604,7 +1600,7 @@ public unsafe class DebugTab : ITab ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelGetAllCustomizationFromCharacter); ImGui.TableNextColumn(); - base64 = GlamourerIpc.GetAllCustomizationFromCharacterSubscriber(_pluginInterface).Invoke(_objects[_gameObjectIndex] as Character); + base64 = GlamourerIpc.GetAllCustomizationFromCharacterSubscriber(_pluginInterface).Invoke(_objectManager.Objects[_gameObjectIndex] as Character); if (base64 != null) ImGuiUtil.CopyOnClickSelectable(base64); else @@ -1618,7 +1614,7 @@ public unsafe class DebugTab : ITab ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevertCharacter); ImGui.TableNextColumn(); if (ImGui.Button("Revert##Character")) - GlamourerIpc.RevertCharacterSubscriber(_pluginInterface).Invoke(_objects[_gameObjectIndex] as Character); + GlamourerIpc.RevertCharacterSubscriber(_pluginInterface).Invoke(_objectManager.Objects[_gameObjectIndex] as Character); ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAll); ImGui.TableNextColumn(); @@ -1628,7 +1624,7 @@ public unsafe class DebugTab : ITab ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAllToCharacter); ImGui.TableNextColumn(); if (ImGui.Button("Apply##AllCharacter")) - GlamourerIpc.ApplyAllToCharacterSubscriber(_pluginInterface).Invoke(_base64Apply, _objects[_gameObjectIndex] as Character); + GlamourerIpc.ApplyAllToCharacterSubscriber(_pluginInterface).Invoke(_base64Apply, _objectManager.Objects[_gameObjectIndex] as Character); ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyOnlyEquipment); ImGui.TableNextColumn(); @@ -1639,7 +1635,7 @@ public unsafe class DebugTab : ITab ImGui.TableNextColumn(); if (ImGui.Button("Apply##EquipCharacter")) GlamourerIpc.ApplyOnlyEquipmentToCharacterSubscriber(_pluginInterface) - .Invoke(_base64Apply, _objects[_gameObjectIndex] as Character); + .Invoke(_base64Apply, _objectManager.Objects[_gameObjectIndex] as Character); ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyOnlyCustomization); ImGui.TableNextColumn(); @@ -1650,7 +1646,7 @@ public unsafe class DebugTab : ITab ImGui.TableNextColumn(); if (ImGui.Button("Apply##CustomizeCharacter")) GlamourerIpc.ApplyOnlyCustomizationToCharacterSubscriber(_pluginInterface) - .Invoke(_base64Apply, _objects[_gameObjectIndex] as Character); + .Invoke(_base64Apply, _objectManager.Objects[_gameObjectIndex] as Character); } #endregion diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index c55248b..d70acc7 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -7,7 +7,6 @@ using Glamourer.Services; using Glamourer.Unlocks; using ImGuiNET; using OtterGui; -using OtterGui.Classes; using OtterGui.Raii; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -149,16 +148,15 @@ public class UnlockOverview var iconSize = ImGuiHelpers.ScaledVector2(64); var iconsPerRow = IconsPerRow(iconSize.X, spacing.X); var numRows = (items.Count + iconsPerRow - 1) / iconsPerRow; - var numVisibleRows = (int)(Math.Ceiling(ImGui.GetContentRegionAvail().Y / (iconSize.Y + spacing.Y)) + 0.5f); + var numVisibleRows = (int)(Math.Ceiling(ImGui.GetContentRegionAvail().Y / (iconSize.Y + spacing.Y)) + 0.5f) + 1; void DrawItem(EquipItem item) { var unlocked = _itemUnlocks.IsUnlocked(item.Id, out var time); - var iconHandle = _textures.LoadIcon(item.IconId.Id); - if (!iconHandle.HasValue) + if (!_textures.TryLoadIcon(item.IconId.Id, out var iconHandle)) return; - var (icon, size) = iconHandle.Value.Value; + var (icon, size) = (iconHandle.ImGuiHandle, new Vector2(iconHandle.Width, iconHandle.Height)); ImGui.Image(icon, iconSize, Vector2.Zero, Vector2.One, unlocked ? Vector4.One : UnavailableTint); if (ImGui.IsItemClicked()) diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index 5bd5f73..e7eaf15 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -35,7 +35,6 @@ public class UnlockTable : Table, IDisposable Sortable = true; Flags |= ImGuiTableFlags.Hideable; _event.Subscribe(OnObjectUnlock, ObjectUnlocked.Priority.UnlockTable); - textures.Logger = Glamourer.Log; } public void Dispose() @@ -61,9 +60,8 @@ public class UnlockTable : Table, IDisposable public override void DrawColumn(EquipItem item, int _) { - var iconHandle = _textures.LoadIcon(item.IconId.Id); - if (iconHandle.HasValue) - ImGuiUtil.HoverIcon(iconHandle.Value, new Vector2(ImGui.GetFrameHeight())); + if (_textures.TryLoadIcon(item.IconId.Id, out var iconHandle)) + ImGuiUtil.HoverIcon(iconHandle, new Vector2(ImGui.GetFrameHeight())); else ImGui.Dummy(new Vector2(ImGui.GetFrameHeight())); ImGui.SameLine(); @@ -260,7 +258,8 @@ public class UnlockTable : Table, IDisposable if (FilterRegex?.IsMatch(item.ModelString) ?? item.ModelString.Contains(FilterValue, StringComparison.OrdinalIgnoreCase)) return true; - if (item.Type.ValidOffhand().IsOffhandType() && _items.ItemService.AwaitedService.TryGetValue(item.ItemId, EquipSlot.OffHand, out var offhand)) + if (item.Type.ValidOffhand().IsOffhandType() + && _items.ItemService.AwaitedService.TryGetValue(item.ItemId, EquipSlot.OffHand, out var offhand)) return FilterRegex?.IsMatch(offhand.ModelString) ?? offhand.ModelString.Contains(FilterValue, StringComparison.OrdinalIgnoreCase); diff --git a/Glamourer/Interop/ContextMenuService.cs b/Glamourer/Interop/ContextMenuService.cs index 1ed4a99..aa58ead 100644 --- a/Glamourer/Interop/ContextMenuService.cs +++ b/Glamourer/Interop/ContextMenuService.cs @@ -1,8 +1,8 @@ using System; using Dalamud.ContextMenu; -using Dalamud.Game.Gui; using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Plugin.Services; using Glamourer.Events; using Glamourer.Services; using Glamourer.State; @@ -20,9 +20,9 @@ public class ContextMenuService : IDisposable private readonly DalamudContextMenu _contextMenu = new(); private readonly StateManager _state; private readonly ObjectManager _objects; - private readonly GameGui _gameGui; + private readonly IGameGui _gameGui; - public ContextMenuService(ItemManager items, StateManager state, ObjectManager objects, GameGui gameGui, Configuration config) + public ContextMenuService(ItemManager items, StateManager state, ObjectManager objects, IGameGui gameGui, Configuration config) { _items = items; _state = state; diff --git a/Glamourer/Interop/JobService.cs b/Glamourer/Interop/JobService.cs index a4249a6..4a91338 100644 --- a/Glamourer/Interop/JobService.cs +++ b/Glamourer/Interop/JobService.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using Dalamud.Data; using Dalamud.Hooking; +using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Character; using Glamourer.Interop.Structs; @@ -19,7 +19,7 @@ public class JobService : IDisposable public event Action? JobChanged; - public JobService(DataManager gameData) + public JobService(IDataManager gameData) { SignatureHelper.Initialise(this); _characterDataOffset = Marshal.OffsetOf(nameof(Character.CharacterData)); @@ -29,9 +29,7 @@ public class JobService : IDisposable } public void Dispose() - { - _changeJobHook.Dispose(); - } + => _changeJobHook.Dispose(); private delegate void ChangeJobDelegate(nint data, uint job); diff --git a/Glamourer/Interop/ObjectManager.cs b/Glamourer/Interop/ObjectManager.cs index 3995076..41e32d7 100644 --- a/Glamourer/Interop/ObjectManager.cs +++ b/Glamourer/Interop/ObjectManager.cs @@ -2,24 +2,26 @@ using System.Collections; using System.Collections.Generic; using Dalamud.Game; -using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Objects; +using Dalamud.Plugin.Services; using Glamourer.Interop.Structs; using Glamourer.Services; using Penumbra.GameData.Actors; -using Penumbra.String; namespace Glamourer.Interop; public class ObjectManager : IReadOnlyDictionary { private readonly Framework _framework; - private readonly ClientState _clientState; - private readonly ObjectTable _objects; + private readonly IClientState _clientState; + private readonly IObjectTable _objects; private readonly ActorService _actors; - private readonly TargetManager _targets; + private readonly ITargetManager _targets; - public ObjectManager(Framework framework, ClientState clientState, ObjectTable objects, ActorService actors, TargetManager targets) + public IObjectTable Objects + => _objects; + + public ObjectManager(Framework framework, IClientState clientState, IObjectTable objects, ActorService actors, ITargetManager targets) { _framework = framework; _clientState = clientState; @@ -132,14 +134,14 @@ public class ObjectManager : IReadOnlyDictionary if (identifier.Type is IdentifierType.Owned) { var nonOwned = _actors.AwaitedService.CreateNpc(identifier.Kind, identifier.DataId); - if (!_nonOwnedIdentifiers.TryGetValue(nonOwned, out var allWorldData)) + if (!_nonOwnedIdentifiers.TryGetValue(nonOwned, out var nonOwnedData)) { - allWorldData = new ActorData(character, nonOwned.ToString()); - _allWorldIdentifiers[nonOwned] = allWorldData; + nonOwnedData = new ActorData(character, nonOwned.ToString()); + _nonOwnedIdentifiers[nonOwned] = nonOwnedData; } else { - allWorldData.Objects.Add(character); + nonOwnedData.Objects.Add(character); } } } diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index 1e25c42..e06d151 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -4,6 +4,7 @@ using System.Linq; using Dalamud.Game.Command; using Dalamud.Game.Gui; using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Plugin.Services; using Glamourer.Automation; using Glamourer.Customization; using Glamourer.Designs; @@ -23,7 +24,7 @@ public class CommandService : IDisposable private const string MainCommandString = "/glamourer"; private const string ApplyCommandString = "/glamour"; - private readonly CommandManager _commands; + private readonly ICommandManager _commands; private readonly MainWindow _mainWindow; private readonly ChatGui _chat; private readonly ActorService _actors; @@ -34,7 +35,7 @@ public class CommandService : IDisposable private readonly DesignConverter _converter; private readonly DesignFileSystem _designFileSystem; - public CommandService(CommandManager commands, MainWindow mainWindow, ChatGui chat, ActorService actors, ObjectManager objects, + public CommandService(ICommandManager commands, MainWindow mainWindow, ChatGui chat, ActorService actors, ObjectManager objects, AutoDesignApplier autoDesignApplier, StateManager stateManager, DesignManager designManager, DesignConverter converter, DesignFileSystem designFileSystem) { diff --git a/Glamourer/Services/CustomizationService.cs b/Glamourer/Services/CustomizationService.cs index cfabef3..c728a5f 100644 --- a/Glamourer/Services/CustomizationService.cs +++ b/Glamourer/Services/CustomizationService.cs @@ -1,9 +1,6 @@ -using System; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; -using Dalamud.Data; -using Dalamud.Plugin; +using Dalamud.Plugin.Services; using Glamourer.Customization; using Penumbra.GameData.Data; using Penumbra.GameData.Enums; @@ -14,8 +11,8 @@ public sealed class CustomizationService : AsyncServiceWrapper CustomizationManager.Create(pi, gameData)) + public CustomizationService(ITextureProvider textures, IDataManager gameData, HumanModelList humanModels) + : base(nameof(CustomizationService), () => CustomizationManager.Create(textures, gameData)) => HumanModels = humanModels; public (Customize NewValue, CustomizeFlag Applied, CustomizeFlag Changed) Combine(Customize oldValues, Customize newValues, diff --git a/Glamourer/Services/DalamudServices.cs b/Glamourer/Services/DalamudServices.cs index 2864f9b..d8e5914 100644 --- a/Glamourer/Services/DalamudServices.cs +++ b/Glamourer/Services/DalamudServices.cs @@ -1,13 +1,11 @@ -using Dalamud.Data; using Dalamud.Game; -using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Keys; using Dalamud.Game.ClientState.Objects; -using Dalamud.Game.Command; using Dalamud.Game.Gui; using Dalamud.Interface.DragDrop; using Dalamud.IoC; using Dalamud.Plugin; +using Dalamud.Plugin.Services; using Microsoft.Extensions.DependencyInjection; namespace Glamourer.Services; @@ -34,19 +32,21 @@ public class DalamudServices services.AddSingleton(this); services.AddSingleton(PluginInterface.UiBuilder); services.AddSingleton(DragDropManager); + services.AddSingleton(TextureProvider); } // @formatter:off [PluginService][RequiredVersion("1.0")] public DalamudPluginInterface PluginInterface { get; private set; } = null!; - [PluginService][RequiredVersion("1.0")] public CommandManager Commands { get; private set; } = null!; - [PluginService][RequiredVersion("1.0")] public DataManager GameData { get; private set; } = null!; - [PluginService][RequiredVersion("1.0")] public ClientState ClientState { get; private set; } = null!; - [PluginService][RequiredVersion("1.0")] public GameGui GameGui { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public ICommandManager Commands { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public IDataManager GameData { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public IClientState ClientState { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public IGameGui GameGui { get; private set; } = null!; [PluginService][RequiredVersion("1.0")] public ChatGui Chat { get; private set; } = null!; [PluginService][RequiredVersion("1.0")] public Framework Framework { get; private set; } = null!; - [PluginService][RequiredVersion("1.0")] public TargetManager Targets { get; private set; } = null!; - [PluginService][RequiredVersion("1.0")] public ObjectTable Objects { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public ITargetManager Targets { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public IObjectTable Objects { get; private set; } = null!; [PluginService][RequiredVersion("1.0")] public KeyState KeyState { get; private set; } = null!; [PluginService][RequiredVersion("1.0")] public IDragDropManager DragDropManager { get; private set; } = null!; + [PluginService][RequiredVersion("1.0")] public ITextureProvider TextureProvider { get; private set; } = null!; // @formatter:on } diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index ef027eb..6698abb 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -1,8 +1,8 @@ using System; using System.Linq; using System.Runtime.CompilerServices; -using Dalamud.Data; using Dalamud.Plugin; +using Dalamud.Plugin.Services; using Lumina.Excel; using Penumbra.GameData.Data; using Penumbra.GameData.Enums; @@ -27,7 +27,7 @@ public class ItemManager : IDisposable public readonly EquipItem DefaultSword; - public ItemManager(Configuration config, DalamudPluginInterface pi, DataManager gameData, IdentifierService identifierService, + public ItemManager(Configuration config, DalamudPluginInterface pi, IDataManager gameData, IdentifierService identifierService, ItemService itemService) { _config = config; diff --git a/Glamourer/Services/ServiceWrapper.cs b/Glamourer/Services/ServiceWrapper.cs index a0c150d..9e6bc9c 100644 --- a/Glamourer/Services/ServiceWrapper.cs +++ b/Glamourer/Services/ServiceWrapper.cs @@ -1,12 +1,9 @@ -using Dalamud.Data; -using Dalamud.Game.ClientState.Objects; -using Dalamud.Game.ClientState; -using Dalamud.Game.Gui; using Dalamud.Plugin; using Penumbra.GameData.Actors; using System; using System.Threading.Tasks; using Dalamud.Game; +using Dalamud.Plugin.Services; using Glamourer.Interop.Penumbra; using Penumbra.GameData.Data; using Penumbra.GameData; @@ -75,23 +72,23 @@ public abstract class AsyncServiceWrapper : IDisposable public sealed class IdentifierService : AsyncServiceWrapper { - public IdentifierService(DalamudPluginInterface pi, DataManager data, ItemService itemService) + public IdentifierService(DalamudPluginInterface pi, IDataManager data, ItemService itemService) : base(nameof(IdentifierService), () => Penumbra.GameData.GameData.GetIdentifier(pi, data, itemService.AwaitedService)) { } } public sealed class ItemService : AsyncServiceWrapper { - public ItemService(DalamudPluginInterface pi, DataManager gameData) + public ItemService(DalamudPluginInterface pi, IDataManager gameData) : base(nameof(ItemService), () => new ItemData(pi, gameData, gameData.Language)) { } } public sealed class ActorService : AsyncServiceWrapper { - public ActorService(DalamudPluginInterface pi, ObjectTable objects, ClientState clientState, Framework framework, DataManager gameData, - GameGui gui, PenumbraService penumbra) + public ActorService(DalamudPluginInterface pi, IObjectTable objects, IClientState clientState, Framework framework, IDataManager gameData, + IGameGui gui, PenumbraService penumbra) : base(nameof(ActorService), () => new ActorManager(pi, objects, clientState, framework, gameData, gui, idx => (short)penumbra.CutsceneParent(idx))) { } -} \ No newline at end of file +} diff --git a/Glamourer/Services/TextureService.cs b/Glamourer/Services/TextureService.cs index 02d080a..9d6b581 100644 --- a/Glamourer/Services/TextureService.cs +++ b/Glamourer/Services/TextureService.cs @@ -1,9 +1,8 @@ using System; -using System.Linq; -using Dalamud.Data; using System.Numerics; using Dalamud.Game; using Dalamud.Interface; +using Dalamud.Plugin.Services; using ImGuiScene; using OtterGui.Classes; using Penumbra.GameData.Enums; @@ -13,8 +12,8 @@ namespace Glamourer.Services; public sealed class TextureService : TextureCache, IDisposable { - public TextureService(Framework framework, UiBuilder uiBuilder, DataManager dataManager) - : base(framework, uiBuilder, dataManager) + public TextureService(UiBuilder uiBuilder, IDataManager dataManager, ITextureProvider textureProvider) + : base(dataManager, textureProvider) => _slotIcons = CreateSlotIcons(uiBuilder); private readonly TextureWrap?[] _slotIcons; @@ -22,7 +21,7 @@ public sealed class TextureService : TextureCache, IDisposable public (nint, Vector2, bool) GetIcon(EquipItem item) { if (item.IconId.Id != 0 && TryLoadIcon(item.IconId.Id, out var ret)) - return (ret.Value.Texture, ret.Value.Dimensions, false); + return (ret.ImGuiHandle, new Vector2(ret.Width, ret.Height), false); var idx = item.Type.ToSlot().ToIndex(); return idx < 12 && _slotIcons[idx] != null @@ -30,9 +29,8 @@ public sealed class TextureService : TextureCache, IDisposable : (nint.Zero, Vector2.Zero, true); } - public new void Dispose() + public void Dispose() { - base.Dispose(); for (var i = 0; i < _slotIcons.Length; ++i) { _slotIcons[i]?.Dispose(); diff --git a/Glamourer/Unlocks/CustomizeUnlockManager.cs b/Glamourer/Unlocks/CustomizeUnlockManager.cs index f3bc683..9973f06 100644 --- a/Glamourer/Unlocks/CustomizeUnlockManager.cs +++ b/Glamourer/Unlocks/CustomizeUnlockManager.cs @@ -3,9 +3,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Dalamud; -using Dalamud.Data; -using Dalamud.Game.ClientState; using Dalamud.Hooking; +using Dalamud.Plugin.Services; using Dalamud.Utility; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.UI; @@ -19,7 +18,7 @@ namespace Glamourer.Unlocks; public class CustomizeUnlockManager : IDisposable, ISavable { private readonly SaveService _saveService; - private readonly ClientState _clientState; + private readonly IClientState _clientState; private readonly ObjectUnlocked _event; private readonly Dictionary _unlocked = new(); @@ -29,8 +28,8 @@ public class CustomizeUnlockManager : IDisposable, ISavable public IReadOnlyDictionary Unlocked => _unlocked; - public unsafe CustomizeUnlockManager(SaveService saveService, CustomizationService customizations, DataManager gameData, - ClientState clientState, ObjectUnlocked @event) + public CustomizeUnlockManager(SaveService saveService, CustomizationService customizations, IDataManager gameData, + IClientState clientState, ObjectUnlocked @event) { SignatureHelper.Initialise(this); _saveService = saveService; @@ -178,7 +177,7 @@ public class CustomizeUnlockManager : IDisposable, ISavable /// Create a list of all unlockable hairstyles and facepaints. private static Dictionary CreateUnlockableCustomizations(CustomizationService customizations, - DataManager gameData) + IDataManager gameData) { var ret = new Dictionary(); var sheet = gameData.GetExcelSheet(ClientLanguage.English)!; diff --git a/Glamourer/Unlocks/ItemUnlockManager.cs b/Glamourer/Unlocks/ItemUnlockManager.cs index 5431a2f..2ffa205 100644 --- a/Glamourer/Unlocks/ItemUnlockManager.cs +++ b/Glamourer/Unlocks/ItemUnlockManager.cs @@ -3,9 +3,8 @@ using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; -using Dalamud.Data; using Dalamud.Game; -using Dalamud.Game.ClientState; +using Dalamud.Plugin.Services; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.UI; @@ -22,7 +21,7 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionary Unlockable; - public ItemUnlockManager(SaveService saveService, ItemManager items, ClientState clientState, DataManager gameData, Framework framework, + public ItemUnlockManager(SaveService saveService, ItemManager items, IClientState clientState, IDataManager gameData, Framework framework, ObjectUnlocked @event, IdentifierService identifier) { SignatureHelper.Initialise(this); @@ -282,7 +281,7 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionary Scan(); - private static Dictionary CreateUnlockData(DataManager gameData, ItemManager items) + private static Dictionary CreateUnlockData(IDataManager gameData, ItemManager items) { var ret = new Dictionary(); var cabinet = gameData.GetExcelSheet()!; diff --git a/OtterGui b/OtterGui index 03b6b17..fe1f34c 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 03b6b17fee66488fff7f598e444fa99454098767 +Subproject commit fe1f34caba82f64dbc9cc7e248c0830db720f3d9 diff --git a/Penumbra.Api b/Penumbra.Api index 983c98f..97610e1 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 983c98f74e7cd052b21f6ca35ef0ceaa9b388964 +Subproject commit 97610e1c9d27d863ae8563bb9c8525cc6f8a3709 diff --git a/Penumbra.GameData b/Penumbra.GameData index 1e65d3f..d84508e 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 1e65d3fd028d3ac58090a8c886f351acbd9f3a2a +Subproject commit d84508ea1a607976525265e8f75a329667eec0e5