Thread Tools Display Modes
09-14-18, 03:35 AM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 329
Altering texture instead of covering it with new texture?

I have a frame with a texture that is defined in xml:

Code:
<CheckButton name="BagnonReagentbankToggleTemplate" inherits="BagnonMenuCheckButtonTemplate" virtual="true">
  <Layers>
    <Layer level="BACKGROUND">
      <Texture file="Interface\Icons\Achievement_GuildPerk_BountifulBags"/>
    </Layer>
  </Layers>
</CheckButton>

Under certain circumstances, I want to change this texture in my lua code:

Code:
function ReagentbankToggle:Update()
  if (not IsReagentBankUnlocked()) then
    local tex = self:CreateTexture(nil, "OVERLAY")
    tex:SetAllPoints()
    tex:SetTexture('Interface/Icons/Achievement_GuildPerk_BountifulBags');
    tex:SetVertexColor(1,0.1,0.1)
  end
end

But this solution always draws a new Texture on top of the others. With \fstack I can see them becoming more and more with every Update(). Isn't there a way to just alter the already existing texture? Or at least delete the old one before creating the new one?

My problem might just be that I don't know how to get a handle for the old texture into a variable...
  Reply With Quote
09-14-18, 06:11 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 6,007
Because the texture in the first block of code doesn't have a name or parentkey setting you have no direct access to it. If you did have them you would be able to simply access it directly and SetTexture to it directly without creating a new texture object which your second block of code does to solve the issue.

If you are the creator of the first block of code simply add parentKey = "<TextureName>" inside the xml file for that texture and then you can access it directly via <CheckButtonName>.<TextureName>.
__________________


All Level 70 Characters:
Demon Warlock
Resto Druid
Disc Priest
Resto Shaman
Survival Hunter
Augment Evoker
Frost Mage
Vengence Demon Hunter
Rogue ( was subtlety )

Brewmaster Monk (TR)
Prot Paladin (TR)
Blood Death Knight ( TR)

As you can see I am missing a warrior

And .. I don't have all the allied races covered. Time Runner time when it happens again

  Reply With Quote
09-14-18, 06:32 AM   #3
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 329
Thanks a lot! Worked like a charm! :-)
  Reply With Quote
09-14-18, 06:52 AM   #4
Jamestheone85
A Kobold Labourer
Join Date: Aug 2018
Posts: 1
Originally Posted by Xrystal View Post
Because the texture in the first block of code doesn't have a name or parentkey setting you have no direct access to it. If you did have them you would be able to simply access it directly and SetTexture to it directly without fever creating a new texture object which your second block of code does to solve the issue.

If you are the creator of the first block of code simply add parentKey = "<TextureName>" inside the xml file for that texture and then you can access it directly via <CheckButtonName>.<TextureName>.
Worked for me, thanks!

Last edited by Jamestheone85 : 10-19-18 at 09:37 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Altering texture instead of covering it with new texture?


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