From 14bb07f7abbd1ffcdec6fd75a36140941838623e Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Wed, 16 Nov 2022 07:30:21 +0100 Subject: [PATCH] use gray color at text formatting applying --- .../Features/NameplateTagTargetFeature.cs | 52 ++++--------------- PlayerTags/Features/TagTargetFeature.cs | 7 +-- PlayerTags/Resources/Strings.Designer.cs | 2 +- PlayerTags/Resources/Strings.resx | 2 +- 4 files changed, 16 insertions(+), 47 deletions(-) diff --git a/PlayerTags/Features/NameplateTagTargetFeature.cs b/PlayerTags/Features/NameplateTagTargetFeature.cs index 09786f4..7b02576 100644 --- a/PlayerTags/Features/NameplateTagTargetFeature.cs +++ b/PlayerTags/Features/NameplateTagTargetFeature.cs @@ -114,31 +114,8 @@ namespace PlayerTags.Features var beforeTitleBytes = args.Title.Encode(); var iconID = args.IconId; var generalOptions = m_PluginConfiguration.GeneralOptions[ActivityContextManager.CurrentActivityContext.ActivityType]; - var applyTags = false; - var grayOut = false; - if (args.PlayerCharacter != null) - { - if (args.PlayerCharacter.IsDead) - { - switch (generalOptions.NameplateDeadPlayerHandling) - { - case DeadPlayerHandling.Include: - applyTags = true; - break; - case DeadPlayerHandling.GrayOut: - grayOut = true; - break; - } - } - else - applyTags = true; - } - - if (applyTags) - AddTagsToNameplate(args.PlayerCharacter, args.Name, args.Title, args.FreeCompany, ref iconID, generalOptions); - else if(grayOut) - GrayOutNameplate(args.PlayerCharacter, args.Name, args.Title, args.FreeCompany, ref iconID); + AddTagsToNameplate(args.PlayerCharacter, args.Name, args.Title, args.FreeCompany, ref iconID, generalOptions); args.IconId = iconID; @@ -200,7 +177,7 @@ namespace PlayerTags.Features int? newStatusIcon = null; NameplateChanges nameplateChanges = GenerateEmptyNameplateChanges(name, title, freeCompany); - if (gameObject is PlayerCharacter playerCharacter) + if (gameObject is PlayerCharacter playerCharacter && (!playerCharacter.IsDead || generalOptions.NameplateDeadPlayerHandling != DeadPlayerHandling.Ignore)) { var classJob = playerCharacter.ClassJob; var classJobGameData = classJob?.GameData; @@ -258,6 +235,12 @@ namespace PlayerTags.Features if (gameObject is PlayerCharacter playerCharacter1) { + ushort? colorOverwrite = null; + + // Use gray color if player is dead + if (playerCharacter1.IsDead && generalOptions.NameplateDeadPlayerHandling == DeadPlayerHandling.GrayOut) + colorOverwrite = 3; + // An additional step to apply text color to additional locations Identity identity = m_PluginData.GetIdentity(playerCharacter1); foreach (var customTagId in identity.CustomTagIds) @@ -274,27 +257,12 @@ namespace PlayerTags.Features { var destStrings = new[] { name, title, freeCompany }; var isTextColorApplied = new[] { tag.IsTextColorAppliedToNameplateName, tag.IsTextColorAppliedToNameplateTitle, tag.IsTextColorAppliedToNameplateFreeCompany }; - ApplyTextFormatting(gameObject, tag, new[] { name, title, freeCompany }, isTextColorApplied, null); + ApplyTextFormatting(gameObject, tag, new[] { name, title, freeCompany }, isTextColorApplied, null, + overwriteTextColor: colorOverwrite); } } } - protected void GrayOutNameplate(GameObject gameObject, SeString name, SeString title, SeString freeCompany, ref int statusIcon) - { - if (gameObject is PlayerCharacter playerCharacter) - { - NameplateChanges nameplateChanges = GenerateEmptyNameplateChanges(name, title, freeCompany); - - foreach (NameplateElements element in Enum.GetValues()) - { - nameplateChanges.GetChange(element, StringPosition.Before).Payloads.Add(new UIForegroundPayload(3)); - nameplateChanges.GetChange(element, StringPosition.After).Payloads.Add(new UIForegroundPayload(0)); - } - - ApplyNameplateChanges(nameplateChanges); - } - } - protected void ApplyNameplateChanges(NameplateChanges nameplateChanges) { var props = new NameplateChangesProps diff --git a/PlayerTags/Features/TagTargetFeature.cs b/PlayerTags/Features/TagTargetFeature.cs index 7773da5..a0e6c0b 100644 --- a/PlayerTags/Features/TagTargetFeature.cs +++ b/PlayerTags/Features/TagTargetFeature.cs @@ -223,7 +223,7 @@ namespace PlayerTags.Features StringUpdateFactory.ApplyStringChanges(props); } - protected void ApplyTextFormatting(GameObject gameObject, Tag tag, SeString[] destStrings, InheritableValue[] textColorApplied, List preferedPayloads) + protected void ApplyTextFormatting(GameObject gameObject, Tag tag, SeString[] destStrings, InheritableValue[] textColorApplied, List preferedPayloads, ushort? overwriteTextColor = null) { if (IsTagVisible(tag, gameObject)) { @@ -239,11 +239,12 @@ namespace PlayerTags.Features void applyTextColor(SeString destPayload, InheritableValue enableFlag, InheritableValue colorValue) { + var colorToUse = overwriteTextColor ?? colorValue?.InheritedValue; if (shouldApplyFormattingPayloads(destPayload) && enableFlag.InheritedValue != null && enableFlag.InheritedValue.Value - && colorValue.InheritedValue != null) - applyTextFormattingPayloads(destPayload, new UIForegroundPayload(colorValue.InheritedValue.Value), new UIForegroundPayload(0)); + && colorToUse != null) + applyTextFormattingPayloads(destPayload, new UIForegroundPayload(colorToUse.Value), new UIForegroundPayload(0)); } //void applyTextGlowColor(SeString destPayload, InheritableValue enableFlag, InheritableValue colorValue) diff --git a/PlayerTags/Resources/Strings.Designer.cs b/PlayerTags/Resources/Strings.Designer.cs index 94f850b..e0808c2 100644 --- a/PlayerTags/Resources/Strings.Designer.cs +++ b/PlayerTags/Resources/Strings.Designer.cs @@ -223,7 +223,7 @@ namespace PlayerTags.Resources { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Gray out the nameplate of dead players and don't apply any tag for. ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Apply any tag but gray out the nameplate. ähnelt. /// public static string Loc_DeadPlayerHandling_GrayOut_Description { get { diff --git a/PlayerTags/Resources/Strings.resx b/PlayerTags/Resources/Strings.resx index 6f9fd7b..43bbdae 100644 --- a/PlayerTags/Resources/Strings.resx +++ b/PlayerTags/Resources/Strings.resx @@ -805,7 +805,7 @@ Use this if you want to to have every option under your control or just want to Handling for dead players - Gray out the nameplate of dead players and don't apply any tag for. + Apply any tag but gray out the nameplate. Don't process dead players and don't apply any tag for.