diff --git a/Penumbra/Collections/Manager/IndividualCollections.Files.cs b/Penumbra/Collections/Manager/IndividualCollections.Files.cs index 6fe12a9d..94bf9b46 100644 --- a/Penumbra/Collections/Manager/IndividualCollections.Files.cs +++ b/Penumbra/Collections/Manager/IndividualCollections.Files.cs @@ -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; diff --git a/Penumbra/Collections/Manager/IndividualCollections.cs b/Penumbra/Collections/Manager/IndividualCollections.cs index dfecec67..8708df11 100644 --- a/Penumbra/Collections/Manager/IndividualCollections.cs +++ b/Penumbra/Collections/Manager/IndividualCollections.cs @@ -17,15 +17,16 @@ public sealed partial class IndividualCollections private readonly List<(string DisplayName, IReadOnlyList Identifiers, ModCollection Collection)> _assignments = new(); private readonly Dictionary _individuals = new(); - public event Action? Loaded; + public event Action Loaded; public IReadOnlyList<(string DisplayName, IReadOnlyList Identifiers, ModCollection Collection)> Assignments => _assignments; public IndividualCollections(ActorService actorService, Configuration config) { - _config = config; - _actorService = actorService; + _config = config; + _actorService = actorService; + Loaded += () => Penumbra.Log.Information($"{_assignments.Count} Individual Assignments loaded after delay."); } public enum AddResult diff --git a/Penumbra/Services/SaveService.cs b/Penumbra/Services/SaveService.cs index ff4ec151..2445392e 100644 --- a/Penumbra/Services/SaveService.cs +++ b/Penumbra/Services/SaveService.cs @@ -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; + _log = log; + _framework = framework; + FileNames = fileNames; + DalamudFramework = dalamudFramework; } /// Queue a save for the next framework tick. 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); }); } /// Immediately trigger a save. @@ -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; diff --git a/Penumbra/UI/Tabs/DebugTab.cs b/Penumbra/UI/Tabs/DebugTab.cs index 2d5dee5a..267937b9 100644 --- a/Penumbra/UI/Tabs/DebugTab.cs +++ b/Penumbra/UI/Tabs/DebugTab.cs @@ -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,23 +129,37 @@ 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); + 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}"); - 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()); + 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()