-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMover.lua
More file actions
130 lines (109 loc) · 4.42 KB
/
Copy pathMover.lua
File metadata and controls
130 lines (109 loc) · 4.42 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
local _, UI = ...
local GridFrame
local function ShowAlignmentGrid()
if not GridFrame then
GridFrame = CreateFrame("Frame", "CleanUIGrid", UIParent)
GridFrame:SetAllPoints(UIParent)
GridFrame:SetFrameStrata("BACKGROUND")
local size = 64
local width = GetScreenWidth()
local height = GetScreenHeight()
local centerX = width / 2
local centerY = height / 2
local vCenter = GridFrame:CreateTexture(nil, "ARTWORK")
vCenter:SetTexture(0, 1, 0, 0.8)
vCenter:SetWidth(1)
vCenter:SetPoint("TOP", GridFrame, "TOP", 0, 0)
vCenter:SetPoint("BOTTOM", GridFrame, "BOTTOM", 0, 0)
local hCenter = GridFrame:CreateTexture(nil, "ARTWORK")
hCenter:SetTexture(0, 1, 0, 0.8)
hCenter:SetHeight(1)
hCenter:SetPoint("LEFT", GridFrame, "LEFT", 0, 0)
hCenter:SetPoint("RIGHT", GridFrame, "RIGHT", 0, 0)
local numCols = math.ceil(centerX / size)
for i = -numCols, numCols do
if i ~= 0 then
local line = GridFrame:CreateTexture(nil, "BACKGROUND")
line:SetTexture(0, 0, 0, 0.6)
line:SetWidth(1)
line:SetPoint("TOPLEFT", GridFrame, "TOPLEFT", centerX + (i * size), 0)
line:SetPoint("BOTTOMLEFT", GridFrame, "BOTTOMLEFT", centerX + (i * size), 0)
end
end
local numRows = math.ceil(centerY / size)
for i = -numRows, numRows do
if i ~= 0 then
local line = GridFrame:CreateTexture(nil, "BACKGROUND")
line:SetTexture(0, 0, 0, 0.6)
line:SetHeight(1)
line:SetPoint("TOPLEFT", GridFrame, "TOPLEFT", 0, -(centerY + (i * size)))
line:SetPoint("TOPRIGHT", GridFrame, "TOPRIGHT", 0, -(centerY + (i * size)))
end
end
end
GridFrame:Show()
end
local function HideAlignmentGrid()
if GridFrame then GridFrame:Hide() end
end
local WelcomeMessageShown = false
function UI.MakeMovableAndSave(frame, name)
if not frame or frame.isMovableSet then return end
CleanUIPositions = CleanUIPositions or {}
if not WelcomeMessageShown then
print("|cff00ff00CleanUI:|r Hold Shift + Control + Left-Click to move frames.")
WelcomeMessageShown = true
end
frame:SetMovable(true)
frame:SetClampedToScreen(true)
if not InCombatLockdown() then frame:EnableMouse(true) end
frame:RegisterForDrag("LeftButton")
if CleanUIPositions[name] then
local p = CleanUIPositions[name]
frame:ClearAllPoints()
frame:SetPoint(p.pt, UIParent, p.rel, p.x, p.y)
frame:SetUserPlaced(true)
else
frame:SetUserPlaced(false)
end
local originalStrata = frame:GetFrameStrata()
frame:HookScript("OnUpdate", function(self)
if not InCombatLockdown() and ((IsShiftKeyDown() and IsControlKeyDown()) or self.isCleanUIMoving) then
self:SetFrameStrata("DIALOG")
else
if not self.isCleanUIMoving then
if self:GetFrameStrata() ~= originalStrata then
self:SetFrameStrata(originalStrata)
end
end
end
end)
frame:SetScript("OnMouseDown", function(self, btn)
if not InCombatLockdown() and IsShiftKeyDown() and IsControlKeyDown() and btn == "LeftButton" then
self:StartMoving()
self.isCleanUIMoving = true
ShowAlignmentGrid()
end
end)
frame:SetScript("OnMouseUp", function(self)
if self.isCleanUIMoving then
self:StopMovingOrSizing()
self.isCleanUIMoving = false
HideAlignmentGrid()
local pt, _, rel, x, y = self:GetPoint()
CleanUIPositions[name] = {pt = pt, rel = rel, x = x, y = y}
self:SetUserPlaced(true)
print("|cff00ff00CleanUI:|r " .. name .. " position saved.")
end
end)
frame.isMovableSet = true
end
local CoreMoverInit = CreateFrame("Frame")
CoreMoverInit:RegisterEvent("PLAYER_LOGIN")
CoreMoverInit:SetScript("OnEvent", function(self)
if PlayerFrame then UI.MakeMovableAndSave(PlayerFrame, "PlayerFrame") end
if TargetFrame then UI.MakeMovableAndSave(TargetFrame, "TargetFrame") end
if FocusFrame then UI.MakeMovableAndSave(FocusFrame, "FocusFrame") end
if CleanUIPartyAnchor then UI.MakeMovableAndSave(CleanUIPartyAnchor, "PartyAnchor") end
self:UnregisterAllEvents()
end)