View Single Post
10-19-23, 02:42 PM   #9
Railander
A Kobold Labourer
Join Date: Oct 2023
Posts: 1
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

Last edited by Railander : 10-19-23 at 02:44 PM. Reason: lua highlight
  Reply With Quote