-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcore.lua
More file actions
394 lines (352 loc) · 7.93 KB
/
core.lua
File metadata and controls
394 lines (352 loc) · 7.93 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
local _, MoveAny = ...
local hooksecurefunc = _G["hooksecurefunc"]
local CreateFrame = _G["CreateFrame"]
local InCombatLockdown = _G["InCombatLockdown"]
local colors = {}
colors["bg"] = {0.03, 0.03, 0.03}
colors["se"] = {1.0, 1.0, 0.0}
colors["el"] = {0.6, 0.84, 1.0}
colors["hidden"] = {1.0, 0.0, 0.0}
colors["clickthrough"] = {0.2, 0.2, 1.0}
function MoveAny:GetColor(key)
return colors[key][1], colors[key][2], colors[key][3]
end
local MADF = {}
function MoveAny:GetDragFrames()
return MADF
end
--[[ HIDEPANEL ]]
local MAHIDDEN = CreateFrame("Frame", "MAHIDDEN")
function MoveAny:GetHidden()
return MAHIDDEN
end
MoveAny:GetHidden():Hide()
MoveAny:GetHidden().unit = "player"
MoveAny:GetHidden().auraRows = 0
local sethidden = {}
local sethiddenSetup = {}
function MoveAny:HideFrame(frame, soft)
if not soft then
if InCombatLockdown() then
MoveAny:After(
0.1,
function()
MoveAny:HideFrame(frame, soft)
end, "HideFrame"
)
return
end
sethidden[frame] = true
if sethiddenSetup[frame] == nil then
sethiddenSetup[frame] = true
local setparent = false
hooksecurefunc(
frame,
"SetParent",
function(sel, parent)
if sethidden[sel] == nil then return end
if setparent then return end
setparent = true
MoveAny:TrySetParent(sel, MoveAny:GetHidden())
setparent = false
end
)
end
MoveAny:TrySetParent(frame, MoveAny:GetHidden())
return
end
sethidden[frame] = true
if sethiddenSetup[frame] == nil then
sethiddenSetup[frame] = true
local setalpha = false
hooksecurefunc(
frame,
"SetAlpha",
function(sel, alpha)
if sethidden[sel] == nil then return end
if setalpha then return end
setalpha = true
sel:SetAlpha(0)
if not InCombatLockdown() then
sel:EnableMouse(false)
end
if sel.GetChildren then
MoveAny:ForeachChildren(
sel,
function(child)
child:SetAlpha(0)
if not InCombatLockdown() then
child:EnableMouse(false)
end
end, "HideFrame"
)
end
setalpha = false
end
)
end
frame:SetAlpha(0)
frame:EnableMouse(false)
if InCombatLockdown() then
MoveAny:After(
0.1,
function()
MoveAny:HideFrame(frame, soft)
end, "HideFrame 2"
)
end
end
function MoveAny:ShowFrame(frame)
sethidden[frame] = nil
frame:SetAlpha(1)
if not InCombatLockdown() then
frame:EnableMouse(true)
else
MoveAny:After(
0.1,
function()
MoveAny:ShowFrame(frame)
end, "ShowFrame"
)
end
end
--[[ HIDEPANEL ]]
--[[ NEW ]]
local MAUIP = CreateFrame("Frame", "UIParent")
MAUIP:SetAllPoints(UIParent)
MAUIP.unit = "player"
MAUIP.auraRows = 0
function MoveAny:SetMAUIPAlpha(alpha)
if UIParent:IsShown() then
MAUIP:SetAlpha(alpha)
else
MAUIP:SetAlpha(0)
end
end
local uiscalecvar = CreateFrame("Frame")
--MoveAny:RegisterEvent(uiscalecvar, "CVAR_UPDATE")
MoveAny:OnEvent(
uiscalecvar,
function(self, event, target, value)
if event == "CVAR_UPDATE" and (target == "uiScale" or target == "useUiScale") then
if MoveAny:GetCVar("useUiScale") == "1" then
MAUIP:SetScale(MoveAny:GetCVar("uiScale"))
else
MAUIP:SetScale(UIParent:GetScale())
end
MoveAny:UpdateGrid()
end
end, "uiscalecvar"
)
local setScale = false
local scaleVale = 1
function MoveAny:MAUI_SetScale(scale)
scaleVale = scale
if setScale then return end
setScale = true
local worked = MoveAny:TrySetScale(MAUIP, scaleVale)
if not worked then
MoveAny:After(
0.1,
function()
setScale = false
MoveAny:MAUI_SetScale(scaleVale)
end, "MAUI_SetScale"
)
end
end
hooksecurefunc(
UIParent,
"SetScale",
function(sel, scale)
if MoveAny:GetCVar("useUiScale") == "0" and type(scale) == "number" then
MoveAny:MAUI_SetScale(scale)
end
end
)
if MoveAny:GetCVar("useUiScale") == "1" then
MoveAny:MAUI_SetScale(MoveAny:GetCVar("uiScale"))
else
MoveAny:After(
0,
function()
MoveAny:MAUI_SetScale(UIParent:GetScale())
end, "uiScale"
)
end
MoveAny:SetMAUIPAlpha(UIParent:GetAlpha())
hooksecurefunc(
UIParent,
"Show",
function(self)
MoveAny:SetMAUIPAlpha(1)
end
)
hooksecurefunc(
UIParent,
"Hide",
function(self)
MoveAny:SetMAUIPAlpha(0)
end
)
hooksecurefunc(
_G,
"SetUIVisibility",
function(show, ...)
if show then
MoveAny:SetMAUIPAlpha(1)
else
MoveAny:SetMAUIPAlpha(0)
end
end
)
function MoveAny:GetMainPanel()
return MAUIP
end
--[[ NEW ]]
local isToggling = false
function MoveAny:Unlock()
if not isToggling then
isToggling = true
MoveAny:SetEnabled("MALOCK", true)
isToggling = false
else
MoveAny:MSG("[Unlock] Settings Frame is toggling. ShowMenu: " .. tostring(MoveAny:IsEnabled("MALOCK", false)))
end
end
function MoveAny:Lock()
if not isToggling then
isToggling = true
MoveAny:SetEnabled("MALOCK", false)
isToggling = false
else
MoveAny:MSG("[Lock] Settings Frame is toggling. ShowMenu: " .. tostring(MoveAny:IsEnabled("MALOCK", false)))
end
end
function MoveAny:IsMALockNotReady()
if MALock == nil then
MoveAny:MSG("Settings Frame is not created yet, maybe you got an error? If not error, please install BugSack, Buggrabber to see the error.")
return true
end
return false
end
function MoveAny:ShowMALock()
if MoveAny:IsMALockNotReady() then return end
MoveAny:Unlock()
if MoveAny:IsEnabled("MALOCK", false) then
for i, df in pairs(MoveAny:GetDragFrames()) do
df:Show()
if df.opt then
df.opt:Show()
end
end
if MALock then
MALock:Show()
if MAGridFrame then
MAGridFrame:Show()
end
else
MoveAny:MSG("[ShowMALock] Settings Frame couldn't be created, please tell dev.")
end
end
end
function MoveAny:HideMALock(onlyHide)
if MoveAny:IsMALockNotReady() then return end
if not onlyHide then
MoveAny:Lock()
end
if not MoveAny:IsEnabled("MALOCK", false) then
for i, df in pairs(MoveAny:GetDragFrames()) do
df:Hide()
if df.opt then
df.opt:Hide()
end
end
if MALock then
MALock:Hide()
if MAGridFrame then
MAGridFrame:Hide()
end
else
MoveAny:MSG("[HideMALock] Settings Frame couldn't be created, please tell dev.")
end
end
end
function MoveAny:ToggleMALock()
if MoveAny:IsMALockNotReady() then return end
if MoveAny:IsEnabled("MALOCK", false) and MALock.save and MALock.save:IsEnabled() then
MoveAny:INFO("Can't Toggle Settings Frame when it is not saved.")
return
end
if not MoveAny:IsEnabled("MALOCK", false) then
MoveAny:ShowMALock()
else
MoveAny:HideMALock()
end
end
local inCombat = false
function MoveAny:UpdateMALock(event)
if MoveAny:IsEnabled("MALOCK", false) and InCombatLockdown() then
inCombat = true
MoveAny:HideMALock()
elseif inCombat and not InCombatLockdown() then
inCombat = false
MoveAny:ShowMALock()
end
end
local maLockCheck = CreateFrame("Frame")
MoveAny:RegisterEvent(maLockCheck, "PLAYER_REGEN_ENABLED")
MoveAny:RegisterEvent(maLockCheck, "PLAYER_REGEN_DISABLED")
MoveAny:OnEvent(
maLockCheck,
function(sel, event)
MoveAny:UpdateMALock(event)
end, "maLockCheck"
)
function MoveAny:InitSlash()
MoveAny:AddSlash("move", MoveAny.ToggleMALock)
MoveAny:AddSlash("moveany", MoveAny.ToggleMALock)
if C_UI then
MoveAny:AddSlash("rl", C_UI.Reload)
MoveAny:AddSlash("rel", C_UI.Reload)
else
MoveAny:AddSlash("rl", _G["ReloadUI"])
MoveAny:AddSlash("rel", _G["ReloadUI"])
end
end
if false then
C_Timer.After(
1,
function()
MoveAny:SetDebug(true)
if false then
MoveAny:DrawDebug(
"MoveAny Test DrawDebug 1",
function()
local text = ""
for i, v in pairs(MoveAny:GetCountAfter()) do
if v > 200 then
text = text .. v .. "x: " .. i .. "\n"
end
end
return text
end, 14, 1440, 1440, "CENTER", UIParent, "CENTER", 400, 0
)
end
if false then
MoveAny:DrawDebug(
"MoveAny Test DrawDebug 2",
function()
local text = ""
for i, v in pairs(MoveAny:GetCountAfterEvents()) do
if v > 1 then
text = text .. v .. "x: " .. i .. "\n"
end
end
return text
end, 14, 1440, 1440, "CENTER", UIParent, "CENTER", 900, 0
)
end
end
)
end