diff --git a/PlayerTags/Configuration/PluginConfiguration.cs b/PlayerTags/Configuration/PluginConfiguration.cs index d7c8dc8..7c697d2 100644 --- a/PlayerTags/Configuration/PluginConfiguration.cs +++ b/PlayerTags/Configuration/PluginConfiguration.cs @@ -20,6 +20,7 @@ namespace PlayerTags.Configuration public bool IsPlayerNameRandomlyGenerated = false; public bool IsCustomTagsContextMenuEnabled = true; public bool IsShowInheritedPropertiesEnabled = true; + public bool IsSortedByProximity = true; [JsonProperty(TypeNameHandling = TypeNameHandling.None, ItemTypeNameHandling = TypeNameHandling.None)] public Dictionary AllTagsChanges = new Dictionary(); diff --git a/PlayerTags/Configuration/PluginConfigurationUI.cs b/PlayerTags/Configuration/PluginConfigurationUI.cs index 74df546..b852f69 100644 --- a/PlayerTags/Configuration/PluginConfigurationUI.cs +++ b/PlayerTags/Configuration/PluginConfigurationUI.cs @@ -138,12 +138,14 @@ namespace PlayerTags.Configuration ImGui.EndTabItem(); } - if (ImGui.BeginTabItem(Strings.Loc_Static_Vicinity)) + if (ImGui.BeginTabItem(Strings.Loc_Static_Proximity)) { ImGui.Spacing(); ImGui.Spacing(); ImGui.TreePush(); - if (ImGui.BeginTable("##VicinityAssignTable", 1 + m_PluginData.CustomTags.Count)) + DrawCheckbox(nameof(m_PluginConfiguration.IsSortedByProximity), true, ref m_PluginConfiguration.IsSortedByProximity, () => m_PluginConfiguration.Save(m_PluginData)); + + if (ImGui.BeginTable("##ProximityAssignTable", 1 + m_PluginData.CustomTags.Count)) { ImGui.TableHeader(Strings.Loc_Static_PlayerName); ImGui.TableSetupColumn(Strings.Loc_Static_PlayerName); @@ -156,8 +158,18 @@ namespace PlayerTags.Configuration } ImGui.TableHeadersRow(); + var players = PluginServices.ObjectTable.Where(gameObject => gameObject is PlayerCharacter); + if (m_PluginConfiguration.IsSortedByProximity && PluginServices.ClientState.LocalPlayer != null) + { + players = players.OrderBy(gameObject => (gameObject.Position - PluginServices.ClientState.LocalPlayer.Position).Length()); + } + else + { + players = players.OrderBy(obj => obj.Name.TextValue); + } + int rowIndex = 0; - foreach (var gameObject in PluginServices.ObjectTable.Where(obj => obj is PlayerCharacter).OrderBy(obj => obj.Name.TextValue)) + foreach (var gameObject in players) { DrawPlayerAssignmentRow(gameObject.Name.TextValue, rowIndex); ++rowIndex; diff --git a/PlayerTags/Resources/Strings.Designer.cs b/PlayerTags/Resources/Strings.Designer.cs index a5f7535..a9a0d9e 100644 --- a/PlayerTags/Resources/Strings.Designer.cs +++ b/PlayerTags/Resources/Strings.Designer.cs @@ -276,6 +276,24 @@ namespace PlayerTags.Resources { } } + /// + /// Looks up a localized string similar to Sort by proximity. + /// + public static string Loc_IsSortedByProximity { + get { + return ResourceManager.GetString("Loc_IsSortedByProximity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Players that are closer to the local player will be ordered towards the top.. + /// + public static string Loc_IsSortedByProximity_Description { + get { + return ResourceManager.GetString("Loc_IsSortedByProximity_Description", resourceCulture); + } + } + /// /// Looks up a localized string similar to Text italic. /// @@ -331,7 +349,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Visible for alliance players. + /// Looks up a localized string similar to Show for alliance members. /// public static string Loc_IsVisibleForAlliancePlayers { get { @@ -340,7 +358,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Visible for enemy players. + /// Looks up a localized string similar to Show for enemies. /// public static string Loc_IsVisibleForEnemyPlayers { get { @@ -349,7 +367,16 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Visible for other players. + /// Looks up a localized string similar to Show for friends. + /// + public static string Loc_IsVisibleForFriendPlayers { + get { + return ResourceManager.GetString("Loc_IsVisibleForFriendPlayers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show for others. /// public static string Loc_IsVisibleForOtherPlayers { get { @@ -358,7 +385,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Visible for party players. + /// Looks up a localized string similar to Show for party members. /// public static string Loc_IsVisibleForPartyPlayers { get { @@ -367,7 +394,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Visible for self. + /// Looks up a localized string similar to Show for self. /// public static string Loc_IsVisibleForSelf { get { @@ -376,7 +403,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Visible in overworld. + /// Looks up a localized string similar to Show elsewhere. /// public static string Loc_IsVisibleInOverworld { get { @@ -385,7 +412,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Visible in pve duties. + /// Looks up a localized string similar to Show in pve duties. /// public static string Loc_IsVisibleInPveDuties { get { @@ -394,7 +421,7 @@ namespace PlayerTags.Resources { } /// - /// Looks up a localized string similar to Visible in pvp duties. + /// Looks up a localized string similar to Show in pvp duties. /// public static string Loc_IsVisibleInPvpDuties { get { @@ -816,6 +843,15 @@ namespace PlayerTags.Resources { } } + /// + /// Looks up a localized string similar to Proximity. + /// + public static string Loc_Static_Proximity { + get { + return ResourceManager.GetString("Loc_Static_Proximity", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remove this custom tag.. /// @@ -852,15 +888,6 @@ 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 c0d6d0c..4a97185 100644 --- a/PlayerTags/Resources/Strings.resx +++ b/PlayerTags/Resources/Strings.resx @@ -129,8 +129,8 @@ Party - - Vicinity + + Proximity Tagged Players @@ -452,4 +452,11 @@ Show for others + + + Sort by proximity + + + Players that are closer to the local player will be ordered towards the top. + \ No newline at end of file