View Single Post
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