Mercurial > wow > askmrrobot
comparison ui/CombatLogTab.lua @ 11:ece9167c0d1c v1.2.14.0
Localization support, combat log features (wipe command, aura/pet tracking, and realm detection).
author | yellowfive |
---|---|
date | Thu, 10 Jul 2014 12:24:59 -0700 |
parents | ec731d2fe6ba |
children | 218628cb4a29 |
comparison
equal
deleted
inserted
replaced
10:ef8b45e96b08 | 11:ece9167c0d1c |
---|---|
1 local _, AskMrRobot = ... | 1 local _, AskMrRobot = ... |
2 local L = AskMrRobot.L; | |
2 | 3 |
3 -- initialize the ExportTab class | 4 -- initialize the ExportTab class |
4 AskMrRobot.CombatLogTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame) | 5 AskMrRobot.CombatLogTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame) |
6 | |
7 -- these are valid keys in AmrLogData, all others will be deleted | |
8 local _logDataKeys = { | |
9 ["_logging"] = true, | |
10 ["_autoLog"] = true, | |
11 ["_lastZone"] = true, | |
12 ["_lastDiff"] = true, | |
13 ["_current2"] = true, | |
14 ["_history2"] = true, | |
15 ["_wipes"] = true, | |
16 ["_lastWipe"] = true, | |
17 ["_currentExtra"] = true, | |
18 ["_historyExtra"] = true | |
19 }; | |
20 | |
21 local _undoButton = false | |
5 | 22 |
6 -- helper to create text for this tab | 23 -- helper to create text for this tab |
7 local function CreateText(tab, font, relativeTo, xOffset, yOffset, text) | 24 local function CreateText(tab, font, relativeTo, xOffset, yOffset, text) |
8 local t = tab:CreateFontString(nil, "ARTWORK", font) | 25 local t = tab:CreateFontString(nil, "ARTWORK", font) |
9 t:SetPoint("TOPLEFT", relativeTo, "BOTTOMLEFT", xOffset, yOffset) | 26 t:SetPoint("TOPLEFT", relativeTo, "BOTTOMLEFT", xOffset, yOffset) |
10 t:SetPoint("RIGHT", tab, "RIGHT", -25, 0) | 27 t:SetPoint("RIGHT", tab, "RIGHT", -5, 0) |
11 t:SetWidth(t:GetWidth()) | 28 t:SetWidth(t:GetWidth()) |
12 t:SetJustifyH("LEFT") | 29 t:SetJustifyH("LEFT") |
13 t:SetText(text) | 30 t:SetText(text) |
14 | 31 |
15 return t | 32 return t |
28 return check | 45 return check |
29 end | 46 end |
30 | 47 |
31 function AskMrRobot.CombatLogTab:new(parent) | 48 function AskMrRobot.CombatLogTab:new(parent) |
32 | 49 |
33 local tab = AskMrRobot.Frame:new(nil, parent) | 50 local tab = AskMrRobot.Frame:new(nil, parent) |
34 setmetatable(tab, { __index = AskMrRobot.CombatLogTab }) | 51 setmetatable(tab, { __index = AskMrRobot.CombatLogTab }) |
35 tab:SetPoint("TOPLEFT") | 52 tab:SetPoint("TOPLEFT") |
36 tab:SetPoint("BOTTOMRIGHT") | 53 tab:SetPoint("BOTTOMRIGHT") |
37 tab:Hide() | 54 tab:Hide() |
38 | 55 |
56 -- tab header | |
39 local text = tab:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") | 57 local text = tab:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") |
40 text:SetPoint("TOPLEFT", 0, -5) | 58 text:SetPoint("TOPLEFT", 0, -5) |
41 text:SetText("Combat Logging") | 59 text:SetText("Combat Logging") |
42 | 60 |
43 local manulText = CreateText(tab, "GameFontWhite", text, 0, -15, "Manual:") | 61 --scrollframe |
44 manulText:SetJustifyV("MIDDLE") | 62 tab.scrollframe = AskMrRobot.ScrollFrame:new(nil, tab) |
45 manulText:SetHeight(30) | 63 tab.scrollframe:SetPoint("TOPLEFT", tab, "TOPLEFT", 0, -30) |
46 | 64 tab.scrollframe:SetPoint("BOTTOMRIGHT", tab, "BOTTOMRIGHT", -30, 10) |
47 local btn = CreateFrame("Button", "AmrCombatLogStart", tab, "UIPanelButtonTemplate") | 65 |
48 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 75, -15) | 66 local content = tab.scrollframe.content |
67 content:SetHeight(730) | |
68 | |
69 local btn = CreateFrame("Button", "AmrCombatLogStart", content, "UIPanelButtonTemplate") | |
70 btn:SetPoint("TOPLEFT", content, "TOPLEFT", 0, 0) | |
49 btn:SetText("Start Logging") | 71 btn:SetText("Start Logging") |
50 btn:SetWidth(120) | 72 btn:SetWidth(120) |
51 btn:SetHeight(30) | 73 btn:SetHeight(30) |
52 tab.btnStart = btn | 74 tab.btnStart = btn |
53 | 75 |
54 btn:SetScript("OnClick", function() | 76 btn:SetScript("OnClick", function() |
55 tab:StartLogging() | 77 tab:ToggleLogging() |
56 end) | 78 end) |
57 | 79 |
58 btn = CreateFrame("Button", "AmrCombatLogEnd", tab, "UIPanelButtonTemplate") | 80 |
59 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 225, -15) | 81 text = content:CreateFontString(nil, "ARTWORK", "GameFontWhite") |
60 btn:SetText("Stop Logging") | 82 text:SetPoint("LEFT", btn, "RIGHT", 10, 0) |
61 btn:SetWidth(120) | 83 tab.loggingStatus = text; |
62 btn:SetHeight(30) | 84 |
63 tab.btnEnd = btn | 85 local autoChk = newCheckbox(content, |
64 | 86 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_SOO_LABEL, |
65 btn:SetScript("OnClick", function() | 87 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_SOO_TOOLTIP_TITLE, |
66 tab:StopLogging() | 88 L.AMR_COMBATLOGTAB_CHECKBOX_AUTOLOG_SOO_DESCRIPTION, |
67 end) | |
68 | |
69 local autoText = CreateText(tab, "GameFontWhite", text, 0, -50, "Automatic:") | |
70 autoText:SetJustifyV("MIDDLE") | |
71 autoText:SetHeight(28) | |
72 | |
73 local autoChk = newCheckbox(tab, | |
74 "Always log Siege of Orgrimmar", | |
75 "Auto-Log Siege of Orgrimmar", | |
76 "Automatically start logging when you enter SoO and stop when you leave SoO.\n\nNote that you should disable similar features in other addons to avoid conflicts.", | |
77 function(self, value) | 89 function(self, value) |
78 if value then | 90 if value then |
79 AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] = "enabled" | 91 AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] = "enabled" |
80 else | 92 else |
81 AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] = "disabled" | 93 AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] = "disabled" |
85 AmrLogData._lastDiff = nil | 97 AmrLogData._lastDiff = nil |
86 tab:UpdateAutoLogging() | 98 tab:UpdateAutoLogging() |
87 end | 99 end |
88 ) | 100 ) |
89 autoChk:SetChecked(AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] == "enabled") | 101 autoChk:SetChecked(AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] == "enabled") |
90 autoChk:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 75, -50) | 102 autoChk:SetPoint("TOPLEFT", btn, "BOTTOMLEFT", 0, -10) |
91 autoChk:SetHeight(30) | 103 autoChk:SetHeight(30) |
92 | 104 |
93 text = CreateText(tab, "GameFontNormalLarge", text, 0, -100, "Character Data") | 105 |
94 | 106 local text = CreateText(content, "GameFontNormalLarge", autoChk, 0, -20, L.AMR_COMBATLOGTAB_INFIGHT) |
95 btn = CreateFrame("Button", "AmrCombatLogSaveCharData", tab, "UIPanelButtonTemplate") | 107 |
108 btn = CreateFrame("Button", "AmrCombatLogWipe", autoChk, "UIPanelButtonTemplate") | |
109 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -10) | |
110 btn:SetText("Wipe") | |
111 btn:SetWidth(70) | |
112 btn:SetHeight(30) | |
113 btn:SetScript("OnClick", function() | |
114 tab:LogWipe() | |
115 end) | |
116 | |
117 tab.btnWipe = btn | |
118 | |
119 local text2 = CreateText(content, "GameFontWhite", text, 80, -12, L.AMR_COMBATLOGTAB_WIPE_1) | |
120 text2 = CreateText(content, "GameFontWhite", text2, 0, -2, L.AMR_COMBATLOGTAB_WIPE_2) | |
121 text2 = CreateText(content, "GameFontWhite", text2, 0, -2, L.AMR_COMBATLOGTAB_WIPE_3) | |
122 | |
123 btn = CreateFrame("Button", "AmrCombatLogUnWipe", content, "UIPanelButtonTemplate") | |
124 btn:SetPoint("LEFT", text, "LEFT", 0, 0) | |
125 btn:SetPoint("TOP", text2, "BOTTOM", 0, -10) | |
126 btn:SetText("Undo") | |
127 btn:SetWidth(70) | |
128 btn:SetHeight(30) | |
129 btn:Hide() -- initially hidden | |
130 btn:SetScript("OnClick", function() | |
131 tab:LogUnwipe() | |
132 end) | |
133 tab.btnUnwipe = btn | |
134 | |
135 text = content:CreateFontString(nil, "ARTWORK", "GameFontWhite") | |
136 text:SetPoint("LEFT", btn, "LEFT", 80, 0) | |
137 tab.lastWipeLabel = text | |
138 | |
139 text = CreateText(tab, "GameFontNormalLarge", btn, 0, -20, L.AMR_COMBATLOGTAB_HEADLINE_OVER_BUTTON) | |
140 | |
141 btn = CreateFrame("Button", "AmrCombatLogSaveCharData", content, "UIPanelButtonTemplate") | |
96 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -5) | 142 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -5) |
97 btn:SetText("Save Character Data") | 143 btn:SetText(L.AMR_COMBATLOGTAB_SAVE_CHARACTER) |
98 btn:SetWidth(150) | 144 btn:SetWidth(150) |
99 btn:SetHeight(30) | 145 btn:SetHeight(30) |
100 | 146 |
101 btn:SetScript("OnClick", function() | 147 -- reload the UI will save character data to disk |
102 -- reload the UI will save character data to disk | 148 btn:SetScript("OnClick", ReloadUI) |
103 ReloadUI() | 149 |
104 end) | 150 text = CreateText(content, "GameFontWhite", btn, 0, -15, L.AMR_COMBATLOGTAB_SAVE_CHARACTER_INFO) |
105 | 151 |
106 text = CreateText(tab, "GameFontNormalLarge", btn, 0, -30, "INSTRUCTIONS") | 152 text = CreateText(content, "GameFontNormalLarge", text, 0, -30, L.AMR_COMBATLOGTAB_INSTRUCTIONS) |
107 text = CreateText(tab, "GameFontWhite", text, 0, -10, "1. Use the Start/Stop buttons or check 'Always log Siege of Orgrimmar'.") | 153 text = CreateText(content, "GameFontWhite", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_1) |
108 text = CreateText(tab, "GameFontWhite", text, 0, -10, "2. When you are ready to upload, press 'Save Character Data'. *") | 154 text = CreateText(content, "GameFontWhite", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_2) |
109 text = CreateText(tab, "GameFontWhite", text, 0, -10, "3. Exit World of Warcraft. **") | 155 text = CreateText(content, "GameFontWhite", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_3) |
110 text = CreateText(tab, "GameFontWhite", text, 0, -10, "4. Launch the Ask Mr. Robot client and follow the instructions. ***") | 156 text = CreateText(content, "GameFontWhite", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_4) |
111 | 157 |
112 text = CreateText(tab, "GameFontNormalSmall", text, 0, -30, "|c00999999* This will reload your UI to ensure that all collected data is saved to disk. This step is not necessary if you log out of the game before uploading.|r") | 158 text = CreateText(content, "GameFontNormalSmall", text, 0, -30, L.AMR_COMBATLOGTAB_INSTRUCTIONS_5) |
113 text = CreateText(tab, "GameFontNormalSmall", text, 0, -10, "|c00999999** Exiting WoW before uploading your combat log is optional, but highly recommended. This prevents your log file from getting ridiculously large and slowing down your uploads.|r") | 159 text = CreateText(content, "GameFontNormalSmall", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_6) |
114 text = CreateText(tab, "GameFontNormalSmall", text, 0, -10, "|c00999999*** You can download the client program at|r |c003333ffhttp://www.askmrrobot.com/wow/combatlog/upload|r|c00999999.|r") | 160 text = CreateText(content, "GameFontNormalSmall", text, 0, -10, L.AMR_COMBATLOGTAB_INSTRUCTIONS_7) |
115 | 161 |
116 --[[ | |
117 btn = CreateFrame("Button", "AmrCombatLogTest", tab, "UIPanelButtonTemplate") | 162 btn = CreateFrame("Button", "AmrCombatLogTest", tab, "UIPanelButtonTemplate") |
118 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -15) | 163 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -15) |
119 btn:SetText("Test") | 164 btn:SetText("Test") |
120 btn:SetWidth(120) | 165 btn:SetWidth(120) |
121 btn:SetHeight(30) | 166 btn:SetHeight(30) |
122 | 167 |
123 btn:SetScript("OnClick", function() | 168 btn:SetScript("OnClick", function() |
124 AskMrRobot.ExportToAddonChat(time()) | 169 |
170 local t = time() | |
171 AskMrRobot.SaveAll() | |
172 AskMrRobot.ExportToAddonChat(t) | |
173 AskMrRobot.ExportLoggingData(t) | |
125 end) | 174 end) |
126 ]] | |
127 | 175 |
128 -- when we start up, ensure that logging is still enabled if it was enabled when they last used the addon | 176 -- when we start up, ensure that logging is still enabled if it was enabled when they last used the addon |
129 if (tab:IsLogging()) then | 177 if (tab:IsLogging()) then |
130 SetCVar("advancedCombatLogging", 1) | 178 SetCVar("advancedCombatLogging", 1) |
131 LoggingCombat(true) | 179 LoggingCombat(true) |
147 return AmrLogData._logging == true | 195 return AmrLogData._logging == true |
148 end | 196 end |
149 | 197 |
150 function AskMrRobot.CombatLogTab:StartLogging() | 198 function AskMrRobot.CombatLogTab:StartLogging() |
151 | 199 |
200 local now = time() | |
201 local oldDuration = 60 * 60 * 24 * 10 | |
202 | |
152 -- archive the current logging session so that users don't accidentally blow away data before uploading it | 203 -- archive the current logging session so that users don't accidentally blow away data before uploading it |
153 if AmrLogData._current2 ~= nil then | 204 if AmrLogData._current2 ~= nil then |
154 if not AmrLogData._history2 then AmrLogData._history2 = {} end | 205 if not AmrLogData._history2 then AmrLogData._history2 = {} end |
155 | 206 |
156 -- add new entries | 207 -- add new entries |
160 AmrLogData._history2[name][timestamp] = dataString | 211 AmrLogData._history2[name][timestamp] = dataString |
161 end | 212 end |
162 end | 213 end |
163 | 214 |
164 -- delete entries that are more than 10 days old | 215 -- delete entries that are more than 10 days old |
165 local now = time() | |
166 local interval = 60 * 60 * 24 * 10 | |
167 for name, timeList in AskMrRobot.spairs(AmrLogData._history2) do | 216 for name, timeList in AskMrRobot.spairs(AmrLogData._history2) do |
168 for timestamp, dataString in AskMrRobot.spairs(timeList) do | 217 for timestamp, dataString in AskMrRobot.spairs(timeList) do |
169 if difftime(now, tonumber(timestamp)) > interval then | 218 if difftime(now, tonumber(timestamp)) > oldDuration then |
170 timeList[timestamp] = nil | 219 timeList[timestamp] = nil |
171 end | 220 end |
172 end | 221 end |
173 | 222 |
174 local count = 0 | 223 local count = 0 |
179 AmrLogData._history2[name] = nil | 228 AmrLogData._history2[name] = nil |
180 end | 229 end |
181 end | 230 end |
182 end | 231 end |
183 | 232 |
233 -- same idea with extra info (auras, pets, whatever we end up adding to it) | |
234 if AmrLogData._currentExtra ~= nil then | |
235 if not AmrLogData._historyExtra then AmrLogData._historyExtra = {} end | |
236 | |
237 -- add new entries | |
238 for name, timeList in AskMrRobot.spairs(AmrLogData._currentExtra) do | |
239 if not AmrLogData._historyExtra[name] then AmrLogData._historyExtra[name] = {} end | |
240 for timestamp, dataString in AskMrRobot.spairs(timeList) do | |
241 AmrLogData._historyExtra[name][timestamp] = dataString | |
242 end | |
243 end | |
244 | |
245 -- delete entries that are more than 10 days old | |
246 for name, timeList in AskMrRobot.spairs(AmrLogData._historyExtra) do | |
247 for timestamp, dataString in AskMrRobot.spairs(timeList) do | |
248 if difftime(now, tonumber(timestamp)) > oldDuration then | |
249 timeList[timestamp] = nil | |
250 end | |
251 end | |
252 | |
253 local count = 0 | |
254 for timestamp, dataString in pairs(timeList) do | |
255 count = count + 1 | |
256 end | |
257 if count == 0 then | |
258 AmrLogData._historyExtra[name] = nil | |
259 end | |
260 end | |
261 end | |
262 | |
263 | |
264 -- delete _wipes entries that are more than 10 days old | |
265 if AmrLogData._wipes then | |
266 local i = 1 | |
267 while i <= #AmrLogData._wipes do | |
268 local t = AmrLogData._wipes[i] | |
269 if difftime(now, t) > oldDuration then | |
270 tremove(AmrLogData._wipes, i) | |
271 else | |
272 i = i + 1 | |
273 end | |
274 end | |
275 end | |
276 | |
277 -- delete the _lastWipe if it is more than 10 days old | |
278 if AmrLogData._lastWipe and difftime(now, AmrLogData._lastWipe) > oldDuration then | |
279 AmrLogData_lastWipe = nil | |
280 end | |
281 | |
184 -- clean up old-style logging data from previous versions of the addon | 282 -- clean up old-style logging data from previous versions of the addon |
185 for k, v in AskMrRobot.spairs(AmrLogData) do | 283 for k, v in AskMrRobot.spairs(AmrLogData) do |
186 if k ~= "_logging" and k ~= "_autoLog" and k ~= "_lastZone" and k ~= "_lastDiff" and k ~= "_current2" and k ~= "_history2" then | 284 if not _logDataKeys[k] then |
187 AmrLogData[k] = nil | 285 AmrLogData[k] = nil |
188 end | 286 end |
189 end | 287 end |
190 | 288 |
191 -- start a new logging session | 289 -- start a new logging session |
192 AmrLogData._current2 = {} | 290 AmrLogData._current2 = {} |
291 AmrLogData._currentExtra = {} | |
193 AmrLogData._logging = true | 292 AmrLogData._logging = true |
194 | 293 |
195 -- always enable advanced combat logging via our addon, gathers more detailed data for better analysis | 294 -- always enable advanced combat logging via our addon, gathers more detailed data for better analysis |
196 SetCVar("advancedCombatLogging", 1) | 295 SetCVar("advancedCombatLogging", 1) |
197 | 296 |
198 LoggingCombat(true) | 297 LoggingCombat(true) |
199 self:Update() | 298 self:Update() |
200 | 299 |
201 print("You are now logging combat, and Mr. Robot is logging character data for your raid.") | 300 AskMrRobot.AmrUpdateMinimap() |
301 | |
302 print(L.AMR_COMBATLOGTAB_IS_LOGGING) | |
202 end | 303 end |
203 | 304 |
204 function AskMrRobot.CombatLogTab:StopLogging() | 305 function AskMrRobot.CombatLogTab:StopLogging() |
205 LoggingCombat(false) | 306 LoggingCombat(false) |
206 AmrLogData._logging = false | 307 AmrLogData._logging = false |
207 self:Update() | 308 self:Update() |
208 | 309 |
209 print("Combat logging has been stopped.") | 310 AskMrRobot.AmrUpdateMinimap() |
311 | |
312 print(L.AMR_COMBATLOGTAB_STOPPED_LOGGING) | |
313 end | |
314 | |
315 function AskMrRobot.CombatLogTab:ToggleLogging() | |
316 if self:IsLogging() then | |
317 self:StopLogging() | |
318 else | |
319 self:StartLogging() | |
320 end | |
210 end | 321 end |
211 | 322 |
212 -- update the panel and state | 323 -- update the panel and state |
213 function AskMrRobot.CombatLogTab:Update() | 324 function AskMrRobot.CombatLogTab:Update() |
214 local isLogging = self:IsLogging() | 325 local isLogging = self:IsLogging() |
215 | 326 |
216 if isLogging then | 327 if isLogging then |
217 self.btnStart:Disable() | 328 self.btnStart:SetText(L.AMR_COMBATLOGTAB_STOP_LOGGING) |
218 self.btnEnd:Enable() | 329 self.loggingStatus:SetText(L.AMR_COMBATLOGTAB_CURRENTLY_LOGGING) |
219 else | 330 else |
220 self.btnStart:Enable() | 331 self.btnStart:SetText(L.AMR_COMBATLOGTAB_START_LOGGING) |
221 self.btnEnd:Disable() | 332 self.loggingStatus:SetText("") |
222 end | 333 end |
334 | |
335 if AmrLogData._lastWipe then | |
336 self.lastWipeLabel:SetText(L.AMR_COMBATLOGTAB_LASTWIPE:format(date('%B %d', AmrLogData._lastWipe), date('%I:%M %p', AmrLogData._lastWipe))) | |
337 self.btnUnwipe:Show() | |
338 else | |
339 self.lastWipeLabel:SetText("") | |
340 self.btnUnwipe:Hide() | |
341 end | |
342 | |
223 end | 343 end |
224 | 344 |
225 -- called to update logging state when auto-logging is enabled | 345 -- called to update logging state when auto-logging is enabled |
226 function AskMrRobot.CombatLogTab:UpdateAutoLogging() | 346 function AskMrRobot.CombatLogTab:UpdateAutoLogging() |
227 | 347 |
256 end | 376 end |
257 end | 377 end |
258 | 378 |
259 end | 379 end |
260 | 380 |
381 local function RaidChatType() | |
382 if UnitIsGroupAssistant("player") or UnitIsGroupLeader("player") then | |
383 return "RAID_WARNING" | |
384 else | |
385 return "RAID" | |
386 end | |
387 end | |
388 | |
389 -- used to store wipes to AmrLogData so that we trim data after the wipe | |
390 function AskMrRobot.CombatLogTab:LogWipe() | |
391 local t = time() | |
392 tinsert(AmrLogData._wipes, t) | |
393 AmrLogData._lastWipe = t | |
394 | |
395 if GetNumGroupMembers() > 0 then | |
396 SendChatMessage(L.AMR_COMBATLOGTAB_WIPE_CHAT, RaidChatType()) | |
397 end | |
398 print(string.format(L.AMR_COMBATLOGTAB_WIPE_MSG, date('%I:%M %p', t))) | |
399 | |
400 self:Update() | |
401 --AskMrRobot.wait(301, AskMrRobot.CombatLogTab.Update, self) | |
402 end | |
403 | |
404 -- used to undo the wipe command | |
405 function AskMrRobot.CombatLogTab:LogUnwipe() | |
406 local t = AmrLogData._lastWipe | |
407 if not t then | |
408 print(L.AMR_COMBATLOGTAB_NOWIPES) | |
409 else | |
410 tremove(AmrLogData._wipes) | |
411 AmrLogData._lastWipe = nil | |
412 print(string.format(L.AMR_COMBATLOGTAB_UNWIPE_MSG, date('%I:%M %p', t))) | |
413 end | |
414 self:Update() | |
415 end | |
416 | |
417 -- initialize the AmrLogData variable | |
418 function AskMrRobot.CombatLogTab.InitializeVariable() | |
419 if not AmrLogData then AmrLogData = {} end | |
420 if not AmrLogData._autoLog then AmrLogData._autoLog = {} end | |
421 if not AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] then | |
422 AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] = "disabled" | |
423 end | |
424 AmrLogData._wipes = AmrLogData._wipes or {} | |
425 end | |
426 | |
427 function AskMrRobot.CombatLogTab.SaveExtras(data, timestamp) | |
428 | |
429 for name,val in pairs(data) do | |
430 -- record aura stuff, we never check for duplicates, need to know it at each point in time | |
431 if AmrLogData._currentExtra[name] == nil then | |
432 AmrLogData._currentExtra[name] = {} | |
433 end | |
434 AmrLogData._currentExtra[name][timestamp] = val | |
435 end | |
436 end | |
437 | |
261 -- read a message sent to the addon channel with a player's info at the time an encounter started | 438 -- read a message sent to the addon channel with a player's info at the time an encounter started |
262 function AskMrRobot.CombatLogTab:ReadAddonMessage(message) | 439 function AskMrRobot.CombatLogTab:ReadAddonMessage(message) |
263 | 440 |
264 -- message will be of format: timestamp\nrealm\nname\n[stuff] | 441 -- message will be of format: timestamp\nrealm\nname\n[stuff] |
265 local parts = {} | 442 local parts = {} |
272 local data = parts[4] | 449 local data = parts[4] |
273 | 450 |
274 if (data == "done") then | 451 if (data == "done") then |
275 -- we have finished receiving this message; now process it to reduce the amount of duplicate data | 452 -- we have finished receiving this message; now process it to reduce the amount of duplicate data |
276 local setup = AmrLogData._current2[name][timestamp] | 453 local setup = AmrLogData._current2[name][timestamp] |
277 | 454 |
278 if (AmrLogData._previousSetup == nil) then | 455 if (AmrLogData._previousSetup == nil) then |
279 AmrLogData._previousSetup = {} | 456 AmrLogData._previousSetup = {} |
280 end | 457 end |
281 | 458 |
282 local previousSetup = AmrLogData._previousSetup[name] | 459 local previousSetup = AmrLogData._previousSetup[name] |
286 AmrLogData._current2[name][timestamp] = nil | 463 AmrLogData._current2[name][timestamp] = nil |
287 else | 464 else |
288 -- record the last-seen setup | 465 -- record the last-seen setup |
289 AmrLogData._previousSetup[name] = setup | 466 AmrLogData._previousSetup[name] = setup |
290 end | 467 end |
468 | |
291 else | 469 else |
292 -- concatenate messages with the same timestamp+name | 470 -- concatenate messages with the same timestamp+name |
293 if (AmrLogData._current2[name] == nil) then | 471 if (AmrLogData._current2[name] == nil) then |
294 AmrLogData._current2[name] = {} | 472 AmrLogData._current2[name] = {} |
295 end | 473 end |