-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathPlater_DebugFrames.lua
239 lines (198 loc) · 10.7 KB
/
Plater_DebugFrames.lua
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
local Plater = _G.Plater
local C_Timer = _G.C_Timer
local addonName, platerInternal = ...
---@type detailsframework
local DF = DetailsFramework
local MEMBER_UNITID = "namePlateUnitToken"
local GetSpellInfo = GetSpellInfo or function(spellID) if not spellID then return nil end local si = C_Spell.GetSpellInfo(spellID) if si then return si.name, nil, si.iconID, si.castTime, si.minRange, si.maxRange, si.spellID, si.originalIconID end end
function Plater.DebugNameplate()
return Plater.DebugTargetNameplate()
end
function Plater.DebugTargetNameplate()
local plateFrame = C_NamePlate.GetNamePlateForUnit("target", issecure())
if (plateFrame) then
if (not _G.FrameInspect) then
Plater:Msg("Please install FrameInspect addon to use this function.")
return
end
_G.FrameInspect.Inspect(plateFrame)
else
Plater:Msg("You don't have a target or the nameplate is protected.")
return
end
end
---open the options panel and select the cast colors tab
---searchString is optional, if provided, it will be used to search for a spellId, npcId, spellName, npcName, zoneName, sound name, and encounterName.
---@param searchString string
---@return nil
function Plater.OpenCastColorsPanel(searchString)
--ColorFrame
Plater.OpenOptionsPanel(platerInternal.CastColorsFrameIndex)
--due to lazy loading, the panel might not be loaded yet
local castColorFrame = PlaterOptionsPanelContainerCastColorManagementColorFrame
if (not castColorFrame) then
C_Timer.After(platerInternal.CastColorsCreationDelay + 0.1, function()
Plater.OpenOptionsPanel(platerInternal.CastColorsFrameIndex)
castColorFrame = PlaterOptionsPanelContainerCastColorManagementColorFrame
castColorFrame.AuraSearchTextEntry:SetText(searchString)
castColorFrame.OnSearchBoxTextChanged()
end)
else
castColorFrame.AuraSearchTextEntry:SetText(searchString)
castColorFrame.OnSearchBoxTextChanged()
end
end
function Plater.OpenNpcColorsPanel(searchString) --/run Plater.OpenNpcColorsPanel("")
Plater.OpenOptionsPanel(platerInternal.NpcColorsFrameIndex)
--due to lazy loading, the panel might not be loaded yet
local npcColorFrame = PlaterOptionsPanelContainerColorManagement
Plater.OpenOptionsPanel(platerInternal.NpcColorsFrameIndex, true)
--first time loading the options panel
if (not npcColorFrame.AuraSearchTextEntry) then
C_Timer.After(0.25, function()
npcColorFrame.AuraSearchTextEntry:SetText(searchString)
npcColorFrame.OnSearchBoxTextChanged()
end)
else
npcColorFrame.AuraSearchTextEntry:SetText(searchString)
npcColorFrame.OnSearchBoxTextChanged()
end
--C_Timer.After(0, function() Plater.OpenOptionsPanel(platerInternal.NpcColorsFrameIndex) print("selected tab") end)
end
function platerInternal.InstallMDTHooks()
--first check if Mythic Dungeon Tools is installed
if (not MDT) then
return
end
--this function open the plater options panel and search for the npcId under the tab 'Npc Color and Names'
local fSeeNpcOnPlater = function(self, fixedParameter, npcId)
Plater.OpenNpcColorsPanel(npcId)
end
--this function open the plater options panel and search for the spellId under the tab 'Cast Color and Names'
local fSeeSpellOnPlater = function(self, fixedParameter, spellId)
Plater.OpenCastColorsPanel(spellId)
end
if (not MDT.UpdateEnemyInfoFrame) then
return
end
hooksecurefunc(MDT, "UpdateEnemyInfoFrame", function()
local midContainerChildren = MDT.EnemyInfoFrame and MDT.EnemyInfoFrame.midContainer and MDT.EnemyInfoFrame.midContainer.children
if (midContainerChildren) then
for i = 1, #midContainerChildren do
local containerFrame = midContainerChildren[i]
if (containerFrame.idEditBox) then
if (not containerFrame.GoToPlaterButton) then
containerFrame.GoToPlaterButton = DF:CreateButton(containerFrame.frame, fSeeNpcOnPlater, 1, 1, "")
containerFrame.GoToPlaterButton.tooltip = "Setup this npc on Plater"
--DF:ApplyStandardBackdrop(containerFrame.GoToPlaterButton) --debug button size
--DF:ApplyStandardBackdrop(containerFrame.frame) --debug container size
--DF:DebugVisibility(containerFrame.frame)
end
local npcId = containerFrame.idEditBox:GetText()
npcId = tonumber(npcId)
if (npcId and npcId > 1) then
containerFrame.GoToPlaterButton.param1 = npcId
--/dump MDT.EnemyInfoFrame.midContainer.children[2].healthEditBox
local point1 = Plater.MDTSettings.enemyinfo_button_point
containerFrame.GoToPlaterButton:ClearAllPoints()
containerFrame.GoToPlaterButton:SetPoint(point1[1], containerFrame.frame, point1[2], point1[3], point1[4])
containerFrame.GoToPlaterButton:SetSize(Plater.MDTSettings.button_width, Plater.MDTSettings.button_height)
containerFrame.GoToPlaterButton:SetIcon(Plater.MDTSettings.icon_texture, Plater.MDTSettings.button_width, Plater.MDTSettings.button_height, "overlay", Plater.MDTSettings.icon_coords)
containerFrame.GoToPlaterButton:SetAlpha(Plater.MDTSettings.alpha)
else
containerFrame.GoToPlaterButton:Hide()
end
end
end
end
--MDT spells info section
local spellScrollChildren = MDT.EnemyInfoFrame and MDT.EnemyInfoFrame.spellScroll and MDT.EnemyInfoFrame.spellScroll.children --.children is an array of tables, each table has a frame and a spellId
if (spellScrollChildren) then
for i = 1, #spellScrollChildren do
---@type table
local spellFrameTable = spellScrollChildren[i]
if (spellFrameTable) then
local spellButton = spellFrameTable.frame
local spellId = spellFrameTable.spellId
local _, _, _, castTime = GetSpellInfo(spellId or 1)
if (castTime and castTime > 0) then
if (not spellButton.GoToPlaterButton) then
spellButton.GoToPlaterButton = DF:CreateButton(spellButton, fSeeSpellOnPlater, 1, 1, "", spellId)
spellButton.GoToPlaterButton.tooltip = "Setup this spell on Plater"
--DF:ApplyStandardBackdrop(spellButton.GoToPlaterButton) --debug button size
end
spellButton.GoToPlaterButton.param1 = spellId
local point1 = Plater.MDTSettings.spellinfo_button_point
spellButton.GoToPlaterButton:ClearAllPoints()
spellButton.GoToPlaterButton:SetPoint(point1[1], spellButton, point1[2], point1[3], point1[4])
spellButton.GoToPlaterButton:SetSize(Plater.MDTSettings.button_width, Plater.MDTSettings.button_height)
spellButton.GoToPlaterButton:SetIcon(Plater.MDTSettings.icon_texture, Plater.MDTSettings.button_width, Plater.MDTSettings.button_height, "overlay", Plater.MDTSettings.icon_coords)
spellButton.GoToPlaterButton:SetAlpha(Plater.MDTSettings.alpha)
else
if (spellButton.GoToPlaterButton) then
spellButton.GoToPlaterButton:Hide()
end
end
end
end
end
end)
end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> debuggers ~debug
function Plater.DebugColorAnimation()
if (Plater.DebugColorAnimation_Timer) then
return
end
Plater.DebugColorAnimation_Timer = C_Timer.NewTicker (0.5, function() --~animationtest
for _, plateFrame in ipairs (Plater.GetAllShownPlates()) do
--make the bar jump from green to pink - pink to green
Plater.ChangeHealthBarColor_Internal (plateFrame.unitFrame.healthBar, abs (math.sin (GetTime())), abs (math.cos (GetTime())), abs (math.sin (GetTime())), 1)
end
end)
C_Timer.After (10, function()
if (Plater.DebugColorAnimation_Timer) then
Plater.DebugColorAnimation_Timer:Cancel()
Plater.DebugColorAnimation_Timer = nil
Plater:Msg ("stopped the animation test.")
Plater.UpdateAllPlates()
end
end)
Plater:Msg ("is now animating color nameplates in your screen for test purposes.")
end
function Plater.DebugHealthAnimation()
if (Plater.DebugHealthAnimation_Timer) then
return
end
Plater.DebugHealthAnimation_Timer = C_Timer.NewTicker (1.5, function() --~animationtest
for _, plateFrame in ipairs (Plater.GetAllShownPlates()) do
local self = plateFrame.unitFrame
if self and self.PlaterOnScreen then
if (self.healthBar.CurrentHealth == 0) then
self.healthBar.AnimationStart = 0
self.healthBar.AnimationEnd = UnitHealthMax(self [MEMBER_UNITID])
else
self.healthBar.AnimationStart = UnitHealthMax(self [MEMBER_UNITID])
self.healthBar.AnimationEnd = 0
end
self.healthBar:SetValue (self.healthBar.CurrentHealth)
self.healthBar.CurrentHealthMax = UnitHealthMax(self [MEMBER_UNITID])
self.healthBar.IsAnimating = true
if (self.healthBar.AnimationEnd > self.healthBar.AnimationStart) then
self.healthBar.AnimateFunc = Plater.AnimateRightWithAccel
else
self.healthBar.AnimateFunc = Plater.AnimateLeftWithAccel
end
end
end
end)
C_Timer.After (10, function()
if (Plater.DebugHealthAnimation_Timer) then
Plater.DebugHealthAnimation_Timer:Cancel()
Plater.DebugHealthAnimation_Timer = nil
Plater:Msg ("stopped the animation test.")
Plater.UpdateAllPlates()
end
end)
Plater:Msg ("is now animating nameplates in your screen for test purposes.")
end