Better tracking of expanded tags

This commit is contained in:
r00telement
2021-12-07 23:08:05 +00:00
parent 984aba9d42
commit b06da0dac0
4 changed files with 17 additions and 11 deletions

View File

@@ -29,6 +29,7 @@ namespace PlayerTags
{
AllTagsChanges = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
TagPositionInChat = TagPosition.Before,
TagPositionInNameplates = TagPosition.Replace,
TagTargetInNameplates = NameplateElement.Title,
@@ -37,30 +38,35 @@ namespace PlayerTags
AllRoleTagsChanges = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
IsIconVisibleInChat = true,
IsTextVisibleInNameplates = true,
}.GetChanges();
RoleTagsChanges[Role.LandHand] = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
Icon = BitmapFontIcon.Crafter,
TextColor = 3,
}.GetChanges();
RoleTagsChanges[Role.Tank] = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
Icon = BitmapFontIcon.Tank,
TextColor = 546,
}.GetChanges();
RoleTagsChanges[Role.Healer] = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
Icon = BitmapFontIcon.Healer,
TextColor = 43,
}.GetChanges();
RoleTagsChanges[Role.DPS] = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
Icon = BitmapFontIcon.DPS,
TextColor = 508,
}.GetChanges();
@@ -89,6 +95,7 @@ namespace PlayerTags
AllCustomTagsChanges = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
IsTextVisibleInChat = true,
IsTextVisibleInNameplates = true,
}.GetChanges();

View File

@@ -18,8 +18,6 @@ namespace PlayerTags
public bool IsPlayerNameRandomlyGenerated = false;
public bool IsCustomTagContextMenuEnabled = true;
public List<string> ExpandedTags = new List<string>();
[JsonProperty(TypeNameHandling = TypeNameHandling.None, ItemTypeNameHandling = TypeNameHandling.None)]
public Dictionary<string, InheritableData> AllTagsChanges = new Dictionary<string, InheritableData>();

View File

@@ -144,12 +144,9 @@ namespace PlayerTags
{
ImGui.PushID(tag.GetHashCode().ToString());
string collapsingHeaderId = tag.Name.Value;
string collapsingHeaderName = tag.Name.Value;
if (m_PluginData.CustomTags.Contains(tag))
{
collapsingHeaderId = $"Custom_{m_PluginData.CustomTags.IndexOf(tag)}";
if (tag.Text.InheritedValue != null)
{
collapsingHeaderName = tag.Text.InheritedValue;
@@ -160,13 +157,12 @@ namespace PlayerTags
}
}
bool isExpanded = m_PluginConfiguration.ExpandedTags.Contains(collapsingHeaderName);
bool isVisible = true;
if (ImGui.CollapsingHeader($"{collapsingHeaderName}###{tag.GetHashCode()}", ref isVisible, isExpanded ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None))
if (ImGui.CollapsingHeader($"{collapsingHeaderName}###{tag.GetHashCode()}", ref isVisible, tag.IsExpanded.Value ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None))
{
if (!m_PluginConfiguration.ExpandedTags.Contains(collapsingHeaderName))
if (!tag.IsExpanded.Value)
{
m_PluginConfiguration.ExpandedTags.Add(collapsingHeaderName);
tag.IsExpanded.Value = true;
m_PluginConfiguration.Save(m_PluginData);
}
@@ -366,9 +362,9 @@ namespace PlayerTags
ImGui.EndGroup();
ImGui.TreePop();
}
else if(!isExpanded && m_PluginConfiguration.ExpandedTags.Contains(collapsingHeaderName))
else if (tag.IsExpanded.Value)
{
m_PluginConfiguration.ExpandedTags.Remove(collapsingHeaderName);
tag.IsExpanded.Value = false;
m_PluginConfiguration.Save(m_PluginData);
}

View File

@@ -64,6 +64,11 @@ namespace PlayerTags
}
}
public InheritableValue<bool> IsExpanded = new InheritableValue<bool>(false)
{
Behavior = InheritableBehavior.Enabled
};
public InheritableValue<BitmapFontIcon> Icon = new InheritableValue<BitmapFontIcon>(BitmapFontIcon.Aethernet);
public InheritableValue<bool> IsIconVisibleInChat = new InheritableValue<bool>(false);
public InheritableValue<bool> IsIconVisibleInNameplates = new InheritableValue<bool>(false);