implement job icon feature

This commit is contained in:
2022-11-06 11:32:02 +01:00
parent c4baba304e
commit 1e3380cbd1
8 changed files with 130 additions and 35 deletions

View File

@@ -1,6 +1,7 @@
using Dalamud.Configuration;
using Newtonsoft.Json;
using Pilz.Dalamud.ActivityContexts;
using Pilz.Dalamud.Nameplates.Tools;
using PlayerTags.Data;
using PlayerTags.Inheritables;
using System;
@@ -35,12 +36,13 @@ namespace PlayerTags.Configuration
{ ActivityType.PvpDuty, new GeneralOptionsClass() }
};
public StatusIconPriorizerSettings StatusIconPriorizerSettings = new();
public bool IsPlayerNameRandomlyGenerated = false;
public bool IsCustomTagsContextMenuEnabled = true;
public bool IsShowInheritedPropertiesEnabled = true;
public bool IsPlayersTabOrderedByProximity = false;
public bool IsPlayersTabSelfVisible = true;
public bool IsPlayersTabFriendsVisible = true;
public bool IsPlayersTabFriendsVisible = true;
public bool IsPlayersTabPartyVisible = true;
public bool IsPlayersTabAllianceVisible = true;
public bool IsPlayersTabEnemiesVisible = true;

View File

@@ -6,6 +6,7 @@ using Dalamud.Logging;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Pilz.Dalamud.ActivityContexts;
using Pilz.Dalamud.Icons;
using PlayerTags.Data;
using PlayerTags.Inheritables;
using PlayerTags.PluginStrings;
@@ -692,6 +693,10 @@ namespace PlayerTags.Configuration
{
DrawInheritable(selectedInheritable.Inheritable.Key, true, false, inheritableNameplateTitlePosition);
}
else if (selectedInheritable.Inheritable.Value is InheritableValue<JobIconSetName> inheritableJobIconSetName)
{
DrawInheritable(selectedInheritable.Inheritable.Key, false, false, inheritableJobIconSetName);
}
else if (selectedInheritable.Inheritable.Value is InheritableReference<string> inheritableString)
{
DrawInheritable(selectedInheritable.Inheritable.Key, inheritableString);

View File

@@ -50,9 +50,9 @@ namespace PlayerTags.Data
{
IsSelected = false,
IsExpanded = true,
IsIconVisibleInChat = true,
IsRoleIconVisibleInChat = true,
IsTextVisibleInChat = true,
IsIconVisibleInNameplates = true,
IsRoleIconVisibleInNameplates = true,
IsTextVisibleInNameplates = true,
IsTextColorAppliedToChatName = true,
};

View File

@@ -1,4 +1,5 @@
using Dalamud.Game.Text.SeStringHandling;
using Pilz.Dalamud.Icons;
using PlayerTags.Inheritables;
using PlayerTags.PluginStrings;
using System;
@@ -99,9 +100,13 @@ namespace PlayerTags.Data
[InheritableCategory("IconCategory")]
public InheritableValue<BitmapFontIcon> Icon = new InheritableValue<BitmapFontIcon>(BitmapFontIcon.Aethernet);
[InheritableCategory("IconCategory")]
public InheritableValue<bool> IsIconVisibleInChat = new InheritableValue<bool>(false);
public InheritableValue<bool> IsRoleIconVisibleInChat = new InheritableValue<bool>(false);
[InheritableCategory("IconCategory")]
public InheritableValue<bool> IsIconVisibleInNameplates = new InheritableValue<bool>(false);
public InheritableValue<bool> IsRoleIconVisibleInNameplates = new InheritableValue<bool>(false);
[InheritableCategory("IconCategory")]
public InheritableValue<bool> IsJobIconVisibleInNameplates = new InheritableValue<bool>(false);
[InheritableCategory("IconCategory")]
public InheritableValue<JobIconSetName> JobIconSet = new InheritableValue<JobIconSetName>(JobIconSetName.Framed);
[InheritableCategory("TextCategory")]
public InheritableReference<string> Text = new InheritableReference<string>("");

View File

@@ -130,9 +130,9 @@ namespace PlayerTags.Features
protected override bool IsIconVisible(Tag tag)
{
if (tag.IsIconVisibleInChat.InheritedValue != null)
if (tag.IsRoleIconVisibleInChat.InheritedValue != null)
{
return tag.IsIconVisibleInChat.InheritedValue.Value;
return tag.IsRoleIconVisibleInChat.InheritedValue.Value;
}
return false;

View File

@@ -3,6 +3,7 @@ using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Lumina.Excel.GeneratedSheets;
using Pilz.Dalamud.Icons;
using Pilz.Dalamud.Nameplates.Tools;
using Pilz.Dalamud.Tools.Strings;
using PlayerTags.Configuration;
@@ -20,25 +21,31 @@ namespace PlayerTags.Features
/// </summary>
public class NameplateTagTargetFeature : TagTargetFeature
{
private PluginConfiguration m_PluginConfiguration;
private PluginData m_PluginData;
private readonly PluginConfiguration m_PluginConfiguration;
private readonly PluginData m_PluginData;
private readonly StatusIconPriorizer statusiconPriorizer;
private readonly JobIconSets jobIconSets = new();
private Nameplate? m_Nameplate;
public NameplateTagTargetFeature(PluginConfiguration pluginConfiguration, PluginData pluginData)
{
m_PluginConfiguration = pluginConfiguration;
m_PluginData = pluginData;
statusiconPriorizer = new(pluginConfiguration.StatusIconPriorizerSettings);
PluginServices.ClientState.Login += ClientState_Login;
PluginServices.ClientState.Logout += ClientState_Logout;
Hook();
}
public override void Dispose()
{
Unhook();
PluginServices.ClientState.Logout -= ClientState_Logout;
PluginServices.ClientState.Login -= ClientState_Login;
base.Dispose();
}
@@ -81,9 +88,9 @@ namespace PlayerTags.Features
protected override bool IsIconVisible(Tag tag)
{
if (tag.IsIconVisibleInNameplates.InheritedValue != null)
if (tag.IsRoleIconVisibleInNameplates.InheritedValue != null)
{
return tag.IsIconVisibleInNameplates.InheritedValue.Value;
return tag.IsRoleIconVisibleInNameplates.InheritedValue.Value;
}
return false;
@@ -102,9 +109,12 @@ namespace PlayerTags.Features
private void Nameplate_PlayerNameplateUpdated(PlayerNameplateUpdatedArgs args)
{
var beforeTitleBytes = args.Title.Encode();
AddTagsToNameplate(args.PlayerCharacter, args.Name, args.Title, args.FreeCompany);
var iconID = args.IconId;
var generalOptions = m_PluginConfiguration.GeneralOptions[ActivityContextManager.CurrentActivityContext.ActivityType];
AddTagsToNameplate(args.PlayerCharacter, args.Name, args.Title, args.FreeCompany, ref iconID);
args.IconId = iconID;
if (generalOptions.NameplateTitlePosition == NameplateTitlePosition.AlwaysAboveName)
args.IsTitleAboveName = true;
else if (generalOptions.NameplateTitlePosition == NameplateTitlePosition.AlwaysBelowName)
@@ -147,8 +157,9 @@ namespace PlayerTags.Features
/// <param name="name">The name text to change.</param>
/// <param name="title">The title text to change.</param>
/// <param name="freeCompany">The free company text to change.</param>
private void AddTagsToNameplate(GameObject gameObject, SeString name, SeString title, SeString freeCompany)
private void AddTagsToNameplate(GameObject gameObject, SeString name, SeString title, SeString freeCompany, ref int statusIcon)
{
int? newStatusIcon = null;
NameplateChanges nameplateChanges = new();
nameplateChanges.GetProps(NameplateElements.Name).Destination = name;
nameplateChanges.GetProps(NameplateElements.Title).Destination = title;
@@ -156,8 +167,11 @@ namespace PlayerTags.Features
if (gameObject is PlayerCharacter playerCharacter)
{
var classJob = playerCharacter.ClassJob;
var classJobGameData = classJob?.GameData;
// Add the job tags
if (playerCharacter.ClassJob.GameData != null && m_PluginData.JobTags.TryGetValue(playerCharacter.ClassJob.GameData.Abbreviation, out var jobTag))
if (classJobGameData != null && m_PluginData.JobTags.TryGetValue(classJobGameData.Abbreviation, out var jobTag))
{
if (jobTag.TagTargetInNameplates.InheritedValue != null && jobTag.TagPositionInNameplates.InheritedValue != null)
checkTag(jobTag);
@@ -192,9 +206,18 @@ namespace PlayerTags.Features
if (payloads.Any())
AddPayloadChanges(tag.TagTargetInNameplates.InheritedValue.Value, tag.TagPositionInNameplates.InheritedValue.Value, payloads, nameplateChanges, false);
}
if (newStatusIcon == null && classJob != null && (tag.IsJobIconVisibleInNameplates?.InheritedValue ?? false))
newStatusIcon = jobIconSets.GetJobIcon(JobIconSetName.Framed, classJob.Id);
}
}
// Apply new status icon
if (newStatusIcon != null)
{
var change = nameplateChanges.GetChange(NameplateElements.Name, StringPosition.Before);
NameplateUpdateFactory.ApplyStatusIconWithPrio(ref statusIcon, (int)newStatusIcon, change, ActivityContextManager.CurrentActivityContext, statusiconPriorizer);
}
// Build the final strings out of the payloads
ApplyNameplateChanges(nameplateChanges);

View File

@@ -358,29 +358,20 @@ namespace PlayerTags.Resources {
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Whether the icon will be shown in chat. ähnelt.
/// Sucht eine lokalisierte Zeichenfolge, die Show job icon in nameplates ähnelt.
/// </summary>
public static string Loc_IsIconVisibleInChat_Description {
public static string Loc_IsJobIconVisibleInNameplates {
get {
return ResourceManager.GetString("Loc_IsIconVisibleInChat_Description", resourceCulture);
return ResourceManager.GetString("Loc_IsJobIconVisibleInNameplates", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Show in nameplates ähnelt.
/// Sucht eine lokalisierte Zeichenfolge, die Whether the job icon will be shown in nameplates. ähnelt.
/// </summary>
public static string Loc_IsIconVisibleInNameplates {
public static string Loc_IsJobIconVisibleInNameplates_Description {
get {
return ResourceManager.GetString("Loc_IsIconVisibleInNameplates", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Whether the icon will be shown in nameplates. ähnelt.
/// </summary>
public static string Loc_IsIconVisibleInNameplates_Description {
get {
return ResourceManager.GetString("Loc_IsIconVisibleInNameplates_Description", resourceCulture);
return ResourceManager.GetString("Loc_IsJobIconVisibleInNameplates_Description", resourceCulture);
}
}
@@ -546,6 +537,42 @@ namespace PlayerTags.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Whether the role icon will be shown in chat. ähnelt.
/// </summary>
public static string Loc_IsRoleIconVisibleInChat_Description {
get {
return ResourceManager.GetString("Loc_IsRoleIconVisibleInChat_Description", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Show role icon in nameplates ähnelt.
/// </summary>
public static string Loc_IsRoleIconVisibleInNameplates {
get {
return ResourceManager.GetString("Loc_IsRoleIconVisibleInNameplates", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Whether the role icon will be shown in nameplates. ähnelt.
/// </summary>
public static string Loc_IsRoleIconVisibleInNameplates_Description {
get {
return ResourceManager.GetString("Loc_IsRoleIconVisibleInNameplates_Description", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Show role icon in nameplate ähnelt.
/// </summary>
public static string Loc_IsRoleJobIconVisibleInNameplates {
get {
return ResourceManager.GetString("Loc_IsRoleJobIconVisibleInNameplates", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Selected ähnelt.
/// </summary>
@@ -861,6 +888,24 @@ namespace PlayerTags.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Job icon set ähnelt.
/// </summary>
public static string Loc_JobIconSet {
get {
return ResourceManager.GetString("Loc_JobIconSet", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die The icon set to use for displaying the job icon. You can also choose the role icon set to display the role icon instead. ähnelt.
/// </summary>
public static string Loc_JobIconSet_Description {
get {
return ResourceManager.GetString("Loc_JobIconSet_Description", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Hand ähnelt.
/// </summary>

View File

@@ -354,14 +354,14 @@
<data name="Loc_IsIconVisibleInChat" xml:space="preserve">
<value>Show in chat</value>
</data>
<data name="Loc_IsIconVisibleInChat_Description" xml:space="preserve">
<value>Whether the icon will be shown in chat.</value>
<data name="Loc_IsRoleIconVisibleInChat_Description" xml:space="preserve">
<value>Whether the role icon will be shown in chat.</value>
</data>
<data name="Loc_IsIconVisibleInNameplates" xml:space="preserve">
<value>Show in nameplates</value>
<data name="Loc_IsRoleIconVisibleInNameplates" xml:space="preserve">
<value>Show role icon in nameplates</value>
</data>
<data name="Loc_IsIconVisibleInNameplates_Description" xml:space="preserve">
<value>Whether the icon will be shown in nameplates.</value>
<data name="Loc_IsRoleIconVisibleInNameplates_Description" xml:space="preserve">
<value>Whether the role icon will be shown in nameplates.</value>
</data>
<data name="Loc_Text" xml:space="preserve">
<value>Text</value>
@@ -642,4 +642,19 @@
<data name="Loc_Static_Chat" xml:space="preserve">
<value>Chat</value>
</data>
<data name="Loc_IsRoleJobIconVisibleInNameplates" xml:space="preserve">
<value>Show role icon in nameplate</value>
</data>
<data name="Loc_IsJobIconVisibleInNameplates" xml:space="preserve">
<value>Show job icon in nameplates</value>
</data>
<data name="Loc_IsJobIconVisibleInNameplates_Description" xml:space="preserve">
<value>Whether the job icon will be shown in nameplates.</value>
</data>
<data name="Loc_JobIconSet" xml:space="preserve">
<value>Job icon set</value>
</data>
<data name="Loc_JobIconSet_Description" xml:space="preserve">
<value>The icon set to use for displaying the job icon. You can also choose the role icon set to display the role icon instead.</value>
</data>
</root>