Update Dalamud Services and use Dalamuds texture provider.

This commit is contained in:
Ottermandias 2023-08-10 20:44:48 +02:00
parent 79ec604e89
commit 0afcc8cca8
24 changed files with 94 additions and 115 deletions

View file

@ -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
{

View file

@ -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();
}

View file

@ -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<CustomName>().Length];
private void SetNames(DataManager gameData, TemporaryData tmp)
private void SetNames(IDataManager gameData, TemporaryData tmp)
{
var subRace = gameData.GetExcelSheet<Tribe>()!;
@ -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);

View file

@ -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<byte, Job>? _jobs;
private static Dictionary<ushort, JobGroup>? _jobGroups;
public static IReadOnlyDictionary<byte, Job> Jobs(DataManager dataManager)
public static IReadOnlyDictionary<byte, Job> Jobs(IDataManager dataManager)
{
if (_jobs != null)
return _jobs;
@ -22,7 +22,7 @@ public static class GameData
return _jobs;
}
public static IReadOnlyDictionary<ushort, JobGroup> JobGroups(DataManager dataManager)
public static IReadOnlyDictionary<ushort, JobGroup> JobGroups(IDataManager dataManager)
{
if (_jobGroups != null)
return _jobGroups;

View file

@ -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;

View file

@ -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<EquipItem>
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<EquipItem>
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<Addon>()!;

View file

@ -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;
}

View file

@ -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<CustomizeIndex>())
{
@ -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

View file

@ -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())

View file

@ -35,7 +35,6 @@ public class UnlockTable : Table<EquipItem>, 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<EquipItem>, 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<EquipItem>, 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);

View file

@ -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;

View file

@ -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<Actor, Job, Job>? JobChanged;
public JobService(DataManager gameData)
public JobService(IDataManager gameData)
{
SignatureHelper.Initialise(this);
_characterDataOffset = Marshal.OffsetOf<Character>(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);

View file

@ -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<ActorIdentifier, ActorData>
{
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<ActorIdentifier, ActorData>
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);
}
}
}

View file

@ -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)
{

View file

@ -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<ICustomizationMan
{
public readonly HumanModelList HumanModels;
public CustomizationService(DalamudPluginInterface pi, DataManager gameData, HumanModelList humanModels)
: base(nameof(CustomizationService), () => 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,

View file

@ -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
}

View file

@ -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;

View file

@ -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<T> : IDisposable
public sealed class IdentifierService : AsyncServiceWrapper<IObjectIdentifier>
{
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<ItemData>
{
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<ActorManager>
{
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)))
{ }
}
}

View file

@ -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();

View file

@ -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<uint, long> _unlocked = new();
@ -29,8 +28,8 @@ public class CustomizeUnlockManager : IDisposable, ISavable
public IReadOnlyDictionary<uint, long> 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
/// <summary> Create a list of all unlockable hairstyles and facepaints. </summary>
private static Dictionary<CustomizeData, (uint Data, string Name)> CreateUnlockableCustomizations(CustomizationService customizations,
DataManager gameData)
IDataManager gameData)
{
var ret = new Dictionary<CustomizeData, (uint Data, string Name)>();
var sheet = gameData.GetExcelSheet<CharaMakeCustomize>(ClientLanguage.English)!;

View file

@ -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<Item
{
private readonly SaveService _saveService;
private readonly ItemManager _items;
private readonly ClientState _clientState;
private readonly IClientState _clientState;
private readonly Framework _framework;
private readonly ObjectUnlocked _event;
private readonly IdentifierService _identifier;
@ -47,7 +46,7 @@ public class ItemUnlockManager : ISavable, IDisposable, IReadOnlyDictionary<Item
public readonly IReadOnlyDictionary<ItemId, UnlockRequirements> 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<Item
private void OnLogin(object? _, EventArgs _2)
=> Scan();
private static Dictionary<ItemId, UnlockRequirements> CreateUnlockData(DataManager gameData, ItemManager items)
private static Dictionary<ItemId, UnlockRequirements> CreateUnlockData(IDataManager gameData, ItemManager items)
{
var ret = new Dictionary<ItemId, UnlockRequirements>();
var cabinet = gameData.GetExcelSheet<Cabinet>()!;

@ -1 +1 @@
Subproject commit 03b6b17fee66488fff7f598e444fa99454098767
Subproject commit fe1f34caba82f64dbc9cc7e248c0830db720f3d9

@ -1 +1 @@
Subproject commit 983c98f74e7cd052b21f6ca35ef0ceaa9b388964
Subproject commit 97610e1c9d27d863ae8563bb9c8525cc6f8a3709

@ -1 +1 @@
Subproject commit 1e65d3fd028d3ac58090a8c886f351acbd9f3a2a
Subproject commit d84508ea1a607976525265e8f75a329667eec0e5