diff --git a/PlayerTags/PluginConfiguration.cs b/PlayerTags/PluginConfiguration.cs index 40c0832..d7876fa 100644 --- a/PlayerTags/PluginConfiguration.cs +++ b/PlayerTags/PluginConfiguration.cs @@ -18,6 +18,8 @@ namespace PlayerTags public bool IsPlayerNameRandomlyGenerated = false; public bool IsCustomTagContextMenuEnabled = true; + public List ExpandedTags = new List(); + [JsonProperty(TypeNameHandling = TypeNameHandling.None, ItemTypeNameHandling = TypeNameHandling.None)] public Dictionary AllTagsChanges = new Dictionary(); diff --git a/PlayerTags/PluginConfigurationUI.cs b/PlayerTags/PluginConfigurationUI.cs index b7799e7..bd38585 100644 --- a/PlayerTags/PluginConfigurationUI.cs +++ b/PlayerTags/PluginConfigurationUI.cs @@ -135,14 +135,29 @@ namespace PlayerTags { ImGui.PushID(tag.GetHashCode().ToString()); - var collapsingHeaderName = tag.Name.Value; + string collapsingHeaderName = tag.Name.Value; if (m_PluginData.CustomTags.Contains(tag)) { - collapsingHeaderName = tag.Text.InheritedValue; + if (tag.Text.InheritedValue != null) + { + collapsingHeaderName = tag.Text.InheritedValue; + } + else + { + collapsingHeaderName = ""; + } } - if (ImGui.CollapsingHeader($"{collapsingHeaderName}###{tag.GetHashCode()}")) + bool isExpanded = m_PluginConfiguration.ExpandedTags.Contains(collapsingHeaderName); + bool isVisible = true; + if (ImGui.CollapsingHeader($"{collapsingHeaderName}###{tag.GetHashCode()}", ref isVisible, isExpanded ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None)) { + if (!m_PluginConfiguration.ExpandedTags.Contains(collapsingHeaderName)) + { + m_PluginConfiguration.ExpandedTags.Add(collapsingHeaderName); + m_PluginConfiguration.Save(m_PluginData); + } + ImGui.TreePush(); ImGui.BeginGroup(); @@ -339,6 +354,11 @@ namespace PlayerTags ImGui.EndGroup(); ImGui.TreePop(); } + else if(!isExpanded && m_PluginConfiguration.ExpandedTags.Contains(collapsingHeaderName)) + { + m_PluginConfiguration.ExpandedTags.Remove(collapsingHeaderName); + m_PluginConfiguration.Save(m_PluginData); + } ImGui.PopID(); }