Thread Tools Display Modes
11-07-22, 02:55 PM   #1
Elanthis
A Murloc Raider
Join Date: Nov 2022
Posts: 6
Problem with setting the tex-coords of a statusbar's texture

Pretext:
I am trying to change the health- and manabar textures of the default ui's personal resource display to match the new bar textures of the new Blizzard ui's player and target frames.
For that I use SetAtlas() on the textures used by the status bars of the personal resource display. That works fine, but...
...All variations of those new bar textures (that I can find in the atlas) have at least partially rounded corners. I want to get rid of those by cropping the bar textures at the left and right ends.

The problem:
When using SetTexCoord() on my newly changed health and mana bar textures of the personal resource display, nothing happens - the bar textures aren't cropped.

To elaborate:
The changing of the bar texture takes place after the NAME_PLATE_UNIT_ADDED event fires if the added nameplate's unit is the player (as the personal resource display is just called into existence as another nameplate).
This is when SetTexCoord() is called. When I tell the game to print() the status bar texture's tex-coords in the same function - just after calling SetTexCoord() - I get the newly set tex-coords, just like I want.
But it seems to be overwritten (or something - this is where I need your help) immediately, because I see no visual change in the game and when I manually tell the game to print() the status bar texture's tex-coords at any point in time, I get the un-cropped default coordinates.

Here's a minimal implementation of my code:
Lua Code:
  1. local handleNamePlateAddedFrame = CreateFrame("Frame")
  2. handleNamePlateAddedFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  3. handleNamePlateAddedFrame:SetScript("OnEvent", function(self, event, ...)
  4.     local unitToken = ...
  5.     if not UnitIsPlayer(unitToken) then return end
  6.  
  7.     local namePlate = C_NamePlate.GetNamePlateForUnit(unitToken)
  8.     local healthBar = namePlate.UnitFrame.healthBar
  9.     local healthBarTexture = healthBar:GetStatusBarTexture()
  10.  
  11.     healthBarTexture:SetAtlas("UI-HUD-UnitFrame-Player-PortraitOff-Bar-Health-Status")
  12.     healthBarTexture:SetTexCoord(0.1, 0.9, 0, 1)
  13.  
  14.     -- print(healthBar:GetStatusBarTexture():GetTexCoord())
  15. end)

Some thoughts:
I tried several things to (try to) rule out trivial mistakes/misunderstanding (as I'm not very experienced with all this). I won't post them here now, hoping that the problem is not something trivial and some of you can just instantly spot what's going on here.
If that is not the case and you want to rule out trivial mistakes, tell me and I'll follow up with a list of everything I tried so far.
Else I can just half-guess what's the problem here. One of my tests was to replicate the whole scenario but with just a simple status bar that I created and that I "ran the same code through" as I did with the pre-existing personal resource display status bars. And with my own, simple status bar it worked as expected.
So I figure there's something that the personal resource display structure does under the hood that I don't know of that's messing with my tex-coords.

Final words:
I'm not a very experienced wow programmer, it might be that I am missing something generic here. But I did try to search through the widget api doc and other forum posts regarding this matter and don't seem to be able to solve this one on my own. Help is much appreciated.

Last edited by Elanthis : 11-07-22 at 03:24 PM.
  Reply With Quote
11-07-22, 03:24 PM   #2
Elanthis
A Murloc Raider
Join Date: Nov 2022
Posts: 6
(I'm sorry. I wanted to move this post to the "Lua/XML Help" forum but now I can't seem to find a way to delete this old post (I'm new here). I apologize for the duplicate.)
  Reply With Quote

WoWInterface » Developer Discussions » Graphics Help » Problem with setting the tex-coords of a statusbar's texture

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