Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make nameplate settings less ambiguous #753

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions totalRP3/Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1402,15 +1402,9 @@ If you wish to report %s's profile and you cannot target them you will need to o
NAMEPLATES_CONFIG_DISABLE_IN_COMBAT_HELP = "If checked, disables nameplate customizations while you are in combat.",
NAMEPLATES_CONFIG_DISABLE_OUT_OF_CHARACTER = "Disable customizations when OOC",
NAMEPLATES_CONFIG_DISABLE_OUT_OF_CHARACTER_HELP = "If checked, disables all nameplate customizations while you are out of character.",
NAMEPLATES_CONFIG_DISABLE_OUT_OF_CHARACTER_UNITS = "Disable customizations on OOC units",
NAMEPLATES_CONFIG_DISABLE_OUT_OF_CHARACTER_UNITS_HELP = "If checked, disables nameplate customizations on units that are out of character.",
NAMEPLATES_CONFIG_HIDE_NON_ROLEPLAY_UNITS = "Hide non-roleplay units",
NAMEPLATES_CONFIG_HIDE_NON_ROLEPLAY_UNITS_HELP = "If checked, hides the nameplates of player and companion units that do not have roleplay profiles.",
NAMEPLATES_CONFIG_HIDE_OUT_OF_CHARACTER_UNITS = "Hide out of character units",
NAMEPLATES_CONFIG_HIDE_OUT_OF_CHARACTER_UNITS_HELP = "If checked, hides the nameplates of units that are currently out of character.",
NAMEPLATES_CONFIG_ELEMENT_HEADER = "Customization settings",
NAMEPLATES_CONFIG_CUSTOMIZE_NAMES = "Show custom names",
NAMEPLATES_CONFIG_CUSTOMIZE_NAMES_HELP = "If checked, replaces the name shown on nameplates.",
NAMEPLATES_CONFIG_CUSTOMIZE_NAMES_HELP = "Controls how custom names for units will be displayed.",
NAMEPLATES_CONFIG_CUSTOMIZE_NAME_COLORS = "Show custom name colors",
NAMEPLATES_CONFIG_CUSTOMIZE_NAME_COLORS_HELP = "If checked, overrides the color of name texts with the class color of a units' profile.",
NAMEPLATES_CONFIG_CUSTOMIZE_HEALTH_COLORS = "Show custom health colors",
Expand All @@ -1423,6 +1417,12 @@ If you wish to report %s's profile and you cannot target them you will need to o
NAMEPLATES_CONFIG_CUSTOMIZE_ROLEPLAY_STATUS_HELP = "If checked, shows an indicator of a units' roleplay status (IC or OOC) on nameplates.",
NAMEPLATES_CONFIG_CUSTOMIZE_ICONS = "Show icons",
NAMEPLATES_CONFIG_CUSTOMIZE_ICONS_HELP = "If checked, shows profile icons on nameplates.",
NAMEPLATES_CONFIG_CUSTOMIZE_OOC_UNITS = "Customize OOC units",
NAMEPLATES_CONFIG_CUSTOMIZE_OOC_UNITS_HELP = "Controls the customization of out of character units.",
NAMEPLATES_CONFIG_CUSTOMIZE_NON_ROLEPLAY_UNITS = "Customize non-roleplay units",
NAMEPLATES_CONFIG_CUSTOMIZE_NON_ROLEPLAY_UNITS_HELP = "Controls the customization of units that do not have roleplay profiles.",
NAMEPLATES_CONFIG_CUSTOMIZE_NPC_UNITS = "Customize NPC units",
NAMEPLATES_CONFIG_CUSTOMIZE_NPC_UNITS_HELP = "Controls the customization of NPC units.",
NAMEPLATES_CONFIG_ICON_SIZE = "Icon size",
NAMEPLATES_CONFIG_ICON_SIZE_HELP = "Configures the size of icons displayed on nameplates if the |cffffff00Show icons|r option is enabled.",
NAMEPLATES_CONFIG_ACTIVE_QUERY = "Automatically fetch profiles",
Expand All @@ -1431,6 +1431,18 @@ If you wish to report %s's profile and you cannot target them you will need to o
NAMEPLATES_CONFIG_ENABLE_CLASS_COLOR_FALLBACK_HELP = "If checked, this enables the use of class colors for names and health bars as a fallback for units that do not have a custom class color in their profile.|n|nUnits that do not have roleplay profiles are unaffected by this setting and will not be class-colored.",
NAMEPLATES_CONFIG_BLIZZARD_NAME_ONLY = "Hide bars on |cff449fe0Blizzard|r nameplates",
NAMEPLATES_CONFIG_BLIZZARD_NAME_ONLY_HELP = "If checked, this enables the use of name-only mode for |cff449fe0Blizzard|r nameplates.|n|nIn this mode, all nameplates will have their health bars hidden, including those of enemy units and other players with or without roleplay profiles.|n|nThis option requires a UI reload to take effect.",
NAMEPLATES_CONFIG_UNIT_STATE_SHOW = "Show",
NAMEPLATES_CONFIG_UNIT_STATE_SHOW_HELP = "Show nameplates for these units with full customizations applied.|n|nVisibility of these nameplates may be overridden by other settings.",
NAMEPLATES_CONFIG_UNIT_STATE_HIDE = "Always hide",
NAMEPLATES_CONFIG_UNIT_STATE_HIDE_HELP = "Always hide nameplates for these units.",
NAMEPLATES_CONFIG_UNIT_STATE_DISABLE = "Do not customize",
NAMEPLATES_CONFIG_UNIT_STATE_DISABLE_HELP = "Ignore nameplates for these units and do not customize them.",
NAMEPLATES_CONFIG_UNIT_NAME_FULL = "Show full name",
NAMEPLATES_CONFIG_UNIT_NAME_FULL_HELP = "Shows the full name of units.",
NAMEPLATES_CONFIG_UNIT_NAME_FIRST = "Show first name",
NAMEPLATES_CONFIG_UNIT_NAME_FIRST_HELP = "Only show first names of players rather than full names.|n|nThis will not work with companion units and profiles received from other roleplay addons.",
NAMEPLATES_CONFIG_UNIT_NAME_ORIGINAL = "Show original name",
NAMEPLATES_CONFIG_UNIT_NAME_ORIGINAL_HELP = "Shows the original unmodified player name of the unit.",

BLIZZARD_NAMEPLATES_MODULE_NAME = "Blizzard Nameplates",
BLIZZARD_NAMEPLATES_MODULE_DESCRIPTION = "Enables the customization of Blizzard's default nameplates.",
Expand Down Expand Up @@ -1553,14 +1565,10 @@ If you wish to report %s's profile and you cannot target them you will need to o
CO_TOOLBAR_VISIBILITY_2 = "Only show in-character",
CO_TOOLBAR_VISIBILITY_3 = "Always hidden",

NAMEPLATES_CONFIG_CUSTOMIZE_FIRST_NAMES = "Show first names only",
NAMEPLATES_CONFIG_CUSTOMIZE_FIRST_NAMES_HELP = "If checked, only show the first names rather than full names.|n|nThis can only be applied to player units, and will not work with profiles received from other roleplay addons.",
NAMEPLATES_CONFIG_CUSTOMIZE_GUILD = "Show custom guild names",
NAMEPLATES_CONFIG_CUSTOMIZE_GUILD_HELP = "If checked, show custom guild names on nameplates that support them.",
NAMEPLATES_CONFIG_DISABLE_IN_INSTANCES = "Disable customizations in instances",
NAMEPLATES_CONFIG_DISABLE_IN_INSTANCES_HELP = "If checked, disables nameplate customizations while in instances.|n|nIn instanced content friendly nameplates cannot be customized.",
NAMEPLATES_CONFIG_DISABLE_NON_PLAYABLE_UNITS = "Disable customizations on NPC units",
NAMEPLATES_CONFIG_DISABLE_NON_PLAYABLE_UNITS_HELP = "If checked, disables nameplate customizations on non-playable character units.",
NAMEPLATES_CONFIG_MAX_NAME_CHARS = "Maximum name length",
NAMEPLATES_CONFIG_MAX_NAME_CHARS_HELP = "The maximum number of characters to display for names and prefix titles. Names exceeding this length will be cropped.",
NAMEPLATES_CONFIG_MAX_TITLE_CHARS = "Maximum title length",
Expand Down
2 changes: 1 addition & 1 deletion totalRP3/Modules/Flyway/Flyway.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TRP3_API.flyway = {};

local type, tostring = type, tostring;

local SCHEMA_VERSION = 15;
local SCHEMA_VERSION = 16;

if not TRP3_Flyway then
TRP3_Flyway = {};
Expand Down
53 changes: 53 additions & 0 deletions totalRP3/Modules/Flyway/FlywayPatches.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,56 @@ TRP3_API.flyway.patches["15"] = function()
TRP3_Configuration["increase_color_contrast"] = nil;
end
end

TRP3_API.flyway.patches["16"] = function()
-- This patch migrates a few nameplates settings from separated booleans
-- to enums.

if not TRP3_Configuration then
return;
end

local customizeNonRoleplayUnits;
local customizeNPCUnits;
local customizeOOCUnits;
local customizeNames;

if TRP3_Configuration["NamePlates_DisableOutOfCharacterUnits"] then
customizeOOCUnits = TRP3_NamePlateUnitCustomizationState.Disable;
elseif TRP3_Configuration["NamePlates_HideOutOfCharacterUnits"] then
customizeOOCUnits = TRP3_NamePlateUnitCustomizationState.Hide;
else
customizeOOCUnits = TRP3_NamePlateUnitCustomizationState.Show;
end

if TRP3_Configuration["NamePlates_DisableNonPlayableUnits"] then
customizeNPCUnits = TRP3_NamePlateUnitCustomizationState.Disable;
else
customizeNPCUnits = TRP3_NamePlateUnitCustomizationState.Show;
end

if TRP3_Configuration["NamePlates_HideNonRoleplayUnits"] then
customizeNonRoleplayUnits = TRP3_NamePlateUnitCustomizationState.Hide;
else
customizeNonRoleplayUnits = TRP3_NamePlateUnitCustomizationState.Show;
end

if TRP3_Configuration["NamePlates_CustomizeNames"] == false then
customizeNames = TRP3_NamePlateUnitNameDisplayMode.OriginalName;
elseif TRP3_Configuration["NamePlates_CustomizeFirstNames"] then
customizeNames = TRP3_NamePlateUnitNameDisplayMode.FirstName;
else
customizeNames = TRP3_NamePlateUnitNameDisplayMode.FullName;
end

TRP3_Configuration["NamePlates_CustomizeNonRoleplayUnits"] = customizeNonRoleplayUnits;
TRP3_Configuration["NamePlates_CustomizeNPCUnits"] = customizeNPCUnits;
TRP3_Configuration["NamePlates_CustomizeOOCUnits"] = customizeOOCUnits;
TRP3_Configuration["NamePlates_CustomizeNames"] = customizeNames;

TRP3_Configuration["NamePlates_DisableNonPlayableUnits"] = nil;
TRP3_Configuration["NamePlates_HideNonRoleplayUnits"] = nil;
TRP3_Configuration["NamePlates_DisableOutOfCharacterUnits"] = nil;
TRP3_Configuration["NamePlates_HideOutOfCharacterUnits"] = nil;
TRP3_Configuration["NamePlates_CustomizeFirstName"] = nil;
end
101 changes: 66 additions & 35 deletions totalRP3/Modules/NamePlates/NamePlates_Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local function GetOrCreateDisplayInfo(unitToken)
displayInfo.guildRank = nil;
displayInfo.guildIsCustom = nil;
displayInfo.icon = nil;
displayInfo.isRoleplayUnit = false;
displayInfo.name = nil;
displayInfo.roleplayStatus = nil;
displayInfo.shouldColorHealth = nil;
Expand Down Expand Up @@ -91,44 +92,48 @@ local function IsUnitOutOfCharacter(unitToken)
return roleplayStatus == AddOn_TotalRP3.Enums.ROLEPLAY_STATUS.OUT_OF_CHARACTER;
end

local function IsNPCUnit(unitToken)
return not UnitIsPlayer(unitToken) and not UnitIsOtherPlayersPet(unitToken);
end

local function ShouldCustomizeUnitNamePlate(unitToken)
local shouldCustomize;

if not TRP3_NamePlates:IsEnabled() then
return false; -- Module is disabled.
shouldCustomize = false; -- Module is disabled.
elseif not unitToken then
return false; -- Unit is invalid.
shouldCustomize = false; -- Unit is invalid.
elseif UnitIsUnit(unitToken, "player") then
return false; -- Never decorate personal nameplates.
shouldCustomize = false; -- Never decorate personal nameplates.
elseif TRP3_NamePlatesSettings.DisableInCombat and isInCombat then
return false; -- Player is in (or about to enter) combat.
shouldCustomize = false; -- Player is in (or about to enter) combat.
elseif TRP3_NamePlatesSettings.DisableInInstances and IsInInstance() then
return false; -- Player is in instanced content.
shouldCustomize = false; -- Player is in instanced content.
elseif TRP3_NamePlatesSettings.DisableOutOfCharacter and IsUnitOutOfCharacter("player") then
return false; -- Player is currently OOC.
elseif TRP3_NamePlatesSettings.DisableNonPlayableUnits and (not UnitIsPlayer(unitToken) and not UnitIsOtherPlayersPet(unitToken)) then
return false; -- NPC unit decorations are disabled.
elseif TRP3_NamePlatesSettings.DisableOutOfCharacterUnits and IsUnitOutOfCharacter(unitToken) then
return false; -- Unit is currently OOC.
shouldCustomize = false; -- Player is currently OOC.
elseif TRP3_NamePlatesSettings.CustomizeNPCUnits == TRP3_NamePlateUnitCustomizationState.Disable and IsNPCUnit(unitToken) then
shouldCustomize = false; -- NPC unit decorations are disabled.
elseif TRP3_NamePlatesSettings.CustomizeOOCUnits == TRP3_NamePlateUnitCustomizationState.Disable and IsUnitOutOfCharacter(unitToken) then
shouldCustomize = false; -- Unit is currently OOC.
else
return true;
shouldCustomize = true;
end

return shouldCustomize;
end

local function ShouldHideUnitNamePlate(unitToken)
if TRP3_NamePlatesSettings.ShowTargetUnit and UnitIsUnit(unitToken, "target") then
return false;
end

local roleplayStatus = GetUnitRoleplayStatus(unitToken);
local isNonRoleplayUnit = (roleplayStatus == nil);
local isOutOfCharacter = (roleplayStatus == AddOn_TotalRP3.Enums.ROLEPLAY_STATUS.OUT_OF_CHARACTER);
local shouldHide;

if TRP3_NamePlatesSettings.HideNonRoleplayUnits and isNonRoleplayUnit then
return true;
elseif TRP3_NamePlatesSettings.HideOutOfCharacterUnits and isOutOfCharacter then
return true;
if TRP3_NamePlatesSettings.CustomizeNPCUnits == TRP3_NamePlateUnitCustomizationState.Hide and IsNPCUnit(unitToken) then
shouldHide = true; -- NPC units should be hidden.
elseif TRP3_NamePlatesSettings.CustomizeOOCUnits == TRP3_NamePlateUnitCustomizationState.Hide and IsUnitOutOfCharacter(unitToken) then
shouldHide = true; -- OOC units should be hidden.
else
return false;
shouldHide = false;
end

return shouldHide;
end

local function GetCompanionColorForDisplay(colorHexString)
Expand All @@ -153,28 +158,29 @@ end

local function GetCharacterUnitDisplayInfo(unitToken, characterID)
local displayInfo = GetOrCreateDisplayInfo(unitToken);
displayInfo.shouldHide = ShouldHideUnitNamePlate(unitToken);

if characterID and TRP3_API.register.isUnitIDKnown(characterID) then
local player = GetOrCreatePlayerFromCharacterID(characterID);
local classToken = UnitClassBase(unitToken);

displayInfo.isRoleplayUnit = true;

do -- Names/Titles
if TRP3_NamePlatesSettings.CustomizeNames then
if TRP3_NamePlatesSettings.CustomizeFirstNames then
displayInfo.name = player:GetFirstName();
end
if TRP3_NamePlatesSettings.CustomizeNames == TRP3_NamePlateUnitNameDisplayMode.FirstName then
displayInfo.name = player:GetFirstName(); -- May be nil or empty.
elseif TRP3_NamePlatesSettings.CustomizeNames == TRP3_NamePlateUnitNameDisplayMode.OriginalName then
displayInfo.name = player:GetName(); -- Should never be nil or empty.
end

if not displayInfo.name or displayInfo.name == "" then
displayInfo.name = player:GetRoleplayingName();
end
if not displayInfo.name or displayInfo.name == "" then
displayInfo.name = player:GetRoleplayingName();
end

if TRP3_NamePlatesSettings.CustomizeTitles then
local prefix = player:GetTitle();

if prefix then
displayInfo.name = strjoin(" ", prefix, displayInfo.name or player:GetName());
displayInfo.name = strjoin(" ", prefix, displayInfo.name);
end
end

Expand Down Expand Up @@ -246,13 +252,14 @@ end

local function GetCompanionUnitDisplayInfo(unitToken, companionFullID)
local displayInfo = GetOrCreateDisplayInfo(unitToken);
displayInfo.shouldHide = ShouldHideUnitNamePlate(unitToken);

local profile = TRP3_API.companions.register.getCompanionProfile(companionFullID);

if profile and profile.data then
displayInfo.isRoleplayUnit = true;

do -- Names/Titles
if TRP3_NamePlatesSettings.CustomizeNames then
if TRP3_NamePlatesSettings.CustomizeNames ~= TRP3_NamePlateUnitNameDisplayMode.OriginalName then
displayInfo.name = profile.data.NA;
end

Expand Down Expand Up @@ -300,7 +307,6 @@ end

local function GetNonPlayableUnitDisplayInfo(unitToken)
local displayInfo = GetOrCreateDisplayInfo(unitToken);
displayInfo.shouldHide = ShouldHideUnitNamePlate(unitToken);
return displayInfo;
end

Expand Down Expand Up @@ -474,6 +480,31 @@ function TRP3_NamePlates:GetUnitDisplayInfo(unitToken)
end
end

-- Apply additional post-filter logic for non-roleplay units. Filters can
-- flag display info as being roleplay related or not, allowing other
-- addons to mark units like NPCs as being roleplay units.

if displayInfo and not displayInfo.isRoleplayUnit then
if TRP3_NamePlatesSettings.CustomizeNonRoleplayUnits == TRP3_NamePlateUnitCustomizationState.Disable then
displayInfo = nil;
elseif TRP3_NamePlatesSettings.CustomizeNonRoleplayUnits == TRP3_NamePlateUnitCustomizationState.Hide then
displayInfo.shouldHide = true;
end
end

-- If no explicit visibility was set by any filter, figure out a default
-- based on the unit in question.

if displayInfo and displayInfo.shouldHide == nil then
displayInfo.shouldHide = ShouldHideUnitNamePlate(unitToken);
end

-- Target visibility takes priority over everything else and is forced.

if displayInfo and TRP3_NamePlatesSettings.ShowTargetUnit and UnitIsUnit(unitToken, "target") then
displayInfo.shouldHide = false;
end

return displayInfo;
end

Expand Down
Loading