diff --git a/PlayerTags/Plugin.cs b/PlayerTags/Plugin.cs index efd5f54..2987c2b 100644 --- a/PlayerTags/Plugin.cs +++ b/PlayerTags/Plugin.cs @@ -157,11 +157,11 @@ namespace PlayerTags }))); } - // TODO: Temp hack because when opening somewhere other than the chat log, the last added item for some reason is added to the { }))); - } + //// TODO: Temp hack because when opening somewhere other than the chat log, the last added item for some reason is added to the { }))); + //} })); if (!removedTags.Any()) @@ -186,11 +186,11 @@ namespace PlayerTags }))); } - // TODO: Temp hack because when opening somewhere other than the chat log, the last added item for some reason is added to the { }))); - } + //// TODO: Temp hack because when opening somewhere other than the chat log, the last added item for some reason is added to the { }))); + //} })); if (!addedTags.Any()) diff --git a/PlayerTags/PluginConfigurationUI.cs b/PlayerTags/PluginConfigurationUI.cs index 6b07319..43e15d4 100644 --- a/PlayerTags/PluginConfigurationUI.cs +++ b/PlayerTags/PluginConfigurationUI.cs @@ -41,11 +41,19 @@ namespace PlayerTags ImGui.TextWrapped(Strings.Loc_Static_WarningMessage); ImGui.PopStyleColor(); + + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.Spacing(); DrawHeading(Strings.Loc_Static_General); ImGui.TreePush(); DrawCheckbox(nameof(m_PluginConfiguration.IsCustomTagContextMenuEnabled), true, ref m_PluginConfiguration.IsCustomTagContextMenuEnabled, () => m_PluginConfiguration.Save(m_PluginData)); ImGui.TreePop(); + + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.Spacing(); DrawHeading(Strings.Loc_Static_Nameplates); ImGui.TreePush(); DrawComboBox(true, true, false, ref m_PluginConfiguration.NameplateFreeCompanyVisibility, () => m_PluginConfiguration.Save(m_PluginData)); @@ -53,18 +61,28 @@ namespace PlayerTags DrawComboBox(true, true, false, ref m_PluginConfiguration.NameplateTitlePosition, () => m_PluginConfiguration.Save(m_PluginData)); ImGui.TreePop(); + + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.Spacing(); DrawHeading(Strings.Loc_Static_Development); ImGui.TreePush(); DrawCheckbox(nameof(m_PluginConfiguration.IsPlayerNameRandomlyGenerated), true, ref m_PluginConfiguration.IsPlayerNameRandomlyGenerated, () => m_PluginConfiguration.Save(m_PluginData)); ImGui.TreePop(); + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.Spacing(); DrawHeading(Strings.Loc_Static_Tags); ImGui.TreePush(); Draw(m_PluginData.AllTags); ImGui.TreePop(); + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.Spacing(); DrawHeading(Strings.Loc_Static_PartyAssign); ImGui.TreePush(); if (ImGui.BeginTable("##PartyAssignTable", 1 + m_PluginData.CustomTags.Count)) @@ -80,13 +98,21 @@ namespace PlayerTags } ImGui.TableHeadersRow(); - var drawPartyMember = (string playerName) => + var drawPartyMember = (string playerName, int rowIndex) => { ImGui.PushID(playerName); ImGui.TableNextRow(); + if (rowIndex % 2 != 0) + { + var backgroundColor = ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 0.05f)); + ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBg1, backgroundColor); + } + ImGui.TableNextColumn(); + + ImGui.AlignTextToFramePadding(); ImGui.Text(playerName); foreach (Tag customTag in m_PluginData.CustomTags) @@ -96,8 +122,8 @@ namespace PlayerTags ImGui.TableNextColumn(); bool isTagAssigned = customTag.IncludesGameObjectNameToApplyTo(playerName); - - DrawCheckbox("IsEnabled", false, ref isTagAssigned, () => + + DrawSimpleCheckbox(string.Format(Strings.Loc_Static_Format_AddTagToPlayer, customTag.Text.InheritedValue, playerName), ref isTagAssigned, () => { if (isTagAssigned) { @@ -117,20 +143,28 @@ namespace PlayerTags ImGui.PopID(); }; + int rowIndex = 0; foreach (var partyMember in m_PartyList) { - drawPartyMember(partyMember.Name.TextValue); + drawPartyMember(partyMember.Name.TextValue, rowIndex); + ++rowIndex; } if (m_PartyList.Length == 0 && m_ClientState.LocalPlayer != null) { - drawPartyMember(m_ClientState.LocalPlayer.Name.TextValue); + drawPartyMember(m_ClientState.LocalPlayer.Name.TextValue, 0); } ImGui.EndTable(); } ImGui.TreePop(); + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.End(); } @@ -182,6 +216,60 @@ namespace PlayerTags 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"); @@ -247,6 +335,7 @@ namespace PlayerTags { 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); @@ -299,56 +388,11 @@ namespace PlayerTags } } - if (m_PluginData.CustomTags.Contains(tag)) - { - ImGui.SameLine(); - ImGui.BeginGroup(); - ImGui.Indent(); - ImGui.Text(""); - - 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); - } - ImGui.PopStyleColor(); - ImGui.PopStyleColor(); - ImGui.PopStyleColor(); - ImGui.EndGroup(); - } - foreach (var childTag in tag.Children.ToArray()) { Draw(childTag); } - 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); - } - ImGui.PopStyleColor(); - ImGui.PopStyleColor(); - ImGui.PopStyleColor(); - } - ImGui.EndGroup(); ImGui.TreePop(); } @@ -614,6 +658,19 @@ namespace PlayerTags } } + private void DrawSimpleCheckbox(string localizedString, ref bool isChecked, System.Action changed) + { + if (ImGui.Checkbox($"###{localizedString}", ref isChecked)) + { + changed(); + } + + if (ImGui.IsItemHovered()) + { + ImGui.SetTooltip(localizedString); + } + } + private void DrawColorButton(string colorId, Vector4 color, System.Action clicked) { ImGui.PushStyleColor(ImGuiCol.Button, color); diff --git a/PlayerTags/Resources/Strings.Designer.cs b/PlayerTags/Resources/Strings.Designer.cs index ac5a97c..704c029 100644 --- a/PlayerTags/Resources/Strings.Designer.cs +++ b/PlayerTags/Resources/Strings.Designer.cs @@ -556,7 +556,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Add a custom tag. + /// Looks up a localized string similar to Add. /// public static string Loc_Static_AddCustomTag { get { @@ -564,6 +564,15 @@ namespace PlayerTags.Resources { } } + /// + /// Looks up a localized string similar to Add a new custom tag.. + /// + public static string Loc_Static_AddCustomTag_Description { + get { + return ResourceManager.GetString("Loc_Static_AddCustomTag_Description", resourceCulture); + } + } + /// /// Looks up a localized string similar to Add an override.. /// @@ -600,6 +609,15 @@ namespace PlayerTags.Resources { } } + /// + /// Looks up a localized string similar to Add '{0}' to {1}.. + /// + public static string Loc_Static_Format_AddTagToPlayer { + get { + return ResourceManager.GetString("Loc_Static_Format_AddTagToPlayer", resourceCulture); + } + } + /// /// Looks up a localized string similar to General. /// @@ -619,7 +637,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Assign custom tags to party. + /// Looks up a localized string similar to Add custom tags to party members. /// public static string Loc_Static_PartyAssign { get { @@ -628,7 +646,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Player name. + /// Looks up a localized string similar to Player. /// public static string Loc_Static_PlayerName { get { @@ -646,7 +664,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Remove this custom tag. + /// Looks up a localized string similar to Remove. /// public static string Loc_Static_RemoveCustomTag { get { @@ -654,6 +672,15 @@ namespace PlayerTags.Resources { } } + /// + /// Looks up a localized string similar to Remove this custom tag.. + /// + public static string Loc_Static_RemoveCustomTag_Description { + get { + return ResourceManager.GetString("Loc_Static_RemoveCustomTag_Description", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remove this override. The value will be inherited.. /// diff --git a/PlayerTags/Resources/Strings.resx b/PlayerTags/Resources/Strings.resx index 88d0f56..e09c8b8 100644 --- a/PlayerTags/Resources/Strings.resx +++ b/PlayerTags/Resources/Strings.resx @@ -127,10 +127,10 @@ General - Assign custom tags to party + Add custom tags to party members - Player name + Player Add tag @@ -141,6 +141,9 @@ Nameplates + + Add '{0}' to {1}. + Enable context menu options for custom tags @@ -274,12 +277,17 @@ Remove this override. The value will be inherited. - Add a custom tag + Add + + + Add a new custom tag. - Remove this custom tag + Remove + + + Remove this custom tag. - Icon diff --git a/PlayerTags/Tag.cs b/PlayerTags/Tag.cs index d6a84ef..f71d596 100644 --- a/PlayerTags/Tag.cs +++ b/PlayerTags/Tag.cs @@ -94,7 +94,7 @@ namespace PlayerTags return new string[] { }; } - return GameObjectNamesToApplyTo.InheritedValue.Split(';', ','); + return GameObjectNamesToApplyTo.InheritedValue.Split(';', ',').Where(item => !string.IsNullOrEmpty(item)).ToArray(); } } @@ -127,7 +127,7 @@ namespace PlayerTags newSplitGameObjectNamesToApplyTo.Add(gameObjectName); - GameObjectNamesToApplyTo = string.Join(";", newSplitGameObjectNamesToApplyTo); + GameObjectNamesToApplyTo = string.Join(",", newSplitGameObjectNamesToApplyTo); } public void RemoveGameObjectNameToApplyTo(string gameObjectName) @@ -142,7 +142,7 @@ namespace PlayerTags var index = Array.IndexOf(CleanGameObjectNamesToApplyTo, gameObjectName.ToLower()); newSplitGameObjectNamesToApplyTo.RemoveAt(index); - GameObjectNamesToApplyTo = string.Join(";", newSplitGameObjectNamesToApplyTo); + GameObjectNamesToApplyTo = string.Join(",", newSplitGameObjectNamesToApplyTo); } public Dictionary GetChanges(Dictionary? defaultChanges = null)