WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   Custom Clickable Buttons (https://www.wowinterface.com/forums/showthread.php?t=43238)

Artanis186 04-11-12 09:04 PM

Custom Clickable Buttons
 
So I'm designing my interface with a very specific idea in mind. But I need some custom buttons to make this work. What I need is a semi-transparent clickable button that can have an image set as it (bonus points for 'hover' and 'click' states) with custom X and Y dimensions and can be set to do things like open the Friends list, open the achievements, open the menu, etc. I need it to be movable and have at least 5 different buttons at a time that each have a different image and ability.

EDIT: Simply put I want to be able to add an image to my UI of any dimension that you can click to open various panels.

If all of this is possible and could be provided in a single addon, I would greatly appreciate it being linked. Else if it'd be simple enough for a competent individual (that hasn't actually designed any UI items for WoW before) to make, it'd be nice to get an idea how to do that.

jeffy162 04-11-12 09:31 PM

Take a look at CustomButtons, or maybe Button Forge for the "buttons".

You can make your own custom graphics to use (as long as you save them to the proper size and image format) and put them in a folder (titled ICONS) in your Interface folder and they will show up in the icons for the Macro window.

Which leads me to this: I know there are scripts, or macros, you can run to open just about any default window in WoW. I don't know them, unfortunately, but I've seen them posted a few times on boards and know they're available.

EDIT: Or, you might take a look at nibMicroMenu /EDIT

Artanis186 04-11-12 09:46 PM

None of those seem to do what I need. I need custom graphics with specifically sized rectangular buttons and no forced borders.

zork 04-12-12 01:45 AM

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.

Artanis186 04-14-12 09:40 AM

Thanks for the info, but considering my experience, I could use some help. I have no idea how to make it do something simple, like show a UI panel. Could you lead me in the right direction there?

zork 04-14-12 02:25 PM

Example:
http://imgur.com/a/39TYH#0

There is a small button with the text "A" on it. Clicking the button will toggle the achievment frame.

Button will be less visibile by default and fade in on mouseover.

The red color comes from using a Blizzard button template called "UIPanelButtonTemplate"

Code to do it:
Lua Code:
  1. local myButton = CreateFrame("Button", "myFirstButton", UIParent, 'UIPanelButtonTemplate')
  2.   myButton:SetSize(20,20)
  3.   myButton:SetPoint("CENTER",200,0)
  4.   myButton:SetText('A')
  5.   myButton:RegisterForClicks("LeftButtonUp")
  6.   myButton:SetScript("OnClick", function() ToggleAchievementFrame() end)
  7.   myButton:SetAlpha(0.2)
  8.   myButton:SetScript("OnEnter", function(self) self:SetAlpha(1) end)
  9.   myButton:SetScript("OnLeave", function(self) self:SetAlpha(0.2) end)

http://wowprogramming.com/docs/api/CreateFrame
http://wowprogramming.com/docs/api/SetPoint
http://wowprogramming.com/docs/api/SetSize

etc.

How to create the addon for it.

Go to your WoW AddOns folder. Create a folder "myFirstButton". In that folder create a file called "myFirstButton.toc".

Put this code into the file
Lua Code:
  1. ## Interface: 40300
  2. ## Author: You
  3. ## Title: myFirstButton
  4. ## Notes: Buttons
  5.  
  6. core.lua

Now create another file called "core.lua" and copy the button code from above in that file.

Restart WoW to load the addon.

Narfi 01-23-20 09:00 AM

years aber
 
Quote:

Originally Posted by zork (Post 255359)
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.

Just still helpful for me at classic : )

thanks Zork

Gruss

hasnogaems 02-23-20 07:04 AM

Thank you for this guide zork, is very nice.

Quote:

Originally Posted by jeffy162 (Post 255348)
Take a look at CustomButtons

This link lead to no addon, and I googled it and did not find any.

Seerah 02-23-20 09:06 PM

Quote:

Originally Posted by hasnogaems (Post 335197)
Thank you for this guide zork, is very nice.

This link lead to no addon, and I googled it and did not find any.

Considering that link is from almost 8 years ago, it's likely that the addon no longer exists.

I'll be locking this thread now. Anything new can be put in a new thread.


All times are GMT -6. The time now is 11:19 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI