Thread Tools Display Modes
11-16-19, 05:58 AM   #1
Mandraxon
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 21
Nameplate modifications (wow original)

Hello all.
Im using a code i found on the web that alows me to adjust nameplate fontsize and also change server Visuals.

Now i want to find a way to
1. change text colour to Always be White
2. move the text offset closer to the nameplate bar (anchor Point)

what is the best way to do this?

Lua Code:
  1. --nameplate font size
  2.  
  3. local f = CreateFrame("Frame")
  4. f:RegisterEvent("PLAYER_LOGIN")
  5. f:SetScript("OnEvent", function()  
  6.  
  7. local function SetFont(obj, optSize)
  8.     local fontName= obj:GetFont()  
  9.     obj:SetFont(fontName,optSize,"THINOUTLINE")
  10. end
  11.  
  12. SetFont(SystemFont_LargeNamePlate,8)
  13. SetFont(SystemFont_NamePlate,8)
  14. SetFont(SystemFont_LargeNamePlateFixed,8)
  15. SetFont(SystemFont_NamePlateFixed,8)
  16.  
  17. end)
  18.  
  19. -- no RealmName on nameplates
  20.  
  21. hooksecurefunc("CompactUnitFrame_UpdateName", function(frame)
  22.     if ShouldShowName(frame) then
  23.         if frame.optionTable.colorNameBySelection then
  24.             frame.name:SetText(GetUnitName(frame.unit))
  25.         end
  26.     end
  27. end)
  Reply With Quote
11-16-19, 12:24 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Looks fine to me, though you don't need to wait for an event to change the font properties. They already exist by the time the addon runs.



As for your additional requests, here's how I'd reset the nametag anchors.
Lua Code:
  1. hooksecurefunc(NamePlateDriverFrame,"OnNamePlateCreated",function(base)--   Hook nameplate creation function
  2.     local unitframe=base.UnitFrame;--   UnitFrame attached to nameplate base
  3.  
  4.     unitframe.name:ClearAllPoints();--  Clear nametag anchors
  5. --  Set new anchor(s) here
  6. end);

I think the nametag is always white. The nameplates just change their alpha when "selected".
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-16-19 at 12:29 PM.
  Reply With Quote
11-16-19, 12:31 PM   #3
Mandraxon
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 21
hey SDPhantom!
Thanks for the help.

im new at this, just grew tired of things not doing what i wanted and searched arround.

Care to explain deeper "you don't need to wait for an event to change the font properties"

If youd clean up the code i use and add your new extras how would it look.

now what code will be used to move down the Nameplate font slightly where you added
-- Set new anchor(s) here


i tested this
-- Disable target highlight
DefaultCompactNamePlateFriendlyFrameOptions.displaySelectionHighlight=false;
DefaultCompactNamePlateEnemyFrameOptions.displaySelectionHighlight=false;
DefaultCompactNamePlatePlayerFrameOptions.displaySelectionHighlight=false;

but the font does not change to white on all nameplates

what i want is for enemy (npc and player) text to be white with black outline!
at the moment the text folows namplate colour.
so agrro mobs are red. neutral yellow both text and nameplates.
i want nameplates to be the colour but the names white.

Last edited by Mandraxon : 11-16-19 at 12:37 PM.
  Reply With Quote
11-17-19, 01:47 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Looks like nameplates on classic behave differently than on modern.
Here's a more complete example with the changes.
Lua Code:
  1. --  Nametag font size
  2. local function SetFont(obj,optSize)
  3.     local fontName=obj:GetFont();
  4.     obj:SetFont(fontName,optSize,"THINOUTLINE");
  5. end
  6.  
  7. SetFont(SystemFont_LargeNamePlate,8);
  8. SetFont(SystemFont_NamePlate,8);
  9. SetFont(SystemFont_LargeNamePlateFixed,8);
  10. SetFont(SystemFont_NamePlateFixed,8);
  11.  
  12. --  Disable nametag colors
  13. DefaultCompactNamePlateFriendlyFrameOptions.colorNameBySelection=false;
  14. DefaultCompactNamePlateEnemyFrameOptions.colorNameBySelection=false;
  15. DefaultCompactNamePlatePlayerFrameOptions.colorNameBySelection=false;
  16.  
  17. --  Move nametag
  18. hooksecurefunc(NamePlateDriverFrame,"OnNamePlateCreated",function(_,base)--   Hook nameplate creation function
  19.     local unitframe=base.UnitFrame;--   UnitFrame attached to nameplate base
  20.     unitframe.name:ClearAllPoints();--  Clear nametag anchors
  21.  
  22. --  Set new anchor(s) here
  23.     unitframe.name:SetPoint("BOTTOM",unitframe.healthBar,"TOP",0,4);
  24. end);
  25.  
  26. --  Remove realm names
  27. hooksecurefunc("CompactUnitFrame_UpdateName",function(frame)
  28.     if ShouldShowName(frame) then
  29.         frame.name:SetVertexColor(1,1,1);-- Fixes tapped mobs permanently setting the nametag gray
  30.         frame.name:SetText(GetUnitName(frame.unit));
  31.     end
  32. end);

Note: A recreation of the existing anchor is given to illustrate how to set an anchor from Lua. If you need more detail on the function, see fontstring:SetPoint().
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-18-19 at 12:14 PM.
  Reply With Quote
11-17-19, 03:08 PM   #5
Mandraxon
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 21
Hey.
Thanks for the help. the text color is working nicely but something with the anchor is messing up.

i get this error but if i remove

-- Move nametag
hooksecurefunc(NamePlateDriverFrame,"OnNamePlateCreated",function(base)-- Hook nameplate creation function
local unitframe=base.UnitFrame;-- UnitFrame attached to nameplate base
unitframe.name:ClearAllPoints();-- Clear nametag anchors

-- Set new anchor(s) here
unitframe.name:SetPoint("BOTTOM",unitframe.healthBar,"TOP",0,0);
end);

i only get inteface caused an error in chat.


ERROR MESSAGE

Message: Interface\AddOns\EmyaraMod\EmyaraMod.lua:47: attempt to index local 'unitframe' (a nil value)
Time: Sun Nov 17 22:07:15 2019
Count: 4
Stack: Interface\AddOns\EmyaraMod\EmyaraMod.lua:47: attempt to index local 'unitframe' (a nil value)
[string "@Interface\AddOns\EmyaraMod\EmyaraMod.lua"]:47: in function <Interface\AddOns\EmyaraMod\EmyaraMod.lua:45>
[string "=[C]"]: in function `OnNamePlateCreated'
[string "@Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua"]:45: in function <...e\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:42>

Locals: base = NamePlateDriverFrame {
0 = <userdata>
OnNamePlateAdded = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:91
GetBaseNamePlateWidth = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:305
UpdateInsetsForType = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:130
namePlateAnchorFunctions = <table> {
}
OnUnitAuraUpdate = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:154
namePlateSetupFunctions = <table> {
}
OnNamePlateResized = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:204
ApplyFrameOptions = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:112
IsUsingLargerNamePlateStyle = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:313
namePlateSetInsetFunctions = <table> {
}
UpdateNamePlateOptions = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:318
classNamePlatePowerBar = ClassNameplateManaBarFrame {
}
GetClassNameplateBar = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:283
OnForbiddenNamePlateCreated = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:83
SetClassNameplateBar = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:278
SetupClassNameplateBars = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:213
OnNamePlateCreated = <function> defined =[C]:-1
SetClassNameplateManaBar = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:291
SetBaseNamePlateSize = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:296
GetOnSizeChangedFunction = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:125
OnNamePlateRemoved = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:143
GetClassNameplateManaBar = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:287
OnLoad = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:3
baseNamePlateWidth = 110
OnUnitFactionChanged = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:196
OnEvent = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:42
preferredInsets = <table> {
}
GetBaseNamePlateHeight = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:309
OnTargetChanged = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:149
baseNamePlateHeight = 45
OnRaidTargetUpdate = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:182
GetNamePlateTypeFromUnit = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:102
}
unitframe = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to index local 'unitframe' (a nil value)"

Last edited by Mandraxon : 11-17-19 at 03:11 PM.
  Reply With Quote
11-18-19, 12:16 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Oh, right. I forgot the function is called as NamePlateDriverFrame:OnNamePlateCreated(...). I adjusted the argument list in my previous post to fix that.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-18-19, 04:08 PM   #7
Mandraxon
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 21
Originally Posted by SDPhantom View Post
Oh, right. I forgot the function is called as NamePlateDriverFrame:OnNamePlateCreated(...). I adjusted the argument list in my previous post to fix that.
thanks man..
I tested it now and No errors
but the hookpoint does not seam to work

Code:
    --  Move nametag
    hooksecurefunc(NamePlateDriverFrame,"OnNamePlateCreated",function(_,base)--   Hook nameplate creation function
        local unitframe=base.UnitFrame;--   UnitFrame attached to nameplate base
        unitframe.name:ClearAllPoints();--  Clear nametag anchors
     
    --  Set new anchor(s) here
        unitframe.name:SetPoint("BOTTOM",unitframe.healthBar,"TOP",0,4);
    end);
TOP",0,4); i changed both the 0 and 4 and nothing moves =/ even as high as 0,25 and nothing..

/M
  Reply With Quote
11-19-19, 02:40 AM   #8
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Looks like more modern version trickery. Try replacing that block with this instead.
Lua Code:
  1. --  Move nametag
  2. hooksecurefunc("DefaultCompactNamePlateFrameAnchorInternal",function(frame)
  3.     frame.name:ClearAllPoints();--  Clear nametag anchors
  4.     PixelUtil.SetPoint(frame.name,"BOTTOM",frame.healthBar,"TOP",0,4);--    Set new anchor
  5. end);
Note: Since the original function uses PixelUtil.SetPoint() to set its position agnostic to scaling. I believe it should be used here too.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-19-19 at 02:45 AM.
  Reply With Quote
11-19-19, 10:17 AM   #9
Mandraxon
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 21
Originally Posted by SDPhantom View Post
Looks like more modern version trickery. Try replacing that block with this instead.
Lua Code:
  1. --  Move nametag
  2. hooksecurefunc("DefaultCompactNamePlateFrameAnchorInternal",function(frame)
  3.     frame.name:ClearAllPoints();--  Clear nametag anchors
  4.     PixelUtil.SetPoint(frame.name,"BOTTOM",frame.healthBar,"TOP",0,4);--    Set new anchor
  5. end);
Note: Since the original function uses PixelUtil.SetPoint() to set its position agnostic to scaling. I believe it should be used here too.

That did it.
Awsome, Thanks alot.

The only issue i need to work out now is the debuff location and size.
why did blizz set them so far of?
if you have any code for that id be most happy.
This is how it looks now

Last edited by Mandraxon : 11-19-19 at 10:22 AM.
  Reply With Quote
11-19-19, 01:39 PM   #10
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
To isolate the adjustment to only when the name is showing, we'll just semi-recreate the original function managing the buff container.
Lua Code:
  1. hooksecurefunc(NameplateBuffContainerMixin,"UpdateAnchor",function(self)
  2.     local parent=self:GetParent();
  3.     local unit=parent.unit;
  4.  
  5.     if unit and ShouldShowName(parent) then
  6. --      Replicate the calculation of the original function
  7.         local offset=self:GetBaseYOffset()+((unit and UnitIsUnit(unit,"target")) and self:GetTargetYOffset() or 0);
  8.         self:SetPoint("BOTTOM",parent,"TOP",0,offset);--    Apply offset here
  9.     end--   We'll leave the false side of this alone to preserve the original anchor in that case
  10. end);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-19-19, 02:04 PM   #11
Mandraxon
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 21
Originally Posted by SDPhantom View Post
To isolate the adjustment to only when the name is showing, we'll just semi-recreate the original function managing the buff container.
Lua Code:
  1. hooksecurefunc(NameplateBuffContainerMixin,"UpdateAnchor",function(self)
  2.     local parent=self:GetParent();
  3.     local unit=parent.unit;
  4.  
  5.     if unit and ShouldShowName(parent) then
  6. --      Replicate the calculation of the original function
  7.         local offset=self:GetBaseYOffset()+((unit and UnitIsUnit(unit,"target")) and self:GetTargetYOffset() or 0);
  8.         self:SetPoint("BOTTOM",parent,"TOP",0,offset);--    Apply offset here
  9.     end--   We'll leave the false side of this alone to preserve the original anchor in that case
  10. end);


dude thats awsome.
You are a true star.

i used to use flyplate debuffs and it had a toggle to show names on untracked nameplates (se image )
I need to be able to scale the debuffs to match the style better

Thanks for all the work man.. making my UI be how i want it to be.



as you can se, only the targeted nameplate has text.
i can fix it with the tracking function in wow.. but then i get names shwoing where i dont.
in FlyPlates i had a function to --fix nameplates without names like the dummys in the image.

anyhow.
Thanx for the aid.
  Reply With Quote
12-13-21, 04:35 PM   #12
Fourteen
A Kobold Labourer
Join Date: Dec 2021
Posts: 1
Originally Posted by Mandraxon View Post
dude thats awsome.
You are a true star.

i used to use flyplate debuffs and it had a toggle to show names on untracked nameplates (se image )
I need to be able to scale the debuffs to match the style better

Thanks for all the work man.. making my UI be how i want it to be.



as you can se, only the targeted nameplate has text.
i can fix it with the tracking function in wow.. but then i get names shwoing where i dont.
in FlyPlates i had a function to --fix nameplates without names like the dummys in the image.

anyhow.
Thanx for the aid.
I want to change nameplate health bar texture just like you do
I dont know how to do it
can i have your code please
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Nameplate modifications (wow original)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off