Revamp tag ui again; this time using a proper tree

This commit is contained in:
r00telement
2021-12-08 17:58:51 +00:00
parent 219e028caa
commit b7edb5b4a1
5 changed files with 594 additions and 342 deletions

View File

@@ -29,6 +29,7 @@ namespace PlayerTags
{
AllTagsChanges = new Tag(new LiteralPluginString(""))
{
IsSelected = true,
IsExpanded = true,
TagPositionInChat = TagPosition.Before,
TagPositionInNameplates = TagPosition.Replace,
@@ -38,6 +39,7 @@ namespace PlayerTags
AllRoleTagsChanges = new Tag(new LiteralPluginString(""))
{
IsSelected = false,
IsExpanded = true,
IsIconVisibleInChat = true,
IsTextVisibleInNameplates = true,
@@ -45,28 +47,32 @@ namespace PlayerTags
RoleTagsChanges[Role.LandHand] = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
IsSelected = false,
IsExpanded = false,
Icon = BitmapFontIcon.Crafter,
TextColor = 3,
}.GetChanges();
RoleTagsChanges[Role.Tank] = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
IsSelected = false,
IsExpanded = false,
Icon = BitmapFontIcon.Tank,
TextColor = 546,
}.GetChanges();
RoleTagsChanges[Role.Healer] = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
IsSelected = false,
IsExpanded = false,
Icon = BitmapFontIcon.Healer,
TextColor = 43,
}.GetChanges();
RoleTagsChanges[Role.DPS] = new Tag(new LiteralPluginString(""))
{
IsExpanded = true,
IsSelected = false,
IsExpanded = false,
Icon = BitmapFontIcon.DPS,
TextColor = 508,
}.GetChanges();
@@ -87,6 +93,8 @@ namespace PlayerTags
{
JobTagsChanges[classJob.Abbreviation.RawString] = new Tag(new LiteralPluginString(""))
{
IsSelected = false,
IsExpanded = false,
Text = classJob.Abbreviation.RawString,
}.GetChanges();
}
@@ -95,6 +103,7 @@ namespace PlayerTags
AllCustomTagsChanges = new Tag(new LiteralPluginString(""))
{
IsSelected = false,
IsExpanded = true,
IsTextVisibleInChat = true,
IsTextVisibleInNameplates = true,

View File

@@ -2,6 +2,7 @@
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Party;
using Dalamud.Interface;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
@@ -76,8 +77,25 @@ namespace PlayerTags
ImGui.Spacing();
DrawHeading(Strings.Loc_Static_Tags);
ImGui.TreePush();
Draw(m_PluginData.AllTags);
ImGui.BeginGroup();
ImGui.Columns(2);
ImGui.BeginGroup();
DrawTree(m_PluginData.AllTags);
ImGui.EndGroup();
ImGui.NextColumn();
ImGui.BeginGroup();
var selectedTag = m_PluginData.AllTags.Descendents.SingleOrDefault(descendent => descendent.IsSelected.Value);
if (selectedTag != null)
{
DrawControls(selectedTag);
}
ImGui.EndGroup();
ImGui.EndGroup();
ImGui.TreePop();
ImGui.Columns(1);
ImGui.Spacing();
@@ -174,226 +192,153 @@ namespace PlayerTags
}
}
public void Draw(Tag tag)
public string GetTreeItemName(Tag tag)
{
ImGui.PushID(tag.GetHashCode().ToString());
string collapsingHeaderName = tag.Name.Value;
string itemName = tag.Name.Value;
if (m_PluginData.CustomTags.Contains(tag))
{
if (tag.Text.InheritedValue != null)
{
collapsingHeaderName = tag.Text.InheritedValue;
itemName = tag.Text.InheritedValue;
}
else
{
collapsingHeaderName = "";
itemName = "";
}
}
if (ImGui.CollapsingHeader($"{collapsingHeaderName}###{tag.GetHashCode()}", tag.IsExpanded.Value ? ImGuiTreeNodeFlags.DefaultOpen : ImGuiTreeNodeFlags.None))
return itemName;
}
public void Select(Tag tag)
{
foreach (var descendent in m_PluginData.AllTags.Descendents)
{
if (!tag.IsExpanded.Value)
descendent.IsSelected.Value = false;
}
tag.IsSelected.Value = true;
m_PluginConfiguration.Save(m_PluginData);
}
public void DrawTree(Tag tag)
{
ImGui.PushID(tag.GetHashCode().ToString());
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.NoTreePushOnOpen | ImGuiTreeNodeFlags.SpanFullWidth | ImGuiTreeNodeFlags.AllowItemOverlap | ImGuiTreeNodeFlags.FramePadding;
if (!tag.Children.Any())
{
flags |= ImGuiTreeNodeFlags.Leaf;
}
if (tag.IsSelected.Value)
{
flags |= ImGuiTreeNodeFlags.Selected;
}
if (tag.IsExpanded.Value)
{
flags |= ImGuiTreeNodeFlags.DefaultOpen;
}
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(0, 3));
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
bool isOpened = ImGui.TreeNodeEx($"{GetTreeItemName(tag)}###{tag.GetHashCode()}", flags);
ImGui.PopStyleVar();
ImGui.PopStyleVar();
if (ImGui.IsItemClicked())
{
Select(tag);
}
// Add custom tag button
if (tag == m_PluginData.AllCustomTags)
{
ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.1f, 0.3f, 0.1f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0.2f, 0.6f, 0.2f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0.2f, 0.6f, 0.2f, 1));
ImGui.PushFont(UiBuilder.IconFont);
ImGui.GetCursorPos();
ImGui.GetContentRegionAvail();
ImGui.SetCursorPosX(ImGui.GetCursorPos().X + ImGui.GetContentRegionAvail().X - 23);
if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString()))
{
var newTag = new Tag(new LocalizedPluginString(nameof(PluginData.CustomTags)))
{
IsExpanded = true,
Text = Strings.Loc_Static_NewTag,
GameObjectNamesToApplyTo = ""
};
m_PluginData.CustomTags.Add(newTag);
newTag.Parent = m_PluginData.AllCustomTags;
Select(newTag);
}
ImGui.PopFont();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Strings.Loc_Static_AddCustomTag_Description);
}
}
// Remove custom tag button
if (m_PluginData.CustomTags.Contains(tag))
{
ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.3f, 0.1f, 0.1f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0.6f, 0.2f, 0.2f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0.6f, 0.2f, 0.2f, 1));
ImGui.PushFont(UiBuilder.IconFont);
ImGui.SetCursorPosX(ImGui.GetCursorPos().X + ImGui.GetContentRegionAvail().X - 23);
if (ImGui.Button(FontAwesomeIcon.TrashAlt.ToIconString()))
{
m_PluginData.AllCustomTags.Children.Remove(tag);
m_PluginData.CustomTags.Remove(tag);
m_PluginConfiguration.Save(m_PluginData);
Select(m_PluginData.AllCustomTags);
}
ImGui.PopFont();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Strings.Loc_Static_RemoveCustomTag_Description);
}
}
if (isOpened)
{
if (tag.Children.Any() && !tag.IsExpanded.Value)
{
tag.IsExpanded.Value = true;
m_PluginConfiguration.Save(m_PluginData);
}
ImGui.TreePush();
ImGui.BeginGroup();
ImGui.BeginGroup();
var addButtonSize = new Vector2(23, 23);
if (ImGui.IsPopupOpen("AddPopup"))
foreach (var childTag in tag.Children.OrderBy(child => GetTreeItemName(child)).ToArray())
{
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.2f, 0.6f, 0.2f, 1));
DrawTree(childTag);
}
else
{
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.1f, 0.3f, 0.1f, 1));
}
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0.2f, 0.6f, 0.2f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0.2f, 0.6f, 0.2f, 1));
ImGui.Text("");
// Add custom tag button
if (tag == m_PluginData.AllCustomTags)
{
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.1f, 0.3f, 0.1f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0.2f, 0.6f, 0.2f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0.2f, 0.6f, 0.2f, 1));
if (ImGui.Button(Strings.Loc_Static_AddCustomTag))
{
var newTag = new Tag(new LocalizedPluginString(nameof(PluginData.CustomTags)))
{
IsExpanded = true,
Text = "",
GameObjectNamesToApplyTo = ""
};
m_PluginData.CustomTags.Add(newTag);
newTag.Parent = m_PluginData.AllCustomTags;
m_PluginConfiguration.Save(m_PluginData);
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Strings.Loc_Static_AddCustomTag_Description);
}
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.SameLine();
}
// Remove custom tag button
if (m_PluginData.CustomTags.Contains(tag))
{
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.3f, 0.1f, 0.1f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0.6f, 0.2f, 0.2f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0.6f, 0.2f, 0.2f, 1));
if (ImGui.Button(Strings.Loc_Static_RemoveCustomTag))
{
m_PluginData.AllCustomTags.Children.Remove(tag);
m_PluginData.CustomTags.Remove(tag);
m_PluginConfiguration.Save(m_PluginData);
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Strings.Loc_Static_RemoveCustomTag_Description);
}
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.SameLine();
}
if (ImGui.Button("+", addButtonSize))
{
ImGui.OpenPopup("AddPopup");
}
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
bool wasPaddingConsumed = false;
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 5));
ImGui.SetNextWindowPos(ImGui.GetCursorScreenPos() - new Vector2(0, 4));
if (ImGui.BeginPopup("AddPopup"))
{
wasPaddingConsumed = true;
ImGui.PopStyleVar();
ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0f, 0f, 0f, 0));
if (ImGui.BeginListBox("###SelectableInheritables"))
{
var selectableInheritables = tag.Inheritables.Where(inheritable => inheritable.Value.Behavior == InheritableBehavior.Inherit).ToDictionary(item => item.Key, item => item.Value);
var selectableInheritablesWithLocalizedNames = selectableInheritables
.Select(inheritable => new { Name = inheritable.Key, LocalizedName = Localizer.GetString(inheritable.Key, false) })
.OrderBy(item => item.LocalizedName);
foreach (var inheritableLocalizedName in selectableInheritablesWithLocalizedNames)
{
bool isSelected = false;
if (ImGui.Selectable(inheritableLocalizedName.LocalizedName, isSelected))
{
selectableInheritables[inheritableLocalizedName.Name].Behavior = InheritableBehavior.Enabled;
if (selectableInheritables[inheritableLocalizedName.Name] is InheritableValue<bool> inheritableBool)
{
inheritableBool.Value = true;
}
m_PluginConfiguration.Save(m_PluginData);
ImGui.CloseCurrentPopup();
}
if (isSelected)
{
ImGui.SetItemDefaultFocus();
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Localizer.GetString(inheritableLocalizedName.Name, true));
}
}
ImGui.EndListBox();
}
ImGui.PopStyleColor();
ImGui.EndPopup();
}
if (!wasPaddingConsumed)
{
ImGui.PopStyleVar();
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Strings.Loc_Static_AddPropertyOverride_Description);
}
ImGui.EndGroup();
var selectedInheritables = tag.Inheritables.Where(inheritable => inheritable.Value.Behavior != InheritableBehavior.Inherit).ToDictionary(item => item.Key, item => item.Value);
var selectedInheritablesWithLocalizedNames = selectedInheritables
.Select(inheritable => new { Name = inheritable.Key, LocalizedName = Localizer.GetString(inheritable.Key, false) })
.OrderBy(item => item.LocalizedName);
foreach (var selectedInheritablesWithLocalizedName in selectedInheritablesWithLocalizedNames)
{
switch (selectedInheritablesWithLocalizedName.Name)
{
case nameof(tag.Icon):
DrawInheritable(nameof(tag.Icon), false, true, tag.Icon);
break;
case nameof(tag.IsIconVisibleInChat):
DrawInheritable(nameof(tag.IsIconVisibleInChat), tag.IsIconVisibleInChat);
break;
case nameof(tag.IsIconVisibleInNameplates):
DrawInheritable(nameof(tag.IsIconVisibleInNameplates), tag.IsIconVisibleInNameplates);
break;
case nameof(tag.Text):
DrawInheritable(nameof(tag.Text), tag.Text);
break;
case nameof(tag.TextColor):
DrawInheritable(nameof(tag.TextColor), tag.TextColor);
break;
case nameof(tag.IsTextItalic):
DrawInheritable(nameof(tag.IsTextItalic), tag.IsTextItalic);
break;
case nameof(tag.IsTextVisibleInChat):
DrawInheritable(nameof(tag.IsTextVisibleInChat), tag.IsTextVisibleInChat);
break;
case nameof(tag.IsTextVisibleInNameplates):
DrawInheritable(nameof(tag.IsTextVisibleInNameplates), tag.IsTextVisibleInNameplates);
break;
case nameof(tag.TagPositionInChat):
DrawInheritable(nameof(tag.TagPositionInChat), true, false, tag.TagPositionInChat);
break;
case nameof(tag.TagPositionInNameplates):
DrawInheritable(nameof(tag.TagPositionInNameplates), true, false, tag.TagPositionInNameplates);
break;
case nameof(tag.TagTargetInNameplates):
DrawInheritable(nameof(tag.TagTargetInNameplates), true, false, tag.TagTargetInNameplates);
break;
case nameof(tag.GameObjectNamesToApplyTo):
DrawInheritable(nameof(tag.GameObjectNamesToApplyTo), tag.GameObjectNamesToApplyTo);
break;
default:
break;
}
}
foreach (var childTag in tag.Children.ToArray())
{
Draw(childTag);
}
ImGui.EndGroup();
ImGui.TreePop();
}
else if (tag.IsExpanded.Value)
@@ -405,17 +350,168 @@ namespace PlayerTags
ImGui.PopID();
}
public void DrawControls(Tag tag)
{
ImGui.PushID(tag.GetHashCode().ToString());
ImGui.TreePush();
ImGui.BeginGroup();
ImGui.BeginGroup();
var addButtonSize = new Vector2(23, 23);
if (ImGui.IsPopupOpen("AddPopup"))
{
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.2f, 0.6f, 0.2f, 1));
}
else
{
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.1f, 0.3f, 0.1f, 1));
}
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0.2f, 0.6f, 0.2f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0.2f, 0.6f, 0.2f, 1));
ImGui.Text("");
ImGui.PushFont(UiBuilder.IconFont);
if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString(), addButtonSize))
{
ImGui.OpenPopup("AddPopup");
}
ImGui.PopFont();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
bool wasPaddingConsumed = false;
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 5));
ImGui.SetNextWindowPos(ImGui.GetCursorScreenPos() - new Vector2(0, 4));
if (ImGui.BeginPopup("AddPopup"))
{
wasPaddingConsumed = true;
ImGui.PopStyleVar();
ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0f, 0f, 0f, 0));
if (ImGui.BeginListBox("###SelectableInheritables"))
{
var selectableInheritables = tag.Inheritables.Where(inheritable => inheritable.Value.Behavior == InheritableBehavior.Inherit).ToDictionary(item => item.Key, item => item.Value);
var selectableInheritablesWithLocalizedNames = selectableInheritables
.Select(inheritable => new { Name = inheritable.Key, LocalizedName = Localizer.GetString(inheritable.Key, false) })
.OrderBy(item => item.LocalizedName);
foreach (var inheritableLocalizedName in selectableInheritablesWithLocalizedNames)
{
bool isSelected = false;
if (ImGui.Selectable(inheritableLocalizedName.LocalizedName, isSelected))
{
selectableInheritables[inheritableLocalizedName.Name].Behavior = InheritableBehavior.Enabled;
if (selectableInheritables[inheritableLocalizedName.Name] is InheritableValue<bool> inheritableBool)
{
inheritableBool.Value = true;
}
m_PluginConfiguration.Save(m_PluginData);
ImGui.CloseCurrentPopup();
}
if (isSelected)
{
ImGui.SetItemDefaultFocus();
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Localizer.GetString(inheritableLocalizedName.Name, true));
}
}
ImGui.EndListBox();
}
ImGui.PopStyleColor();
ImGui.EndPopup();
}
if (!wasPaddingConsumed)
{
ImGui.PopStyleVar();
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(Strings.Loc_Static_AddPropertyOverride_Description);
}
ImGui.EndGroup();
var selectedInheritables = tag.Inheritables/*.Where(inheritable => inheritable.Value.Behavior != InheritableBehavior.Inherit)*/.ToDictionary(item => item.Key, item => item.Value);
var selectedInheritablesWithLocalizedNames = selectedInheritables
.Select(inheritable => new { Name = inheritable.Key, LocalizedName = Localizer.GetString(inheritable.Key, false) })
.OrderBy(item => item.LocalizedName);
foreach (var selectedInheritablesWithLocalizedName in selectedInheritablesWithLocalizedNames)
{
switch (selectedInheritablesWithLocalizedName.Name)
{
case nameof(tag.Icon):
DrawInheritable(nameof(tag.Icon), false, true, tag.Icon);
break;
case nameof(tag.IsIconVisibleInChat):
DrawInheritable(nameof(tag.IsIconVisibleInChat), tag.IsIconVisibleInChat);
break;
case nameof(tag.IsIconVisibleInNameplates):
DrawInheritable(nameof(tag.IsIconVisibleInNameplates), tag.IsIconVisibleInNameplates);
break;
case nameof(tag.Text):
DrawInheritable(nameof(tag.Text), tag.Text);
break;
case nameof(tag.TextColor):
DrawInheritable(nameof(tag.TextColor), tag.TextColor);
break;
case nameof(tag.IsTextItalic):
DrawInheritable(nameof(tag.IsTextItalic), tag.IsTextItalic);
break;
case nameof(tag.IsTextVisibleInChat):
DrawInheritable(nameof(tag.IsTextVisibleInChat), tag.IsTextVisibleInChat);
break;
case nameof(tag.IsTextVisibleInNameplates):
DrawInheritable(nameof(tag.IsTextVisibleInNameplates), tag.IsTextVisibleInNameplates);
break;
case nameof(tag.TagPositionInChat):
DrawInheritable(nameof(tag.TagPositionInChat), true, false, tag.TagPositionInChat);
break;
case nameof(tag.TagPositionInNameplates):
DrawInheritable(nameof(tag.TagPositionInNameplates), true, false, tag.TagPositionInNameplates);
break;
case nameof(tag.TagTargetInNameplates):
DrawInheritable(nameof(tag.TagTargetInNameplates), true, false, tag.TagTargetInNameplates);
break;
case nameof(tag.GameObjectNamesToApplyTo):
DrawInheritable(nameof(tag.GameObjectNamesToApplyTo), tag.GameObjectNamesToApplyTo);
break;
default:
break;
}
}
ImGui.PopID();
}
private void DrawRemoveButton(IInheritable inheritable)
{
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(0, 0));
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.3f, 0.1f, 0.1f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0.6f, 0.2f, 0.2f, 1));
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0.6f, 0.2f, 0.2f, 1));
if (ImGui.Button($"x", new Vector2(23, 23)))
ImGui.PushFont(UiBuilder.IconFont);
if (ImGui.Button(FontAwesomeIcon.TrashAlt.ToIconString(), new Vector2(23, 23)))
{
inheritable.Behavior = InheritableBehavior.Inherit;
m_PluginConfiguration.Save(m_PluginData);
}
ImGui.PopFont();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
ImGui.PopStyleColor();
@@ -428,166 +524,288 @@ namespace PlayerTags
private void DrawInheritable(string localizedStringName, InheritableValue<bool> inheritable)
{
ImGui.SameLine();
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f);
}
ImGui.BeginGroup();
ImGui.Indent();
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(180, 50));
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(0 , 50));
ImGui.Text(Localizer.GetString(localizedStringName, false));
DrawCheckbox("IsEnabled", false, ref inheritable.Value, () =>
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
m_PluginConfiguration.Save(m_PluginData);
});
ImGui.SameLine();
ImGui.TextColored(new Vector4(0.66f, 0.5f, 0.5f, 1), Strings.Loc_Static_Inherited);
}
ImGui.SameLine();
DrawRemoveButton(inheritable);
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
bool value = inheritable.InheritedValue != null ? inheritable.InheritedValue.Value : false;
DrawCheckbox("IsEnabled", false, ref value, () =>
{
});
}
else
{
DrawCheckbox("IsEnabled", false, ref inheritable.Value, () =>
{
m_PluginConfiguration.Save(m_PluginData);
});
ImGui.SameLine();
DrawRemoveButton(inheritable);
}
ImGui.EndChild();
ImGui.EndGroup();
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.PopStyleVar();
}
}
private void DrawInheritable<TEnum>(string localizedStringName, bool shouldLocalizeNames, bool shouldOrderNames, InheritableValue<TEnum> inheritable)
where TEnum : struct, Enum
{
ImGui.SameLine();
ImGui.BeginGroup();
ImGui.Indent();
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(180, 50));
ImGui.Text(Localizer.GetString(localizedStringName, false));
bool isEnabled = inheritable.Behavior == InheritableBehavior.Enabled;
DrawCheckbox("IsEnabled", false, ref isEnabled, () =>
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
if (isEnabled)
{
inheritable.Behavior = InheritableBehavior.Enabled;
}
else
{
inheritable.Behavior = InheritableBehavior.Disabled;
}
m_PluginConfiguration.Save(m_PluginData);
});
if (isEnabled)
{
ImGui.SameLine();
DrawComboBox(false, shouldLocalizeNames, shouldOrderNames, ref inheritable.Value, () => { m_PluginConfiguration.Save(m_PluginData); });
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f);
}
ImGui.SameLine();
DrawRemoveButton(inheritable);
ImGui.BeginGroup();
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(0, 50));
ImGui.Text(Localizer.GetString(localizedStringName, false));
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.SameLine();
ImGui.TextColored(new Vector4(0.66f, 0.5f, 0.5f, 1), Strings.Loc_Static_Inherited);
}
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
bool isEnabled = inheritable.InheritedValue != null;
DrawCheckbox("IsEnabled", false, ref isEnabled, () => { });
if (isEnabled)
{
ImGui.SameLine();
ImGui.SetNextItemWidth(200);
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(200, 0));
TEnum value = inheritable.InheritedValue != null ? inheritable.InheritedValue.Value : default(TEnum);
DrawComboBox(false, shouldLocalizeNames, shouldOrderNames, ref value, () => { });
ImGui.EndChild();
}
}
else
{
bool isEnabled = inheritable.Behavior == InheritableBehavior.Enabled;
DrawCheckbox("IsEnabled", false, ref isEnabled, () =>
{
if (isEnabled)
{
inheritable.Behavior = InheritableBehavior.Enabled;
}
else
{
inheritable.Behavior = InheritableBehavior.Disabled;
}
m_PluginConfiguration.Save(m_PluginData);
});
if (isEnabled)
{
ImGui.SameLine();
ImGui.SetNextItemWidth(200);
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(200, 0));
DrawComboBox(false, shouldLocalizeNames, shouldOrderNames, ref inheritable.Value, () => { m_PluginConfiguration.Save(m_PluginData); });
ImGui.EndChild();
}
ImGui.SameLine();
DrawRemoveButton(inheritable);
}
ImGui.EndChild();
ImGui.EndGroup();
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.PopStyleVar();
}
}
private void DrawInheritable(string localizedStringName, InheritableValue<ushort> inheritable)
{
ImGui.SameLine();
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f);
}
ImGui.BeginGroup();
ImGui.Indent();
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(180, 50));
ImGui.Text(Localizer.GetString(localizedStringName, false));
bool isEnabled = inheritable.Behavior == InheritableBehavior.Enabled;
DrawCheckbox("IsEnabled", false, ref isEnabled, () =>
{
if (isEnabled)
{
inheritable.Behavior = InheritableBehavior.Enabled;
}
else
{
inheritable.Behavior = InheritableBehavior.Disabled;
}
m_PluginConfiguration.Save(m_PluginData);
});
if (isEnabled)
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.SameLine();
DrawColorButton(
inheritable.Value.ToString(),
UIColorHelper.ToColor(inheritable.Value),
() =>
{
m_ColorPickerPopupDataContext = inheritable;
ImGui.OpenPopup("ColorPickerPopup");
});
ImGui.TextColored(new Vector4(0.66f, 0.5f, 0.5f, 1), Strings.Loc_Static_Inherited);
}
bool wasStyleConsumed = false;
ImGui.SetNextWindowPos(ImGui.GetCursorScreenPos() + new Vector2(31, 0));
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
if (ImGui.BeginPopup("ColorPickerPopup"))
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
wasStyleConsumed = true;
ImGui.PopStyleVar();
bool isEnabled = inheritable.InheritedValue != null;
DrawCheckbox("IsEnabled", false, ref isEnabled, () => { });
DrawUIColorPicker(
(UIColor value) =>
if (isEnabled)
{
ImGui.SameLine();
ushort value = inheritable.InheritedValue != null ? inheritable.InheritedValue.Value : default(ushort);
DrawColorButton(value.ToString(), UIColorHelper.ToColor(value), () => { });
}
}
else
{
bool isEnabled = inheritable.Behavior == InheritableBehavior.Enabled;
DrawCheckbox("IsEnabled", false, ref isEnabled, () =>
{
if (isEnabled)
{
if (m_ColorPickerPopupDataContext != null)
inheritable.Behavior = InheritableBehavior.Enabled;
}
else
{
inheritable.Behavior = InheritableBehavior.Disabled;
}
m_PluginConfiguration.Save(m_PluginData);
});
if (isEnabled)
{
ImGui.SameLine();
DrawColorButton(
inheritable.Value.ToString(),
UIColorHelper.ToColor(inheritable.Value),
() =>
{
m_ColorPickerPopupDataContext.Value = (ushort)value.RowId;
m_ColorPickerPopupDataContext = null;
m_PluginConfiguration.Save(m_PluginData);
}
m_ColorPickerPopupDataContext = inheritable;
ImGui.OpenPopup("ColorPickerPopup");
});
}
ImGui.CloseCurrentPopup();
});
bool wasStyleConsumed = false;
ImGui.SetNextWindowPos(ImGui.GetCursorScreenPos() + new Vector2(31, 0));
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
if (ImGui.BeginPopup("ColorPickerPopup"))
{
wasStyleConsumed = true;
ImGui.PopStyleVar();
ImGui.EndPopup();
DrawUIColorPicker(
(UIColor value) =>
{
if (m_ColorPickerPopupDataContext != null)
{
m_ColorPickerPopupDataContext.Value = (ushort)value.RowId;
m_ColorPickerPopupDataContext = null;
m_PluginConfiguration.Save(m_PluginData);
}
ImGui.CloseCurrentPopup();
});
ImGui.EndPopup();
}
if (!wasStyleConsumed)
{
ImGui.PopStyleVar();
}
ImGui.SameLine();
DrawRemoveButton(inheritable);
}
if (!wasStyleConsumed)
{
ImGui.PopStyleVar();
}
ImGui.SameLine();
DrawRemoveButton(inheritable);
ImGui.EndChild();
ImGui.EndGroup();
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.PopStyleVar();
}
}
private void DrawInheritable(string localizedStringName, InheritableReference<string> inheritable)
{
ImGui.SameLine();
ImGui.BeginGroup();
ImGui.Indent();
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(180, 50));
ImGui.Text(Localizer.GetString(localizedStringName, false));
bool isEnabled = inheritable.Behavior == InheritableBehavior.Enabled;
DrawCheckbox("IsEnabled", false, ref isEnabled, () =>
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
if (isEnabled)
{
inheritable.Behavior = InheritableBehavior.Enabled;
}
else
{
inheritable.Behavior = InheritableBehavior.Disabled;
}
m_PluginConfiguration.Save(m_PluginData);
});
if (isEnabled)
{
ImGui.SameLine();
DrawTextBox(localizedStringName, ref inheritable.Value, () => { m_PluginConfiguration.Save(m_PluginData); });
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.25f);
}
ImGui.SameLine();
DrawRemoveButton(inheritable);
ImGui.BeginGroup();
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(0, 50));
ImGui.Text(Localizer.GetString(localizedStringName, false));
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.SameLine();
ImGui.TextColored(new Vector4(0.66f, 0.5f, 0.5f, 1), Strings.Loc_Static_Inherited);
}
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
bool isEnabled = inheritable.InheritedValue != null;
DrawCheckbox("IsEnabled", false, ref isEnabled, () =>
{
});
if (isEnabled)
{
ImGui.SameLine();
ImGui.SetNextItemWidth(200);
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(200, 0));
string value = inheritable.Value;
DrawTextBox(localizedStringName, ref value, () => { });
ImGui.EndChild();
}
}
else
{
bool isEnabled = inheritable.Behavior == InheritableBehavior.Enabled;
DrawCheckbox("IsEnabled", false, ref isEnabled, () =>
{
if (isEnabled)
{
inheritable.Behavior = InheritableBehavior.Enabled;
}
else
{
inheritable.Behavior = InheritableBehavior.Disabled;
}
m_PluginConfiguration.Save(m_PluginData);
});
if (isEnabled)
{
ImGui.SameLine();
ImGui.SetNextItemWidth(200);
ImGui.BeginChild(inheritable.GetHashCode().ToString(), new Vector2(200, 0));
DrawTextBox(localizedStringName, ref inheritable.Value, () => { m_PluginConfiguration.Save(m_PluginData); });
ImGui.EndChild();
}
ImGui.SameLine();
DrawRemoveButton(inheritable);
}
ImGui.EndChild();
ImGui.EndGroup();
if (inheritable.Behavior == InheritableBehavior.Inherit)
{
ImGui.PopStyleVar();
}
}
private void DrawHeading(string label)

View File

@@ -231,6 +231,15 @@ namespace PlayerTags.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Selected.
/// </summary>
public static string Loc_IsSelected {
get {
return ResourceManager.GetString("Loc_IsSelected", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Text italic.
/// </summary>
@@ -564,15 +573,6 @@ namespace PlayerTags.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Add.
/// </summary>
public static string Loc_Static_AddCustomTag {
get {
return ResourceManager.GetString("Loc_Static_AddCustomTag", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Add a new custom tag..
/// </summary>
@@ -636,6 +636,15 @@ namespace PlayerTags.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Inherited&gt;.
/// </summary>
public static string Loc_Static_Inherited {
get {
return ResourceManager.GetString("Loc_Static_Inherited", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Nameplates.
/// </summary>
@@ -645,6 +654,15 @@ namespace PlayerTags.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to New tag.
/// </summary>
public static string Loc_Static_NewTag {
get {
return ResourceManager.GetString("Loc_Static_NewTag", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Add custom tags to party members.
/// </summary>
@@ -672,15 +690,6 @@ namespace PlayerTags.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Remove.
/// </summary>
public static string Loc_Static_RemoveCustomTag {
get {
return ResourceManager.GetString("Loc_Static_RemoveCustomTag", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Remove this custom tag..
/// </summary>

View File

@@ -144,6 +144,12 @@
<data name="Loc_Static_Format_AddTagToPlayer" xml:space="preserve">
<value>Add '{0}' to {1}.</value>
</data>
<data name="Loc_Static_Inherited" xml:space="preserve">
<value>&lt;Inherited&gt;</value>
</data>
<data name="Loc_IsSelected" xml:space="preserve">
<value>Selected</value>
</data>
<data name="Loc_IsExpanded" xml:space="preserve">
<value>Expanded</value>
</data>
@@ -279,15 +285,12 @@
<data name="Loc_Static_RemovePropertyOverride_Description" xml:space="preserve">
<value>Remove this override. The value will be inherited.</value>
</data>
<data name="Loc_Static_AddCustomTag" xml:space="preserve">
<value>Add</value>
<data name="Loc_Static_NewTag" xml:space="preserve">
<value>New tag</value>
</data>
<data name="Loc_Static_AddCustomTag_Description" xml:space="preserve">
<value>Add a new custom tag.</value>
</data>
<data name="Loc_Static_RemoveCustomTag" xml:space="preserve">
<value>Remove</value>
</data>
<data name="Loc_Static_RemoveCustomTag_Description" xml:space="preserve">
<value>Remove this custom tag.</value>
</data>

View File

@@ -40,6 +40,21 @@ namespace PlayerTags
public List<Tag> Children { get; } = new List<Tag>();
public IEnumerable<Tag> Descendents
{
get
{
IEnumerable<Tag> descendents = Children.Prepend(this);
foreach (var child in Children)
{
descendents = descendents.Union(child.Descendents);
}
return descendents.Distinct();
}
}
private Dictionary<string, IInheritable>? m_Inheritables = null;
public Dictionary<string, IInheritable> Inheritables
{
@@ -64,10 +79,8 @@ namespace PlayerTags
}
}
public InheritableValue<bool> IsExpanded = new InheritableValue<bool>(false)
{
Behavior = InheritableBehavior.Enabled
};
public InheritableValue<bool> IsSelected = new InheritableValue<bool>(false);
public InheritableValue<bool> IsExpanded = new InheritableValue<bool>(false);
public InheritableValue<BitmapFontIcon> Icon = new InheritableValue<BitmapFontIcon>(BitmapFontIcon.Aethernet);
public InheritableValue<bool> IsIconVisibleInChat = new InheritableValue<bool>(false);