Reply
 
Thread Tools Display Modes
Old 01-08-07, 05:59 PM   #1
Flickerstreak
A Deviate Faerie Dragon
Join Date: Dec 2006
Posts: 19
Arrow Request: SecureTemplate access for forgotten protected functions

There are quite a few "forgotten" protected functions which don't have any secure template access (and really need it):

- StopAttack()
- TogglePetAutocast()
- PetStopAttack()
- PetAggressiveMode/DefensiveMode/PassiveMode/Follow/Wait()
- CastShapeshiftForm()

And that's only in the action button domain.

Really, all protected functions should have some sort of secure template access, unless they're very specifically (and carefully) excluded completely from AddOn use (e.g. TurnOrMoveStart()). Ideally, it should be possible for an author to completely rewrite the default interface without using any Blizzard code other than secure templates. Currently that is not possible (shapeshift bar and pet bar) due to the exclusion of any non-tainted path to the above functions.

Now, some of these (e.g. TogglePetAutocast) you can work around by using a "click" action handler which clicks the (hidden?) original default UI button ... but that's about as elegant as swatting a fly with a Buick and it only works in certain scenarios.

Basically it's an artifact of not converting all the Blizzard UI code (see PetActionBarFrame.lua for example) to use the new security model: the blanket permission for all blizzard code to be trusted means that inevitably lots of these types of functions fall through the cracks. If the trusted files were reduced to Bindings.xml, SecureTemplates.lua, and SecureStateHeader.lua, that would be a preferable model.

Here's an example of how you could modify SecureButton_OnClick() to perform all the functionality listed above:

Code:
elseif ( type == "pet" ) then
  local action = SecureButton_GetModifiedAttribute(self, "action", button);
  local autocast = SecureButton_GetModifiedAttribute(self, "autocast", button);
  if ( action ) then
    if ( autocast ) then
      TogglePetAutocast(action)
    elsef ( IsPetAttackActive(action) ) then
      PetStopAttack();
    else
      CastPetAction(action);
    end
  else
    local mode = SecureButton_GetModifiedAttribute(self, "mode", button);
    if mode == "aggressive" then
      PetModeAggressive()
    elseif mode == "passive" then
      PetModePassive()
    elseif mode == "defensive" then
      PetModeDefensive()
    end
  end

...

elseif ( type == "shapeshift" ) then
  local action = SecureButton_GetModifiedAttribute(self, "action", button);
  if action then
    CastShapeshiftForm(action)
  end
    
...

Last edited by Flickerstreak : 01-10-07 at 05:12 PM. Reason: added implementation example, removed PlaceAction from the list since it's not actually protected
Flickerstreak is offline   Reply With Quote
Old 10-08-08, 01:39 PM   #2
BDelacroix
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 33
Necro warning!!! Yes, I'm bringing this back up because this needs to be done especially with the advent of the 3.0 patch that comes with a lot more than just 4 active pet abilities.

Building a better pet bar isn't difficult. Its just the fact that you can't build it with the pet attack/defend/passive etc. buttons for the simple fact that there is no secure access to these protected functions.
BDelacroix is offline   Reply With Quote
Old 10-09-08, 11:39 AM   #3
Maul
Ion Engines, Engage!
 
Maul's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 401
Well, you can actually. I have done it very easily. However, I do agree that the Secure Template could be fleshed out to be more all inclusive.

But almost all of the about functions, if not all, can be done via a button with adding type macro and macrotext.

Here is a little snippet of my code in Macaroon for pet buttons, slightly modified to be clearer -

button:SetAttribute("type1", "pet")
button:SetAttribute("type2", "macro")
button:SetAttribute("*action1", "[#]") - pet action number
button:SetAttribute("*macrotext2", "/petautocasttoggle "..petspell)

Through extensive testing these buttons work and behave like the default UI pet buttons. They are not the default UI pet buttons re-parented to Macaroon frames.
__________________

Twitter: @IonMaul | Windows Live: trinityui@live.com | Google Talk: trinityui@gmail.com
Maul is offline   Reply With Quote
Old 10-09-08, 03:52 PM   #4
Cirk
A Cobalt Mageweaver
 
Cirk's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 226
For pet actions, why not just inherit from the PetActionButtonTemplate, and set your button IDs to the appropriate values to trigger the needed pet actions?

Same with shapeshift actions - inherit from ShapeshiftButtonTemplate.

And for more complex operations, I guess you can either use the "click" or "macro" attribute style approaches.

In other words, although having secure template access to every protected function would make coding some things simpler, if there's already a default way to do things from a UI button perspective, then there's probably already a way to do it in an addon by some clever method


-- Cirk
__________________
Cirk's Addons
Cirk is offline   Reply With Quote
Old 10-11-08, 07:49 PM   #5
Maul
Ion Engines, Engage!
 
Maul's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 401
Well, in Trinity Bars I did just that, I used the Blizz templates. However, in Macaroon, I needed to approach things a bit different for various reasons.

But it is possible to create buttons that behave how they are expected to behave (based on how they are in the default UI) via secure templates. It is just not a straight forward as the above suggestion
__________________

Twitter: @IonMaul | Windows Live: trinityui@live.com | Google Talk: trinityui@gmail.com
Maul is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Wish List » Request: SecureTemplate access for forgotten protected functions

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