Thread Tools Display Modes
02-03-15, 02:23 AM   #1
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
buttons and textures (a pro post on getting help) (from Phanx) (#needsalife))

DISCLAIMER! (In big red text!)
I'm really really really bored! So I attempted to make a good post for Phanx's sake


Anyways:

I feel like my buttons are screwed up somewhere >.> or I missed another stupid thing. Or I really did forget how to do stuff lua or rather in general.

Phanx (or someone else ) please point out the error in my ways! all my buttons are the same texture even though they should be diffeent colors!

code (because I'm a good OP like that!)

Lua Code:
  1. local use_Minimap = false --disabling this forces Click Menu to make a button
  2. local button_location = { "CENTER", UIParent, "CENTER", 0, 0 }
  3. local blizzard_theme = false
  4. local color_normal = { 1, 1, 1, 0.5 }
  5. local color_hover = { 1, 0, 1, 0.5 }
  6. local color_pushed = { 1, 1, 0, 0.5 }
  7.  
  8.   local button = CreateFrame("Button", nil, mainframe)
  9.   button:SetPoint(unpack(button_location))
  10.   button:SetWidth(50)
  11.   button:SetHeight(25)
  12.  
  13.   button:SetText("Menu")
  14.   button:SetNormalFontObject("GameFontNormal")
  15.  
  16.   local ntex = button:CreateTexture()
  17.   if blizzard_theme then
  18.     ntex:SetTexture("Interface/Buttons/UI-Panel-Button-Up")
  19.   else
  20.     ntex:SetTexture("Interface\\Buttons\\WHITE8x8")
  21.     ntex:SetVertexColor("color_normal")
  22.   end
  23.   ntex:SetTexCoord(0, 0.625, 0, 0.6875)
  24.   ntex:SetAllPoints()
  25.   button:SetNormalTexture(ntex)
  26.  
  27.   local htex = button:CreateTexture()
  28.   if blizzard_theme then
  29.     htex:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight")
  30.   else
  31.     htex:SetTexture("Interface\\Buttons\\WHITE8x8")
  32.     htex:SetVertexColor("color_hover")
  33.   end
  34.   htex:SetTexCoord(0, 0.625, 0, 0.6875)
  35.   htex:SetAllPoints()
  36.   button:SetHighlightTexture(htex)
  37.  
  38.   local ptex = button:CreateTexture()
  39.   if blizzard_theme then
  40.     ptex:SetTexture("Interface/Buttons/UI-Panel-Button-Down")
  41.   else
  42.     ptex:SetTexture("Interface\\Buttons\\WHITE8x8")
  43.     ptex:SetVertexColor("color_pushed")
  44.   end
  45.   ptex:SetTexCoord(0, 0.625, 0, 0.6875)
  46.   ptex:SetAllPoints()
  47.   button:SetPushedTexture(ptex)
  48.  
  49.   button:SetScript('OnMouseUp', function(self, button)
  50.     if button == "LeftButton" or button == "RightButton" then
  51.       securecall(EasyMenu, menuList, menuFrame, self, 27, 190, 'MENU', 8)
  52.     end
  53.   end)
  54. end

TL;DR
I need to go to bed and get some sleep been up for well over 48 hours at this point.....
__________________
Tweets YouTube Website
  Reply With Quote
02-03-15, 02:30 AM   #2
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
for a more common style help post

Me: "My button textures are all broke can I getz help"
Phanx: "post your code!"
Seerah: "post your code!"
Someone Else: "post your code!"
Me: It's this
Lua Code:
  1. frame:SetTexture("texturename")
Phanx: /facepalm "Need MOAR CODEZ"
Me: I'm sorry Phanx I don't understand what mmore you need I gave you plenty!"
Phanx: Insert long rant about why Phanx should just give up and stop helping 10leej
Me: BUT I WANTZ HELP!
Seerah: "Post more code next time" /closethread
Dammit I'm going to sleep I'll let this all play out and look at all the replays later before I start posting more hypothetical scenarios for Phanx......
__________________
Tweets YouTube Website
  Reply With Quote
02-03-15, 03:07 AM   #3
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
lua Code:
  1. ntex:SetVertexColor("color_normal")

You're passing a string to SetVertexColor instead of the RGBA values it expects.

This is what you want:
lua Code:
  1. ntex:SetVertexColor(unpack(color_normal))

This unpacks the color_normal table into the four numbers expected by SetVertexColor.
  Reply With Quote
02-04-15, 12:05 AM   #4
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by Choonstertwo View Post
lua Code:
  1. ntex:SetVertexColor("color_normal")

You're passing a string to SetVertexColor instead of the RGBA values it expects.

This is what you want:
lua Code:
  1. ntex:SetVertexColor(unpack(color_normal))

This unpacks the color_normal table into the four numbers expected by SetVertexColor.
Ah it's a
I missed another stupid thing. Or I really did forget how to do stuff lua or rather in general.
type of thing then....

(I feel like Phanx is avoiding me now...)
__________________
Tweets YouTube Website
  Reply With Quote
02-04-15, 12:19 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by 10leej View Post
(I feel like Phanx is avoiding me now...)
No point in replying when someone else already answered the question.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » buttons and textures (a pro post on getting help) (from Phanx) (#needsalife))

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