Advertisement
Guest User

Moveanything 8.2.5 fix

a guest
Oct 3rd, 2019
2,940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 170.24 KB | None | 0 0
  1. --[[
  2. MoveAnything by Wagthaa @ Earthen Ring EU
  3. MoP version: Resike
  4. FanUpdate by Alea @ Gordynni EU
  5. Vanilla & TBC versions by: Skrag, Jason, Vincent
  6. ]]
  7.  
  8. local _G = _G
  9. local format = format
  10. local getmetatable = getmetatable
  11. local hooksecurefunc = hooksecurefunc
  12. local ipairs = ipairs
  13. local math = math
  14. local pairs = pairs
  15. local print = print
  16. local select = select
  17. local setmetatable = setmetatable
  18. local string = string
  19. local table = table
  20. local time = time
  21. local tinsert = tinsert
  22. local tonumber = tonumber
  23. local tostring = tostring
  24. local tremove = tremove
  25. local type = type
  26. local unpack = unpack
  27. local xpcall = xpcall
  28.  
  29. local CreateFrame = CreateFrame
  30. local GetAddOnMetadata = GetAddOnMetadata
  31. local GetCVar = GetCVar
  32. local GetMouseFocus = GetMouseFocus
  33. local GetRealmName = GetRealmName
  34. local GetScreenHeight = GetScreenHeight
  35. local GetScreenWidth = GetScreenWidth
  36. local InCombatLockdown = InCombatLockdown
  37. local IsAddOnLoaded = IsAddOnLoaded
  38. local IsAltKeyDown = IsAltKeyDown
  39. local IsInInstance = IsInInstance
  40. local IsShiftKeyDown = IsShiftKeyDown
  41. local PlaySound = PlaySound
  42. local RegisterStateDriver = RegisterStateDriver
  43. local UnitName = UnitName
  44.  
  45. local UIParent = UIParent
  46.  
  47. local MOVANY = _G.MOVANY
  48. local MAOptions
  49.  
  50. function MA_tdeepcopy(object)
  51. local lookup_table = { }
  52. local function _copy(object)
  53. if type(object) ~= "table" then
  54. return object
  55. elseif lookup_table[object] then
  56. return lookup_table[object]
  57. end
  58. local new_table = { }
  59. lookup_table[object] = new_table
  60. for index, value in pairs(object) do
  61. new_table[_copy(index)] = _copy(value)
  62. end
  63. return setmetatable(new_table, getmetatable(object))
  64. end
  65. return _copy(object)
  66. end
  67.  
  68. function MA_tcopy(object)
  69. if type(object) ~= "table" then
  70. return object
  71. end
  72. local new_table = { }
  73. for index, value in pairs(object) do
  74. new_table[index] = value
  75. end
  76. return setmetatable(new_table, getmetatable(object))
  77. end
  78.  
  79. local function tlen(t)
  80. local i = 0
  81. if t ~= nil then
  82. for k in pairs(t) do
  83. i = i + 1
  84. end
  85. end
  86. return i
  87. end
  88.  
  89. local API
  90.  
  91. MADB = {
  92. tooltips = true,
  93. characters = { },
  94. profiles = { },
  95. }
  96.  
  97. local MovAny = {
  98. fVoid = function() end,
  99. guiLines = - 1,
  100. resetConfirm = "",
  101. bagFrames = { },
  102. cats = { },
  103. collapsed = true,
  104. defFrames = { },
  105. frames = { },
  106. framesCount = 0,
  107. framesIdx = { },
  108. initRun = nil,
  109. lastFrameName = nil,
  110. lSafeRelatives = { },
  111. lAllowedTypes = {
  112. ["Frame"] = true,
  113. ["FontString"] = true,
  114. ["Texture"] = true,
  115. ["Button"] = true,
  116. ["CheckButton"] = true,
  117. ["StatusBar"] = true,
  118. ["GameTooltip"] = true,
  119. ["MessageFrame"] = true,
  120. ["PlayerModel"] = true,
  121. ["ColorSelect"] = true,
  122. ["EditBox"] = true,
  123. ["ScrollingMessageFrame"] = true,
  124. ["Slider"] = true,
  125. ["Minimap"] = true
  126. },
  127. lDisallowedFrames = {
  128. ["UIParent"] = true,
  129. ["WorldFrame"] = true,
  130. ["CinematicFrame"] = true,
  131. ["ArenaPrepFrames"] = true,
  132. --["ArenaEnemyFrames"] = true,
  133. ["PetBattleFrame"] = true,
  134. ["StoreFrame"] = true
  135. },
  136. lCreateVMs = {
  137. "BagFrame1",
  138. "BagFrame2",
  139. "BagFrame3",
  140. "BagFrame4",
  141. "BagFrame5",
  142. },
  143. lForceProtected = {
  144. ["ArenaPrepFrames"] = true,
  145. ["ArenaEnemyFrames"] = true,
  146. ["WorldStateAlwaysUpFrame"] = true,
  147. ["AlwaysUpFrame1"] = true,
  148. ["AlwaysUpFrame2"] = true,
  149. ["AlwaysUpFrame3"] = true,
  150. ["CompactRaidFrameManager"] = true,
  151. },
  152. lForceForbidden = {
  153. ["NamePlateTooltip"] = true,
  154. },
  155. lForcedLock = {
  156. ["Boss1TargetFrame"] = true,
  157. ["Boss2TargetFrame"] = true,
  158. ["Boss3TargetFrame"] = true,
  159. ["Boss4TargetFrame"] = true,
  160. ["Boss5TargetFrame"] = true,
  161. ["ActionButton1"] = true,
  162. --[[["ArenaEnemyFrame1"] = true,
  163. ["ArenaEnemyFrame2"] = true,
  164. ["ArenaEnemyFrame3"] = true,
  165. ["ArenaEnemyFrame4"] = true,
  166. ["ArenaEnemyFrame5"] = true,
  167. ["ArenaPrepFrame1"] = true,
  168. ["ArenaPrepFrame2"] = true,
  169. ["ArenaPrepFrame3"] = true,
  170. ["ArenaPrepFrame4"] = true,
  171. ["ArenaPrepFrame5"] = true,
  172. ["ArenaPrepFrames"] = true,
  173. ["ArenaEnemyFrames"] = true,
  174. ["ArenaEnemyFrame1PetFrame"] = true,
  175. ["ArenaEnemyFrame2PetFrame"] = true,
  176. ["ArenaEnemyFrame3PetFrame"] = true,
  177. ["ArenaEnemyFrame4PetFrame"] = true,
  178. ["ArenaEnemyFrame5PetFrame"] = true,--]]
  179. ["PetFrame"] = true,
  180. --["BuffFrame"] = true,
  181. ["MinimapCluster"] = true,
  182. ["WorldStateAlwaysUpFrame"] = true,
  183. ["AlwaysUpFrame1"] = true,
  184. ["AlwaysUpFrame2"] = true,
  185. ["AlwaysUpFrame3"] = true,
  186. ["TargetBuffsMover"] = true,
  187. ["TargetDebuffsMover"] = true,
  188. ["TargetFrameToTDebuffsMover"] = true,
  189. ["FocusBuffsMover"] = true,
  190. ["FocusDebuffsMover"] = true,
  191. ["FocusFrameToTDebuffsMover"] = true,
  192. --["TargetFrameBuff1"] = true,
  193. --["TargetFrameDebuff1"] = true,
  194. },
  195. lEnableMouse = {
  196. ObjectiveTrackerFrameMover,
  197. ObjectiveTrackerFrameScaleMover,
  198. DurabilityFrame,
  199. CastingBarFrame,
  200. WorldStateScoreFrame,
  201. WorldStateAlwaysUpFrame,
  202. AlwaysUpFrame1,
  203. AlwaysUpFrame2,
  204. AlwaysUpFrame3,
  205. WorldStateCaptureBar1,
  206. VehicleMenuBar,
  207. TargetFrameSpellBar,
  208. FocusFrameSpellBar,
  209. MirrorTimer1,
  210. MiniMapInstanceDifficulty,
  211. VoidStorageFrame,
  212. ComboPointPlayerFrame,
  213. RuneFrame,
  214. MageArcaneChargesFrame,
  215. PaladinPowerBarFrame,
  216. WarlockPowerFrame,
  217. MonkHarmonyBarFrame,
  218. MonkStaggerBar,
  219. },
  220. lTranslate = {
  221. minimap = "MinimapCluster",
  222. tooltip = "TooltipMover",
  223. player = "PlayerFrame",
  224. target = "TargetFrame",
  225. tot = "TargetFrameToT",
  226. targetoftarget = "TargetFrameToT",
  227. pet = "PetFrame",
  228. focus = "FocusFrame",
  229. bags = "BagButtonsMover",
  230. --keyring = "KeyRingFrame",
  231. castbar = "CastingBarFrame",
  232. buffs = "PlayerBuffsMover",
  233. debuffs = "PlayerDebuffsMover",
  234. GameTooltip = "TooltipMover",
  235. StanceBarFrame = "StanceButtonsMover",
  236. TemporaryEnchantFrame = "PlayerBuffsMover",
  237. TempEnchant1 = "PlayerBuffsMover",
  238. ConsolidatedBuffs = "PlayerBuffsMover",
  239. BuffFrame = "PlayerBuffsMover",
  240. Minimap = "MinimapCluster",
  241. Boss = "PlayerPowerBarAltMover",
  242. },
  243. lTranslateSec = {
  244. BuffFrame = "PlayerBuffsMover",
  245. ConsolidatedBuffFrame = "PlayerBuffsMover",
  246. --[[ChatFrame1EditBox = "ChatEditBoxesMover",
  247. ChatFrame2EditBox = "ChatEditBoxesMover",
  248. ChatFrame3EditBox = "ChatEditBoxesMover",
  249. ChatFrame4EditBox = "ChatEditBoxesMover",
  250. ChatFrame5EditBox = "ChatEditBoxesMover",
  251. ChatFrame6EditBox = "ChatEditBoxesMover",
  252. ChatFrame7EditBox = "ChatEditBoxesMover",
  253. ChatFrame8EditBox = "ChatEditBoxesMover",
  254. ChatFrame9EditBox = "ChatEditBoxesMover",
  255. ChatFrame10EditBox = "ChatEditBoxesMover",]]
  256. },
  257. lTransContainerToBag = {
  258. ContainerFrame1 = "BagFrame1",
  259. ContainerFrame2 = "BagFrame2",
  260. ContainerFrame3 = "BagFrame3",
  261. ContainerFrame4 = "BagFrame4",
  262. ContainerFrame5 = "BagFrame5",
  263. ContainerFrame6 = "BankBagFrame1",
  264. ContainerFrame7 = "BankBagFrame2",
  265. ContainerFrame8 = "BankBagFrame3",
  266. ContainerFrame9 = "BankBagFrame4",
  267. ContainerFrame10 = "BankBagFrame5",
  268. ContainerFrame11 = "BankBagFrame6",
  269. ContainerFrame12 = "BankBagFrame7",
  270. --ContainerFrame13 = "KeyRingFrame",
  271. },
  272. lFrameNameRewrites = {
  273. --CompactRaidFrameContainer = "RaidUnitFramesMover",
  274. --CompactRaidFrameManager = "RaidUnitFramesManagerMover",
  275. TargetOfFocusDebuffsMover = "FocusFrameToTDebuffsMover",
  276. },
  277. lDeleteFrameNames = {
  278. BuffFrame = "BuffFrame",
  279. ConsolidatedBuffFrame = "ConsolidatedBuffFrame",
  280. TemporaryEnchantFrame = "TemporaryEnchantFrame",
  281. },
  282. rendered = nil,
  283. nextFrameIdx = 1,
  284. pendingActions = { },
  285. pendingFrames = { },
  286. pendingMovers = { },
  287. minimizedMovers = { },
  288. SCROLL_HEIGHT = 24,
  289. currentMover = nil,
  290. moverPrefix = "MAMover",
  291. moverNextId = 1,
  292. movers = { },
  293. frameEditors = { },
  294. DDMPointList = {
  295. {"Top Left", "TOPLEFT"},
  296. {"Top", "TOP"},
  297. {"Top Right", "TOPRIGHT"},
  298. {"Left", "LEFT"},
  299. {"Center", "CENTER"},
  300. {"Right", "RIGHT"},
  301. {"Bottom Left", "BOTTOMLEFT"},
  302. {"Bottom", "BOTTOM"},
  303. {"Bottom Right", "BOTTOMRIGHT"},
  304. },
  305. DDMStrataList = {
  306. {"Background", "BACKGROUND"},
  307. {"Low", "LOW"},
  308. {"Medium", "MEDIUM"},
  309. {"High", "HIGH"},
  310. {"Dialog", "DIALOG"},
  311. {"Fullscreen", "FULLSCREEN"},
  312. {"Fullscreen Dialog", "FULLSCREEN_DIALOG"},
  313. {"Tooltip", "TOOLTIP"},
  314. },
  315. DetachFromParent = {
  316. --MainMenuBarPerformanceBarFrame = "UIParent",
  317. TargetofFocusFrame = "UIParent",
  318. PetFrame = "UIParent",
  319. PartyMemberFrame1PetFrame = "UIParent",
  320. PartyMemberFrame2PetFrame = "UIParent",
  321. PartyMemberFrame3PetFrame = "UIParent",
  322. PartyMemberFrame4PetFrame = "UIParent",
  323. DebuffButton1 = "UIParent",
  324. ReputationWatchBar = "UIParent",
  325. --MainMenuExpBar = "UIParent",
  326. TimeManagerClockButton = "UIParent",
  327. OverrideMenuBarHealthBar = "UIParent",
  328. OverrideMenuBarLeaveButton = "UIParent",
  329. OverrideMenuBarPowerBar = "UIParent",
  330. MultiCastActionBarFrame = "UIParent",
  331. --MainMenuBarRightEndCap = "UIParent",
  332. --MainMenuBarMaxLevelBar = "UIParent",
  333. TargetFrameSpellBar = "UIParent",
  334. FocusFrameSpellBar = "UIParent",
  335. MultiBarBottomLeft = "UIParent",
  336. MANudger = "UIParent",
  337. MultiBarBottomRight = "UIParent",
  338. MultiBarBottomLeft = "UIParent",
  339. PlayerDebuffsMover = "UIParent",
  340. TotemFrame = "UIParent",
  341. Boss1TargetFrame = "UIParent",
  342. Boss2TargetFrame = "UIParent",
  343. Boss3TargetFrame = "UIParent",
  344. Boss4TargetFrame = "UIParent",
  345. Boss5TargetFrame = "UIParent",
  346. RuneFrame = "UIParent",
  347. --ArenaEnemyFrame1 = "UIParent",
  348. },
  349. NoReparent = {
  350. TargetFrameSpellBar = "TargetFrameSpellBar",
  351. FocusFrameSpellBar = "FocusFrameSpellBar",
  352. OverrideMenuBarHealthBar = "OverrideMenuBarHealthBar",
  353. OverrideMenuBarLeaveButton = "OverrideMenuBarLeaveButton",
  354. OverrideMenuBarPowerBar = "OverrideMenuBarPowerBar",
  355. ArenaPrepFrames = "ArenaPrepFrames",
  356. --ArenaEnemyFrames = "ArenaEnemyFrames",
  357. MinimapCluster = "MinimapCluster",
  358. ObjectiveTrackerFrameMover = "ObjectiveTrackerFrameMover",
  359. ObjectiveTrackerFrameScaleMover = "ObjectiveTrackerFrameScaleMover",
  360. },
  361. NoUnanchoring = {
  362. BuffFrame = "BuffFrame",
  363. RuneFrame = "RuneFrame",
  364. TotemFrame = "TotemFrame",
  365. ComboFrame = "ComboFrame",
  366. MANudger = "MANudger",
  367. TimeManagerClockButton = "TimeManagerClockButton",
  368. PartyMember1DebuffsMover = "PartyMember1DebuffsMover",
  369. PartyMember2DebuffsMover = "PartyMember2DebuffsMover",
  370. PartyMember3DebuffsMover = "PartyMember3DebuffsMover",
  371. PartyMember4DebuffsMover = "PartyMember4DebuffsMover",
  372. PetDebuffsMover = "PetDebuffsMover",
  373. TargetBuffsMover = "TargetBuffsMover",
  374. TargetDebuffsMover = "TargetDebuffsMover",
  375. FocusBuffsMover = "FocusBuffsMover",
  376. FocusDebuffsMover = "FocusDebuffsMover",
  377. TargetFrameToTDebuffsMover = "TargetFrameToTDebuffsMover",
  378. FocusFrameToTDebuffsMover = "FocusFrameToTDebuffsMover",
  379. TemporaryEnchantFrame = "TemporaryEnchantFrame",
  380. AuctionDressUpFrame = "AuctionDressUpFrame",
  381. MinimapCluster = "MinimapCluster",
  382. --[[ArenaEnemyFrame1PetFrame = "ArenaEnemyFrame1PetFrame",
  383. ArenaEnemyFrame2PetFrame = "ArenaEnemyFrame2PetFrame",
  384. ArenaEnemyFrame3PetFrame = "ArenaEnemyFrame3PetFrame",
  385. ArenaEnemyFrame4PetFrame = "ArenaEnemyFrame4PetFrame",
  386. ArenaEnemyFrame5PetFrame = "ArenaEnemyFrame5PetFrame",
  387. ArenaEnemyFrame1CastingBar = "ArenaEnemyFrame1CastingBar",
  388. ArenaEnemyFrame2CastingBar = "ArenaEnemyFrame2CastingBar",
  389. ArenaEnemyFrame3CastingBar = "ArenaEnemyFrame3CastingBar",
  390. ArenaEnemyFrame4CastingBar = "ArenaEnemyFrame4CastingBar",
  391. ArenaEnemyFrame5CastingBar = "ArenaEnemyFrame5CastingBar",--]]
  392. },
  393. lAllowedMAFrames = {
  394. MAOptions = "MAOptions",
  395. MANudger = "MANudger",
  396. MAPortDialog = "MAPortDialog",
  397. GameMenuButtonMoveAnything = "GameMenuButtonMoveAnything",
  398. --MACompactRaidFrameManagerToggleButton = "MACompactRaidFrameManagerToggleButton",
  399. --MA_FEMover = "MA_FEMover",
  400. },
  401. CONTAINER_FRAME_TABLE = {
  402. [0] = {"Interface\\ContainerFrame\\UI-BackpackBackground", 256, 256, 239},
  403. [1] = {"Interface\\ContainerFrame\\UI-Bag-1x4", 256, 128, 96},
  404. [2] = {"Interface\\ContainerFrame\\UI-Bag-1x4", 256, 128, 96},
  405. [3] = {"Interface\\ContainerFrame\\UI-Bag-1x4", 256, 128, 96},
  406. [4] = {"Interface\\ContainerFrame\\UI-Bag-1x4", 256, 128, 96},
  407. [5] = {"Interface\\ContainerFrame\\UI-Bag-1x4+2", 256, 128, 116},
  408. [6] = {"Interface\\ContainerFrame\\UI-Bag-1x4+2", 256, 128, 116},
  409. [7] = {"Interface\\ContainerFrame\\UI-Bag-1x4+2", 256, 128, 116},
  410. [8] = {"Interface\\ContainerFrame\\UI-Bag-2x4", 256, 256, 137},
  411. [9] = {"Interface\\ContainerFrame\\UI-Bag-2x4+2", 256, 256, 157},
  412. [10] = {"Interface\\ContainerFrame\\UI-Bag-2x4+2", 256, 256, 157},
  413. [11] = {"Interface\\ContainerFrame\\UI-Bag-2x4+2", 256, 256, 157},
  414. [12] = {"Interface\\ContainerFrame\\UI-Bag-3x4", 256, 256, 178},
  415. [13] = {"Interface\\ContainerFrame\\UI-Bag-3x4+2", 256, 256, 198},
  416. [14] = {"Interface\\ContainerFrame\\UI-Bag-3x4+2", 256, 256, 198},
  417. [15] = {"Interface\\ContainerFrame\\UI-Bag-3x4+2", 256, 256, 198},
  418. [16] = {"Interface\\ContainerFrame\\UI-Bag-4x4", 256, 256, 219},
  419. [18] = {"Interface\\ContainerFrame\\UI-Bag-4x4+2", 256, 256, 239},
  420. [20] = {"Interface\\ContainerFrame\\UI-Bag-5x4", 256, 256, 259},
  421. [22] = {"Interface\\ContainerFrame\\UI-Bag-5x4+2", 256, 256, 279},
  422. [24] = {"Interface\\ContainerFrame\\UI-Bag-5x5", 256, 256, 299},
  423. [26] = {"Interface\\ContainerFrame\\UI-Bag-5x5+2", 256, 256, 319},
  424. [28] = {"Interface\\ContainerFrame\\UI-Bag-5x6", 256, 256, 339},
  425. [30] = {"Interface\\ContainerFrame\\UI-Bag-5x6+2", 256, 256, 359},
  426. [32] = {"Interface\\ContainerFrame\\UI-Bag-5x7", 256, 256, 379},
  427. [34] = {"Interface\\ContainerFrame\\UI-Bag-5x7+2", 256, 256, 399},
  428. [36] = {"Interface\\ContainerFrame\\UI-Bag-5x8", 256, 256, 419},
  429. [38] = {"Interface\\ContainerFrame\\UI-Bag-5x8+2", 256, 256, 439},
  430. [40] = {"Interface\\ContainerFrame\\UI-Bag-5x9", 256, 256, 459},
  431. },
  432. -- X: hook replacements
  433. ContainerFrame_GenerateFrame = function(frame, size, id)
  434. MovAny:GrabContainerFrame(frame, MovAny:GetBag(id))
  435. end,
  436. hCreateFrame = function(frameType, name, parent, inherit, dontHook)
  437. if name and not MovAny.lForceProtected[name] then
  438. if dontHook == "MADontHook" then
  439. return
  440. end
  441. API:SyncElement(name)
  442. end
  443. end,
  444. hBlizzard_TalentUI = function(self)
  445. if PlayerTalentFrame_Toggle then
  446. hooksecurefunc("PlayerTalentFrame_Toggle", function()
  447. API:SyncElement("PlayerTalentFrame", true)
  448. end)
  449. MovAny.hBlizzard_TalentUI = nil
  450. end
  451. end,
  452. hReputationWatchBar_Update = function()
  453. API:SyncElement("ReputationWatchBar")
  454. end,
  455. --[[hChatFrame_OnUpdate = function(arg1)
  456. local b = arg1
  457. if MovAny:IsModified(b) then
  458. b:SetWidth(200)
  459. b:SetPoint("TOPLEFT", ChatEditBoxesMover, "TOPLEFT", 0, 0)
  460. b:SetPoint("BOTTOMRIGHT", ChatEditBoxesMover, "BOTTOMRIGHT", 0, 0)
  461. end
  462. end,]]
  463. --[[hCaptureBar_Create = function(id)
  464. local f = MovAny.oCaptureBar_Create(id)
  465. local e = API:GetElement("WorldStateCaptureBar1")
  466. if e then
  467. e:Sync()
  468. if not e.userData or not e.userData.pos then
  469. f:ClearAllPoints()
  470. f:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, -175)
  471. end
  472. end
  473. return f
  474. end,]]
  475. hAchievementAlertFrame_OnLoad = function(f)
  476. f.RegisterForClicks = MovAny.fVoid
  477. MovAny.oAchievementAlertFrame_OnLoad(f)
  478. API:SyncElement(f:GetName())
  479. end,
  480. hAchievementAlertFrame_GetAlertFrame = function()
  481. local f = MovAny.oAchievementAlertFrame_GetAlertFrame()
  482. if not f then
  483. return
  484. end
  485. API:SyncElement(f:GetName())
  486. return f
  487. end,
  488. hStanceBar_Update = function()
  489. API:SyncElement("StanceButtonsMover")
  490. API:SyncElement("StanceButtonsVerticalMover")
  491. end,
  492. hStanceBar_UpdateState = function()
  493. API:SyncElement("StanceButtonsMover")
  494. API:SyncElement("StanceButtonsVerticalMover")
  495. end,
  496. --[[hookArenaEnemyFrames = function()
  497. if ArenaPrepFrames and not ArenaPrepFrames.hooked_ma then
  498. ArenaPrepFrames.hooked_ma = true
  499. ArenaPrepFrames.Hide = function()end
  500. ArenaPrepFrames:Show()
  501. ArenaPrepFrames.Show = function()end
  502. ArenaPrepFrames.clear_all_points = ArenaPrepFrames.ClearAllPoints
  503. ArenaPrepFrames.ClearAllPoints = function(self)
  504. if not InCombatLockdown() then
  505. self:clear_all_points()
  506. end
  507. end
  508. ArenaPrepFrames.set_points = ArenaPrepFrames.SetPoint
  509. ArenaPrepFrames.SetPoint = function(self, ...)
  510. if not InCombatLockdown() then
  511. self:set_points(...)
  512. end
  513. end
  514. end
  515. if ArenaEnemyFrames and not ArenaEnemyFrames.hooked_ma then
  516. ArenaEnemyFrames.hooked_ma = true
  517. ArenaEnemyFrames.Hide = function()end
  518. ArenaEnemyFrames:Show()
  519. ArenaEnemyFrames.Show = function()end
  520. ArenaEnemyFrames.clear_all_points = ArenaEnemyFrames.ClearAllPoints
  521. ArenaEnemyFrames.ClearAllPoints = function(self)
  522. if not InCombatLockdown() then
  523. self:clear_all_points()
  524. end
  525. end
  526. ArenaEnemyFrames.set_points = ArenaEnemyFrames.SetPoint
  527. ArenaEnemyFrames.SetPoint = function(self, ...)
  528. if not InCombatLockdown() then
  529. self:set_points(...)
  530. end
  531. end
  532. end
  533. end,--]]
  534. --arenaframes15hooked = false,
  535. --[[hookArenaEnemyFrames15 = function(self)
  536. if InCombatLockdown() then
  537. return
  538. end
  539. if not MovAny:IsModified("ArenaEnemyFrame1") then
  540. ArenaEnemyFrame1:SetPoint("TOP", UIParent, "TOP", 600, - 300)
  541. ArenaEnemyFrame1:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  542. ArenaEnemyFrame2:SetPoint("TOP", ArenaEnemyFrame1, "BOTTOM", 0, - 20)
  543. ArenaEnemyFrame2:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  544. ArenaEnemyFrame3:SetPoint("TOP", ArenaEnemyFrame2, "BOTTOM", 0, - 20)
  545. ArenaEnemyFrame3:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  546. ArenaEnemyFrame4:SetPoint("TOP", ArenaEnemyFrame3, "BOTTOM", 0, - 20)
  547. ArenaEnemyFrame4:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  548. ArenaEnemyFrame5:SetPoint("TOP", ArenaEnemyFrame4, "BOTTOM", 0, - 20)
  549. ArenaEnemyFrame5:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  550. end
  551. if not MovAny:IsModified("ArenaPrepFrame1") then
  552. ArenaPrepFrame1:SetPoint("TOP", UIParent, "TOP", 600, - 300)
  553. ArenaPrepFrame1:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  554. ArenaPrepFrame2:SetPoint("TOP", ArenaPrepFrame1, "BOTTOM", 0, - 20)
  555. ArenaPrepFrame2:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  556. ArenaPrepFrame3:SetPoint("TOP", ArenaPrepFrame2, "BOTTOM", 0, - 20)
  557. ArenaPrepFrame3:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  558. ArenaPrepFrame4:SetPoint("TOP", ArenaPrepFrame3, "BOTTOM", 0, - 20)
  559. ArenaPrepFrame4:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  560. ArenaPrepFrame5:SetPoint("TOP", ArenaPrepFrame4, "BOTTOM", 0, - 20)
  561. ArenaPrepFrame5:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  562. end
  563. end,
  564. hookArenaEnemyPets15 = function() end,
  565. hArenaEnemyFrames_Enable = function()
  566. ArenaPrepFrames:ma_Show()
  567. ArenaEnemyFrames:ma_Show()
  568. end,
  569. hArenaEnemyFrames_Disable = function()
  570. ArenaPrepFrames:ma_Hide()
  571. ArenaEnemyFrames:ma_Hide()
  572. end,--]]
  573. --[[hWatchFrameExpand = function()
  574. if ArenaEnemyFrames then
  575. local _, instanceType = IsInInstance()
  576. if not WatchFrame:IsUserPlaced() then
  577. if ArenaEnemyFrames:IsShown() then
  578. if WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests) then
  579. ArenaEnemyFrames.hidWatchedQuests = true
  580. end
  581. elseif instanceType == "arena" or instanceType == "pvp" then
  582. if WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests) then
  583. ArenaEnemyFrames.hidWatchedQuests = true
  584. end
  585. else
  586. if ArenaEnemyFrames.hidWatchedQuests then
  587. WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
  588. ArenaEnemyFrames.hidWatchedQuests = false
  589. end
  590. end
  591. elseif ArenaEnemyFrames.hidWatchedQuests then
  592. WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
  593. ArenaEnemyFrames.hidWatchedQuests = false
  594. end
  595. elseif ArenaPrepFrames then
  596. local _, instanceType = IsInInstance()
  597. if not WatchFrame:IsUserPlaced() then
  598. if ArenaPrepFrames:IsShown() then
  599. if WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests) then
  600. ArenaPrepFrames.hidWatchedQuests = true
  601. end
  602. elseif instanceType == "arena" or instanceType == "pvp" then
  603. if WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests) then
  604. ArenaPrepFrames.hidWatchedQuests = true
  605. end
  606. else
  607. if ArenaPrepFrames.hidWatchedQuests then
  608. WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
  609. ArenaPrepFrames.hidWatchedQuests = false
  610. end
  611. end
  612. elseif ArenaPrepFrames.hidWatchedQuests then
  613. WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
  614. ArenaPrepFrames.hidWatchedQuests = false
  615. end
  616. end
  617. end,]]
  618. hFocusFrame_Update = function()
  619. if MovAny:IsModified(FocusFrame) then
  620. RegisterStateDriver("FocusFrame", "visibility", "hide")
  621. else
  622. RegisterStateDriver("FocusFrame", "visibility", "show")
  623. end
  624. end,
  625. --[[hPetActionBarFrame_OnUpdate = function()
  626. if MovAny:IsModified(PetActionButtonsMover) or MovAny:IsModified(PetActionButtonsVerticalMover) then
  627. API:SyncElement("PetActionButtonsMover")
  628. API:SyncElement("PetActionButtonsVerticalMover")
  629. end
  630. end,]]
  631. hAddFrameLock = function()
  632. MultiBarBottomLeft:Hide()
  633. MultiBarBottomRight:Hide()
  634. end,
  635. hRemoveFrameLock = function()
  636. if SHOW_MULTI_ACTIONBAR_1 then
  637. MultiBarBottomLeft:Show()
  638. elseif (MovAny:IsModified(MultiBarBottomLeft) and not MovAny:IsModified(MultiBarBottomLeft)) then
  639. MultiBarBottomLeft:Show()
  640. end
  641. if SHOW_MULTI_ACTIONBAR_2 then
  642. MultiBarBottomRight:Show()
  643. elseif (MovAny:IsModified(MultiBarBottomRight) and not MovAny:IsModified(MultiBarBottomRight)) then
  644. MultiBarBottomRight:Show()
  645. end
  646. end
  647. }
  648.  
  649. if ChatEdit_ActivateChat then
  650. hooksecurefunc("ChatEdit_ActivateChat", function(self)
  651. if MovAny:IsModified("ChatEditBoxesMover") then
  652. MovAny.API:SyncElement("ChatEditBoxesMover")
  653. end
  654. end)
  655. end
  656.  
  657. if InterfaceOptionsFrame then
  658. InterfaceOptionsFrame:HookScript("OnShow", function(self)
  659. MovAny_OptionsOnShow()
  660. end)
  661. end
  662.  
  663. if CompactRaidFrameManager_Expand then
  664. hooksecurefunc("CompactRaidFrameManager_Expand", function(self)
  665. if InCombatLockdown() then
  666. return
  667. end
  668. if MovAny:IsModified(self) then
  669. MovAny:UnlockPoint(self)
  670. local point, relativeTo, relativePoint, xOfs, yOfs = self:GetPoint(1)
  671. self:ClearAllPoints()
  672. self:SetPoint("TOPLEFT", UIParent, "TOPLEFT", xOfs + 175, yOfs)
  673. MovAny:LockPoint(self)
  674. end
  675. end)
  676. end
  677.  
  678. if CompactRaidFrameManager_Collapse then
  679. hooksecurefunc("CompactRaidFrameManager_Collapse", function(self)
  680. if InCombatLockdown() then
  681. return
  682. end
  683. if MovAny:IsModified(self) then
  684. MovAny:UnlockPoint(self)
  685. local point, relativeTo, relativePoint, xOfs, yOfs = self:GetPoint(1)
  686. self:ClearAllPoints()
  687. self:SetPoint("TOPLEFT", UIParent, "TOPLEFT", xOfs - 175, yOfs)
  688. MovAny:LockPoint(self)
  689. end
  690. end)
  691. end
  692. if WorldMap_ToggleSizeDown then
  693. hooksecurefunc("WorldMap_ToggleSizeDown", function()
  694. if MovAny:IsModified(WorldMapFrame) then
  695. MovAny.API:SyncElement("WorldMapFrame")
  696. end
  697. end)
  698. end
  699.  
  700. --[[OverrideActionBar:HookScript("OnShow", function(self)
  701. if not MovAny:IsModified(MicroButtonsMover) and not MovAny:IsModified(MicroButtonsSplitMover) and not MovAny:IsModified(MicroButtonsVerticalMover) then
  702. return
  703. end
  704. local children = {
  705. CharacterMicroButton,
  706. SpellbookMicroButton,
  707. TalentMicroButton,
  708. AchievementMicroButton,
  709. QuestLogMicroButton,
  710. GuildMicroButton,
  711. --PVPMicroButton,
  712. LFDMicroButton,
  713. CollectionsMicroButton,
  714. EJMicroButton,
  715. StoreMicroButton,
  716. MainMenuMicroButton
  717. }
  718. for i = 1, #children, 1 do
  719. MovAny:UnlockPoint(children[i])
  720. MovAny:UnlockScale(children[i])
  721. children[i]:ClearAllPoints()
  722. children[i]:SetScale(1)
  723. if i == 1 then
  724. children[i]:SetPoint("LEFT", OverrideActionBarLeaveFrame, "LEFT", - 165, 20)
  725. elseif children[i] == LFDMicroButton then
  726. children[i]:SetPoint("LEFT", CharacterMicroButton, "LEFT", 0, - 34)
  727. else
  728. children[i]:SetPoint("LEFT", children[i - 1], "RIGHT", - 2, 0)
  729. end
  730. MovAny:LockPoint(children[i])
  731. MovAny:LockScale(children[i])
  732. end
  733. end)
  734.  
  735. OverrideActionBar:HookScript("OnHide", function(self)
  736. if not MovAny:IsModified(MicroButtonsMover) and not MovAny:IsModified(MicroButtonsSplitMover) and not MovAny:IsModified(MicroButtonsVerticalMover) then
  737. return
  738. end
  739. if MovAny:IsModified(MicroButtonsMover) then
  740. MovAny.API:SyncElement("MicroButtonsMover")
  741. elseif MovAny:IsModified(MicroButtonsSplitMover) then
  742. MovAny.API:SyncElement("MicroButtonsSplitMover")
  743. elseif MovAny:IsModified(MicroButtonsVerticalMover) then
  744. MovAny.API:SyncElement("MicroButtonsVerticalMover")
  745. end
  746. end)--]]
  747.  
  748. _G.MovAny = MovAny
  749.  
  750. BINDING_HEADER_MOVEANYTHING = "MoveAnything"
  751.  
  752. StaticPopupDialogs["MOVEANYTHING_RESET_ALL_CONFIRM"] = {
  753. preferredIndex = 3,
  754. text = MOVANY.RESET_ALL_CONFIRM,
  755. button1 = YES,
  756. button2 = NO,
  757. OnAccept = function()
  758. MovAny:CompleteReset()
  759. end,
  760. timeout = 0,
  761. exclusive = 0,
  762. showAlert = 1,
  763. whileDead = 1,
  764. hideOnEscape = 1
  765. }
  766.  
  767. function MovAny:Load()
  768. if self.inited then
  769. return
  770. end
  771. MAOptions = _G["MAOptions"]
  772. if not MADB.noMMMW and Minimap:GetScript("OnMouseWheel") == nil then
  773. Minimap:SetScript("OnMouseWheel", function(self, dir)
  774. if dir < 0 then
  775. Minimap_ZoomOut()
  776. else
  777. Minimap_ZoomIn()
  778. end
  779. end)
  780. Minimap:EnableMouseWheel(true)
  781. end
  782. local MADB_Defaults = {
  783. frameListRows = 18,
  784. }
  785. for i, v in pairs(MADB_Defaults) do
  786. if MADB[i] == nil then
  787. MADB[i] = v
  788. end
  789. end
  790. if tlen(MADB.profiles) == 0 then
  791. MADB.autoShowNext = true
  792. end
  793. self:VerifyData()
  794. if MADB.squareMM then
  795. Minimap:SetMaskTexture("Interface\\AddOns\\MoveAnything\\Textures\\MinimapMaskSquare")
  796. end
  797. self:SetNumRows(MADB.frameListRows, false)
  798. if MADB.closeGUIOnEscape then
  799. tinsert(UISpecialFrames, "MAOptions")
  800. end
  801. MAOptionsMoveHeader:SetText(MOVANY.LIST_HEADING_MOVER)
  802. MAOptionsHideHeader:SetText(MOVANY.LIST_HEADING_HIDE)
  803. MAOptionsToggleFrameEditors:SetChecked(true)
  804. self.userData = MADB.profiles[self:GetProfileName()].frames
  805. for i, m in pairs(self.core) do
  806. if m.Init then
  807. m:Init()
  808. end
  809. end
  810. for i, m in pairs(self.core) do
  811. if m.Enable then
  812. m:Enable()
  813. end
  814. end
  815. for i, m in pairs(self.modules) do
  816. if m.Enable then
  817. m:Enable()
  818. end
  819. end
  820. API = self.API
  821. local ar = { }
  822. local e
  823. for n, v in pairs(self.userData) do
  824. e = API:GetElement(n)
  825. if not e then
  826. tinsert(ar, n)
  827. else
  828. e:SetUserData(v)
  829. end
  830. end
  831. table.sort(ar, function(o1, o2)
  832. return o1:lower() < o2:lower()
  833. end)
  834. for _, fn in ipairs(ar) do
  835. e = API:AddElement({name = fn})
  836. e:SetUserData(self.userData[fn])
  837. end
  838. if self.lVirtualMovers then
  839. if type(self.lCreateVMs) == "table" then
  840. if not MADB.noBags then
  841. for _, name in pairs(self.lCreateVMs) do
  842. if not _G[name] then
  843. self:CreateVM(name)
  844. end
  845. end
  846. end
  847. self.lCreateVMs = nil
  848. end
  849. local vmClosure = function(name)
  850. return function()
  851. if not _G[name] then
  852. MovAny:CreateVM(name)
  853. end
  854. end
  855. end
  856. local el, vm
  857. for name, data in pairs(self.lVirtualMovers) do
  858. vm = _G[name]
  859. if not vm then
  860. el = API:GetElement(name)
  861. if el then
  862. el.runOnce = vmClosure(name)
  863. end
  864. end
  865. if not data.notMAParent then
  866. if type(data.count) == "number" then
  867. for i = 1, data.count, 1 do
  868. local child = _G[data.prefix..i..(data.postfix or "")]
  869. if child then
  870. if not self:IsModified(child:GetName()) then
  871. child.MAParent = vm or name
  872. end
  873. else
  874. break
  875. end
  876. end
  877. end
  878. if type(data.children) == "table" then
  879. for i, v in pairs(data.children) do
  880. local child = v
  881. if type(v) == "string" then
  882. child = _G[v]
  883. end
  884. if child then
  885. if not self:IsModified(child:GetName()) then
  886. child.MAParent = name
  887. end
  888. else
  889. break
  890. end
  891. end
  892. end
  893. end
  894. end
  895. end
  896. if not MADB.noBags then
  897. MAOptions:RegisterEvent("BANKFRAME_OPENED")
  898. MAOptions:RegisterEvent("BANKFRAME_CLOSED")
  899. end
  900. MAOptions:RegisterUnitEvent("UNIT_AURA", "player")
  901. MAOptions:RegisterEvent("BAG_UPDATE")
  902. --MAOptions:RegisterEvent("PET_BATTLE_OPENING_START")
  903. --MAOptions:RegisterEvent("PET_BATTLE_CLOSE")
  904. end
  905.  
  906. function MovAny:Boot()
  907. if self.inited then
  908. return
  909. end
  910. if not MADB.dontHookCreateFrame and CreateFrame then
  911. hooksecurefunc("CreateFrame", self.hCreateFrame)
  912. end
  913. --[[if ContainerFrame_GenerateFrame then
  914. hooksecurefunc("ContainerFrame_GenerateFrame", self.ContainerFrame_GenerateFrame)
  915. end]]
  916. if ShowUIPanel then
  917. hooksecurefunc("ShowUIPanel", self.SyncUIPanels)
  918. end
  919. if HideUIPanel then
  920. hooksecurefunc("HideUIPanel", self.SyncUIPanels)
  921. end
  922. if UpdateUIPanelPositions then
  923. hooksecurefunc("UpdateUIPanelPositions", self.SyncUIPanels)
  924. end
  925. if GameTooltip_SetDefaultAnchor then
  926. hooksecurefunc("GameTooltip_SetDefaultAnchor", self.hGameTooltip_SetDefaultAnchor)
  927. end
  928. if StanceBar_Update then
  929. hooksecurefunc("StanceBar_Update", self.hStanceBar_Update)
  930. end
  931. if StanceBar_UpdateState then
  932. hooksecurefunc("StanceBar_UpdateState", self.hStanceBar_UpdateState)
  933. end
  934. --[[if false then
  935. hooksecurefunc("PetActionBar_Update", self.hPetActionBar_Update)
  936. end]]
  937. if GameTooltip and GameTooltip.SetBagItem then
  938. hooksecurefunc(GameTooltip, "SetBagItem", self.hGameTooltip_SetBagItem)
  939. end
  940. if GameTooltip and GameTooltip.SetGuildBankItem then
  941. hooksecurefunc(GameTooltip, "SetGuildBankItem", self.hGameTooltip_SetGuildBankItem)
  942. end
  943. if ContainerFrameItemButton_CalculateItemTooltipAnchors then
  944. hooksecurefunc("ContainerFrameItemButton_CalculateItemTooltipAnchors", self.hGameTooltip_SetBagItem)
  945. end
  946. if AddFrameLock then
  947. hooksecurefunc("AddFrameLock", self.hAddFrameLock)
  948. end
  949. if RemoveFrameLock then
  950. hooksecurefunc("RemoveFrameLock", self.hRemoveFrameLock)
  951. end
  952. if UpdateContainerFrameAnchors then
  953. hooksecurefunc("UpdateContainerFrameAnchors", self.hUpdateContainerFrameAnchors)
  954. end
  955. if SpellBookFrame_Update then
  956. hooksecurefunc("SpellBookFrame_Update", function()
  957. SpellBookPage1:SetPoint("LEFT", SpellBookFrame)
  958. end)
  959. end
  960. --[[if WatchFrame_Update then
  961. hooksecurefunc("WatchFrame_Update", self.hWatchFrameExpand)
  962. end]]
  963. --setfenv(WorldMapFrame_OnShow, setmetatable({UpdateMicroButtons = function() end }, { __index = _G}))
  964. --[[hooksecurefunc("PetActionBar_UpdatePositionValues", function()
  965. if MovAny:IsModified(PetActionButtonsVerticalMover) or MovAny:IsModified(PetActionButtonsMover) then
  966. --print("PetActionBar_UpdatePositionValues()", MovAny:IsModified(PetActionButtonsVerticalMover), MovAny:IsModified(PetActionButtonsMover))
  967. PetActionBarFrame:SetPoint("TOPLEFT", PetActionBarFrame:GetParent(), "BOTTOMLEFT", 500, 0)
  968. end
  969. end)
  970. hooksecurefunc("ShowPetActionBar", function()
  971. if MovAny:IsModified(PetActionButtonsVerticalMover) or MovAny:IsModified(PetActionButtonsMover) then
  972. --print("ShowPetActionBar()", MovAny:IsModified(PetActionButtonsVerticalMover), MovAny:IsModified(PetActionButtonsMover))
  973. PetActionBarFrame:SetPoint("TOPLEFT", PetActionBarFrame:GetParent(), "BOTTOMLEFT", 500, 0)
  974. end
  975. end)]]
  976. --[[hooksecurefunc("ChatEdit_UpdateHeader",function(arg1, arg2)
  977. local b = arg1
  978. if MovAny:IsModified(b) then
  979. b:SetWidth(ChatFrame1:GetWidth())
  980. b:SetPoint("TOPLEFT", ChatEditBoxesMover, "TOPLEFT", 0, 0)
  981. b:SetPoint("BOTTOMRIGHT", ChatEditBoxesMover, "BOTTOMRIGHT", 0, 0)
  982. end
  983. end)]]
  984. --[[if ExtendedUI and ExtendedUI.CAPTUREPOINT then
  985. self.oCaptureBar_Create = ExtendedUI.CAPTUREPOINT.create
  986. ExtendedUI.CAPTUREPOINT.create = self.hCaptureBar_Create
  987. end]]
  988. if AchievementAlertFrame_OnLoad then
  989. self.oAchievementAlertFrame_OnLoad = AchievementAlertFrame_OnLoad
  990. AchievementAlertFrame_OnLoad = self.hAchievementAlertFrame_OnLoad
  991. end
  992. if AchievementAlertFrame_GetAlertFrame then
  993. self.oAchievementAlertFrame_GetAlertFrame = AchievementAlertFrame_GetAlertFrame
  994. AchievementAlertFrame_GetAlertFrame = self.hAchievementAlertFrame_GetAlertFrame
  995. end
  996. --[[if LootWonAlertFrame_SetUp then
  997. hooksecurefunc("LootWonAlertFrame_SetUp", function(self, arg1, ...)
  998. --print("TestDone", self, arg1, select(1, ...), select(2, ...), select(3, ...), select(4, ...), select(5, ...))
  999. if self == LOOT_WON_ALERT_FRAMES[1] and MovAny:IsModified(LootWonAlertMover1) then
  1000. print("LootWonAlert1 - Find")
  1001. LOOT_WON_ALERT_FRAMES[1]:SetPoint("BOTTOMLEFT", LootWonAlertMover1, "BOTTOMLEFT", 0, 0)
  1002. end
  1003. if self == LOOT_WON_ALERT_FRAMES[2] and MovAny:IsModified(LootWonAlertMover2) then
  1004. print("LootWonAlert2 - Find")
  1005. LOOT_WON_ALERT_FRAMES[2]:SetPoint("BOTTOMLEFT", LootWonAlertMover2, "BOTTOMLEFT", 0, 0)
  1006. end
  1007. if self == LOOT_WON_ALERT_FRAMES[3] and MovAny:IsModified(LootWonAlertMover3) then
  1008. print("LootWonAlert3 - Find")
  1009. LOOT_WON_ALERT_FRAMES[3]:SetPoint("BOTTOMLEFT", LootWonAlertMover3, "BOTTOMLEFT", 0, 0)
  1010. end
  1011. if self == LOOT_WON_ALERT_FRAMES[4] and MovAny:IsModified(LootWonAlertMover4) then
  1012. print("LootWonAlert4 - Find")
  1013. LOOT_WON_ALERT_FRAMES[4]:SetPoint("BOTTOMLEFT", LootWonAlertMover4, "BOTTOMLEFT", 0, 0)
  1014. end
  1015. if self == LOOT_WON_ALERT_FRAMES[5] and MovAny:IsModified(LootWonAlertMover5) then
  1016. print("LootWonAlert5 - Find")
  1017. LOOT_WON_ALERT_FRAMES[5]:SetPoint("BOTTOMLEFT", LootWonAlertMover5, "BOTTOMLEFT", 0, 0)
  1018. end
  1019. end)
  1020. end]]
  1021. --[[if GroupLootContainer_AddFrame then
  1022. hooksecurefunc("GroupLootContainer_AddFrame", function(self, ...)
  1023. --print(self, select(1, ...), select(2, ...))
  1024. if MovAny:IsModified(GroupLootFrameMover1) then
  1025. GroupLootFrame1:SetPoint("BOTTOMLEFT", GroupLootFrameMover1, "BOTTOMLEFT", 0, 0)
  1026. end
  1027. if MovAny:IsModified(GroupLootFrameMover2) then
  1028. GroupLootFrame2:SetPoint("BOTTOMLEFT", GroupLootFrameMover2, "BOTTOMLEFT", 0, 0)
  1029. end
  1030. if MovAny:IsModified(GroupLootFrameMover3) then
  1031. GroupLootFrame1:SetPoint("BOTTOMLEFT", GroupLootFrameMover3, "BOTTOMLEFT", 0, 0)
  1032. end
  1033. if MovAny:IsModified(GroupLootFrameMover4) then
  1034. GroupLootFrame4:SetPoint("BOTTOMLEFT", GroupLootFrameMover4, "BOTTOMLEFT", 0, 0)
  1035. end
  1036. end)
  1037. end]]
  1038. self.inited = true
  1039. if IsAddOnLoaded("Blizzard_TalentUI") and self.hBlizzard_TalentUI then
  1040. self:hBlizzard_TalentUI()
  1041. end
  1042. end
  1043.  
  1044. function MovAny:OnPlayerLogout()
  1045. if not MAOptions then
  1046. return
  1047. end
  1048. if MAOptions:IsShown() then
  1049. MADB.autoShowNext = true
  1050. end
  1051. if type(self.movers) == "table" then
  1052. for i, v in ipairs(MA_tcopy(self.movers)) do
  1053. self:StopMoving(v.tagged:GetName())
  1054. end
  1055. end
  1056. --[[if type(MADB.profiles) == "table" then
  1057. for i, v in pairs(MADB.profiles) do
  1058. MovAny:CleanProfile(i)
  1059. end
  1060. end]]
  1061. end
  1062.  
  1063. function MovAny:VerifyData()
  1064. if MoveAnything_CharacterSettings then
  1065. MADB.profiles = { }
  1066. for i, v in pairs(MoveAnything_CharacterSettings) do
  1067. if type(v) == "table" then
  1068. MADB.profiles[i] = {name = i, frames = v}
  1069. end
  1070. end
  1071. MoveAnything_CharacterSettings = nil
  1072.  
  1073. MADB.characters = { }
  1074. if MoveAnything_UseCharacterSettings then
  1075. for i, _ in pairs(MADB.profiles) do
  1076. MADB.characters[i] = {profile = i}
  1077. end
  1078. end
  1079. end
  1080. if type(MADB) ~= "table" then
  1081. MADB = { }
  1082. end
  1083. if type(MADB.profiles) ~= "table" then
  1084. MADB.profiles = { }
  1085. end
  1086. if type(MADB.characters) ~= "table" then
  1087. MADB.characters = { }
  1088. end
  1089. if MADB.profiles["default"] == nil then
  1090. self:AddProfile("default", true, true)
  1091. end
  1092. if MADB.profiles[self:GetProfileName()] == nil then
  1093. local char = MADB.characters[self:GetCharacterIndex()]
  1094. if char then
  1095. char.profile = nil
  1096. end
  1097. end
  1098. local remList = { }
  1099. local addList = { }
  1100. local rewriteName
  1101. for pi, profile in pairs(MADB.profiles) do
  1102. table.wipe(remList)
  1103. table.wipe(addList)
  1104. if type(profile.frames) ~= "table" then
  1105. profile.frames = { }
  1106. end
  1107. for fn, opt in pairs(profile.frames) do
  1108. if type(fn) ~= "string" or type(opt) ~= "table" or self.lDeleteFrameNames[fn] then
  1109. tinsert(remList, fn)
  1110. else
  1111. rewriteName = nil
  1112. if self.lFrameNameRewrites[fn] then
  1113. rewriteName = fn
  1114. fn = self.lFrameNameRewrites[fn]
  1115. end
  1116. opt.cat = nil
  1117. if opt.name ~= fn then
  1118. opt.name = fn
  1119. end
  1120. opt.originalLeft = nil
  1121. opt.originalBottom = nil
  1122. opt.originalWidth = nil
  1123. opt.orgWidth = nil
  1124. opt.originalHeight = nil
  1125. opt.orgHeight = nil
  1126. opt.orgPos = nil
  1127. opt.originalScale = nil
  1128. opt.orgScale = nil
  1129. opt.originalAlpha = nil
  1130. opt.origAlpha = nil
  1131. opt.MANAGED_FRAME = nil
  1132. opt.UIPanelWindows = nil
  1133. if type(opt.scale) == "number" then
  1134. if opt.scale > 0.991 and opt.scale < 1.009 then
  1135. opt.scale = 1
  1136. end
  1137. else
  1138. opt.scale = nil
  1139. end
  1140. if opt.x ~= nil and opt.y ~= nil then
  1141. local f = _G[fn]
  1142. local fRel = self:ForcedDetachFromParent(fn, opt)
  1143. local p
  1144. if not fRel then
  1145. p = f and f.GetParent and f:GetParent() ~= nil and f:GetParent():GetName() or "UIParent"
  1146. end
  1147. opt.pos = {"BOTTOMLEFT", p, "BOTTOMLEFT", opt.x, opt.y}
  1148. opt.x = nil
  1149. opt.y = nil
  1150. else
  1151. opt.x = nil
  1152. opt.y = nil
  1153. end
  1154. if type(opt.pos) == "table" then
  1155. local relTo = opt.pos[2]
  1156. if type(relTo) == "table" and relTo.GetName and relTo:GetName() then
  1157. opt.pos[2] = relTo:GetName()
  1158. end
  1159. end
  1160. --[[if opt.width and opt.orgWidth and opt.width == opt.orgWidth then
  1161. opt.width = nil
  1162. end
  1163. if opt.height and opt.orgHeight and opt.height == opt.orgHeight then
  1164. opt.height = nil
  1165. end]]
  1166. if rewriteName then
  1167. if not self:IsModified(fn, nil, opt) then
  1168. tinsert(remList, rewriteName)
  1169. else
  1170. tinsert(remList, rewriteName)
  1171. addList[fn] = opt
  1172. end
  1173. elseif not self:IsModified(fn, nil, opt) then
  1174. tinsert(remList, fn)
  1175. end
  1176. end
  1177. end
  1178. for i, v in ipairs(remList) do
  1179. MADB.profiles[pi].frames[v] = nil
  1180. end
  1181. for i, opt in pairs(addList) do
  1182. MADB.profiles[pi].frames[i] = opt
  1183. end
  1184. end
  1185. self.lFrameNameRewrites = nil
  1186. self.lDeleteFrameNames = nil
  1187. end
  1188.  
  1189. function MovAny:VerifyFrameData(fn)
  1190. local e = API:GetElement(fn)
  1191. if e.userData and not e:IsModified() then
  1192. e:SetUserData(nil)
  1193. MovAny.userData[fn] = nil
  1194. end
  1195. end
  1196.  
  1197. function MovAny:ForcedDetachFromParent(fn, opt)
  1198. if self.DetachFromParent[fn] then
  1199. return self.DetachFromParent[fn]
  1200. end
  1201. if UIPanelWindows[fn] then
  1202. return "UIParent"
  1203. end
  1204. opt = opt or self.userData[fn]
  1205. if not opt or opt.UIPanelWindows then
  1206. return "UIParent"
  1207. end
  1208. end
  1209.  
  1210. function MovAny:ErrorNotInCombat(f, quiet)
  1211. if f and self:IsProtected(f) and InCombatLockdown() then
  1212. if not quiet then
  1213. maPrint(string.format(MOVANY.FRAME_PROTECTED_DURING_COMBAT, f:GetName()))
  1214. end
  1215. return true
  1216. end
  1217. end
  1218.  
  1219. function MovAny:IsValidObject(f, silent)
  1220. if type(f) == "string" then
  1221. f = _G[f]
  1222. end
  1223. if not f then
  1224. return
  1225. end
  1226. if type(f) ~= "table" then
  1227. if not silent then
  1228. maPrint(string.format(MOVANY.UNSUPPORTED_TYPE, type(f)))
  1229. end
  1230. return
  1231. end
  1232. if self.lDisallowedFrames[f:GetName()] then
  1233. if not silent then
  1234. maPrint(string.format(MOVANY.UNSUPPORTED_FRAME, f:GetName()))
  1235. end
  1236. return
  1237. end
  1238. if not self.lAllowedTypes[f:GetObjectType()] then
  1239. if not silent then
  1240. maPrint(string.format(MOVANY.UNSUPPORTED_TYPE, f:GetObjectType()))
  1241. end
  1242. return
  1243. end
  1244. if MovAny:IsMAFrame(f:GetName()) then
  1245. if MovAny.lAllowedMAFrames[f:GetName()] or string.sub(f:GetName(), 1, 5) == "MA_FE" then
  1246. return true
  1247. end
  1248. return
  1249. end
  1250. return true
  1251. end
  1252.  
  1253. function MovAny:SyncAllFrames(dontReset)
  1254. if not self.rendered then
  1255. dontReset = true
  1256. end
  1257. table.wipe(self.pendingFrames)
  1258. if type(self.userData) == "table" then
  1259. for i, v in pairs(self.userData) do
  1260. if i ~= "ArenaPrepFrames" or i ~= "ArenaEnemyFrames" then
  1261. self.pendingFrames[i] = API:GetElement(i)
  1262. end
  1263. end
  1264. end
  1265. self:SyncFrames(dontReset)
  1266. end
  1267.  
  1268. function MovAny:SyncFrames(dontReset)
  1269. if not self.inited or self.syncingFrames then
  1270. return
  1271. end
  1272. local i = 0
  1273. for k in pairs(self.pendingFrames) do
  1274. i = i + 1
  1275. break
  1276. end
  1277. if i == 0 then
  1278. return
  1279. end
  1280. self.syncingFrames = true
  1281. local f, parent, handled
  1282. local skippedFrames = { }
  1283. if dontReset then
  1284. for fn, e in pairs(self.pendingFrames) do
  1285. f = _G[fn]
  1286. if f and not e.noMove then
  1287. self:UnanchorRelatives(e, f, e.userData)
  1288. end
  1289. end
  1290. end
  1291. for fn, e in pairs(self.pendingFrames) do
  1292. if not self:GetMoverByFrame(fn) then
  1293. self.curSync = e
  1294. local _, ret = xpcall(function()
  1295. return e:Sync()
  1296. end, self.SyncErrorHandler, self)
  1297. if not ret or self.syncError then
  1298. skippedFrames[fn] = e
  1299. end
  1300.  
  1301. self.curSync = nil
  1302. self.syncError = nil
  1303. end
  1304. end
  1305. self.pendingFrames = skippedFrames
  1306. local postponed = { }
  1307. for k, f in pairs(self.pendingActions) do
  1308. if f() then
  1309. tinsert(postponed, f)
  1310. end
  1311. end
  1312. self.pendingActions = postponed
  1313. self:SyncUIPanels()
  1314. self.rendered = true
  1315. self.syncingFrames = nil
  1316. if MADB.autoShowNext then
  1317. MAOptions:Show()
  1318. end
  1319. end
  1320.  
  1321. function MovAny.SyncErrorHandler(msg, frame, stack, ...)
  1322. if MADB.disableErrorMessages then
  1323. return
  1324. end
  1325. local e = MovAny.curSync
  1326. if e then
  1327. MovAny.syncError = 1
  1328. stack = stack or debugstack(2, 20, 20)
  1329. local funcs = ""
  1330. for m in string.gmatch(stack, "function (%b`')") do
  1331. if m ~= "xpcall" then
  1332. if funcs == "" then
  1333. funcs = m
  1334. else
  1335. funcs = funcs..", "..m
  1336. end
  1337. end
  1338. end
  1339. maPrint(string.format(MOVANY.ERROR_FRAME_FAILED, e.name, e.name, GetAddOnMetadata("MoveAnything", "Version"), msg, funcs))
  1340. end
  1341. local errorHandler = geterrorhandler()
  1342. if type(errorHandler) == "function" and errorHandler ~= _ERRORMESSAGE then
  1343. errorHandler(msg, frame, stack, ...)
  1344. end
  1345. end
  1346.  
  1347. function MovAny:IsProtected(f)
  1348. if not f then
  1349. return
  1350. end
  1351. local isProtected = f:IsProtected()
  1352. if isProtected or f.MAProtected or MovAny.lForceProtected[f:GetName()] then
  1353. return true
  1354. else
  1355. return nil
  1356. end
  1357. end
  1358.  
  1359. function MovAny:IsForbidden(f)
  1360. if not f then
  1361. return
  1362. end
  1363. local isForbidden = f:IsForbidden()
  1364. if isForbidden or MovAny.lForceForbidden[f:GetName()] then
  1365. return true
  1366. else
  1367. return nil
  1368. end
  1369. end
  1370.  
  1371. function MovAny:GetCharacterIndex()
  1372. return GetRealmName().." "..UnitName("player")
  1373. end
  1374.  
  1375. function MovAny:ClearUserData(fn)
  1376. self.userData[fn] = nil
  1377. API:RemoveCustomElement(fn)
  1378. end
  1379.  
  1380. function MovAny:GetUserData(fn, noSymLink, create)
  1381. if self.userData == nil then
  1382. return nil
  1383. end
  1384. if not noSymLink and not self.userData[fn] and self.lTranslateSec[fn] then
  1385. fn = self.lTranslateSec[fn]
  1386. end
  1387. if create and self.userData[fn] == nil then
  1388. local ud = {name = fn}
  1389. local e = API:AddElementIfNew(fn)
  1390. MovAny.userData[fn] = ud
  1391. e:SetUserData(ud)
  1392. return ud
  1393. else
  1394. return MovAny.userData[fn]
  1395. end
  1396. end
  1397.  
  1398. function MovAny.hShow(f, ...)
  1399. if not f then
  1400. return
  1401. end
  1402. if f.MAHidden then
  1403. if MovAny:IsProtected(f) and InCombatLockdown() then
  1404. local e = API:GetElement(f:GetName())
  1405. if e ~= nil and e.userData then
  1406. MovAny.pendingFrames[f:GetName()] = e
  1407. end
  1408. else
  1409. f.MAHidden = nil
  1410. f:Hide()
  1411. f.MAHidden = true
  1412. end
  1413. end
  1414. end
  1415.  
  1416. --[[local hider = CreateFrame("Frame")
  1417. hider:Hide()]]
  1418.  
  1419. function MovAny:LockVisibility(f, dontHide)
  1420. if not f then
  1421. return
  1422. end
  1423. if f.MAHidden then
  1424. return
  1425. end
  1426. f.MAHidden = true
  1427. if not f.MAShowHook then
  1428. hooksecurefunc(f, "Show", MovAny.hShow)
  1429. f.MAShowHook = true
  1430. end
  1431. f.MAWasShown = f:IsShown()
  1432. if not dontHide and f.MAWasShown then
  1433. f:Hide()
  1434. --f.my_real_parent = f:GetParent()
  1435. --f:SetParent(hider)
  1436. end
  1437. end
  1438.  
  1439. function MovAny:UnlockVisibility(f)
  1440. if not f then
  1441. return
  1442. end
  1443. if not f.MAHidden then
  1444. return
  1445. end
  1446. f.MAHidden = nil
  1447. if f.MAWasShown then
  1448. f.MAWasShown = nil
  1449. --[[if f.my_real_parent then
  1450. f:SetParent(f.my_real_parent)
  1451. end]]
  1452. f:Show()
  1453. end
  1454. end
  1455.  
  1456. function MovAny.hSetPoint(f, ...)
  1457. if not f then
  1458. return
  1459. end
  1460. --[[if MovAny.lForceProtected[f:GetName()] then
  1461. print(f:GetName())
  1462. return
  1463. end]]
  1464. if f.MAPoint then
  1465. local fn = f:GetName()
  1466. if fn and string.match(fn, "^ContainerFrame[1-9][0-9]*$") then
  1467. local bag = MovAny:GetBagInContainerFrame(f)
  1468. if not bag then
  1469. return
  1470. end
  1471. fn = bag:GetName()
  1472. end
  1473. if InCombatLockdown() and MovAny:IsProtected(f) then
  1474. local closure = function(f)
  1475. return function()
  1476. local p = f.MAPoint
  1477. f.MAPoint = nil
  1478. f:ClearAllPoints()
  1479. if p then
  1480. f:SetPoint(unpack(p))
  1481. f.MAPoint = p
  1482. end
  1483. p = nil
  1484. end
  1485. end
  1486. MovAny.pendingActions[fn..":SetPoint"] = closure(f)
  1487. else
  1488. local p = f.MAPoint
  1489. f.MAPoint = nil
  1490. f:ClearAllPoints()
  1491. f:SetPoint(unpack(p))
  1492. f.MAPoint = p
  1493. p = nil
  1494. end
  1495. end
  1496. end
  1497.  
  1498. function MovAny:LockPoint(f, opt)
  1499. if not f then
  1500. return
  1501. end
  1502. if not f.MAPoint then
  1503. if f:GetName() and (MovAny.lForcedLock[f:GetName()] or (opt and opt.forcedLock)) then
  1504. if not f.MASetPoint then
  1505. f.MASetPoint = f.SetPoint
  1506. f.SetPoint = MovAny.fVoid
  1507. end
  1508. else
  1509. if not f.MALockPointHook then
  1510. hooksecurefunc(f, "SetPoint", MovAny.hSetPoint)
  1511. f.MALockPointHook = true
  1512. end
  1513. f.MAPoint = {f:GetPoint(1)}
  1514. end
  1515. end
  1516. end
  1517.  
  1518. function MovAny:UnlockPoint(f)
  1519. if not f then
  1520. return
  1521. end
  1522. f.MAPoint = nil
  1523. end
  1524.  
  1525. function MovAny:LockParent(f)
  1526. if not f then
  1527. return
  1528. end
  1529. if not f.MAParented and not f.MAParentHook then
  1530. hooksecurefunc(f, "SetParent", MovAny.hSetParent)
  1531. f.MAParentHook = true
  1532. end
  1533. f.MAParented = f:GetParent()
  1534. end
  1535.  
  1536. function MovAny:UnlockParent(f)
  1537. if not f then
  1538. return
  1539. end
  1540. f.MAParented = nil
  1541. end
  1542.  
  1543. function MovAny.hSetParent(f, ...)
  1544. if not f then
  1545. return
  1546. end
  1547. if f.MAParented then
  1548. if InCombatLockdown() and MovAny:IsProtected(f) then
  1549. MovAny.pendingFrames[f:GetName()] = API:GetElement(f:GetName())
  1550. else
  1551. local p = f.MAParented
  1552. MovAny:UnlockParent(f)
  1553. f:SetParent(p)
  1554. MovAny:LockParent(f)
  1555. end
  1556. end
  1557. end
  1558.  
  1559. --[[function MovAny.hSetWidth(f, ...)
  1560. if f.MAScaled then
  1561. local fn = f:GetName()
  1562. if string.match(fn, "^ContainerFrame[0-9]+$") then
  1563. local bag = MovAny:GetBagInContainerFrame(f)
  1564. fn = bag:GetName()
  1565. end
  1566. MovAny.pendingFrames[fn] = API:GetElement(fn)
  1567. if not MovAny:IsProtected(f) or not InCombatLockdown() then
  1568. MovAny:SyncFrames()
  1569. end
  1570. end
  1571. end
  1572.  
  1573. function MovAny.hSetHeight(f, ...)
  1574. if f.MAScaled then
  1575. local fn = f:GetName()
  1576. if string.match(fn, "^ContainerFrame[0-9]+$") then
  1577. local bag = MovAny:GetBagInContainerFrame(f)
  1578. fn = bag:GetName()
  1579. end
  1580. MovAny.pendingFrames[fn] = API:GetElement(fn)
  1581. if not MovAny:IsProtected(f) or not InCombatLockdown() then
  1582. MovAny:SyncFrames()
  1583. end
  1584. end
  1585. end
  1586.  
  1587. function MovAny.hSetScale(f, ...)
  1588. if f.MAScaled then
  1589. local fn = f:GetName()
  1590. if string.match(fn, "^ContainerFrame[0-9]+$") then
  1591. local bag = MovAny:GetBagInContainerFrame(f)
  1592. fn = bag:GetName()
  1593. end
  1594. MovAny.pendingFrames[fn] = API:GetElement(fn)
  1595. if not MovAny:IsProtected(f) or not InCombatLockdown() then
  1596. MovAny:SyncFrames()
  1597. end
  1598. end
  1599. end
  1600.  
  1601. function MovAny:LockScale(f)
  1602. if f.SetScale and not f.MAScaleLocked then
  1603. if not f.MAScaleHook then
  1604. -- the following doesnt work. it needs to be hooked through the metatable somehow, these hooksecurefunc's never fires
  1605. if f.SetWidth then
  1606. hooksecurefunc(f, "SetWidth", MovAny.hSetWidth)
  1607. end
  1608. if f.SetHeight then
  1609. hooksecurefunc(f, "SetHeight", MovAny.hSetHeight)
  1610. end
  1611. if f.SetScale then
  1612. hooksecurefunc(f, "SetScale", MovAny.hSetScale)
  1613. end
  1614. f.MAScaleHook = true
  1615. end
  1616. end
  1617. end
  1618.  
  1619. function MovAny:UnlockScale(f)
  1620. f.MAScaleLocked = nil
  1621. end]]
  1622.  
  1623. function MovAny.hSetScale(f)
  1624. if not f then
  1625. return
  1626. end
  1627. if f.MAScaled then
  1628. local fn = f:GetName()
  1629. if string.match(fn, "^ContainerFrame[1-9][0-9]*$") then
  1630. local bag = MovAny:GetBagInContainerFrame(f)
  1631. if not bag then
  1632. if MovAny:IsProtected(f) and InCombatLockdown() then
  1633. MovAny.pendingActions[f:GetName()..":SetScale"] = function()
  1634. if MovAny:IsProtected(f) and InCombatLockdown() then
  1635. return true
  1636. end
  1637. MovAny:Rescale(f, f.MAScaled)
  1638. end
  1639. else
  1640. MovAny:Rescale(f, f.MAScaled)
  1641. end
  1642. return
  1643. end
  1644. fn = bag:GetName()
  1645. if MovAny:IsProtected(f) and InCombatLockdown() then
  1646. MovAny.pendingFrames[fn] = API:GetElement(fn)
  1647. else
  1648. MovAny:Rescale(f, f.MAScaled)
  1649. end
  1650. else
  1651. if MovAny:IsProtected(f) and InCombatLockdown() then
  1652. MovAny.pendingFrames[fn] = API:GetElement(fn)
  1653. else
  1654. MovAny:Rescale(f, f.MAScaled)
  1655. end
  1656. end
  1657. end
  1658. end
  1659.  
  1660. function MovAny:LockScale(f)
  1661. if not f then
  1662. return
  1663. end
  1664. if f.SetScale and not f.MAScaled then
  1665. local meta = getmetatable(f).__index
  1666. if not meta.MAScaleHook then
  1667. if meta.SetScale then
  1668. hooksecurefunc(meta, "SetScale", MovAny.hSetScale)
  1669. end
  1670. meta.MAScaleHook = true
  1671. end
  1672. f.MAScaled = f:GetScale()
  1673. end
  1674. end
  1675.  
  1676. function MovAny:UnlockScale(f)
  1677. if not f then
  1678. return
  1679. end
  1680. f.MAScaled = nil
  1681. end
  1682.  
  1683. function MovAny:Rescale(f, scale)
  1684. if not f then
  1685. return
  1686. end
  1687. MovAny:UnlockScale(f)
  1688. f:SetScale(scale)
  1689. MovAny:LockScale(f)
  1690. end
  1691.  
  1692. function MovAny.hSyncIfScaled(self, f)
  1693. if not f then
  1694. return
  1695. end
  1696. if f.MAScaled and f:GetName() ~= nil then
  1697. API:SyncElement(f:GetName())
  1698. end
  1699. end
  1700.  
  1701. function MovAny:LockWH(f)
  1702. if not f then
  1703. return
  1704. end
  1705. if f.SetScale and not f.MAScaled then
  1706. if not f.MAScaleHook then
  1707. if f.SetWidth then
  1708. hooksecurefunc(f, "SetWidth", MovAny.hSyncIfScaled)
  1709. end
  1710. if f.SetHeight then
  1711. hooksecurefunc(f, "SetHeight", MovAny.hSyncIfScaled)
  1712. end
  1713. f.MAScaleHook = true
  1714. end
  1715. f.MAScaled = f:GetScale()
  1716. end
  1717. end
  1718.  
  1719. function MovAny:HookFrame(e, f, dontUnanchor, runBeforeInteract)
  1720. if not f then
  1721. f = e.f
  1722. if not f then
  1723. return
  1724. end
  1725. end
  1726. if InCombatLockdown() and MovAny:IsProtected(f) then
  1727. return
  1728. end
  1729. if not self:IsValidObject(f) then
  1730. return
  1731. end
  1732. if not runBeforeInteract and e and e.runBeforeInteract and e.runBeforeInteract() then
  1733. return
  1734. end
  1735. local fn = f:GetName()
  1736. local opt = self:GetUserData(fn, nil, true)
  1737. if opt.name == nil then
  1738. opt.name = fn
  1739. end
  1740. if opt.disabled then
  1741. return
  1742. end
  1743. if f.MAOrgScale then
  1744. self:UnlockScale(f)
  1745. f:SetScale(f.MAOrgScale)
  1746. f.MAOrgScale = nil
  1747. end
  1748. if f.MAOrgAlpha then
  1749. f:SetAlpha(f.MAOrgAlpha)
  1750. f.MAOrgAlpha = nil
  1751. end
  1752. if fn == "FocusFrame" then
  1753. f.orgScale = f:GetScale()
  1754. f.scale = f:GetScale()
  1755. end
  1756. if f.SetMovable and e and not e.noMove then
  1757. if f:IsUserPlaced() then
  1758. f.MAWasUserPlaced = true
  1759. end
  1760. if f:IsMovable() then
  1761. f.MAWasMovable = true
  1762. end
  1763. if f:IsResizable() then
  1764. f.MAWasResizable = true
  1765. end
  1766. f:SetMovable(true)
  1767. if f ~= MainMenuBar then
  1768. f:SetUserPlaced(true)
  1769. end
  1770. end
  1771. f.MAE = e
  1772. if not opt.orgPos and e and not e.noMove then
  1773. self.Position:StoreOrgPoints(f, opt)
  1774. end
  1775. if not f.MAHooked then
  1776. if f.OnMAHook and f:OnMAHook() ~= nil then
  1777. return
  1778. end
  1779. f.MAHooked = true
  1780. end
  1781. if not dontUnanchor and e and not e.noUnanchorRelatives and not e.noMove then
  1782. self:UnanchorRelatives(e, f, opt)
  1783. end
  1784. if self.DetachFromParent[fn] and not self.NoReparent[fn] and not f.MAOrgParent then
  1785. f.MAOrgParent = f:GetParent()
  1786. f:SetParent(_G[ self.DetachFromParent[fn] ])
  1787. --self:LockParent(f)
  1788. end
  1789. if f.OnMAPostHook and f.OnMAPostHook(f) ~= nil then
  1790. return
  1791. end
  1792. return opt
  1793. end
  1794.  
  1795. function MovAny:IsModified(fn, var, opt)
  1796. if fn == nil then
  1797. return
  1798. end
  1799. if type(fn) == "table" then
  1800. fn = fn:GetName()
  1801. end
  1802. opt = opt or self:GetUserData(fn)
  1803. if opt then
  1804. if var then
  1805. if opt[var] then
  1806. return true
  1807. end
  1808. elseif opt.pos or opt.hidden or opt.scale ~= nil or opt.alpha ~= nil or opt.frameStrata ~= nil or opt.disableLayerArtwork ~= nil or opt.disableLayerBackground ~= nil or opt.disableLayerBorder ~= nil or opt.disableLayerHighlight ~= nil or opt.disableLayerOverlay ~= nil or opt.unregisterAllEvents ~= nil or opt.groups ~= nil or opt.forcedLock ~= nil then
  1809. return true
  1810. end
  1811. else
  1812. if MovAny:GetMoverByFrameName(fn) then
  1813. return true
  1814. end
  1815. end
  1816. return false
  1817. end
  1818.  
  1819. function MovAny:AttachMover(fn, displayName)
  1820. local f = _G[fn]
  1821. if self:ErrorNotInCombat(f) then
  1822. return
  1823. end
  1824. local e = API:AddElementIfNew(fn)
  1825. if e.unsupported then
  1826. string.format(MOVANY.UNSUPPORTED_FRAME, fn)
  1827. return
  1828. end
  1829. if e.noMove and e.noScale and e.noAlpha then
  1830. maPrint(string.format(MOVANY.FRAME_VISIBILITY_ONLY, fn))
  1831. return
  1832. end
  1833. if e.onlyOnceCreated and (f == nil or not f:IsShown()) then
  1834. maPrint(string.format(MOVANY.ONLY_ONCE_CREATED, fn))
  1835. return
  1836. end
  1837. if e and e.refuseSync then
  1838. if type(e.refuseSync) == "string" then
  1839. maPrint(string.format(e.refuseSync, fn))
  1840. end
  1841. return
  1842. end
  1843. if f and type(f) ~= "table" then
  1844. maPrint(string.format(MOVANY.ERROR_NOT_A_TABLE, fn))
  1845. return
  1846. end
  1847. if not self:GetMoverByFrame(f) then
  1848. if e then
  1849. if e.runOnce then
  1850. if not e:runOnce() then
  1851. e.runOnce = nil
  1852. else
  1853. return
  1854. end
  1855. end
  1856. if e.runBeforeInteract and e:runBeforeInteract() then
  1857. return
  1858. end
  1859. end
  1860. local created = nil
  1861. local handled = nil
  1862. if e then
  1863. if e.create and _G[fn] == nil then
  1864. f = CreateFrame("Frame", fn, UIParent, e.create)
  1865. created = true
  1866. else
  1867. f = _G[fn]
  1868. end
  1869. end
  1870. if f and fn ~= f:GetName() then
  1871. fn = f:GetName()
  1872. f = _G[fn]
  1873. e = API:GetElement(fn)
  1874. end
  1875. self.lastFrameName = fn
  1876. if self:IsValidObject(f) then
  1877. local mover = self:GetAvailableMover()
  1878. mover.tagged = f
  1879. if f.OnMAAttach then
  1880. f.OnMAAttach(f, mover)
  1881. end
  1882. API:AddElementIfNew(fn, displayName)
  1883. if self:HookFrame(e, f) then
  1884. if self:AttachMoverToFrame(mover, f) then
  1885. handled = true
  1886. mover.createdTagged = created
  1887. if f.OnMAPostAttach then
  1888. f.OnMAPostAttach(f, mover)
  1889. end
  1890. self:UpdateGUIIfShown()
  1891. end
  1892. end
  1893. end
  1894. if e and e.runAfterInteract then
  1895. e:runAfterInteract(handled)
  1896. end
  1897. return true
  1898. end
  1899. end
  1900.  
  1901. function MovAny:GetAvailableMover()
  1902. local f
  1903. for id = 1, 1000000, 1 do
  1904. f = _G[self.moverPrefix..id]
  1905. if not f then
  1906. f = CreateFrame("Frame", self.moverPrefix..id, UIParent, "MAMoverTemplate")
  1907. f:SetID(id)
  1908. break
  1909. end
  1910. if not f.tagged then
  1911. break
  1912. end
  1913. end
  1914. if f then
  1915. tinsert(self.movers, f)
  1916. return f
  1917. end
  1918. end
  1919.  
  1920. function MovAny:GetDefaultFrameParent(f)
  1921. local c = f
  1922. while c and c ~= UIParent and c ~= nil do
  1923. if c.GetName and c:GetName() ~= nil and c:GetName() ~= "" then
  1924. local m = string.match(c:GetName(),"^ContainerFrame[1-9][0-9]*$")
  1925. if m then
  1926. local bag = self:GetBagInContainerFrame(_G[ m ])
  1927. if bag and self:IsModified(bag:GetName()) then
  1928. return _G[bag:GetName()]
  1929. end
  1930. end
  1931. local maParent = c.MAParent
  1932. if maParent then
  1933. if type(maParent) == "string" then
  1934. maParent = self:CreateVM(maParent)
  1935. end
  1936. return maParent
  1937. end
  1938. local transName = self:Translate(c:GetName(),true,true)
  1939. if self:IsModified(transName) then
  1940. return _G[ transName ]
  1941. else
  1942. local frame = API:GetElement(transName)
  1943. if frame then
  1944. return _G[frame.name]
  1945. end
  1946. end
  1947. end
  1948. c = c:GetParent()
  1949. end
  1950. return nil
  1951. end
  1952.  
  1953. function MovAny:GetTopFrameParent(f)
  1954. local c = f
  1955. local l = nil
  1956. local ln
  1957. local n
  1958. while c and c ~= UIParent do
  1959. if c:IsToplevel() then
  1960. n = c:GetName()
  1961. if n ~= nil and n ~= "" then
  1962. return c
  1963. elseif ln ~= nil then
  1964. return ln
  1965. else
  1966. maPrint(MOVANY.NO_NAMED_FRAMES_FOUND)
  1967. return nil
  1968. end
  1969. end
  1970. l = c
  1971. n = c:GetName()
  1972. if n ~= nil and n ~= "" then
  1973. ln = c
  1974. end
  1975. c = c:GetParent()
  1976. end
  1977. if c == UIParent then
  1978. return l
  1979. end
  1980. return nil
  1981. end
  1982.  
  1983. function MovAny:ToggleMove(fn)
  1984. local ret = nil
  1985. if self:GetMoverByFrame(fn) then
  1986. ret = self:StopMoving(fn)
  1987. else
  1988. ret = self:AttachMover(fn)
  1989. end
  1990. self.lastFrameName = fn
  1991. self:UpdateGUIIfShown(true)
  1992. return ret
  1993. end
  1994.  
  1995. function MovAny:ToggleHide(fn)
  1996. local ret = nil
  1997. local f = _G[fn]
  1998. if f and type(f) ~= "table" then
  1999. maPrint(string.format(MOVANY.ERROR_NOT_A_TABLE, fn))
  2000. return
  2001. end
  2002. if f and fn ~= f:GetName() then
  2003. fn = f:GetName()
  2004. end
  2005. self:AttachMover(fn)
  2006. local opt = self:GetUserData(fn, nil, true)
  2007. if not f or not opt.hidden then
  2008. ret = self:HideFrame(fn)
  2009. else
  2010. ret = self:ShowFrame(fn)
  2011. end
  2012. self.lastFrameName = fn
  2013. self:UpdateGUIIfShown(true)
  2014. return ret
  2015. end
  2016.  
  2017. -- X: bindings
  2018. function MovAny:SafeMoveFrameAtCursor()
  2019. local obj = GetMouseFocus()
  2020. while true and obj do
  2021. while true and obj do
  2022. if self:IsMAFrame(obj:GetName()) then
  2023. if self:IsMover(obj:GetName()) then
  2024. if obj.tagged then
  2025. obj = obj.tagged
  2026. else
  2027. return
  2028. end
  2029. elseif not self:IsValidObject(obj, true) then
  2030. obj = obj:GetParent()
  2031. if not obj or obj == UIParent then
  2032. return
  2033. end
  2034. else
  2035. break
  2036. end
  2037. else
  2038. break
  2039. end
  2040. end
  2041. local transName = self:Translate(obj:GetName(), 1)
  2042.  
  2043. if transName ~= obj:GetName() then
  2044. self:ToggleMove(transName)
  2045. break
  2046. end
  2047. local p = obj:GetParent()
  2048. -- check for minimap button
  2049. if (p == MinimapBackdrop or p == Minimap or p == MinimapCluster) and obj ~= Minimap then
  2050. self:ToggleMove(obj:GetName())
  2051. break
  2052. end
  2053. local objTest = self:GetDefaultFrameParent(obj)
  2054. if objTest then
  2055. self:ToggleMove(objTest:GetName())
  2056. break
  2057. end
  2058. objTest = self:GetTopFrameParent(obj)
  2059. if objTest then
  2060. self:ToggleMove(objTest:GetName())
  2061. break
  2062. end
  2063. if obj and obj ~= WorldFrame and obj ~= UIParent and obj.GetName then
  2064. self:ToggleMove(obj:GetName())
  2065. end
  2066. break
  2067. end
  2068. self:UpdateGUIIfShown(true)
  2069. end
  2070.  
  2071. function MovAny:MoveFrameAtCursor()
  2072. local obj = GetMouseFocus()
  2073. if self:IsMAFrame(obj:GetName()) then
  2074. if self:IsMover(obj:GetName()) and obj.tagged then
  2075. obj = obj.tagged
  2076. elseif not self:IsValidObject(obj) then
  2077. return
  2078. end
  2079. end
  2080. if not self:IsModified(obj:GetName()) and obj.MAParent then
  2081. self:ToggleMove(type(obj.MAParent== "string") and obj.MAParent or obj.MAParent:GetName())
  2082. else
  2083. local transName = self:Translate(obj:GetName(), true, true)
  2084. if transName ~= obj:GetName() then
  2085. self:ToggleMove(transName)
  2086. elseif obj and obj ~= WorldFrame and obj ~= UIParent and obj:GetName() then
  2087. self:ToggleMove(obj:GetName())
  2088. end
  2089. end
  2090. self:UpdateGUIIfShown(true)
  2091. end
  2092.  
  2093. function MovAny:SafeHideFrameAtCursor()
  2094. local obj = GetMouseFocus()
  2095. while true do
  2096. if self:IsMAFrame(obj:GetName()) then
  2097. if self:IsMover(obj:GetName()) and obj.tagged then
  2098. obj = obj.tagged
  2099. elseif not self:IsValidObject(obj, true) then
  2100. obj = obj:GetParent()
  2101. end
  2102. end
  2103. local transName = self:Translate(obj:GetName(), 1)
  2104. if transName ~= obj:GetName() then
  2105. self:ToggleHide(transName)
  2106. break
  2107. end
  2108. local objTest = self:GetDefaultFrameParent(obj)
  2109. if objTest then
  2110. self:ToggleHide(objTest:GetName())
  2111. break
  2112. end
  2113. objTest = self:GetTopFrameParent(obj)
  2114. if objTest then
  2115. API:AddElementIfNew(objTest:GetName())
  2116. self:ToggleHide(objTest:GetName())
  2117. break
  2118. end
  2119. if obj and obj ~= WorldFrame and obj ~= UIParent then
  2120. API:AddElementIfNew(obj:GetName())
  2121. self:ToggleHide(obj:GetName())
  2122. break
  2123. end
  2124. break
  2125. end
  2126. self:UpdateGUIIfShown(true)
  2127. end
  2128.  
  2129. function MovAny:HideFrameAtCursor()
  2130. local obj = GetMouseFocus()
  2131. if self:IsMAFrame(obj:GetName()) then
  2132. if self:IsMover(obj:GetName()) and obj.tagged then
  2133. obj = obj.tagged
  2134. else
  2135. return
  2136. end
  2137. end
  2138. if not self:IsModified(obj:GetName()) and obj.MAParent then
  2139. self:ToggleHide(type(obj.MAParent== "string") and obj.MAParent or obj.MAParent:GetName())
  2140. else
  2141. local transName = self:Translate(obj:GetName(), true, true)
  2142. if transName ~= obj:GetName() then
  2143. self:ToggleHide(transName)
  2144. elseif obj and obj ~= WorldFrame and obj ~= UIParent and obj:GetName() then
  2145. self:ToggleHide(obj:GetName())
  2146. end
  2147. end
  2148.  
  2149. self:UpdateGUIIfShown(true)
  2150. end
  2151.  
  2152. function MovAny:SafeResetFrameAtCursor()
  2153. local obj = GetMouseFocus()
  2154. local fn = obj:GetName()
  2155. while true do
  2156. if fn and self.userData[fn] then
  2157. self:ResetFrameConfirm(fn)
  2158. break
  2159. end
  2160. if self:IsMAFrame(fn) then
  2161. if self:IsMover(fn) and obj.tagged then
  2162. obj = obj.tagged
  2163. self:ResetFrameConfirm(obj:GetName())
  2164. break
  2165. elseif not self:IsValidObject(obj, true) then
  2166. obj = obj:GetParent()
  2167. end
  2168. fn = obj:GetName()
  2169. end
  2170. local transName = self:Translate(fn, 1)
  2171. if transName ~= fn and self.userData[fn] then
  2172. self:ResetFrameConfirm(fn)
  2173. break
  2174. end
  2175. local objTest = self:GetDefaultFrameParent(obj)
  2176. if objTest and self.userData[ objTest:GetName() ] then
  2177. self:ResetFrameConfirm(objTest:GetName())
  2178. break
  2179. end
  2180. objTest = self:GetTopFrameParent(obj)
  2181. if objTest and self.userData[ objTest:GetName() ] then
  2182. self:ResetFrameConfirm(objTest:GetName())
  2183. break
  2184. end
  2185. if obj and obj ~= WorldFrame and obj ~= UIParent and self.userData[fn] then
  2186. self:ResetFrameConfirm(fn)
  2187. break
  2188. end
  2189. break
  2190. end
  2191. end
  2192.  
  2193. function MovAny:ResetFrameAtCursor()
  2194. local obj = GetMouseFocus()
  2195. if self:IsMAFrame(obj:GetName()) then
  2196. if self:IsMover(obj:GetName()) and obj.tagged then
  2197. obj = obj.tagged
  2198. else
  2199. return
  2200. end
  2201. end
  2202. if InCombatLockdown() and MovAny:IsProtected(obj) then
  2203. self:ErrorNotInCombat(obj)
  2204. return
  2205. end
  2206. local fn
  2207. if not self:IsModified(obj:GetName()) and obj.MAParent then
  2208. fn = type(obj.MAParent == "string") and obj.MAParent or obj.MAParent:GetName()
  2209. else
  2210. fn = self:Translate(obj:GetName(), true, true)
  2211. if transName ~= obj:GetName() then
  2212. fn = transName
  2213. elseif obj and obj ~= WorldFrame and obj ~= UIParent and obj:GetName() then
  2214. fn = obj:GetName()
  2215. end
  2216. end
  2217. if fn and self.userData[fn] then
  2218. self:ResetFrameConfirm(fn)
  2219. end
  2220. end
  2221.  
  2222. function MovAny:SafeMAFEFrameAtCursor()
  2223. local obj = GetMouseFocus()
  2224. while true and obj do
  2225. while true and obj do
  2226. if self:IsMAFrame(obj:GetName()) then
  2227. if self:IsMover(obj:GetName()) then
  2228. if obj.tagged then
  2229. obj = obj.tagged
  2230. else
  2231. return
  2232. end
  2233. elseif not self:IsValidObject(obj, true) then
  2234. obj = obj:GetParent()
  2235. if not obj or obj == UIParent then
  2236. return
  2237. end
  2238. else
  2239. break
  2240. end
  2241. else
  2242. break
  2243. end
  2244. end
  2245. local transName = self:Translate(obj:GetName(), 1)
  2246. if transName ~= obj:GetName() then
  2247. self:FrameEditor(transName)
  2248. break
  2249. end
  2250. local p = obj:GetParent()
  2251. -- check for minimap button
  2252. if (p == MinimapBackdrop or p == Minimap or p == MinimapCluster) and obj ~= Minimap then
  2253. self:FrameEditor(obj:GetName())
  2254. break
  2255. end
  2256. local objTest = self:GetDefaultFrameParent(obj)
  2257. if objTest then
  2258. self:FrameEditor(objTest:GetName())
  2259. break
  2260. end
  2261. objTest = self:GetTopFrameParent(obj)
  2262. if objTest then
  2263. self:FrameEditor(objTest:GetName())
  2264. break
  2265. end
  2266. if obj and obj ~= WorldFrame and obj ~= UIParent and obj.GetName then
  2267. self:FrameEditor(obj:GetName())
  2268. end
  2269. break
  2270. end
  2271. self:UpdateGUIIfShown(true)
  2272. end
  2273.  
  2274. function MovAny:MAFEFrameAtCursor()
  2275. local obj = GetMouseFocus()
  2276. if self:IsMAFrame(obj:GetName()) then
  2277. if self:IsMover(obj:GetName()) and obj.tagged then
  2278. obj = obj.tagged
  2279. elseif not self:IsValidObject(obj) then
  2280. return
  2281. end
  2282. end
  2283. if not self:IsModified(obj:GetName()) and obj.MAParent then
  2284. self:FrameEditor(type(obj.MAParent== "string") and obj.MAParent or obj.MAParent:GetName())
  2285. else
  2286. local transName = self:Translate(obj:GetName(), true, true)
  2287. if transName ~= obj:GetName() then
  2288. self:FrameEditor(transName)
  2289. elseif obj and obj ~= WorldFrame and obj ~= UIParent and obj:GetName() then
  2290. self:FrameEditor(obj:GetName())
  2291. end
  2292. end
  2293. self:UpdateGUIIfShown(true)
  2294. end
  2295.  
  2296. function MovAny:IsMover(fn)
  2297. if fn ~= nil and string.match(fn, "^"..self.moverPrefix.."[0-9]+$") ~= nil then
  2298. return true
  2299. end
  2300. end
  2301.  
  2302. function MovAny:IsMAFrame(fn)
  2303. if fn ~= nil and (string.match(fn, "^MoveAnything") ~= nil or string.match(fn, "^MA") ~= nil) then
  2304. return true
  2305. end
  2306. end
  2307.  
  2308. function MovAny:IsContainer(fn)
  2309. if type(fn) == "string" and string.match(fn, "^ContainerFrame[1-9][0-9]*$") then
  2310. return true
  2311. end
  2312. end
  2313.  
  2314. function MovAny:Translate(f, secondary, nofirst)
  2315. if not nofirst and self.lTranslate[f] then
  2316. return self.lTranslate[f]
  2317. end
  2318. if secondary and self.lTranslateSec[f] then
  2319. return self.lTranslateSec[f]
  2320. end
  2321. if f == "last" then
  2322. return MovAny.lastFrameName
  2323. else
  2324. return f
  2325. end
  2326. end
  2327.  
  2328. function MovAny:ToggleMovers()
  2329. if _G.MAOptionsToggleMovers:GetChecked() then
  2330. local protected = { }
  2331. for i, v in ipairs(self.minimizedMovers) do
  2332. if InCombatLockdown() and self:IsProtected(v) then
  2333. tinsert(protected, v)
  2334. else
  2335. self:AttachMover(v:GetName())
  2336. end
  2337. end
  2338. table.wipe(self.minimizedMovers)
  2339. self.minimizedMovers = protected
  2340. else
  2341. for i, v in ipairs(MA_tcopy(self.movers)) do
  2342. tinsert(self.minimizedMovers, v.tagged)
  2343. self:StopMoving(v.tagged:GetName())
  2344. end
  2345. end
  2346. end
  2347.  
  2348. function MovAny:GetMoverByFrame(f)
  2349. if not f then
  2350. return
  2351. end
  2352. if type(f) == "string" then
  2353. f = _G[f]
  2354. end
  2355. for i, m in ipairs(self.movers) do
  2356. if type(m) == "table" and m:IsShown() and m.tagged == f then
  2357. return m
  2358. end
  2359. end
  2360. return nil
  2361. end
  2362.  
  2363. function MovAny:GetMoverByFrameName(fn)
  2364. if not fn then
  2365. return
  2366. end
  2367. if type(fn) == "table" then
  2368. fn = fn:GetName()
  2369. end
  2370. for i, m in ipairs(self.movers) do
  2371. if type(m) == "table" and m:IsShown() and m.tagged and m.tagged:GetName() == fn then
  2372. return m
  2373. end
  2374. end
  2375. return nil
  2376. end
  2377.  
  2378. function MovAny:AttachMoverToFrame(mover, f)
  2379. if f.MAHidden == true then
  2380. return
  2381. end
  2382. self:UnlockPoint(f)
  2383. local e = f.MAE
  2384. if not e then
  2385. self:DetachMover(mover)
  2386. return
  2387. end
  2388. mover.MAE = e
  2389. --[[if not string.find(e.name, "Mover") then
  2390. self:ShowFrame(f)
  2391. end]]
  2392. local opt = e.userData or MovAny:GetUserData(e.name, nil, true)
  2393. mover.displayName = e.displayName or f:GetName()
  2394. f.MAMover = mover
  2395. if f.OnMAMoving then
  2396. if not f:OnMAMoving() then
  2397. self:DetachMover(mover)
  2398. return
  2399. end
  2400. end
  2401. local x, y = 0, 0
  2402. if f:GetLeft() == nil and not f:IsShown() then
  2403. f:Show()
  2404. f:Hide()
  2405. end
  2406. mover.attaching = true
  2407. mover.dontUpdate = nil
  2408. if f.IsClampedToScreen then
  2409. mover:SetClampedToScreen(f:IsClampedToScreen())
  2410. end
  2411. opt.disabled = nil
  2412. mover:ClearAllPoints()
  2413. mover:SetPoint("CENTER", f, "CENTER")
  2414. mover:SetWidth(f:GetWidth() * MAGetScale(f))
  2415. mover:SetHeight(f:GetHeight() * MAGetScale(f))
  2416. if f.GetFrameLevel then
  2417. mover:SetFrameLevel(f:GetFrameLevel() + 1)
  2418. end
  2419. if not e.noMove then
  2420. if not opt.pos then
  2421. opt.pos = self:GetRelativePoint(self.Position:GetFirstOrgPoint(opt), f)
  2422. end
  2423. local p = self:GetRelativePoint({"BOTTOMLEFT", UIParent, "BOTTOMLEFT"}, mover)
  2424. mover:ClearAllPoints()
  2425. mover:SetPoint(unpack(p))
  2426. mover.MAStartPoint = self:GetRelativePoint({"BOTTOMLEFT", UIParent, "BOTTOMLEFT"}, f)
  2427. if f.GetScale then
  2428. mover.MAStartScale = f:GetScale()
  2429. end
  2430. f:ClearAllPoints()
  2431. if f.MASetPoint then
  2432. f:MASetPoint("BOTTOMLEFT", mover, "BOTTOMLEFT", 0, 0)
  2433. else
  2434. f:SetPoint("BOTTOMLEFT", mover, "BOTTOMLEFT", 0, 0)
  2435. end
  2436. f.orgX = x
  2437. f.orgY = y
  2438. end
  2439. mover.tagged = f
  2440. local label = _G[ mover:GetName().."BackdropInfoLabel"]
  2441. label:Hide()
  2442. label:ClearAllPoints()
  2443. label:SetPoint("CENTER", label:GetParent(), "CENTER", 0, 0)
  2444. mover:Show()
  2445. mover.attaching = nil
  2446. return true
  2447. end
  2448.  
  2449. function MovAny:DetachMover(mover)
  2450. mover.detaching = true
  2451. local f = mover.tagged
  2452. if mover.tagged and not mover.attaching and not f.MAHidden then
  2453. if mover.MAE and not mover.MAE.noMove and not mover.dontUpdate then
  2454. if mover.MAStartPoint then
  2455. self:MoverUpdatePosition(mover)
  2456. end
  2457. self.Position:Apply(mover.MAE, f)
  2458. end
  2459. if mover.createdTagged then
  2460. mover.tagged:Hide()
  2461. end
  2462. if f.OnMADetach then
  2463. f.OnMADetach(f, mover)
  2464. end
  2465. end
  2466. mover:Hide()
  2467. mover.tagged = nil
  2468. mover.attaching = nil
  2469. mover.infoShown = nil
  2470. mover.MAE = nil
  2471. mover.MAStartPoint = nil
  2472. mover.MAStartScale = nil
  2473. mover.dontUpdate = nil
  2474. if mover.tagged then
  2475. mover.tagged.MAMover = nil
  2476. end
  2477. for i, m in ipairs(self.movers) do
  2478. if m == mover then
  2479. tremove(self.movers, i)
  2480. end
  2481. end
  2482. if self.currentMover == mover then
  2483. self:NudgerChangeMover(1)
  2484. else
  2485. self:NudgerFrameRefresh()
  2486. end
  2487. mover.detaching = nil
  2488. end
  2489.  
  2490. function MovAny:StopMoving(fn)
  2491. local mover = self:GetMoverByFrame(fn)
  2492. if mover and not self:ErrorNotInCombat(_G[fn]) then
  2493. self:DetachMover(mover)
  2494. self:UpdateGUIIfShown()
  2495. end
  2496. end
  2497.  
  2498. function MovAny:ResetFrameConfirm(fn)
  2499. local f = _G[fn]
  2500. if InCombatLockdown() and self:IsProtected(f) then
  2501. self:ErrorNotInCombat(f)
  2502. return
  2503. end
  2504. if self.resetConfirm == fn and self.resetConfirmTime + 5 >= time() then
  2505. self.resetConfirm = nil
  2506. maPrint(string.format(MOVANY.RESETTING_FRAME, fn))
  2507. self:ResetFrame(fn)
  2508. return true
  2509. else
  2510. self.resetConfirm = fn
  2511. self.resetConfirmTime = time()
  2512. maPrint(string.format(MOVANY.RESET_FRAME_CONFIRM, fn))
  2513. end
  2514. end
  2515.  
  2516. function MovAny:ResetFrame(f, dontUpdate, readOnly)
  2517. if not f then
  2518. return
  2519. end
  2520. local fn
  2521. if type(f) == "string" then
  2522. fn = f
  2523. f = _G[fn]
  2524. elseif f and f.GetName then
  2525. fn = f:GetName()
  2526. end
  2527. if not fn then
  2528. return
  2529. end
  2530. if self:ErrorNotInCombat(f) or (InCombatLockdown() and f.UMFP) then
  2531. return
  2532. end
  2533. if not readOnly then
  2534. self:ShowFrame(f)
  2535. else
  2536. self:ShowFrame(f, true, true)
  2537. end
  2538. self:StopMoving(fn)
  2539. self.lastFrameName = fn
  2540. if not f then
  2541. if not readOnly then
  2542. self:ClearUserData(fn)
  2543. end
  2544. if not dontUpdate then
  2545. self:UpdateGUIIfShown(true)
  2546. end
  2547. return
  2548. end
  2549. local e = API:GetElement(fn)
  2550. local opt = e.userData or self:GetUserData(fn)
  2551. if opt == nil then
  2552. opt = { }
  2553. end
  2554. if f.MAHooked then
  2555. e:Reset(f, readOnly, opt)
  2556. end
  2557. if UIPanelWindows[fn] and (not self:IsProtected(f) or not InCombatLockdown()) then
  2558. self:SyncUIPanels()
  2559. end
  2560. if not readOnly then
  2561. e:SetUserData(nil)
  2562. self:ClearUserData(fn)
  2563. end
  2564. if f.attachedChildren then
  2565. table.wipe(f.attachedChildren)
  2566. end
  2567. if not dontUpdate then
  2568. if f:GetObjectType() ~= "Texture" and f:GetObjectType() ~= "FontString" then
  2569. f:SetMovable(true)
  2570. f:SetUserPlaced(false)
  2571. f:SetMovable(false)
  2572. end
  2573. self:UpdateGUIIfShown(true)
  2574. end
  2575. end
  2576.  
  2577. function MovAny:ToggleGUI()
  2578. if MAOptions:IsShown() then
  2579. MAOptions:Hide()
  2580. else
  2581. MAOptions:Show()
  2582. end
  2583. end
  2584.  
  2585. function MovAny:OnMoveCheck(button)
  2586. local fn = API:GetItem(button:GetParent().idx).name
  2587. if not self:ToggleMove(fn) then
  2588. local f = _G[fn]
  2589. if self:IsProtected(f) and not InCombatLockdown() then
  2590. button:SetChecked(nil)
  2591. end
  2592. end
  2593. end
  2594.  
  2595. function MovAny:OnHideCheck(button)
  2596. local fn = API:GetItem(button:GetParent().idx).name
  2597. if not self:ToggleHide(fn) then
  2598. local f = _G[fn]
  2599. if self:IsProtected(f) and not InCombatLockdown() then
  2600. button:SetChecked(nil)
  2601. end
  2602. end
  2603. end
  2604.  
  2605. function MovAny:OnResetCheck(button)
  2606. local fn = API:GetItem(button:GetParent().idx).name
  2607. local f = _G[fn]
  2608. if f then
  2609. if fn ~= f:GetName() then
  2610. fn = f:GetName()
  2611. f = _G[fn]
  2612. end
  2613. if MovAny:ErrorNotInCombat(f) then
  2614. return
  2615. end
  2616. end
  2617. MovAny:ResetFrame(f or fn)
  2618. end
  2619.  
  2620. function MovAny:HideFrame(f, readOnly)
  2621. if not self:IsModified(f) then
  2622. return
  2623. end
  2624. local fn
  2625. if type(f) == "string" then
  2626. fn = f
  2627. f = _G[fn]
  2628. end
  2629. if self:ErrorNotInCombat(f) then
  2630. return
  2631. end
  2632. if not f then
  2633. if self.lVirtualMovers[fn] then
  2634. f = self:CreateVM(fn)
  2635. else
  2636. return
  2637. end
  2638. end
  2639. if not fn then
  2640. fn = f:GetName()
  2641. end
  2642. API:AddElementIfNew(fn)
  2643. if fn == "PaladinPowerBarFrame" then
  2644. f:UnregisterAllEvents()
  2645. elseif fn == "CompactRaidFrameManager" then
  2646. f:UnregisterAllEvents()
  2647. CompactRaidFrameContainer:SetParent(UIParent)
  2648. elseif fn == "Boss1TargetFrame" or fn == "Boss2TargetFrame" or fn == "Boss3TargetFrame" or fn == "Boss4TargetFrame" or fn == "Boss5TargetFrame" then
  2649. f:UnregisterAllEvents()
  2650. f:Hide()
  2651. f.oldShow = f.Show
  2652. f.Show = function()
  2653. -- empty
  2654. end
  2655. elseif fn == "MicroButtonsMover" or fn == "MicroButtonsSplitMover" or fn == "MicroButtonsVerticalMover" or fn == "AchievementMicroButton" then
  2656. AchievementMicroButton.IsShown = function(self)
  2657. local opt = MovAny:GetUserData(fn)
  2658. if opt and opt.hidden then
  2659. return true
  2660. else
  2661. if self:IsShown() then
  2662. return true
  2663. else
  2664. return false
  2665. end
  2666. end
  2667. end
  2668. end
  2669. local e = API:GetElement(fn)
  2670. local mover = self:GetMoverByFrame(f)
  2671. if mover then
  2672. self:DetachMover(mover)
  2673. end
  2674. local opt
  2675. if readOnly then
  2676. opt = { }
  2677. else
  2678. opt = self:GetUserData(fn, nil, true)
  2679. opt.hidden = true
  2680. end
  2681. if not f then
  2682. return true
  2683. end
  2684. if not self:IsValidObject(f) or not self:HookFrame(e, f) or self:ErrorNotInCombat(f) then
  2685. return
  2686. end
  2687. f.MAWasShown = f:IsShown()
  2688. if f.GetAttribute then
  2689. opt.unit = f:GetAttribute("unit")
  2690. if opt.unit then
  2691. f:SetAttribute("unit", nil)
  2692. end
  2693. end
  2694. if e and e.hideList then
  2695. for hIndex, hideEntry in pairs(e.hideList) do
  2696. local val = _G[hideEntry[1]]
  2697. local hideType
  2698. for i = 2, table.getn(hideEntry) do
  2699. hideType = hideEntry[ i ]
  2700. if type(hideType) == "function" then
  2701. hideType(nil)
  2702. elseif hideType == "DISABLEMOUSE" then
  2703. val:EnableMouse(nil)
  2704. elseif hideType == "FRAME" then
  2705. self:LockVisibility(val)
  2706. elseif hideType == "WH" then
  2707. self:StopMoving(fn)
  2708. val:SetWidth(1)
  2709. val:SetHeight(1)
  2710. else
  2711. val:DisableDrawLayer(hideType)
  2712. end
  2713. end
  2714. end
  2715. elseif e and e.hideUsingWH then
  2716. self:StopMoving(fn)
  2717. f:SetWidth(1)
  2718. f:SetHeight(1)
  2719. self:LockVisibility(f)
  2720. else
  2721. self:LockVisibility(f)
  2722. end
  2723. if f.OnMAHide then
  2724. f.OnMAHide(f, true)
  2725. end
  2726. return true
  2727. end
  2728.  
  2729. function MovAny:ShowFrame(f, readOnly, dontHook)
  2730. local fn
  2731. if type(f) == "string" then
  2732. fn = f
  2733. f = _G[f]
  2734. end
  2735. if self:ErrorNotInCombat(f) then
  2736. return
  2737. end
  2738. if not f then
  2739. if self.lVirtualMovers[fn] then
  2740. f = self:CreateVM(fn)
  2741. else
  2742. return
  2743. end
  2744. end
  2745. if not fn then
  2746. fn = f:GetName()
  2747. end
  2748. API:AddElementIfNew(fn)
  2749. if fn == "PaladinPowerBarFrame" then
  2750. PaladinPowerBar.OnLoad(f)
  2751. elseif fn == "CompactRaidFrameManager" then
  2752. f:RegisterEvent("DISPLAY_SIZE_CHANGED")
  2753. f:RegisterEvent("UI_SCALE_CHANGED")
  2754. f:RegisterEvent("GROUP_ROSTER_UPDATE")
  2755. f:RegisterEvent("UNIT_FLAGS")
  2756. f:RegisterEvent("PLAYER_FLAGS_CHANGED")
  2757. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  2758. f:RegisterEvent("PARTY_LEADER_CHANGED")
  2759. f:RegisterEvent("RAID_TARGET_UPDATE")
  2760. f:RegisterEvent("PLAYER_TARGET_CHANGED")
  2761. CompactRaidFrameContainer:ClearAllPoints()
  2762. CompactRaidFrameContainer:SetParent(f)
  2763. MovAny:UnlockPoint(CompactRaidFrameContainer)
  2764. CompactRaidFrameContainer:SetPoint("TOPLEFT", CompactRaidFrameManagerContainerResizeFrame, "TOPLEFT", 4, - 7)
  2765. elseif fn == "Boss1TargetFrame" or fn == "Boss2TargetFrame" or fn == "Boss3TargetFrame" or fn == "Boss4TargetFrame" or fn == "Boss5TargetFrame" then
  2766. f.Show = f.oldShow
  2767. f.oldShow = nil
  2768. end
  2769. --[[local mover = self:GetMoverByFrame(f)
  2770. if mover then
  2771. if not string.find(e.name, "Mover") then
  2772. self:AttachMoverToFrame(mover, f)
  2773. end
  2774. end]]
  2775. local e = API:GetElement(fn)
  2776. local opt = self:GetUserData(fn, nil, true)
  2777. --[[if e and e.userData then
  2778. opt = e.userData
  2779. end]]
  2780. if not readOnly and opt then
  2781. opt.hidden = nil
  2782. opt.unit = nil
  2783. end
  2784. if not f then
  2785. self:VerifyFrameData(fn)
  2786. return true
  2787. end
  2788. if not self:IsValidObject(f) or (not dontHook and not self:HookFrame(e, f)) or self:ErrorNotInCombat(f) then
  2789. return
  2790. end
  2791. if opt ~= nil and opt.unit and f.SetAttribute then
  2792. f:SetAttribute("unit", opt.unit)
  2793. end
  2794. if e and e.hideList then
  2795. for hIndex, hideEntry in pairs(e.hideList) do
  2796. local val = _G[hideEntry[1]]
  2797. for i = 2, table.getn(hideEntry) do
  2798. local hideType = hideEntry[i]
  2799. if type(hideType) == "function" then
  2800. hideType(true)
  2801. elseif hideType == "DISABLEMOUSE" then
  2802. val:EnableMouse(true)
  2803. elseif hideType == "FRAME" then
  2804. self:UnlockVisibility(val)
  2805. elseif hideType == "WH" then
  2806. if type(opt.orgWidth) == "number" then
  2807. val:SetWidth(opt.orgWidth)
  2808. end
  2809. if type(opt.orgHeight) == "number" then
  2810. val:SetHeight(opt.orgHeight)
  2811. end
  2812. else
  2813. val:EnableDrawLayer(hideType)
  2814. end
  2815. end
  2816. end
  2817. self.Layers:Apply(e, f)
  2818. elseif e and e.hideUsingWH then
  2819. if type(opt.orgWidth) == "number" then
  2820. f:SetWidth(opt.orgWidth)
  2821. end
  2822. if type(opt.orgHeight) == "number" then
  2823. f:SetHeight(opt.orgHeight)
  2824. end
  2825. self:UnlockVisibility(f)
  2826. else
  2827. self:UnlockVisibility(f)
  2828. end
  2829. if f.OnMAHide then
  2830. f.OnMAHide(f, nil)
  2831. end
  2832. self:VerifyFrameData(fn)
  2833. return true
  2834. end
  2835.  
  2836. function MovAny:OnCheckToggleCategories(button)
  2837. local state = button:GetChecked()
  2838. if state then
  2839. self.collapsed = true
  2840. else
  2841. self.collapsed = nil
  2842. end
  2843. for i, v in pairs(API.cats) do
  2844. v.collapsed = state
  2845. end
  2846. self:UpdateGUIIfShown(true)
  2847. end
  2848.  
  2849. function MovAny:OnCheckToggleModifiedFramesOnly(button)
  2850. local state = button:GetChecked()
  2851. if state then
  2852. MADB.modifiedFramesOnly = true
  2853. else
  2854. MADB.modifiedFramesOnly = nil
  2855. end
  2856. self:UpdateGUIIfShown(true)
  2857. end
  2858.  
  2859. function MovAny:GroupMove(sender, groups, x, y)
  2860. local f, e, mover
  2861. for g in pairs(groups) do
  2862. for fn, opt in pairs(self.userData) do
  2863. if fn ~= sender.name and type(opt.groups) == "table" and opt.groups[g] and type(opt.pos) == "table" then
  2864. f = _G[fn]
  2865. if f then
  2866. mover = self:GetMoverByFrame(f)
  2867. if mover then
  2868. mover.attaching = true
  2869. self:DetachMover(mover)
  2870. end
  2871. e = API:GetElement(fn)
  2872. if e and e:IsModified("pos") then
  2873. opt.pos[4] = opt.pos[4] + (x / f:GetScale())
  2874. opt.pos[5] = opt.pos[5] + (y / f:GetScale())
  2875. self.Position:Apply(e, f)
  2876. end
  2877. if mover then
  2878. self:AttachMover(fn)
  2879. end
  2880. end
  2881. end
  2882. end
  2883. end
  2884. end
  2885.  
  2886. function MovAny:GroupScale(sender, groups, scaleMod, scale, dir)
  2887. local f, e, mover
  2888. for g in pairs(groups) do
  2889. for fn, opt in pairs(self.userData) do
  2890. if fn ~= sender.name and type(opt.groups) == "table" and opt.groups[g] then
  2891. f = _G[fn]
  2892. if f then
  2893. mover = self:GetMoverByFrame(f)
  2894. if mover then
  2895. self:DetachMover(mover)
  2896. end
  2897. end
  2898. e = API:GetElement(fn)
  2899. local orgScale = opt.scale or (f and f:GetScale() or 1)
  2900. if not e.scaleWH then
  2901. if opt.pos then
  2902. opt.pos[4] = opt.pos[4] * orgScale
  2903. opt.pos[5] = opt.pos[5] * orgScale
  2904. end
  2905. opt.scale = orgScale + scaleMod
  2906. if opt.pos then
  2907. opt.pos[4] = opt.pos[4] / opt.scale
  2908. opt.pos[5] = opt.pos[5] / opt.scale
  2909. end
  2910. else
  2911. if f then
  2912. if type(opt.orgWidth) ~= "number" then
  2913. opt.orgWidth = f:GetWidth()
  2914. end
  2915. if type(opt.orgHeight) ~= "number" then
  2916. opt.orgHeight = f:GetHeight()
  2917. end
  2918. end
  2919. if dir == 0 then
  2920. if type(opt.width) ~= "number" then
  2921. opt.width = opt.orgWidth
  2922. end
  2923. if type(opt.width) == "number" then
  2924. opt.width = opt.width * (1 + scaleMod)
  2925. end
  2926. elseif dir == 1 then
  2927. if type(opt.height) ~= "number" then
  2928. opt.height = opt.orgHeight
  2929. end
  2930. if type(opt.height) == "number" then
  2931. opt.height = opt.height * (1 + scaleMod)
  2932. end
  2933. end
  2934. end
  2935. if f then
  2936. self.Scale:Apply(e, f)
  2937. if opt.pos then
  2938. self.Position:Apply(e, f)
  2939. end
  2940. if mover then
  2941. self:AttachMover(fn)
  2942. end
  2943. end
  2944. end
  2945. end
  2946. end
  2947. end
  2948.  
  2949. function MovAny:GroupAlpha(sender, groups, alphaMod, alpha)
  2950. local f, e, fAlpha, mover
  2951. for g in pairs(groups) do
  2952. for fn, opt in pairs(self.userData) do
  2953. if fn ~= sender.name and type(opt.groups) == "table" and opt.groups[g] then
  2954. f = _G[fn]
  2955. if f then
  2956. mover = self:GetMoverByFrame(f)
  2957. if mover then
  2958. self:DetachMover(mover)
  2959. end
  2960. end
  2961. e = API:GetElement(fn)
  2962. if not opt.alpha then
  2963. fAlpha = (f and (f.GetAlpha and f:GetAlpha() or 1) + alphaMod) or alpha
  2964. else
  2965. fAlpha = opt.alpha + alphaMod
  2966. end
  2967. if fAlpha < 0 then
  2968. fAlpha = 0
  2969. elseif fAlpha > 1 then
  2970. fAlpha = 1
  2971. end
  2972. opt.alpha = fAlpha
  2973. self.Alpha:Apply(e, f)
  2974. if mover then
  2975. self:AttachMover(fn)
  2976. end
  2977. end
  2978. end
  2979. end
  2980. end
  2981.  
  2982. function MovAny:GroupBackdropAlpha(sender, groups, alphaMod, alpha)
  2983. local f, e, fAlpha, mover
  2984. for g in pairs(groups) do
  2985. for fn, opt in pairs(self.userData) do
  2986. if fn ~= sender.name and type(opt.groups) == "table" and opt.groups[g] then
  2987. f = _G[fn]
  2988. if f then
  2989. mover = self:GetMoverByFrame(f)
  2990. if mover then
  2991. self:DetachMover(mover)
  2992. end
  2993. end
  2994. e = API:GetElement(fn)
  2995. if not opt.backdropAlpha then
  2996. local _
  2997. _, _, _, fAlpha = f:GetBackdropColor()
  2998. fAlpha = fAlpha or alpha
  2999. else
  3000. fAlpha = opt.backdropAlpha + alphaMod
  3001. end
  3002. if fAlpha < 0 then
  3003. fAlpha = 0
  3004. elseif fAlpha > 1 then
  3005. fAlpha = 1
  3006. end
  3007. opt.backdropAlpha = fAlpha
  3008. self.Alpha:Apply(e, f)
  3009. if mover then
  3010. self:AttachMover(fn)
  3011. end
  3012. end
  3013. end
  3014. end
  3015. end
  3016.  
  3017. function MovAny:GroupLayers(sender, groups, layer, opt)
  3018. local f, e
  3019. for g in pairs(groups) do
  3020. for fn, fOpt in pairs(self.userData) do
  3021. if fn ~= sender.name and fOpt.groups and fOpt.groups[g] then
  3022. f = _G[fn]
  3023. if f then
  3024. e = API:GetElement(fn)
  3025. self.Layers:Reset(e, f, true, fOpt)
  3026. end
  3027. fOpt[layer] = opt[layer]
  3028. if f then
  3029. self.Layers:Apply(e, f, fOpt)
  3030. end
  3031. end
  3032. end
  3033. end
  3034. end
  3035.  
  3036. function MovAny:MoverUpdatePosition(mover)
  3037. if mover.attaching then
  3038. return
  3039. end
  3040. if mover.tagged then
  3041. if not mover.MAE or mover.MAE.noMove then
  3042. return
  3043. end
  3044. local f = mover.tagged
  3045. local opt = mover.MAE.userData
  3046. local p = self:GetRelativePoint({"BOTTOMLEFT", "UIParent", "BOTTOMLEFT"}, f)
  3047. if mover.MAStartPoint and (mover.MAStartPoint[1] == p[1] and mover.MAStartPoint[2] == p[2] and mover.MAStartPoint[3] == p[3] and (mover.MAStartPoint[4] * (mover.MAStartScale or 1)) == p[4] and (mover.MAStartPoint[5] * (mover.MAStartScale or 1)) == p[5]) then
  3048. return
  3049. end
  3050. p = self:GetRelativePoint(opt.pos or self.Position:GetFirstOrgPoint(opt) or {"BOTTOMLEFT", "UIParent", "BOTTOMLEFT"}, f)
  3051. if not skipGroups and opt.groups and not IsShiftKeyDown() then
  3052. local _, _, _, x, y = unpack(self:GetRelativePoint(p, f, true))
  3053. x = x - opt.pos[4]
  3054. y = y - opt.pos[5]
  3055. if not mover.MAE.scaleWH then
  3056. x = x * (opt.scale or (f.GetScale and f:GetScale()) or 1)
  3057. y = y * (opt.scale or (f.GetScale and f:GetScale()) or 1)
  3058. end
  3059. MovAny:GroupMove(mover.MAE, opt.groups, x, y)
  3060. end
  3061. opt.pos = p
  3062. table.wipe(mover.MAStartPoint)
  3063. for i = 1, 5, 1 do
  3064. mover.MAStartPoint[i] = p[i]
  3065. end
  3066. if f.OnMAPosition then
  3067. f:OnMAPosition()
  3068. end
  3069. self:UpdateGUIIfShown()
  3070. end
  3071. end
  3072.  
  3073. function MovAny:MoverOnSizeChanged(mover)
  3074. if mover.attaching or mover.detaching then
  3075. return
  3076. end
  3077. if mover.tagged then
  3078. local s, w, h, f, opt
  3079. f = mover.tagged
  3080. local opt = mover.MAE.userData
  3081. if mover.MAE.scaleWH then
  3082. if opt.width ~= mover:GetWidth() or opt.height ~= mover:GetHeight() then
  3083. if not mover.skipGroups and opt.groups and not IsShiftKeyDown() then
  3084. local dir = mover:GetHeight() ~= opt.height and 1 or 0
  3085. if dir == 0 then
  3086. s = mover:GetWidth() / f:GetWidth()
  3087. s = s / MAGetScale(f:GetParent(), 1 ) * UIParent:GetScale()
  3088. else
  3089. s = mover:GetHeight() / f:GetHeight()
  3090. s = s / MAGetScale(f:GetParent(), 1 ) * UIParent:GetScale()
  3091. end
  3092. self:GroupScale(mover.MAE, opt.groups, s - 1, s, dir)
  3093. end
  3094. opt.width = mover:GetWidth()
  3095. opt.height = mover:GetHeight()
  3096. self.Scale:Apply(mover.MAE, f, opt)
  3097. mover.skipGroups = true
  3098. self:MoverUpdatePosition(mover)
  3099. mover.skipGroups = nil
  3100. end
  3101. else
  3102. if mover.MASizingAnchor == "LEFT" or mover.MASizingAnchor == "RIGHT" then
  3103. w = mover:GetWidth()
  3104. h = w * (f:GetHeight() / f:GetWidth())
  3105. if h < 8 then
  3106. h = 8
  3107. w = h * (f:GetWidth() / f:GetHeight())
  3108. end
  3109. else
  3110. h = mover:GetHeight()
  3111. w = h * (f:GetWidth() / f:GetHeight())
  3112. if w < 8 then
  3113. w = 8
  3114. h = w * (f:GetHeight() / f:GetWidth())
  3115. end
  3116. end
  3117. s = mover:GetWidth() / f:GetWidth()
  3118. s = s / MAGetScale(f:GetParent(), 1) * UIParent:GetScale()
  3119. if s > 0.991 and s < 1 then
  3120. s = 1
  3121. end
  3122. if f.GetScale and s ~= f:GetScale() then
  3123. if not mover.skipGroups and opt.groups and not IsShiftKeyDown() then
  3124. self:GroupScale(mover.MAE, opt.groups, s - (opt.scale or f:GetScale()), s)
  3125. end
  3126. opt.scale = s
  3127. self.Scale:Apply(mover.MAE, f)
  3128. --self:MoverUpdatePosition(mover)
  3129. mover.skipGroups = true
  3130. self:MoverUpdatePosition(mover)
  3131. mover.skipGroups = nil
  3132. end
  3133. mover:SetWidth(w)
  3134. mover:SetHeight(h)
  3135. local label = _G[ mover:GetName().."BackdropInfoLabel"]
  3136. label:SetWidth(w+100)
  3137. label:SetHeight(h)
  3138. end
  3139. local label = _G[ mover:GetName().."BackdropInfoLabel"]
  3140. label:ClearAllPoints()
  3141. label:SetPoint("TOP", label:GetParent(), "TOP", 0, 0)
  3142. local brief, long
  3143. if MovAny.Scale:CanBeScaled(f) then
  3144. if mover.MAE.scaleWH then
  3145. brief = "W: "..MANumFor(f:GetWidth()).." H:"..MANumFor(f:GetHeight())
  3146. long = brief
  3147. else
  3148. brief = MANumFor(f:GetScale())
  3149. long = "Scale: "..brief
  3150. end
  3151. label:Show()
  3152. label:SetText(brief)
  3153. if mover == self.currentMover then
  3154. _G[ "MANudgerInfoLabel"]:Show()
  3155. _G[ "MANudgerInfoLabel"]:SetText(long)
  3156. end
  3157. end
  3158. label = _G[ mover:GetName().."BackdropMovingFrameName" ]
  3159. label:ClearAllPoints()
  3160. label:SetPoint("TOP", label:GetParent(), "TOP", 0, 20)
  3161. self:UpdateGUIIfShown(true)
  3162. end
  3163. end
  3164.  
  3165. function MovAny:MoverOnMouseWheel(mover, arg1)
  3166. if not mover.tagged or mover.MAE.noAlpha then
  3167. return
  3168. end
  3169. local alpha
  3170. if IsAltKeyDown() then
  3171. local r, g, b
  3172. r, g, b, alpha = mover.tagged:GetBackdropColor()
  3173. alpha = alpha or 1
  3174. else
  3175. alpha = mover.tagged:GetAlpha()
  3176. end
  3177. if type(alpha) ~= "number" then
  3178. return
  3179. end
  3180. local alphaMod
  3181. if arg1 > 0 then
  3182. alphaMod = 0.05
  3183. else
  3184. alphaMod = - 0.05
  3185. end
  3186. alpha = alpha + alphaMod
  3187. if alpha < 0 then
  3188. alpha = 0
  3189. mover.tagged.alphaAttempts = nil
  3190. elseif alpha > 0.99 then
  3191. alpha = 1
  3192. mover.tagged.alphaAttempts = nil
  3193. elseif alpha > 0.92 then
  3194. if not mover.tagged.alphaAttempts then
  3195. mover.tagged.alphaAttempts = 1
  3196. elseif mover.tagged.alphaAttempts > 2 then
  3197. alpha = 1
  3198. mover.tagged.alphaAttempts = nil
  3199. else
  3200. mover.tagged.alphaAttempts = mover.tagged.alphaAttempts + 1
  3201. end
  3202. else
  3203. mover.tagged.alphaAttempts = nil
  3204. end
  3205. alpha = tonumber(MANumFor(alpha))
  3206. local opt = mover.MAE.userData
  3207. if IsAltKeyDown() then
  3208. if not mover.skipGroups and opt.groups and not IsShiftKeyDown() then
  3209. self:GroupBackdropAlpha(mover.MAE, opt.groups, alphaMod, alpha)
  3210. end
  3211. opt.backdropAlpha = alpha
  3212. if opt.backdropAlpha == opt.orgBackdropAlpha then
  3213. opt.backdropAlpha = nil
  3214. opt.orgBackdropAlpha = nil
  3215. end
  3216. else
  3217. if not mover.skipGroups and opt.groups and not IsShiftKeyDown() then
  3218. self:GroupAlpha(mover.MAE, opt.groups, alphaMod, alpha)
  3219. end
  3220. opt.alpha = alpha
  3221. if opt.alpha == opt.orgAlpha then
  3222. opt.alpha = nil
  3223. opt.orgAlpha = nil
  3224. end
  3225. end
  3226. self.Alpha:Apply(mover.tagged.MAE, mover.tagged)
  3227. local label = _G[ mover:GetName().."BackdropInfoLabel"]
  3228. label:Show()
  3229. label:SetText(MANumFor(alpha * 100).."%")
  3230. if mover == self.currentMover then
  3231. _G["MANudgerInfoLabel"]:Show()
  3232. _G["MANudgerInfoLabel"]:SetText("Alpha:"..MANumFor(alpha * 100).."%")
  3233. end
  3234. self:UpdateGUIIfShown(true)
  3235. end
  3236.  
  3237. function MovAny:CompleteReset()
  3238. for i, v in pairs(self.userData) do
  3239. self:ResetFrame(v.name, true, true)
  3240. end
  3241. self:ReanchorRelatives()
  3242. if MADB.squareMM then
  3243. Minimap:SetMaskTexture("Textures\\MinimapMask")
  3244. end
  3245. MADB = {
  3246. collapsed = true,
  3247. frameListRows = 18,
  3248. tooltips = true,
  3249. }
  3250. MADB.profiles = { }
  3251. MADB.characters = { }
  3252. self.userData = { }
  3253. MADB.profiles[self:GetProfileName()] = {frames = self.userData}
  3254. MAOptionsToggleCategories:SetChecked(true)
  3255. MovAny:OnCheckToggleCategories(MAOptionsToggleCategories)
  3256. MovAny_OptionsOnShow()
  3257. self:UpdateGUIIfShown(true)
  3258. end
  3259.  
  3260. function MovAny:OnShow()
  3261. if MADB.playSound then
  3262. PlaySound(850)
  3263. end
  3264. MADB.autoShowNext = true
  3265. MANudger:Show()
  3266. self:NudgerFrameRefresh()
  3267. self:UpdateGUI()
  3268. for i, v in pairs(self.lEnableMouse) do
  3269. if v and v.EnableMouse and (not MovAny:IsProtected(v) or not InCombatLockdown()) then
  3270. v:EnableMouse(true)
  3271. end
  3272. end
  3273. end
  3274.  
  3275. function MovAny:OnHide()
  3276. if MADB.playSound then
  3277. PlaySound(851)
  3278. end
  3279. MADB.autoShowNext = nil
  3280. if not self.currentMover then
  3281. MANudger:Hide()
  3282. end
  3283. for i, v in pairs(self.lEnableMouse) do
  3284. if v and v.EnableMouse and (not MovAny:IsProtected(v) or not InCombatLockdown()) then
  3285. v:EnableMouse(nil)
  3286. end
  3287. end
  3288. end
  3289.  
  3290. function MovAny:RowTitleClicked(title)
  3291. local o = API:GetItem(MAGetParent(title).idx)
  3292. if o.elems then
  3293. if o.collapsed then
  3294. o.collapsed = nil
  3295. else
  3296. o.collapsed = true
  3297. end
  3298. self:UpdateGUI(1)
  3299. else
  3300. if self.FrameEditor then
  3301. self:FrameEditor(o.name)
  3302. end
  3303. end
  3304. end
  3305.  
  3306. local uiDisplayedFrameNames = { }
  3307.  
  3308. function MovAny:CountGUIItems()
  3309. if API.compile then
  3310. API:CompileList()
  3311. end
  3312. local items = 0
  3313. local curCatItems = 0
  3314. local curCat = nil
  3315. if self.searchWord and self.searchWord ~= "" then
  3316. local uiDisplayedFrameNames = { }
  3317. for i, o in pairs(API.all) do
  3318. if not o.elems and not uiDisplayedFrameNames[o.name] then
  3319. if (not MADB.dontSearchFrameNames and string.match(string.lower(tostring(o.name)), self.searchWord)) or (o.displayName and string.match(string.lower(tostring(o.displayName)), self.searchWord)) then
  3320. if MADB.modifiedFramesOnly then
  3321. if MovAny:IsModified(o.name) then
  3322. uiDisplayedFrameNames[o.name] = 1
  3323. items = items + 1
  3324. end
  3325. else
  3326. uiDisplayedFrameNames[o.name] = 1
  3327. items = items + 1
  3328. end
  3329. end
  3330. end
  3331. end
  3332. else
  3333. for i, o in pairs(API.all) do
  3334. if o.elems then
  3335. if curCat then
  3336. curCat.items = curCatItems
  3337. curCatItems = 0
  3338. end
  3339. curCat = o
  3340. elseif not o.hidden then
  3341. if MADB.modifiedFramesOnly then
  3342. if MovAny:IsModified(o.name) then
  3343. curCatItems = curCatItems + 1
  3344. end
  3345. else
  3346. curCatItems = curCatItems + 1
  3347. end
  3348. end
  3349. end
  3350. if curCat then
  3351. curCat.items = curCatItems
  3352. end
  3353. for i, o in pairs(API.all) do
  3354. if o.elems then
  3355. if not MADB.modifiedFramesOnly then
  3356. if o.collapsed then
  3357. items = items + 1
  3358. else
  3359. items = items + o.items + 1
  3360. end
  3361. else
  3362. if o.items > 0 then
  3363. if o.collapsed then
  3364. items = items + 1
  3365. else
  3366. items = items + o.items + 1
  3367. end
  3368. end
  3369. end
  3370. end
  3371. end
  3372. end
  3373. self.guiLines = items
  3374. end
  3375.  
  3376. function MovAny:UpdateGUI(recount)
  3377. if recount or MovAny.guiLines == - 1 then
  3378. MovAny:CountGUIItems()
  3379. end
  3380. FauxScrollFrame_Update(MAScrollFrame, MovAny.guiLines, MADB.frameListRows, MovAny.SCROLL_HEIGHT)
  3381. local topOffset = FauxScrollFrame_GetOffset(MAScrollFrame)
  3382. local displayList = { }
  3383. local lastCat = nil
  3384. local uiDisplayedFrameNames = { }
  3385. if MovAny.searchWord and MovAny.searchWord ~= "" then
  3386. local results = { }
  3387. local skip = topOffset
  3388. for i, o in pairs(API.all) do
  3389. if not o.elems and not uiDisplayedFrameNames[o.name] then
  3390. if (not MADB.dontSearchFrameNames and string.match(string.lower(o.name), MovAny.searchWord)) or (o.displayName and string.match(string.lower(o.displayName), MovAny.searchWord)) then
  3391. if MADB.modifiedFramesOnly then
  3392. if o:IsModified() then
  3393. uiDisplayedFrameNames[o.name] = 1
  3394. tinsert(results, o)
  3395. end
  3396. else
  3397. uiDisplayedFrameNames[o.name] = 1
  3398. tinsert(results, o)
  3399. end
  3400. end
  3401. end
  3402. end
  3403. table.sort(results, function(o1,o2)
  3404. return o1.displayName:lower() < o2.displayName:lower()
  3405. end)
  3406. for i, o in pairs(results) do
  3407. if skip > 0 then
  3408. skip = skip - 1
  3409. else
  3410. tinsert(displayList, o)
  3411. end
  3412. end
  3413. results = nil
  3414. else
  3415. local startOffset = 0
  3416. local hidden = 0
  3417. local shown = 0
  3418. for i, o in pairs(API.all) do
  3419. if startOffset == 0 and shown >= topOffset then
  3420. startOffset = topOffset + hidden
  3421. break
  3422. end
  3423. if o.elems then
  3424. lastCat = o
  3425. if o.items == 0 then
  3426. hidden = hidden + 1
  3427. else
  3428. shown = shown + 1
  3429. end
  3430. else
  3431. if lastCat and lastCat.collapsed then
  3432. else
  3433. if lastCat.items > 0 then
  3434. shown = shown + 1
  3435. else
  3436. hidden = hidden + 1
  3437. end
  3438. end
  3439. end
  3440. end
  3441. if startOffset ~= 0 then
  3442. -- X: fix off by one
  3443. if startOffset > 0 then
  3444. startOffset = startOffset + 1
  3445. end
  3446. end
  3447. local sepOffset, wtfOffset
  3448. sepOffset = 0
  3449. wtfOffset = 0
  3450. local skip = topOffset
  3451. for i = 1, MADB.frameListRows, 1 do
  3452. local index = i + sepOffset + wtfOffset
  3453. local o
  3454. -- forward to next shown element
  3455. while true do
  3456. if index > API.allCount then
  3457. o = nil
  3458. break
  3459. end
  3460. o = API.all[ index ]
  3461. if o.elems then
  3462. lastCat = o
  3463. if o.items > 0 then
  3464. if skip > 0 then
  3465. index = index + 1
  3466. wtfOffset = wtfOffset + 1
  3467. skip = skip -1
  3468. else
  3469. if o.elems and o.collapsed then
  3470. sepOffset = sepOffset + o.items
  3471. end
  3472. break
  3473. end
  3474. else
  3475. index = index + 1
  3476. wtfOffset = wtfOffset + 1
  3477. end
  3478. else
  3479. local c = lastCat or o:GetCategory()
  3480. if c.collapsed then
  3481. index = index + 1
  3482. wtfOffset = wtfOffset + 1
  3483. else
  3484. if MADB.modifiedFramesOnly then
  3485. if MovAny:IsModified(o.name) then
  3486. if skip > 0 then
  3487. index = index + 1
  3488. wtfOffset = wtfOffset + 1
  3489. skip = skip -1
  3490. else
  3491. break
  3492. end
  3493. else
  3494. index = index + 1
  3495. wtfOffset = wtfOffset + 1
  3496. end
  3497. else
  3498. if skip > 0 then
  3499. index = index + 1
  3500. wtfOffset = wtfOffset + 1
  3501. skip = skip -1
  3502. else
  3503. break
  3504. end
  3505. end
  3506. end
  3507. end
  3508. end
  3509. if o then
  3510. tinsert(displayList, o)
  3511. else
  3512. break
  3513. end
  3514. end
  3515. end
  3516. local prefix, move, backdrop, hide
  3517. prefix = "MAMove"
  3518. move = "Move"
  3519. hide = "Hide"
  3520. local skip = topOffset
  3521. for i = 1, MADB.frameListRows, 1 do
  3522. local o = displayList[i]
  3523. local row = _G[ prefix..i ]
  3524. if not o then
  3525. row:Hide()
  3526. else
  3527. local fn = o.name
  3528. local opts = o.userData
  3529. local moveCheck = _G[ prefix..i..move ]
  3530. local hideCheck = _G[ prefix..i..hide ]
  3531. local text, frameNameLabel
  3532. local idx = o:GetAllIndex()
  3533. frameNameLabel = _G[ prefix..i.."FrameName" ]
  3534. if not frameNameLabel then
  3535. break
  3536. end
  3537. frameNameLabel.idx = idx
  3538. row.idx = idx
  3539. row.name = o.name
  3540. row:Show()
  3541. if o.elems then
  3542. text = _G[ prefix..i.."FrameNameText" ]
  3543. text:Hide()
  3544. text = _G[ prefix..i.."FrameNameHighlight" ]
  3545. text:Show()
  3546. if o.collapsed and o.items > 0 then
  3547. text:SetText("+ "..o.name)
  3548. else
  3549. text:SetText(" "..o.name)
  3550. end
  3551. frameNameLabel.tooltipLines = nil
  3552. else
  3553. text = _G[ prefix..i.."FrameNameHighlight" ]
  3554. text:Hide()
  3555. text = _G[ prefix..i.."FrameNameText" ]
  3556. text:Show()
  3557. text:SetText((opts and opts.disabled and "*" or "")..o.displayName)
  3558. end
  3559. if not o.unsupported and not o.elems and fn then
  3560. _G[ prefix..i.."Backdrop" ]:Show()
  3561. if o.noMove and o.noScale and o.noAlpha then
  3562. moveCheck:Hide()
  3563. else
  3564. moveCheck:SetChecked(MovAny:GetMoverByFrame(fn) and 1 or nil)
  3565. moveCheck:Show()
  3566. end
  3567. if o.noHide then
  3568. hideCheck:Hide()
  3569. else
  3570. hideCheck:SetChecked(opts and opts.hidden or nil)
  3571. hideCheck:Show()
  3572. end
  3573. if MovAny:IsModified(fn) then
  3574. _G[ prefix..i.."Reset" ]:Show()
  3575. else
  3576. _G[ prefix..i.."Reset" ]:Hide()
  3577. end
  3578. else
  3579. _G[ prefix..i.."Backdrop" ]:Hide()
  3580. moveCheck:Hide()
  3581. hideCheck:Hide()
  3582. _G[ prefix..i.."Reset" ]:Hide()
  3583. end
  3584. end
  3585. end
  3586. MAOptionsToggleCategories:SetChecked(MovAny.collapsed)
  3587. MAOptionsToggleModifiedFramesOnly:SetChecked(MADB.modifiedFramesOnly)
  3588. if MovAny.searchWord and MovAny.searchWord ~= "" then
  3589. MAOptionsFrameNameHeader:SetText(string.format(MOVANY.LIST_HEADING_SEARCH_RESULTS, MovAny.guiLines))
  3590. else
  3591. MAOptionsFrameNameHeader:SetText(MOVANY.LIST_HEADING_CATEGORY_AND_FRAMES)
  3592. end
  3593. MovAny:TooltipHide()
  3594. end
  3595.  
  3596. function MovAny:UpdateGUIIfShown(recount, dontUpdateEditors)
  3597. if recount then
  3598. self.guiLines = - 1
  3599. end
  3600. if MAOptions and MAOptions:IsShown() then
  3601. self:UpdateGUI()
  3602. end
  3603. if not dontUpdateEditors then
  3604. for fn, fe in pairs(self.frameEditors) do
  3605. if fe:IsShown() and not fe.updating then
  3606. fe:UpdateEditor()
  3607. end
  3608. end
  3609. end
  3610. if self.portDlg and self.portDlg:IsShown() then
  3611. self.portDlg:Reload()
  3612. end
  3613. end
  3614.  
  3615. function MovAny:NudgerChangeMover(dir)
  3616. local p
  3617. local first, sel
  3618. local cur = self.currentMover
  3619. local matchNext = false
  3620. for i, m in ipairs(self.movers) do
  3621. if not first then
  3622. first = m
  3623. end
  3624. if matchNext then
  3625. self.currentMover = m
  3626. matchNext = nil
  3627. break
  3628. end
  3629. if m == cur then
  3630. if dir < 0 then
  3631. if first == m then
  3632. for i2, m2 in ipairs(self.movers) do
  3633. sel = m2
  3634. end
  3635. self.currentMover = sel
  3636. else
  3637. self.currentMover = p
  3638. end
  3639. break
  3640. else
  3641. matchNext = true
  3642. end
  3643. end
  3644. p = m
  3645. end
  3646. if matchNext then
  3647. self.currentMover = first
  3648. end
  3649. self:NudgerFrameRefresh()
  3650. end
  3651.  
  3652. function MovAny:GetFirstMover()
  3653. for i, m in ipairs(self.movers) do
  3654. if m and m.IsShown and m:IsShown() then
  3655. return m
  3656. end
  3657. end
  3658. return nil
  3659. end
  3660.  
  3661. function MovAny:MoverOnShow(mover)
  3662. local mn = mover:GetName()
  3663. MANudger:Show()
  3664. self.currentMover = mover
  3665. self:NudgerFrameRefresh()
  3666. mover.startAlpha = mover.tagged:GetAlpha()
  3667. _G[mn.."Backdrop"]:Show()
  3668. _G[mn.."BackdropMovingFrameName"]:SetText(mover.displayName)
  3669. if not mover.tagged or not MovAny.Scale:CanBeScaled(mover.tagged) then
  3670. _G[mn.."Resize_TOP"]:Hide()
  3671. _G[mn.."Resize_LEFT"]:Hide()
  3672. _G[mn.."Resize_BOTTOM"]:Hide()
  3673. _G[mn.."Resize_RIGHT"]:Hide()
  3674. else
  3675. _G[mn.."Resize_TOP"]:Show()
  3676. _G[mn.."Resize_LEFT"]:Show()
  3677. _G[mn.."Resize_BOTTOM"]:Show()
  3678. _G[mn.."Resize_RIGHT"]:Show()
  3679. end
  3680. _G[ mn.."BackdropInfoLabel"]:SetText("")
  3681. if mover == self.currentMover then
  3682. _G[ "MANudgerInfoLabel"]:SetText("")
  3683. end
  3684. end
  3685.  
  3686. function MovAny:MoverOnHide()
  3687. local firstMover = self:GetFirstMover()
  3688. if not MADB.alwaysShowNudger and firstMover == nil then
  3689. MANudger:Hide()
  3690. else
  3691. self.currentMover = firstMover
  3692. self:NudgerFrameRefresh()
  3693. end
  3694. end
  3695.  
  3696. function MovAny:NudgerOnShow()
  3697. if not MADB.alwaysShowNudger then
  3698. local firstMover = self:GetFirstMover()
  3699. if firstMover == nil then
  3700. MANudger:Hide()
  3701. return
  3702. end
  3703. end
  3704. self:NudgerFrameRefresh()
  3705. end
  3706.  
  3707. function MovAny:NudgerFrameRefresh()
  3708. local labelText = ""
  3709. if self.currentMover ~= nil then
  3710. local cur = 0
  3711. for i, m in ipairs(self.movers) do
  3712. cur = cur + 1
  3713. if m == self.currentMover then
  3714. break
  3715. end
  3716. end
  3717. local f = self.currentMover.tagged
  3718. if f then
  3719. labelText = cur.." / "..#self.movers
  3720. local fn = f:GetName()
  3721. if fn then
  3722. labelText = labelText.."\n"..fn
  3723. MANudger.idx = API:GetElement(fn).idx
  3724. if self.currentMover.MAE and self.currentMover.MAE.noHide then
  3725. MANudger_Hide:Hide()
  3726. else
  3727. MANudger_Hide:Show()
  3728. end
  3729. end
  3730. end
  3731. end
  3732. local moverCount = #self.movers
  3733. if moverCount > 0 then
  3734. MANudger_CenterH:Show()
  3735. MANudger_CenterV:Show()
  3736. MANudger_NudgeLeft:Show()
  3737. MANudger_NudgeUp:Show()
  3738. MANudger_NudgeDown:Show()
  3739. MANudger_NudgeRight:Show()
  3740. MANudger_CenterMe:Show()
  3741. MANudger_Detach:Show()
  3742. MANudger_Hide:Show()
  3743. MANudgerMouseOver:ClearAllPoints()
  3744. MANudgerMouseOver:SetPoint("BOTTOM", MANudger, "BOTTOM", 0, 6)
  3745. MANudgerInfoLabel:Show()
  3746. if #self.movers > 1 then
  3747. MANudger_MoverMinus:Show()
  3748. MANudger_MoverPlus:Show()
  3749. else
  3750. MANudger_MoverMinus:Hide()
  3751. MANudger_MoverPlus:Hide()
  3752. end
  3753. else
  3754. MANudger_CenterH:Hide()
  3755. MANudger_CenterV:Hide()
  3756. MANudger_NudgeLeft:Hide()
  3757. MANudger_NudgeUp:Hide()
  3758. MANudger_NudgeDown:Hide()
  3759. MANudger_NudgeRight:Hide()
  3760. MANudger_CenterMe:Hide()
  3761. MANudger_Detach:Hide()
  3762. MANudger_Hide:Hide()
  3763. MANudgerMouseOver:ClearAllPoints()
  3764. MANudgerMouseOver:SetPoint("CENTER", MANudger, "CENTER", 0, 0)
  3765. MANudgerInfoLabel:Hide()
  3766. MANudgerInfoLabel:SetText("")
  3767. MANudger_MoverMinus:Hide()
  3768. MANudger_MoverPlus:Hide()
  3769. end
  3770. MANudgerTitle:SetText(labelText)
  3771. end
  3772.  
  3773. function MovAny:NudgerOnUpdate()
  3774. local obj = GetMouseFocus()
  3775. local text = ""
  3776. local text2 = ""
  3777. local label = MANudgerMouseOver
  3778. local labelSafe = MANudgerMouseOver
  3779. local name
  3780. if obj and obj ~= WorldFrame and obj:GetName() then
  3781. local objTest = self:GetDefaultFrameParent(obj)
  3782. if objTest then
  3783. name = objTest:GetName()
  3784. if name then
  3785. text = text.."Safe: "..name
  3786. end
  3787. else
  3788. objTest = self:GetTopFrameParent(obj)
  3789. if objTest then
  3790. name = objTest:GetName()
  3791. if name then
  3792. text = text.."Safe: "..objTest:GetName()
  3793. end
  3794. end
  3795. end
  3796. end
  3797. if obj and obj ~= WorldFrame and obj:GetName() then
  3798. name = obj:GetName()
  3799. if name then
  3800. text2 = "Mouseover: "..text2..name
  3801. end
  3802. if obj:GetParent() and obj:GetParent() ~= WorldFrame and obj:GetParent():GetName() then
  3803. name = obj:GetParent():GetName()
  3804. if name then
  3805. text2 = text2.."\nParent: "..name
  3806. end
  3807. if obj:GetParent():GetParent() and obj:GetParent():GetParent() ~= WorldFrame and obj:GetParent():GetParent():GetName() then
  3808. name = obj:GetParent():GetParent():GetName()
  3809. if name then
  3810. text2 = text2.."\nParent's Parent: "..name
  3811. end
  3812. end
  3813. end
  3814. end
  3815. if not string.find(text2, "MANudger") then
  3816. label:SetText(text2.."\n"..text)
  3817. else
  3818. label:SetText(text)
  3819. end
  3820. end
  3821.  
  3822. function MovAny:Center(lock)
  3823. local mover = self.currentMover
  3824. local x, y
  3825. if lock == 0 then
  3826. -- Both
  3827. mover:ClearAllPoints()
  3828. mover:SetPoint("CENTER",0,0)
  3829. x = mover:GetLeft()
  3830. y = mover:GetBottom()
  3831. mover:ClearAllPoints()
  3832. mover:SetPoint("BOTTOMLEFT",x,y)
  3833. else
  3834. x = mover:GetLeft()
  3835. y = mover:GetBottom()
  3836. mover:ClearAllPoints()
  3837. if lock == 1 then
  3838. -- Horizontal
  3839. mover:SetPoint("CENTER",0,0)
  3840. x = mover:GetLeft()
  3841. mover:ClearAllPoints()
  3842. mover:SetPoint("BOTTOMLEFT",x,y)
  3843. elseif lock == 2 then
  3844. -- Vertical
  3845. mover:SetPoint("CENTER",0,0)
  3846. y = mover:GetBottom()
  3847. mover:ClearAllPoints()
  3848. mover:SetPoint("BOTTOMLEFT",x,y)
  3849. end
  3850. end
  3851. mover.skipGroups = true
  3852. self:MoverUpdatePosition(mover)
  3853. mover.skipGroups = nil
  3854. end
  3855.  
  3856. function MovAny:Nudge(dir, button)
  3857. local x, y, offsetX, offsetY, parent, mover, offsetAmount
  3858. mover = self.currentMover
  3859. if not mover:IsShown() then
  3860. return
  3861. end
  3862. x = mover:GetLeft()
  3863. y = mover:GetBottom()
  3864. if button == "RightButton" then
  3865. if IsShiftKeyDown() then
  3866. offsetAmount = 250
  3867. else
  3868. offsetAmount = 50
  3869. end
  3870. else
  3871. if IsShiftKeyDown() then
  3872. offsetAmount = 10
  3873. elseif IsAltKeyDown() then
  3874. offsetAmount = 0.1
  3875. else
  3876. offsetAmount = 1
  3877. end
  3878. end
  3879. if dir == 1 then
  3880. offsetX = 0
  3881. offsetY = offsetAmount
  3882. elseif dir == 2 then
  3883. offsetX = 0
  3884. offsetY = - offsetAmount
  3885. elseif dir == 3 then
  3886. offsetX = - offsetAmount
  3887. offsetY = 0
  3888. elseif dir == 4 then
  3889. offsetX = offsetAmount
  3890. offsetY = 0
  3891. end
  3892. mover:ClearAllPoints()
  3893. mover:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", x + offsetX, y + offsetY)
  3894. self:MoverUpdatePosition(mover)
  3895. end
  3896.  
  3897. function MovAny:SizingAnchor(button)
  3898. local s, e = string.find(button:GetName(), "Resize_")
  3899. local anchorto = string.sub(button:GetName(), e + 1)
  3900. local anchor
  3901. if anchorto == "LEFT" then
  3902. anchor = "RIGHT"
  3903. elseif anchorto == "RIGHT" then
  3904. anchor = "LEFT"
  3905. elseif anchorto == "TOP" then
  3906. anchor = "BOTTOM"
  3907. elseif anchorto == "BOTTOM" then
  3908. anchor = "TOP"
  3909. end
  3910. return anchorto, anchor
  3911. end
  3912.  
  3913. function MovAny:SyncUIPanel(mn, f)
  3914. local mover = _G[mn]
  3915. if f and (f ~= LootFrame or GetCVar("lootUnderMouse") ~= "1") and not MovAny:IsModified(f) and not MovAny:GetMoverByFrame(f) then
  3916. if self:IsModified(mn) then
  3917. if MovAny:IsProtected(f) and InCombatLockdown() then
  3918. local closure = function(f)
  3919. return function()
  3920. if MovAny:IsProtected(f) and InCombatLockdown() then
  3921. return true
  3922. end
  3923. MovAny:UnlockPoint(f)
  3924. f:ClearAllPoints()
  3925. local UIPOpt = UIPanelWindows[f:GetName()]
  3926. local x = 0
  3927. local y = 0
  3928. if not UIPOpt or not UIPOpt.xoffset then
  3929. x = 16
  3930. y = -12
  3931. end
  3932. f:SetPoint("TOPLEFT", mn, "TOPLEFT", x, y)
  3933. if not f.MAOrgScale then
  3934. f.MAOrgScale = f:GetScale()
  3935. end
  3936. f:SetScale(mover:GetScale())
  3937. if not f.MAOrgAlpha then
  3938. f.MAOrgAlpha = f:GetAlpha()
  3939. end
  3940. f:SetAlpha(mover:GetAlpha())
  3941. end
  3942. end
  3943. MovAny.pendingActions[f:GetName()..":UIPanel"] = closure(f)
  3944. else
  3945. MovAny:UnlockPoint(f)
  3946. f:ClearAllPoints()
  3947. local UIPOpt = UIPanelWindows[f:GetName()]
  3948. local x = 0
  3949. local y = 0
  3950. if not UIPOpt or not UIPOpt.xoffset then
  3951. x = 16
  3952. y = -12
  3953. end
  3954. f:SetPoint("TOPLEFT", mn, "TOPLEFT", x, y)
  3955.  
  3956. if not f.MAOrgScale then
  3957. f.MAOrgScale = f:GetScale()
  3958. end
  3959. f:SetScale(mover:GetScale())
  3960.  
  3961. if not f.MAOrgAlpha then
  3962. f.MAOrgAlpha = f:GetAlpha()
  3963. end
  3964. f:SetAlpha(mover:GetAlpha())
  3965. end
  3966. elseif f.MAOrgScale or f.MAOrgAlpha then
  3967. if MovAny:IsProtected(f) and InCombatLockdown() then
  3968. local closure = function(f)
  3969. return function()
  3970. if MovAny:IsProtected(f) and InCombatLockdown() then
  3971. return true
  3972. end
  3973. if f.MAOrgScale then
  3974. f:SetScale(f.MAOrgScale)
  3975. f.MAOrgScale = nil
  3976. end
  3977. if f.MAOrgAlpha then
  3978. f:SetAlpha(f.MAOrgAlpha)
  3979. f.MAOrgAlpha = nil
  3980. end
  3981. end
  3982. end
  3983. MovAny.pendingActions[f:GetName()..":UIPanel"] = closure(f)
  3984. else
  3985. if f.MAOrgScale then
  3986. f:SetScale(f.MAOrgScale)
  3987. f.MAOrgScale = nil
  3988. end
  3989. if f.MAOrgAlpha then
  3990. f:SetAlpha(f.MAOrgAlpha)
  3991. f.MAOrgAlpha = nil
  3992. end
  3993. end
  3994. end
  3995. end
  3996. end
  3997.  
  3998. function MovAny:SyncUIPanels()
  3999. local self = MovAny
  4000. local f = GetUIPanel("left")
  4001. if f then
  4002. self:SyncUIPanel("UIPanelMover1", f)
  4003. f = GetUIPanel("center")
  4004. if f then
  4005. self:SyncUIPanel("UIPanelMover2", f)
  4006. f = GetUIPanel("right")
  4007. if f then
  4008. self:SyncUIPanel("UIPanelMover3", f)
  4009. end
  4010. end
  4011. else
  4012. f = GetUIPanel("doublewide")
  4013. if f then
  4014. self:SyncUIPanel("UIPanelMover1", f)
  4015. f = GetUIPanel("right")
  4016. if f then
  4017. self:SyncUIPanel("UIPanelMover3", f)
  4018. end
  4019. end
  4020. end
  4021. end
  4022.  
  4023. function MovAny:GetContainerFrame(id)
  4024. local i = 1
  4025. local container
  4026. while true do
  4027. container = _G["ContainerFrame"..i]
  4028. if not container then
  4029. break
  4030. end
  4031. if container:IsShown() and container:GetID() == id then
  4032. return container
  4033. end
  4034. i = i + 1
  4035. end
  4036. return nil
  4037. end
  4038.  
  4039. function MovAny:GetBagInContainerFrame(f)
  4040. return self:GetBag(f:GetID())
  4041. end
  4042.  
  4043. function MovAny:GetBag(id)
  4044. return self.bagFrames[id]
  4045. end
  4046.  
  4047. function MovAny:SetBag(id, bag)
  4048. self.bagFrames[id] = bag
  4049. end
  4050.  
  4051. function MovAny:GrabContainerFrame(container, movableBag)
  4052. if movableBag and MovAny:IsModified(movableBag) then
  4053. movableBag:Show()
  4054. MovAny:UnlockScale(container)
  4055. container:SetScale(MAGetScale(movableBag))
  4056. MovAny:LockScale(container)
  4057. MovAny:UnlockPoint(container)
  4058. container:ClearAllPoints()
  4059. container:SetPoint("CENTER", movableBag, "CENTER", 0, 0)
  4060. MovAny:LockPoint(container)
  4061. movableBag.attachedChildren = { }
  4062. tinsert(movableBag.attachedChildren, container)
  4063. container:SetAlpha(movableBag:GetAlpha())
  4064. end
  4065. end
  4066.  
  4067. function MovAny:UnanchorRelatives(e, f, opt)
  4068. if f.GetName and f:GetName() ~= nil and e.noUnanchorRelatives then
  4069. return
  4070. end
  4071. if not f.GetParent then
  4072. return
  4073. end
  4074. local p = f:GetParent()
  4075. if not p then
  4076. return
  4077. end
  4078. opt = opt or self:GetUserData(f:GetName())
  4079. local named = { }
  4080. self:_AddNamedChildren(named, f)
  4081. local relatives = MA_tcopy(named)
  4082. relatives[f] = f
  4083. if p.GetRegions then
  4084. local children = {p:GetRegions()}
  4085. if children ~= nil then
  4086. for i, v in ipairs(children) do
  4087. self:_AddDependents(relatives, v)
  4088. end
  4089. end
  4090. end
  4091. --local num = p:GetNumChildren()
  4092. --assert((num < 8000), "Too much childrens stuck in owerflow")
  4093. if p.GetChildren then
  4094. local children = {p:GetChildren()}
  4095. if children ~= nil then
  4096. for i, v in ipairs(children) do
  4097. if not self:IsForbidden(v) and not self:IsProtected(v) and v.GetPoint then
  4098. self:_AddDependents(relatives, v)
  4099. end
  4100. end
  4101. end
  4102. end
  4103. relatives[f] = nil
  4104. relatives[GameTooltip] = nil
  4105. for i, v in pairs(named) do
  4106. relatives[v] = nil
  4107. end
  4108. -- local fRel = self:ForcedDetachFromParent(f:GetName())
  4109. local fRel = (select(2, opt.orgPos))
  4110. if fRel == nil then
  4111. fRel = (select(2, f:GetPoint(1)))
  4112. end
  4113. local size = tlen(relatives)
  4114. if size > 0 then
  4115. local unanchored = { }
  4116. local x, y, i
  4117. for i, v in pairs(relatives) do
  4118. if v:GetName() ~= nil and not self:IsContainer(v:GetName()) and not string.match(v:GetName(), "BagFrame[1-9][0-9]*") and not self.NoUnanchoring[v:GetName()] and not v.MAPoint then
  4119. -- alternatively use not self:GetUserData(v:GetName()) instead of v.MAPoint
  4120. if v:GetRight() ~= nil and v:GetTop() ~= nil then
  4121. local p = {v:GetPoint(1)}
  4122. p[2] = fRel
  4123. p = MovAny:GetRelativePoint(p, v, true)
  4124. if MovAny:IsProtected(v) and InCombatLockdown() then
  4125. MovAny:AddPendingPoint(v, p)
  4126. else
  4127. v.MAOrgPoint = {v:GetPoint(1)}
  4128. MovAny:UnlockPoint(v)
  4129. v:ClearAllPoints()
  4130. v:SetPoint(unpack(p))
  4131. MovAny:LockPoint(v)
  4132. end
  4133. unanchored[ i ] = v
  4134. end
  4135. end
  4136. end
  4137. if i ~= nil then
  4138. f.MAUnanchoredRelatives = unanchored
  4139. end
  4140. end
  4141. end
  4142.  
  4143. function MovAny:_AddDependents(l, f)
  4144. if (MovAny:IsProtected(f) and InCombatLockdown()) or not f.GetPoint then
  4145. return
  4146. end
  4147.  
  4148. local error = false
  4149. xpcall(function() return f:GetPoint(1); end,
  4150. function() error = true; end)
  4151. if error then
  4152. return
  4153. end
  4154.  
  4155. local _, relativeTo = f:GetPoint(1)
  4156. if relativeTo and l[relativeTo] then
  4157. l[f] = f
  4158. end
  4159. end
  4160.  
  4161. function MovAny:_AddNamedChildren(l, f)
  4162. if f.GetChildren then
  4163. local children = {f:GetChildren()}
  4164. if children ~= nil then
  4165. for i, v in pairs(children) do
  4166. self:_AddNamedChildren(l, v)
  4167. if v.GetName then
  4168. local n = v:GetName()
  4169. if n then
  4170. l[v] = v
  4171. end
  4172. end
  4173. end
  4174. end
  4175. end
  4176. if f.attachedChildren then
  4177. local children = f.attachedChildren
  4178. if children ~= nil then
  4179. for i, v in pairs(children) do
  4180. self:_AddNamedChildren(l, v)
  4181. if v.GetName then
  4182. local n = v:GetName()
  4183. if n then
  4184. l[v] = v
  4185. end
  4186. end
  4187. end
  4188. end
  4189. end
  4190. end
  4191.  
  4192. function MovAny:ReanchorRelatives()
  4193. for i, v in pairs(self.userData) do
  4194. local f = _G[v.name]
  4195. if f and f.MAUnanchoredRelatives then
  4196. for k, r in pairs(f.MAUnanchoredRelatives) do
  4197. if not MovAny:IsModified(r) then
  4198. MovAny:UnlockPoint(r)
  4199. if r.MAOrgPoint then
  4200. r:SetPoint(unpack(r.MAOrgPoint))
  4201. r.MAOrgPoint = nil
  4202. end
  4203. end
  4204. end
  4205. f.MAUnanchoredRelatives = nil
  4206. end
  4207. end
  4208. end
  4209.  
  4210. function MovAny:AddPendingPoint(f, p)
  4211. local closure = function(f, p)
  4212. return function()
  4213. if MovAny:IsProtected(f) and InCombatLockdown() then
  4214. return true
  4215. end
  4216. if not f.MAOrgPoint then
  4217. f.MAOrgPoint = {f:GetPoint(1)}
  4218. end
  4219. MovAny:UnlockPoint(f)
  4220. f:ClearAllPoints()
  4221. --MovAny:SetPoint(f, p)
  4222. if f.MASetPoint then
  4223. f:MASetPoint(unpack(p))
  4224. else
  4225. f:SetPoint(unpack(p))
  4226. end
  4227. MovAny:LockPoint(f)
  4228. end
  4229. end
  4230. local fn = f:GetName()
  4231. MovAny.pendingActions[fn..":Point"] = closure(f, p)
  4232. end
  4233.  
  4234. function MovAny:GetSerializedPoint(f, num)
  4235. num = num or 1
  4236. local point, rel, relPoint, x, y = f:GetPoint(num)
  4237. if point then
  4238. if rel and rel.GetName and rel:GetName() ~= "" then
  4239. rel = rel:GetName()
  4240. else
  4241. rel = "UIParent"
  4242. end
  4243. return {point, rel, relPoint, x, y}
  4244. end
  4245. return nil
  4246. end
  4247.  
  4248. function MovAny:GetRelativePoint(o, f, lockRel)
  4249. if not o then
  4250. o = {"BOTTOMLEFT", UIParent, "BOTTOMLEFT"}
  4251. end
  4252. local rel = o[2]
  4253. if rel == nil then
  4254. rel = UIParent
  4255. end
  4256. if type(rel) == "string" then
  4257. rel = _G[rel]
  4258. end
  4259. if not rel then
  4260. return
  4261. end
  4262. local point = o[1]
  4263. local relPoint = o[3]
  4264. if not lockRel then
  4265. local newRel = self:ForcedDetachFromParent(f:GetName())
  4266. if newRel then
  4267. rel = _G[newRel]
  4268. point = "BOTTOMLEFT"
  4269. relPoint = "BOTTOMLEFT"
  4270. end
  4271. if not rel then
  4272. return
  4273. end
  4274. end
  4275. local rX, rY, pX, pY
  4276. if rel:GetLeft() ~= nil then
  4277. if relPoint == "TOPRIGHT" then
  4278. rY = rel:GetTop()
  4279. rX = rel:GetRight()
  4280. elseif relPoint == "TOPLEFT" then
  4281. rY = rel:GetTop()
  4282. rX = rel:GetLeft()
  4283. elseif relPoint == "TOP" then
  4284. rY = rel:GetTop()
  4285. rX = (rel:GetRight() + rel:GetLeft()) / 2
  4286. elseif relPoint == "BOTTOMRIGHT" then
  4287. rY = rel:GetBottom()
  4288. rX = rel:GetRight()
  4289. elseif relPoint == "BOTTOMLEFT" then
  4290. rY = rel:GetBottom()
  4291. rX = rel:GetLeft()
  4292. elseif relPoint == "BOTTOM" then
  4293. rY = rel:GetBottom()
  4294. rX = (rel:GetRight() + rel:GetLeft()) / 2
  4295. elseif relPoint == "CENTER" then
  4296. rY = (rel:GetTop() + rel:GetBottom()) / 2
  4297. rX = (rel:GetRight() + rel:GetLeft()) / 2
  4298. elseif relPoint == "LEFT" then
  4299. rY = (rel:GetTop() + rel:GetBottom()) / 2
  4300. rX = rel:GetLeft()
  4301. elseif relPoint == "RIGHT" then
  4302. rY = (rel:GetTop() + rel:GetBottom()) / 2
  4303. rX = rel:GetRight()
  4304. else
  4305. return
  4306. end
  4307. if rel.GetEffectiveScale then
  4308. rY = rY * rel:GetEffectiveScale()
  4309. rX = rX * rel:GetEffectiveScale()
  4310. else
  4311. rY = rY * UIParent:GetEffectiveScale()
  4312. rX = rX * UIParent:GetEffectiveScale()
  4313. end
  4314. end
  4315. if f:GetLeft() ~= nil then
  4316. if point == "TOPRIGHT" then
  4317. pY = f:GetTop()
  4318. pX = f:GetRight()
  4319. elseif point == "TOPLEFT" then
  4320. pY = f:GetTop()
  4321. pX = f:GetLeft()
  4322. elseif point == "TOP" then
  4323. pY = f:GetTop()
  4324. pX = (f:GetRight() + f:GetLeft()) / 2
  4325. elseif point == "BOTTOMRIGHT" then
  4326. pY = f:GetBottom()
  4327. pX = f:GetRight()
  4328. elseif point == "BOTTOMLEFT" then
  4329. pY = f:GetBottom()
  4330. pX = f:GetLeft()
  4331. elseif point == "BOTTOM" then
  4332. pY = f:GetBottom()
  4333. pX = (f:GetRight() + f:GetLeft()) / 2
  4334. elseif point == "CENTER" then
  4335. pY = (f:GetTop() + f:GetBottom()) / 2
  4336. pX = (f:GetRight() + f:GetLeft()) / 2
  4337. elseif point == "LEFT" then
  4338. pY = (f:GetTop() + f:GetBottom()) / 2
  4339. pX = f:GetLeft()
  4340. elseif point == "RIGHT" then
  4341. pY = (f:GetTop() + f:GetBottom()) / 2
  4342. pX = f:GetRight()
  4343. else
  4344. return
  4345. end
  4346. if f.GetEffectiveScale then
  4347. pY = pY * f:GetEffectiveScale()
  4348. pX = pX * f:GetEffectiveScale()
  4349. else
  4350. pY = pY * UIParent:GetEffectiveScale()
  4351. pX = pX * UIParent:GetEffectiveScale()
  4352. end
  4353. end
  4354. if rY ~= nil and rX ~= nil and pY ~= nil and pX ~= nil then
  4355. rX = pX - rX
  4356. rY = pY - rY
  4357. if f.GetEffectiveScale then
  4358. rY = rY / f:GetEffectiveScale()
  4359. rX = rX / f:GetEffectiveScale()
  4360. else
  4361. rY = rY / UIParent:GetEffectiveScale()
  4362. rX = rX / UIParent:GetEffectiveScale()
  4363. end
  4364. else
  4365. rX = 0
  4366. rY = 0
  4367. end
  4368. return {point, rel:GetName(), relPoint, rX, rY}
  4369. end
  4370.  
  4371. -- modfied version of blizzards updateContainerFrameAnchors
  4372. local MARefBlizzBags = { }
  4373. function MovAny:hUpdateContainerFrameAnchors()
  4374. if MADB.noBags then
  4375. return
  4376. end
  4377. local bagsMover = _G.BagsMover
  4378. local bagsHooked = bagsMover and bagsMover.MAHooked or nil
  4379. local xRemaining, yRemaining, column, frame, frameHeight, visibleSpacing, bag, xOffset, yOffset, containerScale, xAvail, yAvail
  4380. local highestFrame = 0
  4381. if bagsHooked then
  4382. containerScale = BagsMover:GetScale()
  4383. xOffset, yOffset = math.abs(BagsMover:GetRight() * containerScale - GetScreenWidth()), BagsMover:GetBottom() * containerScale
  4384. else
  4385. containerScale = 1
  4386. xOffset, yOffset = CONTAINER_OFFSET_X , CONTAINER_OFFSET_Y --/ containerScale
  4387. end
  4388. while containerScale > 0.02 do
  4389. xAvail, yAvail = (GetScreenWidth() - xOffset) / containerScale, (GetScreenHeight() - yOffset) / containerScale
  4390. if BankFrame:IsShown() and not BankFrame.MAHooked then
  4391. xAvail = xAvail + (20 / containerScale) - (BankFrame:GetRight() * BankFrame:GetScale()) / containerScale
  4392. end
  4393. yRemaining = yAvail
  4394. column = 1
  4395. highestFrame = 0
  4396. --visibleSpacing = VISIBLE_CONTAINER_SPACING * containerScale
  4397. for index, frameName in ipairs(ContainerFrame1.bags) do
  4398. frame = MARefBlizzBags[frameName]
  4399. if frame == nil then
  4400. frame = _G[frameName]
  4401. MARefBlizzBags[frameName] = frame
  4402. end
  4403. bag = MovAny:GetBagInContainerFrame(frame)
  4404. if not bag or (bag and not MovAny:IsModified(bag, "pos") and not MovAny:GetMoverByFrame(bag)) then
  4405. frameHeight = frame:GetHeight() --* containerScale
  4406.  
  4407. if yRemaining < frameHeight + VISIBLE_CONTAINER_SPACING then
  4408. column = column + 1
  4409. yRemaining = yAvail
  4410. end
  4411. if frameHeight > highestFrame then
  4412. highestFrame = frameHeight
  4413. end
  4414. yRemaining = yRemaining - frameHeight - VISIBLE_CONTAINER_SPACING
  4415. end
  4416. end
  4417. if highestFrame > yAvail or column * ((CONTAINER_WIDTH --[[* containerScale]]) + VISIBLE_CONTAINER_SPACING) > xAvail then
  4418. containerScale = containerScale - .01
  4419. else
  4420. break
  4421. end
  4422. end
  4423. if not bagsHooked and containerScale < CONTAINER_SCALE then
  4424. containerScale = CONTAINER_SCALE
  4425. end
  4426. column = 0
  4427. yRemaining = yAvail
  4428. local lastFrame, firstFrame, skippedFrame = nil, nil, nil
  4429. for i = 1, 13, 1 do
  4430. frame = _G["ContainerFrame"..i]
  4431. bag = MovAny:GetBagInContainerFrame(frame)
  4432. if not bag or (bag and not MovAny:IsModified(bag, "pos") and not MovAny:GetMoverByFrame(bag)) then
  4433. MovAny:UnlockPoint(frame)
  4434. --MovAny:UnlockScale(frame)
  4435. frame:ClearAllPoints()
  4436. frame:SetScale(containerScale)
  4437. frame:SetAlpha(1)
  4438. frameHeight = frame:GetHeight() --* containerScale
  4439. if firstFrame == nil then
  4440. firstFrame = frame
  4441. if bagsHooked then
  4442. frame:SetPoint("BOTTOMRIGHT", BagsMover, "BOTTOMRIGHT", 0, 0)
  4443. else
  4444. frame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -xOffset, yOffset )
  4445. end
  4446. elseif yRemaining < frameHeight then
  4447. yRemaining = yAvail
  4448. frame:SetPoint("BOTTOMRIGHT", firstFrame, "BOTTOMLEFT", -(column * CONTAINER_WIDTH), 0)
  4449. column = column + 1
  4450. else
  4451. frame:SetPoint("BOTTOMRIGHT", lastFrame, "TOPRIGHT", 0, -CONTAINER_SPACING)
  4452. end
  4453. yRemaining = yRemaining - frameHeight - VISIBLE_CONTAINER_SPACING
  4454. lastFrame = frame
  4455. end
  4456. end
  4457. end
  4458.  
  4459. -- X: slash commands
  4460. SLASH_MAMOVE1 = "/move"
  4461. SlashCmdList["MAMOVE"] = function(msg)
  4462. if msg == nil or string.len(msg) == 0 then
  4463. MovAny:ToggleGUI()
  4464. else
  4465. MovAny:ToggleMove(MovAny:Translate(msg))
  4466. end
  4467. end
  4468.  
  4469. SLASH_MAUNMOVE1= "/unmove"
  4470. SlashCmdList["MAUNMOVE"] = function(msg)
  4471. if msg then
  4472. if MovAny.userData[ msg ] then
  4473. MovAny:ResetFrame(msg)
  4474. elseif MovAny.userData[ MovAny:Translate(msg) ] then
  4475. MovAny:ResetFrame(MovAny:Translate(msg))
  4476. end
  4477. else
  4478. maPrint(MOVANY.CMD_SYNTAX_UNMOVE)
  4479. end
  4480. end
  4481.  
  4482. SLASH_MAHIDE1 = "/hide"
  4483. SlashCmdList["MAHIDE"] = function(msg)
  4484. if msg == nil or string.len(msg) == 0 then
  4485. maPrint(MOVANY.CMD_SYNTAX_HIDE)
  4486. return
  4487. end
  4488. MovAny:ToggleHide(MovAny:Translate(msg))
  4489. end
  4490.  
  4491. SLASH_MAIMPORT1 = "/moveimport"
  4492. SlashCmdList["MAIMPORT"] = function(msg)
  4493. if msg == nil or string.len(msg) == 0 then
  4494. maPrint(MOVANY.CMD_SYNTAX_IMPORT)
  4495. return
  4496. end
  4497. if InCombatLockdown() then
  4498. maPrint(MOVANY.DISABLED_DURING_COMBAT)
  4499. return
  4500. end
  4501.  
  4502. if MADB.profiles[msg] == nil then
  4503. maPrint(string.format(MOVANY.PROFILE_UNKNOWN, msg))
  4504. return
  4505. end
  4506. MovAny:CopyProfile(msg, MovAny:GetProfileName())
  4507. MovAny:UpdateProfile()
  4508. maPrint(string.format(MOVANY.PROFILE_IMPORTED, msg, MovAny:GetProfileName()))
  4509. end
  4510.  
  4511. SLASH_MAEXPORT1 = "/moveexport"
  4512. SlashCmdList["MAEXPORT"] = function(msg)
  4513. if msg == nil or string.len(msg) == 0 then
  4514. maPrint(MOVANY.CMD_SYNTAX_EXPORT)
  4515. return
  4516. end
  4517.  
  4518. MovAny:CopyProfile(MovAny:GetProfileName(), msg)
  4519. maPrint(string.format(MOVANY.PROFILE_EXPORTED, MovAny:GetProfileName(), msg))
  4520. end
  4521.  
  4522. SLASH_MALIST1 = "/movelist"
  4523. SlashCmdList["MALIST"] = function(msg)
  4524. maPrint(MOVANY.PROFILES..":")
  4525. for i, val in pairs(MADB.profiles) do
  4526. local str = " \""..i.."\""
  4527. if val == MovAny.userData then
  4528. str = str.." <- "..MOVANY.PROFILE_CURRENT
  4529. end
  4530. maPrint(str)
  4531. end
  4532. end
  4533.  
  4534. SLASH_MADELETE1 = "/movedelete"
  4535. SLASH_MADELETE2 = "/movedel"
  4536. SlashCmdList["MADELETE"] = function(msg)
  4537. if msg == nil or string.len(msg) == 0 then
  4538. maPrint(MOVANY.CMD_SYNTAX_DELETE)
  4539. return
  4540. end
  4541. if MADB.profiles[msg] == nil then
  4542. maPrint(string.format(MOVANY.PROFILE_UNKNOWN, msg))
  4543. return
  4544. end
  4545. if msg == MovAny:GetProfileName() and InCombatLockdown() then
  4546. maPrint(MOVANY.PROFILE_CANT_DELETE_CURRENT_IN_COMBAT)
  4547. return
  4548. end
  4549. if MovAny:DeleteProfile(msg) then
  4550. maPrint(string.format(MOVANY.PROFILE_DELETED, msg))
  4551. end
  4552. end
  4553.  
  4554. SLASH_MAMAFE1 = "/mafe"
  4555. SlashCmdList["MAMAFE"] = function(msg)
  4556. if string.len(msg) > 0 then
  4557. MovAny:FrameEditor(MovAny:Translate(msg))
  4558. else
  4559. maPrint(MOVANY.CMD_SYNTAX_MAFE)
  4560. end
  4561. end
  4562.  
  4563. SLASH_MAINFO1 = "/info"
  4564. SlashCmdList["MAINFO"] = function(msg)
  4565. GetParentInfoFromCursor()
  4566. end
  4567.  
  4568. -- X: global functions
  4569. function MANumFor(n, decimals)
  4570. if n == nil then
  4571. return "nil"
  4572. end
  4573. n = string.format("%."..(decimals or 2).."f", n)
  4574. if decimals == nil then
  4575. decimals = 2
  4576. end
  4577. while decimals > 0 do
  4578. if string.sub(n, - 1) == "0" then
  4579. n = string.sub(n, 1, - 2)
  4580. end
  4581. decimals = decimals - 1
  4582. end
  4583. if string.sub(n, - 1) == "." then
  4584. n = string.sub(n, 1, - 2)
  4585. end
  4586. return n
  4587. end
  4588.  
  4589. function MAGetParent(f)
  4590. if not f or not f.GetParent then
  4591. return
  4592. end
  4593. local p = f:GetParent()
  4594. if p == nil then
  4595. return UIParent
  4596. end
  4597. return p
  4598. end
  4599.  
  4600. function MAGetScale(f, effective)
  4601. if not f or not f.GetScale then
  4602. return 1
  4603. elseif f.MAE and f.MAE.noScale then
  4604. return f:GetScale()
  4605. else
  4606. if not f.GetScale or f:GetScale() == nil then
  4607. return 1
  4608. end
  4609. if effective then
  4610. return f:GetEffectiveScale()
  4611. else
  4612. return f:GetScale()
  4613. end
  4614. end
  4615. end
  4616.  
  4617. function maPrint(msgKey, msgHighlight, msgAdditional, r, g, b, frame)
  4618. local msgOutput
  4619. if frame then
  4620. msgOutput = frame
  4621. else
  4622. msgOutput = DEFAULT_CHAT_FRAME
  4623. end
  4624. if msgKey == "" then
  4625. return
  4626. end
  4627. if msgKey == nil then
  4628. msgKey = "<nomsg>"
  4629. end
  4630. if msgHighlight == nil or msgHighlight == "" then
  4631. msgHighlight = " "
  4632. end
  4633. if msgAdditional == nil or msgAdditional == "" then
  4634. msgAdditional = " "
  4635. end
  4636. if msgOutput then
  4637. msgOutput:AddMessage("|caaff0000MoveAnything|r|caaffff00>|r "..msgKey.." |caaaaddff"..msgHighlight.."|r"..msgAdditional, r, g, b)
  4638. end
  4639. end
  4640.  
  4641. function MovAny:ToggleEnableFrame(fn, opt)
  4642. local f = _G[fn]
  4643. if f and fn ~= f:GetName() then
  4644. fn = f:GetName()
  4645. end
  4646. local opt = opt or MovAny:GetUserData(fn, nil, true)
  4647. if opt.disabled then
  4648. self:EnableFrame(fn)
  4649. else
  4650. self:DisableFrame(fn)
  4651. end
  4652. MovAny:UpdateGUIIfShown()
  4653. end
  4654.  
  4655. function MovAny:EnableFrame(fn)
  4656. local f = _G[fn]
  4657. if not fn then
  4658. return
  4659. end
  4660. if not f then
  4661. return
  4662. end
  4663. local opt = self:GetUserData(f:GetName())
  4664. if not opt then
  4665. return
  4666. end
  4667. opt.disabled = nil
  4668. local e = API:GetElement(fn)
  4669. e:Sync(f)
  4670. if f.MAOnEnable then
  4671. f:MAOnEnable()
  4672. end
  4673. end
  4674.  
  4675. function MovAny:DisableFrame(fn)
  4676. if fn == nil then
  4677. return
  4678. end
  4679. self:StopMoving(fn)
  4680. local opt = self:GetUserData(fn, nil, true)
  4681. if not opt then
  4682. return
  4683. end
  4684. local f = _G[fn]
  4685. if f then
  4686. self:ResetFrame(f, nil, true)
  4687. end
  4688. opt.disabled = true
  4689. end
  4690.  
  4691. function MovAny:UnhookTooltip()
  4692. local tooltip = _G.GameTooltip
  4693. if tooltip.MAMover then
  4694. local e = tooltip.MAMover.MAE
  4695. local opt = e.userData
  4696. if type(opt) == "table" then
  4697. if opt.hidden then
  4698. tooltip.MAHidden = nil
  4699. end
  4700. MovAny.Alpha:Reset(e, tooltip, true)
  4701. MovAny.Scale:Reset(e, tooltip, true)
  4702. MovAny.Misc:Reset(e, tooltip, true)
  4703. end
  4704. tooltip.MAMover = nil
  4705. end
  4706. end
  4707.  
  4708. function MovAny:HookTooltip(mover)
  4709. if not mover then
  4710. return
  4711. end
  4712. local l, r, t, b, anchor
  4713. local tooltip = _G.GameTooltip
  4714. self:UnhookTooltip()
  4715. --[[local opt = MovAny:GetUserData(mover:GetName())
  4716. opt = mover.MAE.userData
  4717. if type(opt) ~= "table" then
  4718. return
  4719. end]]
  4720. tooltip.MAMover = mover
  4721. l = mover:GetLeft() * mover:GetEffectiveScale()
  4722. r = mover:GetRight() * mover:GetEffectiveScale()
  4723. t = mover:GetTop() * mover:GetEffectiveScale()
  4724. b = mover:GetBottom() * mover:GetEffectiveScale()
  4725. anchor = "CENTER"
  4726. if ((b + t) / 2) < ((UIParent:GetTop() * UIParent:GetScale()) / 2) - 25 then
  4727. anchor = "BOTTOM"
  4728. elseif ((b + t) / 2) > ((UIParent:GetTop() * UIParent:GetScale()) / 2) + 25 then
  4729. anchor = "TOP"
  4730. end
  4731. if anchor ~= "CENTER" then
  4732. if ((l + r) / 2) > ((UIParent:GetRight() * UIParent:GetScale()) / 2) + 25 then
  4733. anchor = anchor.."RIGHT"
  4734. elseif ((l + r) / 2) < ((UIParent:GetRight() * UIParent:GetScale()) / 2) - 25 then
  4735. anchor = anchor.."LEFT"
  4736. end
  4737. end
  4738. --MovAny:UnlockPoint(tooltip)
  4739. tooltip:ClearAllPoints()
  4740. tooltip:SetPoint(anchor, mover, anchor, 0, 0)
  4741. --MovAny:LockPoint(tooltip)
  4742. local opt = MovAny:GetUserData(mover:GetName())
  4743. if opt and opt.hidden then
  4744. self:LockVisibility(tooltip)
  4745. end
  4746. MovAny.Alpha:Apply(mover.MAE, tooltip)
  4747. MovAny.Scale:Apply(mover.MAE, tooltip)
  4748. MovAny.Misc:Apply(mover.MAE, tooltip)
  4749. end
  4750.  
  4751. function MovAny:hGameTooltip_SetDefaultAnchor(relative)
  4752. local tooltip = _G.GameTooltip
  4753. if tooltip.MASkip then
  4754. return
  4755. end
  4756. if MovAny:IsModified("TooltipMover") then
  4757. MovAny:HookTooltip(_G["TooltipMover"])
  4758. elseif MovAny:IsModified("BagItemTooltipMover") then
  4759. MovAny:UnlockPoint(tooltip)
  4760. end
  4761. end
  4762.  
  4763. function MovAny:hGameTooltip_SetBagItem(container, slot)
  4764. if MovAny:IsModified("BagItemTooltipMover") then
  4765. MovAny:HookTooltip(_G["BagItemTooltipMover"])
  4766. end
  4767. end
  4768.  
  4769. function MovAny:hGameTooltip_SetGuildBankItem(container, slot)
  4770. if MovAny:IsModified("GuildBankItemTooltipMover") then
  4771. MovAny:HookTooltip(_G["GuildBankItemTooltipMover"])
  4772. end
  4773. end
  4774.  
  4775. -- X: MA tooltip funcs
  4776. function MovAny:TooltipShow(self)
  4777. if not self.tooltipText then
  4778. return
  4779. end
  4780. if self.alwaysShowTooltip or (MADB.tooltips and not IsShiftKeyDown() and not self.neverShowTooltip) or (not MADB.tooltips and IsShiftKeyDown()) or (self.neverShowTooltip and IsShiftKeyDown()) then
  4781. GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  4782. GameTooltip:ClearLines()
  4783. GameTooltip:AddLine(self.tooltipText)
  4784. GameTooltip:Show()
  4785. end
  4786. end
  4787.  
  4788. function MovAny:TooltipHide()
  4789. GameTooltip:Hide()
  4790. end
  4791.  
  4792. function MovAny:TooltipShowMultiline(self)
  4793. local tooltipLines = self.tooltipLines
  4794. if tooltipLines == nil then
  4795. local el = API:GetItem(self.idx)
  4796. if el.elems then
  4797. return
  4798. end
  4799. tooltipLines = MovAny:GetFrameTooltipLines(el.name)
  4800. end
  4801. if tooltipLines == nil then
  4802. return
  4803. end
  4804. local g = 0
  4805. for k in pairs(tooltipLines) do
  4806. g = 1
  4807. break
  4808. end
  4809. if g == 0 then
  4810. return
  4811. end
  4812. if self.alwaysShowTooltip or (self.neverShowTooltip and IsShiftKeyDown()) or (MADB.tooltips and not IsShiftKeyDown() and not self.neverShowTooltip) or (not MADB.tooltips and IsShiftKeyDown()) then
  4813. GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  4814. GameTooltip:ClearLines()
  4815. for i,v in ipairs(tooltipLines) do
  4816. GameTooltip:AddLine(v)
  4817. end
  4818. GameTooltip:Show()
  4819. end
  4820. end
  4821.  
  4822. function MovAny:GetFrameTooltipLines(fn)
  4823. if not fn then
  4824. return
  4825. end
  4826. local o = API:GetElement(fn)
  4827. if not o then
  4828. return
  4829. end
  4830. local opts = o.userData
  4831. local msgs = { }
  4832. local enough = nil
  4833. local added = nil
  4834. tinsert(msgs, o.displayName or fn)
  4835. if opts then
  4836. if opts.hidden then
  4837. if o.hideList then
  4838. tinsert(msgs, "Specially hidden")
  4839. else
  4840. tinsert(msgs, "Hidden")
  4841. end
  4842. enough = true
  4843. end
  4844. end
  4845. if o and o.displayName and o.displayName ~= fn and fn ~= nil then
  4846. tinsert(msgs, " ")
  4847. tinsert(msgs, "Frame: "..fn)
  4848. end
  4849. if opts then
  4850. if opts.pos then
  4851. if not added then
  4852. tinsert(msgs, " ")
  4853. end
  4854. tinsert(msgs, "Position: "..MANumFor(opts.pos[4])..", "..MANumFor(opts.pos[5]))
  4855. enough = true
  4856. added = true
  4857. end
  4858. if opts.scale then
  4859. if not added then
  4860. tinsert(msgs, " ")
  4861. end
  4862. tinsert(msgs, "Scale: "..MANumFor(opts.scale))
  4863. enough = true
  4864. added = true
  4865. end
  4866. if opts.alpha then
  4867. if not added then
  4868. tinsert(msgs, " ")
  4869. end
  4870. tinsert(msgs, "Alpha: "..MANumFor(opts.alpha))
  4871. enough = true
  4872. added = true
  4873. end
  4874. added = nil
  4875. if opts.scale then
  4876. if not added then
  4877. tinsert(msgs, " ")
  4878. end
  4879. tinsert(msgs, "Original Scale: "..MANumFor(opts.orgScale or 1))
  4880. enough = true
  4881. added = true
  4882. end
  4883. if opts.alpha and opts.orgAlpha and opts.alpha ~= opts.orgAlpha then
  4884. if not added then
  4885. tinsert(msgs, " ")
  4886. end
  4887. tinsert(msgs, "Original Alpha: "..MANumFor(opts.orgAlpha))
  4888. enough = true
  4889. added = true
  4890. end
  4891. end
  4892. -- enable this to only show tooltips if actual modifications have been made to the frame
  4893. --[[if not enough then
  4894. table.wipe(msgs)
  4895. end]]
  4896. return msgs
  4897. end
  4898.  
  4899. -- X: debugging code
  4900. function echo(...)
  4901. local msg = ""
  4902. for k, v in pairs({...}) do
  4903. msg = msg..k.."=["..tostring(v) .."] "
  4904. end
  4905. DEFAULT_CHAT_FRAME:AddMessage(msg)
  4906. end
  4907.  
  4908. function decho(ar, limit)
  4909. local msg = ""
  4910. for k, v in pairs(ar) do
  4911. if type(v) == "table" then
  4912. msg = msg..k.."=["..dechoSub(v, 1, limit) .."] \n"
  4913. else
  4914. msg = msg..k.."=["..tostring(v) .."] \n"
  4915. end
  4916. end
  4917. DEFAULT_CHAT_FRAME:AddMessage(msg)
  4918. end
  4919.  
  4920. function dechoSub(t, d, limit)
  4921. local msg = ""
  4922. if d > 10 or (type(limit) == "number" and d <= limit) then
  4923. return msg
  4924. end
  4925. for k, v in pairs(t) do
  4926. if type(v) == "table" then
  4927. msg = msg..k.."=["..dechoSub(v, d + 1) .."] \n"
  4928. else
  4929. msg = msg..k.."=["..tostring(v) .."] \n"
  4930. end
  4931. end
  4932. return msg
  4933. end
  4934.  
  4935. function necho(...)
  4936. local msg = ""
  4937. for k,v in pairs({...}) do
  4938. if type(v) == "table" then
  4939. for k2,v2 in pairs(v) do
  4940. msg = msg..k2.."=("..type(v2) ..") "
  4941. end
  4942. end
  4943. end
  4944. DEFAULT_CHAT_FRAME:AddMessage(msg)
  4945. end
  4946.  
  4947. function MovAny:DebugFrameAtCursor()
  4948. local o = GetMouseFocus()
  4949. if o then
  4950. if self:IsMAFrame(o:GetName()) then
  4951. if self:IsMover(o:GetName()) and o.tagged then
  4952. o = o.tagged
  4953. end
  4954. end
  4955. if o ~= WorldFrame and o ~= UIParent then
  4956. MovAny:Dump(o)
  4957. end
  4958. end
  4959. end
  4960.  
  4961. function MovAny:Dump(o)
  4962. if type(o) ~= "table" then
  4963. maPrint(string.format(MOVANY.UNSUPPORTED_TYPE, type(o)))
  4964. return
  4965. end
  4966. local s = " Name: "..o:GetName()
  4967. if o.GetObjectType then
  4968. s = s.." Type: "..o:GetObjectType()
  4969. end
  4970. local p = o:GetParent()
  4971. if p == nil then
  4972. p = UIParent
  4973. end
  4974. if o ~= p then
  4975. s = s.." Parent: "..(p:GetName() or "unnamed")
  4976. end
  4977. if o.MAParent then
  4978. s = s.." MA Parent: "..((type(o.MAParent) == "table" and o.MAParent:GetName()) or (type(o.MAParent) == "string" and o.MAParent) or "unnamed")
  4979. end
  4980. if s ~= "" then
  4981. maPrint(s)
  4982. end
  4983. if o.IsProtected and o:IsProtected() then
  4984. maPrint(" Protected: true")
  4985. elseif o.MAProtected then
  4986. maPrint(" Virtually protected: true")
  4987. end
  4988. s = ""
  4989. if o.IsShown then
  4990. if o:IsShown() then
  4991. s = s.." Shown: true"
  4992. else
  4993. s = s.." Shown: false"
  4994. end
  4995. if o.IsVisible then
  4996. if o:IsVisible() then
  4997. s = s.." Visible: true"
  4998. else
  4999. s = s.." Visible: false"
  5000. end
  5001. end
  5002. end
  5003. if o.IsTopLevel and o:IsToplevel() then
  5004. s = s.." Top Level: true"
  5005. end
  5006. if o.GetFrameLevel then
  5007. s = s.." Level: "..o:GetFrameLevel()
  5008. end
  5009. if o.GetFrameStrata then
  5010. s = s.." Strata: "..o:GetFrameStrata()
  5011. end
  5012. if s ~= "" then
  5013. maPrint(s)
  5014. end
  5015. local point = {o:GetPoint()}
  5016. if point and point[1] and point[2] and point[3] and point[4] and point[5] then
  5017. if not point[2] then
  5018. point[2] = UIParent
  5019. end
  5020. maPrint(" Point: "..point[1]..", "..point[2]:GetName()..", "..point[3]..", "..point[4]..", "..point[5])
  5021. end
  5022. s = ""
  5023. if o:GetTop() then
  5024. s = " Top: "..o:GetTop()
  5025. end
  5026. if o:GetRight() then
  5027. s = s.." Right: "..o:GetRight()
  5028. end
  5029. if o:GetBottom() then
  5030. s = s.." Bottom: "..o:GetBottom()
  5031. end
  5032. if o:GetLeft() then
  5033. s = s.." Left: "..o:GetLeft()
  5034. end
  5035. if s ~= "" then
  5036. maPrint(s)
  5037. end
  5038. s = ""
  5039. if o:GetHeight() then
  5040. s = " Height: "..o:GetHeight()
  5041. end
  5042. if o:GetWidth() then
  5043. s = s.." Width: "..o:GetWidth()
  5044. end
  5045. if s ~= "" then
  5046. maPrint(s)
  5047. end
  5048. s = ""
  5049. if o.GetScale then
  5050. s = s.." Scale: "..o:GetScale()
  5051. end
  5052. if o.GetEffectiveScale then
  5053. s = s.." Effective: "..o:GetEffectiveScale()
  5054. end
  5055. if s ~= "" then
  5056. maPrint(s)
  5057. end
  5058. s = ""
  5059. if o.GetAlpha then
  5060. s = s.." Alpha: "..o:GetAlpha()
  5061. end
  5062. if o.GetEffectiveAlpha then
  5063. s = s.." Effective: "..o:GetEffectiveAlpha()
  5064. end
  5065. if s ~= "" then
  5066. maPrint(s)
  5067. end
  5068. s = ""
  5069. if o.IsUserPlaced then
  5070. if o:IsUserPlaced() then
  5071. s = s.." UserPlaced: true"
  5072. else
  5073. s = s.." UserPlaced: false"
  5074. end
  5075. end
  5076. if o.IsMovable then
  5077. if o:IsMovable() then
  5078. s = s.." Movable: true"
  5079. else
  5080. s = s.." Movable: false"
  5081. end
  5082. end
  5083. if o.IsResizable then
  5084. if o:IsResizable() then
  5085. s = s.." Resizable: true"
  5086. else
  5087. s = s.." Resizable: false"
  5088. end
  5089. end
  5090. if s ~= "" then
  5091. maPrint(s)
  5092. end
  5093. s = ""
  5094. if o.IsKeyboardEnabled then
  5095. if o:IsKeyboardEnabled() then
  5096. s = s.." KeyboardEnabled: true"
  5097. else
  5098. s = s.." KeyboardEnabled: false"
  5099. end
  5100. end
  5101. if o.IsMouseEnabled then
  5102. if o:IsMouseEnabled() then
  5103. s = s.." MouseEnabled: true"
  5104. else
  5105. s = s.." MouseEnabled: false"
  5106. end
  5107. end
  5108. if o.IsMouseWheelEnabled then
  5109. if o:IsMouseWheelEnabled() then
  5110. s = s.." MouseWheelEnabled: true"
  5111. else
  5112. s = s.." MouseWheelEnabled: false"
  5113. end
  5114. end
  5115. if s ~= "" then
  5116. maPrint(s)
  5117. end
  5118. local opts = self:GetUserData(o:GetName())
  5119. if opts ~= nil then
  5120. maPrint(" MA stored variables:")
  5121. for i, v in pairs(opts) do
  5122. if i ~= "cat" and i ~= "name" then
  5123. if v == nil then
  5124. maPrint(" "..i..": nil")
  5125. elseif v == true then
  5126. maPrint(" "..i..": true")
  5127. elseif v == false then
  5128. maPrint(" "..i..": false")
  5129. elseif type(v) == "string" then
  5130. maPrint(" "..i..": "..v)
  5131. elseif type(v) == "number" then
  5132. maPrint(" "..i..": "..MANumFor(v))
  5133. elseif type(v) == "table" then
  5134. s = ""
  5135. for i2, v2 in pairs(v) do
  5136. if type(v2) == "table" then
  5137. s = s.." "..i2..": "
  5138. for i3, v3 in pairs(v2) do
  5139. s = s.." "..v3
  5140. end
  5141. else
  5142. s = s.." "..v2
  5143. end
  5144. end
  5145. maPrint(" "..i..":"..s)
  5146. else
  5147. maPrint(" "..i.." is a "..type(v).."")
  5148. end
  5149. end
  5150. end
  5151. end
  5152. end
  5153.  
  5154. SLASH_MADBG1 = "/madbg"
  5155. SlashCmdList["MADBG"] = function(msg)
  5156. if msg == nil or msg == "" then
  5157. return
  5158. end
  5159. local f = _G[msg]
  5160. if f == nil then
  5161. local tr = MovAny:Translate(msg)
  5162. if tr then
  5163. f = _G[tr]
  5164. end
  5165. end
  5166. if f == nil then
  5167. maPrint(string.format(MOVANY.ELEMENT_NOT_FOUND_NAMED, msg))
  5168. else
  5169. MovAny:Dump(f)
  5170. end
  5171. end
  5172.  
  5173. MovAny.dbg = dbg
  5174.  
  5175. -- X: Blizzard Interface Options functions
  5176. function MovAny:OptionCheckboxChecked(button, var)
  5177. if var == "squareMM" then
  5178. if button:GetChecked() then
  5179. Minimap:SetMaskTexture("Interface\\AddOns\\MoveAnything\\Textures\\MinimapMaskSquare")
  5180. else
  5181. Minimap:SetMaskTexture("Textures\\MinimapMask")
  5182. end
  5183. elseif var =="closeGUIOnEscape" then
  5184. if button:GetChecked() then
  5185. tinsert(UISpecialFrames, "MAOptions")
  5186. else
  5187. for i, v in pairs(UISpecialFrames) do
  5188. if v == "MAOptions" then
  5189. tremove(UISpecialFrames, i)
  5190. break
  5191. end
  5192. end
  5193. end
  5194. end
  5195. MADB[var] = button:GetChecked()
  5196. MovAny:UpdateGUIIfShown()
  5197. end
  5198.  
  5199. function MovAny:SetOptions()
  5200. MADB.alwaysShowNudger = MAOptAlwaysShowNudger:GetChecked()
  5201. MADB.noBags = MAOptNoBags:GetChecked()
  5202. MADB.noMMMW = MAOptNoMMMW:GetChecked()
  5203. MADB.playSound = MAOptPlaySound:GetChecked()
  5204. MADB.tooltips = MAOptShowTooltips:GetChecked()
  5205. if MAOptCloseGUIOnEscape:GetChecked() then
  5206. MADB.closeGUIOnEscape = true
  5207. else
  5208. MADB.closeGUIOnEscape = false
  5209. end
  5210. MADB.squareMM = MAOptsSquareMM:GetChecked()
  5211. MADB.dontHookCreateFrame = MAOptDontHookCreateFrame:GetChecked()
  5212. MADB.dontSyncWhenLeavingCombat = MAOptDontSyncWhenLeavingCombat:GetChecked()
  5213. MADB.dontSearchFrameNames = MAOptDontSearchFrameNames:GetChecked()
  5214. MADB.disableErrorMessages = MAOptDisableErrorMessages:GetChecked()
  5215. MADB.frameListRows = MAOptRowsSlider:GetValue()
  5216. if MADB.closeGUIOnEscape then
  5217. tinsert(UISpecialFrames, "MAOptions")
  5218. else
  5219. for i, v in pairs(UISpecialFrames) do
  5220. if v == "MAOptions" then
  5221. tremove(UISpecialFrames, i)
  5222. break
  5223. end
  5224. end
  5225. end
  5226. end
  5227.  
  5228. function MovAny:SetDefaultOptions()
  5229. if MADB.squareMM then
  5230. Minimap:SetMaskTexture("Textures\\MinimapMask")
  5231. end
  5232. if MADB.closeGUIOnEscape then
  5233. for i, v in pairs(UISpecialFrames) do
  5234. if v == "MAOptions" then
  5235. tremove(UISpecialFrames, i)
  5236. break
  5237. end
  5238. end
  5239. end
  5240. MADB.alwaysShowNudger = nil
  5241. MADB.noBags = nil
  5242. MADB.noMMMW = nil
  5243. MADB.playSound = nil
  5244. MADB.tooltips = true
  5245. MADB.closeGUIOnEscape = nil
  5246. MADB.squareMM = nil
  5247. MADB.dontHookCreateFrame = nil
  5248. MADB.dontSyncWhenLeavingCombat = nil
  5249. MADB.dontSearchFrameNames = nil
  5250. MADB.frameListRows = 18
  5251. MovAny_OptionsOnShow()
  5252. MovAny:UpdateGUIIfShown()
  5253. end
  5254.  
  5255. function MovAny_OptionsOnLoad(f)
  5256. f.name = GetAddOnMetadata("MoveAnything", "Title")
  5257. f.okay = MovAny.SetOptions
  5258. f.default = MovAny.SetDefaultOptions
  5259. InterfaceOptions_AddCategory(f)
  5260. end
  5261.  
  5262. function MovAny_OptionsOnShow()
  5263. MAOptVersion:SetText("Version: |cffeeeeee"..GetAddOnMetadata("MoveAnything", "Version").."|r")
  5264. MAOptAlwaysShowNudger:SetChecked(MADB.alwaysShowNudger)
  5265. MAOptNoBags:SetChecked(MADB.noBags)
  5266. MAOptPlaySound:SetChecked(MADB.playSound)
  5267. MAOptShowTooltips:SetChecked(MADB.tooltips)
  5268. MAOptCloseGUIOnEscape:SetChecked(MADB.closeGUIOnEscape)
  5269. MAOptSquareMM:SetChecked(MADB.squareMM)
  5270. MAOptNoMMMW:SetChecked(MADB.noMMMW)
  5271. MAOptDontHookCreateFrame:SetChecked(MADB.dontHookCreateFrame)
  5272. MAOptDontSyncWhenLeavingCombat:SetChecked(MADB.dontSyncWhenLeavingCombat)
  5273. MAOptDontSearchFrameNames:SetChecked(MADB.dontSearchFrameNames)
  5274. MAOptDisableErrorMessages:SetChecked(MADB.disableErrorMessages)
  5275. if MADB.frameListRows then
  5276. MAOptRowsSlider:SetValue(MADB.frameListRows)
  5277. end
  5278. if type(MADB.characters) == "table" then
  5279. local profile = MovAny:GetProfileName()
  5280. Lib_UIDropDownMenu_Initialize(MAOptProfileDropDown, MovAny.ProfileDropDownInit)
  5281. Lib_UIDropDownMenu_SetSelectedValue(MAOptProfileDropDown, profile)
  5282. if "default" == profile then
  5283. MAOptProfileRename:Disable()
  5284. MAOptProfileDelete:Disable()
  5285. else
  5286. MAOptProfileRename:Enable()
  5287. MAOptProfileDelete:Enable()
  5288. end
  5289. end
  5290. end
  5291.  
  5292. --[[function MovAny:ProfileRenameClicked(b)
  5293. MoveAny_ProfileRename:Show()
  5294. MoveAny_ProfileRename.editBox:SetText(MovAny:GetProfileName())
  5295. end
  5296.  
  5297. function MovAny:ProfileSaveAsClicked(b)
  5298. MoveAny_SaveAs:Show()
  5299. end
  5300.  
  5301. function MovAny:ProfileAddClicked(b)
  5302. MoveAny_ProfileAdd:Show()
  5303. end
  5304.  
  5305. function MovAny:ProfileDeleteClicked(b)
  5306. StaticPopup_Show("MOVEANYTHING_PROFILE_DELETE", MovAny:GetProfileName())
  5307. MoveAny_ProfileDelete:Show()
  5308. end
  5309.  
  5310. function MovAny.ProfileDropDownClicked(b)
  5311. MovAny:ChangeProfile(b.value)
  5312. MovAny_OptionsOnShow()
  5313. end]]
  5314.  
  5315. function MovAny:ProfileRenameClicked(b)
  5316. local dlg = StaticPopup_Show("MOVEANYTHING_PROFILE_RENAME", MovAny:GetProfileName())
  5317. if dlg then
  5318. dlg.editBox:SetText(MovAny:GetProfileName())
  5319. end
  5320. end
  5321.  
  5322. function MovAny:ProfileSaveAsClicked(b)
  5323. StaticPopup_Show("MOVEANYTHING_PROFILE_SAVE_AS")
  5324. end
  5325.  
  5326. function MovAny:ProfileAddClicked(b)
  5327. StaticPopup_Show("MOVEANYTHING_PROFILE_ADD")
  5328. end
  5329.  
  5330. function MovAny:ProfileDeleteClicked(b)
  5331. StaticPopup_Show("MOVEANYTHING_PROFILE_DELETE", MovAny:GetProfileName())
  5332. end
  5333.  
  5334. function MovAny.ProfileDropDownClicked(b)
  5335. MovAny:ChangeProfile(b.value)
  5336. MovAny_OptionsOnShow()
  5337. end
  5338. function MovAny.ProfileDropDownInit()
  5339. local sel = MovAny:GetProfileName()
  5340. local info
  5341. info = Lib_UIDropDownMenu_CreateInfo()
  5342. info.text = "default"
  5343. info.value = "default"
  5344. info.func = MovAny.ProfileDropDownClicked
  5345. if "default" == sel then
  5346. info.checked = true
  5347. end
  5348. Lib_UIDropDownMenu_AddButton(info)
  5349. local names = { }
  5350. for name, _ in pairs(MADB.profiles) do
  5351. tinsert(names, name)
  5352. end
  5353. table.sort(names, function(o1, o2)
  5354. return o1:lower() < o2:lower()
  5355. end)
  5356. for _, name in pairs(names) do
  5357. if "default" ~= name then
  5358. info = Lib_UIDropDownMenu_CreateInfo()
  5359. info.text = name
  5360. info.value = name
  5361. info.func = MovAny.ProfileDropDownClicked
  5362. if name == sel then
  5363. info.checked = true
  5364. end
  5365. Lib_UIDropDownMenu_AddButton(info)
  5366. end
  5367. end
  5368. end
  5369.  
  5370. function MovAny:SetNumRows(num, dontUpdate)
  5371. if not MAOptions then
  5372. return
  5373. end
  5374. num = tonumber(format("%.0f", tostring(num)))
  5375. MADB.frameListRows = num
  5376. local base = 0
  5377. local h = 24
  5378. MAOptions:SetHeight(base + 81 + (num * h))
  5379. MAScrollFrame:SetHeight(base + 11 + (num * h))
  5380. MAScrollBorder:SetHeight(base - 22 + (num * h))
  5381. for i = 1, 100, 1 do
  5382. local row = _G["MAMove"..i]
  5383. if num >= i then
  5384. if not row then
  5385. row = CreateFrame("Frame", "MAMove"..i, MAOptions, "MAListRowTemplate")
  5386. if i == 1 then
  5387. row:SetPoint("TOPLEFT", "MAOptionsFrameNameHeader", "BOTTOMLEFT", -8, -4)
  5388. else
  5389. row:SetPoint("TOPLEFT", "MAMove"..(i - 1), "BOTTOMLEFT")
  5390. end
  5391. local label = _G[ "MAMove"..i.."FrameName" ]
  5392. label:SetScript("OnEnter", MovAny_TooltipShowMultiline)
  5393. label:SetScript("OnLeave", MovAny_TooltipHide)
  5394. end
  5395. else
  5396. if row then
  5397. row:Hide()
  5398. end
  5399. end
  5400. end
  5401. _G["MAOptRowsSliderText"]:SetText(num)
  5402. if not dontUpdate then
  5403. self:UpdateGUIIfShown(true)
  5404. end
  5405. end
  5406.  
  5407. function MovAny_TooltipShow(a, b, c, d, e)
  5408. MovAny:TooltipShow(a,b,c,d,e)
  5409. end
  5410.  
  5411. function MovAny_TooltipHide(a, b, c, d, e)
  5412. MovAny:TooltipHide(a,b,c,d,e)
  5413. end
  5414.  
  5415. function MovAny_TooltipShowMultiline(a, b, c, d, e)
  5416. MovAny:TooltipShowMultiline(a,b,c,d,e)
  5417. end
  5418.  
  5419. local stateMonitor = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate")
  5420.  
  5421. function MovAny:Search(searchWord)
  5422. if searchWord ~= MOVANY.SEARCH_TEXT then
  5423. searchWord = string.gsub(string.gsub(string.lower(searchWord), "([%(%)%%%.%[%]%+%-%?])", "%%%1"), "%*", "[%%w %%c]*")
  5424. if self.searchWord ~= searchWord then
  5425. -- searchWord ~= MOVANY.SEARCH_TEXT
  5426. self.searchWord = searchWord
  5427. self:UpdateGUIIfShown(true)
  5428. end
  5429. else
  5430. self.searchWord = nil
  5431. self:UpdateGUIIfShown()
  5432. end
  5433. end
  5434.  
  5435. function MovAny_OnEvent(self, event, arg1)
  5436. if event == "PLAYER_REGEN_DISABLED" then
  5437. if #MovAny.movers > 0 then
  5438. for i, v in ipairs(MA_tcopy(MovAny.movers)) do
  5439. if MovAny:IsProtected(v.tagged) then
  5440. tinsert(MovAny.pendingMovers, v.tagged)
  5441. MovAny:StopMoving(v.tagged:GetName())
  5442. end
  5443. end
  5444. end
  5445. elseif event == "PLAYER_REGEN_ENABLED" then
  5446. if #MovAny.pendingMovers > 0 then
  5447. for i, v in ipairs(MovAny.pendingMovers) do
  5448. if _G.MAOptionsToggleMovers:GetChecked() then
  5449. MovAny:AttachMover(v:GetName())
  5450. else
  5451. tinsert(MovAny.minimizedMovers, v)
  5452. end
  5453. end
  5454. table.wipe(MovAny.pendingMovers)
  5455. end
  5456. if not MADB.dontSyncWhenLeavingCombat then
  5457. MovAny:SyncFrames()
  5458. end
  5459. elseif event == "ADDON_LOADED" then
  5460. if arg1 == "MoveAnything" then
  5461. if MovAny.Load ~= nil then
  5462. MovAny:Load()
  5463. MovAny.Load = nil
  5464. if MovAny:IsModified(LFRParentFrame) then
  5465. MovAny:ResetFrame(LFRParentFrame)
  5466. end
  5467. if MovAny:IsModified(QuestLogFrame) then
  5468. MovAny:ResetFrame(QuestLogFrame)
  5469. end
  5470. if MovAny:IsModified(QuestLogDetailFrame) then
  5471. MovAny:ResetFrame(QuestLogDetailFrame)
  5472. end
  5473. if MovAny:IsModified(PlayerPowerBarAltCounterBar) then
  5474. MovAny:ResetFrame(PlayerPowerBarAltCounterBar)
  5475. end
  5476. for k, v in pairs(MADB.profiles) do
  5477. if v.frames["PaladinPowerBar"] then
  5478. v.frames["PaladinPowerBar"] = nil
  5479. end
  5480. for i = 1, 10 do
  5481. if v.frames["LootWonAlertMover"..i] then
  5482. v.frames["LootWonAlertMover"..i] = nil
  5483. end
  5484. end
  5485. for i = 1, 5 do
  5486. if v.frames["MoneyWonAlertMover"..i] then
  5487. v.frames["MoneyWonAlertMover"..i] = nil
  5488. end
  5489. end
  5490. end
  5491. end
  5492. elseif arg1 == "Blizzard_TalentUI" and MovAny.hBlizzard_TalentUI then
  5493. MovAny:hBlizzard_TalentUI()
  5494. --[[elseif arg1 == "Blizzard_AchievementUI" then
  5495. setfenv(AchievementFrame_OnShow, setmetatable({UpdateMicroButtons = function()
  5496. if (AchievementFrame and AchievementFrame:IsShown()) then
  5497. AchievementMicroButton:SetButtonState("PUSHED", 1)
  5498. end
  5499. end }, { __index = _G}))
  5500. elseif arg1 == "Blizzard_PetJournal" then
  5501. setfenv(PetJournalParent_OnShow, setmetatable({UpdateMicroButtons = function()
  5502. if (PetJournalParent and PetJournalParent:IsShown()) then
  5503. CollectionsMicroButton:Enable()
  5504. CollectionsMicroButton:SetButtonState("PUSHED", 1)
  5505. end
  5506. end }, { __index = _G}))]]
  5507. --[=[elseif arg1 == "Blizzard_ArenaUI" then
  5508. ArenaEnemyFrame_UpdatePet = function() end
  5509. ArenaEnemyFrames_UpdateWatchFrame = function()
  5510. local _, instanceType = IsInInstance()
  5511. if not WatchFrame:IsUserPlaced() then
  5512. if ArenaEnemyFrames:IsShown() then
  5513. if WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests) then
  5514. ArenaEnemyFrames.hidWatchedQuests = true
  5515. end
  5516. elseif instanceType == "arena" or instanceType == "pvp" then
  5517. if WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests) then
  5518. ArenaEnemyFrames.hidWatchedQuests = true
  5519. end
  5520. else
  5521. if ArenaEnemyFrames.hidWatchedQuests then
  5522. WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
  5523. ArenaEnemyFrames.hidWatchedQuests = false
  5524. end
  5525. end
  5526. WatchFrame_ClearDisplay()
  5527. WatchFrame_Update()
  5528. elseif ArenaEnemyFrames.hidWatchedQuests then
  5529. WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
  5530. ArenaEnemyFrames.hidWatchedQuests = false
  5531. WatchFrame_ClearDisplay()
  5532. WatchFrame_Update()
  5533. end
  5534. end
  5535. ArenaPrepFrames_UpdateWatchFrame = function()
  5536. local _, instanceType = IsInInstance()
  5537. if not WatchFrame:IsUserPlaced() then
  5538. if ArenaPrepFrames:IsShown() then
  5539. if WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests) then
  5540. ArenaPrepFrames.hidWatchedQuests = true
  5541. end
  5542. elseif instanceType == "arena" or instanceType == "pvp" then
  5543. if WatchFrame_RemoveObjectiveHandler(WatchFrame_DisplayTrackedQuests) then
  5544. ArenaPrepFrames.hidWatchedQuests = true
  5545. end
  5546. else
  5547. if ArenaPrepFrames.hidWatchedQuests then
  5548. WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
  5549. ArenaPrepFrames.hidWatchedQuests = false
  5550. end
  5551. end
  5552. WatchFrame_ClearDisplay()
  5553. WatchFrame_Update()
  5554. elseif ArenaPrepFrames.hidWatchedQuests then
  5555. WatchFrame_AddObjectiveHandler(WatchFrame_DisplayTrackedQuests)
  5556. ArenaPrepFrames.hidWatchedQuests = false
  5557. WatchFrame_ClearDisplay()
  5558. WatchFrame_Update()
  5559. end
  5560. end
  5561. hooksecurefunc("ArenaEnemyFrame_UpdatePlayer", MovAny.hookArenaEnemyFrames15)
  5562. hooksecurefunc("UpdatePrepFrames", MovAny.hookArenaEnemyFrames15)
  5563. hooksecurefunc("ArenaEnemyFrames_UpdateVisible", MovAny.hookArenaEnemyFrames15)
  5564. hooksecurefunc("ArenaEnemyFrames_Enable", MovAny.hArenaEnemyFrames_Enable)
  5565. hooksecurefunc("ArenaEnemyFrames_Disable", MovAny.hArenaEnemyFrames_Disable)
  5566. --hooksecurefunc("ArenaEnemyFrames_UpdateWatchFrame", MovAny.hWatchFrameExpand)
  5567. if ArenaPrepFrames and not ArenaPrepFrames.hooked_ma then
  5568. ArenaPrepFrames.hooked_ma = true
  5569. ArenaPrepFrames.ma_Show = ArenaPrepFrames.Show
  5570. --[[ArenaPrepFrames.Show = function(self)
  5571. if not InCombatLockdown() then
  5572. self:ma_Show()
  5573. end
  5574. end]]
  5575. ArenaPrepFrames.Hide = function()
  5576. ArenaPrepFrames.ma_isshown = false
  5577. ArenaPrepFrames_UpdateWatchFrame()
  5578. end
  5579. ArenaPrepFrames.IsShown = function()
  5580. local _, instanceType = IsInInstance()
  5581. if instanceType == "arena" or instanceType == "pvp" then
  5582. return true
  5583. else
  5584. if ArenaPrepFrame1:IsShown() then
  5585. return true
  5586. end
  5587. if ArenaPrepFrame2:IsShown() then
  5588. return true
  5589. end
  5590. if ArenaPrepFrame3:IsShown() then
  5591. return true
  5592. end
  5593. if ArenaPrepFrame4:IsShown() then
  5594. return true
  5595. end
  5596. if ArenaPrepFrame5:IsShown() then
  5597. return true
  5598. end
  5599. end
  5600. return false
  5601. end
  5602. if GetCVarBool("showArenaEnemyFrames") then
  5603. ArenaPrepFrames:Show()
  5604. else
  5605. ArenaPrepFrames:Hide()
  5606. end
  5607. ArenaPrepFrames.Show = function()
  5608. ArenaPrepFrames.ma_isshown = true
  5609. ArenaPrepFrames_UpdateWatchFrame()
  5610. end
  5611. ArenaPrepFrames.ma_Hide = ArenaPrepFrames.Hide
  5612. --[[ArenaPrepFrames.Hide = function(self)
  5613. if not InCombatLockdown() then
  5614. self:ma_Hide()
  5615. end
  5616. end]]
  5617. ArenaPrepFrames.clear_all_points = ArenaPrepFrames.ClearAllPoints
  5618. ArenaPrepFrames.ClearAllPoints = function(self)
  5619. if not InCombatLockdown() then
  5620. self:clear_all_points()
  5621. end
  5622. end
  5623. ArenaPrepFrames.set_points = ArenaPrepFrames.SetPoint
  5624. ArenaPrepFrames.SetPoint = function(self, ...)
  5625. if not InCombatLockdown() then
  5626. self:set_points(...)
  5627. end
  5628. end
  5629. end
  5630. if ArenaEnemyFrames and not ArenaEnemyFrames.hooked_ma then
  5631. ArenaEnemyFrames.hooked_ma = true
  5632. ArenaEnemyFrames.ma_Show = ArenaEnemyFrames.Show
  5633. --[[ArenaEnemyFrames.Show = function(self)
  5634. if not InCombatLockdown() then
  5635. self:ma_Show()
  5636. end
  5637. end]]
  5638. ArenaEnemyFrames.IsShown = function()
  5639. local _, instanceType = IsInInstance()
  5640. if instanceType == "arena" or instanceType == "pvp" then
  5641. return true
  5642. else
  5643. if ArenaEnemyFrame1:IsShown() then
  5644. return true
  5645. end
  5646. if ArenaEnemyFrame2:IsShown() then
  5647. return true
  5648. end
  5649. if ArenaEnemyFrame3:IsShown() then
  5650. return true
  5651. end
  5652. if ArenaEnemyFrame4:IsShown() then
  5653. return true
  5654. end
  5655. if ArenaEnemyFrame5:IsShown() then
  5656. return true
  5657. end
  5658. end
  5659. return false
  5660. end
  5661. ArenaEnemyFrames.ma_Hide = ArenaEnemyFrames.Hide
  5662. --[[ArenaEnemyFrames.Hide = function(self)
  5663. if not InCombatLockdown() then
  5664. self:ma_Hide()
  5665. end
  5666. end]]
  5667. ArenaEnemyFrames.Hide = function()
  5668. ArenaEnemyFrames.ma_isshown = false
  5669. ArenaEnemyFrames_UpdateWatchFrame()
  5670. end
  5671. if GetCVarBool("showArenaEnemyFrames") then
  5672. ArenaEnemyFrames:Show()
  5673. else
  5674. ArenaEnemyFrames:Hide()
  5675. end
  5676. ArenaEnemyFrames.Show = function()
  5677. ArenaEnemyFrames.ma_isshown = true
  5678. ArenaEnemyFrames_UpdateWatchFrame()
  5679. end
  5680. ArenaEnemyFrames.clear_all_points = ArenaEnemyFrames.ClearAllPoints
  5681. ArenaEnemyFrames.ClearAllPoints = function(self)
  5682. if not InCombatLockdown() then
  5683. self:clear_all_points()
  5684. end
  5685. end
  5686. ArenaEnemyFrames.set_points = ArenaEnemyFrames.SetPoint
  5687. ArenaEnemyFrames.SetPoint = function(self, ...)
  5688. if not InCombatLockdown() then
  5689. self:set_points(...)
  5690. end
  5691. end
  5692. end
  5693. --ArenaEnemyFrame1:ClearAllPoints()
  5694. ArenaEnemyFrame1:SetPoint("TOP", UIParent, "TOP", 600, - 300)
  5695. ArenaEnemyFrame1:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  5696. ArenaEnemyFrame2:SetPoint("TOP", ArenaEnemyFrame1, "BOTTOM", 0, - 20)
  5697. ArenaEnemyFrame2:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  5698. ArenaEnemyFrame3:SetPoint("TOP", ArenaEnemyFrame2, "BOTTOM", 0, - 20)
  5699. ArenaEnemyFrame3:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  5700. ArenaEnemyFrame4:SetPoint("TOP", ArenaEnemyFrame3, "BOTTOM", 0, - 20)
  5701. ArenaEnemyFrame4:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  5702. ArenaEnemyFrame5:SetPoint("TOP", ArenaEnemyFrame4, "BOTTOM", 0, - 20)
  5703. ArenaEnemyFrame5:SetPoint("RIGHT", ArenaEnemyFrames, "RIGHT", - 18, 0)
  5704. for i = 1, 5 do
  5705. local frame = "ArenaEnemyFrame"..i
  5706. if _G[frame] and not _G[frame].hooked_ma then
  5707. _G[frame].hooked_ma = true
  5708. _G[frame].clear_all_points = _G[frame].ClearAllPoints
  5709. _G[frame].ClearAllPoints = function(self)
  5710. if InCombatLockdown() then
  5711. return
  5712. end
  5713. self:clear_all_points()
  5714. end
  5715. _G[frame].set_point = _G[frame].SetPoint
  5716. _G[frame].SetPoint = function(self, ...)
  5717. if InCombatLockdown() then
  5718. return
  5719. end
  5720. self:set_point(...)
  5721. end
  5722. end
  5723. MovAny.API:SyncElement(frame)
  5724. local frame = "ArenaEnemyFrame"..i.."PetFrame"
  5725. if _G[frame] and not _G[frame].hooked_ma then
  5726. _G[frame].hooked_ma = true
  5727. _G[frame]:SetAttribute("unit", "arenapet"..i)
  5728. stateMonitor:WrapScript(_G[frame], "OnAttributeChanged", [[
  5729. if name == "state-unitexists" then
  5730. if UnitExists(self:GetAttribute("unit")) then
  5731. self:Show()
  5732. else
  5733. self:Hide()
  5734. end
  5735. end
  5736. ]])
  5737. RegisterUnitWatch(_G[frame], true)
  5738. --RegisterStateDriver(_G[frame], "visibility", "[@arenapet"..i", exists] show hide")
  5739. end
  5740. MovAny.API:SyncElement(frame)
  5741. end]=]
  5742. end
  5743. MovAny:SyncFrames()
  5744. elseif event == "GROUP_ROSTER_UPDATE" then
  5745. if not MovAny:IsModified(RaidUnitFramesMover) then
  5746. return
  5747. end
  5748. if InCombatLockdown() then
  5749. return
  5750. end
  5751. --[[local f = _G["CompactRaidFrameManager"]
  5752. if f then
  5753. f.MAParent = "RaidUnitFramesManagerMover"
  5754. end]]
  5755. local f = _G["CompactRaidFrameContainer"]
  5756. if f then
  5757. f.MAParent = "RaidUnitFramesMover"
  5758. end
  5759. --MovAny.API:SyncElement("RaidUnitFramesManagerMover")
  5760. MovAny.API:SyncElement("RaidUnitFramesMover")
  5761. --[[elseif event == "PET_BATTLE_OPENING_START" then
  5762. if not MovAny:IsModified(MicroButtonsMover) and not MovAny:IsModified(MicroButtonsSplitMover) and not MovAny:IsModified(MicroButtonsVerticalMover) then
  5763. return
  5764. end
  5765. local children = {
  5766. CharacterMicroButton,
  5767. SpellbookMicroButton,
  5768. TalentMicroButton,
  5769. AchievementMicroButton,
  5770. QuestLogMicroButton,
  5771. GuildMicroButton,
  5772. LFDMicroButton,
  5773. CollectionsMicroButton,
  5774. EJMicroButton,
  5775. StoreMicroButton,
  5776. MainMenuMicroButton
  5777. }
  5778. for i = 1, #children, 1 do
  5779. MovAny:UnlockPoint(children[i])
  5780. MovAny:UnlockScale(children[i])
  5781. children[i]:ClearAllPoints()
  5782. children[i]:SetScale(1)
  5783. if i == 1 then
  5784. children[i]:SetPoint("TOPLEFT", PetBattleFrame.BottomFrame, "TOPRIGHT", - 180, 0)
  5785. elseif children[i] == LFDMicroButton then
  5786. children[i]:SetPoint("LEFT", CharacterMicroButton, "LEFT", 0, - 34)
  5787. else
  5788. children[i]:SetPoint("LEFT", children[i - 1], "RIGHT", - 2, 0)
  5789. end
  5790. MovAny:LockPoint(children[i])
  5791. MovAny:LockScale(children[i])
  5792. end
  5793. elseif event == "PET_BATTLE_CLOSE" then
  5794. if not MovAny:IsModified(MicroButtonsMover) and not MovAny:IsModified(MicroButtonsSplitMover) and not MovAny:IsModified(MicroButtonsVerticalMover) then
  5795. return
  5796. end
  5797. if MovAny:IsModified(MicroButtonsMover) then
  5798. MovAny.API:SyncElement("MicroButtonsMover")
  5799. elseif MovAny:IsModified(MicroButtonsSplitMover) then
  5800. MovAny.API:SyncElement("MicroButtonsSplitMover")
  5801. elseif MovAny:IsModified(MicroButtonsVerticalMover) then
  5802. MovAny.API:SyncElement("MicroButtonsVerticalMover")
  5803. end--]]
  5804. elseif event == "PLAYER_FOCUS_CHANGED" then
  5805. MovAny.API:SyncElement("FocusFrame")
  5806. elseif event == "BANKFRAME_OPENED" then
  5807. local e
  5808. for i = 1, 7, 1 do
  5809. e = API:GetElement("BankBagFrame"..i)
  5810. if e then
  5811. e.refuseSync = nil
  5812. end
  5813. end
  5814. MovAny:SyncFrames()
  5815. for i = 1, 7, 1 do
  5816. MovAny:CreateVM("BankBagFrame"..i)
  5817. end
  5818. elseif event == "BANKFRAME_CLOSED" then
  5819. local e
  5820. for i = 1, 7, 1 do
  5821. e = API:GetElement("BankBagFrame"..i)
  5822. --[[if e then
  5823. e.refuseSync = MOVANY.FRAME_ONLY_WHEN_BANK_IS_OPEN
  5824. end]]
  5825. end
  5826. elseif event == "PLAYER_LOGOUT" then
  5827. MovAny:OnPlayerLogout()
  5828. elseif event == "PLAYER_ENTERING_WORLD" then
  5829. if MovAny.Boot ~= nil then
  5830. MovAny:Boot()
  5831. MovAny.Boot = nil
  5832. end
  5833. MovAny:SyncAllFrames()
  5834. elseif event == "BAG_UPDATE" then
  5835. local e
  5836. if arg1 < 6 then
  5837. e = API:GetElement("BagFrame"..(arg1))
  5838. if e then
  5839. e.refuseSync = nil
  5840. e:Sync()
  5841. end
  5842. else
  5843. for i = 1, 5, 1 do
  5844. e = API:GetElement("BagFrame"..(arg1))
  5845. if e then
  5846. e.refuseSync = nil
  5847. e:Sync()
  5848. end
  5849. end
  5850. MAOptions:UnregisterEvent("BAG_UPDATE")
  5851. end
  5852. elseif event == "UNIT_AURA" then
  5853. if MovAny:IsModified("PlayerBuffsMover") or MovAny:IsModified("PlayerBuffsMover2") then
  5854. MovAny.API:SyncElement(PlayerBuffsMover)
  5855. end
  5856. else
  5857. MovAny:SyncAllFrames()
  5858. end
  5859. end
  5860.  
  5861. function MAMoverTemplate_OnMouseWheel(self, dir)
  5862. MovAny:MoverOnMouseWheel(self, dir)
  5863. end
  5864.  
  5865. function MANudgeButton_OnClick(self, event, button)
  5866. MovAny:Nudge(self.dir, button)
  5867. end
  5868.  
  5869. function MANudger_OnMouseWheel(self, dir)
  5870. MovAny:NudgerChangeMover(dir)
  5871. end
  5872.  
  5873. function MovAny:CreateVM(name)
  5874. local data = MovAny.lVirtualMovers[name]
  5875. if not data then
  5876. return
  5877. end
  5878. if data.created then
  5879. return _G[name]
  5880. end
  5881. local vm = CreateFrame("Frame", name, UIParent, data.inherits, "MADontHook")
  5882. vm.MAEVM = API:GetElement(name)
  5883. --[[if vm.MAEVM and vm.MAEVM.runOnce then
  5884. vm.MAEVM:runOnce()
  5885. vm.MAEVM.runOnce = nil
  5886. end]]
  5887. vm.opt = MovAny:GetUserData(name)
  5888. local opt = vm.opt
  5889. if data.id then
  5890. vm:SetID(data.id)
  5891. end
  5892. vm.data = data
  5893. if data.linkedSize then
  5894. local ref = _G[data.linkedSize]
  5895. if ref then
  5896. vm:SetWidth(ref:GetWidth())
  5897. vm:SetHeight(ref:GetHeight())
  5898. end
  5899. else
  5900. if data.w then
  5901. vm:SetWidth(data.w)
  5902. end
  5903. if data.h then
  5904. vm:SetHeight(data.h)
  5905. end
  5906. end
  5907. if data.s then
  5908. vm:SetScale(data.s)
  5909. end
  5910. if data.dontLock then
  5911. vm.MADontLock = true
  5912. end
  5913. if data.dontHide then
  5914. vm.MADontHide = true
  5915. end
  5916. vm.FoundChild = function(self, index, child)
  5917. if not self.firstChild then
  5918. self.firstChild = child
  5919. end
  5920. child.MAParent = self
  5921. if data.OnMAFoundChild then
  5922. data.OnMAFoundChild(self, index, child)
  5923. --[[xpcall(function()
  5924. data.OnMAFoundChild(self, index, child)
  5925. end,
  5926. function()
  5927. --print("Error: "..debugstack(2, 20, 20))
  5928. end)]]
  5929. end
  5930. if not self.MADontLock then
  5931. MovAny:LockPoint(child)
  5932. end
  5933. if self.MAHidden and not child.MAHidden then
  5934. MovAny:LockVisibility(child)
  5935. end
  5936. self.attachedChildren[index] = child
  5937. self.lastChild = child
  5938. return child
  5939. end
  5940. vm.ReleaseChild = function(self, index)
  5941. local child = self.attachedChildren[index]
  5942. if not child then
  5943. return
  5944. end
  5945. if not self.MADontLock then
  5946. MovAny:UnlockPoint(child)
  5947. end
  5948. if data.OnMAReleaseChild then
  5949. data.OnMAReleaseChild(self, index, child)
  5950. end
  5951. self.lastChild = child
  5952. end
  5953. vm.ReleaseChildByName = function(self, name)
  5954. for i, c in pairs(self.attachedChildren) do
  5955. if c:GetName() == name then
  5956. self:ReleaseChild(i)
  5957. return true
  5958. end
  5959. end
  5960. return false
  5961. end
  5962. local MAScanForChildren = function (self, dontCallNewChild, dontSync)
  5963. if not self.attachedChildren then
  5964. return
  5965. end
  5966. local newChild = false
  5967. if type(data.count) == "number" then
  5968. local name, child
  5969. if data.prefix == "ContainerFrame" then
  5970. for i = 1, data.count, 1 do
  5971. name = data.prefix..i..(data.postfix or "")
  5972. if not self.attachedChildren[name] then
  5973. child = _G[name]
  5974. if child then
  5975. local bag = MovAny:GetBagInContainerFrame(child)
  5976. if not bag or not MovAny:IsModified(bag:GetName()) then
  5977. newChild = self:FoundChild(i, child, 1)
  5978. end
  5979. else
  5980. break
  5981. end
  5982. end
  5983. end
  5984. else
  5985. for i = 1, data.count, 1 do
  5986. name = data.prefix..i..(data.postfix or "")
  5987. if not self.attachedChildren[name] then
  5988. child = _G[name]
  5989. if child then
  5990. if not MovAny:IsModified(name) then
  5991. newChild = self:FoundChild(i, child, 1)
  5992. end
  5993. else
  5994. break
  5995. end
  5996. end
  5997. end
  5998. end
  5999. if data.prefix1 then
  6000. for i = 1, data.count, 1 do
  6001. name = data.prefix1..i..(data.postfix1 or "")
  6002. if not self.attachedChildren[name] then
  6003. child = _G[name]
  6004. if child then
  6005. if not MovAny:IsModified(name) then
  6006. newChild = self:FoundChild(i, child, 2)
  6007. end
  6008. else
  6009. break
  6010. end
  6011. end
  6012. end
  6013. end
  6014. if data.prefix2 then
  6015. for i = 1, data.count, 1 do
  6016. name = data.prefix2..i..(data.postfix2 or "")
  6017. if not self.attachedChildren[name] then
  6018. child = _G[name]
  6019. if child then
  6020. if not MovAny:IsModified(name) then
  6021. newChild = self:FoundChild(i, child, 3)
  6022. end
  6023. else
  6024. break
  6025. end
  6026. end
  6027. end
  6028. end
  6029. end
  6030. if type(data.children) == "table" then
  6031. for i, v in pairs(data.children) do
  6032. local child = type(v) == "string" and _G[v] or v
  6033. if type(child) == "table" and not self.attachedChildren[child:GetName()] then
  6034. if not MovAny:IsModified(child) then
  6035. newChild = self:FoundChild(child:GetName(), child)
  6036. end
  6037. end
  6038. end
  6039. end
  6040. if not dontCallNewChild and newChild and self.OnMANewChild then
  6041. self:OnMANewChild()
  6042. end
  6043. if newChild and not dontSync then
  6044. self.MAEVM:Sync(self)
  6045. end
  6046. end
  6047. vm.MAScanForChildren = function(vm, dontCallNewChild, dontSync)
  6048. --[[xpcall(function()
  6049. MAScanForChildren(vm, dontCallNewChild, dontSync)
  6050. end,]]
  6051. xpcall(function()
  6052. MAScanForChildren(vm, dontCallNewChild, dontSync)
  6053. end, MovAny.SyncErrorHandler)
  6054. end
  6055. if not vm.MAPoint then
  6056. if data.point then
  6057. vm:SetPoint(unpack(data.point))
  6058. if opt and opt.pos and not opt.orgPos then
  6059. opt.orgPos = data.point
  6060. end
  6061. elseif data.relPoint then
  6062. vm:SetPoint(unpack(data.relPoint))
  6063. vm:SetPoint(unpack(self:GetRelativePoint(nil, vm)))
  6064. if opt and opt.pos and not opt.orgPos then
  6065. opt.orgPos = data.point
  6066. end
  6067. elseif not opt or not opt.pos then
  6068. if data.linkedPoint then
  6069. local ref = _G[data.linkedPoint]
  6070. if ref then
  6071. local p = MovAny:GetRelativePoint(nil, ref)
  6072. if p then
  6073. vm:SetPoint(unpack(p))
  6074. end
  6075. end
  6076. end
  6077. end
  6078. elseif data.point then
  6079. opt.orgPos = data.point
  6080. end
  6081. if opt and opt.pos and data.point and not opt.orgPos then
  6082. opt.orgPos = data.point
  6083. end
  6084. if data.protected then
  6085. vm.MAProtected = true
  6086. end
  6087. if data.dontScale then
  6088. vm.MADontScaleChildren = true
  6089. end
  6090. if data.dontAlpha then
  6091. vm.MADontAlphaChildren = true
  6092. end
  6093. if data.frameStrata and (not opt or not opt.frameStrata) then
  6094. vm:SetFrameStrata(data.frameStrata)
  6095. end
  6096. vm.orgOnMAAttach = vm.OnMAAttach
  6097. vm.OnMAAttach = function(self, mover)
  6098. if data.linkedSize then
  6099. local ref = _G[data.linkedSize]
  6100. if ref then
  6101. self:SetWidth(ref:GetWidth())
  6102. self:SetHeight(ref:GetHeight())
  6103. end
  6104. end
  6105. if not self.MAEVM.userData or not self.MAEVM.userData.pos then
  6106. if data.linkedPoint then
  6107. local ref = _G[data.linkedPoint]
  6108. if ref then
  6109. local p = MovAny:GetRelativePoint(nil, ref)
  6110. if p then
  6111. self:SetPoint(unpack(p))
  6112. end
  6113. end
  6114. end
  6115. end
  6116. if data.OnMAAttach then
  6117. data.OnMAAttach(self, mover)
  6118. end
  6119. if data.OnMAPosition then
  6120. data.OnMAPosition(self)
  6121. end
  6122. if vm.orgOnMAAttach then
  6123. vm.orgOnMAAttach(self, mover)
  6124. end
  6125. end
  6126. if data.OnMAPosition then
  6127. vm.OnMAPosition = data.OnMAPosition
  6128. end
  6129. if data.OnMAAlpha then
  6130. vm.OnMAAlpha = data.OnMAAlpha
  6131. end
  6132. if data.OnMAScale then
  6133. vm.OnMAScale = data.OnMAScale
  6134. end
  6135. if data.OnMAPostAttach then
  6136. vm.OnMAPostAttach = data.OnMAPostAttach
  6137. end
  6138.  
  6139. if data.OnMAPostHook then
  6140. vm.OnMAPostHook = data.OnMAPostHook
  6141. end
  6142. vm.OnMAHide = function(self, hidden)
  6143. if hidden then
  6144. if self.attachedChildren then
  6145. for i, v in pairs(self.attachedChildren) do
  6146. MovAny:LockVisibility(v)
  6147. end
  6148. end
  6149. else
  6150. if self.attachedChildren then
  6151. for i, v in pairs(self.attachedChildren) do
  6152. MovAny:UnlockVisibility(v)
  6153. end
  6154. end
  6155. end
  6156. if data.OnMAHide then
  6157. data.OnMAHide(self, hidden)
  6158. end
  6159. end
  6160. if data.OnMAMoving then
  6161. vm.OnMAMoving = data.OnMAMoving
  6162. end
  6163. if data.OnMADetach then
  6164. vm.OnMADetach = data.OnMADetach
  6165. end
  6166. if data.OnMAPositionReset then
  6167. vm.OnMAPositionReset = data.OnMAPositionReset
  6168. end
  6169.  
  6170. if vm.OnMAHook and not data.OnMAHook then
  6171. data.OnMAHook = vm.OnMAHook
  6172. end
  6173. vm.OnMAHook = function(self)
  6174. self.MAEVM = MovAny.API:GetElement(self:GetName())
  6175. self.opt = MovAny:GetUserData(self:GetName())
  6176. if self.opt and self.opt.disabled then
  6177. return
  6178. end
  6179. if data.excludes and MovAny:IsModified(data.excludes) then
  6180. MovAny:ResetFrame(data.excludes)
  6181. MovAny:UpdateGUIIfShown(true)
  6182. end
  6183. if data.excludes2 and MovAny:IsModified(data.excludes2) then
  6184. MovAny:ResetFrame(data.excludes2)
  6185. MovAny:UpdateGUIIfShown(true)
  6186. end
  6187. if self.attachedChildren then
  6188. table.wipe(self.attachedChildren)
  6189. else
  6190. self.attachedChildren = { }
  6191. end
  6192. self:MAScanForChildren(true, true)
  6193. if data.OnMAHook then
  6194. data.OnMAHook(self)
  6195. end
  6196. self:Show()
  6197. end
  6198. if vm.OnMAPostReset and not data.OnMAPostReset then
  6199. data.OnMAPreReset = vm.OnMAPreReset
  6200. end
  6201. vm.OnMAPreReset = function(self, readOnly)
  6202. if data.OnMAPreReset then
  6203. if data.OnMAPreReset(self, readOnly) then
  6204. return
  6205. end
  6206. end
  6207. if type(self.attachedChildren) == "table" then
  6208. if type(data.count) == "number" then
  6209. local name
  6210. for i = 1, data.count, 1 do
  6211. self:ReleaseChild(i)
  6212. end
  6213. end
  6214. if type(self.data.children) == "table" then
  6215. self.lastChild = nil
  6216. for _, name in pairs(self.data.children) do
  6217. self:ReleaseChild(name)
  6218. end
  6219. end
  6220. table.wipe(self.attachedChildren)
  6221. end
  6222. self.firstChild = nil
  6223. self.lastChild = nil
  6224. end
  6225. if vm.OnMAPostReset and not data.OnMAPostReset then
  6226. data.OnMAPostReset = vm.OnMAPostReset
  6227. end
  6228. vm.OnMAPostReset = function(self, readOnly)
  6229. if data.OnMAPostReset then
  6230. if data.OnMAPostReset(self, readOnly) then
  6231. return
  6232. end
  6233. end
  6234. self:Hide()
  6235. end
  6236. if data.OnMAScanForChildren then
  6237. vm.OnMAScanForChildren = data.OnMAScanForChildren
  6238. end
  6239. vm.OnMANewChild = data.OnMANewChild
  6240. vm.MAOnEnable = function(self)
  6241. self:MAScanForChildren()
  6242. end
  6243. if data.inherits then
  6244. local super = _G[data.inherits]
  6245. if super and super.OnMACreateVM then
  6246. vm.OnMACreateVM = super.OnMACreateVM
  6247. vm:OnMACreateVM()
  6248. vm.OnMACreateVM = nil
  6249. end
  6250. end
  6251. if data.OnLoad then
  6252. vm.MAOnLoad = data.OnLoad
  6253. vm:MAOnLoad()
  6254. vm.MAOnLoad = nil
  6255. end
  6256. if data.OnMACreateVM then
  6257. data.OnMACreateVM(vm)
  6258. end
  6259. if vm.OnMACreateVM then
  6260. vm:OnMACreateVM()
  6261. end
  6262. data.created = true
  6263. return vm
  6264. end
  6265.  
  6266. function MovAny:UnserializeProfile(str)
  6267. str = string.gsub(str, "^%s+", "")
  6268. str = string.gsub(str, "%s+$", "")
  6269. str = string.gsub(str, "[\r\n]", "")
  6270. local sName
  6271. for i, v in string.gmatch(str, ",name:\"(.-)\"") do
  6272. sName = i
  6273. end
  6274. if not sName then
  6275. maPrint(MOVANY.UNSERIALIZE_PROFILE_NO_NAME)
  6276. return
  6277. end
  6278. local frames = { }
  6279. local opt
  6280. str = str..","
  6281. for i in string.gmatch(str, "frames:{(.+)}") do
  6282. for j in string.gmatch(i, "(%[.-%])") do
  6283. opt = MovAny:UnserializeFrame(j)
  6284. if opt then
  6285. frames[opt.name] = opt
  6286. end
  6287. end
  6288. end
  6289. local tName = sName
  6290. local ct = 1
  6291. while MADB.profiles[tName] do
  6292. tName = sName.." ("..ct..")"
  6293. ct = ct + 1
  6294. end
  6295. MovAny:AddProfile(tName)
  6296. MADB.profiles[tName].frames = frames
  6297. maPrint(string.format(MOVANY.UNSERIALIZE_PROFILE_COMPLETED, tlen(frames), tName))
  6298. return true
  6299. end
  6300.  
  6301. function MovAny:UnserializeFrame(str, name)
  6302. str = string.gsub(str, "^%s+", "")
  6303. str = string.gsub(str, "%s+$", "")
  6304. str = string.gsub(str, "[\r\n]", "")
  6305. str = string.match(str, "%[(.+)%]")
  6306. --[[s:0.70035458463692, h:1, p:("CENTER", "UIParent", "CENTER", 1028.675318659, 84.760391583122), n:"MAOptions"]]
  6307. if not str then
  6308. maPrint(MOVANY.UNSERIALIZE_FRAME_INVALID_FORMAT)
  6309. return nil
  6310. end
  6311. str = str..","
  6312. local scannedName
  6313. local opt = { }
  6314. for m1, m2, m3 in string.gmatch(str, "(%a+):(.-),") do
  6315. if m1 == "s" then
  6316. opt.scale = tonumber(m2)
  6317. elseif m1 == "hi" then
  6318. opt.hidden = true
  6319. elseif m1 == "a" then
  6320. opt.alpha = tonumber(m2)
  6321. elseif m1 == "w" then
  6322. opt.width = tonumber(m2)
  6323. elseif m1 == "h" then
  6324. opt.height = tonumber(m2)
  6325. elseif m1 == "fs" then
  6326. opt.frameStrata = string.sub(m2, 2, - 2)
  6327. elseif m1 == "cts" then
  6328. opt.clampToScreen = true
  6329. elseif m1 == "em" then
  6330. opt.enableMouse = true
  6331. elseif m1 == "m" then
  6332. opt.movable = true
  6333. elseif m1 == "uae" then
  6334. opt.unregisterAllEvents = true
  6335. elseif m1 == "dla" then
  6336. opt.disableLayerArtwork = true
  6337. elseif m1 == "dlb" then
  6338. opt.disableLayerBackground = true
  6339. elseif m1 == "dlbo" then
  6340. opt.disableLayerBorder = true
  6341. elseif m1 == "dlh" then
  6342. opt.disableLayerHighlight = true
  6343. elseif m1 == "dlo" then
  6344. opt.disableLayerOverlay = true
  6345. elseif m1 == "n" then
  6346. scannedName = string.sub(m2, 2, - 2)
  6347. end
  6348. -- XXX: what to do about groups?
  6349. end
  6350. for m1, m2, m3, m4, m5 in string.gmatch(str, "p:%(\"(.-)\",\"(.-)\",\"(.-)\",(-?%d+%.*%d*),(-?%d+%.*%d*)%)") do
  6351. opt.pos = {m1, m2, m3, tonumber(m4), tonumber(m5)}
  6352. end
  6353. if name and name ~= scannedName then
  6354. maPrint(MOVANY.UNSERIALIZE_FRAME_NAME_DIFFERS)
  6355. return
  6356. end
  6357. opt.name = scannedName or name
  6358. return opt
  6359. end
  6360.  
  6361. function MovAny:SerializeProfile(pn)
  6362. local p = MADB.profiles[pn]
  6363. local s = ""
  6364. for i, v in pairs(p.frames) do
  6365. s = s..","..self:SerializeFrame(i, v)
  6366. end
  6367. s = "frames:{"..string.sub(s, 2).."},name:\""..string.gsub(string.gsub(pn, "%]", ")"), "%[", "(").."\""
  6368. return s
  6369. end
  6370.  
  6371. function MovAny:SerializeFrame(fn, opt)
  6372. opt = opt or self:GetUserData(fn)
  6373. local s = "["
  6374. for i, v in pairs(opt) do
  6375. if i == "pos" then
  6376. s = s.."p:(\""..v[1].."\",\""..v[2].."\",\""..v[3].."\","..v[4]..","..v[5].."),"
  6377. elseif i == "hidden" then
  6378. s = s.."hi:1,"
  6379. elseif i == "alpha" then
  6380. s = s.."a:"..v..","
  6381. elseif i == "scale" then
  6382. s = s.."s:"..v..","
  6383. elseif i == "width" then
  6384. s = s.."w:"..v..","
  6385. elseif i == "height" then
  6386. s = s.."h:"..v..","
  6387. elseif i == "frameStrata" then
  6388. s = s.."fs:\""..v.."\","
  6389. elseif i == "clampToScreen" then
  6390. s = s.."cts:1,"
  6391. elseif i == "enableMouse" then
  6392. s = s.."em:1,"
  6393. elseif i == "movable" then
  6394. s = s.."m:1,"
  6395. elseif i == "unregisterAllEvents" then
  6396. s = s.."uae:1,"
  6397. elseif i == "disableLayerArtwork" then
  6398. s = s.."dla:1,"
  6399. elseif i == "disableLayerBackground" then
  6400. s = s.."dlb:1,"
  6401. elseif i == "disableLayerBorder" then
  6402. s = s.."dlbo:1,"
  6403. elseif i == "disableLayerHighlight" then
  6404. s = s.."dlh:1,"
  6405. elseif i == "disableLayerOverlay" then
  6406. s = s.."dlo:1,"
  6407. end
  6408. end
  6409. s = s.."n:\""..fn.."\"".."]"
  6410. return s
  6411. end
  6412.  
  6413. MovAny.core = { }
  6414. function MovAny:AddCore(name, m)
  6415. m.name = name
  6416. tinsert(self.core, m)
  6417. self[name] = m
  6418. return m
  6419. end
  6420.  
  6421. MovAny.modules = { }
  6422. function MovAny:AddModule(name, m)
  6423. m.name = name
  6424. tinsert(self.modules, m)
  6425. self[name] = m
  6426. return m
  6427. end
  6428.  
  6429. function MovAny:DeleteModule(m)
  6430. for i, v in ipairs(self.modules) do
  6431. if v == m then
  6432. tremove(self.modules, i)
  6433. break
  6434. end
  6435. end
  6436. self[m.name] = nil
  6437. end
  6438.  
  6439. function GetParentInfo(f)
  6440. local fn = f:GetName()
  6441. print("|cFF50C0FF".."<---------------------------------------------->".."|r")
  6442. print("|cFF50C0FF".."Frame:".."|r", fn)
  6443. local p = f:GetParent()
  6444. print("|cFF50C0FF".."Parent:".."|r", p:GetName())
  6445. for i = 1, f:GetNumPoints() do
  6446. local point, relativeTo, relativePoint, xOfs, yOfs = f:GetPoint(i)
  6447. if relativeTo then
  6448. print(i..".", "|cFF50C0FF".."p:".."|r", point, "|cFF50C0FF".."rfn:".."|r", relativeTo:GetName(), "|cFF50C0FF".."rp:".."|r", relativePoint, "|cFF50C0FF".."x:".."|r", xOfs, "|cFF50C0FF".."y:".."|r", yOfs)
  6449. end
  6450. end
  6451. print("|cFF50C0FF".."Width:".."|r", f:GetWidth())
  6452. print("|cFF50C0FF".."Height:".."|r", f:GetHeight())
  6453. end
  6454.  
  6455. function GetParentInfoFromCursor()
  6456. local fn = GetMouseFocus():GetName()
  6457. local f = _G[fn]
  6458. print("|cFF50C0FF".."<---------------------------------------------->".."|r")
  6459. print("|cFF50C0FF".."Frame:".."|r", fn)
  6460. local p = f:GetParent()
  6461. print("|cFF50C0FF".."Parent:".."|r", p:GetName())
  6462. for i = 1, f:GetNumPoints() do
  6463. local point, relativeTo, relativePoint, xOfs, yOfs = f:GetPoint(i)
  6464. if relativeTo then
  6465. print(i..".", "|cFF50C0FF".."p:".."|r", point, "|cFF50C0FF".."rfn:".."|r", relativeTo:GetName(), "|cFF50C0FF".."rp:".."|r", relativePoint, "|cFF50C0FF".."x:".."|r", xOfs, "|cFF50C0FF".."y:".."|r", yOfs)
  6466. end
  6467. end
  6468. print("|cFF50C0FF".."Width:".."|r", f:GetWidth())
  6469. print("|cFF50C0FF".."Height:".."|r", f:GetHeight())
  6470. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement