annotate 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
rev   line source
adam@0 1 local _, AskMrRobot = ...
yellowfive@11 2 local L = AskMrRobot.L;
adam@0 3
adam@0 4 -- initialize the ExportTab class
adam@0 5 AskMrRobot.CombatLogTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame)
adam@0 6
yellowfive@11 7 -- these are valid keys in AmrLogData, 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@0 91 AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] = "enabled"
adam@0 92 else
adam@0 93 AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] = "disabled"
adam@0 94 end
adam@0 95
adam@0 96 AmrLogData._lastZone = nil
adam@0 97 AmrLogData._lastDiff = nil
adam@0 98 tab:UpdateAutoLogging()
adam@0 99 end
adam@0 100 )
adam@0 101 autoChk:SetChecked(AmrLogData._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
adam@0 162 btn = CreateFrame("Button", "AmrCombatLogTest", tab, "UIPanelButtonTemplate")
adam@0 163 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -15)
adam@0 164 btn:SetText("Test")
adam@0 165 btn:SetWidth(120)
adam@0 166 btn:SetHeight(30)
adam@0 167
adam@0 168 btn:SetScript("OnClick", function()
yellowfive@11 169
yellowfive@11 170 local t = time()
yellowfive@11 171 AskMrRobot.SaveAll()
yellowfive@11 172 AskMrRobot.ExportToAddonChat(t)
yellowfive@11 173 AskMrRobot.ExportLoggingData(t)
adam@0 174 end)
adam@0 175
adam@0 176 -- when we start up, ensure that logging is still enabled if it was enabled when they last used the addon
adam@0 177 if (tab:IsLogging()) then
adam@0 178 SetCVar("advancedCombatLogging", 1)
adam@0 179 LoggingCombat(true)
adam@0 180 end
adam@0 181
adam@0 182 -- if auto-logging is enabled, do a check when the addon is loaded to make sure that state is set correctly
adam@0 183 if AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] == "enabled" then
adam@0 184 tab:UpdateAutoLogging()
adam@0 185 end
adam@0 186
adam@0 187 tab:SetScript("OnShow", function()
adam@0 188 tab:Update()
adam@0 189 end)
adam@0 190
adam@0 191 return tab
adam@0 192 end
adam@0 193
adam@0 194 function AskMrRobot.CombatLogTab:IsLogging()
adam@0 195 return AmrLogData._logging == true
adam@0 196 end
adam@0 197
adam@0 198 function AskMrRobot.CombatLogTab:StartLogging()
adam@0 199
yellowfive@11 200 local now = time()
yellowfive@11 201 local oldDuration = 60 * 60 * 24 * 10
yellowfive@11 202
adam@0 203 -- archive the current logging session so that users don't accidentally blow away data before uploading it
adam@0 204 if AmrLogData._current2 ~= nil then
adam@0 205 if not AmrLogData._history2 then AmrLogData._history2 = {} end
adam@0 206
adam@0 207 -- add new entries
adam@0 208 for name, timeList in AskMrRobot.spairs(AmrLogData._current2) do
adam@0 209 if not AmrLogData._history2[name] then AmrLogData._history2[name] = {} end
adam@0 210 for timestamp, dataString in AskMrRobot.spairs(timeList) do
adam@0 211 AmrLogData._history2[name][timestamp] = dataString
adam@0 212 end
adam@0 213 end
adam@0 214
adam@0 215 -- delete entries that are more than 10 days old
adam@0 216 for name, timeList in AskMrRobot.spairs(AmrLogData._history2) do
adam@0 217 for timestamp, dataString in AskMrRobot.spairs(timeList) do
yellowfive@11 218 if difftime(now, tonumber(timestamp)) > oldDuration then
adam@0 219 timeList[timestamp] = nil
adam@0 220 end
adam@0 221 end
adam@0 222
adam@0 223 local count = 0
adam@0 224 for timestamp, dataString in pairs(timeList) do
adam@0 225 count = count + 1
adam@0 226 end
adam@0 227 if count == 0 then
adam@0 228 AmrLogData._history2[name] = nil
adam@0 229 end
adam@0 230 end
adam@0 231 end
adam@0 232
yellowfive@11 233 -- same idea with extra info (auras, pets, whatever we end up adding to it)
yellowfive@11 234 if AmrLogData._currentExtra ~= nil then
yellowfive@11 235 if not AmrLogData._historyExtra then AmrLogData._historyExtra = {} end
yellowfive@11 236
yellowfive@11 237 -- add new entries
yellowfive@11 238 for name, timeList in AskMrRobot.spairs(AmrLogData._currentExtra) do
yellowfive@11 239 if not AmrLogData._historyExtra[name] then AmrLogData._historyExtra[name] = {} end
yellowfive@11 240 for timestamp, dataString in AskMrRobot.spairs(timeList) do
yellowfive@11 241 AmrLogData._historyExtra[name][timestamp] = dataString
yellowfive@11 242 end
yellowfive@11 243 end
yellowfive@11 244
yellowfive@11 245 -- delete entries that are more than 10 days old
yellowfive@11 246 for name, timeList in AskMrRobot.spairs(AmrLogData._historyExtra) do
yellowfive@11 247 for timestamp, dataString in AskMrRobot.spairs(timeList) do
yellowfive@11 248 if difftime(now, tonumber(timestamp)) > oldDuration then
yellowfive@11 249 timeList[timestamp] = nil
yellowfive@11 250 end
yellowfive@11 251 end
yellowfive@11 252
yellowfive@11 253 local count = 0
yellowfive@11 254 for timestamp, dataString in pairs(timeList) do
yellowfive@11 255 count = count + 1
yellowfive@11 256 end
yellowfive@11 257 if count == 0 then
yellowfive@11 258 AmrLogData._historyExtra[name] = nil
yellowfive@11 259 end
yellowfive@11 260 end
yellowfive@11 261 end
yellowfive@11 262
yellowfive@11 263
yellowfive@11 264 -- delete _wipes entries that are more than 10 days old
yellowfive@11 265 if AmrLogData._wipes then
yellowfive@11 266 local i = 1
yellowfive@11 267 while i <= #AmrLogData._wipes do
yellowfive@11 268 local t = AmrLogData._wipes[i]
yellowfive@11 269 if difftime(now, t) > oldDuration then
yellowfive@11 270 tremove(AmrLogData._wipes, i)
yellowfive@11 271 else
yellowfive@11 272 i = i + 1
yellowfive@11 273 end
yellowfive@11 274 end
yellowfive@11 275 end
yellowfive@11 276
yellowfive@11 277 -- delete the _lastWipe if it is more than 10 days old
yellowfive@11 278 if AmrLogData._lastWipe and difftime(now, AmrLogData._lastWipe) > oldDuration then
yellowfive@11 279 AmrLogData_lastWipe = nil
yellowfive@11 280 end
yellowfive@11 281
adam@0 282 -- clean up old-style logging data from previous versions of the addon
adam@0 283 for k, v in AskMrRobot.spairs(AmrLogData) do
yellowfive@11 284 if not _logDataKeys[k] then
adam@0 285 AmrLogData[k] = nil
adam@0 286 end
adam@0 287 end
adam@0 288
adam@0 289 -- start a new logging session
adam@0 290 AmrLogData._current2 = {}
yellowfive@11 291 AmrLogData._currentExtra = {}
adam@0 292 AmrLogData._logging = true
adam@0 293
adam@0 294 -- always enable advanced combat logging via our addon, gathers more detailed data for better analysis
adam@0 295 SetCVar("advancedCombatLogging", 1)
adam@0 296
adam@0 297 LoggingCombat(true)
adam@0 298 self:Update()
yellowfive@11 299
yellowfive@11 300 AskMrRobot.AmrUpdateMinimap()
adam@0 301
yellowfive@11 302 print(L.AMR_COMBATLOGTAB_IS_LOGGING)
adam@0 303 end
adam@0 304
adam@0 305 function AskMrRobot.CombatLogTab:StopLogging()
adam@0 306 LoggingCombat(false)
adam@0 307 AmrLogData._logging = false
adam@0 308 self:Update()
adam@0 309
yellowfive@11 310 AskMrRobot.AmrUpdateMinimap()
yellowfive@11 311
yellowfive@11 312 print(L.AMR_COMBATLOGTAB_STOPPED_LOGGING)
yellowfive@11 313 end
yellowfive@11 314
yellowfive@11 315 function AskMrRobot.CombatLogTab:ToggleLogging()
yellowfive@11 316 if self:IsLogging() then
yellowfive@11 317 self:StopLogging()
yellowfive@11 318 else
yellowfive@11 319 self:StartLogging()
yellowfive@11 320 end
adam@0 321 end
adam@0 322
adam@0 323 -- update the panel and state
adam@0 324 function AskMrRobot.CombatLogTab:Update()
adam@0 325 local isLogging = self:IsLogging()
adam@0 326
adam@0 327 if isLogging then
yellowfive@11 328 self.btnStart:SetText(L.AMR_COMBATLOGTAB_STOP_LOGGING)
yellowfive@11 329 self.loggingStatus:SetText(L.AMR_COMBATLOGTAB_CURRENTLY_LOGGING)
adam@0 330 else
yellowfive@11 331 self.btnStart:SetText(L.AMR_COMBATLOGTAB_START_LOGGING)
yellowfive@11 332 self.loggingStatus:SetText("")
adam@0 333 end
yellowfive@11 334
yellowfive@11 335 if AmrLogData._lastWipe then
yellowfive@11 336 self.lastWipeLabel:SetText(L.AMR_COMBATLOGTAB_LASTWIPE:format(date('%B %d', AmrLogData._lastWipe), date('%I:%M %p', AmrLogData._lastWipe)))
yellowfive@11 337 self.btnUnwipe:Show()
yellowfive@11 338 else
yellowfive@11 339 self.lastWipeLabel:SetText("")
yellowfive@11 340 self.btnUnwipe:Hide()
yellowfive@11 341 end
yellowfive@11 342
adam@0 343 end
adam@0 344
adam@0 345 -- called to update logging state when auto-logging is enabled
adam@0 346 function AskMrRobot.CombatLogTab:UpdateAutoLogging()
adam@0 347
adam@0 348 -- get the info about the instance
adam@0 349 --local zone, zonetype, difficultyIndex, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID = GetInstanceInfo()
adam@0 350 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo()
adam@0 351 --local difficulty = difficultyIndex
adam@0 352 -- Unless Blizzard fixes scenarios to not return nil, let's hardcode this into returning "scenario" -Znuff
adam@0 353 --if zonetype == nil and difficultyIndex == 1 then
adam@0 354 --zonetype = "scenario"
adam@0 355 --end
adam@0 356
adam@0 357 if zone == AmrLogData._lastZone and difficultyIndex == AmrLogData._lastDiff then
adam@0 358 -- do nothing if the zone hasn't actually changed, otherwise we may override the user's manual enable/disable
adam@0 359 return
adam@0 360 end
adam@0 361
adam@0 362 AmrLogData._lastZone = zone
adam@0 363 AmrLogData._lastDiff = difficultyIndex
adam@0 364
adam@0 365 if AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] == "enabled" then
adam@0 366 if tonumber(instanceMapID) == AskMrRobot.instanceIds.SiegeOfOrgrimmar then
adam@0 367 -- if in SoO, make sure logging is on
adam@0 368 if not self:IsLogging() then
adam@0 369 self:StartLogging()
adam@0 370 end
adam@0 371 else
adam@0 372 -- not in SoO, turn logging off
adam@0 373 if self:IsLogging() then
adam@0 374 self:StopLogging()
adam@0 375 end
adam@0 376 end
adam@0 377 end
adam@0 378
adam@0 379 end
adam@0 380
yellowfive@11 381 local function RaidChatType()
yellowfive@11 382 if UnitIsGroupAssistant("player") or UnitIsGroupLeader("player") then
yellowfive@11 383 return "RAID_WARNING"
yellowfive@11 384 else
yellowfive@11 385 return "RAID"
yellowfive@11 386 end
yellowfive@11 387 end
yellowfive@11 388
yellowfive@11 389 -- used to store wipes to AmrLogData so that we trim data after the wipe
yellowfive@11 390 function AskMrRobot.CombatLogTab:LogWipe()
yellowfive@11 391 local t = time()
yellowfive@11 392 tinsert(AmrLogData._wipes, t)
yellowfive@11 393 AmrLogData._lastWipe = t
yellowfive@11 394
yellowfive@11 395 if GetNumGroupMembers() > 0 then
yellowfive@11 396 SendChatMessage(L.AMR_COMBATLOGTAB_WIPE_CHAT, RaidChatType())
yellowfive@11 397 end
yellowfive@11 398 print(string.format(L.AMR_COMBATLOGTAB_WIPE_MSG, date('%I:%M %p', t)))
yellowfive@11 399
yellowfive@11 400 self:Update()
yellowfive@11 401 --AskMrRobot.wait(301, AskMrRobot.CombatLogTab.Update, self)
yellowfive@11 402 end
yellowfive@11 403
yellowfive@11 404 -- used to undo the wipe command
yellowfive@11 405 function AskMrRobot.CombatLogTab:LogUnwipe()
yellowfive@11 406 local t = AmrLogData._lastWipe
yellowfive@11 407 if not t then
yellowfive@11 408 print(L.AMR_COMBATLOGTAB_NOWIPES)
yellowfive@11 409 else
yellowfive@11 410 tremove(AmrLogData._wipes)
yellowfive@11 411 AmrLogData._lastWipe = nil
yellowfive@11 412 print(string.format(L.AMR_COMBATLOGTAB_UNWIPE_MSG, date('%I:%M %p', t)))
yellowfive@11 413 end
yellowfive@11 414 self:Update()
yellowfive@11 415 end
yellowfive@11 416
yellowfive@11 417 -- initialize the AmrLogData variable
yellowfive@11 418 function AskMrRobot.CombatLogTab.InitializeVariable()
yellowfive@11 419 if not AmrLogData then AmrLogData = {} end
yellowfive@11 420 if not AmrLogData._autoLog then AmrLogData._autoLog = {} end
yellowfive@11 421 if not AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] then
yellowfive@11 422 AmrLogData._autoLog[AskMrRobot.instanceIds.SiegeOfOrgrimmar] = "disabled"
yellowfive@11 423 end
yellowfive@11 424 AmrLogData._wipes = AmrLogData._wipes or {}
yellowfive@11 425 end
yellowfive@11 426
yellowfive@11 427 function AskMrRobot.CombatLogTab.SaveExtras(data, timestamp)
yellowfive@11 428
yellowfive@11 429 for name,val in pairs(data) do
yellowfive@11 430 -- record aura stuff, we never check for duplicates, need to know it at each point in time
yellowfive@11 431 if AmrLogData._currentExtra[name] == nil then
yellowfive@11 432 AmrLogData._currentExtra[name] = {}
yellowfive@11 433 end
yellowfive@11 434 AmrLogData._currentExtra[name][timestamp] = val
yellowfive@11 435 end
yellowfive@11 436 end
yellowfive@11 437
adam@0 438 -- read a message sent to the addon channel with a player's info at the time an encounter started
adam@0 439 function AskMrRobot.CombatLogTab:ReadAddonMessage(message)
adam@0 440
adam@0 441 -- message will be of format: timestamp\nrealm\nname\n[stuff]
adam@0 442 local parts = {}
adam@0 443 for part in string.gmatch(message, "([^\n]+)") do
adam@0 444 tinsert(parts, part)
adam@0 445 end
adam@0 446
adam@0 447 local timestamp = parts[1]
adam@0 448 local name = parts[2] .. ":" .. parts[3]
adam@0 449 local data = parts[4]
adam@0 450
adam@0 451 if (data == "done") then
adam@0 452 -- we have finished receiving this message; now process it to reduce the amount of duplicate data
adam@0 453 local setup = AmrLogData._current2[name][timestamp]
yellowfive@11 454
adam@0 455 if (AmrLogData._previousSetup == nil) then
adam@0 456 AmrLogData._previousSetup = {}
adam@0 457 end
adam@0 458
adam@0 459 local previousSetup = AmrLogData._previousSetup[name]
adam@0 460
adam@0 461 if (previousSetup == setup) then
adam@0 462 -- if the last-seen setup for this player is the same as the current one, we don't need this entry
adam@0 463 AmrLogData._current2[name][timestamp] = nil
adam@0 464 else
adam@0 465 -- record the last-seen setup
adam@0 466 AmrLogData._previousSetup[name] = setup
adam@0 467 end
yellowfive@11 468
adam@0 469 else
adam@0 470 -- concatenate messages with the same timestamp+name
adam@0 471 if (AmrLogData._current2[name] == nil) then
adam@0 472 AmrLogData._current2[name] = {}
adam@0 473 end
adam@0 474
adam@0 475 if (AmrLogData._current2[name][timestamp] == nil) then
adam@0 476 AmrLogData._current2[name][timestamp] = data
adam@0 477 else
adam@0 478 AmrLogData._current2[name][timestamp] = AmrLogData._current2[name][timestamp] .. data
adam@0 479 end
adam@0 480 end
adam@0 481 end