View Single Post
04-12-12, 01:45 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I made myself a button for vehicle exit.
Lua Code:
  1. local b = CreateFrame("BUTTON", nil, UIParent, "SecureHandlerClickTemplate");
  2.   b:SetSize(50,50)
  3.   b:SetPoint("CENTER",0,0)
  4.   b:RegisterForClicks("AnyUp")
  5.   b:SetNormalTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Up")
  6.   b:SetPushedTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down")
  7.   b:SetHighlightTexture("Interface\\Vehicles\\UI-Vehicles-Button-Exit-Down")
  8.   b:SetScript("OnClick", function(self) VehicleExit() end)
  9.   RegisterStateDriver(b, "visibility", "[target=vehicle,exists] show;hide")
Nearly the same could be done for anything else. You may even add a new texture to the button to display any type of icon. Spell textures can be get via GetSpellInfo(). If you want no highlight/border textures just leave them out. As you can see you can even add macro-states for visibility.

Adding a texture could be done like this (Only needed if you want to add a border-texture as normaltexture. Otherwise just use normaltexture for this)
Lua Code:
  1. --icon texture
  2.     local _, _, icon_texture = GetSpellInfo(spellid) --input your spellid here
  3.     local t = b:CreateTexture(nil,"BACKGROUND",nil,-6)
  4.     t:SetTexture(icon_texture)
  5.     t:SetTexCoord(0.1,0.9,0.1,0.9) --cut out crappy icon border
  6.     t:SetAllPoints(b) --make texture same size as button

If you want hover-states with different alpha you need to add OnEnter and OnLeave events with the behaviour you want to achieve. Like
Lua Code:
  1. --alpha
  2.     b:SetAlpha(0.2)
  3.     b:SetScript("OnEnter", function(self) self:SetAlpha(1) end)
  4.     b:SetScript("OnLeave", function(self) self:SetAlpha(0.2) end)

Just write your own addon for this.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 04-12-12 at 02:05 AM.