From 1d5c27d4878f606b341bc5f7126e0e69780f69f9 Mon Sep 17 00:00:00 2001 From: Limiana <5073202+Limiana@users.noreply.github.com> Date: Mon, 1 Apr 2024 01:33:10 +0300 Subject: [PATCH] Folders and UI adjustments --- DynamicBridge/Configuration/Config.cs | 1 + DynamicBridge/Configuration/Profile.cs | 2 + DynamicBridge/Gui/Debug.cs | 4 +- DynamicBridge/Gui/GuiPresets.cs | 77 +++++++++++++------ DynamicBridge/Gui/GuiProfiles.cs | 57 ++++++++------ DynamicBridge/Gui/GuiSettings.cs | 37 +++++---- .../IPC/Customize/CustomizePlusManager.cs | 16 +++- .../IPC/Glamourer/GlamourerManager.cs | 10 ++- DynamicBridge/IPC/Moodles/MoodlesManager.cs | 50 ++++++++++-- DynamicBridge/Utils.cs | 19 ++--- ECommons | 2 +- 11 files changed, 189 insertions(+), 86 deletions(-) diff --git a/DynamicBridge/Configuration/Config.cs b/DynamicBridge/Configuration/Config.cs index b912337..d94aaff 100644 --- a/DynamicBridge/Configuration/Config.cs +++ b/DynamicBridge/Configuration/Config.cs @@ -55,6 +55,7 @@ public class Config : IEzConfig public bool ShowTutorial = true; public bool UnifyJobs = true; public bool HonotificUnfiltered = false; + public bool AutofillFromGlam = false; } public enum GlamourerNoRuleBehavior diff --git a/DynamicBridge/Configuration/Profile.cs b/DynamicBridge/Configuration/Profile.cs index c6ffa04..a575697 100644 --- a/DynamicBridge/Configuration/Profile.cs +++ b/DynamicBridge/Configuration/Profile.cs @@ -18,6 +18,8 @@ public class Profile public List Subprofiles = []; public HashSet Characters = []; public List Pathes = []; + public List CustomizePathes = []; + public List MoodlesPathes = []; public Preset FallbackPreset = new(); internal bool IsGlobal => C.GlobalProfile == this; diff --git a/DynamicBridge/Gui/Debug.cs b/DynamicBridge/Gui/Debug.cs index 7118d40..151dd87 100644 --- a/DynamicBridge/Gui/Debug.cs +++ b/DynamicBridge/Gui/Debug.cs @@ -179,7 +179,7 @@ public static void Draw() } } } - if(ImGui.CollapsingHeader("Pathes")) + /*if(ImGui.CollapsingHeader("Pathes")) { foreach(var x in Utils.GetCombinedPathes()) { @@ -189,7 +189,7 @@ public static void Draw() } ImGuiEx.TextV($"{x.Name}"); } - } + }*/ if (ImGui.CollapsingHeader("Items")) { ImGuiEx.Text($"Current: {Utils.GetCurrentGear().Print()}"); diff --git a/DynamicBridge/Gui/GuiPresets.cs b/DynamicBridge/Gui/GuiPresets.cs index b4ee831..9970248 100644 --- a/DynamicBridge/Gui/GuiPresets.cs +++ b/DynamicBridge/Gui/GuiPresets.cs @@ -402,7 +402,7 @@ void FiltersSelection() { if (ImGui.IsWindowAppearing()) Utils.ResetCaches(); FiltersSelection(); - ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, 5f); + ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, Utils.IndentSpacing); // normal { List<(string[], Action)> items = []; @@ -417,7 +417,15 @@ void FiltersSelection() var contains = preset.Glamourer.Contains(id); if (OnlySelected[filterCnt] && !contains) continue; - items.Add((transformedName.SplitDirectories()[0..^1], () => Utils.CollectionSelectable(contains ? Colors.TabGreen : null, $"{name} ##{x.Identifier}", id, preset.Glamourer))); + items.Add((transformedName.SplitDirectories()[0..^1], () => + { + if(Utils.CollectionSelectable(contains ? Colors.TabGreen : null, $"{name} ##{x.Identifier}", id, preset.Glamourer)) + { + if (C.AutofillFromGlam && preset.Name == "" && preset.Glamourer.Contains(id)) preset.Name = name; + } + } + + )); } foreach (var x in preset.Glamourer) { @@ -444,7 +452,15 @@ void FiltersSelection() foreach (var x in preset.ComplexGlamourer) { if (designs.Any(d => d.Name == x)) continue; - items.Add(([], () => Utils.CollectionSelectable(ImGuiColors.DalamudRed, $"{x}", x, preset.ComplexGlamourer, true))); + items.Add(([], () => + { + if (Utils.CollectionSelectable(ImGuiColors.DalamudRed, $"{x}", x, preset.ComplexGlamourer, true)) + { + if (C.AutofillFromGlam && preset.Name == "" && preset.ComplexGlamourer.Contains(x)) preset.Name = x; + } + } + + )); } if (items.Count > 0) { @@ -471,13 +487,18 @@ void FiltersSelection() if (C.EnableCustomize) { ImGui.TableNextColumn(); + if (isGlobal) + { + ImGuiEx.HelpMarker("All registered profiles are displayed in global profile, but only ones that are assigned to your current character will be used.", EColor.OrangeBright, FontAwesomeIcon.ExclamationTriangle.ToIconString(), false); + ImGui.SameLine(); + } ImGuiEx.SetNextItemFullWidth(); if (ImGui.BeginCombo("##customize", preset.Customize.Select(P.CustomizePlusManager.TransformName).PrintRange(out var fullList, "- None -"), C.ComboSize)) { - ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, 5f); + ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, Utils.IndentSpacing); if (ImGui.IsWindowAppearing()) Utils.ResetCaches(); FiltersSelection(); - var profiles = P.CustomizePlusManager.GetProfiles(currentProfile.Characters.Select(Utils.GetCharaNameFromCID).Select(z => z.Split("@")[0])).OrderBy(x => P.CustomizePlusManager.TransformName($"{x.ID}")); + var profiles = P.CustomizePlusManager.GetProfiles(isGlobal?null:currentProfile.Characters.Select(Utils.GetCharaNameFromCID).Select(z => z.Split("@")[0])).OrderBy(x => P.CustomizePlusManager.TransformName($"{x.ID}")); var index = 0; List<(string[], Action)> items = []; foreach (var x in profiles) @@ -485,7 +506,7 @@ void FiltersSelection() index++; ImGui.PushID(index); var name = P.CustomizePlusManager.TransformName($"{x.ID}"); - if (C.GlamourerFullPath && currentProfile.Pathes.Count > 0 && !name.StartsWithAny(currentProfile.Pathes)) continue; + if (C.GlamourerFullPath && currentProfile.CustomizePathes.Count > 0 && !name.StartsWithAny(currentProfile.CustomizePathes)) continue; if (Filters[filterCnt].Length > 0 && !name.Contains(Filters[filterCnt], StringComparison.OrdinalIgnoreCase)) continue; if (OnlySelected[filterCnt] && !preset.Customize.Contains($"{x.ID}")) continue; var contains = preset.Customize.Contains($"{x.ID}"); @@ -516,34 +537,40 @@ void FiltersSelection() ImGui.TableNextColumn(); if (isGlobal && !C.HonotificUnfiltered) { - ImGuiEx.HelpMarker("All registered titles are displayed in global profile, but only ones that are assigned to current character will be used UNLESS \"Allow selecting titles registered for other characters\" is enabled in settings.", EColor.RedBright, FontAwesomeIcon.ExclamationTriangle.ToIconString()); + ImGuiEx.HelpMarker("All registered titles are displayed in global profile, but only ones that are assigned to your current character will be used UNLESS \"Allow selecting titles registered for other characters\" is enabled in settings.", EColor.OrangeBright, FontAwesomeIcon.ExclamationTriangle.ToIconString(), false); ImGui.SameLine(); } ImGuiEx.SetNextItemFullWidth(); if (ImGui.BeginCombo("##honorific", preset.Honorific.PrintRange(out var fullList, "- None -"), C.ComboSize)) { - ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, 5f); + ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, Utils.IndentSpacing); if (ImGui.IsWindowAppearing()) Utils.ResetCaches(); FiltersSelection(); - var titles = P.HonorificManager.GetTitleData(C.HonotificUnfiltered || isGlobal?null:currentProfile.Characters).OrderBy(x => x.Title); - var index = 0; + IEnumerable charas = C.HonotificUnfiltered || isGlobal ? C.SeenCharacters.Keys : currentProfile.Characters; List<(string[], Action)> items = []; - foreach (var x in titles) + List allTitles = []; + foreach (var chara in charas) { - index++; - ImGui.PushID(index); - var name = x.Title; - if (Filters[filterCnt].Length > 0 && !name.Contains(Filters[filterCnt], StringComparison.OrdinalIgnoreCase)) continue; - if (OnlySelected[filterCnt] && !preset.Honorific.Contains(name)) continue; - if (x.Color != null) ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(x.Color.Value, 1f)); - var contains = preset.Honorific.Contains(x.Title); - items.Add(([], () => Utils.CollectionSelectable(contains ? Colors.TabGreen : null, $"{name} ", x.Title, preset.Honorific))); - if (x.Color != null) ImGui.PopStyleColor(); - ImGui.PopID(); + var titles = P.HonorificManager.GetTitleData([chara]).OrderBy(x => x.Title); + allTitles.AddRange(titles); + var index = 0; + foreach (var x in titles) + { + index++; + ImGui.PushID(index); + var name = x.Title; + if (Filters[filterCnt].Length > 0 && !name.Contains(Filters[filterCnt], StringComparison.OrdinalIgnoreCase)) continue; + if (OnlySelected[filterCnt] && !preset.Honorific.Contains(name)) continue; + if (x.Color != null) ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(x.Color.Value, 1f)); + var contains = preset.Honorific.Contains(x.Title); + items.Add(([Utils.GetCharaNameFromCID(chara)], () => Utils.CollectionSelectable(contains ? Colors.TabGreen : null, $"{name} ", x.Title, preset.Honorific))); + if (x.Color != null) ImGui.PopStyleColor(); + ImGui.PopID(); + } } foreach (var x in preset.Honorific) { - if (titles.Any(d => d.Title == x)) continue; + if (allTitles.Any(d => d.Title == x)) continue; items.Add(([], () => Utils.CollectionSelectable(ImGuiColors.DalamudRed, $"{x} ", x, preset.Honorific, true))); } Utils.DrawFolder(items); @@ -565,7 +592,7 @@ void FiltersSelection() string fullList = null; if (ImGui.BeginCombo("##penumbra", preset.PenumbraType != SpecialPenumbraAssignment.Use_Named_Collection ? preset.PenumbraType.ToString().Replace("_", " ") : preset.Penumbra.PrintRange(out fullList, "- None -"), C.ComboSize)) { - ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, 5f); + ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, Utils.IndentSpacing); if (ImGui.IsWindowAppearing()) Utils.ResetCaches(); ImGuiEx.Text($"Assignment Type:"); ImGuiEx.EnumCombo($"##asstype", ref preset.PenumbraType); @@ -609,7 +636,7 @@ void FiltersSelection() ImGuiEx.SetNextItemFullWidth(); if (ImGui.BeginCombo("##moodles", preset.Moodles.Select(Utils.GetName).PrintRange(out var fullList, "- None -"), C.ComboSize)) { - ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, 5f); + ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, Utils.IndentSpacing); if (ImGui.IsWindowAppearing()) Utils.ResetCaches(); void ToggleMoodle(Vector4 selectedCol, Guid id, string name) { @@ -663,6 +690,7 @@ void ToggleMoodle(Vector4 selectedCol, Guid id, string name) var name = x.FullPath; if (Filters[filterCnt].Length > 0 && !name.Contains(Filters[filterCnt], StringComparison.OrdinalIgnoreCase)) continue; if (OnlySelected[filterCnt] && !preset.Moodles.Any(z => z.Guid == x.ID)) continue; + if (currentProfile.MoodlesPathes.Count > 0 && !name.StartsWithAny(currentProfile.MoodlesPathes)) continue; var parts = name.SplitDirectories(); items.Add((parts[0..^1], () => ToggleMoodle(Colors.TabGreen, x.ID, parts[^1]))); ImGui.PopID(); @@ -680,6 +708,7 @@ void ToggleMoodle(Vector4 selectedCol, Guid id, string name) var name = x.FullPath; if (Filters[filterCnt].Length > 0 && !name.Contains(Filters[filterCnt], StringComparison.OrdinalIgnoreCase)) continue; if (OnlySelected[filterCnt] && !preset.Moodles.Any(z => z.Guid == x.ID)) continue; + if (currentProfile.MoodlesPathes.Count > 0 && !name.StartsWithAny(currentProfile.MoodlesPathes)) continue; var parts = name.SplitDirectories(); items.Add((parts[0..^1], () => ToggleMoodle(Colors.TabYellow, x.ID, parts[^1]))); ImGui.PopID(); diff --git a/DynamicBridge/Gui/GuiProfiles.cs b/DynamicBridge/Gui/GuiProfiles.cs index 0c08bf3..5242817 100644 --- a/DynamicBridge/Gui/GuiProfiles.cs +++ b/DynamicBridge/Gui/GuiProfiles.cs @@ -89,38 +89,51 @@ public static void Draw() ImGui.TableNextColumn(); ImGuiEx.SetNextItemFullWidth(); - if(ImGui.BeginCombo($"##FoldersWhitelist", profile.Pathes.PrintRange(out _), C.ComboSize)) + if (ImGui.BeginCombo($"##FoldersWhitelist", profile.Pathes.Union(profile.CustomizePathes).Union(profile.MoodlesPathes).PrintRange(out _), C.ComboSize)) { - if(profile.Pathes.Count > 1) ImGuiEx.Tooltip(profile.Pathes.Join("\n")); + if (profile.Pathes.Count > 1) ImGuiEx.Tooltip(profile.Pathes.Join("\n")); if (ImGui.IsWindowAppearing()) Utils.ResetCaches(); - var pathes = Utils.GetCombinedPathes(); - foreach (var x in pathes) + void DrawPathes(List pathes, List targetCollection) { - for (int q = 0; q < x.Indentation; q++) + foreach (var x in pathes) { - ImGuiEx.Spacing(); + for (int q = 0; q < x.Indentation; q++) + { + ImGuiEx.Spacing(); + } + Utils.CollectionSelectable(null, $"{x.Name}", x.Name, targetCollection); } - ImGuiEx.CollectionCheckbox($"{x.Name}", x.Name, profile.Pathes); - if (x.Glamourer) + foreach (var x in targetCollection) { - ImGui.SameLine(); - ImGuiEx.Text(ImGuiColors.DalamudGrey3, UiBuilder.IconFont, "\uf630"); - ImGuiEx.Tooltip("This folder is present in Glamourer"); - } - if (x.Customize) - { - ImGui.SameLine(); - ImGuiEx.Text(ImGuiColors.DalamudGrey3, UiBuilder.IconFont, "\ue541"); - ImGuiEx.Tooltip("This folder is present in Customize+"); + if (pathes.Any(z => z.Name == x)) continue; + ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); + Utils.CollectionSelectable(null, $"{x}", x, targetCollection, true); + ImGui.PopStyleColor(); } } - foreach(var x in profile.Pathes) + ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, Utils.IndentSpacing); + if (C.EnableGlamourer && ImGuiEx.TreeNode(Colors.TabBlue, "Glamourer", ImGuiTreeNodeFlags.DefaultOpen)) + { + ImGui.PushID("Glam"); + DrawPathes(P.GlamourerManager.GetCombinedPathes(), profile.Pathes); + ImGui.PopID(); + ImGui.TreePop(); + } + if (C.EnableCustomize && ImGuiEx.TreeNode(Colors.TabBlue, "Customize+", ImGuiTreeNodeFlags.DefaultOpen)) + { + ImGui.PushID("Customize"); + DrawPathes(P.CustomizePlusManager.GetCombinedPathes(), profile.CustomizePathes); + ImGui.PopID(); + ImGui.TreePop(); + } + if (C.EnableMoodles && ImGuiEx.TreeNode(Colors.TabBlue, "Moodles", ImGuiTreeNodeFlags.DefaultOpen)) { - if (pathes.Any(z => z.Name == x)) continue; - ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); - ImGuiEx.CollectionCheckbox($"{x}", x, profile.Pathes); - ImGui.PopStyleColor(); + ImGui.PushID("Moodles"); + DrawPathes(P.MoodlesManager.GetCombinedPathes(), profile.MoodlesPathes); + ImGui.PopID(); + ImGui.TreePop(); } + ImGui.PopStyleVar(); ImGui.EndCombo(); } else diff --git a/DynamicBridge/Gui/GuiSettings.cs b/DynamicBridge/Gui/GuiSettings.cs index d445df3..8d32334 100644 --- a/DynamicBridge/Gui/GuiSettings.cs +++ b/DynamicBridge/Gui/GuiSettings.cs @@ -70,17 +70,20 @@ public static void Draw() if(ImGuiGroup.BeginGroupBox("Configure rule conditions")) { ImGuiEx.TextWrapped($"Enable extra conditions or disable unused for convenience and performance boost."); - ImGui.Checkbox($"State", ref C.Cond_State); - ImGui.Checkbox($"Biome", ref C.Cond_Biome); - ImGui.Checkbox($"Weather", ref C.Cond_Weather); - ImGui.Checkbox($"Time", ref C.Cond_Time); - ImGui.Checkbox($"Zone group", ref C.Cond_ZoneGroup); - ImGui.Checkbox($"Zone", ref C.Cond_Zone); - ImGui.Checkbox($"House", ref C.Cond_House); - ImGui.Checkbox($"Emote", ref C.Cond_Emote); - ImGui.Checkbox($"Job", ref C.Cond_Job); - ImGui.Checkbox($"World", ref C.Cond_World); - ImGui.Checkbox($"Gearset", ref C.Cond_Gearset); + ImGuiEx.EzTableColumns("extras", [ + () => ImGui.Checkbox($"State", ref C.Cond_State), + () => ImGui.Checkbox($"Biome", ref C.Cond_Biome), + () => ImGui.Checkbox($"Weather", ref C.Cond_Weather), + () => ImGui.Checkbox($"Time", ref C.Cond_Time), + () => ImGui.Checkbox($"Zone group", ref C.Cond_ZoneGroup), + () => ImGui.Checkbox($"Zone", ref C.Cond_Zone), + () => ImGui.Checkbox($"House", ref C.Cond_House), + () => ImGui.Checkbox($"Emote", ref C.Cond_Emote), + () => ImGui.Checkbox($"Job", ref C.Cond_Job), + () => ImGui.Checkbox($"World", ref C.Cond_World), + () => ImGui.Checkbox($"Gearset", ref C.Cond_Gearset), + ], + (int)(ImGui.GetContentRegionAvail().X / 180f), ImGuiTableFlags.BordersInner); ImGuiGroup.EndGroupBox(); } @@ -91,8 +94,10 @@ public static void Draw() ImGui.Checkbox("Glamourer", ref C.EnableGlamourer); DrawPluginCheck("Glamourer", "1.2.0.2"); + ImGuiEx.Spacing(); ImGuiEx.TextV($"DynamicBridge behavior when no Glamourer rule is found:"); ImGui.SameLine(); + ImGuiEx.Spacing(); ImGuiEx.SetNextItemWidthScaled(200f); ImGuiEx.EnumCombo("##dbglamdef", ref C.GlamNoRuleBehaviour, GlamourerNoRuleBehaviorNames); if (C.ManageGlamourerAutomation) @@ -102,7 +107,7 @@ public static void Draw() ImGuiEx.HelpMarker("Revert to Automation is recommended if you are using Glamourer automation.", ImGuiColors.DalamudRed, FontAwesomeIcon.ExclamationTriangle.ToIconString()); } } - var c = new CancellationTokenSource(); + ImGuiEx.Spacing(); ImGui.Checkbox("Allow DynamicBridge to manage Glamourer's automation setting", ref C.ManageGlamourerAutomation); ImGuiEx.HelpMarker("If this setting is enabled, Glamourer's global automation setting will be automatically disabled upon applying any rule and will be automatically enabled when no rules are found."); if (P.GlamourerManager.Reflector.GetAutomationGlobalState() && P.GlamourerManager.Reflector.GetAutomationStatusForChara()) @@ -112,8 +117,12 @@ public static void Draw() ImGuiEx.HelpMarker("You MUST enable this setting or disable Glamourer's automation, otherwise either Glamourer's or DynamicBridge's automation will not work correctly.", ImGuiColors.DalamudRed, FontAwesomeIcon.ExclamationTriangle.ToIconString()); } } - ImGui.Checkbox("[Beta] Revert character before restoring automation", ref C.RevertBeforeAutomationRestore); - ImGui.Checkbox("[Beta] Revert character before applying rule", ref C.RevertGlamourerBeforeApply); + ImGuiEx.Spacing(); + ImGui.Checkbox("Revert character before restoring automation", ref C.RevertBeforeAutomationRestore); + ImGuiEx.Spacing(); + ImGui.Checkbox("Revert character before applying rule", ref C.RevertGlamourerBeforeApply); + ImGuiEx.Spacing(); + ImGui.Checkbox("Autofill preset name with Glamourer's preset name upon selecting it", ref C.AutofillFromGlam); ImGui.Separator(); diff --git a/DynamicBridge/IPC/Customize/CustomizePlusManager.cs b/DynamicBridge/IPC/Customize/CustomizePlusManager.cs index 8f41e10..b84a492 100644 --- a/DynamicBridge/IPC/Customize/CustomizePlusManager.cs +++ b/DynamicBridge/IPC/Customize/CustomizePlusManager.cs @@ -4,6 +4,7 @@ using ECommons.GameHelpers; using Newtonsoft.Json; using System; +using static System.Windows.Forms.AxHost; namespace DynamicBridge.IPC.Customize; public class CustomizePlusManager @@ -22,7 +23,14 @@ public CustomizePlusManager() Reflector = new(); EzIPC.Init(this, "CustomizePlus", SafeWrapper.AnyException); } - + + List PathInfos = null; + public List GetCombinedPathes() + { + PathInfos ??= Utils.BuildPathes(GetRawPathes()); + return PathInfos; + } + public List GetRawPathes() { var ret = new List(); @@ -54,7 +62,11 @@ public IEnumerable GetProfiles(IEnumerable chara = } } - public void ResetCache() => Cache = null; + public void ResetCache() + { + Cache = null; + PathInfos = null; + } public void SetProfile(string profileGuidStr, string charName) { diff --git a/DynamicBridge/IPC/Glamourer/GlamourerManager.cs b/DynamicBridge/IPC/Glamourer/GlamourerManager.cs index d5feda3..db50b08 100644 --- a/DynamicBridge/IPC/Glamourer/GlamourerManager.cs +++ b/DynamicBridge/IPC/Glamourer/GlamourerManager.cs @@ -23,6 +23,13 @@ public GlamourerManager() Commands = new(); } + List PathInfos = null; + public List GetCombinedPathes() + { + PathInfos ??= Utils.BuildPathes(GetRawPathes()); + return PathInfos; + } + public void RevertToAutomation() { Commands.RevertToAutomation(); @@ -165,8 +172,9 @@ public List GetRawPathes() return ret; } - public void ResetNameCache() + public void ResetCache() { TransformNameCache.Clear(); + PathInfos = null; } } diff --git a/DynamicBridge/IPC/Moodles/MoodlesManager.cs b/DynamicBridge/IPC/Moodles/MoodlesManager.cs index 514627b..ed75b12 100644 --- a/DynamicBridge/IPC/Moodles/MoodlesManager.cs +++ b/DynamicBridge/IPC/Moodles/MoodlesManager.cs @@ -1,4 +1,5 @@ using Dalamud.Game.ClientState.Objects.SubKinds; +using DynamicBridge.Configuration; using ECommons.EzIpcManager; using ECommons.GameHelpers; using System; @@ -10,22 +11,59 @@ namespace DynamicBridge.IPC.Moodles; public class MoodlesManager { - [EzIPC] Func> GetRegisteredMoodles { get; init; } - [EzIPC] Func> GetRegisteredProfiles { get; init; } - [EzIPC] Action AddOrUpdateMoodleByGUID { get; init; } - [EzIPC] Action ApplyPresetByGUID { get; init; } - [EzIPC] Action RemoveMoodleByGUID { get; init; } - [EzIPC] Action RemovePresetByGUID { get; init; } + [EzIPC] readonly Func> GetRegisteredMoodles; + [EzIPC] readonly Func> GetRegisteredProfiles; + [EzIPC] readonly Action AddOrUpdateMoodleByGUID; + [EzIPC] readonly Action ApplyPresetByGUID; + [EzIPC] readonly Action RemoveMoodleByGUID; + [EzIPC] readonly Action RemovePresetByGUID; public MoodlesManager() { EzIPC.Init(this, "Moodles"); } + List PathInfos = null; + public List GetCombinedPathes() + { + PathInfos ??= Utils.BuildPathes(GetRawPathes()); + return PathInfos; + } + + public List GetRawPathes() + { + var ret = new List(); + try + { + foreach (var x in GetMoodles()) + { + var path = x.FullPath; + if (path != null) + { + ret.Add(path); + } + } + foreach (var x in GetPresets()) + { + var path = x.FullPath; + if (path != null) + { + ret.Add(path); + } + } + } + catch (Exception e) + { + e.LogInternal(); + } + return ret; + } + public void ResetCache() { MoodleCache = null; MoodleProfilesCache = null; + PathInfos = null; } List MoodleCache = null; diff --git a/DynamicBridge/Utils.cs b/DynamicBridge/Utils.cs index 65f6dab..59425d9 100644 --- a/DynamicBridge/Utils.cs +++ b/DynamicBridge/Utils.cs @@ -20,6 +20,7 @@ public unsafe static class Utils public static bool IsInWater => Player.Available && Player.Object.IsInWater(); public static ImGuiInputTextFlags CensorFlags => C.NoNames ? ImGuiInputTextFlags.Password : ImGuiInputTextFlags.None; public static Vector2 CellPadding => ImGui.GetStyle().CellPadding + new Vector2(0, 2); + public const float IndentSpacing = 5f; public static void DrawFolder(IEnumerable<(string[] Folder, Action Draw)> values) { @@ -58,16 +59,12 @@ public static List TrimPathes(IEnumerable origPathes) return pathes; } - static List PathInfos = null; - public static List GetCombinedPathes() + public static List BuildPathes(List rawPathes) { - if (PathInfos != null) return PathInfos; var ret = new List(); try { - var glamPathes = TrimPathes(P.GlamourerManager.GetRawPathes()); - var custPathes = TrimPathes(P.CustomizePlusManager.GetRawPathes()); - var pathes = glamPathes.Concat(custPathes).ToList(); + var pathes = Utils.TrimPathes(rawPathes); pathes.Sort(); foreach (var x in pathes) { @@ -76,11 +73,7 @@ public static List GetCombinedPathes() for (int i = 1; i <= parts.Length; i++) { var part = parts[..i].Join("/"); - var info = new PathInfo(part, i - 1) - { - Glamourer = glamPathes.Contains(x), - Customize = custPathes.Contains(x), - }; + var info = new PathInfo(part, i - 1); if (!ret.Contains(info)) ret.Add(info); } } @@ -89,16 +82,14 @@ public static List GetCombinedPathes() { e.LogInternal(); } - PathInfos = ret; return ret; } public static void ResetCaches() { - P.GlamourerManager.ResetNameCache(); + P.GlamourerManager.ResetCache(); P.MoodlesManager.ResetCache(); P.CustomizePlusManager.ResetCache(); - PathInfos = null; } public static IEnumerable HonorificFiltered(this Preset preset) diff --git a/ECommons b/ECommons index ee79600..79db619 160000 --- a/ECommons +++ b/ECommons @@ -1 +1 @@ -Subproject commit ee79600225484ba0922528983f5bc39e2b342d4d +Subproject commit 79db61912cbfbb1627fc20a226ef02f8f0f7ad5c