[FR] NameOnly for nonattackable units, Level for NameOnly, QuestIcon for NameOnly
BelegCufea opened this issue ยท 3 comments
Hello.
First of all. Thanks for excellent addon. Best one I have tried so far (TidyPlates, TheratPlates, KUINameplates, Plater ...). Very easy but quite powerful configuration.
(BTW, not a lua programmer and not a native speaker, so sorry for mistakes in either of these)
May I suggest few features, I would like to see in Stripes.
I have implemented some hardcoded changes that works for me right now, but it would be nice to have them in your addon without me tinkering in it (and with some nice configuration).
I have "Health progress in name" option checked, so the changes may need to be implemented elsewhere.
Can we have NameOnly for non attackable units? I would like to know if that other faction "guard" will attack me, when I run by.
My take on changes looks something like that (with current config options, changes are somewhat commented):
Handler.lua
local function IsNameOnlyModeAndFriendly(unitType, canAttack)
if not NAME_ONLY_FRIENDLY_ENABLED or canAttack then
return false;
end
-- nonattackable
if NAME_ONLY_FRIENDLY_ENABLED and not canAttack then
return true;
end
if NAME_ONLY_FRIENDLY_PLAYERS_ONLY then
return unitType == 'FRIENDLY_PLAYER';
else
return NAME_ONLY_FRIENDLY_UNIT_TYPES[unitType];
end
end
Name.lua
local function NameOnly_UpdateNameHealth(unitframe)
...
if NAME_ONLY_COLOR_HEALTH then
if unitframe.data.unitType == 'FRIENDLY_PLAYER' and not unitframe.data.canAttack then
...
--elseif not NAME_ONLY_FRIENDLY_PLAYERS_ONLY and unitframe.data.unitType == 'FRIENDLY_NPC' then
elseif not NAME_ONLY_FRIENDLY_PLAYERS_ONLY and IsNameOnlyModeAndFriendly(unitframe.data.unitType, unitframe.data.canAttack) then
...
end
end
...
local function NameOnly_UpdateGuildName(unitframe)
...
if IsNameOnlyMode() and NAME_ONLY_GUILD_NAME then
if unitframe.data.unitType == 'FRIENDLY_PLAYER' and unitframe.data.guild then
...
--elseif unitframe.data.unitType == 'FRIENDLY_NPC' then
elseif IsNameOnlyModeAndFriendly(unitframe.data.unitType, unitframe.data.canAttack) then
...
else
unitframe.GuildName:Hide();
end
else
unitframe.GuildName:Hide();
end
end
As I like to see level even for units that have NameOnly (as I am extending their number by above change) it would be nice to have lvl text for them as well.
Again my take for changes:
Name.lua
local function NameOnly_UpdateNameHealth(unitframe)
...
if NAME_ONLY_COLOR_HEALTH then
-- local variable for level text (dunno if it is OK)
local level = ""
if ... then
if ... then
if unitframe.data.healthCurrent > 0 and unitframe.data.healthMax > 0 then
local name = GetPlayerName(unitframe);
-- get level text (with Player text for players)
if unitframe.data.level and unitframe.data.diff then
level = U.RGB2CFFHEX(unitframe.data.diff) .. unitframe.data.level .. " Player|r "
end
local health_len = strlenutf8(name) * (unitframe.data.healthCurrent / unitframe.data.healthMax);
-- show level
unitframe.name:SetText(level .. utf8sub(name, 0, health_len) .. GREY_COLOR_START .. utf8sub(name, health_len + 1));
end
else
...
end
elseif ... then
...
if unitframe.data.healthCurrent > 0 and unitframe.data.healthMax > 0 then
-- get level text
if unitframe.data.level and unitframe.data.diff and unitframe.data.classification then
level = U.RGB2CFFHEX(unitframe.data.diff) .. unitframe.data.level .. unitframe.data.classification .. "|r "
end
local health_len = strlenutf8(name) * (unitframe.data.healthCurrent / unitframe.data.healthMax);
-- show level
unitframe.name:SetText(level .. utf8sub(name, 0, health_len) .. GREY_COLOR_START .. utf8sub(name, health_len + 1));
end
end
end
end
And last but not least. It would be nice to have QuestIcon on NameOnly nameplates.
Again my take (it breaks when changing position of quest icon in options and needs a reload of UI) :
QuestIndicatior.lua
local S, L, O, U, D, E = unpack(select(2, ...));
local Module = S:NewNameplateModule('QuestIndicator');
-- to distinguish when to put quest icon next to name a when next to healthbar)
local Stripes = S:GetNameplateModule('Handler');
local IsNameOnlyModeAndFriendly = Stripes.IsNameOnlyModeAndFriendly;
...
local function Create(unitframe)
...
-- parent frame to unitframe instead of unitframe.healhBar
local frame = CreateFrame('Frame', '$parentQuestIndicator', unitframe);
...
end
...
local function UpdateStyle(unitframe)
unitframe.QuestIndicator:ClearAllPoints();
if IsNameOnlyModeAndFriendly(unitframe.data.unitType, unitframe.data.canAttack) then
unitframe.QuestIndicator:SetAllPoints(unitframe.name);
else
unitframe.QuestIndicator:SetAllPoints(unitframe.healthBar);
end
...
end
Thanks again for phenomenal addon.
Hey! Thank you for your kind words! I appreciate it!
I did everything you asked (almost no changes) and made the "Show level" setting for "Name Only" mode.
A new version will be available in an hour
WoW. That was quick.
Thank you very much Voopie.
Hope nobody will object to the changes (too much :-))