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 Lumina.Data.Parsing;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.GameData.Data;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Files;
|
||||
|
|
@ -33,7 +34,7 @@ public static class EquipmentSwap
|
|||
: 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 )
|
||||
{
|
||||
LookupItem( itemFrom, out var actualSlotFrom, out var idFrom, out var variantFrom );
|
||||
|
|
@ -43,7 +44,7 @@ public static class EquipmentSwap
|
|||
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 imcFileTo = new ImcFile( imcManip );
|
||||
var skipFemale = false;
|
||||
|
|
@ -96,7 +97,7 @@ public static class EquipmentSwap
|
|||
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 )
|
||||
{
|
||||
// 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 >();
|
||||
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 imcFileTo = new ImcFile( imcManip );
|
||||
|
||||
|
|
@ -250,7 +251,7 @@ public static class EquipmentSwap
|
|||
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 imc = new ImcFile( entry );
|
||||
|
|
@ -258,12 +259,12 @@ public static class EquipmentSwap
|
|||
byte[] variants;
|
||||
if( idFrom.Value == idTo.Value )
|
||||
{
|
||||
items = Penumbra.Identifier.Identify( idFrom, variantFrom, slotFrom ).ToArray();
|
||||
items = identifier.Identify( idFrom, variantFrom, slotFrom ).ToArray();
|
||||
variants = new[] { variantFrom };
|
||||
}
|
||||
else
|
||||
{
|
||||
items = Penumbra.Identifier.Identify( slotFrom.IsEquipment()
|
||||
items = identifier.Identify( slotFrom.IsEquipment()
|
||||
? GamePaths.Equipment.Mdl.Path( idFrom, GenderRace.MidlanderMale, slotFrom )
|
||||
: 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();
|
||||
|
|
|
|||
|
|
@ -8,12 +8,15 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Mods.Manager;
|
||||
|
||||
namespace Penumbra.Mods.ItemSwap;
|
||||
|
||||
public class ItemSwapContainer
|
||||
{
|
||||
private readonly IObjectIdentifier _identifier;
|
||||
|
||||
private Dictionary< Utf8GamePath, FullPath > _modRedirections = new();
|
||||
private HashSet< MetaManipulation > _modManipulations = new();
|
||||
|
||||
|
|
@ -109,8 +112,9 @@ public class ItemSwapContainer
|
|||
}
|
||||
}
|
||||
|
||||
public ItemSwapContainer()
|
||||
public ItemSwapContainer(IObjectIdentifier identifier)
|
||||
{
|
||||
_identifier = identifier;
|
||||
LoadMod( null, null );
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +133,7 @@ public class ItemSwapContainer
|
|||
{
|
||||
Swaps.Clear();
|
||||
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;
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -138,7 +142,7 @@ public class ItemSwapContainer
|
|||
{
|
||||
Swaps.Clear();
|
||||
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;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin;
|
||||
using ImGuiNET;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
|
@ -12,16 +10,13 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using OtterGui;
|
||||
using OtterGui.Classes;
|
||||
using OtterGui.Log;
|
||||
using OtterGui.Widgets;
|
||||
using Penumbra.Api;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Interop;
|
||||
using Penumbra.UI;
|
||||
using Penumbra.Util;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.GameData.Actors;
|
||||
using Penumbra.GameData.Data;
|
||||
using Penumbra.Interop.ResourceLoading;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
using CharacterUtility = Penumbra.Interop.Services.CharacterUtility;
|
||||
|
|
@ -48,14 +43,12 @@ public class Penumbra : IDalamudPlugin
|
|||
|
||||
public static ResidentResourceManager ResidentResources { 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 ModManager ModManager { get; private set; } = null!;
|
||||
public static ModCacheManager ModCaches { get; private set; } = null!;
|
||||
public static CollectionManager CollectionManager { get; private set; } = null!;
|
||||
public static TempCollectionManager TempCollections { 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 ActorManager Actors { get; private set; } = null!;
|
||||
public static IObjectIdentifier Identifier { get; private set; } = null!;
|
||||
|
|
@ -65,9 +58,6 @@ public class Penumbra : IDalamudPlugin
|
|||
// TODO
|
||||
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 ModFileSystem ModFileSystem;
|
||||
public HttpApi HttpApi = null!;
|
||||
|
|
@ -86,12 +76,10 @@ public class Penumbra : IDalamudPlugin
|
|||
ChatService = _tmp.Services.GetRequiredService<ChatService>();
|
||||
Filenames = _tmp.Services.GetRequiredService<FilenameService>();
|
||||
SaveService = _tmp.Services.GetRequiredService<SaveService>();
|
||||
Performance = _tmp.Services.GetRequiredService<PerformanceTracker>();
|
||||
ValidityChecker = _tmp.Services.GetRequiredService<ValidityChecker>();
|
||||
_tmp.Services.GetRequiredService<BackupService>();
|
||||
Config = _tmp.Services.GetRequiredService<Configuration>();
|
||||
CharacterUtility = _tmp.Services.GetRequiredService<CharacterUtility>();
|
||||
GameEvents = _tmp.Services.GetRequiredService<GameEventManager>();
|
||||
MetaFileManager = _tmp.Services.GetRequiredService<MetaFileManager>();
|
||||
Framework = _tmp.Services.GetRequiredService<FrameworkManager>();
|
||||
Actors = _tmp.Services.GetRequiredService<ActorService>().AwaitedService;
|
||||
|
|
@ -107,11 +95,10 @@ public class Penumbra : IDalamudPlugin
|
|||
ModFileSystem = _tmp.Services.GetRequiredService<ModFileSystem>();
|
||||
RedrawService = _tmp.Services.GetRequiredService<RedrawService>();
|
||||
_tmp.Services.GetRequiredService<ResourceService>();
|
||||
ResourceLoader = _tmp.Services.GetRequiredService<ResourceLoader>();
|
||||
ModCaches = _tmp.Services.GetRequiredService<ModCacheManager>();
|
||||
using (var t = _tmp.Services.GetRequiredService<StartTracker>().Measure(StartTimeType.PathResolver))
|
||||
{
|
||||
PathResolver = _tmp.Services.GetRequiredService<PathResolver>();
|
||||
_tmp.Services.GetRequiredService<PathResolver>();
|
||||
}
|
||||
|
||||
SetupInterface();
|
||||
|
|
|
|||
|
|
@ -32,13 +32,14 @@ public class ItemSwapTab : IDisposable, ITab
|
|||
private readonly Configuration _config;
|
||||
|
||||
public ItemSwapTab(CommunicatorService communicator, ItemService itemService, CollectionManager collectionManager,
|
||||
ModManager modManager, Configuration config)
|
||||
ModManager modManager, Configuration config, IdentifierService identifier)
|
||||
{
|
||||
_communicator = communicator;
|
||||
_itemService = itemService;
|
||||
_collectionManager = collectionManager;
|
||||
_modManager = modManager;
|
||||
_config = config;
|
||||
_swapData = new ItemSwapContainer(identifier.AwaitedService);
|
||||
|
||||
_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? _weaponTarget;
|
||||
private readonly WeaponSelector _slotSelector = new();
|
||||
private readonly ItemSwapContainer _swapData = new();
|
||||
private readonly ItemSwapContainer _swapData;
|
||||
|
||||
private Mod? _mod;
|
||||
private ModSettings? _modSettings;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
{
|
||||
private const string WindowBaseLabel = "###SubModEdit";
|
||||
|
||||
private readonly PerformanceTracker _performance;
|
||||
private readonly ModEditor _editor;
|
||||
private readonly ModCacheManager _modCaches;
|
||||
private readonly Configuration _config;
|
||||
|
|
@ -69,7 +70,7 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
|
||||
public override void PreDraw()
|
||||
{
|
||||
using var performance = Penumbra.Performance.Measure(PerformanceType.UiAdvancedWindow);
|
||||
using var performance = _performance.Measure(PerformanceType.UiAdvancedWindow);
|
||||
|
||||
var sb = new StringBuilder(256);
|
||||
|
||||
|
|
@ -127,7 +128,7 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
|
||||
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");
|
||||
if (!tabBar)
|
||||
|
|
@ -491,10 +492,11 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
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)
|
||||
: base(WindowBaseLabel)
|
||||
{
|
||||
_performance = performance;
|
||||
_itemSwapTab = itemSwapTab;
|
||||
_config = config;
|
||||
_editor = editor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue