From d33634bbee80a6d54e07ff757b4cdc709ed57bc8 Mon Sep 17 00:00:00 2001 From: Dragon Date: Sat, 12 Sep 2020 08:21:27 +0300 Subject: [PATCH] Add option to show free company members --- .../Configuration/VisibilityConfiguration.cs | 44 +++++++++++++++++-- Visibility/VisibilityPlugin.cs | 30 ++++++++----- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/Visibility/Configuration/VisibilityConfiguration.cs b/Visibility/Configuration/VisibilityConfiguration.cs index 7705ee9..f4ac225 100644 --- a/Visibility/Configuration/VisibilityConfiguration.cs +++ b/Visibility/Configuration/VisibilityConfiguration.cs @@ -42,6 +42,24 @@ public bool HideChocobo set => _hideChocobo = value; } + public bool ShowCompanyPet + { + get => _showCompanyPet; + set => _showCompanyPet = value; + } + + public bool ShowCompanyPlayer + { + get => _showCompanyPlayer; + set => _showCompanyPlayer = value; + } + + public bool ShowCompanyChocobo + { + get => _showCompanyChocobo; + set => _showCompanyChocobo = value; + } + public bool ShowPartyPet { get => _showPartyPet; @@ -143,10 +161,17 @@ public bool ShowDeadPlayer private bool _showFriendChocobo = false; [NonSerialized] private bool _showDeadPlayer = false; - + [NonSerialized] + private bool _showCompanyPet = false; + [NonSerialized] + private bool _showCompanyPlayer = false; + [NonSerialized] + private bool _showCompanyChocobo = false; + [NonSerialized] public readonly Dictionary> settingDictionary = new Dictionary>(); + public void Init(VisibilityPlugin plugin, DalamudPluginInterface pluginInterface) { _plugin = plugin; @@ -155,6 +180,9 @@ public void Init(VisibilityPlugin plugin, DalamudPluginInterface pluginInterface settingDictionary["hidepet"] = x => _hidePet = x; settingDictionary["hideplayer"] = x => _hidePlayer = x; settingDictionary["hideminion"] = x => _hideMinion = x; + settingDictionary["showcompanypet"] = x => _showCompanyPet = x; + settingDictionary["showcompanyplayer"] = x => _showCompanyPlayer = x; + settingDictionary["showcompanychocobo"] = x => _showCompanyChocobo = x; settingDictionary["showpartypet"] = x => _showPartyPet = x; settingDictionary["showpartyplayer"] = x => _showPartyPlayer = x; settingDictionary["showpartychocobo"] = x => _showPartyChocobo = x; @@ -181,7 +209,7 @@ public bool DrawConfigUi() var scale = ImGui.GetIO().FontGlobalScale; - ImGui.SetNextWindowSize(new Vector2(450 * scale, 230), ImGuiCond.Always); + ImGui.SetNextWindowSize(new Vector2(500 * scale, 230), ImGuiCond.Always); ImGui.Begin($"{_plugin.Name} Config", ref drawConfig, ImGuiWindowFlags.NoResize); if (ImGui.Checkbox($"###{nameof(_plugin.enabled)}", ref _plugin.enabled)) @@ -194,7 +222,7 @@ public bool DrawConfigUi() ImGui.Text("Enable"); ImGui.Separator(); - ImGui.Columns(5, "###cols", false); + ImGui.Columns(6, "###cols", false); ImGui.NextColumn(); ImGui.Text("Hide all"); @@ -205,6 +233,8 @@ public bool DrawConfigUi() ImGui.NextColumn(); ImGui.Text("Show dead"); ImGui.NextColumn(); + ImGui.Text("Show FC"); + ImGui.NextColumn(); ImGui.Separator(); ImGui.Text("Pets"); ImGui.NextColumn(); @@ -215,6 +245,8 @@ public bool DrawConfigUi() Checkbox(nameof(_showFriendPet), ref _showFriendPet); ImGui.NextColumn(); ImGui.NextColumn(); + Checkbox(nameof(_showCompanyPet), ref _showCompanyPet); + ImGui.NextColumn(); ImGui.Text("Minions"); ImGui.NextColumn(); @@ -223,6 +255,7 @@ public bool DrawConfigUi() ImGui.NextColumn(); ImGui.NextColumn(); ImGui.NextColumn(); + ImGui.NextColumn(); ImGui.Text("Chocobos"); ImGui.NextColumn(); @@ -233,6 +266,8 @@ public bool DrawConfigUi() Checkbox(nameof(_showFriendChocobo), ref _showFriendChocobo); ImGui.NextColumn(); ImGui.NextColumn(); + Checkbox(nameof(_showCompanyChocobo), ref _showCompanyChocobo); + ImGui.NextColumn(); ImGui.Text("Players"); ImGui.NextColumn(); @@ -244,6 +279,8 @@ public bool DrawConfigUi() ImGui.NextColumn(); Checkbox(nameof(_showDeadPlayer), ref _showDeadPlayer); ImGui.NextColumn(); + Checkbox(nameof(_showCompanyPlayer), ref _showCompanyPlayer); + ImGui.NextColumn(); ImGui.Separator(); if (ImGui.Button("Refresh")) @@ -255,6 +292,7 @@ public bool DrawConfigUi() ImGui.NextColumn(); ImGui.NextColumn(); ImGui.NextColumn(); + ImGui.NextColumn(); if (ImGui.Button("VoidList")) { diff --git a/Visibility/VisibilityPlugin.cs b/Visibility/VisibilityPlugin.cs index 478a609..174168a 100644 --- a/Visibility/VisibilityPlugin.cs +++ b/Visibility/VisibilityPlugin.cs @@ -248,8 +248,10 @@ private void OnChatMessage(XivChatType type, uint senderId, ref SeString sender, } } - private void CheckRender(IEnumerable collection, ICollection friendCollection, ref bool oneShot, - bool hide = false, bool showParty = false, bool showFriend = false, bool showDead = false, IEnumerable mounts = null) where T: Actor + private void CheckRender(IEnumerable collection, ICollection friendCollection, + ICollection companyCollection, ref bool oneShot, bool hide = false, bool showParty = false, + bool showFriend = false, bool showCompany = false, bool showDead = false, IEnumerable mounts = null) + where T : Actor { if (hide) { @@ -263,6 +265,7 @@ private void CheckRender(IEnumerable collection, ICollection friendCo var lookupId = item is BattleNpc battleNpc ? battleNpc.OwnerId : item.ActorId; if ((showParty && _partyActorId.Contains(lookupId)) || (showFriend && friendCollection.Contains(lookupId)) + || (showCompany && companyCollection.Contains(lookupId)) || (showDead && (item as Chara).CurrentHp == 0)) { item.Render(); @@ -329,8 +332,10 @@ where actor is PlayerCharacter character where actor.IsStatus(StatusFlags.Friend) select actor.ActorId).ToHashSet(); - var partyMembers = (from actor in _pluginInterface.ClientState.Actors - where Array.Exists(_partyActorId, actorId => actorId == actor.ActorId) + var companyMembers = (from actor in _pluginInterface.ClientState.Actors + where actor is PlayerCharacter playerCharacter + && !string.IsNullOrEmpty(playerCharacter.CompanyTag) + && playerCharacter.CompanyTag == _pluginInterface.ClientState.LocalPlayer?.CompanyTag select actor.ActorId).ToHashSet(); var pets = from actor in _pluginInterface.ClientState.Actors @@ -354,15 +359,17 @@ where actor is BattleNpc npc && npc.OwnerId != _pluginInterface.ClientState.LocalPlayer?.ActorId select actor as BattleNpc; - CheckRender(chocobos, friends, + CheckRender(chocobos, friends, companyMembers, ref _oneShot[0], _pluginConfig.HideChocobo, _pluginConfig.ShowPartyChocobo, - _pluginConfig.ShowFriendChocobo); + _pluginConfig.ShowFriendChocobo, + _pluginConfig.ShowCompanyChocobo); - CheckRender(pets, friends, + CheckRender(pets, friends, companyMembers, ref _oneShot[1], _pluginConfig.HidePet, _pluginConfig.ShowPartyPet, - _pluginConfig.ShowFriendPet); + _pluginConfig.ShowFriendPet, + _pluginConfig.ShowCompanyPet); if (!_pluginInterface.ClientState.Condition[ConditionFlag.BoundByDuty]) { @@ -371,15 +378,16 @@ where actor is BattleNpc npc item.Hide(); } - CheckRender(players, friends, + CheckRender(players, friends, companyMembers, ref _oneShot[2], _pluginConfig.HidePlayer, _pluginConfig.ShowPartyPlayer, _pluginConfig.ShowFriendPlayer, + _pluginConfig.ShowCompanyPlayer, _pluginConfig.ShowDeadPlayer); } - CheckRender(minions, friends, ref _oneShot[3], - _pluginConfig.HideMinion, false, false, false, mounts); + CheckRender(minions, friends, companyMembers, ref _oneShot[3], + _pluginConfig.HideMinion, false, false, false, false, mounts); foreach (var item in voidItems) {