diff --git a/PlayerTags/Plugin.cs b/PlayerTags/Plugin.cs index 40a4ee7..260f38a 100644 --- a/PlayerTags/Plugin.cs +++ b/PlayerTags/Plugin.cs @@ -69,7 +69,7 @@ namespace PlayerTags m_PluginConfiguration = PluginInterface.GetPluginConfig() as PluginConfiguration ?? new PluginConfiguration(); m_PluginConfiguration.Initialize(PluginInterface); m_PluginData.Initialize(DataManager, m_PluginConfiguration); - m_PluginConfigurationUI = new PluginConfigurationUI(m_PluginConfiguration, m_PluginData, ClientState, PartyList); + m_PluginConfigurationUI = new PluginConfigurationUI(m_PluginConfiguration, m_PluginData, ClientState, PartyList, ObjectTable); ClientState.Login += ClientState_Login; ClientState.Logout += ClientState_Logout; diff --git a/PlayerTags/PluginConfigurationUI.cs b/PlayerTags/PluginConfigurationUI.cs index dcdce94..5b6efb9 100644 --- a/PlayerTags/PluginConfigurationUI.cs +++ b/PlayerTags/PluginConfigurationUI.cs @@ -20,14 +20,16 @@ namespace PlayerTags private PluginData m_PluginData; private ClientState m_ClientState; private PartyList m_PartyList; + private ObjectTable m_ObjectTable; private InheritableValue? m_ColorPickerPopupDataContext; - public PluginConfigurationUI(PluginConfiguration config, PluginData pluginData, ClientState clientState, PartyList partyList) + public PluginConfigurationUI(PluginConfiguration config, PluginData pluginData, ClientState clientState, PartyList partyList, ObjectTable objectTable) { m_PluginConfiguration = config; m_PluginData = pluginData; m_ClientState = clientState; m_PartyList = partyList; + m_ObjectTable = objectTable; } public void Draw() @@ -43,145 +45,179 @@ 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)); - DrawComboBox(true, true, false, ref m_PluginConfiguration.NameplateTitleVisibility, () => m_PluginConfiguration.Save(m_PluginData)); - 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(); - DrawCheckbox(nameof(m_PluginConfiguration.IsShowInheritedPropertiesEnabled), true, ref m_PluginConfiguration.IsShowInheritedPropertiesEnabled, () => m_PluginConfiguration.Save(m_PluginData)); - ImGui.BeginGroup(); - ImGui.Columns(2); - - ImGui.BeginGroup(); - DrawTree(m_PluginData.AllTags); - ImGui.EndGroup(); - - ImGui.NextColumn(); - var selectedTag = m_PluginData.AllTags.Descendents.SingleOrDefault(descendent => descendent.IsSelected.Value); - if (selectedTag != null) + if (ImGui.BeginTabBar("MainTabs")) { - DrawControls(selectedTag); - } - - ImGui.EndGroup(); - ImGui.TreePop(); - ImGui.Columns(1); - - - ImGui.Spacing(); - ImGui.Spacing(); - ImGui.Spacing(); - DrawHeading(Strings.Loc_Static_PartyAssign); - ImGui.TreePush(); - if (ImGui.BeginTable("##PartyAssignTable", 1 + m_PluginData.CustomTags.Count)) - { - ImGui.TableHeader(Strings.Loc_Static_PlayerName); - ImGui.TableSetupColumn(Strings.Loc_Static_PlayerName); - ImGui.NextColumn(); - foreach (var customTag in m_PluginData.CustomTags) + if (ImGui.BeginTabItem(Strings.Loc_Static_General)) { - ImGui.TableHeader(customTag.Text.InheritedValue); - ImGui.TableSetupColumn(customTag.Text.InheritedValue); + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.TreePush(); + DrawCheckbox(nameof(m_PluginConfiguration.IsCustomTagContextMenuEnabled), true, ref m_PluginConfiguration.IsCustomTagContextMenuEnabled, () => m_PluginConfiguration.Save(m_PluginData)); + ImGui.TreePop(); + + + ImGui.Spacing(); + ImGui.Spacing(); + DrawHeading(Strings.Loc_Static_Nameplates); + ImGui.TreePush(); + DrawComboBox(true, true, false, ref m_PluginConfiguration.NameplateFreeCompanyVisibility, () => m_PluginConfiguration.Save(m_PluginData)); + DrawComboBox(true, true, false, ref m_PluginConfiguration.NameplateTitleVisibility, () => m_PluginConfiguration.Save(m_PluginData)); + DrawComboBox(true, true, false, ref m_PluginConfiguration.NameplateTitlePosition, () => m_PluginConfiguration.Save(m_PluginData)); + ImGui.TreePop(); + + + 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.EndTabItem(); + } + + if (ImGui.BeginTabItem(Strings.Loc_Static_Tags)) + { + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.TreePush(); + DrawCheckbox(nameof(m_PluginConfiguration.IsShowInheritedPropertiesEnabled), true, ref m_PluginConfiguration.IsShowInheritedPropertiesEnabled, () => m_PluginConfiguration.Save(m_PluginData)); + ImGui.BeginGroup(); + ImGui.Columns(2); + + ImGui.BeginGroup(); + DrawTree(m_PluginData.AllTags); + ImGui.EndGroup(); + ImGui.NextColumn(); - } - ImGui.TableHeadersRow(); - - var drawPartyMember = (string playerName, int rowIndex) => - { - ImGui.PushID(playerName); - - ImGui.TableNextRow(); - - if (rowIndex % 2 != 0) + var selectedTag = m_PluginData.AllTags.Descendents.SingleOrDefault(descendent => descendent.IsSelected.Value); + if (selectedTag != null) { - var backgroundColor = ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 0.05f)); - ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBg1, backgroundColor); + DrawControls(selectedTag); } - ImGui.TableNextColumn(); + ImGui.EndGroup(); + ImGui.TreePop(); + ImGui.Columns(1); - ImGui.AlignTextToFramePadding(); - ImGui.Text(playerName); + ImGui.EndTabItem(); + } - foreach (Tag customTag in m_PluginData.CustomTags) + if (ImGui.BeginTabItem(Strings.Loc_Static_Party)) + { + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.TreePush(); + if (ImGui.BeginTable("##PartyAssignTable", 1 + m_PluginData.CustomTags.Count)) { - ImGui.PushID(customTag.GetHashCode().ToString()); - - ImGui.TableNextColumn(); - - bool isTagAssigned = customTag.IncludesGameObjectNameToApplyTo(playerName); - - DrawSimpleCheckbox(string.Format(Strings.Loc_Static_Format_AddTagToPlayer, customTag.Text.InheritedValue, playerName), ref isTagAssigned, () => + ImGui.TableHeader(Strings.Loc_Static_PlayerName); + ImGui.TableSetupColumn(Strings.Loc_Static_PlayerName); + ImGui.NextColumn(); + foreach (var customTag in m_PluginData.CustomTags) { - if (isTagAssigned) - { - customTag.AddGameObjectNameToApplyTo(playerName); - } - else - { - customTag.RemoveGameObjectNameToApplyTo(playerName); - } + ImGui.TableHeader(customTag.Text.InheritedValue); + ImGui.TableSetupColumn(customTag.Text.InheritedValue); + ImGui.NextColumn(); + } + ImGui.TableHeadersRow(); - m_PluginConfiguration.Save(m_PluginData); - }); + int rowIndex = 0; + foreach (var partyMember in m_PartyList.OrderBy(obj => obj.Name.TextValue).ToArray()) + { + DrawPlayerAssignmentRow(partyMember.Name.TextValue, rowIndex); + ++rowIndex; + } - ImGui.PopID(); + if (m_PartyList.Length == 0 && m_ClientState.LocalPlayer != null) + { + DrawPlayerAssignmentRow(m_ClientState.LocalPlayer.Name.TextValue, 0); + } + + ImGui.EndTable(); } + ImGui.TreePop(); - ImGui.PopID(); - }; - - int rowIndex = 0; - foreach (var partyMember in m_PartyList) - { - drawPartyMember(partyMember.Name.TextValue, rowIndex); - ++rowIndex; + ImGui.EndTabItem(); } - if (m_PartyList.Length == 0 && m_ClientState.LocalPlayer != null) + if (ImGui.BeginTabItem(Strings.Loc_Static_Vicinity)) { - drawPartyMember(m_ClientState.LocalPlayer.Name.TextValue, 0); + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.TreePush(); + if (ImGui.BeginTable("##VicinityAssignTable", 1 + m_PluginData.CustomTags.Count)) + { + ImGui.TableHeader(Strings.Loc_Static_PlayerName); + ImGui.TableSetupColumn(Strings.Loc_Static_PlayerName); + ImGui.NextColumn(); + foreach (var customTag in m_PluginData.CustomTags) + { + ImGui.TableHeader(customTag.Text.InheritedValue); + ImGui.TableSetupColumn(customTag.Text.InheritedValue); + ImGui.NextColumn(); + } + ImGui.TableHeadersRow(); + + int rowIndex = 0; + foreach (var gameObject in m_ObjectTable.Where(obj => obj is PlayerCharacter).OrderBy(obj => obj.Name.TextValue)) + { + DrawPlayerAssignmentRow(gameObject.Name.TextValue, rowIndex); + ++rowIndex; + } + + if (m_ObjectTable.Length == 0 && m_ClientState.LocalPlayer != null) + { + DrawPlayerAssignmentRow(m_ClientState.LocalPlayer.Name.TextValue, 0); + } + + ImGui.EndTable(); + } + ImGui.TreePop(); + + ImGui.EndTabItem(); } - ImGui.EndTable(); + if (ImGui.BeginTabItem(Strings.Loc_Static_TaggedPlayers)) + { + ImGui.Spacing(); + ImGui.Spacing(); + ImGui.TreePush(); + if (ImGui.BeginTable("##TaggedPlayersTable", 1 + m_PluginData.CustomTags.Count)) + { + ImGui.TableHeader(Strings.Loc_Static_PlayerName); + ImGui.TableSetupColumn(Strings.Loc_Static_PlayerName); + ImGui.NextColumn(); + foreach (var customTag in m_PluginData.CustomTags) + { + ImGui.TableHeader(customTag.Text.InheritedValue); + ImGui.TableSetupColumn(customTag.Text.InheritedValue); + ImGui.NextColumn(); + } + ImGui.TableHeadersRow(); + + int rowIndex = 0; + foreach (var gameObjectName in m_PluginData.CustomTags.SelectMany(customTag => customTag.SplitGameObjectNamesToApplyTo).Distinct().OrderBy(name => name).ToArray()) + { + DrawPlayerAssignmentRow(gameObjectName, rowIndex); + ++rowIndex; + } + + if (m_ObjectTable.Length == 0 && m_ClientState.LocalPlayer != null) + { + DrawPlayerAssignmentRow(m_ClientState.LocalPlayer.Name.TextValue, 0); + } + + ImGui.EndTable(); + } + ImGui.TreePop(); + + ImGui.EndTabItem(); + } + + ImGui.EndTabBar(); } - ImGui.TreePop(); - - ImGui.Spacing(); - ImGui.Spacing(); - ImGui.Spacing(); - ImGui.Spacing(); - ImGui.Spacing(); ImGui.End(); } @@ -192,6 +228,51 @@ namespace PlayerTags } } + void DrawPlayerAssignmentRow(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) + { + ImGui.PushID(customTag.GetHashCode().ToString()); + + ImGui.TableNextColumn(); + + bool isTagAssigned = customTag.IncludesGameObjectNameToApplyTo(playerName); + + DrawSimpleCheckbox(string.Format(Strings.Loc_Static_Format_AddTagToPlayer, customTag.Text.InheritedValue, playerName), ref isTagAssigned, () => + { + if (isTagAssigned) + { + customTag.AddGameObjectNameToApplyTo(playerName); + } + else + { + customTag.RemoveGameObjectNameToApplyTo(playerName); + } + + m_PluginConfiguration.Save(m_PluginData); + }); + + ImGui.PopID(); + } + + ImGui.PopID(); + } + public string GetTreeItemName(Tag tag) { string itemName = tag.Name.Value; diff --git a/PlayerTags/Resources/Strings.Designer.cs b/PlayerTags/Resources/Strings.Designer.cs index d7b4ef5..2ded504 100644 --- a/PlayerTags/Resources/Strings.Designer.cs +++ b/PlayerTags/Resources/Strings.Designer.cs @@ -133,7 +133,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Enable context menu integration. + /// Looks up a localized string similar to Context menu integration. /// public static string Loc_IsCustomTagContextMenuEnabled { get { @@ -142,7 +142,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to When opening the player context menu, options will be available to add and remove custom tags for the selected player.. + /// Looks up a localized string similar to Options will be available in context menus for adding and removing custom tags from players.. /// public static string Loc_IsCustomTagContextMenuEnabled_Description { get { @@ -682,11 +682,11 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Add custom tags to party members. + /// Looks up a localized string similar to Party. /// - public static string Loc_Static_PartyAssign { + public static string Loc_Static_Party { get { - return ResourceManager.GetString("Loc_Static_PartyAssign", resourceCulture); + return ResourceManager.GetString("Loc_Static_Party", resourceCulture); } } @@ -726,6 +726,15 @@ namespace PlayerTags.Resources { } } + /// + /// Looks up a localized string similar to Tagged Players. + /// + public static string Loc_Static_TaggedPlayers { + get { + return ResourceManager.GetString("Loc_Static_TaggedPlayers", resourceCulture); + } + } + /// /// Looks up a localized string similar to Tags. /// @@ -735,6 +744,15 @@ namespace PlayerTags.Resources { } } + /// + /// Looks up a localized string similar to Vicinity. + /// + public static string Loc_Static_Vicinity { + get { + return ResourceManager.GetString("Loc_Static_Vicinity", resourceCulture); + } + } + /// /// Looks up a localized string similar to This plugin can modify nameplates. When combined with other plugins that modify nameplates, you are likely to see unexpected behavior.. /// diff --git a/PlayerTags/Resources/Strings.resx b/PlayerTags/Resources/Strings.resx index 1ebd8dc..232c37a 100644 --- a/PlayerTags/Resources/Strings.resx +++ b/PlayerTags/Resources/Strings.resx @@ -126,8 +126,14 @@ General - - Add custom tags to party members + + Party + + + Vicinity + + + Tagged Players Player @@ -154,10 +160,10 @@ Expanded - Enable context menu integration + Context menu integration - When opening the player context menu, options will be available to add and remove custom tags for the selected player. + Options will be available in context menus for adding and removing custom tags from players. Show inherited properties diff --git a/PlayerTags/Tag.cs b/PlayerTags/Tag.cs index b469384..e762643 100644 --- a/PlayerTags/Tag.cs +++ b/PlayerTags/Tag.cs @@ -99,7 +99,7 @@ namespace PlayerTags public InheritableReference GameObjectNamesToApplyTo = new InheritableReference(""); - private string[] SplitGameObjectNamesToApplyTo + public string[] SplitGameObjectNamesToApplyTo { get {