WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Trying to move CompactRaidFrameManager (https://www.wowinterface.com/forums/showthread.php?t=48445)

Mayron 11-02-13 05:30 PM

Trying to move CompactRaidFrameManager
 
Hi and sorry if recently I have posted a lot. This is the last issue I have till my UI should be finished.

I want to move the CompactRaidFrameManager window on the left as its in the way of my chat box as I have it at the top left corner instead. To move it I used the following code:

Lua Code:
  1. function eventHandlers.PLAYER_ENTERING_WORLD()
  2.     if CompactRaidFrameManager:IsVisible() then
  3.         local point, relativeTo, relativePoint, xOfs, yOfs = CompactRaidFrameManager:GetPoint()
  4.         CompactRaidFrameManager:SetPoint(point, relativeTo, relativePoint, xOfs, -300)
  5.     end
  6. end
  7.  
  8.  
  9. CompactRaidFrameManagerToggleButton:HookScript("OnClick", function()
  10.     if CompactRaidFrameManager:IsVisible() then  
  11.         local point, relativeTo, relativePoint, xOfs, yOfs = CompactRaidFrameManager:GetPoint()
  12.         CompactRaidFrameManager:SetPoint(point, relativeTo, relativePoint, xOfs, -300)
  13.     end
  14. end)

This works however if you click the "CompactRaidFrameManagerToggleButton" Button while in combat it resets its position. I have been looking for a solution and found the code below but it doesn't do anything, most likely because I'm using it wrong and not sure what to do with it.

Lua Code:
  1. if CompactRaidFrameManager.collapsed then    
  2.         CompactRaidFrameManager:SetScript("OnUpdate", nil)
  3. end

Thought I might as well ask for help in case someone has encountered this issue before and knows a fix. Greatly appreciated! Thank you for reading :)

Mayron 11-03-13 05:04 AM

I've tried using hooksecurefunction and hook script to try to get this to work but it all comes down to the issue where I'm in combat and I use the CompactRaidFrameManager button which then resets its position. I got fed up with this and used an OnUpdate handler (the code below) but even this will not work while I'm in combat which does not make any sense to me. Surely this OnUpdate function should work regardless of whether I'm in combat or not and then Blizzard Compact Raid Frame Manager code seems to mention nothing at all about being in combat so no idea whats blocking it.

Lua Code:
  1. local e = 0
  2. local CompactOnUpdate = CreateFrame("Frame")
  3. CompactOnUpdate:SetScript('OnUpdate', function(self, elapsed)
  4.     e = e + elapsed
  5.     if e >= 2 then
  6.         if CompactRaidFrameManager:IsVisible() then
  7.         local point, relativeTo, relativePoint, xOfs, yOfs = CompactRaidFrameManager:GetPoint()
  8.         CompactRaidFrameManager:SetPoint(point, relativeTo, relativePoint, xOfs, -300)
  9.         end
  10.         e = 0
  11.     end
  12. end)

Mayron 11-03-13 07:04 PM

I've managed to get it to work while out of combat and I've just made it so that you cannot click the ToggleButton while in combat. That avoids it from moving location on its own. Very odd that I cannot alter it at all while in combat but will just have to settle for it.

Phanx 11-03-13 09:28 PM

Quote:

Originally Posted by Mayron (Post 286617)
Very odd that I cannot alter it at all while in combat ...

It's not odd at all. You cannot programmatically move (or show, hide, resize, etc.) secure frames while in combat.

Mayron 11-04-13 02:35 PM

Quote:

Originally Posted by Phanx (Post 286626)
It's not odd at all. You cannot programmatically move (or show, hide, resize, etc.) secure frames while in combat.

Ah okay, was trying to find out how the default compact raid frame manager does it in combat but couldn't but ah well :/

AnrDaemon 11-05-13 02:07 AM

Quote:

Originally Posted by Mayron (Post 286658)
Ah okay, was trying to find out how the default compact raid frame manager does it in combat but couldn't but ah well :/

The default (that is, Blizzard own) code is cheating. Simple as that.

Phanx 11-05-13 05:38 AM

Yep. Blizzard's code is not subject to the same restrictions as addons. That's why they can call CastSpellByName, even though addons have been forbidden from calling that function since TBC.

Resike 01-18-14 12:17 PM

I also have been playing this recently:

Lua Code:
  1. hooksecurefunc("CompactRaidFrameManager_Expand", function(self)
  2.     if MovAny:IsModified(self) then
  3.         MovAny:UnlockPoint(self)
  4.         local point, relativeTo, relativePoint, xOfs, yOfs = self:GetPoint(1)
  5.         self:ClearAllPoints()
  6.         self:SetPoint("TOPLEFT", UIParent, "TOPLEFT", xOfs + 175, yOfs)
  7.         MovAny:LockPoint(self)
  8.     end
  9. end)
  10. hooksecurefunc("CompactRaidFrameManager_Collapse", function(self)
  11.     if MovAny:IsModified(self) then
  12.         MovAny:UnlockPoint(self)
  13.         local point, relativeTo, relativePoint, xOfs, yOfs = self:GetPoint(1)
  14.         self:ClearAllPoints()
  15.         self:SetPoint("TOPLEFT", UIParent, "TOPLEFT", xOfs - 175, yOfs)
  16.         MovAny:LockPoint(self)
  17.     end
  18. end)
  19. -- Before you hide it to keep the raidframes:
  20. if fn == "CompactRaidFrameManager" then
  21.     if InCombatLockdown() or UnitAffectingCombat("player") then
  22.         return
  23.     end
  24.     f:UnregisterAllEvents()
  25.     CompactRaidFrameContainer:SetParent(UIParent)
  26. end
  27. -- Before you reshow it, reparent and repoint raidframe to it:
  28. if fn == "CompactRaidFrameManager" then
  29.     if InCombatLockdown() or UnitAffectingCombat("player") then
  30.         return
  31.     end
  32.     f:RegisterEvent("DISPLAY_SIZE_CHANGED")
  33.     f:RegisterEvent("UI_SCALE_CHANGED")
  34.     f:RegisterEvent("GROUP_ROSTER_UPDATE")
  35.     f:RegisterEvent("UNIT_FLAGS")
  36.     f:RegisterEvent("PLAYER_FLAGS_CHANGED")
  37.     f:RegisterEvent("PLAYER_ENTERING_WORLD")
  38.     f:RegisterEvent("PARTY_LEADER_CHANGED")
  39.     f:RegisterEvent("RAID_TARGET_UPDATE")
  40.     f:RegisterEvent("PLAYER_TARGET_CHANGED")
  41.     CompactRaidFrameContainer:ClearAllPoints()
  42.     CompactRaidFrameContainer:SetParent(f)
  43.     MovAny:UnlockPoint(CompactRaidFrameContainer)
  44.     CompactRaidFrameContainer:SetPoint("TOPLEFT", CompactRaidFrameManagerContainerResizeFrame, "TOPLEFT", 4, - 7)
  45. end
  46.  
  47. function MovAny:UnlockPoint(f)
  48.     f.MAPoint = nil
  49. end
  50.  
  51. function MovAny:LockPoint(f, opt)
  52.     if not f.MAPoint then
  53.         if f:GetName() and (MovAny.lForcedLock[f:GetName()] or (opt and opt.forcedLock))  then
  54.             if not f.MASetPoint then
  55.                 f.MASetPoint = f.SetPoint
  56.                 f.SetPoint = MovAny.fVoid
  57.             end
  58.         else
  59.             if not f.MALockPointHook then
  60.                 hooksecurefunc(f, "SetPoint", MovAny.hSetPoint)
  61.                 f.MALockPointHook = true
  62.             end
  63.             f.MAPoint = {f:GetPoint(1)}
  64.         end
  65.     end
  66. end
  67.  
  68. fVoid = function() end

"MovAny:IsModified(self)" determines if the frame's position is modified or it's in the default position.

The moving functions should not be a problem, just don't let it move it in combat.

The advantage of this, when you move the Manager to another position the toggle panel button will work perfectly on that spot too.

Railander 10-19-23 02:42 PM

long-standing issue, with the crumbs from this thread and DejaPRFader i've managed to consolidate the functionality.
for anyone interested, here it is.
https://legacy.curseforge.com/wow/ad...idframemanager

source code for people just wanting a quick understanding for their own implementations:

Lua Code:
  1. -- ingame instructions
  2. local enterColor = "|cFF"
  3. local exitColor = "|r"
  4. local colorOrange = "DF9F1F"
  5. local colorRed = "FF3F1F"
  6. local function MoveCRFM_instructions()
  7.     print(enterColor .. colorOrange .. "Use /movecrfm followed by either the Y coordinate, or whether to fade it out on mouseover, or frame strata 1-8 (ascending priority)." .. exitColor)
  8.     print(enterColor .. colorOrange .. "Example: " .. exitColor .. "/movecrfm -234.5")
  9.     print(enterColor .. colorOrange .. "Example: " .. exitColor .. "/movecrfm yes")
  10.     print(enterColor .. colorOrange .. "Example: " .. exitColor .. "/movecrfm strata 6")
  11. end
  12.  
  13. -- strata database/array
  14. local MoveCRFM_stratas = {
  15.     [1] = "BACKGROUND",
  16.     [2] = "LOW",
  17.     [3] = "MEDIUM",
  18.     [4] = "HIGH",
  19.     [5] = "DIALOG",
  20.     [6] = "FULLSCREEN",
  21.     [7] = "FULLSCREEN_DIALOG",
  22.     [8] = "TOOLTIP",
  23. }
  24.  
  25. -- main functionality
  26. local function MoveCRFM_move()
  27.     local anchorMyselfAt, anchorTo, anchorToAt, coordX, coordY = CompactRaidFrameManager:GetPoint()
  28.     CompactRaidFrameManager:SetPoint(anchorMyselfAt, anchorTo, anchorToAt, coordX, Move_CompactRaidFrameManager.y)
  29. end
  30. local function MoveCRFM_fade()
  31.     if not Move_CompactRaidFrameManager or not Move_CompactRaidFrameManager.fade then
  32.         CompactRaidFrameManager:SetAlpha(1)
  33.     elseif CompactRaidFrameManager:IsMouseOver() or not CompactRaidFrameManager.collapsed then
  34.         CompactRaidFrameManager:SetAlpha(1)
  35.     else
  36.         CompactRaidFrameManager:SetAlpha(0)
  37.     end
  38. end
  39. local function MoveCRFM_strata()
  40.     CompactRaidFrameManager:SetFrameStrata(MoveCRFM_stratas[Move_CompactRaidFrameManager.strata])
  41. end
  42. local function MoveCRFM_set()
  43.     MoveCRFM_move()
  44.     MoveCRFM_fade()
  45.     MoveCRFM_strata()
  46. end
  47.  
  48. -- persist through sessions functionality
  49. local function MoveCRFM_loaded(self, event, arg1)
  50.     if event == "ADDON_LOADED" and arg1 == "Move_CompactRaidFrameManager" then
  51.         if not Move_CompactRaidFrameManager then
  52.             MoveCRFM_instructions()
  53.             Move_CompactRaidFrameManager = {
  54.                 y = -100,
  55.                 fade = false,
  56.                 strata = 4,
  57.             }
  58.         end
  59.         MoveCRFM_set()
  60.         -- append ourselves into blizzard's frames
  61.         hooksecurefunc("CompactRaidFrameManager_Toggle", function()
  62.             MoveCRFM_move()
  63.             MoveCRFM_fade()
  64.         end)
  65.     end
  66. end
  67.  
  68. -- event triggers
  69. local MoveCRFM = CreateFrame("Frame")
  70. MoveCRFM:RegisterEvent("ADDON_LOADED")
  71. MoveCRFM:SetScript("OnEvent", MoveCRFM_loaded)
  72. CompactRaidFrameManager:HookScript("OnShow", MoveCRFM_fade)
  73. CompactRaidFrameManager:HookScript("OnEnter", MoveCRFM_fade)
  74. CompactRaidFrameManager:HookScript("OnLeave", MoveCRFM_fade)
  75.  
  76. -- slash command functionality
  77. SLASH_MOVECRFM1 = "/movecrfm"
  78. function SlashCmdList.MOVECRFM(msg, editbox)
  79.     local msgY = tonumber(string.match(msg, "^(-?%d+\.?%d?)$")) or nil
  80.     local msgFade = (string.match(string.lower(msg), "^yes$") or string.match(string.lower(msg), "^no$")) or nil
  81.     local msgStrata = tonumber(string.match(string.lower(msg), "^strata ([1-8])$")) or nil
  82.     if msgY then
  83.         Move_CompactRaidFrameManager.y = msgY
  84.         MoveCRFM_move()
  85.     elseif msgFade then
  86.         if msgFade == "yes" then
  87.             Move_CompactRaidFrameManager.fade = true
  88.         else
  89.             Move_CompactRaidFrameManager.fade = false
  90.         end
  91.         MoveCRFM_fade()
  92.     elseif msgStrata then
  93.         Move_CompactRaidFrameManager.strata = msgStrata
  94.         MoveCRFM_strata()
  95.     else
  96.         print(enterColor .. colorRed .. "Incorrect usage of " .. exitColor .. "/movecrfm")
  97.         MoveCRFM_instructions()
  98.     end
  99. end


All times are GMT -6. The time now is 04:06 PM.

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