WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Objective Tracker (https://www.wowinterface.com/forums/showthread.php?t=52366)

gempir 06-13-15 08:38 AM

Objective Tracker
 
So Zork wrote a cool addon "rObjectiveTrackerMover"

The problem is me and another guy are having a bug where the ObjectiveTracker jumps in combat around. Weirdly, its not in every combat, I feel like its random, I couldn't figure how I recreate the problem.

Zork said he had problems before, he said it was fixed but the Issue is still sometimes occurring so I wanted to ask this smart forum.

This is basicly the important part of the code, I think

Lua Code:
  1. local function AdjustSetPoint(self,...)
  2.     local a1,af,a2,x,y = ...
  3.     if a1 and af == "MinimapCluster" and y ~= cfg.y then
  4.       if InCombatLockdown() then
  5.         self:SetPoint(a1,af,a2,x,cfg.y)
  6.       else
  7.         frame.point = {a1,af,a2,x,cfg.y}
  8.         frame:RegisterEvent("PLAYER_REGEN_ENABLED")
  9.       end
  10.     end
  11.   end
  12.  
  13.   frame:SetScript("OnEvent", function(self,event)
  14.     self:UnregisterEvent(event)
  15.     if event == "PLAYER_LOGIN" then
  16.       self.point = {ObjectiveTrackerFrame:GetPoint()}
  17.       hooksecurefunc(ObjectiveTrackerFrame, "SetPoint", AdjustSetPoint)
  18.     end
  19.     if InCombatLockdown() then
  20.       ObjectiveTrackerFrame:SetPoint(unpack(self.point))
  21.     end
  22.   end)


I think the problem is something with "If InCombatLockdown()" so my question is, how do I fix this bug of the ObjectiveTracker moving back to its position in Combat.

Clamsoda 06-13-15 09:42 AM

Lua Code:
  1. local function noop() end
  2.  
  3. ObjectiveTrackerFrame:ClearAllPoints()
  4. ObjectiveTrackerFrame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, -300)
  5. ObjectiveTrackerFrame.ClearAllPoints = noop
  6. ObjectiveTrackerFrame.SetPoint       = noop
  7. ObjectiveTrackerFrame:SetHeight(500)

This is the code I have been using to relocate my objective tracker. No need for any events or anything; ObjectiveTrackerFrame exists at file scope; furthermore I haven't had ANY issues with taint via setting ClearAllPoints and SetPoint to a dummy function.

Obviously you are interested in the SetPoint line that has position arguments.

Resike 06-13-15 11:58 AM

I would not suggest to use either of the code. The first one simply doesn't handle the SetPoint hooks, which happens when boss or arena frames appera, or when you enable/disable the Blizzard side bars. The second one is a taint hazzard.

Try this code:

Lua Code:
  1. local moving
  2. hooksecurefunc(ObjectiveTrackerFrame, "SetPoint", function(self)
  3.     if moving then
  4.         return
  5.     end
  6.     moving = true
  7.     self:SetMovable(true)
  8.     self:SetUserPlaced(true)
  9.     self:ClearAllPoints()
  10.     self:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  11.     self:SetScale(1.1) -- optional
  12.     self:SetWidth(300) -- optional
  13.     self:SetHeight(400) -- optional
  14.     self:SetMovable(false)
  15.     moving = nil
  16. end)

Also keep that in mind if the original parent of the frame aka the "MinimapCluster" is not in it's original position, then the client won't be able to bypass secure code for it's children frame aka the "ObjectiveTrackerFrame" and you won't be able to click on the quest items on the frame.

The only solution is that to reset the "MinimapCluster", or to use another 3rd party Minimap addon, which you can reposition securely/properly.

gempir 06-13-15 12:19 PM

How far is the 2nd code from Clamsoda a taint hazzard?

The Quests are clickable and the quest tracker has the correct position

Seerah 06-13-15 02:08 PM

You're calling :SetPoint() in your :SetPoint() hook, Resike. That'll make an infinite loop.

In WFWW, I create a container frame, parent the objective tracker to that, and move/size the container. Then I do this, to avoid the recursive :SetPoint call...
Lua Code:
  1. local cap = ObjectiveTrackerFrame.ClearAllPoints
  2.     local sp = ObjectiveTrackerFrame.SetPoint
  3.     hooksecurefunc(ObjectiveTrackerFrame, "SetPoint", function(self)
  4.         cap(self)
  5.         sp(self, "TOPLEFT", 30, -10)
  6.     end)

Resike 06-13-15 02:11 PM

Quote:

Originally Posted by Seerah (Post 309124)
You're calling :SetPoint() in your :SetPoint() hook, Resike. That'll make an infinite loop.

In WFWW, I create a container frame, parent the objective tracker to that, and move/size the container. Then I do this, to avoid the recursive :SetPoint call...
Lua Code:
  1. local cap = ObjectiveTrackerFrame.ClearAllPoints
  2.     local sp = ObjectiveTrackerFrame.SetPoint
  3.     hooksecurefunc(ObjectiveTrackerFrame, "SetPoint", function(self)
  4.         cap(self)
  5.         sp(self, "TOPLEFT", 30, -10)
  6.     end)

It's not infinite because of the moving variable.

Resike 06-13-15 02:17 PM

Quote:

Originally Posted by gempir (Post 309123)
How far is the 2nd code from Clamsoda a taint hazzard?

The Quests are clickable and the quest tracker has the correct position

There is nothing wrong with it, but it could potentionally spread taint for other addons. Also it's not the best method to permanently kill a function, since you can't really restore it only by deleting the code itself.

Seerah 06-13-15 03:07 PM

Quote:

Originally Posted by Resike (Post 309125)
It's not infinite because of the moving variable.

Bah, I guess my eyes glazed over for that bit. ><


All times are GMT -6. The time now is 01:00 AM.

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