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