adam@0
|
1 local _, AskMrRobot = ...
|
yellowfive@11
|
2 local L = AskMrRobot.L;
|
adam@0
|
3
|
adam@17
|
4 -- initialize the CombatLogTab class
|
adam@0
|
5 AskMrRobot.CombatLogTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame)
|
adam@0
|
6
|
adam@17
|
7 -- these are valid keys in AmrDb.LogData, all others will be deleted
|
yellowfive@11
|
8 local _logDataKeys = {
|
yellowfive@11
|
9 ["_logging"] = true,
|
yellowfive@11
|
10 ["_autoLog"] = true,
|
yellowfive@11
|
11 ["_lastZone"] = true,
|
yellowfive@11
|
12 ["_lastDiff"] = true,
|
yellowfive@11
|
13 ["_current2"] = true,
|
yellowfive@11
|
14 ["_history2"] = true,
|
yellowfive@11
|
15 ["_wipes"] = true,
|
yellowfive@11
|
16 ["_lastWipe"] = true,
|
yellowfive@11
|
17 ["_currentExtra"] = true,
|
yellowfive@11
|
18 ["_historyExtra"] = true
|
yellowfive@11
|
19 };
|
yellowfive@11
|
20
|
yellowfive@11
|
21 local _undoButton = false
|
yellowfive@11
|
22
|
adam@0
|
23 -- helper to create text for this tab
|
adam@0
|
24 local function CreateText(tab, font, relativeTo, xOffset, yOffset, text)
|
adam@0
|
25 local t = tab:CreateFontString(nil, "ARTWORK", font)
|
adam@0
|
26 t:SetPoint("TOPLEFT", relativeTo, "BOTTOMLEFT", xOffset, yOffset)
|
yellowfive@11
|
27 t:SetPoint("RIGHT", tab, "RIGHT", -5, 0)
|
adam@0
|
28 t:SetWidth(t:GetWidth())
|
adam@0
|
29 t:SetJustifyH("LEFT")
|
adam@0
|
30 t:SetText(text)
|
adam@0
|
31
|
adam@0
|
32 return t
|
adam@0
|
33 end
|
adam@0
|
34
|
adam@0
|
35 local function newCheckbox(tab, label, tooltipTitle, description, onClick)
|
adam@0
|
36 local check = CreateFrame("CheckButton", "AmrCheck" .. label, tab, "InterfaceOptionsCheckButtonTemplate")
|
adam@0
|
37 check:SetScript("OnClick", function(self)
|
adam@0
|
38 PlaySound(self:GetChecked() and "igMainMenuOptionCheckBoxOn" or "igMainMenuOptionCheckBoxOff")
|
adam@0
|
39 onClick(self, self:GetChecked() and true or false)
|
adam@0
|
40 end)
|
adam@0
|
41 check.label = _G[check:GetName() .. "Text"]
|
adam@0
|
42 check.label:SetText(label)
|
adam@0
|
43 check.tooltipText = tooltipTitle
|
adam@0
|
44 check.tooltipRequirement = description
|
adam@0
|
45 return check
|
adam@0
|
46 end
|
adam@0
|
47
|
adam@0
|
48 function AskMrRobot.CombatLogTab:new(parent)
|
adam@0
|
49
|
yellowfive@11
|
50 local tab = AskMrRobot.Frame:new(nil, parent)
|
adam@0
|
51 setmetatable(tab, { __index = AskMrRobot.CombatLogTab })
|
adam@0
|
52 tab:SetPoint("TOPLEFT")
|
adam@0
|
53 tab:SetPoint("BOTTOMRIGHT")
|
adam@0
|
54 tab:Hide()
|
adam@0
|
55
|
yellowfive@11
|
56 -- tab header
|
adam@0
|
57 local text = tab:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
|
adam@0
|
58 text:SetPoint("TOPLEFT", 0, -5)
|
yellowfive@49
|
59 text:SetText(L.AMR_COMBATLOGTAB_COMBAT_LOGGING)
|
yellowfive@11
|
60
|
yellowfive@11
|
61 --scrollframe
|
yellowfive@11
|
62 tab.scrollframe = AskMrRobot.ScrollFrame:new(nil, tab)
|
yellowfive@11
|
63 tab.scrollframe:SetPoint("TOPLEFT", tab, "TOPLEFT", 0, -30)
|
yellowfive@11
|
64 tab.scrollframe:SetPoint("BOTTOMRIGHT", tab, "BOTTOMRIGHT", -30, 10)
|
yellowfive@11
|
65
|
yellowfive@11
|
66 local content = tab.scrollframe.content
|
yellowfive@11
|
67 content:SetHeight(730)
|
adam@0
|
68
|
yellowfive@11
|
69 local btn = CreateFrame("Button", "AmrCombatLogStart", content, "UIPanelButtonTemplate")
|
yellowfive@11
|
70 btn:SetPoint("TOPLEFT", content, "TOPLEFT", 0, 0)
|
adam@0
|
71 btn:SetText("Start Logging")
|
adam@0
|
72 btn:SetWidth(120)
|
adam@0
|
73 btn:SetHeight(30)
|
adam@0
|
74 tab.btnStart = btn
|
adam@0
|
75
|
adam@0
|
76 btn:SetScript("OnClick", function()
|
yellowfive@11
|
77 tab:ToggleLogging()
|
adam@0
|
78 end)
|
adam@0
|
79
|
adam@0
|
80
|
yellowfive@11
|
81 text = content:CreateFontString(nil, "ARTWORK", "GameFontWhite")
|
yellowfive@11
|
82 text:SetPoint("LEFT", btn, "RIGHT", 10, 0)
|
yellowfive@11
|
83 tab.loggingStatus = text;
|
adam@0
|
84
|
TuhMuffinMan>@51
|
85 local hmAutoChk = newCheckbox(content,
|
TuhMuffinMan>@51
|
86 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_HM_LABEL,
|
TuhMuffinMan>@51
|
87 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_HM_TOOLTIP_TITLE,
|
TuhMuffinMan>@51
|
88 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_HM_DESCRIPTION,
|
adam@0
|
89 function(self, value)
|
adam@0
|
90 if value then
|
TuhMuffinMan>@51
|
91 AmrDb.LogData._autoLog[AskMrRobot.instanceIds.Highmaul] = "enabled"
|
adam@0
|
92 else
|
TuhMuffinMan>@51
|
93 AmrDb.LogData._autoLog[AskMrRobot.instanceIds.Highmaul] = "disabled"
|
adam@0
|
94 end
|
adam@0
|
95
|
adam@17
|
96 AmrDb.LogData._lastZone = nil
|
adam@17
|
97 AmrDb.LogData._lastDiff = nil
|
adam@0
|
98 tab:UpdateAutoLogging()
|
adam@0
|
99 end
|
adam@0
|
100 )
|
TuhMuffinMan>@51
|
101 hmAutoChk:SetChecked(AmrDb.LogData._autoLog[AskMrRobot.instanceIds.Highmaul] == "enabled")
|
TuhMuffinMan>@51
|
102 hmAutoChk:SetPoint("TOPLEFT", btn, "BOTTOMLEFT", 0, -10)
|
TuhMuffinMan>@51
|
103 hmAutoChk:SetHeight(30)
|
TuhMuffinMan>@51
|
104
|
TuhMuffinMan>@51
|
105 local brfAutoChk = newCheckbox(content,
|
TuhMuffinMan>@51
|
106 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_BRF_LABEL,
|
TuhMuffinMan>@51
|
107 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_BRF_TOOLTIP_TITLE,
|
TuhMuffinMan>@51
|
108 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_BRF_DESCRIPTION,
|
TuhMuffinMan>@51
|
109 function(self, value)
|
TuhMuffinMan>@51
|
110 if value then
|
TuhMuffinMan>@51
|
111 AmrDb.LogData._autoLog[AskMrRobot.instanceIds.BlackrockFoundry] = "enabled"
|
TuhMuffinMan>@51
|
112 else
|
TuhMuffinMan>@51
|
113 AmrDb.LogData._autoLog[AskMrRobot.instanceIds.BlackrockFoundry] = "disabled"
|
TuhMuffinMan>@51
|
114 end
|
adam@0
|
115
|
TuhMuffinMan>@51
|
116 AmrDb.LogData._lastZone = nil
|
TuhMuffinMan>@51
|
117 AmrDb.LogData._lastDiff = nil
|
TuhMuffinMan>@51
|
118 tab:UpdateAutoLogging()
|
TuhMuffinMan>@51
|
119 end
|
TuhMuffinMan>@51
|
120 )
|
TuhMuffinMan>@51
|
121 brfAutoChk:SetChecked(AmrDb.LogData._autoLog[AskMrRobot.instanceIds.BlackrockFoundry] == "enabled")
|
TuhMuffinMan>@51
|
122 brfAutoChk:SetPoint("TOPLEFT", hmAutoChk, "BOTTOMLEFT", 0, -10)
|
TuhMuffinMan>@51
|
123 brfAutoChk:SetHeight(30)
|
adam@0
|
124
|
TuhMuffinMan>@51
|
125 local text = CreateText(content, "GameFontNormalLarge", brfAutoChk, 0, -20, L.AMR_COMBATLOGTAB_INFIGHT)
|
yellowfive@11
|
126
|
TuhMuffinMan>@51
|
127 btn = CreateFrame("Button", "AmrCombatLogWipe", brfAutoChk, "UIPanelButtonTemplate")
|
yellowfive@11
|
128 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -10)
|
yellowfive@11
|
129 btn:SetText("Wipe")
|
yellowfive@11
|
130 btn:SetWidth(70)
|
yellowfive@11
|
131 btn:SetHeight(30)
|
yellowfive@11
|
132 btn:SetScript("OnClick", function()
|
yellowfive@11
|
133 tab:LogWipe()
|
yellowfive@11
|
134 end)
|
yellowfive@11
|
135
|
yellowfive@11
|
136 tab.btnWipe = btn
|
yellowfive@11
|
137
|
yellowfive@11
|
138 local text2 = CreateText(content, "GameFontWhite", text, 80, -12, L.AMR_COMBATLOGTAB_WIPE_1)
|
yellowfive@11
|
139 text2 = CreateText(content, "GameFontWhite", text2, 0, -2, L.AMR_COMBATLOGTAB_WIPE_2)
|
yellowfive@11
|
140 text2 = CreateText(content, "GameFontWhite", text2, 0, -2, L.AMR_COMBATLOGTAB_WIPE_3)
|
yellowfive@11
|
141
|
yellowfive@11
|
142 btn = CreateFrame("Button", "AmrCombatLogUnWipe", content, "UIPanelButtonTemplate")
|
yellowfive@11
|
143 btn:SetPoint("LEFT", text, "LEFT", 0, 0)
|
yellowfive@11
|
144 btn:SetPoint("TOP", text2, "BOTTOM", 0, -10)
|
yellowfive@11
|
145 btn:SetText("Undo")
|
yellowfive@11
|
146 btn:SetWidth(70)
|
yellowfive@11
|
147 btn:SetHeight(30)
|
yellowfive@11
|
148 btn:Hide() -- initially hidden
|
yellowfive@11
|
149 btn:SetScript("OnClick", function()
|
yellowfive@11
|
150 tab:LogUnwipe()
|
yellowfive@11
|
151 end)
|
yellowfive@11
|
152 tab.btnUnwipe = btn
|
yellowfive@11
|
153
|
yellowfive@11
|
154 text = content:CreateFontString(nil, "ARTWORK", "GameFontWhite")
|
yellowfive@11
|
155 text:SetPoint("LEFT", btn, "LEFT", 80, 0)
|
yellowfive@11
|
156 tab.lastWipeLabel = text
|
yellowfive@11
|
157
|
yellowfive@11
|
158 text = CreateText(tab, "GameFontNormalLarge", btn, 0, -20, L.AMR_COMBATLOGTAB_HEADLINE_OVER_BUTTON)
|
yellowfive@11
|
159
|
yellowfive@11
|
160 btn = CreateFrame("Button", "AmrCombatLogSaveCharData", content, "UIPanelButtonTemplate")
|
adam@0
|
161 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -5)
|
yellowfive@11
|
162 btn:SetText(L.AMR_COMBATLOGTAB_SAVE_CHARACTER)
|
adam@0
|
163 btn:SetWidth(150)
|
adam@0
|
164 btn:SetHeight(30)
|
adam@0
|
165
|
yellowfive@11
|
166 -- reload the UI will save character data to disk
|
yellowfive@11
|
167 btn:SetScript("OnClick", ReloadUI)
|
adam@0
|
168
|
yellowfive@11
|
169 text = CreateText(content, "GameFontWhite", btn, 0, -15, L.AMR_COMBATLOGTAB_SAVE_CHARACTER_INFO)
|
adam@0
|
170
|
yellowfive@11
|
171 text = CreateText(content, "GameFontNormalLarge", text, 0, -30, L.AMR_COMBATLOGTAB_INSTRUCTIONS)
|
yellowfive@11
|
172 text = CreateText(content, "GameFontWhite", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_1)
|
yellowfive@11
|
173 text = CreateText(content, "GameFontWhite", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_2)
|
yellowfive@11
|
174 text = CreateText(content, "GameFontWhite", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_3)
|
yellowfive@11
|
175 text = CreateText(content, "GameFontWhite", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_4)
|
yellowfive@11
|
176
|
yellowfive@11
|
177 text = CreateText(content, "GameFontNormalSmall", text, 0, -30, L.AMR_COMBATLOGTAB_INSTRUCTIONS_5)
|
yellowfive@11
|
178 text = CreateText(content, "GameFontNormalSmall", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_6)
|
yellowfive@11
|
179 text = CreateText(content, "GameFontNormalSmall", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_7)
|
adam@0
|
180
|
yellowfive@15
|
181 --[[
|
adam@0
|
182 btn = CreateFrame("Button", "AmrCombatLogTest", tab, "UIPanelButtonTemplate")
|
adam@0
|
183 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -15)
|
adam@0
|
184 btn:SetText("Test")
|
adam@0
|
185 btn:SetWidth(120)
|
adam@0
|
186 btn:SetHeight(30)
|
adam@0
|
187
|
adam@0
|
188 btn:SetScript("OnClick", function()
|
yellowfive@11
|
189
|
yellowfive@11
|
190 local t = time()
|
yellowfive@11
|
191 AskMrRobot.SaveAll()
|
yellowfive@11
|
192 AskMrRobot.ExportToAddonChat(t)
|
adam@17
|
193 AskMrRobot.CombatLogTab.SaveExtras(t)
|
adam@0
|
194 end)
|
yellowfive@15
|
195 ]]
|
adam@0
|
196
|
adam@0
|
197 -- when we start up, ensure that logging is still enabled if it was enabled when they last used the addon
|
adam@17
|
198 if (AskMrRobot.CombatLogTab.IsLogging()) then
|
adam@0
|
199 SetCVar("advancedCombatLogging", 1)
|
adam@0
|
200 LoggingCombat(true)
|
adam@0
|
201 end
|
adam@0
|
202
|
adam@0
|
203 -- if auto-logging is enabled, do a check when the addon is loaded to make sure that state is set correctly
|
TuhMuffinMan>@51
|
204 if AmrDb.LogData._autoLog[AskMrRobot.instanceIds.Highmaul] == "enabled" or AmrDb.LogData._autoLog[AskMrRobot.instanceIds.BlackrockFoundry] == "enabled" then
|
adam@0
|
205 tab:UpdateAutoLogging()
|
adam@0
|
206 end
|
adam@0
|
207
|
adam@0
|
208 tab:SetScript("OnShow", function()
|
adam@0
|
209 tab:Update()
|
adam@0
|
210 end)
|
adam@0
|
211
|
adam@0
|
212 return tab
|
adam@0
|
213 end
|
adam@0
|
214
|
adam@17
|
215 function AskMrRobot.CombatLogTab.IsLogging()
|
adam@17
|
216 return AmrDb.LogData._logging == true
|
adam@0
|
217 end
|
adam@0
|
218
|
adam@0
|
219 function AskMrRobot.CombatLogTab:StartLogging()
|
adam@0
|
220
|
yellowfive@11
|
221 local now = time()
|
yellowfive@11
|
222 local oldDuration = 60 * 60 * 24 * 10
|
yellowfive@11
|
223
|
adam@0
|
224 -- archive the current logging session so that users don't accidentally blow away data before uploading it
|
adam@17
|
225 if AmrDb.LogData._current2 ~= nil then
|
adam@17
|
226 if not AmrDb.LogData._history2 then AmrDb.LogData._history2 = {} end
|
adam@0
|
227
|
adam@0
|
228 -- add new entries
|
adam@17
|
229 for name, timeList in AskMrRobot.spairs(AmrDb.LogData._current2) do
|
adam@17
|
230 if not AmrDb.LogData._history2[name] then AmrDb.LogData._history2[name] = {} end
|
adam@0
|
231 for timestamp, dataString in AskMrRobot.spairs(timeList) do
|
adam@17
|
232 AmrDb.LogData._history2[name][timestamp] = dataString
|
adam@0
|
233 end
|
adam@0
|
234 end
|
adam@0
|
235
|
adam@0
|
236 -- delete entries that are more than 10 days old
|
adam@17
|
237 for name, timeList in AskMrRobot.spairs(AmrDb.LogData._history2) do
|
adam@0
|
238 for timestamp, dataString in AskMrRobot.spairs(timeList) do
|
yellowfive@11
|
239 if difftime(now, tonumber(timestamp)) > oldDuration then
|
adam@0
|
240 timeList[timestamp] = nil
|
adam@0
|
241 end
|
adam@0
|
242 end
|
adam@0
|
243
|
adam@0
|
244 local count = 0
|
adam@0
|
245 for timestamp, dataString in pairs(timeList) do
|
adam@0
|
246 count = count + 1
|
adam@0
|
247 end
|
adam@0
|
248 if count == 0 then
|
adam@17
|
249 AmrDb.LogData._history2[name] = nil
|
adam@0
|
250 end
|
adam@0
|
251 end
|
adam@0
|
252 end
|
adam@0
|
253
|
yellowfive@11
|
254 -- same idea with extra info (auras, pets, whatever we end up adding to it)
|
adam@17
|
255 if AmrDb.LogData._currentExtra ~= nil then
|
adam@17
|
256 if not AmrDb.LogData._historyExtra then AmrDb.LogData._historyExtra = {} end
|
yellowfive@11
|
257
|
yellowfive@11
|
258 -- add new entries
|
adam@17
|
259 for name, timeList in AskMrRobot.spairs(AmrDb.LogData._currentExtra) do
|
adam@17
|
260 if not AmrDb.LogData._historyExtra[name] then AmrDb.LogData._historyExtra[name] = {} end
|
yellowfive@11
|
261 for timestamp, dataString in AskMrRobot.spairs(timeList) do
|
adam@17
|
262 AmrDb.LogData._historyExtra[name][timestamp] = dataString
|
yellowfive@11
|
263 end
|
yellowfive@11
|
264 end
|
yellowfive@11
|
265
|
yellowfive@11
|
266 -- delete entries that are more than 10 days old
|
adam@17
|
267 for name, timeList in AskMrRobot.spairs(AmrDb.LogData._historyExtra) do
|
yellowfive@11
|
268 for timestamp, dataString in AskMrRobot.spairs(timeList) do
|
yellowfive@11
|
269 if difftime(now, tonumber(timestamp)) > oldDuration then
|
yellowfive@11
|
270 timeList[timestamp] = nil
|
yellowfive@11
|
271 end
|
yellowfive@11
|
272 end
|
yellowfive@11
|
273
|
yellowfive@11
|
274 local count = 0
|
yellowfive@11
|
275 for timestamp, dataString in pairs(timeList) do
|
yellowfive@11
|
276 count = count + 1
|
yellowfive@11
|
277 end
|
yellowfive@11
|
278 if count == 0 then
|
adam@17
|
279 AmrDb.LogData._historyExtra[name] = nil
|
yellowfive@11
|
280 end
|
yellowfive@11
|
281 end
|
yellowfive@11
|
282 end
|
yellowfive@11
|
283
|
yellowfive@11
|
284
|
yellowfive@11
|
285 -- delete _wipes entries that are more than 10 days old
|
adam@17
|
286 if AmrDb.LogData._wipes then
|
yellowfive@11
|
287 local i = 1
|
adam@17
|
288 while i <= #AmrDb.LogData._wipes do
|
adam@17
|
289 local t = AmrDb.LogData._wipes[i]
|
yellowfive@11
|
290 if difftime(now, t) > oldDuration then
|
adam@17
|
291 tremove(AmrDb.LogData._wipes, i)
|
yellowfive@11
|
292 else
|
yellowfive@11
|
293 i = i + 1
|
yellowfive@11
|
294 end
|
yellowfive@11
|
295 end
|
yellowfive@11
|
296 end
|
yellowfive@11
|
297
|
yellowfive@11
|
298 -- delete the _lastWipe if it is more than 10 days old
|
adam@17
|
299 if AmrDb.LogData._lastWipe and difftime(now, AmrDb.LogData._lastWipe) > oldDuration then
|
adam@17
|
300 AmrDb.LogData_lastWipe = nil
|
yellowfive@11
|
301 end
|
yellowfive@11
|
302
|
adam@0
|
303 -- clean up old-style logging data from previous versions of the addon
|
adam@17
|
304 for k, v in AskMrRobot.spairs(AmrDb.LogData) do
|
yellowfive@11
|
305 if not _logDataKeys[k] then
|
adam@17
|
306 AmrDb.LogData[k] = nil
|
adam@0
|
307 end
|
adam@0
|
308 end
|
adam@0
|
309
|
adam@0
|
310 -- start a new logging session
|
adam@17
|
311 AmrDb.LogData._current2 = {}
|
adam@17
|
312 AmrDb.LogData._currentExtra = {}
|
adam@17
|
313 AmrDb.LogData._logging = true
|
adam@0
|
314
|
adam@0
|
315 -- always enable advanced combat logging via our addon, gathers more detailed data for better analysis
|
adam@0
|
316 SetCVar("advancedCombatLogging", 1)
|
adam@0
|
317
|
adam@0
|
318 LoggingCombat(true)
|
adam@0
|
319 self:Update()
|
yellowfive@11
|
320
|
yellowfive@11
|
321 AskMrRobot.AmrUpdateMinimap()
|
adam@0
|
322
|
yellowfive@11
|
323 print(L.AMR_COMBATLOGTAB_IS_LOGGING)
|
adam@0
|
324 end
|
adam@0
|
325
|
adam@0
|
326 function AskMrRobot.CombatLogTab:StopLogging()
|
adam@0
|
327 LoggingCombat(false)
|
adam@17
|
328 AmrDb.LogData._logging = false
|
adam@0
|
329 self:Update()
|
adam@0
|
330
|
yellowfive@11
|
331 AskMrRobot.AmrUpdateMinimap()
|
yellowfive@11
|
332
|
yellowfive@11
|
333 print(L.AMR_COMBATLOGTAB_STOPPED_LOGGING)
|
yellowfive@11
|
334 end
|
yellowfive@11
|
335
|
yellowfive@11
|
336 function AskMrRobot.CombatLogTab:ToggleLogging()
|
adam@17
|
337 if AskMrRobot.CombatLogTab.IsLogging() then
|
yellowfive@11
|
338 self:StopLogging()
|
yellowfive@11
|
339 else
|
yellowfive@11
|
340 self:StartLogging()
|
yellowfive@11
|
341 end
|
adam@0
|
342 end
|
adam@0
|
343
|
adam@0
|
344 -- update the panel and state
|
adam@0
|
345 function AskMrRobot.CombatLogTab:Update()
|
adam@17
|
346 local isLogging = AskMrRobot.CombatLogTab.IsLogging()
|
adam@0
|
347
|
adam@0
|
348 if isLogging then
|
yellowfive@11
|
349 self.btnStart:SetText(L.AMR_COMBATLOGTAB_STOP_LOGGING)
|
yellowfive@11
|
350 self.loggingStatus:SetText(L.AMR_COMBATLOGTAB_CURRENTLY_LOGGING)
|
adam@0
|
351 else
|
yellowfive@11
|
352 self.btnStart:SetText(L.AMR_COMBATLOGTAB_START_LOGGING)
|
yellowfive@11
|
353 self.loggingStatus:SetText("")
|
adam@0
|
354 end
|
yellowfive@11
|
355
|
adam@17
|
356 if AmrDb.LogData._lastWipe then
|
adam@17
|
357 self.lastWipeLabel:SetText(L.AMR_COMBATLOGTAB_LASTWIPE:format(date('%B %d', AmrDb.LogData._lastWipe), date('%I:%M %p', AmrDb.LogData._lastWipe)))
|
yellowfive@11
|
358 self.btnUnwipe:Show()
|
yellowfive@11
|
359 else
|
yellowfive@11
|
360 self.lastWipeLabel:SetText("")
|
yellowfive@11
|
361 self.btnUnwipe:Hide()
|
yellowfive@11
|
362 end
|
yellowfive@11
|
363
|
adam@0
|
364 end
|
adam@0
|
365
|
adam@0
|
366 -- called to update logging state when auto-logging is enabled
|
adam@0
|
367 function AskMrRobot.CombatLogTab:UpdateAutoLogging()
|
adam@0
|
368
|
adam@0
|
369 -- get the info about the instance
|
adam@0
|
370 --local zone, zonetype, difficultyIndex, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID = GetInstanceInfo()
|
adam@0
|
371 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo()
|
adam@0
|
372 --local difficulty = difficultyIndex
|
adam@0
|
373 -- Unless Blizzard fixes scenarios to not return nil, let's hardcode this into returning "scenario" -Znuff
|
adam@0
|
374 --if zonetype == nil and difficultyIndex == 1 then
|
adam@0
|
375 --zonetype = "scenario"
|
adam@0
|
376 --end
|
adam@0
|
377
|
adam@17
|
378 if zone == AmrDb.LogData._lastZone and difficultyIndex == AmrDb.LogData._lastDiff then
|
adam@0
|
379 -- do nothing if the zone hasn't actually changed, otherwise we may override the user's manual enable/disable
|
adam@0
|
380 return
|
adam@0
|
381 end
|
adam@0
|
382
|
adam@17
|
383 AmrDb.LogData._lastZone = zone
|
adam@17
|
384 AmrDb.LogData._lastDiff = difficultyIndex
|
adam@0
|
385
|
TuhMuffinMan>@51
|
386 if AmrDb.LogData._autoLog[AskMrRobot.instanceIds.Highmaul] == "enabled" or AmrDb.LogData._autoLog[AskMrRobot.instanceIds.BlackrockFoundry] == "enabled" then
|
TuhMuffinMan>@51
|
387 if tonumber(instanceMapID) == AskMrRobot.instanceIds.Highmaul or tonumber(instanceMapID) == AskMrRobot.instanceIds.BlackrockFoundry then
|
adam@0
|
388 -- if in SoO, make sure logging is on
|
adam@17
|
389 if not AskMrRobot.CombatLogTab.IsLogging() then
|
adam@0
|
390 self:StartLogging()
|
adam@0
|
391 end
|
adam@0
|
392 else
|
adam@0
|
393 -- not in SoO, turn logging off
|
adam@17
|
394 if AskMrRobot.CombatLogTab.IsLogging() then
|
adam@0
|
395 self:StopLogging()
|
adam@0
|
396 end
|
adam@0
|
397 end
|
adam@0
|
398 end
|
adam@0
|
399
|
adam@0
|
400 end
|
adam@0
|
401
|
yellowfive@11
|
402 local function RaidChatType()
|
yellowfive@11
|
403 if UnitIsGroupAssistant("player") or UnitIsGroupLeader("player") then
|
yellowfive@11
|
404 return "RAID_WARNING"
|
yellowfive@11
|
405 else
|
yellowfive@11
|
406 return "RAID"
|
yellowfive@11
|
407 end
|
yellowfive@11
|
408 end
|
yellowfive@11
|
409
|
adam@17
|
410 -- used to store wipes to AmrDb.LogData so that we trim data after the wipe
|
yellowfive@11
|
411 function AskMrRobot.CombatLogTab:LogWipe()
|
yellowfive@11
|
412 local t = time()
|
adam@17
|
413 tinsert(AmrDb.LogData._wipes, t)
|
adam@17
|
414 AmrDb.LogData._lastWipe = t
|
yellowfive@11
|
415
|
adam@17
|
416 --if GetNumGroupMembers() > 0 then
|
adam@17
|
417 -- SendChatMessage(L.AMR_COMBATLOGTAB_WIPE_CHAT, RaidChatType())
|
adam@17
|
418 --end
|
yellowfive@11
|
419 print(string.format(L.AMR_COMBATLOGTAB_WIPE_MSG, date('%I:%M %p', t)))
|
yellowfive@11
|
420
|
yellowfive@11
|
421 self:Update()
|
yellowfive@11
|
422 end
|
yellowfive@11
|
423
|
yellowfive@11
|
424 -- used to undo the wipe command
|
yellowfive@11
|
425 function AskMrRobot.CombatLogTab:LogUnwipe()
|
adam@17
|
426 local t = AmrDb.LogData._lastWipe
|
yellowfive@11
|
427 if not t then
|
yellowfive@11
|
428 print(L.AMR_COMBATLOGTAB_NOWIPES)
|
yellowfive@11
|
429 else
|
adam@17
|
430 tremove(AmrDb.LogData._wipes)
|
adam@17
|
431 AmrDb.LogData._lastWipe = nil
|
yellowfive@11
|
432 print(string.format(L.AMR_COMBATLOGTAB_UNWIPE_MSG, date('%I:%M %p', t)))
|
yellowfive@11
|
433 end
|
yellowfive@11
|
434 self:Update()
|
yellowfive@11
|
435 end
|
yellowfive@11
|
436
|
adam@17
|
437 -- initialize the AmrDb.LogData variable
|
yellowfive@11
|
438 function AskMrRobot.CombatLogTab.InitializeVariable()
|
adam@17
|
439 if not AmrDb.LogData then AmrDb.LogData = {} end
|
adam@17
|
440 if not AmrDb.LogData._autoLog then AmrDb.LogData._autoLog = {} end
|
TuhMuffinMan>@51
|
441 if not AmrDb.LogData._autoLog[AskMrRobot.instanceIds.Highmaul] then
|
TuhMuffinMan>@51
|
442 AmrDb.LogData._autoLog[AskMrRobot.instanceIds.Highmaul] = "disabled"
|
yellowfive@11
|
443 end
|
TuhMuffinMan>@51
|
444 if not AmrDb.LogData._autoLog[AskMrRobot.instanceIds.BlackrockFoundry] then
|
TuhMuffinMan>@51
|
445 AmrDb.LogData._autoLog[AskMrRobot.instanceIds.BlackrockFoundry] = "disabled"
|
TuhMuffinMan>@51
|
446 end
|
adam@17
|
447 AmrDb.LogData._wipes = AmrDb.LogData._wipes or {}
|
yellowfive@11
|
448 end
|
yellowfive@11
|
449
|
yellowfive@41
|
450 local function GetPlayerExtraData(data, unitId, petId)
|
adam@17
|
451
|
adam@17
|
452 local guid = UnitGUID(unitId)
|
adam@17
|
453 if guid == nil then
|
yellowfive@41
|
454 return
|
adam@17
|
455 end
|
adam@17
|
456
|
adam@17
|
457 local fields = {}
|
adam@17
|
458
|
adam@17
|
459 local buffs = {}
|
adam@17
|
460 for i=1,40 do
|
adam@17
|
461 local _,_,_,count,_,_,_,_,_,_,spellId = UnitAura(unitId, i, "HELPFUL")
|
adam@17
|
462 table.insert(buffs, spellId)
|
adam@17
|
463 end
|
adam@17
|
464 if #buffs == 0 then
|
adam@17
|
465 table.insert(fields, "_")
|
adam@17
|
466 else
|
adam@17
|
467 table.insert(fields, AskMrRobot.toCompressedNumberList(buffs))
|
adam@17
|
468 end
|
adam@17
|
469
|
yellowfive@41
|
470 local petGuid = UnitGUID(petId)
|
adam@17
|
471 if petGuid then
|
adam@17
|
472 table.insert(fields, guid .. "," .. petGuid)
|
adam@17
|
473 else
|
adam@17
|
474 table.insert(fields, '_')
|
adam@17
|
475 end
|
adam@17
|
476
|
yellowfive@41
|
477 local name = GetUnitName(unitId, true) -- GetRaidRosterInfo(rosterIndex)
|
adam@17
|
478 local realm = GetRealmName()
|
yellowfive@41
|
479 local region = AskMrRobot.regionNames[GetCurrentRegion()]
|
adam@17
|
480 local splitPos = string.find(name, "-")
|
adam@17
|
481 if splitPos ~= nil then
|
adam@17
|
482 realm = string.sub(name, splitPos + 1)
|
adam@17
|
483 name = string.sub(name, 1, splitPos - 1)
|
adam@17
|
484 end
|
adam@17
|
485
|
yellowfive@41
|
486 data[region .. ":" .. realm .. ":" .. name] = table.concat(fields, ";")
|
adam@17
|
487 end
|
adam@17
|
488
|
adam@17
|
489 function AskMrRobot.CombatLogTab.SaveExtras(timestamp)
|
adam@17
|
490
|
adam@17
|
491 if not AskMrRobot.CombatLogTab.IsLogging() then
|
adam@17
|
492 return
|
adam@17
|
493 end
|
adam@17
|
494
|
yellowfive@41
|
495 local units = {}
|
yellowfive@41
|
496 local petUnits = {}
|
yellowfive@41
|
497
|
yellowfive@41
|
498 if IsInRaid() then
|
yellowfive@41
|
499 for i = 1,40 do
|
yellowfive@41
|
500 table.insert(units, "raid" .. i)
|
yellowfive@41
|
501 table.insert(petUnits, "raidpet" .. i)
|
yellowfive@41
|
502 end
|
yellowfive@41
|
503 elseif IsInGroup() then
|
yellowfive@41
|
504 table.insert(units, "player")
|
yellowfive@41
|
505 table.insert(petUnits, "pet")
|
yellowfive@41
|
506 for i = 1,4 do
|
yellowfive@41
|
507 table.insert(units, "party" .. i)
|
yellowfive@41
|
508 table.insert(petUnits, "partypet" .. i)
|
yellowfive@41
|
509 end
|
yellowfive@41
|
510 else
|
yellowfive@41
|
511 return
|
yellowfive@41
|
512 end
|
adam@17
|
513
|
adam@17
|
514 local data = {}
|
yellowfive@41
|
515 for i = 1,#units do
|
yellowfive@41
|
516 GetPlayerExtraData(data, units[i], petUnits[i])
|
yellowfive@41
|
517 end
|
adam@17
|
518
|
yellowfive@11
|
519 for name,val in pairs(data) do
|
yellowfive@11
|
520 -- record aura stuff, we never check for duplicates, need to know it at each point in time
|
adam@17
|
521 if AmrDb.LogData._currentExtra[name] == nil then
|
adam@17
|
522 AmrDb.LogData._currentExtra[name] = {}
|
yellowfive@11
|
523 end
|
adam@17
|
524 AmrDb.LogData._currentExtra[name][timestamp] = val
|
yellowfive@11
|
525 end
|
yellowfive@11
|
526 end
|
yellowfive@11
|
527
|
adam@0
|
528 -- read a message sent to the addon channel with a player's info at the time an encounter started
|
adam@0
|
529 function AskMrRobot.CombatLogTab:ReadAddonMessage(message)
|
adam@0
|
530
|
yellowfive@41
|
531 -- message will be of format: timestamp\nregion\nrealm\nname\n[stuff]
|
adam@0
|
532 local parts = {}
|
adam@0
|
533 for part in string.gmatch(message, "([^\n]+)") do
|
adam@0
|
534 tinsert(parts, part)
|
adam@0
|
535 end
|
adam@0
|
536
|
adam@0
|
537 local timestamp = parts[1]
|
yellowfive@41
|
538 local name = parts[2] .. ":" .. parts[3] .. ":" .. parts[4]
|
yellowfive@41
|
539 local data = parts[5]
|
adam@0
|
540
|
adam@0
|
541 if (data == "done") then
|
adam@0
|
542 -- we have finished receiving this message; now process it to reduce the amount of duplicate data
|
adam@17
|
543 local setup = AmrDb.LogData._current2[name][timestamp]
|
yellowfive@11
|
544
|
adam@17
|
545 if (AmrDb.LogData._previousSetup == nil) then
|
adam@17
|
546 AmrDb.LogData._previousSetup = {}
|
adam@0
|
547 end
|
adam@0
|
548
|
adam@17
|
549 local previousSetup = AmrDb.LogData._previousSetup[name]
|
adam@0
|
550
|
adam@0
|
551 if (previousSetup == setup) then
|
adam@0
|
552 -- if the last-seen setup for this player is the same as the current one, we don't need this entry
|
adam@17
|
553 AmrDb.LogData._current2[name][timestamp] = nil
|
adam@0
|
554 else
|
adam@0
|
555 -- record the last-seen setup
|
adam@17
|
556 AmrDb.LogData._previousSetup[name] = setup
|
adam@0
|
557 end
|
yellowfive@11
|
558
|
adam@0
|
559 else
|
adam@0
|
560 -- concatenate messages with the same timestamp+name
|
adam@17
|
561 if (AmrDb.LogData._current2[name] == nil) then
|
adam@17
|
562 AmrDb.LogData._current2[name] = {}
|
adam@0
|
563 end
|
adam@0
|
564
|
adam@17
|
565 if (AmrDb.LogData._current2[name][timestamp] == nil) then
|
adam@17
|
566 AmrDb.LogData._current2[name][timestamp] = data
|
adam@0
|
567 else
|
adam@17
|
568 AmrDb.LogData._current2[name][timestamp] = AmrDb.LogData._current2[name][timestamp] .. data
|
adam@0
|
569 end
|
adam@0
|
570 end
|
adam@0
|
571 end
|