yellowfive@57
|
1 local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot")
|
yellowfive@57
|
2 local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true)
|
yellowfive@57
|
3 local AceGUI = LibStub("AceGUI-3.0")
|
yellowfive@57
|
4
|
yellowfive@133
|
5 local _lblLogging = nil
|
yellowfive@57
|
6 local _btnToggle = nil
|
yellowfive@57
|
7 local _panelUndoWipe = nil
|
yellowfive@57
|
8 local _chkAutoAll = nil
|
yellowfive@57
|
9 local _autoChecks = nil
|
yellowfive@57
|
10
|
yellowfive@57
|
11 local function createDifficultyCheckBox(instanceId, difficultyId)
|
yellowfive@57
|
12 local chk = AceGUI:Create("AmrUiCheckBox")
|
yellowfive@57
|
13 chk:SetText(L.DifficultyNames[difficultyId])
|
yellowfive@57
|
14 chk:SetCallback("OnClick", function(widget)
|
yellowfive@57
|
15 Amr:ToggleAutoLog(instanceId, difficultyId)
|
yellowfive@57
|
16 end)
|
yellowfive@57
|
17
|
yellowfive@57
|
18 _autoChecks[instanceId][difficultyId] = chk
|
yellowfive@57
|
19 return chk
|
yellowfive@57
|
20 end
|
yellowfive@57
|
21
|
yellowfive@57
|
22 -- render a group of controls for auto-logging of a raid zone
|
yellowfive@137
|
23 local function renderAutoLogSection(instanceId, container, i, autoLbls, autoChks)
|
yellowfive@57
|
24 _autoChecks[instanceId] = {}
|
yellowfive@57
|
25
|
yellowfive@57
|
26 local lbl = AceGUI:Create("AmrUiLabel")
|
yellowfive@124
|
27 container:AddChild(lbl)
|
yellowfive@57
|
28 lbl:SetWidth(200)
|
yellowfive@57
|
29 lbl:SetText(L.InstanceNames[instanceId])
|
yellowfive@57
|
30 lbl:SetFont(Amr.CreateFont("Regular", 20, Amr.Colors.White))
|
yellowfive@57
|
31
|
yellowfive@137
|
32 if i == 1 then
|
yellowfive@137
|
33 lbl:SetPoint("TOPLEFT", _chkAutoAll.frame, "BOTTOMLEFT", -1, -15)
|
yellowfive@137
|
34 elseif i % 2 == 0 then
|
yellowfive@137
|
35 lbl:SetPoint("TOPLEFT", autoLbls[i - 1].frame, "TOPRIGHT", 40, 0)
|
yellowfive@137
|
36 else
|
yellowfive@137
|
37 lbl:SetPoint("TOPLEFT", autoChks[i - 2].frame, "BOTTOMLEFT", 0, -30)
|
yellowfive@137
|
38 end
|
yellowfive@137
|
39
|
yellowfive@57
|
40 local line = AceGUI:Create("AmrUiPanel")
|
yellowfive@137
|
41 container:AddChild(line)
|
yellowfive@57
|
42 line:SetHeight(1)
|
yellowfive@57
|
43 line:SetBackgroundColor(Amr.Colors.White)
|
yellowfive@57
|
44 line:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 1, -7)
|
yellowfive@57
|
45 line:SetPoint("TOPRIGHT", lbl.frame, "BOTTOMRIGHT", 0, -7)
|
yellowfive@57
|
46
|
yellowfive@57
|
47 local chkMythic = createDifficultyCheckBox(instanceId, Amr.Difficulties.Mythic)
|
yellowfive@124
|
48 container:AddChild(chkMythic)
|
yellowfive@57
|
49 chkMythic:SetPoint("TOPLEFT", line.frame, "BOTTOMLEFT", 0, -8)
|
yellowfive@57
|
50
|
yellowfive@57
|
51 local chkNormal = createDifficultyCheckBox(instanceId, Amr.Difficulties.Normal)
|
yellowfive@124
|
52 container:AddChild(chkNormal)
|
yellowfive@57
|
53 chkNormal:SetPoint("TOPLEFT", line.frame, "BOTTOMLEFT", 0, -30)
|
yellowfive@137
|
54
|
yellowfive@57
|
55 -- find the widest of mythic/normal
|
yellowfive@57
|
56 local w = math.max(chkMythic:GetWidth(), chkNormal:GetWidth())
|
yellowfive@57
|
57
|
yellowfive@57
|
58 local chkHeroic = createDifficultyCheckBox(instanceId, Amr.Difficulties.Heroic)
|
yellowfive@124
|
59 container:AddChild(chkHeroic)
|
yellowfive@57
|
60 chkHeroic:SetPoint("TOPLEFT", line.frame, "BOTTOMLEFT", w + 20, -8)
|
yellowfive@57
|
61
|
yellowfive@57
|
62 local chkLfr = createDifficultyCheckBox(instanceId, Amr.Difficulties.Lfr)
|
yellowfive@124
|
63 container:AddChild(chkLfr)
|
yellowfive@57
|
64 chkLfr:SetPoint("TOPLEFT", line.frame, "BOTTOMLEFT", w + 20, -30)
|
yellowfive@137
|
65
|
yellowfive@61
|
66 return lbl, chkNormal
|
yellowfive@57
|
67 end
|
yellowfive@57
|
68
|
yellowfive@57
|
69 -- renders the main UI for the Combat Log tab
|
yellowfive@57
|
70 function Amr:RenderTabLog(container)
|
yellowfive@57
|
71
|
yellowfive@57
|
72 -- main commands
|
yellowfive@57
|
73 _btnToggle = AceGUI:Create("AmrUiButton")
|
yellowfive@57
|
74 _btnToggle:SetText(L.LogButtonStartText)
|
yellowfive@57
|
75 _btnToggle:SetBackgroundColor(Amr.Colors.Green)
|
yellowfive@57
|
76 _btnToggle:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White))
|
yellowfive@57
|
77 _btnToggle:SetWidth(200)
|
yellowfive@57
|
78 _btnToggle:SetHeight(26)
|
yellowfive@57
|
79 _btnToggle:SetCallback("OnClick", function() Amr:ToggleLogging() end)
|
yellowfive@57
|
80 container:AddChild(_btnToggle)
|
yellowfive@124
|
81 _btnToggle:SetPoint("TOPLEFT", container.content, "TOPLEFT", 0, -40)
|
yellowfive@57
|
82
|
yellowfive@57
|
83 _lblLogging = AceGUI:Create("AmrUiLabel")
|
yellowfive@124
|
84 container:AddChild(_lblLogging)
|
yellowfive@57
|
85 _lblLogging:SetText(L.LogNote)
|
yellowfive@57
|
86 _lblLogging:SetWidth(200)
|
yellowfive@57
|
87 _lblLogging:SetFont(Amr.CreateFont("Italic", 14, Amr.Colors.BrightGreen))
|
yellowfive@57
|
88 _lblLogging:SetJustifyH("MIDDLE")
|
yellowfive@57
|
89 _lblLogging:SetPoint("TOP", _btnToggle.frame, "BOTTOM", 0, -5)
|
yellowfive@57
|
90
|
yellowfive@57
|
91 local btnReload = AceGUI:Create("AmrUiButton")
|
yellowfive@57
|
92 btnReload:SetText(L.LogButtonReloadText)
|
yellowfive@57
|
93 btnReload:SetBackgroundColor(Amr.Colors.Blue)
|
yellowfive@57
|
94 btnReload:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White))
|
yellowfive@57
|
95 btnReload:SetWidth(200)
|
yellowfive@57
|
96 btnReload:SetHeight(26)
|
yellowfive@57
|
97 btnReload:SetCallback("OnClick", ReloadUI)
|
yellowfive@57
|
98 container:AddChild(btnReload)
|
yellowfive@124
|
99 btnReload:SetPoint("TOPLEFT", _btnToggle.frame, "TOPRIGHT", 40, 0)
|
yellowfive@57
|
100
|
yellowfive@91
|
101 --[[
|
yellowfive@57
|
102 local lbl = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
103 lbl:SetText(L.LogReloadNote)
|
yellowfive@57
|
104 lbl:SetWidth(200)
|
yellowfive@57
|
105 lbl:SetFont(Amr.CreateFont("Italic", 14, Amr.Colors.TextTan))
|
yellowfive@57
|
106 lbl:SetJustifyH("MIDDLE")
|
yellowfive@57
|
107 lbl:SetPoint("TOP", btnReload.frame, "BOTTOM", 0, -5)
|
yellowfive@57
|
108 container:AddChild(lbl)
|
yellowfive@57
|
109
|
yellowfive@57
|
110 -- container for undo wipe so we can hide/show it all
|
yellowfive@57
|
111 _panelUndoWipe = AceGUI:Create("AmrUiPanel")
|
yellowfive@57
|
112 _panelUndoWipe:SetLayout("None")
|
yellowfive@57
|
113 _panelUndoWipe:SetBackgroundColor(Amr.Colors.Black, 0)
|
yellowfive@57
|
114 _panelUndoWipe:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -40)
|
yellowfive@57
|
115 container:AddChild(_panelUndoWipe)
|
yellowfive@57
|
116
|
yellowfive@57
|
117 local btnUndoWipe = AceGUI:Create("AmrUiButton")
|
yellowfive@57
|
118 btnUndoWipe:SetText(L.LogButtonUndoWipeText)
|
yellowfive@57
|
119 btnUndoWipe:SetBackgroundColor(Amr.Colors.Orange)
|
yellowfive@57
|
120 btnUndoWipe:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White))
|
yellowfive@57
|
121 btnUndoWipe:SetWidth(200)
|
yellowfive@57
|
122 btnUndoWipe:SetHeight(26)
|
yellowfive@57
|
123 btnUndoWipe:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -40)
|
yellowfive@57
|
124 btnUndoWipe:SetCallback("OnClick", function() Amr:UndoWipe() end)
|
yellowfive@57
|
125 _panelUndoWipe:AddChild(btnUndoWipe)
|
yellowfive@57
|
126
|
yellowfive@57
|
127 lbl = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
128 lbl:SetText(L.LogUndoWipeNote)
|
yellowfive@57
|
129 lbl:SetWidth(200)
|
yellowfive@57
|
130 lbl:SetFont(Amr.CreateFont("Italic", 14, Amr.Colors.TextTan))
|
yellowfive@57
|
131 lbl:SetJustifyH("MIDDLE")
|
yellowfive@57
|
132 lbl:SetPoint("TOP", btnUndoWipe.frame, "BOTTOM", 0, -5)
|
yellowfive@57
|
133 _panelUndoWipe:AddChild(lbl)
|
yellowfive@57
|
134
|
yellowfive@57
|
135 local lbl2 = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
136 lbl2:SetText(L.LogUndoWipeDate(date("%B %d", time()), date("%I:%M %p", time())))
|
yellowfive@57
|
137 lbl2:SetWidth(200)
|
yellowfive@57
|
138 lbl2:SetFont(Amr.CreateFont("Italic", 14, Amr.Colors.TextTan))
|
yellowfive@57
|
139 lbl2:SetJustifyH("MIDDLE")
|
yellowfive@57
|
140 lbl2:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -2)
|
yellowfive@57
|
141 _panelUndoWipe:AddChild(lbl2)
|
yellowfive@57
|
142
|
yellowfive@57
|
143 local btnWipe = AceGUI:Create("AmrUiButton")
|
yellowfive@57
|
144 btnWipe:SetText(L.LogButtonWipeText)
|
yellowfive@57
|
145 btnWipe:SetBackgroundColor(Amr.Colors.Orange)
|
yellowfive@57
|
146 btnWipe:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White))
|
yellowfive@57
|
147 btnWipe:SetWidth(200)
|
yellowfive@57
|
148 btnWipe:SetHeight(26)
|
yellowfive@57
|
149 btnWipe:SetPoint("TOPRIGHT", btnUndoWipe.frame, "TOPLEFT", -40, 0)
|
yellowfive@57
|
150 btnWipe:SetCallback("OnClick", function() Amr:Wipe() end)
|
yellowfive@57
|
151 container:AddChild(btnWipe)
|
yellowfive@91
|
152
|
yellowfive@57
|
153 lbl = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
154 lbl:SetText(L.LogWipeNote)
|
yellowfive@57
|
155 lbl:SetWidth(200)
|
yellowfive@57
|
156 lbl:SetFont(Amr.CreateFont("Italic", 14, Amr.Colors.TextTan))
|
yellowfive@57
|
157 lbl:SetJustifyH("MIDDLE")
|
yellowfive@57
|
158 lbl:SetPoint("TOP", btnWipe.frame, "BOTTOM", 0, -5)
|
yellowfive@57
|
159 container:AddChild(lbl)
|
yellowfive@57
|
160
|
yellowfive@57
|
161 lbl2 = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
162 lbl2:SetText(L.LogWipeNote2("/amr wipe"))
|
yellowfive@57
|
163 lbl2:SetWidth(200)
|
yellowfive@57
|
164 lbl2:SetFont(Amr.CreateFont("Italic", 14, Amr.Colors.TextTan))
|
yellowfive@57
|
165 lbl2:SetJustifyH("MIDDLE")
|
yellowfive@57
|
166 lbl2:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -2)
|
yellowfive@57
|
167 container:AddChild(lbl2)
|
yellowfive@91
|
168 ]]
|
yellowfive@57
|
169
|
yellowfive@57
|
170 -- auto-logging controls
|
yellowfive@91
|
171 local lbl = AceGUI:Create("AmrUiLabel")
|
yellowfive@124
|
172 container:AddChild(lbl)
|
yellowfive@57
|
173 lbl:SetWidth(600)
|
yellowfive@57
|
174 lbl:SetText(L.LogAutoTitle)
|
yellowfive@57
|
175 lbl:SetFont(Amr.CreateFont("Bold", 24, Amr.Colors.TextHeaderActive))
|
yellowfive@91
|
176 lbl:SetPoint("TOPLEFT", _btnToggle.frame, "BOTTOMLEFT", 0, -40)
|
yellowfive@57
|
177
|
yellowfive@57
|
178 _chkAutoAll = AceGUI:Create("AmrUiCheckBox")
|
yellowfive@57
|
179 _chkAutoAll:SetText(L.LogAutoAllText)
|
yellowfive@57
|
180 _chkAutoAll:SetCallback("OnClick", function(widget) Amr:ToggleAllAutoLog() end)
|
yellowfive@57
|
181 container:AddChild(_chkAutoAll)
|
yellowfive@124
|
182 _chkAutoAll:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 1, -15)
|
yellowfive@57
|
183
|
yellowfive@57
|
184 _autoChecks = {}
|
yellowfive@57
|
185
|
yellowfive@57
|
186 -- go through all supported instances, rendering in a left->right pattern, 2 per row
|
yellowfive@61
|
187 local autoLbls = {}
|
yellowfive@61
|
188 local autoChks = {}
|
yellowfive@57
|
189 for i, instanceId in ipairs(Amr.InstanceIdsOrdered) do
|
yellowfive@137
|
190 local autoLbl, autoChk = renderAutoLogSection(instanceId, container, i, autoLbls, autoChks)
|
yellowfive@57
|
191
|
yellowfive@61
|
192 table.insert(autoLbls, autoLbl)
|
yellowfive@61
|
193 table.insert(autoChks, autoChk)
|
yellowfive@57
|
194 end
|
yellowfive@124
|
195 autoLbls = nil
|
yellowfive@124
|
196 autoChks = nil
|
yellowfive@124
|
197
|
yellowfive@57
|
198 -- instructions
|
yellowfive@91
|
199 --[[
|
yellowfive@57
|
200 lbl = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
201 lbl:SetText(L.LogInstructionsTitle)
|
yellowfive@57
|
202 lbl:SetWidth(480)
|
yellowfive@57
|
203 lbl:SetFont(Amr.CreateFont("Italic", 24, Amr.Colors.Text))
|
yellowfive@57
|
204 lbl:SetPoint("TOPRIGHT", container.content, "TOPRIGHT", 0, -40)
|
yellowfive@57
|
205 container:AddChild(lbl)
|
yellowfive@57
|
206
|
yellowfive@57
|
207 lbl2 = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
208 lbl2:SetText(L.LogInstructions)
|
yellowfive@57
|
209 lbl2:SetWidth(480)
|
yellowfive@57
|
210 lbl2:SetFont(Amr.CreateFont("Italic", 14, Amr.Colors.Text))
|
yellowfive@57
|
211 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -10)
|
yellowfive@57
|
212 container:AddChild(lbl2)
|
yellowfive@91
|
213 ]]
|
yellowfive@57
|
214
|
yellowfive@57
|
215 -- initialize state of controls
|
yellowfive@57
|
216 Amr:RefreshLogUi()
|
yellowfive@57
|
217 end
|
yellowfive@57
|
218
|
yellowfive@57
|
219 function Amr:ReleaseTabLog()
|
yellowfive@133
|
220 _lblLogging = nil
|
yellowfive@57
|
221 _btnToggle = nil
|
yellowfive@57
|
222 _panelUndoWipe = nil
|
yellowfive@57
|
223 _chkAutoAll = nil
|
yellowfive@57
|
224 _autoChecks = nil
|
yellowfive@57
|
225 end
|
yellowfive@57
|
226
|
yellowfive@69
|
227 -- update the game's logging state
|
yellowfive@69
|
228 local function updateGameLogging(enabled)
|
yellowfive@69
|
229 if enabled then
|
yellowfive@69
|
230 -- always enable advanced combat logging via our addon, gathers more detailed data for better analysis
|
yellowfive@69
|
231 SetCVar("advancedCombatLogging", 1)
|
yellowfive@69
|
232 LoggingCombat(true)
|
yellowfive@69
|
233 else
|
yellowfive@69
|
234 LoggingCombat(false)
|
yellowfive@69
|
235 end
|
yellowfive@69
|
236 end
|
yellowfive@69
|
237
|
yellowfive@69
|
238 local function isAnyAutoLoggingEnabled()
|
yellowfive@69
|
239 local anyChecked = false
|
yellowfive@69
|
240 for i, instanceId in ipairs(Amr.InstanceIdsOrdered) do
|
yellowfive@69
|
241 for k, difficultyId in pairs(Amr.Difficulties) do
|
yellowfive@69
|
242 if Amr.db.profile.Logging.Auto[instanceId][difficultyId] then
|
yellowfive@69
|
243 anyChecked = true
|
yellowfive@69
|
244 break
|
yellowfive@69
|
245 end
|
yellowfive@69
|
246 end
|
yellowfive@69
|
247 if anyChecked then break end
|
yellowfive@69
|
248 end
|
yellowfive@69
|
249
|
yellowfive@69
|
250 return anyChecked
|
yellowfive@69
|
251 end
|
yellowfive@69
|
252
|
yellowfive@57
|
253 local function isAllAutoLoggingEnabled()
|
yellowfive@57
|
254 -- see if all auto-logging options are enabled
|
yellowfive@57
|
255 local allChecked = true
|
yellowfive@57
|
256 for i, instanceId in ipairs(Amr.InstanceIdsOrdered) do
|
yellowfive@57
|
257 for k, difficultyId in pairs(Amr.Difficulties) do
|
yellowfive@57
|
258 if not Amr.db.profile.Logging.Auto[instanceId][difficultyId] then
|
yellowfive@57
|
259 allChecked = false
|
yellowfive@57
|
260 break
|
yellowfive@57
|
261 end
|
yellowfive@57
|
262 end
|
yellowfive@57
|
263 if not allChecked then break end
|
yellowfive@57
|
264 end
|
yellowfive@57
|
265
|
yellowfive@57
|
266 return allChecked
|
yellowfive@57
|
267 end
|
yellowfive@57
|
268
|
yellowfive@57
|
269 -- check current zone and auto-logging settings, and enable logging if appropriate
|
yellowfive@69
|
270 local function updateAutoLogging(force, noWait)
|
yellowfive@69
|
271
|
yellowfive@69
|
272 local hasAuto = isAnyAutoLoggingEnabled()
|
yellowfive@69
|
273
|
yellowfive@69
|
274 -- before doing anything, make sure logging matches the user's current setting, deals with any inconsistency due to a crash or disconnect
|
yellowfive@69
|
275 if hasAuto then
|
yellowfive@69
|
276 updateGameLogging(Amr:IsLogging())
|
yellowfive@69
|
277 end
|
yellowfive@57
|
278
|
yellowfive@57
|
279 -- get the info about the instance
|
yellowfive@57
|
280 local zone, _, difficultyId, _, _, _, _, instanceId = GetInstanceInfo()
|
yellowfive@57
|
281
|
yellowfive@69
|
282 if Amr.IsSupportedInstanceId(instanceId) and difficultyId == 0 and not noWait then
|
yellowfive@69
|
283 -- the game is sometimes returning no difficulty id for raid zones... not sure why, wait 10 seconds and check again
|
yellowfive@69
|
284 Amr.Wait(10, function()
|
yellowfive@69
|
285 updateAutoLogging(false, false)
|
yellowfive@69
|
286 end)
|
yellowfive@69
|
287 return
|
yellowfive@69
|
288 end
|
yellowfive@69
|
289
|
yellowfive@57
|
290 if not force and zone == Amr.db.char.Logging.LastZone and difficultyId == Amr.db.char.Logging.LastDiff then
|
yellowfive@57
|
291 -- do nothing if the zone hasn't actually changed, otherwise we may override the user's manual enable/disable
|
yellowfive@57
|
292 return
|
yellowfive@57
|
293 end
|
yellowfive@57
|
294
|
yellowfive@57
|
295 Amr.db.char.Logging.LastZone = zone
|
yellowfive@57
|
296 Amr.db.char.Logging.LastDiff = difficultyId
|
yellowfive@57
|
297
|
yellowfive@137
|
298 if Amr.IsSupportedInstanceId(instanceId) then
|
yellowfive@137
|
299 if not Amr.db.profile.Logging.Auto[tonumber(instanceId)] then
|
yellowfive@137
|
300 Amr.db.profile.Logging.Auto[tonumber(instanceId)] = {}
|
yellowfive@137
|
301 end
|
yellowfive@91
|
302 end
|
yellowfive@91
|
303
|
yellowfive@57
|
304 if Amr.IsSupportedInstanceId(instanceId) and Amr.db.profile.Logging.Auto[tonumber(instanceId)][tonumber(difficultyId)] then
|
yellowfive@57
|
305 -- we are in a supported zone that we want to auto-log, turn logging on
|
yellowfive@69
|
306
|
yellowfive@57
|
307 -- (supported check is probably redundant, but just in case someone has old settings lying around)
|
yellowfive@57
|
308 if not Amr:IsLogging() then
|
yellowfive@57
|
309 Amr:StartLogging()
|
yellowfive@57
|
310 end
|
yellowfive@69
|
311 elseif hasAuto then
|
yellowfive@57
|
312 -- not in a zone that we want to auto-log, turn logging off
|
yellowfive@57
|
313 if Amr:IsLogging() then
|
yellowfive@57
|
314 Amr:StopLogging()
|
yellowfive@57
|
315 end
|
yellowfive@57
|
316 end
|
yellowfive@57
|
317 end
|
yellowfive@57
|
318
|
yellowfive@57
|
319 -- refresh the state of the tab based on current settings
|
yellowfive@57
|
320 function Amr:RefreshLogUi()
|
yellowfive@57
|
321 if not _btnToggle then return end
|
yellowfive@57
|
322
|
yellowfive@57
|
323 -- set state of logging button based on whether it is on or off
|
yellowfive@57
|
324 if self:IsLogging() then
|
yellowfive@57
|
325 _btnToggle:SetBackgroundColor(Amr.Colors.Red)
|
yellowfive@57
|
326 _btnToggle:SetText(L.LogButtonStopText)
|
yellowfive@57
|
327 else
|
yellowfive@57
|
328 _btnToggle:SetBackgroundColor(Amr.Colors.Green)
|
yellowfive@57
|
329 _btnToggle:SetText(L.LogButtonStartText)
|
yellowfive@57
|
330 end
|
yellowfive@57
|
331
|
yellowfive@57
|
332 _lblLogging:SetVisible(self:IsLogging())
|
yellowfive@57
|
333
|
yellowfive@57
|
334 -- hide/show undo wipe button based on whether a wipe has been called recently
|
yellowfive@91
|
335 if _panelUndoWipe then
|
yellowfive@91
|
336 _panelUndoWipe:SetVisible(Amr.db.char.Logging.LastWipe and true or false)
|
yellowfive@91
|
337 end
|
yellowfive@57
|
338
|
yellowfive@57
|
339 local all = isAllAutoLoggingEnabled()
|
yellowfive@57
|
340 _chkAutoAll:SetChecked(all)
|
yellowfive@57
|
341
|
yellowfive@57
|
342 for i, instanceId in ipairs(Amr.InstanceIdsOrdered) do
|
yellowfive@91
|
343 if not Amr.db.profile.Logging.Auto[instanceId] then
|
yellowfive@91
|
344 Amr.db.profile.Logging.Auto[instanceId] = {}
|
yellowfive@91
|
345 end
|
yellowfive@57
|
346 for k, difficultyId in pairs(Amr.Difficulties) do
|
yellowfive@57
|
347 _autoChecks[instanceId][difficultyId]:SetChecked(Amr.db.profile.Logging.Auto[instanceId][difficultyId])
|
yellowfive@57
|
348 end
|
yellowfive@57
|
349 end
|
yellowfive@57
|
350 end
|
yellowfive@57
|
351
|
yellowfive@57
|
352 function Amr:IsLogging()
|
yellowfive@57
|
353 return Amr.db.char.Logging.Enabled
|
yellowfive@57
|
354 end
|
yellowfive@57
|
355
|
yellowfive@57
|
356 function Amr:ToggleLogging()
|
yellowfive@57
|
357 if not Amr.db.char.Logging.Enabled then
|
yellowfive@57
|
358 Amr:StartLogging()
|
yellowfive@57
|
359 else
|
yellowfive@57
|
360 Amr:StopLogging()
|
yellowfive@57
|
361 end
|
yellowfive@57
|
362 end
|
yellowfive@57
|
363
|
yellowfive@57
|
364 function Amr:StartLogging()
|
yellowfive@57
|
365
|
yellowfive@91
|
366 --[[
|
yellowfive@57
|
367 local now = time()
|
yellowfive@57
|
368 local oldDuration = 60 * 60 * 24 * 10
|
yellowfive@57
|
369
|
yellowfive@57
|
370 -- prune out entries in log data that are more than 10 days old
|
yellowfive@57
|
371
|
yellowfive@57
|
372 -- player data
|
yellowfive@57
|
373 local playerData = Amr.db.global.Logging.PlayerData
|
yellowfive@57
|
374 if playerData then
|
yellowfive@57
|
375 for name, timeList in pairs(playerData) do
|
yellowfive@57
|
376 for timestamp, dataString in pairs(timeList) do
|
yellowfive@57
|
377 if difftime(now, tonumber(timestamp)) > oldDuration then
|
yellowfive@57
|
378 timeList[timestamp] = nil
|
yellowfive@57
|
379 end
|
yellowfive@57
|
380 end
|
yellowfive@57
|
381
|
yellowfive@57
|
382 if next(timeList) == nil then
|
yellowfive@57
|
383 playerData[name] = nil
|
yellowfive@57
|
384 end
|
yellowfive@57
|
385 end
|
yellowfive@57
|
386 end
|
yellowfive@57
|
387
|
yellowfive@57
|
388 -- same idea with extra info (auras, pets, whatever we end up adding to it)
|
yellowfive@57
|
389 local extraData = Amr.db.global.Logging.PlayerExtras
|
yellowfive@57
|
390 if extraData then
|
yellowfive@57
|
391 for name, timeList in pairs(extraData) do
|
yellowfive@57
|
392 for timestamp, dataString in pairs(timeList) do
|
yellowfive@57
|
393 if difftime(now, tonumber(timestamp)) > oldDuration then
|
yellowfive@57
|
394 timeList[timestamp] = nil
|
yellowfive@57
|
395 end
|
yellowfive@57
|
396 end
|
yellowfive@57
|
397
|
yellowfive@57
|
398 if next(timeList) == nil then
|
yellowfive@57
|
399 extraData[name] = nil
|
yellowfive@57
|
400 end
|
yellowfive@57
|
401 end
|
yellowfive@57
|
402 end
|
yellowfive@57
|
403
|
yellowfive@57
|
404 -- delete wipes that are more than 10 days old
|
yellowfive@57
|
405 if Amr.db.global.Logging.Wipes then
|
yellowfive@57
|
406 local wipes = Amr.db.global.Logging.Wipes
|
yellowfive@57
|
407 local i = 1
|
yellowfive@57
|
408 while i <= #wipes do
|
yellowfive@57
|
409 local t = wipes[i]
|
yellowfive@57
|
410 if difftime(now, t) > oldDuration then
|
yellowfive@57
|
411 table.remove(wipes, i)
|
yellowfive@57
|
412 else
|
yellowfive@57
|
413 i = i + 1
|
yellowfive@57
|
414 end
|
yellowfive@57
|
415 end
|
yellowfive@57
|
416 end
|
yellowfive@57
|
417
|
yellowfive@57
|
418 -- delete the last wipe date if it is more than 10 days old
|
yellowfive@57
|
419 if Amr.db.char.Logging.LastWipe and difftime(now, Amr.db.char.Logging.LastWipe) > oldDuration then
|
yellowfive@57
|
420 Amr.db.char.Logging.LastWipe = nil
|
yellowfive@57
|
421 end
|
yellowfive@91
|
422 ]]
|
yellowfive@91
|
423
|
yellowfive@69
|
424 -- enable game log file
|
yellowfive@69
|
425 updateGameLogging(true)
|
yellowfive@57
|
426 Amr.db.char.Logging.Enabled = true
|
yellowfive@57
|
427
|
yellowfive@57
|
428 self:Print(L.LogChatStart)
|
yellowfive@57
|
429
|
yellowfive@57
|
430 self:UpdateMinimap()
|
yellowfive@57
|
431 self:RefreshLogUi()
|
yellowfive@57
|
432 end
|
yellowfive@57
|
433
|
yellowfive@57
|
434 function Amr:StopLogging()
|
yellowfive@57
|
435
|
yellowfive@69
|
436 updateGameLogging(false)
|
yellowfive@57
|
437 Amr.db.char.Logging.Enabled = false
|
yellowfive@57
|
438
|
yellowfive@57
|
439 self:Print(L.LogChatStop)
|
yellowfive@57
|
440
|
yellowfive@57
|
441 self:UpdateMinimap()
|
yellowfive@57
|
442 self:RefreshLogUi()
|
yellowfive@57
|
443 end
|
yellowfive@57
|
444
|
yellowfive@57
|
445 function Amr:Wipe()
|
yellowfive@91
|
446
|
yellowfive@91
|
447 --[[
|
yellowfive@57
|
448 local t = time()
|
yellowfive@57
|
449 table.insert(Amr.db.global.Logging.Wipes, t)
|
yellowfive@57
|
450 Amr.db.char.Logging.LastWipe = t
|
yellowfive@57
|
451
|
yellowfive@57
|
452 self:Print(L.LogChatWipe(date('%I:%M %p', t)))
|
yellowfive@57
|
453
|
yellowfive@57
|
454 self:RefreshLogUi()
|
yellowfive@91
|
455 ]]
|
yellowfive@57
|
456 end
|
yellowfive@57
|
457
|
yellowfive@57
|
458 function Amr:UndoWipe()
|
yellowfive@57
|
459
|
yellowfive@91
|
460 --[[
|
yellowfive@57
|
461 local t = Amr.db.char.Logging.LastWipe
|
yellowfive@57
|
462 local wipes = Amr.db.global.Logging.Wipes
|
yellowfive@57
|
463
|
yellowfive@57
|
464 if not t then
|
yellowfive@57
|
465 self:Print(L.LogChatNoWipes)
|
yellowfive@57
|
466 else
|
yellowfive@57
|
467 -- find this wipe and remove it, may not be the last one if this person is raiding on multiple characters
|
yellowfive@57
|
468 for i = #wipes, 1, -1 do
|
yellowfive@57
|
469 if wipes[i] == t then
|
yellowfive@57
|
470 table.remove(wipes, i)
|
yellowfive@57
|
471 break
|
yellowfive@57
|
472 end
|
yellowfive@57
|
473 end
|
yellowfive@57
|
474
|
yellowfive@57
|
475 Amr.db.char.Logging.LastWipe = nil
|
yellowfive@57
|
476 self:Print(L.LogChatUndoWipe(date('%I:%M %p', t)))
|
yellowfive@57
|
477 end
|
yellowfive@57
|
478
|
yellowfive@57
|
479 self:RefreshLogUi()
|
yellowfive@91
|
480 ]]
|
yellowfive@57
|
481 end
|
yellowfive@57
|
482
|
yellowfive@57
|
483 function Amr:ToggleAutoLog(instanceId, difficultyId)
|
yellowfive@57
|
484
|
yellowfive@57
|
485 local byDiff = Amr.db.profile.Logging.Auto[instanceId]
|
yellowfive@57
|
486 byDiff[difficultyId] = not byDiff[difficultyId]
|
yellowfive@57
|
487
|
yellowfive@57
|
488 self:RefreshLogUi()
|
yellowfive@57
|
489
|
yellowfive@57
|
490 -- see if we should turn logging on right now
|
yellowfive@57
|
491 updateAutoLogging(true)
|
yellowfive@57
|
492 end
|
yellowfive@57
|
493
|
yellowfive@57
|
494 function Amr:ToggleAllAutoLog()
|
yellowfive@57
|
495
|
yellowfive@57
|
496 local val = not isAllAutoLoggingEnabled()
|
yellowfive@57
|
497
|
yellowfive@57
|
498 for i, instanceId in ipairs(Amr.InstanceIdsOrdered) do
|
yellowfive@57
|
499 for k, difficultyId in pairs(Amr.Difficulties) do
|
yellowfive@57
|
500 Amr.db.profile.Logging.Auto[instanceId][difficultyId] = val
|
yellowfive@57
|
501 end
|
yellowfive@57
|
502 end
|
yellowfive@57
|
503
|
yellowfive@57
|
504 self:RefreshLogUi()
|
yellowfive@57
|
505
|
yellowfive@57
|
506 -- see if we should turn logging on right now
|
yellowfive@57
|
507 updateAutoLogging(true)
|
yellowfive@57
|
508 end
|
yellowfive@57
|
509
|
yellowfive@57
|
510 function Amr:ProcessPlayerSnapshot(msg)
|
yellowfive@91
|
511 --[[
|
yellowfive@57
|
512 if not self:IsLogging() then return end
|
yellowfive@57
|
513
|
yellowfive@57
|
514 -- message will be of format: timestamp\nregion\nrealm\nname\n[stuff]
|
yellowfive@57
|
515 local parts = {}
|
yellowfive@57
|
516 for part in string.gmatch(msg, "([^\n]+)") do
|
yellowfive@57
|
517 table.insert(parts, part)
|
yellowfive@57
|
518 end
|
yellowfive@57
|
519
|
yellowfive@57
|
520 local timestamp = tonumber(parts[1])
|
yellowfive@57
|
521 local name = parts[2] .. ":" .. parts[3] .. ":" .. parts[4]
|
yellowfive@57
|
522 local setup = parts[5]
|
yellowfive@57
|
523
|
yellowfive@57
|
524 -- initialize the player's table
|
yellowfive@57
|
525 local playerList = Amr.db.global.Logging.PlayerData[name]
|
yellowfive@57
|
526 if not playerList then
|
yellowfive@57
|
527 playerList = {}
|
yellowfive@57
|
528 Amr.db.global.Logging.PlayerData[name] = playerList
|
yellowfive@57
|
529 end
|
yellowfive@57
|
530
|
yellowfive@57
|
531 -- find the most recent setup already recorded for this player
|
yellowfive@57
|
532 local previousSetup = nil
|
yellowfive@57
|
533 local previousTime = 0
|
yellowfive@57
|
534 for t, v in pairs(playerList) do
|
yellowfive@57
|
535 if t > previousTime then
|
yellowfive@57
|
536 previousSetup = v
|
yellowfive@57
|
537 previousTime = t
|
yellowfive@57
|
538 end
|
yellowfive@57
|
539 end
|
yellowfive@57
|
540
|
yellowfive@57
|
541 -- if the previous setup is more than 12 hours old, don't consider it
|
yellowfive@57
|
542 if previousSetup and difftime(timestamp, previousTime) > 60 * 60 * 12 then
|
yellowfive@57
|
543 previousSetup = nil
|
yellowfive@57
|
544 end
|
yellowfive@57
|
545
|
yellowfive@57
|
546 -- we only need to keep this setup if it is different than the previous
|
yellowfive@57
|
547 if setup ~= previousSetup then
|
yellowfive@57
|
548 playerList[timestamp] = setup
|
yellowfive@57
|
549 end
|
yellowfive@91
|
550 ]]
|
yellowfive@57
|
551 end
|
yellowfive@57
|
552
|
yellowfive@57
|
553 -- read auras and pet mapping info (pet may not be necessary anymore... but doesn't hurt)
|
yellowfive@57
|
554 local function getPlayerExtraData(data, unitId, petId)
|
yellowfive@91
|
555 --[[
|
yellowfive@57
|
556 local guid = UnitGUID(unitId)
|
yellowfive@57
|
557 if guid == nil then return end
|
yellowfive@57
|
558
|
yellowfive@57
|
559 local fields = {}
|
yellowfive@57
|
560
|
yellowfive@57
|
561 local buffs = {}
|
yellowfive@57
|
562 for i=1,40 do
|
yellowfive@57
|
563 local _,_,_,count,_,_,_,_,_,_,spellId = UnitAura(unitId, i, "HELPFUL")
|
yellowfive@57
|
564 table.insert(buffs, spellId)
|
yellowfive@57
|
565 end
|
yellowfive@57
|
566 if not buffs or #buffs == 0 then
|
yellowfive@57
|
567 table.insert(fields, "_")
|
yellowfive@57
|
568 else
|
yellowfive@57
|
569 table.insert(fields, Amr.Serializer:ToCompressedNumberList(buffs))
|
yellowfive@57
|
570 end
|
yellowfive@57
|
571
|
yellowfive@57
|
572 local petGuid = UnitGUID(petId)
|
yellowfive@57
|
573 if petGuid then
|
yellowfive@57
|
574 table.insert(fields, guid .. "," .. petGuid)
|
yellowfive@57
|
575 else
|
yellowfive@57
|
576 table.insert(fields, '_')
|
yellowfive@57
|
577 end
|
yellowfive@57
|
578
|
yellowfive@57
|
579 local name = GetUnitName(unitId, true) -- GetRaidRosterInfo(rosterIndex)
|
yellowfive@57
|
580 local realm = GetRealmName()
|
yellowfive@57
|
581 local region = Amr.RegionNames[GetCurrentRegion()]
|
yellowfive@57
|
582 local splitPos = string.find(name, "-")
|
yellowfive@57
|
583 if splitPos ~= nil then
|
yellowfive@57
|
584 realm = string.sub(name, splitPos + 1)
|
yellowfive@57
|
585 name = string.sub(name, 1, splitPos - 1)
|
yellowfive@57
|
586 end
|
yellowfive@57
|
587
|
yellowfive@57
|
588 data[region .. ":" .. realm .. ":" .. name] = table.concat(fields, ";")
|
yellowfive@91
|
589 ]]
|
yellowfive@57
|
590 end
|
yellowfive@57
|
591
|
yellowfive@57
|
592 local function logPlayerExtraData()
|
yellowfive@91
|
593 --[[
|
yellowfive@57
|
594 if not Amr:IsLogging() or not Amr:IsSupportedInstance() then return end
|
yellowfive@57
|
595
|
yellowfive@57
|
596 local timestamp = time()
|
yellowfive@57
|
597 local units = {}
|
yellowfive@57
|
598 local petUnits = {}
|
yellowfive@57
|
599
|
yellowfive@57
|
600 if IsInRaid() then
|
yellowfive@57
|
601 for i = 1,40 do
|
yellowfive@57
|
602 table.insert(units, "raid" .. i)
|
yellowfive@57
|
603 table.insert(petUnits, "raidpet" .. i)
|
yellowfive@57
|
604 end
|
yellowfive@57
|
605 elseif IsInGroup() then
|
yellowfive@57
|
606 table.insert(units, "player")
|
yellowfive@57
|
607 table.insert(petUnits, "pet")
|
yellowfive@57
|
608 for i = 1,4 do
|
yellowfive@57
|
609 table.insert(units, "party" .. i)
|
yellowfive@57
|
610 table.insert(petUnits, "partypet" .. i)
|
yellowfive@57
|
611 end
|
yellowfive@57
|
612 else
|
yellowfive@57
|
613 return
|
yellowfive@57
|
614 end
|
yellowfive@57
|
615
|
yellowfive@57
|
616 local data = {}
|
yellowfive@57
|
617 for i = 1,#units do
|
yellowfive@57
|
618 getPlayerExtraData(data, units[i], petUnits[i])
|
yellowfive@57
|
619 end
|
yellowfive@57
|
620
|
yellowfive@57
|
621 for name, val in pairs(data) do
|
yellowfive@57
|
622 -- record aura stuff, we never check for duplicates, need to know it at each point in time
|
yellowfive@57
|
623 if Amr.db.global.Logging.PlayerExtras[name] == nil then
|
yellowfive@57
|
624 Amr.db.global.Logging.PlayerExtras[name] = {}
|
yellowfive@57
|
625 end
|
yellowfive@57
|
626 Amr.db.global.Logging.PlayerExtras[name][timestamp] = val
|
yellowfive@57
|
627 end
|
yellowfive@91
|
628 ]]
|
yellowfive@57
|
629 end
|
yellowfive@57
|
630
|
yellowfive@57
|
631 function Amr:InitializeCombatLog()
|
yellowfive@137
|
632 updateAutoLogging()
|
yellowfive@57
|
633 end
|
yellowfive@57
|
634
|
yellowfive@57
|
635 Amr:AddEventHandler("UPDATE_INSTANCE_INFO", updateAutoLogging)
|
yellowfive@57
|
636 Amr:AddEventHandler("PLAYER_DIFFICULTY_CHANGED", updateAutoLogging)
|
yellowfive@65
|
637 Amr:AddEventHandler("ENCOUNTER_START", updateAutoLogging)
|
yellowfive@122
|
638 --Amr:AddEventHandler("PLAYER_REGEN_DISABLED", logPlayerExtraData)
|