mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Add some logging, fix som bugs
This commit is contained in:
parent
85fb98b557
commit
9037166d92
12 changed files with 58 additions and 41 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
|||
Subproject commit 36c2f5f7e5af017b4ce6737f0ef7add873335cc7
|
||||
Subproject commit 8ebcbf3e78ed498be35fa2b9a13d9765d109c428
|
||||
|
|
@ -834,7 +834,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
public PenumbraApiEc CreateNamedTemporaryCollection(string name)
|
||||
{
|
||||
CheckInitialized();
|
||||
if (name.Length == 0 || ModCreator.ReplaceBadXivSymbols(name) != name)
|
||||
if (name.Length == 0 || ModCreator.ReplaceBadXivSymbols(name) != name || name.Contains('|'))
|
||||
return PenumbraApiEc.InvalidArgument;
|
||||
|
||||
return _tempCollections.CreateTemporaryCollection(name).Length > 0
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ public class TempModManager : IDisposable
|
|||
public RedirectResult Register(string tag, ModCollection? collection, Dictionary<Utf8GamePath, FullPath> dict,
|
||||
HashSet<MetaManipulation> manips, int priority)
|
||||
{
|
||||
var mod = GetOrCreateMod(tag, collection, priority, out var created);
|
||||
var mod = GetOrCreateMod(tag, collection, priority, out var created);
|
||||
Penumbra.Log.Verbose($"{(created ? "Created" : "Changed")} temporary Mod {mod.Name}.");
|
||||
mod.SetAll(dict, manips);
|
||||
ApplyModChange(mod, collection, created, false);
|
||||
return RedirectResult.Success;
|
||||
|
|
@ -52,10 +53,11 @@ public class TempModManager : IDisposable
|
|||
|
||||
public RedirectResult Unregister(string tag, ModCollection? collection, int? priority)
|
||||
{
|
||||
Penumbra.Log.Verbose($"Removing temporary mod with tag {tag}...");
|
||||
var list = collection == null ? _modsForAllCollections : _mods.TryGetValue(collection, out var l) ? l : null;
|
||||
if (list == null)
|
||||
return RedirectResult.NotRegistered;
|
||||
|
||||
|
||||
var removed = list.RemoveAll(m =>
|
||||
{
|
||||
if (m.Name != tag || priority != null && m.Priority != priority.Value)
|
||||
|
|
@ -80,12 +82,19 @@ public class TempModManager : IDisposable
|
|||
if (collection != null)
|
||||
{
|
||||
if (removed)
|
||||
{
|
||||
Penumbra.Log.Verbose($"Removing temporary Mod {mod.Name} from {collection.AnonymizedName}.");
|
||||
collection.Remove(mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
Penumbra.Log.Verbose($"Adding {(created ? "new " : string.Empty)}temporary Mod {mod.Name} to {collection.AnonymizedName}.");
|
||||
collection.Apply(mod, created);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Penumbra.Log.Verbose($"Triggering global mod change for {(created ? "new " : string.Empty)}temporary Mod {mod.Name}.");
|
||||
_communicator.TemporaryGlobalModChange.Invoke(mod, created, removed);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@ public record ModConflicts(IMod Mod2, List<object> Conflicts, bool HasPriority,
|
|||
/// The Cache contains all required temporary data to use a collection.
|
||||
/// It will only be setup if a collection gets activated in any way.
|
||||
/// </summary>
|
||||
public class ModCollectionCache : IDisposable
|
||||
public class CollectionCache : IDisposable
|
||||
{
|
||||
private readonly CollectionCacheManager _manager;
|
||||
private readonly ModCollection _collection;
|
||||
public readonly SortedList<string, (SingleArray<IMod>, object?)> _changedItems = new();
|
||||
public readonly Dictionary<Utf8GamePath, ModPath> ResolvedFiles = new();
|
||||
public readonly MetaCache MetaManipulations;
|
||||
public readonly MetaCache MetaManipulations;
|
||||
public readonly Dictionary<IMod, SingleArray<ModConflicts>> _conflicts = new();
|
||||
|
||||
public IEnumerable<SingleArray<ModConflicts>> AllConflicts
|
||||
|
|
@ -46,8 +47,9 @@ public class ModCollectionCache : IDisposable
|
|||
}
|
||||
|
||||
// The cache reacts through events on its collection changing.
|
||||
public ModCollectionCache(ModCollection collection)
|
||||
public CollectionCache(CollectionCacheManager manager, ModCollection collection)
|
||||
{
|
||||
_manager = manager;
|
||||
_collection = collection;
|
||||
MetaManipulations = new MetaCache(_collection);
|
||||
}
|
||||
|
|
@ -205,7 +207,7 @@ public class ModCollectionCache : IDisposable
|
|||
if (addMetaChanges)
|
||||
{
|
||||
++_collection.ChangeCounter;
|
||||
if (Penumbra.ModCaches[mod.Index].TotalManipulations > 0)
|
||||
if ((mod is TemporaryMod temp ? temp.TotalManipulations : Penumbra.ModCaches[mod.Index].TotalManipulations) > 0)
|
||||
AddMetaFiles();
|
||||
|
||||
if (_collection == Penumbra.CollectionManager.Active.Default && Penumbra.CharacterUtility.Ready && Penumbra.Config.EnableMods)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public class TempCollectionManager : IDisposable
|
|||
if (GlobalChangeCounter == int.MaxValue)
|
||||
GlobalChangeCounter = 0;
|
||||
var collection = ModCollection.CreateTemporary(name, ~Count, GlobalChangeCounter++);
|
||||
Penumbra.Log.Debug($"Creating temporary collection {collection.AnonymizedName}.");
|
||||
if (_customCollections.TryAdd(collection.Name.ToLowerInvariant(), collection))
|
||||
{
|
||||
// Temporary collection created.
|
||||
|
|
@ -66,8 +67,12 @@ public class TempCollectionManager : IDisposable
|
|||
public bool RemoveTemporaryCollection(string collectionName)
|
||||
{
|
||||
if (!_customCollections.Remove(collectionName.ToLowerInvariant(), out var collection))
|
||||
{
|
||||
Penumbra.Log.Debug($"Tried to delete temporary collection {collectionName.ToLowerInvariant()}, but did not exist.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Penumbra.Log.Debug($"Deleted temporary collection {collection.AnonymizedName}.");
|
||||
GlobalChangeCounter += Math.Max(collection.ChangeCounter + 1 - GlobalChangeCounter, 0);
|
||||
for (var i = 0; i < Collections.Count; ++i)
|
||||
{
|
||||
|
|
@ -76,6 +81,7 @@ public class TempCollectionManager : IDisposable
|
|||
|
||||
// Temporary collection assignment removed.
|
||||
_communicator.CollectionChange.Invoke(CollectionType.Temporary, collection, null, Collections[i].DisplayName);
|
||||
Penumbra.Log.Verbose($"Unassigned temporary collection {collection.AnonymizedName} from {Collections[i].DisplayName}.");
|
||||
Collections.Delete(i--);
|
||||
}
|
||||
|
||||
|
|
@ -88,6 +94,7 @@ public class TempCollectionManager : IDisposable
|
|||
return false;
|
||||
|
||||
// Temporary collection assignment added.
|
||||
Penumbra.Log.Verbose($"Assigned temporary collection {collection.AnonymizedName} to {Collections.Last().DisplayName}.");
|
||||
_communicator.CollectionChange.Invoke(CollectionType.Temporary, null, collection, Collections.Last().DisplayName);
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using Penumbra.Interop.Structs;
|
||||
using Penumbra.Meta.Files;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
|
|
@ -19,7 +18,7 @@ namespace Penumbra.Collections;
|
|||
public partial class ModCollection
|
||||
{
|
||||
// Only active collections need to have a cache.
|
||||
internal ModCollectionCache? _cache;
|
||||
internal CollectionCache? _cache;
|
||||
|
||||
public bool HasCache
|
||||
=> _cache != null;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public unsafe class GameEventManager : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
Penumbra.Log.Verbose($"{Prefix} {nameof(ResourceHandleDestructor)} triggered with 0x{(nint)handle:X}.");
|
||||
Penumbra.Log.Excessive($"{Prefix} {nameof(ResourceHandleDestructor)} triggered with 0x{(nint)handle:X}.");
|
||||
return _resourceHandleDestructorHook!.Original(handle);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,16 +15,16 @@ namespace Penumbra.Mods.Manager;
|
|||
public class ModCacheManager : IDisposable, IReadOnlyList<ModCache>
|
||||
{
|
||||
private readonly CommunicatorService _communicator;
|
||||
private readonly IdentifierService _identifier;
|
||||
private readonly IReadOnlyList<Mod> _modManager;
|
||||
private readonly IdentifierService _identifier;
|
||||
private readonly ModStorage _modManager;
|
||||
|
||||
private readonly List<ModCache> _cache = new();
|
||||
|
||||
public ModCacheManager(CommunicatorService communicator, IdentifierService identifier, ModManager modManager)
|
||||
public ModCacheManager(CommunicatorService communicator, IdentifierService identifier, ModStorage modStorage)
|
||||
{
|
||||
_communicator = communicator;
|
||||
_identifier = identifier;
|
||||
_modManager = modManager;
|
||||
_identifier = identifier;
|
||||
_modManager = modStorage;
|
||||
|
||||
_communicator.ModOptionChanged.Subscribe(OnModOptionChange);
|
||||
_communicator.ModPathChanged.Subscribe(OnModPathChange);
|
||||
|
|
@ -232,17 +232,17 @@ public class ModCacheManager : IDisposable, IReadOnlyList<ModCache>
|
|||
|
||||
private static void UpdateCounts(ModCache cache, Mod mod)
|
||||
{
|
||||
cache.TotalFileCount = mod.Default.Files.Count;
|
||||
cache.TotalSwapCount = mod.Default.FileSwaps.Count;
|
||||
cache.TotalFileCount = mod.Default.Files.Count;
|
||||
cache.TotalSwapCount = mod.Default.FileSwaps.Count;
|
||||
cache.TotalManipulations = mod.Default.Manipulations.Count;
|
||||
cache.HasOptions = false;
|
||||
cache.HasOptions = false;
|
||||
foreach (var group in mod.Groups)
|
||||
{
|
||||
cache.HasOptions |= group.IsOption;
|
||||
foreach (var s in group)
|
||||
{
|
||||
cache.TotalFileCount += s.Files.Count;
|
||||
cache.TotalSwapCount += s.FileSwaps.Count;
|
||||
cache.TotalFileCount += s.Files.Count;
|
||||
cache.TotalSwapCount += s.FileSwaps.Count;
|
||||
cache.TotalManipulations += s.Manipulations.Count;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,23 +4,23 @@ namespace Penumbra.Mods;
|
|||
|
||||
public class ModCache
|
||||
{
|
||||
public int TotalFileCount;
|
||||
public int TotalSwapCount;
|
||||
public int TotalManipulations;
|
||||
public int TotalFileCount;
|
||||
public int TotalSwapCount;
|
||||
public int TotalManipulations;
|
||||
public bool HasOptions;
|
||||
|
||||
public SortedList<string, object?> ChangedItems = new();
|
||||
public string LowerChangedItemsString = string.Empty;
|
||||
public string AllTagsLower = string.Empty;
|
||||
public readonly SortedList<string, object?> ChangedItems = new();
|
||||
public string LowerChangedItemsString = string.Empty;
|
||||
public string AllTagsLower = string.Empty;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
TotalFileCount = 0;
|
||||
TotalSwapCount = 0;
|
||||
TotalFileCount = 0;
|
||||
TotalSwapCount = 0;
|
||||
TotalManipulations = 0;
|
||||
HasOptions = false;
|
||||
HasOptions = false;
|
||||
ChangedItems.Clear();
|
||||
LowerChangedItemsString = string.Empty;
|
||||
AllTagsLower = string.Empty;
|
||||
AllTagsLower = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -743,7 +743,7 @@ public class ItemSwapTab : IDisposable, ITab
|
|||
private void OnCollectionChange(CollectionType collectionType, ModCollection? oldCollection,
|
||||
ModCollection? newCollection, string _)
|
||||
{
|
||||
if (collectionType != CollectionType.Current || _mod == null || newCollection == null)
|
||||
if (collectionType is not CollectionType.Current || _mod == null || newCollection == null)
|
||||
return;
|
||||
|
||||
UpdateMod(_mod, _mod.Index < newCollection.Settings.Count ? newCollection[_mod.Index].Settings : null);
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
|
|||
|
||||
private void OnCollectionChange(CollectionType collectionType, ModCollection? oldCollection, ModCollection? newCollection, string _)
|
||||
{
|
||||
if (collectionType != CollectionType.Current || oldCollection == newCollection)
|
||||
if (collectionType is not CollectionType.Current || oldCollection == newCollection)
|
||||
return;
|
||||
|
||||
SetFilterDirty();
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@ using OtterGui;
|
|||
using OtterGui.Raii;
|
||||
using OtterGui.Widgets;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Collections.Manager;
|
||||
using Penumbra.Collections.Manager;
|
||||
using Penumbra.Services;
|
||||
using Penumbra.UI.CollectionTab;
|
||||
|
||||
using Penumbra.UI.CollectionTab;
|
||||
|
||||
namespace Penumbra.UI.Tabs;
|
||||
|
||||
public class CollectionsTab : IDisposable, ITab
|
||||
{
|
||||
private readonly CommunicatorService _communicator;
|
||||
private readonly Configuration _config;
|
||||
private readonly CollectionManager _collectionManager;
|
||||
private readonly TutorialService _tutorial;
|
||||
private readonly SpecialCombo _specialCollectionCombo;
|
||||
private readonly CommunicatorService _communicator;
|
||||
private readonly Configuration _config;
|
||||
private readonly CollectionManager _collectionManager;
|
||||
private readonly TutorialService _tutorial;
|
||||
private readonly SpecialCombo _specialCollectionCombo;
|
||||
|
||||
private readonly CollectionSelector _collectionsWithEmpty;
|
||||
private readonly CollectionSelector _collectionSelector;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue