Add some tracking of cached collections.

This commit is contained in:
Ottermandias 2023-04-29 16:08:16 +02:00
parent a9ff6135b3
commit ef5cf14b2b
4 changed files with 45 additions and 32 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Game;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Interface.Internal.Notifications;
using Newtonsoft.Json.Linq;
@ -34,7 +35,7 @@ public partial class IndividualCollections
{
if (ReadJObjectInternal(obj, storage))
saver.ImmediateSave(parent);
Loaded?.Invoke();
saver.DalamudFramework.RunOnFrameworkThread(() => Loaded.Invoke());
_actorService.FinishedCreation -= Func;
}
_actorService.FinishedCreation += Func;

View file

@ -17,7 +17,7 @@ public sealed partial class IndividualCollections
private readonly List<(string DisplayName, IReadOnlyList<ActorIdentifier> Identifiers, ModCollection Collection)> _assignments = new();
private readonly Dictionary<ActorIdentifier, ModCollection> _individuals = new();
public event Action? Loaded;
public event Action Loaded;
public IReadOnlyList<(string DisplayName, IReadOnlyList<ActorIdentifier> Identifiers, ModCollection Collection)> Assignments
=> _assignments;
@ -26,6 +26,7 @@ public sealed partial class IndividualCollections
{
_config = config;
_actorService = actorService;
Loaded += () => Penumbra.Log.Information($"{_assignments.Count} Individual Assignments loaded after delay.");
}
public enum AddResult

View file

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Text;
using Dalamud.Game;
using OtterGui.Classes;
using OtterGui.Log;
using Penumbra.Mods;
@ -32,22 +33,21 @@ public class SaveService
private readonly FrameworkManager _framework;
public readonly FilenameService FileNames;
public readonly Framework DalamudFramework;
public SaveService(Logger log, FrameworkManager framework, FilenameService fileNames)
public SaveService(Logger log, FrameworkManager framework, FilenameService fileNames, Framework dalamudFramework)
{
_log = log;
_framework = framework;
FileNames = fileNames;
DalamudFramework = dalamudFramework;
}
/// <summary> Queue a save for the next framework tick. </summary>
public void QueueSave(ISavable value)
{
var file = value.ToFilename(FileNames);
_framework.RegisterDelayed(value.GetType().Name + file, () =>
{
ImmediateSave(value);
});
_framework.RegisterDelayed(value.GetType().Name + file, () => { ImmediateSave(value); });
}
/// <summary> Immediately trigger a save. </summary>
@ -57,9 +57,7 @@ public class SaveService
try
{
if (name.Length == 0)
{
throw new Exception("Invalid object returned empty filename.");
}
_log.Debug($"Saving {value.TypeName} {value.LogName(name)}...");
var file = new FileInfo(name);
@ -80,9 +78,7 @@ public class SaveService
try
{
if (name.Length == 0)
{
throw new Exception("Invalid object returned empty filename.");
}
if (!File.Exists(name))
return;

View file

@ -9,6 +9,7 @@ using FFXIVClientStructs.FFXIV.Client.System.Resource;
using FFXIVClientStructs.Interop;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using OtterGui.Widgets;
using Penumbra.Api;
using Penumbra.Collections.Manager;
@ -128,11 +129,10 @@ public class DebugTab : ITab
if (!ImGui.CollapsingHeader("General"))
return;
using var table = Table("##DebugGeneralTable", 2, ImGuiTableFlags.SizingFixedFit,
new Vector2(-1, ImGui.GetTextLineHeightWithSpacing() * 1));
if (!table)
return;
using (var table = Table("##DebugGeneralTable", 2, ImGuiTableFlags.SizingFixedFit))
{
if (table)
{
PrintValue("Penumbra Version", $"{_validityChecker.Version} {DebugVersionString}");
PrintValue("Git Commit Hash", _validityChecker.CommitHash);
PrintValue(TutorialService.SelectedCollection, _collectionManager.Active.Current.Name);
@ -146,6 +146,21 @@ public class DebugTab : ITab
PrintValue("Mod Manager Valid", _modManager.Valid.ToString());
PrintValue("Web Server Enabled", _httpApi.Enabled.ToString());
}
}
using (var tree = TreeNode("Collections"))
{
if (!tree)
return;
using var table = Table("##DebugCollectionsTable", 2, ImGuiTableFlags.SizingFixedFit);
if (!table)
return;
foreach (var collection in _collectionManager.Storage)
PrintValue(collection.Name, collection.HasCache.ToString());
}
}
private void DrawPerformanceTab()
{