Thread Tools Display Modes
05-05-10, 04:26 PM   #1
corveroth
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
Buttons and Templates

I've got a couple of questions.

First, has anyone ever bothered to create documentation for the various templates used by the Blizzard UI, or are we each left to work out their quirks and behaviors individually?

Second. I want to make some buttons. In this particular case, the buttons would open tradeskill windows, but I'm also interested in creating buttons for casting arbitrary spells. I'd like these to work in much the same manner as the buttons in the spellbook (locked into a single action, cannot be reassigned), but... SpellButtonTemplate seems to be very specialized for the 12-button paged layout of the spellbook, ActionBarButtonTemplate seems to be highly specialized for action bars, etc. Where should I start here? Should I begin with ActionButtonTemplate and build everything up from there?
  Reply With Quote
05-05-10, 04:42 PM   #2
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
There are 2 aspects of making a button: the looks of the button and WTF it must do when it's clicked. I assume you know how to make a button that looks the way you want it. Next, you must set what to do with it when clicked:

button:SetScript("OnMouseUp", function(self, button)
-- INSERT HERE WTF TO DO
end)

And voila!
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
05-05-10, 04:47 PM   #3
corveroth
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
Originally Posted by nightcracker View Post
There are 2 aspects of making a button: the looks of the button and WTF it must do when it's clicked. I assume you know how to make a button that looks the way you want it. Next, you must set what to do with it when clicked:

button:SetScript("OnMouseUp", function(self, button)
-- INSERT HERE WTF TO DO
end)

And voila!
Alright, sure. For my current specific example, I expect I can get most of the behavior I want by just running CastSpellByName("Leatherworking") or the like OnMouseUp, since CSBN still works for professions. I'd like to know more about the general approach, though - I know that this won't work if I want to make a button that casts an actual spell.

I was looking toward the templates because they encapsulate the look-and-feel aspects of the Blizzard UI, and emulating that is very important to me. If I have to, I'm sure that I could rebuild all the look-and-feel of the spellbook buttons, but that would, quite frankly, suck.
  Reply With Quote
05-05-10, 07:14 PM   #4
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
You're going to need to create a button which inherits from the SecureActionButton template - then use it as a macro. There's an example of this (for disenchanting, milling, prospecting, and lockpicking) in my Revelation AddOn.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
05-06-10, 03:03 AM   #5
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Before you get your hopes up, there is NO WAY to cast spells in a dynamic way in combat except for the options given with macro(ex: /use [combat,nostealth] Stealth).

It is possible to dynamicly update a button out of combat, which for example Buffet and Cork do.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
05-06-10, 05:02 PM   #6
orionshock
A Wyrmkin Dreamwalker
 
orionshock's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 50
Originally Posted by corveroth View Post
I was looking toward the templates because they encapsulate the look-and-feel aspects of the Blizzard UI, and emulating that is very important to me. If I have to, I'm sure that I could rebuild all the look-and-feel of the spellbook buttons, but that would, quite frankly, suck.

http://wowprogramming.com/utils/xmlbrowser

most of the templates are available to look at.. after a while you'll get the feeling on how blizzard organized it's UI
__________________
"I was there in the beginning... and things were very different back then" --An Echo from a time before.
  Reply With Quote
05-06-10, 07:31 PM   #7
corveroth
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
Originally Posted by nightcracker View Post
Before you get your hopes up, there is NO WAY to cast spells in a dynamic way in combat except for the options given with macro(ex: /use [combat,nostealth] Stealth).

It is possible to dynamicly update a button out of combat, which for example Buffet and Cork do.
Of course. I accepted that from the start. Would I be reading too much into Torhal's post to infer that all action buttons (even those present in the spellbook) work through the macro system?

Originally Posted by orionshock View Post
http://wowprogramming.com/utils/xmlbrowser

most of the templates are available to look at.. after a while you'll get the feeling on how blizzard organized it's UI
Yeah, I know about that, and have been doing a lot of reading there. I just hoped there was a summary somewhere - something briefer and more prose-like than code-like. Along the lines of the brief descriptions you can find on pages like this. "This is what this template is for, and where it's used; note the following gotchas."

Last edited by corveroth : 05-06-10 at 07:35 PM.
  Reply With Quote
05-06-10, 08:40 PM   #8
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by corveroth View Post
<snip>Would I be reading too much into Torhal's post to infer that all action buttons (even those present in the spellbook) work through the macro system?<snip>
Only actions which are protected - using CastSpellByName("Tailoring") works just fine, but you'd need to use a macro for "/cast corruption".
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
05-06-10, 09:38 PM   #9
corveroth
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
Originally Posted by Torhal View Post
Only actions which are protected - using CastSpellByName("Tailoring") works just fine, but you'd need to use a macro for "/cast corruption".
I was more getting at "does Blizz do it that way too?"
  Reply With Quote
05-06-10, 09:53 PM   #10
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Oh, no - they have an unrestricted license to run secure code
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Buttons and Templates


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