Thread Tools Display Modes
Unread 07-19-12, 04:59 AM   #1
ballagarba
A Fallenroot Satyr
 
ballagarba's Avatar
Join Date: Mar 2009
Posts: 22
StanceButton1 taint in nMainbar

So, Blizzard was kind enough introduce StanceButton1:SetPoint(...) inside StanceBar.lua:StanceBar_Update()

Code:
function StanceBar_Update ()
    local numForms = GetNumShapeshiftForms();
    if ( numForms > 0 and not IsPossessBarVisible()) then
        --Setup the Stance bar to display the appropriate number of slots
        if ( numForms == 1 ) then
                        StanceBarMiddle:Hide();
                        StanceBarRight:SetPoint("LEFT", "StanceBarLeft", "LEFT", 12, 0);
                        StanceButton1:SetPoint("BOTTOMLEFT", "StanceBarFrame", "BOTTOMLEFT", 12, 3);
        elseif ( numForms == 2 ) then
                        StanceBarMiddle:Hide();
                        StanceBarRight:SetPoint("LEFT", "StanceBarLeft", "RIGHT", 0, 0);
        else
            StanceBarMiddle:Show();
            StanceBarMiddle:SetPoint("LEFT", "StanceBarLeft", "RIGHT", 0, 0);
            StanceBarMiddle:SetWidth(37 * (numForms-2));
            StanceBarMiddle:SetTexCoord(0, numForms-2, 0, 1);
            StanceBarRight:SetPoint("LEFT", "StanceBarMiddle", "RIGHT", 0, 0);
        end

        StanceBarFrame:Show();
        StanceBar_UpdateState();
    else
        StanceBarFrame:Hide();
    end
    UIParent_ManageFramePositions();
end
The problem I'm having is that I set StanceButton1:SetMovable(true) and StanceButton1:SetUserPlaced(true). However, StanceBar_Update() gets executed after whatever code that does user placement rendering it useless.

So I tried a couple of hacks to prevent StanceBar_Update() from moving StanceButton1:

1. I just override Blizzard's function, however this obviously caused taint issues.

lua Code:
  1. function StanceBar_Update()
  2.     local numForms = GetNumShapeshiftForms()
  3.     if (numForms > 0 and not IsPossessBarVisible()) then
  4.         StanceBarFrame:Show()
  5.         securecall('StanceBar_UpdateState')
  6.     else
  7.         StanceBarFrame:Hide()
  8.     end
  9.     securecall('UIParent_ManageFramePositions')
  10. end

2. I figured I could force the statement numForms == 1 to always be false, because that's the only time they re-position. I figured this was a golden solution, however, it also caused taint

lua Code:
  1. StanceBarFrame.numForms = GetNumShapeshiftForms()

3. Now I tried to save the position of StanceButton1 before StanceBar_Update() moves it, and do a hooksecurefunc('StanceBar_Update', ...) and move it after that. Also taint, apparently, you can't do StanceButton1:ClearAllPoints() from inside that hook (WTF?):

lua Code:
  1. local point, relativeTo, relativePoint, xOffset, yOffset = StanceButton1:GetPoint()
  2. hooksecurefunc('StanceBar_Update', function()
  3.     if (GetNumShapeshiftForms() == 1) then
  4.         StanceButton1:ClearAllPoints()
  5.         StanceButton1:SetPoint(point, relativeTo, relativePoint, xOffset, yOffset)
  6.     end
  7. end

4. Next, I came up with the idea of just calling StanceBar_Update() immediately in my code to have it execute before the user position got set. This oddly enough also caused taint

lua Code:
  1. securecall('StanceBar_Update')

5. This works, but is ugly as hell and some quirks appear from time to time:

lua Code:
  1. local point, relativeTo, relativePoint, xOffset, yOffset
  2.  
  3. local f = CreateFrame('Frame')
  4. f:RegisterEvent('VARIABLES_LOADED')
  5. f:RegisterEvent('PLAYER_ALIVE')
  6. f:SetScript('OnEvent', function(self, event, ...)
  7.     if (event == 'VARIABLES_LOADED') then
  8.         point, relativeTo, relativePoint, xOffset, yOffset = StanceButton1:GetPoint()
  9.         self:UnregisterEvent('VARIABLES_LOADED')
  10.     end
  11.  
  12.     if (event == 'PLAYER_ALIVE') then
  13.         if (point) then
  14.             StanceButton1:ClearAllPoints()
  15.             StanceButton1:SetPoint(point, relativeTo, relativePoint, xOffset, yOffset)
  16.         end
  17.         self:UnregisterEvent('PLAYER_ALIVE')
  18.     end
  19. end)

The taint causes a interface blocked action thingie when trying to do action bar switching when in combat, and blocked it from switching. Anyone have any thoughts? I find it weird that StanceButton1:ClearAllPoints() sometimes causes taint, and sometimes it doesn't.

Oh yeah, the addon is nMainbar and here's the MoP source:
https://github.com/renstrom/NeavUI/b.../stancebar.lua.
ballagarba is offline  
Unread 07-19-12, 10:31 AM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,054
You didn't try using hooksecurefunc() by chance, did you?
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of Revelation, Spamalyzer, TravelAgent, Volumizer, and many other AddOns.
Torhal is offline  
Unread 07-19-12, 10:53 AM   #3
ballagarba
A Fallenroot Satyr
 
ballagarba's Avatar
Join Date: Mar 2009
Posts: 22
Originally Posted by Torhal View Post
You didn't try using hooksecurefunc() by chance, did you?
Yeah I did:

Originally Posted by ballagarba View Post
3. Now I tried to save the position of StanceButton1 before StanceBar_Update() moves it, and do a hooksecurefunc('StanceBar_Update', ...) and move it back. Also taints, apparently, you can't do StanceButton1:ClearAllPoints() from inside that hook (WTF?):

lua Code:
  1. local point, relativeTo, relativePoint, xOffset, yOffset = StanceButton1:GetPoint()
  2. hooksecurefunc('StanceBar_Update', function()
  3.     if (GetNumShapeshiftForms() == 1) then
  4.         StanceButton1:ClearAllPoints()
  5.         StanceButton1:SetPoint(point, relativeTo, relativePoint, xOffset, yOffset)
  6.     end
  7. end
However, I don't see how that would work seeing as when the hook runs I have no idea of knowing what StanceButton1 had for position before the original function (StanceBar_Update()) moved it. I could just move it, but the point is that I want it to be user placed, so I can't move it programmatically like that unless I could somehow fetch that information from layout-local.txt.
ballagarba is offline  
Unread 07-19-12, 12:13 PM   #4
Lombra
A Cobalt Mageweaver
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 232
Can you not move the entire StanceBar instead?
__________________
Grab your sword and fight the Horde!
Lombra is offline  
Unread 07-19-12, 12:45 PM   #5
ballagarba
A Fallenroot Satyr
 
ballagarba's Avatar
Join Date: Mar 2009
Posts: 22
Originally Posted by Lombra View Post
Can you not move the entire StanceBar instead?
Hmm, came up with this and it actually seems to work nicely

lua Code:
  1. if (GetNumShapeshiftForms() == 1) then
  2.     StanceBarFrame:SetMovable(true)
  3.     StanceBarFrame:SetUserPlaced(true)
  4.     StanceButton1:HookScript('OnDragStop', function(self)
  5.         local point, relativeTo, relativePoint, xOffset, yOffset = self:GetPoint()
  6.         StanceBarFrame:ClearAllPoints()
  7.         -- 12 and 3 is to offset for StanceButton1's relative position towards StanceBarFrame
  8.         StanceBarFrame:SetPoint(point, relativeTo, relativePoint, xOffset - 12, yOffset - 3)
  9.     end)
  10. end
ballagarba is offline  
Unread 07-20-12, 09:56 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,361
Will not work either. On bars with only one form the StanceButton1 will always reset. Thus you have to actually reparent the StanceBarFrame.

My full solution is here:
http://code.google.com/p/rothui/sour.../stancebar.lua

I have a new frame that the stancebar is reparented to. On unlocking a dragFrame will show up on a pretty high framelevel thus overlaying all the other frames. The drag event is delegated to the frame in the bottom thus the bottom frame will move.
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

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

Last edited by zork : 07-20-12 at 10:00 AM.
zork is online now  
Unread 07-20-12, 10:17 AM   #7
ballagarba
A Fallenroot Satyr
 
ballagarba's Avatar
Join Date: Mar 2009
Posts: 22
Originally Posted by zork View Post
Will not work either. On bars with only one form the StanceButton1 will always reset. Thus you have to actually reparent the StanceBarFrame.

My full solution is here:
http://code.google.com/p/rothui/sour.../stancebar.lua

I have a new frame that the stancebar is reparented to. On unlocking a dragFrame will show up on a pretty high framelevel thus overlaying all the other frames. The drag event is delegated to the frame in the bottom thus the bottom frame will move.
Well that's pretty much what I'm doing. As I've also said, this is only a problem when GetNumShapeshiftForms() == 1. Therefore I made StanceBarFrame movable as well, and when the user drags the StanceButton1 to whatever position they prefer, I update the StanceBarFrame position as well via HookScript('OnDragStop', ...) on StanceButton1 and off-setting with y and x values available in StanceBar_Update() (12 and 3 respectively).

Since Blizzard doesn't re-anchor StanceBarFrame like they do StanceButton1, when they run StanceBar_Update() it will just anchor StanceButton1 to whatever user position StanceBarFrame has.

Plus I can't have an overlay show up every time the user presses alt+shift (I'm not using slash commands).

Last edited by ballagarba : 07-20-12 at 10:20 AM.
ballagarba is offline  
Unread 07-29-12, 05:19 AM   #8
ballagarba
A Fallenroot Satyr
 
ballagarba's Avatar
Join Date: Mar 2009
Posts: 22
So it seems like as of build 15913 Blizzard is no longer moving the StanceButton1 inside the StanceBar_Update() function when GetNumShapeshiftForms() == 1

https://github.com/p3lim/wow-ui-sour...99afb4f7#L75L5
ballagarba is offline  
Unread 07-29-12, 05:25 AM   #9
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,361
... how nice.

I can confirm that. Updated my version of rActionBarStyler already.
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

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

Last edited by zork : 07-30-12 at 02:16 AM.
zork is online now  
 

Go BackWoWInterface » WoD Beta » MoP archived threads » StanceButton1 taint in nMainbar

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