-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmoveframes.lua
More file actions
779 lines (698 loc) · 24.3 KB
/
moveframes.lua
File metadata and controls
779 lines (698 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
local _, MoveAny = ...
local MAFRAMES = {"HousingInviteResidentFrame", "ClickBindingFrame", "TransmogFrame", "PVPParentFrame", "HouseListFrame", "WatchFrameAutoQuestPopUp1", "GuildControlUI", "HousingModelPreviewFrame", "HousingHouseSettingsFrame", "HousingCornerstoneHouseInfoFrame", "HousingDashboardFrame", "HousingCornerstonePurchaseFrame", "HousingCornerstoneVisitorFrame", "HouseFinderFrame", "HousingBulletinBoardFrame", "CooldownViewerSettings", "RemixArtifactFrame", "StableFrame", "DragonflightUIProfessionFrame", "LFGListInviteDialog", "LFDRoleCheckPopup", "TaxiFrame", "BattlefieldFrame", "ChatConfigFrame", "CurrencyTransferMenu", "HeroTalentsSelectionDialog", "CurrencyTransferLog", "DelvesCompanionConfigurationFrame", "DelvesDifficultyPickerFrame", "ItemRefTooltip", "ReforgingFrameInvisibleButton", "ReforgingFrame", "WeakAurasOptions", "ProfessionsBookFrame", "PlayerSpellsFrame", "GroupLootHistoryFrame", "ModelPreviewFrame", "ScrappingMachineFrame", "TabardFrame", "ArchaeologyFrame", "QuestLogDetailFrame", "InspectRecipeFrame", "SettingsPanel", "SplashFrame", "InterfaceOptionsFrame", "QuickKeybindFrame", "VideoOptionsFrame", "KeyBindingFrame", "MacroFrame", "AddonList", "ContainerFrameCombinedBags", "LFGParentFrame", "CharacterFrame", "InspectFrame", "SpellBookFrame", "PlayerTalentFrame", "ClassTalentFrame", "FriendsFrame", "HelpFrame", "TradeFrame", "TradeSkillFrame", "CraftFrame", "QuestLogFrame", "ChallengesKeystoneFrame", "CovenantMissionFrame", "OrderHallMissionFrame", "PVPMatchScoreboard", "GossipFrame", "MerchantFrame", "PetStableFrame", "QuestFrame", "ClassTrainerFrame", "AchievementFrame", "PVEFrame", "EncounterJournal", "WeeklyRewardsFrame", "BankFrame", "WardrobeFrame", "DressUpFrame", "OpenMailFrame", "AuctionHouseFrame", "AuctionFrame", "ProfessionsCustomerOrdersFrame", "AnimaDiversionFrame", "CovenantSanctumFrame", "SoulbindViewer", "GarrisonLandingPage", "PlayerChoiceFrame", "GenericPlayerChoiseTobbleButton", "WorldStateScoreFrame", "ItemTextFrame", "ExpansionLandingPage", "MajorFactionRenownFrame", "GenericTraitFrame", "FlightMapFrame", "ItemUpgradeFrame", "ProfessionsFrame", "CommunitiesFrame", "CollectionsJournal", "CovenantRenownFrame", "ChallengesKeystoneFrame", "ScriptErrorsFrame", "CalendarFrame", "TimeManagerFrame", "GuildBankFrame", "ItemSocketingFrame", "BlackMarketFrame", "QuestLogPopupDetailFrame", "ItemInteractionFrame", "GarrisonCapacitiveDisplayFrame", "ChannelFrame",}
local MAFRAMESIGNORECLAMP = {}
MAFRAMESIGNORECLAMP["TEST"] = true
if not MoveAny:IsAddOnLoaded("Leatrix_Maps") then
tinsert(MAFRAMES, "WorldMapFrame")
end
if MoveAny:GetWoWBuild() ~= "TBC" then
tinsert(MAFRAMES, "PVPFrame")
end
tinsert(MAFRAMES, "GameMenuFrame")
tinsert(MAFRAMES, "PVPReadyDialog")
tinsert(MAFRAMES, "ReadyCheckFrame")
tinsert(MAFRAMES, "RolePollPopup")
tinsert(MAFRAMES, "StaticPopup1")
tinsert(MAFRAMES, "StaticPopup2")
tinsert(MAFRAMES, "InstanceAbandonPopup")
local MAFS = {}
for i, v in pairs(MAFRAMES) do
MAFS[v] = v
end
if C_Widget.IsWidget(ScriptErrorsFrame) and ScriptErrorsFrame.DragArea then
local setParent = false
hooksecurefunc(
ScriptErrorsFrame.DragArea,
"SetParent",
function(sel)
if setParent then return end
setParent = true
MoveAny:TrySetParent(sel, MoveAny:GetHidden())
setParent = false
end
)
MoveAny:TrySetParent(ScriptErrorsFrame.DragArea, MoveAny:GetHidden())
end
local currentWindowName = nil
local prevMouseX = nil
local prevMouseY = nil
local updatingFrame = false
function MoveAny:UpdateCurrentWindow()
if currentWindowName ~= nil then
local currentWindow = _G[currentWindowName]
if currentWindow then
if updatingFrame then return end
updatingFrame = true
if not currentWindow:IsShown() then
currentWindow:SetAlpha(1)
currentWindowName = nil
GameTooltip:Hide()
end
if currentWindowName ~= nil and MoveAny:IsEnabled("SCALEFRAMES", true) then
local curMouseX, curMouseY = GetCursorPosition()
if prevMouseX and prevMouseY then
if curMouseY > prevMouseY then
local newScale = math.min(currentWindow:GetScale() + 0.006, 2.5)
if newScale > 0 then
newScale = tonumber(string.format("%.3f", newScale)) or 1
currentWindow:SetScale(newScale)
if currentWindow.isMaximized and newScale > 1 then
newScale = 1
end
MoveAny:SetFrameScale(currentWindowName, newScale)
end
elseif curMouseY < prevMouseY then
local newScale = math.max(currentWindow:GetScale() - 0.006, 0.5)
if newScale > 0 then
newScale = tonumber(string.format("%.3f", newScale)) or 1
currentWindow:SetScale(newScale)
if currentWindow.isMaximized and newScale > 1 then
newScale = 1
end
MoveAny:SetFrameScale(currentWindowName, newScale)
end
end
end
GameTooltip:SetOwner(currentWindow, "ANCHOR_CURSOR")
GameTooltip:SetText(MoveAny:MathR(currentWindow:GetScale() * 100) .. "%")
prevMouseX = curMouseX
prevMouseY = curMouseY
end
updatingFrame = false
MoveAny:After(0.02, MoveAny.UpdateCurrentWindow, "UpdateCurrentWindow")
end
end
end
function MoveAny:FrameDragInfo(frame, c)
if c > 0 then
if IsMouseButtonDown("RightButton") or IsMouseButtonDown("LeftButton") or IsMouseButtonDown("MiddleButton") then
MoveAny:After(
0.01,
function()
MoveAny:FrameDragInfo(frame, c - 1)
end, "FrameDragInfo"
)
end
else
local text = nil
if IsMouseButtonDown("RightButton") then
if MoveAny:IsEnabled("SCALEFRAMES", true) then
if MoveAny:IsEnabled("FRAMESKEYSCALE", false) then
text = format(MoveAny:Trans("LID_FRAMESKEYSCALE"), MoveAny:MAGV("KEYBINDWINDOWKEY", "SHIFT")) .. "."
end
else
text = MoveAny:Trans("LID_FRAMESCALEDISABLED")
end
elseif IsMouseButtonDown("LeftButton") then
if MoveAny:IsEnabled("FRAMESKEYDRAG", false) then
text = format(MoveAny:Trans("LID_FRAMESKEYDRAG"), MoveAny:MAGV("KEYBINDWINDOWKEY", "SHIFT")) .. "."
end
elseif IsMouseButtonDown("MiddleButton") then
if MoveAny:IsEnabled("FRAMESKEYRESET", false) then
text = format(MoveAny:Trans("LID_FRAMESKEYRESET"), MoveAny:MAGV("KEYBINDWINDOWKEY", "SHIFT")) .. "."
end
end
if text then
GameTooltip:SetOwner(frame, "ANCHOR_TOPRIGHT")
GameTooltip:SetText(text)
end
end
end
local EnableMouseFrames = {"RemixArtifactFrame", "RemixArtifactFrame.BorderContainer", "PlayerChoiceFrame", "GenericPlayerChoiseTobbleButton", "ReadyCheckFrame", "RolePollPopup"}
local HookedEnableMouseFrames = {}
local run = false
local id = 0
local waitingFrames = {}
local waitingFramesDone = {}
local maframesetpoint = {}
local masetscale_frame = {}
local ma_ismoving = {}
local once = true
function MoveAny:MAFrameStopMoving(frameObj, name)
local name2 = MoveAny:GetName(frameObj)
if name2 then
local fM = _G[name2 .. "Move"]
if not fM then
MoveAny:INFO("FAILED TO STOP MOVING", name)
return
end
if fM and ma_ismoving[fM] then
ma_ismoving[fM] = false
fM:StopMovingOrSizing()
fM:SetUserPlaced(false)
end
end
currentWindowName = nil
end
function MoveAny:CheckSave(frameObj, name)
if not MoveAny:IsEnabled("SAVEFRAMEPOSITION", true) then
MoveAny:SaveFramePointToDB(name, nil, nil, nil, nil, nil)
frameObj:SetMovable(true)
if frameObj.SetUserPlaced then
frameObj:SetUserPlaced(false)
end
end
if not InCombatLockdown() and not MoveAny:IsEnabled("SAVEFRAMESCALE", true) then
MoveAny:SetFrameScale(name, nil)
local scale = frameObj:GetScale()
if scale and scale > 0 then
frameObj:SetScale(scale)
end
end
end
function MoveAny:UpdateMoveFrames(from, force, ts)
id = id + 1
if run then return end
run = true
local runId = id
if MoveAny:Loaded("UpdateMoveFrames") and MoveAny:IsEnabled("MOVEFRAMES", true) then
if once then
once = false
if WorldMapFrame and not MoveAny:IsAddOnLoaded("Leatrix_Maps") then
MoveAny:SetClampedToScreen(WorldMapFrame, true, "UpdateMoveFrames 3")
local hookedWorldMap = false
local hookedWorldMapTitle = false
local hookedWorldMapMiniBorder = false
local enableMouseWorldMap = false
local enableMouseWorldMapTitle = false
local enableMouseWorldMapMiniBorder = false
WorldMapFrame:HookScript(
"OnShow",
function()
if not hookedWorldMap then
hookedWorldMap = true
hooksecurefunc(
WorldMapFrame,
"EnableMouse",
function(sel)
if enableMouseWorldMap then return end
enableMouseWorldMap = true
sel:EnableMouse(true)
enableMouseWorldMap = false
end
)
WorldMapFrame:EnableMouse(true)
end
if WorldMapTitleButton and not hookedWorldMapTitle then
hookedWorldMapTitle = true
hooksecurefunc(
WorldMapTitleButton,
"EnableMouse",
function(sel)
if enableMouseWorldMapTitle then return end
enableMouseWorldMapTitle = true
sel:EnableMouse(false)
enableMouseWorldMapTitle = false
end
)
WorldMapTitleButton:EnableMouse(false)
end
if WorldMapFrame.MiniBorderFrame and not hookedWorldMapMiniBorder then
hookedWorldMapMiniBorder = true
hooksecurefunc(
WorldMapFrame.MiniBorderFrame,
"EnableMouse",
function(sel)
if enableMouseWorldMapMiniBorder then return end
enableMouseWorldMapMiniBorder = true
sel:EnableMouse(false)
enableMouseWorldMapMiniBorder = false
end
)
WorldMapFrame.MiniBorderFrame:EnableMouse(false)
end
end
)
end
if GameMenuFrame then
MoveAny:SetClampedToScreen(GameMenuFrame, true, "UpdateMoveFrames 4")
end
if PVPReadyDialog then
MoveAny:SetClampedToScreen(PVPReadyDialog, true, "UpdateMoveFrames 5")
end
if ReadyCheckFrame then
MoveAny:SetClampedToScreen(ReadyCheckFrame, true, "UpdateMoveFrames 6")
end
if RolePollPopup then
MoveAny:SetClampedToScreen(RolePollPopup, true, "UpdateMoveFrames 7")
end
if StaticPopup1 then
MoveAny:SetClampedToScreen(StaticPopup1, true, "UpdateMoveFrames 8")
end
if StaticPopup2 then
MoveAny:SetClampedToScreen(StaticPopup2, true, "UpdateMoveFrames 9")
end
end
for i, name in pairs(EnableMouseFrames) do
local frame = MoveAny:GetFrameByName(name)
if C_Widget.IsWidget(frame) and HookedEnableMouseFrames[name] == nil then
EnableMouseFrames[name] = nil
HookedEnableMouseFrames[name] = true
if name == "RemixArtifactFrame" then
for x, raf in pairs({"RemixArtifactFrame.BorderContainer", "RemixArtifactFrame.FxModelScene", "RemixArtifactFrame.ButtonsParent"}) do
local borderFrame = MoveAny:GetFrameByName(raf)
local enableMouse = false
hooksecurefunc(
borderFrame,
"EnableMouse",
function(sel)
if enableMouse then return end
enableMouse = true
sel:EnableMouse(false)
enableMouse = false
end
)
borderFrame:EnableMouse(false)
frame:SetClampRectInsets(0, 0, 0, 0)
end
end
hooksecurefunc(
frame,
"Show",
function(sel)
sel:EnableMouse(true)
end
)
hooksecurefunc(
frame,
"Hide",
function(sel)
sel:EnableMouse(false)
end
)
frame:EnableMouse(true)
end
end
local count = 0
for i, nam in pairs(MAFS) do
local ret = MoveAny:TryRun(
function(name)
local frame = MoveAny:GetFrameByName(name)
if frame ~= nil and frame:IsVisible() and (not InCombatLockdown() or not frame:IsProtected()) then
MAFS[name] = nil
if (name == "TradeSkillFrame" and MoveAny:IsAddOnLoaded("DragonflightUI", "TradeSkillFrame") and DragonflightUIProfessionFrame) or (name == "BankFrame" and MoveAny:IsAddOnLoaded("Sorted", "BankFrame")) then
frame:SetAlpha(0)
local enableMouse = false
hooksecurefunc(
frame,
"EnableMouse",
function(sel, enable)
if enableMouse then return end
enableMouse = true
sel:EnableMouse(false)
enableMouse = false
end
)
frame:EnableMouse(false)
return
end
local fm = _G[name .. "Move"]
if fm == nil then
fm = CreateFrame("FRAME", name .. "Move", MoveAny:GetMainPanel())
fm:SetMovable(true)
fm:SetUserPlaced(false)
if MAFRAMESIGNORECLAMP[name] == nil and MoveAny:IsEnabled("CLAMPWINDOWTOSCREEN", true) then
MoveAny:SetClampedToScreen(fm, true, "UpdateMoveFrames 1")
end
if (MoveAny:GetWoWBuild() ~= "RETAIL" and MoveAny:GetWoWBuild() ~= "TBC") and WorldMapFrame and WorldMapFrameMove then
local offsetl = 15
local offsetr = 7
local offsett = 18
local offsetb = 23
if MoveAny:IsAddOnLoaded("ElvUI") then
offsetl = 8
offsetr = 66
offsett = 20
offsetb = 23
end
WorldMapFrame:SetClampRectInsets(offsetl, -offsetr, -offsett, offsetb)
WorldMapFrameMove:SetClampRectInsets(offsetl, -offsetr, -offsett, offsetb)
end
fm:RegisterForDrag("LeftButton")
if HookedEnableMouseFrames[name] == nil then
fm:EnableMouse(false)
end
hooksecurefunc(
frame,
"SetScale",
function(sel, scale)
if MoveAny:IsEnabled("SCALEFRAMES", true) == false then return false end
MoveAny:SafeExec(
fm,
function()
if scale and type(scale) == "number" and scale > 0 and (currentWindowName == nil) then
fm:SetScale(scale)
end
end, "frame SetScale MoveFrames"
)
end
)
function fm:UpdatePreview()
local fM = _G[name .. "Move"]
if fM and ma_ismoving[fM] then
if fM:GetLeft() then
fM.ma_x = fM:GetLeft()
fM.ma_y = fM:GetTop() - fM:GetHeight()
fM.ma_x = MoveAny:Snap(fM.ma_x, MoveAny:GetSnapWindowSize())
fM.ma_y = MoveAny:Snap(fM.ma_y, MoveAny:GetSnapWindowSize())
MoveAny:SaveFramePointToDB(name, "BOTTOMLEFT", "UIParent", "BOTTOMLEFT", fM.ma_x, fM.ma_y)
local dbp1, _, dbp3, dbp4, dbp5 = MoveAny:GetFramePoint(name)
if name == "LootFrame" and MoveAny:IsEnabled("MOVELOOTFRAME", false) == false then return end
if dbp1 and dbp3 then
MoveAny:SetPoint(frame, dbp1, nil, dbp3, dbp4, dbp5)
else
frame:ClearAllPoints()
frame:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", fM.ma_x, fM.ma_y)
end
end
MoveAny:After(0.01, fm.UpdatePreview, "UpdatePreview")
end
end
end
if MAFRAMESIGNORECLAMP[name] == nil and MoveAny:IsEnabled("CLAMPWINDOWTOSCREEN", true) then
MoveAny:SetClampedToScreen(frame, true, "UpdateMoveFrames 2")
end
MoveAny:CheckSave(frame, name)
frame:HookScript(
"OnHide",
function()
MoveAny:MAFrameStopMoving(frame, name)
if MoveAny.CheckSave then
MoveAny:CheckSave(frame, name)
end
end
)
function MoveAny:IsResetButtonDown(btn)
return btn == "MiddleButton"
end
frame:RegisterForDrag("LeftClick")
if frame:IsMovable() then
if frame:HasScript("OnMouseDown") then
frame:SetScript("OnMouseDown", function() end)
end
if frame:HasScript("OnMouseUp") then
frame:SetScript("OnMouseUp", function() end)
end
else
frame:SetMovable(true)
end
function frame:MA_OnMouseDown(sel, btn)
if frame:GetPoint() then
fm:SetSize(frame:GetSize())
fm:ClearAllPoints()
if frame:GetLeft() then
local x = frame:GetLeft()
local y = frame:GetTop() - frame:GetHeight()
x = MoveAny:Snap(x, MoveAny:GetSnapWindowSize())
y = MoveAny:Snap(y, MoveAny:GetSnapWindowSize())
fm:SetPoint("BOTTOMLEFT", MoveAny:GetMainPanel(), "BOTTOMLEFT", x, y)
else
fm:SetAllPoints(frame)
end
end
if (MoveAny:IsEnabled("FRAMESKEYSCALE", false) and MoveAny:IsFrameKeyDown() and btn == "RightButton") or (not MoveAny:IsEnabled("FRAMESKEYSCALE", false) and btn == "RightButton") then
currentWindowName = name
MoveAny:UpdateCurrentWindow()
GameTooltip:Hide()
elseif (MoveAny:IsEnabled("FRAMESKEYDRAG", false) and MoveAny:IsFrameKeyDown() and btn == "LeftButton") or (not MoveAny:IsEnabled("FRAMESKEYDRAG", false) and btn == "LeftButton") then
fm:StartMoving()
fm:SetUserPlaced(false)
ma_ismoving[fm] = true
fm:UpdatePreview()
elseif (MoveAny:IsEnabled("FRAMESKEYRESET", false) and MoveAny:IsFrameKeyDown() and MoveAny:IsResetButtonDown(btn)) or (not MoveAny:IsEnabled("FRAMESKEYRESET", false) and MoveAny:IsResetButtonDown(btn)) then
MoveAny:SaveFramePointToDB(name, nil, nil, nil, nil, nil)
MoveAny:SetFrameScale(name, nil)
frame:SetScale(1)
MoveAny:MSG("[" .. name .. "] is reset, reopen the frame.")
else
if MoveAny:IsResetButtonDown(btn) then
MoveAny:FrameDragInfo(frame, 0)
else
MoveAny:FrameDragInfo(frame, 20)
end
end
end
function frame:MA_OnMouseUp(sel, btn)
MoveAny:MAFrameStopMoving(sel, name)
end
if frame.Header then
if frame.Header:HasScript("OnMouseDown") then
frame.Header:SetScript(
"OnMouseDown",
function(sel, btn)
frame:MA_OnMouseDown(frame, btn)
end
)
end
if frame.Header:HasScript("OnMouseUp") then
frame.Header:SetScript(
"OnMouseUp",
function(sel, btn)
frame:MA_OnMouseUp(frame, btn)
end
)
end
end
if frame == CharacterFrame and frame.TitleContainer then
if frame.TitleContainer:HasScript("OnMouseDown") then
frame.TitleContainer:SetScript(
"OnMouseDown",
function(sel, btn)
frame:MA_OnMouseDown(frame, btn)
end
)
end
if frame.TitleContainer:HasScript("OnMouseUp") then
frame.TitleContainer:SetScript(
"OnMouseUp",
function(sel, btn)
frame:MA_OnMouseUp(frame, btn)
end
)
end
end
if CharacterNameText and frame == CharacterFrame and PaperDollItemsFrame then
CharacterNameText:HookScript(
"OnMouseDown",
function(sel, btn)
frame:MA_OnMouseDown(frame, btn)
end
)
CharacterNameText:HookScript(
"OnMouseUp",
function(sel, btn)
frame:MA_OnMouseUp(frame, btn)
end
)
end
frame:HookScript(
"OnMouseDown",
function(sel, btn)
frame:MA_OnMouseDown(sel, btn)
end
)
frame:HookScript(
"OnMouseUp",
function(sel, btn)
frame:MA_OnMouseUp(sel, btn)
end
)
hooksecurefunc(
frame,
"SetPoint",
function(sel, p1, p2, p3, p4, p5)
if maframesetpoint[sel] then return end
maframesetpoint[sel] = true
sel:SetMovable(true)
if sel.SetUserPlaced and sel:IsMovable() then
sel:SetUserPlaced(false)
end
if name == "LootFrame" and MoveAny:IsEnabled("MOVELOOTFRAME", false) == false then return end
local dbp1, _, dbp3, dbp4, dbp5 = MoveAny:GetFramePoint(name)
if dbp1 and dbp3 then
sel.maretrysetpoint = nil
local w, h = sel:GetSize()
MoveAny:SetPoint(sel, dbp1, nil, dbp3, dbp4, dbp5)
if sel:GetNumPoints() > 1 then
sel:SetSize(w, h)
end
end
maframesetpoint[sel] = false
end
)
hooksecurefunc(
frame,
"SetScale",
function(sel, scale)
if masetscale_frame[sel] then return end
masetscale_frame[sel] = true
MoveAny:SafeExec(
sel,
function()
if name == "LootFrame" and MoveAny:IsEnabled("SCALELOOTFRAME", false) == false then return end
if MoveAny:GetFrameScale(name) or (scale and type(scale) == "number") then
local sca = MoveAny:GetFrameScale(name) or scale
if sel.isMaximized and sca and sca > 1 then
sca = 1
end
--scale > 0.001 fix for TSM - TradeSkillMaster, they "hide" it with low scale
if MoveAny:IsEnabled("SCALEFRAMES", true) and sca and type(sca) == "number" and sca > 0 and (currentWindowName == nil) and scale > 0.001 then
sel:SetScale(sca)
end
end
masetscale_frame[sel] = false
end, "UpdateMoveFrames SetScale"
)
end
)
if MoveAny:IsEnabled("SCALEFRAMES", true) then
if MoveAny:GetFrameScale(name) and MoveAny:GetFrameScale(name) > 0 then
if frame:GetHeight() * MoveAny:GetFrameScale(name) > GetScreenHeight() then
frame:SetScale(MoveAny:GetFrameScale(name))
MoveAny:After(
4,
function()
if frame:GetHeight() * MoveAny:GetFrameScale(name) > GetScreenHeight() then
if GetScreenHeight() / frame:GetHeight() > 0 then
MoveAny:SetFrameScale(name, GetScreenHeight() / frame:GetHeight())
end
frame:SetScale(MoveAny:GetFrameScale(name))
end
end, "SCALEFRAMES"
)
elseif MoveAny:GetFrameScale(name) and MoveAny:GetFrameScale(name) > 0 then
frame:SetScale(MoveAny:GetFrameScale(name))
end
else
local scale = frame:GetScale()
if scale and scale > 0 then
frame:SetScale(scale)
end
end
end
if C_Widget.IsWidget(frame) and frame.GetPoint and frame:GetPoint() then
local p1, p2, p3, p4, p5 = frame:GetPoint()
if name ~= "LootFrame" or MoveAny:IsEnabled("MOVELOOTFRAME", false) then
MoveAny:SetPoint(frame, p1, p2, p3, p4, p5)
end
end
elseif C_Widget.IsWidget(frame) and waitingFrames[name] == nil and frame.Show then
waitingFrames[name] = true
hooksecurefunc(
frame,
"Show",
function()
if waitingFramesDone[name] == nil then
waitingFramesDone[name] = true
MoveAny:UpdateMoveFrames("WAITING: " .. name .. " From: " .. from, true, ts)
end
end
)
end
return 1
end, nam
)
if ret ~= nil then
count = count + ret
end
end
else
for i, name in pairs(MAFS) do
local frame = MoveAny:GetFrameByName(name)
if frame ~= nil and waitingFrames[name] == nil and frame.Show then
waitingFrames[name] = true
hooksecurefunc(
frame,
"Show",
function()
if waitingFramesDone[name] == nil then
waitingFramesDone[name] = true
MoveAny:UpdateMoveFrames("WAITING: " .. name .. " From: " .. from, true, ts)
end
end
)
end
end
end
if ts ~= nil then
MoveAny:After(
ts,
function()
run = false
if runId ~= id then
MoveAny:UpdateMoveFrames("RETRY: " .. from, force, ts)
end
end, "UpdateMoveFrames"
)
else
run = false
end
end
function MoveAny:MoveParent(receive, from)
receive:SetMovable(true)
receive:EnableMouse(true)
from:HookScript(
"OnMouseDown",
function(sel, button)
if button == "LeftButton" then
pcall(
function()
receive:StartMoving()
end
)
end
end
)
from:HookScript(
"OnMouseUp",
function(sel, button)
if button == "LeftButton" then
pcall(
function()
receive:StopMovingOrSizing()
end
)
end
end
)
end
local allowedFrameTypes = {}
allowedFrameTypes["frame"] = true
allowedFrameTypes["Frame"] = true
allowedFrameTypes["FRAME"] = true
function MoveAny:MoveFrames()
hooksecurefunc(
"CreateFrame",
function(frameType, frameName, parent, template)
if allowedFrameTypes[frameType] then
MoveAny:UpdateMoveFrames("CreateFrame", 0.1)
end
end
)
if MoveAny:IsEnabled("MOVESMALLBAGS", false) then
for i = 1, 20 do
if _G["ContainerFrame" .. i] and not MAFS["ContainerFrame" .. i] then
MAFS["ContainerFrame" .. i] = "ContainerFrame" .. i
end
end
end
if MoveAny:IsEnabled("MOVELOOTFRAME", false) or MoveAny:IsEnabled("SCALELOOTFRAME", false) then
MAFS["LootFrame"] = "LootFrame"
end
if MoveAny:IsAddOnLoaded("GW2_UI") == false then
MAFS["MailFrame"] = "MailFrame"
MoveAny:MoveParent(MailFrame, SendMailFrame)
end
MoveAny:UpdateMoveFrames("Start", true)
local f = CreateFrame("Frame")
MoveAny:RegisterEvent(f, "ADDON_LOADED")
MoveAny:OnEvent(
f,
function(sel, event, ...)
MoveAny:UpdateMoveFrames("ADDON_LOADED", true)
end, "ADDON_LOADED 123"
)
if BattlefieldFrame then
BattlefieldFrame:EnableMouse(false)
end
end