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

View file

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

View file

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

View file

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