mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Remove some static dependencies.
This commit is contained in:
parent
4294b18bcb
commit
c527d19117
5 changed files with 30 additions and 35 deletions
|
|
@ -4,6 +4,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Lumina.Data.Parsing;
|
using Lumina.Data.Parsing;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
using Penumbra.GameData;
|
||||||
using Penumbra.GameData.Data;
|
using Penumbra.GameData.Data;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
using Penumbra.GameData.Files;
|
using Penumbra.GameData.Files;
|
||||||
|
|
@ -33,7 +34,7 @@ public static class EquipmentSwap
|
||||||
: Array.Empty< EquipSlot >();
|
: Array.Empty< EquipSlot >();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Item[] CreateTypeSwap( List< Swap > swaps, Func< Utf8GamePath, FullPath > redirections, Func< MetaManipulation, MetaManipulation > manips,
|
public static Item[] CreateTypeSwap( IObjectIdentifier identifier, List< Swap > swaps, Func< Utf8GamePath, FullPath > redirections, Func< MetaManipulation, MetaManipulation > manips,
|
||||||
EquipSlot slotFrom, Item itemFrom, EquipSlot slotTo, Item itemTo )
|
EquipSlot slotFrom, Item itemFrom, EquipSlot slotTo, Item itemTo )
|
||||||
{
|
{
|
||||||
LookupItem( itemFrom, out var actualSlotFrom, out var idFrom, out var variantFrom );
|
LookupItem( itemFrom, out var actualSlotFrom, out var idFrom, out var variantFrom );
|
||||||
|
|
@ -43,7 +44,7 @@ public static class EquipmentSwap
|
||||||
throw new ItemSwap.InvalidItemTypeException();
|
throw new ItemSwap.InvalidItemTypeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
var ( imcFileFrom, variants, affectedItems ) = GetVariants( slotFrom, idFrom, idTo, variantFrom );
|
var ( imcFileFrom, variants, affectedItems ) = GetVariants( identifier, slotFrom, idFrom, idTo, variantFrom );
|
||||||
var imcManip = new ImcManipulation( slotTo, variantTo, idTo.Value, default );
|
var imcManip = new ImcManipulation( slotTo, variantTo, idTo.Value, default );
|
||||||
var imcFileTo = new ImcFile( imcManip );
|
var imcFileTo = new ImcFile( imcManip );
|
||||||
var skipFemale = false;
|
var skipFemale = false;
|
||||||
|
|
@ -96,7 +97,7 @@ public static class EquipmentSwap
|
||||||
return affectedItems;
|
return affectedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Item[] CreateItemSwap( List< Swap > swaps, Func< Utf8GamePath, FullPath > redirections, Func< MetaManipulation, MetaManipulation > manips, Item itemFrom,
|
public static Item[] CreateItemSwap( IObjectIdentifier identifier, List< Swap > swaps, Func< Utf8GamePath, FullPath > redirections, Func< MetaManipulation, MetaManipulation > manips, Item itemFrom,
|
||||||
Item itemTo, bool rFinger = true, bool lFinger = true )
|
Item itemTo, bool rFinger = true, bool lFinger = true )
|
||||||
{
|
{
|
||||||
// Check actual ids, variants and slots. We only support using the same slot.
|
// Check actual ids, variants and slots. We only support using the same slot.
|
||||||
|
|
@ -122,7 +123,7 @@ public static class EquipmentSwap
|
||||||
var affectedItems = Array.Empty< Item >();
|
var affectedItems = Array.Empty< Item >();
|
||||||
foreach( var slot in ConvertSlots( slotFrom, rFinger, lFinger ) )
|
foreach( var slot in ConvertSlots( slotFrom, rFinger, lFinger ) )
|
||||||
{
|
{
|
||||||
( var imcFileFrom, var variants, affectedItems ) = GetVariants( slot, idFrom, idTo, variantFrom );
|
( var imcFileFrom, var variants, affectedItems ) = GetVariants( identifier, slot, idFrom, idTo, variantFrom );
|
||||||
var imcManip = new ImcManipulation( slot, variantTo, idTo.Value, default );
|
var imcManip = new ImcManipulation( slot, variantTo, idTo.Value, default );
|
||||||
var imcFileTo = new ImcFile( imcManip );
|
var imcFileTo = new ImcFile( imcManip );
|
||||||
|
|
||||||
|
|
@ -250,7 +251,7 @@ public static class EquipmentSwap
|
||||||
variant = ( byte )( ( Quad )i.ModelMain ).B;
|
variant = ( byte )( ( Quad )i.ModelMain ).B;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (ImcFile, byte[], Item[]) GetVariants( EquipSlot slotFrom, SetId idFrom, SetId idTo, byte variantFrom )
|
private static (ImcFile, byte[], Item[]) GetVariants( IObjectIdentifier identifier, EquipSlot slotFrom, SetId idFrom, SetId idTo, byte variantFrom )
|
||||||
{
|
{
|
||||||
var entry = new ImcManipulation( slotFrom, variantFrom, idFrom.Value, default );
|
var entry = new ImcManipulation( slotFrom, variantFrom, idFrom.Value, default );
|
||||||
var imc = new ImcFile( entry );
|
var imc = new ImcFile( entry );
|
||||||
|
|
@ -258,12 +259,12 @@ public static class EquipmentSwap
|
||||||
byte[] variants;
|
byte[] variants;
|
||||||
if( idFrom.Value == idTo.Value )
|
if( idFrom.Value == idTo.Value )
|
||||||
{
|
{
|
||||||
items = Penumbra.Identifier.Identify( idFrom, variantFrom, slotFrom ).ToArray();
|
items = identifier.Identify( idFrom, variantFrom, slotFrom ).ToArray();
|
||||||
variants = new[] { variantFrom };
|
variants = new[] { variantFrom };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
items = Penumbra.Identifier.Identify( slotFrom.IsEquipment()
|
items = identifier.Identify( slotFrom.IsEquipment()
|
||||||
? GamePaths.Equipment.Mdl.Path( idFrom, GenderRace.MidlanderMale, slotFrom )
|
? GamePaths.Equipment.Mdl.Path( idFrom, GenderRace.MidlanderMale, slotFrom )
|
||||||
: GamePaths.Accessory.Mdl.Path( idFrom, GenderRace.MidlanderMale, slotFrom ) ).Select( kvp => kvp.Value ).OfType< Item >().ToArray();
|
: GamePaths.Accessory.Mdl.Path( idFrom, GenderRace.MidlanderMale, slotFrom ) ).Select( kvp => kvp.Value ).OfType< Item >().ToArray();
|
||||||
variants = Enumerable.Range( 0, imc.Count + 1 ).Select( i => ( byte )i ).ToArray();
|
variants = Enumerable.Range( 0, imc.Count + 1 ).Select( i => ( byte )i ).ToArray();
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,15 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Penumbra.GameData;
|
||||||
using Penumbra.Mods.Manager;
|
using Penumbra.Mods.Manager;
|
||||||
|
|
||||||
namespace Penumbra.Mods.ItemSwap;
|
namespace Penumbra.Mods.ItemSwap;
|
||||||
|
|
||||||
public class ItemSwapContainer
|
public class ItemSwapContainer
|
||||||
{
|
{
|
||||||
|
private readonly IObjectIdentifier _identifier;
|
||||||
|
|
||||||
private Dictionary< Utf8GamePath, FullPath > _modRedirections = new();
|
private Dictionary< Utf8GamePath, FullPath > _modRedirections = new();
|
||||||
private HashSet< MetaManipulation > _modManipulations = new();
|
private HashSet< MetaManipulation > _modManipulations = new();
|
||||||
|
|
||||||
|
|
@ -109,8 +112,9 @@ public class ItemSwapContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemSwapContainer()
|
public ItemSwapContainer(IObjectIdentifier identifier)
|
||||||
{
|
{
|
||||||
|
_identifier = identifier;
|
||||||
LoadMod( null, null );
|
LoadMod( null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,7 +133,7 @@ public class ItemSwapContainer
|
||||||
{
|
{
|
||||||
Swaps.Clear();
|
Swaps.Clear();
|
||||||
Loaded = false;
|
Loaded = false;
|
||||||
var ret = EquipmentSwap.CreateItemSwap( Swaps, PathResolver( collection ), MetaResolver( collection ), from, to, useRightRing, useLeftRing );
|
var ret = EquipmentSwap.CreateItemSwap( _identifier, Swaps, PathResolver( collection ), MetaResolver( collection ), from, to, useRightRing, useLeftRing );
|
||||||
Loaded = true;
|
Loaded = true;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +142,7 @@ public class ItemSwapContainer
|
||||||
{
|
{
|
||||||
Swaps.Clear();
|
Swaps.Clear();
|
||||||
Loaded = false;
|
Loaded = false;
|
||||||
var ret = EquipmentSwap.CreateTypeSwap( Swaps, PathResolver( collection ), MetaResolver( collection ), slotFrom, from, slotTo, to );
|
var ret = EquipmentSwap.CreateTypeSwap( _identifier, Swaps, PathResolver( collection ), MetaResolver( collection ), slotFrom, from, slotTo, to );
|
||||||
Loaded = true;
|
Loaded = true;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Dalamud.Interface.Windowing;
|
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
@ -12,16 +10,13 @@ using Microsoft.Extensions.DependencyInjection;
|
||||||
using OtterGui;
|
using OtterGui;
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
using OtterGui.Log;
|
using OtterGui.Log;
|
||||||
using OtterGui.Widgets;
|
|
||||||
using Penumbra.Api;
|
using Penumbra.Api;
|
||||||
using Penumbra.Api.Enums;
|
using Penumbra.Api.Enums;
|
||||||
using Penumbra.Interop;
|
|
||||||
using Penumbra.UI;
|
using Penumbra.UI;
|
||||||
using Penumbra.Util;
|
using Penumbra.Util;
|
||||||
using Penumbra.Collections;
|
using Penumbra.Collections;
|
||||||
using Penumbra.GameData;
|
using Penumbra.GameData;
|
||||||
using Penumbra.GameData.Actors;
|
using Penumbra.GameData.Actors;
|
||||||
using Penumbra.GameData.Data;
|
|
||||||
using Penumbra.Interop.ResourceLoading;
|
using Penumbra.Interop.ResourceLoading;
|
||||||
using Penumbra.Interop.PathResolving;
|
using Penumbra.Interop.PathResolving;
|
||||||
using CharacterUtility = Penumbra.Interop.Services.CharacterUtility;
|
using CharacterUtility = Penumbra.Interop.Services.CharacterUtility;
|
||||||
|
|
@ -48,14 +43,12 @@ public class Penumbra : IDalamudPlugin
|
||||||
|
|
||||||
public static ResidentResourceManager ResidentResources { get; private set; } = null!;
|
public static ResidentResourceManager ResidentResources { get; private set; } = null!;
|
||||||
public static CharacterUtility CharacterUtility { get; private set; } = null!;
|
public static CharacterUtility CharacterUtility { get; private set; } = null!;
|
||||||
public static GameEventManager GameEvents { get; private set; } = null!;
|
|
||||||
public static MetaFileManager MetaFileManager { get; private set; } = null!;
|
public static MetaFileManager MetaFileManager { get; private set; } = null!;
|
||||||
public static ModManager ModManager { get; private set; } = null!;
|
public static ModManager ModManager { get; private set; } = null!;
|
||||||
public static ModCacheManager ModCaches { get; private set; } = null!;
|
public static ModCacheManager ModCaches { get; private set; } = null!;
|
||||||
public static CollectionManager CollectionManager { get; private set; } = null!;
|
public static CollectionManager CollectionManager { get; private set; } = null!;
|
||||||
public static TempCollectionManager TempCollections { get; private set; } = null!;
|
public static TempCollectionManager TempCollections { get; private set; } = null!;
|
||||||
public static TempModManager TempMods { get; private set; } = null!;
|
public static TempModManager TempMods { get; private set; } = null!;
|
||||||
public static ResourceLoader ResourceLoader { get; private set; } = null!;
|
|
||||||
public static FrameworkManager Framework { get; private set; } = null!;
|
public static FrameworkManager Framework { get; private set; } = null!;
|
||||||
public static ActorManager Actors { get; private set; } = null!;
|
public static ActorManager Actors { get; private set; } = null!;
|
||||||
public static IObjectIdentifier Identifier { get; private set; } = null!;
|
public static IObjectIdentifier Identifier { get; private set; } = null!;
|
||||||
|
|
@ -65,9 +58,6 @@ public class Penumbra : IDalamudPlugin
|
||||||
// TODO
|
// TODO
|
||||||
public static ValidityChecker ValidityChecker { get; private set; } = null!;
|
public static ValidityChecker ValidityChecker { get; private set; } = null!;
|
||||||
|
|
||||||
public static PerformanceTracker Performance { get; private set; } = null!;
|
|
||||||
|
|
||||||
public readonly PathResolver PathResolver;
|
|
||||||
public readonly RedrawService RedrawService;
|
public readonly RedrawService RedrawService;
|
||||||
public readonly ModFileSystem ModFileSystem;
|
public readonly ModFileSystem ModFileSystem;
|
||||||
public HttpApi HttpApi = null!;
|
public HttpApi HttpApi = null!;
|
||||||
|
|
@ -86,12 +76,10 @@ public class Penumbra : IDalamudPlugin
|
||||||
ChatService = _tmp.Services.GetRequiredService<ChatService>();
|
ChatService = _tmp.Services.GetRequiredService<ChatService>();
|
||||||
Filenames = _tmp.Services.GetRequiredService<FilenameService>();
|
Filenames = _tmp.Services.GetRequiredService<FilenameService>();
|
||||||
SaveService = _tmp.Services.GetRequiredService<SaveService>();
|
SaveService = _tmp.Services.GetRequiredService<SaveService>();
|
||||||
Performance = _tmp.Services.GetRequiredService<PerformanceTracker>();
|
|
||||||
ValidityChecker = _tmp.Services.GetRequiredService<ValidityChecker>();
|
ValidityChecker = _tmp.Services.GetRequiredService<ValidityChecker>();
|
||||||
_tmp.Services.GetRequiredService<BackupService>();
|
_tmp.Services.GetRequiredService<BackupService>();
|
||||||
Config = _tmp.Services.GetRequiredService<Configuration>();
|
Config = _tmp.Services.GetRequiredService<Configuration>();
|
||||||
CharacterUtility = _tmp.Services.GetRequiredService<CharacterUtility>();
|
CharacterUtility = _tmp.Services.GetRequiredService<CharacterUtility>();
|
||||||
GameEvents = _tmp.Services.GetRequiredService<GameEventManager>();
|
|
||||||
MetaFileManager = _tmp.Services.GetRequiredService<MetaFileManager>();
|
MetaFileManager = _tmp.Services.GetRequiredService<MetaFileManager>();
|
||||||
Framework = _tmp.Services.GetRequiredService<FrameworkManager>();
|
Framework = _tmp.Services.GetRequiredService<FrameworkManager>();
|
||||||
Actors = _tmp.Services.GetRequiredService<ActorService>().AwaitedService;
|
Actors = _tmp.Services.GetRequiredService<ActorService>().AwaitedService;
|
||||||
|
|
@ -107,11 +95,10 @@ public class Penumbra : IDalamudPlugin
|
||||||
ModFileSystem = _tmp.Services.GetRequiredService<ModFileSystem>();
|
ModFileSystem = _tmp.Services.GetRequiredService<ModFileSystem>();
|
||||||
RedrawService = _tmp.Services.GetRequiredService<RedrawService>();
|
RedrawService = _tmp.Services.GetRequiredService<RedrawService>();
|
||||||
_tmp.Services.GetRequiredService<ResourceService>();
|
_tmp.Services.GetRequiredService<ResourceService>();
|
||||||
ResourceLoader = _tmp.Services.GetRequiredService<ResourceLoader>();
|
|
||||||
ModCaches = _tmp.Services.GetRequiredService<ModCacheManager>();
|
ModCaches = _tmp.Services.GetRequiredService<ModCacheManager>();
|
||||||
using (var t = _tmp.Services.GetRequiredService<StartTracker>().Measure(StartTimeType.PathResolver))
|
using (var t = _tmp.Services.GetRequiredService<StartTracker>().Measure(StartTimeType.PathResolver))
|
||||||
{
|
{
|
||||||
PathResolver = _tmp.Services.GetRequiredService<PathResolver>();
|
_tmp.Services.GetRequiredService<PathResolver>();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupInterface();
|
SetupInterface();
|
||||||
|
|
|
||||||
|
|
@ -29,16 +29,17 @@ public class ItemSwapTab : IDisposable, ITab
|
||||||
private readonly ItemService _itemService;
|
private readonly ItemService _itemService;
|
||||||
private readonly CollectionManager _collectionManager;
|
private readonly CollectionManager _collectionManager;
|
||||||
private readonly ModManager _modManager;
|
private readonly ModManager _modManager;
|
||||||
private readonly Configuration _config;
|
private readonly Configuration _config;
|
||||||
|
|
||||||
public ItemSwapTab(CommunicatorService communicator, ItemService itemService, CollectionManager collectionManager,
|
public ItemSwapTab(CommunicatorService communicator, ItemService itemService, CollectionManager collectionManager,
|
||||||
ModManager modManager, Configuration config)
|
ModManager modManager, Configuration config, IdentifierService identifier)
|
||||||
{
|
{
|
||||||
_communicator = communicator;
|
_communicator = communicator;
|
||||||
_itemService = itemService;
|
_itemService = itemService;
|
||||||
_collectionManager = collectionManager;
|
_collectionManager = collectionManager;
|
||||||
_modManager = modManager;
|
_modManager = modManager;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
_swapData = new ItemSwapContainer(identifier.AwaitedService);
|
||||||
|
|
||||||
_selectors = new Dictionary<SwapType, (ItemSelector Source, ItemSelector Target, string TextFrom, string TextTo)>
|
_selectors = new Dictionary<SwapType, (ItemSelector Source, ItemSelector Target, string TextFrom, string TextTo)>
|
||||||
{
|
{
|
||||||
|
|
@ -149,7 +150,7 @@ public class ItemSwapTab : IDisposable, ITab
|
||||||
private ItemSelector? _weaponSource;
|
private ItemSelector? _weaponSource;
|
||||||
private ItemSelector? _weaponTarget;
|
private ItemSelector? _weaponTarget;
|
||||||
private readonly WeaponSelector _slotSelector = new();
|
private readonly WeaponSelector _slotSelector = new();
|
||||||
private readonly ItemSwapContainer _swapData = new();
|
private readonly ItemSwapContainer _swapData;
|
||||||
|
|
||||||
private Mod? _mod;
|
private Mod? _mod;
|
||||||
private ModSettings? _modSettings;
|
private ModSettings? _modSettings;
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,12 @@ public partial class ModEditWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
private const string WindowBaseLabel = "###SubModEdit";
|
private const string WindowBaseLabel = "###SubModEdit";
|
||||||
|
|
||||||
private readonly ModEditor _editor;
|
private readonly PerformanceTracker _performance;
|
||||||
private readonly ModCacheManager _modCaches;
|
private readonly ModEditor _editor;
|
||||||
private readonly Configuration _config;
|
private readonly ModCacheManager _modCaches;
|
||||||
private readonly ItemSwapTab _itemSwapTab;
|
private readonly Configuration _config;
|
||||||
private readonly DataManager _gameData;
|
private readonly ItemSwapTab _itemSwapTab;
|
||||||
|
private readonly DataManager _gameData;
|
||||||
|
|
||||||
private Mod? _mod;
|
private Mod? _mod;
|
||||||
private Vector2 _iconSize = Vector2.Zero;
|
private Vector2 _iconSize = Vector2.Zero;
|
||||||
|
|
@ -69,7 +70,7 @@ public partial class ModEditWindow : Window, IDisposable
|
||||||
|
|
||||||
public override void PreDraw()
|
public override void PreDraw()
|
||||||
{
|
{
|
||||||
using var performance = Penumbra.Performance.Measure(PerformanceType.UiAdvancedWindow);
|
using var performance = _performance.Measure(PerformanceType.UiAdvancedWindow);
|
||||||
|
|
||||||
var sb = new StringBuilder(256);
|
var sb = new StringBuilder(256);
|
||||||
|
|
||||||
|
|
@ -127,7 +128,7 @@ public partial class ModEditWindow : Window, IDisposable
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
using var performance = Penumbra.Performance.Measure(PerformanceType.UiAdvancedWindow);
|
using var performance = _performance.Measure(PerformanceType.UiAdvancedWindow);
|
||||||
|
|
||||||
using var tabBar = ImRaii.TabBar("##tabs");
|
using var tabBar = ImRaii.TabBar("##tabs");
|
||||||
if (!tabBar)
|
if (!tabBar)
|
||||||
|
|
@ -491,10 +492,11 @@ public partial class ModEditWindow : Window, IDisposable
|
||||||
return new FullPath(path);
|
return new FullPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModEditWindow(FileDialogService fileDialog, ItemSwapTab itemSwapTab, DataManager gameData,
|
public ModEditWindow(PerformanceTracker performance, FileDialogService fileDialog, ItemSwapTab itemSwapTab, DataManager gameData,
|
||||||
Configuration config, ModEditor editor, ResourceTreeFactory resourceTreeFactory, ModCacheManager modCaches)
|
Configuration config, ModEditor editor, ResourceTreeFactory resourceTreeFactory, ModCacheManager modCaches)
|
||||||
: base(WindowBaseLabel)
|
: base(WindowBaseLabel)
|
||||||
{
|
{
|
||||||
|
_performance = performance;
|
||||||
_itemSwapTab = itemSwapTab;
|
_itemSwapTab = itemSwapTab;
|
||||||
_config = config;
|
_config = config;
|
||||||
_editor = editor;
|
_editor = editor;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue