Add activity and player context visibility options
- Options for show in pve/pvp duties, showing for self/friends/party/alliance/enemies
This commit is contained in:
@@ -39,16 +39,8 @@ namespace PlayerTags.Configuration
|
||||
[JsonProperty(TypeNameHandling = TypeNameHandling.None, ItemTypeNameHandling = TypeNameHandling.None)]
|
||||
public List<Dictionary<string, InheritableData>> CustomTagsChanges = new List<Dictionary<string, InheritableData>>();
|
||||
|
||||
[NonSerialized]
|
||||
private DalamudPluginInterface? m_PluginInterface;
|
||||
|
||||
public event System.Action? Saved;
|
||||
|
||||
public void Initialize(DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
m_PluginInterface = pluginInterface;
|
||||
}
|
||||
|
||||
public void Save(PluginData pluginData)
|
||||
{
|
||||
AllTagsChanges = pluginData.AllTags.GetChanges(pluginData.Default.AllTagsChanges);
|
||||
@@ -88,11 +80,8 @@ namespace PlayerTags.Configuration
|
||||
CustomTagsChanges.Add(customTag.GetChanges());
|
||||
}
|
||||
|
||||
if (m_PluginInterface != null)
|
||||
{
|
||||
m_PluginInterface.SavePluginConfig(this);
|
||||
Saved?.Invoke();
|
||||
};
|
||||
PluginServices.DalamudPluginInterface.SavePluginConfig(this);
|
||||
Saved?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Logging;
|
||||
using ImGuiNET;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using PlayerTags.Data;
|
||||
@@ -448,7 +450,7 @@ namespace PlayerTags.Configuration
|
||||
public void DrawControls(Tag tag)
|
||||
{
|
||||
ImGui.PushID(tag.GetHashCode().ToString());
|
||||
ImGui.TreePush();
|
||||
//ImGui.TreePush();
|
||||
|
||||
// Render the add property override button and popup
|
||||
if (ImGui.IsPopupOpen("AddPopup"))
|
||||
@@ -483,36 +485,68 @@ namespace PlayerTags.Configuration
|
||||
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))
|
||||
IEnumerable<KeyValuePair<string, IInheritable>> inheritables1 = tag.Inheritables.Where(inheritable => inheritable.Value.Behavior == InheritableBehavior.Inherit);
|
||||
var selectedInheritables1 = inheritables1
|
||||
.Select(inheritable =>
|
||||
{
|
||||
selectableInheritables[inheritableLocalizedName.Name].Behavior = InheritableBehavior.Enabled;
|
||||
string? categoryId = null;
|
||||
|
||||
if (selectableInheritables[inheritableLocalizedName.Name] is InheritableValue<bool> inheritableBool)
|
||||
var field = tag.GetType().GetField(inheritable.Key);
|
||||
if (field != null)
|
||||
{
|
||||
inheritableBool.Value = true;
|
||||
var inheritableCategory = field.GetCustomAttributes(typeof(InheritableCategoryAttribute), false).Cast<InheritableCategoryAttribute>().FirstOrDefault();
|
||||
if (inheritableCategory != null)
|
||||
{
|
||||
categoryId = inheritableCategory.CategoryId;
|
||||
}
|
||||
}
|
||||
|
||||
m_PluginConfiguration.Save(m_PluginData);
|
||||
ImGui.CloseCurrentPopup();
|
||||
return new
|
||||
{
|
||||
Inheritable = inheritable,
|
||||
CategoryId = categoryId,
|
||||
LocalizedName = Localizer.GetString(inheritable.Key, false)
|
||||
};
|
||||
}).Where(inheritable => inheritable.CategoryId != null);
|
||||
|
||||
var inheritableGroups1 = selectedInheritables1.GroupBy(inheritable => inheritable.CategoryId);
|
||||
|
||||
foreach (var inheritableGroup in inheritableGroups1)
|
||||
{
|
||||
|
||||
if (inheritableGroup.Key != null)
|
||||
{
|
||||
DrawHeading(Localizer.GetString(inheritableGroup.Key, false));
|
||||
}
|
||||
|
||||
if (isSelected)
|
||||
ImGui.TreePush();
|
||||
foreach (var selectedInheritable in inheritableGroup)
|
||||
{
|
||||
ImGui.SetItemDefaultFocus();
|
||||
}
|
||||
bool isSelected = false;
|
||||
if (ImGui.Selectable(selectedInheritable.LocalizedName, isSelected))
|
||||
{
|
||||
selectedInheritable.Inheritable.Value.Behavior = InheritableBehavior.Enabled;
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip(Localizer.GetString(inheritableLocalizedName.Name, true));
|
||||
if (selectedInheritable.Inheritable.Value 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(selectedInheritable.Inheritable.Key, true));
|
||||
}
|
||||
}
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
||||
ImGui.EndListBox();
|
||||
@@ -538,61 +572,77 @@ namespace PlayerTags.Configuration
|
||||
inheritables = inheritables.Where(inheritable => inheritable.Value.Behavior != InheritableBehavior.Inherit);
|
||||
}
|
||||
|
||||
var selectedInheritables = inheritables.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)
|
||||
var selectedInheritables = inheritables
|
||||
.Select(inheritable =>
|
||||
{
|
||||
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.TextGlowColor):
|
||||
DrawInheritable(nameof(tag.TextGlowColor), tag.TextGlowColor);
|
||||
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;
|
||||
string? categoryId = null;
|
||||
|
||||
var field = tag.GetType().GetField(inheritable.Key);
|
||||
if (field != null)
|
||||
{
|
||||
var inheritableCategory = field.GetCustomAttributes(typeof(InheritableCategoryAttribute), false).Cast<InheritableCategoryAttribute>().FirstOrDefault();
|
||||
if (inheritableCategory != null)
|
||||
{
|
||||
categoryId = inheritableCategory.CategoryId;
|
||||
}
|
||||
}
|
||||
|
||||
return new
|
||||
{
|
||||
Inheritable = inheritable,
|
||||
CategoryId = categoryId,
|
||||
LocalizedName = Localizer.GetString(inheritable.Key, false)
|
||||
};
|
||||
}).Where(inheritable => inheritable.CategoryId != null);
|
||||
|
||||
var inheritableGroups = selectedInheritables.GroupBy(inheritable => inheritable.CategoryId);
|
||||
|
||||
foreach (var inheritableGroup in inheritableGroups)
|
||||
{
|
||||
ImGui.Spacing();
|
||||
ImGui.Spacing();
|
||||
if (inheritableGroup.Key != null)
|
||||
{
|
||||
DrawHeading(Localizer.GetString(inheritableGroup.Key, false));
|
||||
}
|
||||
|
||||
ImGui.TreePush();
|
||||
foreach (var selectedInheritable in inheritableGroup)
|
||||
{
|
||||
if (selectedInheritable.Inheritable.Value is InheritableValue<bool> inheritableBool)
|
||||
{
|
||||
DrawInheritable(selectedInheritable.Inheritable.Key, inheritableBool);
|
||||
}
|
||||
else if (selectedInheritable.Inheritable.Value is InheritableValue<ushort> inheritableUshort)
|
||||
{
|
||||
DrawInheritable(selectedInheritable.Inheritable.Key, inheritableUshort);
|
||||
}
|
||||
else if (selectedInheritable.Inheritable.Value is InheritableValue<BitmapFontIcon> inheritableBitmapFontIcon)
|
||||
{
|
||||
DrawInheritable(selectedInheritable.Inheritable.Key, false, true, inheritableBitmapFontIcon);
|
||||
}
|
||||
else if (selectedInheritable.Inheritable.Value is InheritableValue<TagPosition> inheritableTagPosition)
|
||||
{
|
||||
DrawInheritable(selectedInheritable.Inheritable.Key, false, true, inheritableTagPosition);
|
||||
}
|
||||
else if (selectedInheritable.Inheritable.Value is InheritableValue<NameplateElement> inheritableNameplateElement)
|
||||
{
|
||||
DrawInheritable(selectedInheritable.Inheritable.Key, true, false, inheritableNameplateElement);
|
||||
}
|
||||
else if (selectedInheritable.Inheritable.Value is InheritableReference<string> inheritableString)
|
||||
{
|
||||
DrawInheritable(selectedInheritable.Inheritable.Key, inheritableString);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginLog.Warning($"Rendering for inheritable option not implemented: {selectedInheritable.Inheritable.Key}");
|
||||
}
|
||||
}
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
||||
|
||||
ImGui.TreePop();
|
||||
//ImGui.TreePop();
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
|
||||
9
PlayerTags/Data/ActivityContext.cs
Normal file
9
PlayerTags/Data/ActivityContext.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace PlayerTags.Data
|
||||
{
|
||||
public enum ActivityContext
|
||||
{
|
||||
Overworld,
|
||||
PveDuty,
|
||||
PvpDuty,
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,17 @@ namespace PlayerTags.Data
|
||||
TagPositionInNameplates = TagPosition.Replace,
|
||||
TagTargetInNameplates = NameplateElement.Title,
|
||||
IsTextItalic = true,
|
||||
|
||||
IsVisibleInOverworld = true,
|
||||
IsVisibleInPveDuties = true,
|
||||
IsVisibleInPvpDuties = true,
|
||||
|
||||
IsVisibleForSelf = true,
|
||||
IsVisibleForFriendPlayers = true,
|
||||
IsVisibleForPartyPlayers = true,
|
||||
IsVisibleForAlliancePlayers = true,
|
||||
IsVisibleForEnemyPlayers = true,
|
||||
IsVisibleForOtherPlayers = true,
|
||||
}.GetChanges();
|
||||
|
||||
AllRoleTagsChanges = new Tag(new LiteralPluginString(""))
|
||||
|
||||
14
PlayerTags/Data/InheritableCategoryAttribute.cs
Normal file
14
PlayerTags/Data/InheritableCategoryAttribute.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace PlayerTags.Data
|
||||
{
|
||||
public class InheritableCategoryAttribute : Attribute
|
||||
{
|
||||
public string CategoryId { get; private set; }
|
||||
|
||||
public InheritableCategoryAttribute(string categoryId)
|
||||
{
|
||||
CategoryId = categoryId;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
PlayerTags/Data/PlayerContext.cs
Normal file
12
PlayerTags/Data/PlayerContext.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace PlayerTags.Data
|
||||
{
|
||||
public enum PlayerContext
|
||||
{
|
||||
Self,
|
||||
Party,
|
||||
Alliance,
|
||||
Enemy,
|
||||
Friend,
|
||||
Other
|
||||
}
|
||||
}
|
||||
@@ -84,22 +84,55 @@ namespace PlayerTags.Data
|
||||
public InheritableValue<bool> IsSelected = new InheritableValue<bool>(false);
|
||||
public InheritableValue<bool> IsExpanded = new InheritableValue<bool>(false);
|
||||
|
||||
[InheritableCategory("General")]
|
||||
public InheritableReference<string> GameObjectNamesToApplyTo = new InheritableReference<string>("");
|
||||
|
||||
[InheritableCategory("Icon")]
|
||||
public InheritableValue<BitmapFontIcon> Icon = new InheritableValue<BitmapFontIcon>(BitmapFontIcon.Aethernet);
|
||||
[InheritableCategory("Icon")]
|
||||
public InheritableValue<bool> IsIconVisibleInChat = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("Icon")]
|
||||
public InheritableValue<bool> IsIconVisibleInNameplates = new InheritableValue<bool>(false);
|
||||
|
||||
[InheritableCategory("Text")]
|
||||
public InheritableReference<string> Text = new InheritableReference<string>("");
|
||||
[InheritableCategory("Text")]
|
||||
public InheritableValue<ushort> TextColor = new InheritableValue<ushort>(6);
|
||||
[InheritableCategory("Text")]
|
||||
public InheritableValue<ushort> TextGlowColor = new InheritableValue<ushort>(6);
|
||||
[InheritableCategory("Text")]
|
||||
public InheritableValue<bool> IsTextItalic = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("Text")]
|
||||
public InheritableValue<bool> IsTextVisibleInChat = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("Text")]
|
||||
public InheritableValue<bool> IsTextVisibleInNameplates = new InheritableValue<bool>(false);
|
||||
|
||||
[InheritableCategory("Position")]
|
||||
public InheritableValue<TagPosition> TagPositionInChat = new InheritableValue<TagPosition>(TagPosition.Before);
|
||||
[InheritableCategory("Position")]
|
||||
public InheritableValue<TagPosition> TagPositionInNameplates = new InheritableValue<TagPosition>(TagPosition.Before);
|
||||
[InheritableCategory("Position")]
|
||||
public InheritableValue<NameplateElement> TagTargetInNameplates = new InheritableValue<NameplateElement>(NameplateElement.Name);
|
||||
|
||||
public InheritableReference<string> GameObjectNamesToApplyTo = new InheritableReference<string>("");
|
||||
[InheritableCategory("ActivityVisibility")]
|
||||
public InheritableValue<bool> IsVisibleInPveDuties = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("ActivityVisibility")]
|
||||
public InheritableValue<bool> IsVisibleInPvpDuties = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("ActivityVisibility")]
|
||||
public InheritableValue<bool> IsVisibleInOverworld = new InheritableValue<bool>(false);
|
||||
|
||||
[InheritableCategory("PlayerVisibility")]
|
||||
public InheritableValue<bool> IsVisibleForSelf = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("PlayerVisibility")]
|
||||
public InheritableValue<bool> IsVisibleForFriendPlayers = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("PlayerVisibility")]
|
||||
public InheritableValue<bool> IsVisibleForPartyPlayers = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("PlayerVisibility")]
|
||||
public InheritableValue<bool> IsVisibleForAlliancePlayers = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("PlayerVisibility")]
|
||||
public InheritableValue<bool> IsVisibleForEnemyPlayers = new InheritableValue<bool>(false);
|
||||
[InheritableCategory("PlayerVisibility")]
|
||||
public InheritableValue<bool> IsVisibleForOtherPlayers = new InheritableValue<bool>(false);
|
||||
|
||||
public string[] SplitGameObjectNamesToApplyTo
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace PlayerTags.Data
|
||||
namespace PlayerTags.Data
|
||||
{
|
||||
public enum TagTarget
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
@@ -181,12 +182,18 @@ namespace PlayerTags.Features
|
||||
// Add the job tag
|
||||
if (m_PluginData.JobTags.TryGetValue(character.ClassJob.GameData.Abbreviation, out var jobTag))
|
||||
{
|
||||
if (jobTag.TagPositionInChat.InheritedValue != null)
|
||||
bool isVisible = IsVisibleInActivity(jobTag) &&
|
||||
(!(stringMatch.GameObject is PlayerCharacter playerCharacter) || IsVisibleForPlayer(jobTag, playerCharacter));
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
var payloads = GetPayloads(jobTag);
|
||||
if (payloads.Any())
|
||||
if (jobTag.TagPositionInChat.InheritedValue != null)
|
||||
{
|
||||
AddPayloadChanges(jobTag.TagPositionInChat.InheritedValue.Value, payloads, stringChanges);
|
||||
var payloads = GetPayloads(jobTag);
|
||||
if (payloads.Any())
|
||||
{
|
||||
AddPayloadChanges(jobTag.TagPositionInChat.InheritedValue.Value, payloads, stringChanges);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,14 +216,20 @@ namespace PlayerTags.Features
|
||||
// Add the custom tag payloads
|
||||
foreach (var customTag in m_PluginData.CustomTags)
|
||||
{
|
||||
if (customTag.TagPositionInChat.InheritedValue != null)
|
||||
bool isVisible = IsVisibleInActivity(customTag) &&
|
||||
(!(stringMatch.GameObject is PlayerCharacter playerCharacter) || IsVisibleForPlayer(customTag, playerCharacter));
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
if (customTag.IncludesGameObjectNameToApplyTo(stringMatch.GetMatchText()))
|
||||
if (customTag.TagPositionInChat.InheritedValue != null)
|
||||
{
|
||||
var customTagPayloads = GetPayloads(customTag);
|
||||
if (customTagPayloads.Any())
|
||||
if (customTag.IncludesGameObjectNameToApplyTo(stringMatch.GetMatchText()))
|
||||
{
|
||||
AddPayloadChanges(customTag.TagPositionInChat.InheritedValue.Value, customTagPayloads, stringChanges);
|
||||
var customTagPayloads = GetPayloads(customTag);
|
||||
if (customTagPayloads.Any())
|
||||
{
|
||||
AddPayloadChanges(customTag.TagPositionInChat.InheritedValue.Value, customTagPayloads, stringChanges);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,12 +181,18 @@ namespace PlayerTags.Features
|
||||
// Add the job tag
|
||||
if (m_PluginData.JobTags.TryGetValue(character.ClassJob.GameData.Abbreviation, out var jobTag))
|
||||
{
|
||||
if (jobTag.TagTargetInNameplates.InheritedValue != null && jobTag.TagPositionInNameplates.InheritedValue != null)
|
||||
bool isVisible = IsVisibleInActivity(jobTag) &&
|
||||
(!(gameObject is PlayerCharacter playerCharacter) || IsVisibleForPlayer(jobTag, playerCharacter));
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
var payloads = GetPayloads(jobTag);
|
||||
if (payloads.Any())
|
||||
if (jobTag.TagTargetInNameplates.InheritedValue != null && jobTag.TagPositionInNameplates.InheritedValue != null)
|
||||
{
|
||||
AddPayloadChanges(jobTag.TagTargetInNameplates.InheritedValue.Value, jobTag.TagPositionInNameplates.InheritedValue.Value, payloads, nameplateChanges);
|
||||
var payloads = GetPayloads(jobTag);
|
||||
if (payloads.Any())
|
||||
{
|
||||
AddPayloadChanges(jobTag.TagTargetInNameplates.InheritedValue.Value, jobTag.TagPositionInNameplates.InheritedValue.Value, payloads, nameplateChanges);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,14 +215,20 @@ namespace PlayerTags.Features
|
||||
// Add the custom tag payloads
|
||||
foreach (var customTag in m_PluginData.CustomTags)
|
||||
{
|
||||
if (customTag.TagTargetInNameplates.InheritedValue != null && customTag.TagPositionInNameplates.InheritedValue != null)
|
||||
bool isVisible = IsVisibleInActivity(customTag) &&
|
||||
(!(gameObject is PlayerCharacter playerCharacter) || IsVisibleForPlayer(customTag, playerCharacter));
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
if (customTag.IncludesGameObjectNameToApplyTo(gameObject.Name.TextValue))
|
||||
if (customTag.TagTargetInNameplates.InheritedValue != null && customTag.TagPositionInNameplates.InheritedValue != null)
|
||||
{
|
||||
var payloads = GetPayloads(customTag);
|
||||
if (payloads.Any())
|
||||
if (customTag.IncludesGameObjectNameToApplyTo(gameObject.Name.TextValue))
|
||||
{
|
||||
AddPayloadChanges(customTag.TagTargetInNameplates.InheritedValue.Value, customTag.TagPositionInNameplates.InheritedValue.Value, payloads, nameplateChanges);
|
||||
var payloads = GetPayloads(customTag);
|
||||
if (payloads.Any())
|
||||
{
|
||||
AddPayloadChanges(customTag.TagTargetInNameplates.InheritedValue.Value, customTag.TagPositionInNameplates.InheritedValue.Value, payloads, nameplateChanges);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.ClientState.Objects.Enums;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using PlayerTags.Configuration;
|
||||
using PlayerTags.Data;
|
||||
using PlayerTags.Inheritables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -12,6 +16,7 @@ namespace PlayerTags.Features
|
||||
{
|
||||
private PluginConfiguration m_PluginConfiguration;
|
||||
|
||||
private ActivityContext m_ActivityContext;
|
||||
private Dictionary<Tag, Payload[]> m_TagPayloads;
|
||||
private TextPayload m_SpaceTextPayload;
|
||||
|
||||
@@ -19,14 +24,17 @@ namespace PlayerTags.Features
|
||||
{
|
||||
m_PluginConfiguration = pluginConfiguration;
|
||||
|
||||
m_ActivityContext = ActivityContext.Overworld;
|
||||
m_TagPayloads = new Dictionary<Tag, Payload[]>();
|
||||
m_SpaceTextPayload = new TextPayload($" ");
|
||||
|
||||
m_PluginConfiguration.Saved += PluginConfiguration_Saved;
|
||||
PluginServices.ClientState.TerritoryChanged += ClientState_TerritoryChanged;
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
PluginServices.ClientState.TerritoryChanged -= ClientState_TerritoryChanged;
|
||||
m_PluginConfiguration.Saved -= PluginConfiguration_Saved;
|
||||
}
|
||||
|
||||
@@ -40,6 +48,31 @@ namespace PlayerTags.Features
|
||||
m_TagPayloads.Clear();
|
||||
}
|
||||
|
||||
private void ClientState_TerritoryChanged(object? sender, ushort e)
|
||||
{
|
||||
m_ActivityContext = ActivityContext.Overworld;
|
||||
|
||||
var contentFinderConditionsSheet = PluginServices.DataManager.GameData.GetExcelSheet<ContentFinderCondition>();
|
||||
if (contentFinderConditionsSheet != null)
|
||||
{
|
||||
var foundContentFinderCondition = contentFinderConditionsSheet.FirstOrDefault(contentFinderCondition => contentFinderCondition.TerritoryType.Row == PluginServices.ClientState.TerritoryType);
|
||||
if (foundContentFinderCondition != null)
|
||||
{
|
||||
if (foundContentFinderCondition.PvP)
|
||||
{
|
||||
m_ActivityContext = ActivityContext.PvpDuty;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ActivityContext = ActivityContext.PveDuty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Invalidate the cached payloads so they get remade
|
||||
m_TagPayloads.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the payloads for the given tag. If the payloads don't yet exist then they will be created.
|
||||
/// </summary>
|
||||
@@ -56,6 +89,104 @@ namespace PlayerTags.Features
|
||||
return m_TagPayloads[tag];
|
||||
}
|
||||
|
||||
private InheritableValue<bool>? GetInheritableVisibilityForActivity(Tag tag, ActivityContext activityContext)
|
||||
{
|
||||
switch (activityContext)
|
||||
{
|
||||
case ActivityContext.Overworld:
|
||||
return tag.IsVisibleInOverworld;
|
||||
case ActivityContext.PveDuty:
|
||||
return tag.IsVisibleInPveDuties;
|
||||
case ActivityContext.PvpDuty:
|
||||
return tag.IsVisibleInPvpDuties;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsVisibleInActivity(Tag tag)
|
||||
{
|
||||
var inheritable = GetInheritableVisibilityForActivity(tag, m_ActivityContext);
|
||||
if (inheritable == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inheritable.InheritedValue == null || !inheritable.InheritedValue.Value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private PlayerContext GetContextForPlayer(PlayerCharacter playerCharacter)
|
||||
{
|
||||
if (PluginServices.ClientState.LocalPlayer == playerCharacter)
|
||||
{
|
||||
return PlayerContext.Self;
|
||||
}
|
||||
|
||||
if (playerCharacter.StatusFlags.HasFlag(StatusFlags.Friend))
|
||||
{
|
||||
return PlayerContext.Friend;
|
||||
}
|
||||
|
||||
if (playerCharacter.StatusFlags.HasFlag(StatusFlags.PartyMember))
|
||||
{
|
||||
return PlayerContext.Party;
|
||||
}
|
||||
|
||||
if (playerCharacter.StatusFlags.HasFlag(StatusFlags.AllianceMember))
|
||||
{
|
||||
return PlayerContext.Alliance;
|
||||
}
|
||||
|
||||
if (playerCharacter.StatusFlags.HasFlag(StatusFlags.Hostile))
|
||||
{
|
||||
return PlayerContext.Enemy;
|
||||
}
|
||||
|
||||
return PlayerContext.Other;
|
||||
}
|
||||
|
||||
private InheritableValue<bool>? GetInheritableVisibilityForPlayer(Tag tag, PlayerContext playerContext)
|
||||
{
|
||||
switch (playerContext)
|
||||
{
|
||||
case PlayerContext.Self:
|
||||
return tag.IsVisibleForSelf;
|
||||
case PlayerContext.Friend:
|
||||
return tag.IsVisibleForFriendPlayers;
|
||||
case PlayerContext.Party:
|
||||
return tag.IsVisibleForPartyPlayers;
|
||||
case PlayerContext.Alliance:
|
||||
return tag.IsVisibleForAlliancePlayers;
|
||||
case PlayerContext.Enemy:
|
||||
return tag.IsVisibleForEnemyPlayers;
|
||||
case PlayerContext.Other:
|
||||
return tag.IsVisibleForOtherPlayers;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsVisibleForPlayer(Tag tag, PlayerCharacter playerCharacter)
|
||||
{
|
||||
var inheritable = GetInheritableVisibilityForPlayer(tag, GetContextForPlayer(playerCharacter));
|
||||
if (inheritable == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inheritable.InheritedValue == null || !inheritable.InheritedValue.Value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Payload[] CreatePayloads(Tag tag)
|
||||
{
|
||||
List<Payload> newPayloads = new List<Payload>();
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace PlayerTags
|
||||
m_PluginConfigurationUI = new PluginConfigurationUI(m_PluginConfiguration, m_PluginData);
|
||||
|
||||
m_XivCommon = new XivCommonBase(XivCommon.Hooks.ContextMenu);
|
||||
PluginServices.ClientState.TerritoryChanged += ClientState_TerritoryChanged;
|
||||
PluginServices.DalamudPluginInterface.UiBuilder.Draw += UiBuilder_Draw;
|
||||
PluginServices.DalamudPluginInterface.UiBuilder.OpenConfigUi += UiBuilder_OpenConfigUi;
|
||||
PluginServices.CommandManager.AddHandler(c_CommandName, new CommandInfo((string command, string arguments) =>
|
||||
@@ -44,14 +43,6 @@ namespace PlayerTags
|
||||
m_ChatTagTargetFeature = new ChatTagTargetFeature(m_PluginConfiguration, m_PluginData);
|
||||
}
|
||||
|
||||
//private ExcelSheet<ContentFinderCondition> _contentFinderConditionsSheet;
|
||||
private void ClientState_TerritoryChanged(object? sender, ushort e)
|
||||
{
|
||||
//_contentFinderConditionsSheet = DataManager.GameData.GetExcelSheet<ContentFinderCondition>();
|
||||
//var content = _contentFinderConditionsSheet.FirstOrDefault(t => t.TerritoryType.Row == PluginServices.ClientState.TerritoryType);
|
||||
//content.ContentMemberType.Row
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_ChatTagTargetFeature.Dispose();
|
||||
@@ -60,7 +51,6 @@ namespace PlayerTags
|
||||
PluginServices.CommandManager.RemoveHandler(c_CommandName);
|
||||
PluginServices.DalamudPluginInterface.UiBuilder.OpenConfigUi -= UiBuilder_OpenConfigUi;
|
||||
PluginServices.DalamudPluginInterface.UiBuilder.Draw -= UiBuilder_Draw;
|
||||
PluginServices.ClientState.TerritoryChanged -= ClientState_TerritoryChanged;
|
||||
m_XivCommon.Dispose();
|
||||
}
|
||||
|
||||
|
||||
112
PlayerTags/Resources/Strings.Designer.cs
generated
112
PlayerTags/Resources/Strings.Designer.cs
generated
@@ -60,6 +60,15 @@ namespace PlayerTags.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Activities.
|
||||
/// </summary>
|
||||
public static string Loc_ActivityVisibility {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_ActivityVisibility", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to All Custom.
|
||||
/// </summary>
|
||||
@@ -97,7 +106,7 @@ namespace PlayerTags.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Game object names to apply to.
|
||||
/// Looks up a localized string similar to Add to players.
|
||||
/// </summary>
|
||||
public static string Loc_GameObjectNamesToApplyTo {
|
||||
get {
|
||||
@@ -106,7 +115,7 @@ namespace PlayerTags.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A list of game object names to always apply tags to, separated by commas or semi-colons. E.g. "Cloud Strife, Tifa Lockhart"..
|
||||
/// Looks up a localized string similar to A list of players to add tags to, separated by commas or semi-colons. E.g. "Cloud Strife, Tifa Lockhart"..
|
||||
/// </summary>
|
||||
public static string Loc_GameObjectNamesToApplyTo_Description {
|
||||
get {
|
||||
@@ -114,6 +123,15 @@ namespace PlayerTags.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to General.
|
||||
/// </summary>
|
||||
public static string Loc_General {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_General", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Icon.
|
||||
/// </summary>
|
||||
@@ -312,6 +330,78 @@ namespace PlayerTags.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Visible for alliance players.
|
||||
/// </summary>
|
||||
public static string Loc_IsVisibleForAlliancePlayers {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_IsVisibleForAlliancePlayers", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Visible for enemy players.
|
||||
/// </summary>
|
||||
public static string Loc_IsVisibleForEnemyPlayers {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_IsVisibleForEnemyPlayers", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Visible for other players.
|
||||
/// </summary>
|
||||
public static string Loc_IsVisibleForOtherPlayers {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_IsVisibleForOtherPlayers", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Visible for party players.
|
||||
/// </summary>
|
||||
public static string Loc_IsVisibleForPartyPlayers {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_IsVisibleForPartyPlayers", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Visible for self.
|
||||
/// </summary>
|
||||
public static string Loc_IsVisibleForSelf {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_IsVisibleForSelf", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Visible in overworld.
|
||||
/// </summary>
|
||||
public static string Loc_IsVisibleInOverworld {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_IsVisibleInOverworld", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Visible in pve duties.
|
||||
/// </summary>
|
||||
public static string Loc_IsVisibleInPveDuties {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_IsVisibleInPveDuties", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Visible in pvp duties.
|
||||
/// </summary>
|
||||
public static string Loc_IsVisibleInPvpDuties {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_IsVisibleInPvpDuties", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Free company.
|
||||
/// </summary>
|
||||
@@ -555,6 +645,24 @@ namespace PlayerTags.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Players.
|
||||
/// </summary>
|
||||
public static string Loc_PlayerVisibility {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_PlayerVisibility", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Position.
|
||||
/// </summary>
|
||||
public static string Loc_Position {
|
||||
get {
|
||||
return ResourceManager.GetString("Loc_Position", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to DPS.
|
||||
/// </summary>
|
||||
|
||||
@@ -382,10 +382,10 @@
|
||||
</data>
|
||||
|
||||
<data name="Loc_GameObjectNamesToApplyTo" xml:space="preserve">
|
||||
<value>Game object names to apply to</value>
|
||||
<value>Add to players</value>
|
||||
</data>
|
||||
<data name="Loc_GameObjectNamesToApplyTo_Description" xml:space="preserve">
|
||||
<value>A list of game object names to always apply tags to, separated by commas or semi-colons. E.g. "Cloud Strife, Tifa Lockhart".</value>
|
||||
<value>A list of players to add tags to, separated by commas or semi-colons. E.g. "Cloud Strife, Tifa Lockhart".</value>
|
||||
</data>
|
||||
|
||||
<data name="Loc_TagPosition_After" xml:space="preserve">
|
||||
@@ -410,4 +410,46 @@
|
||||
<data name="Loc_IsEnabled" xml:space="preserve">
|
||||
<value>Enabled</value>
|
||||
</data>
|
||||
|
||||
<data name="Loc_Position" xml:space="preserve">
|
||||
<value>Position</value>
|
||||
</data>
|
||||
<data name="Loc_General" xml:space="preserve">
|
||||
<value>General</value>
|
||||
</data>
|
||||
<data name="Loc_ActivityVisibility" xml:space="preserve">
|
||||
<value>Activities</value>
|
||||
</data>
|
||||
<data name="Loc_PlayerVisibility" xml:space="preserve">
|
||||
<value>Players</value>
|
||||
</data>
|
||||
|
||||
<data name="Loc_IsVisibleInPveDuties" xml:space="preserve">
|
||||
<value>Show in pve duties</value>
|
||||
</data>
|
||||
<data name="Loc_IsVisibleInPvpDuties" xml:space="preserve">
|
||||
<value>Show in pvp duties</value>
|
||||
</data>
|
||||
<data name="Loc_IsVisibleInOverworld" xml:space="preserve">
|
||||
<value>Show elsewhere</value>
|
||||
</data>
|
||||
|
||||
<data name="Loc_IsVisibleForSelf" xml:space="preserve">
|
||||
<value>Show for self</value>
|
||||
</data>
|
||||
<data name="Loc_IsVisibleForPartyPlayers" xml:space="preserve">
|
||||
<value>Show for party members</value>
|
||||
</data>
|
||||
<data name="Loc_IsVisibleForAlliancePlayers" xml:space="preserve">
|
||||
<value>Show for alliance members</value>
|
||||
</data>
|
||||
<data name="Loc_IsVisibleForFriendPlayers" xml:space="preserve">
|
||||
<value>Show for friends</value>
|
||||
</data>
|
||||
<data name="Loc_IsVisibleForEnemyPlayers" xml:space="preserve">
|
||||
<value>Show for enemies</value>
|
||||
</data>
|
||||
<data name="Loc_IsVisibleForOtherPlayers" xml:space="preserve">
|
||||
<value>Show for others</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user