diff --git a/core/gears.lua b/core/gears.lua index fc093005..c92c112e 100644 --- a/core/gears.lua +++ b/core/gears.lua @@ -13,14 +13,12 @@ local CONST_SPELLBOOK_GENERAL_TABID = 1 local CONST_SPELLBOOK_CLASSSPELLS_TABID = 2 local storageDebug = false --remember to turn this to false! -local store_instances = _detalhes.InstancesToStoreData +local instancesToStoreData = _detalhes.InstancesToStoreData function _detalhes:UpdateGears() - _detalhes:UpdateParser() _detalhes:UpdateControl() _detalhes:UpdateCombat() - end function _detalhes:GetCoreVersion() @@ -32,7 +30,7 @@ end _detalhes.chat_embed = _detalhes:CreateEventListener() _detalhes.chat_embed.startup = true - + _detalhes.chat_embed.hook_settabname = function(frame, name, doNotSave) if (not doNotSave) then if (_detalhes.chat_tab_embed.enabled and _detalhes.chat_tab_embed.tab_name ~= "") then @@ -56,13 +54,13 @@ end end hooksecurefunc ("FCF_SetWindowName", _detalhes.chat_embed.hook_settabname) hooksecurefunc ("FCF_Close", _detalhes.chat_embed.hook_closetab) - + function _detalhes.chat_embed:SetTabSettings (tab_name, is_enabled, is_single) - + local current_enabled_state = _detalhes.chat_tab_embed.enabled local current_name = _detalhes.chat_tab_embed.tab_name local current_is_single = _detalhes.chat_tab_embed.single_window - + tab_name = tab_name or _detalhes.chat_tab_embed.tab_name if (is_enabled == nil) then is_enabled = _detalhes.chat_tab_embed.enabled @@ -70,11 +68,11 @@ end if (is_single == nil) then is_single = _detalhes.chat_tab_embed.single_window end - + _detalhes.chat_tab_embed.tab_name = tab_name or "" _detalhes.chat_tab_embed.enabled = is_enabled _detalhes.chat_tab_embed.single_window = is_single - + if (current_name ~= tab_name) then --rename the tab on chat frame local ChatFrame = _detalhes.chat_embed:GetTab (current_name) @@ -82,7 +80,7 @@ end FCF_SetWindowName (ChatFrame, tab_name, false) end end - + if (is_enabled) then --was disabled, so we need to save the current window positions. if (not current_enabled_state) then @@ -112,7 +110,7 @@ end end end end - + --need to make the embed _detalhes.chat_embed:DoEmbed() else @@ -122,14 +120,14 @@ end end end end - + function _detalhes.chat_embed:CheckChatEmbed (is_startup) if (_detalhes.chat_tab_embed.enabled) then _detalhes.chat_embed:DoEmbed (is_startup) end end - - --dom + + --dom -- /run _detalhes.chat_embed:SetTabSettings ("Dano", true, false) -- /run _detalhes.chat_embed:SetTabSettings (nil, false, false) -- /dump _detalhes.chat_tab_embed.tab_name @@ -151,30 +149,30 @@ end return _detalhes.chat_embed:ScheduleTimer("DelayedChatEmbed", 5) end local tabname = _detalhes.chat_tab_embed.tab_name - + if (_detalhes.chat_tab_embed.enabled and tabname ~= "") then local ChatFrame, ChatFrameTab, ChatFrameBackground = _detalhes.chat_embed:GetTab (tabname) - + if (not ChatFrame) then FCF_OpenNewWindow (tabname) ChatFrame, ChatFrameTab, ChatFrameBackground = _detalhes.chat_embed:GetTab (tabname) end - + if (ChatFrame) then for index, t in pairs(ChatFrame.messageTypeList) do ChatFrame_RemoveMessageGroup (ChatFrame, t) ChatFrame.messageTypeList [index] = nil end - + _detalhes.chat_tab_embed_onframe = ChatFrame - + if (_detalhes.chat_tab_embed.single_window) then --only one window local window1 = _detalhes:GetInstance(1) - + window1:UngroupInstance() window1.baseframe:ClearAllPoints() - + window1.baseframe:SetParent(ChatFrame) window1.rowframe:SetParent(window1.baseframe) @@ -184,16 +182,16 @@ end window1.windowSwitchButton:SetParent(window1.baseframe) window1.windowSwitchButton:ClearAllPoints() window1.windowSwitchButton:SetAllPoints() - + local y_up = window1.toolbar_side == 1 and -20 or 0 local y_down = (window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0) - + window1.baseframe:SetPoint("topleft", ChatFrameBackground, "topleft", 0, y_up + _detalhes.chat_tab_embed.y_offset) window1.baseframe:SetPoint("bottomright", ChatFrameBackground, "bottomright", _detalhes.chat_tab_embed.x_offset, y_down) window1:LockInstance (true) window1:SaveMainWindowPosition() - + local window2 = _detalhes:GetInstance(2) if (window2 and window2.baseframe) then if (window2.baseframe:GetParent() == ChatFrame) then @@ -209,12 +207,12 @@ end if (not window2) then window2 = _detalhes:CriarInstancia() end - + window1:UngroupInstance() window2:UngroupInstance() window1.baseframe:ClearAllPoints() window2.baseframe:ClearAllPoints() - + window1.baseframe:SetParent(ChatFrame) window2.baseframe:SetParent(ChatFrame) window1.rowframe:SetParent(window1.baseframe) @@ -229,40 +227,40 @@ end window1:LockInstance (true) window2:LockInstance (true) - + local statusbar_enabled1 = window1.show_statusbar local statusbar_enabled2 = window2.show_statusbar table.wipe(window1.snap); table.wipe(window2.snap) window1.snap [3] = 2; window2.snap [1] = 1; window1.horizontalSnap = true; window2.horizontalSnap = true - + local y_up = window1.toolbar_side == 1 and -20 or 0 local y_down = (window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0) - + local width = ChatFrameBackground:GetWidth() / 2 local height = ChatFrameBackground:GetHeight() - y_down + y_up - + window1.baseframe:SetSize(width + (_detalhes.chat_tab_embed.x_offset/2), height + _detalhes.chat_tab_embed.y_offset) window2.baseframe:SetSize(width + (_detalhes.chat_tab_embed.x_offset/2), height + _detalhes.chat_tab_embed.y_offset) - + window1.baseframe:SetPoint("topleft", ChatFrameBackground, "topleft", 0, y_up + _detalhes.chat_tab_embed.y_offset) window2.baseframe:SetPoint("topright", ChatFrameBackground, "topright", _detalhes.chat_tab_embed.x_offset, y_up + _detalhes.chat_tab_embed.y_offset) - + window1:SaveMainWindowPosition() window2:SaveMainWindowPosition() - + -- /dump ChatFrame3Background:GetSize() end end end end - + function _detalhes.chat_embed:ReleaseEmbed (second_window) --release local window1 = _detalhes:GetInstance(1) local window2 = _detalhes:GetInstance(2) - + if (second_window) then window2:UngroupInstance() window2.baseframe:ClearAllPoints() @@ -274,7 +272,7 @@ end window2.rowframe:SetPoint("center", UIParent, "center", 200, 0) window2:LockInstance (false) window2:SaveMainWindowPosition() - + local previous_pos = _detalhes.chat_tab_embed.w2_pos if (previous_pos) then window2:RestorePositionFromPositionTable (previous_pos) @@ -290,14 +288,14 @@ end window1.rowframe:SetPoint("center", UIParent, "center") window1:LockInstance (false) window1:SaveMainWindowPosition() - + local previous_pos = _detalhes.chat_tab_embed.w1_pos if (previous_pos) then window1:RestorePositionFromPositionTable (previous_pos) end - + if (not _detalhes.chat_tab_embed.single_window and window2) then - + window2:UngroupInstance() window2.baseframe:ClearAllPoints() window2.baseframe:SetParent(UIParent) @@ -307,14 +305,14 @@ end window2.rowframe:SetPoint("center", UIParent, "center", 200, 0) window2:LockInstance (false) window2:SaveMainWindowPosition() - + local previous_pos = _detalhes.chat_tab_embed.w2_pos if (previous_pos) then window2:RestorePositionFromPositionTable (previous_pos) end end end - + function _detalhes.chat_embed:GetTab (tabname) tabname = tabname or _detalhes.chat_tab_embed.tab_name for i = 1, 20 do @@ -326,7 +324,7 @@ end end end end - + --[[ --create a tab on chat --FCF_OpenNewWindow(name) @@ -350,7 +348,7 @@ function _detalhes:SetDeathLogLimit (limit) if (limit and type(limit) == "number" and limit >= 8) then _detalhes.deadlog_events = limit - + local combat = _detalhes.tabela_vigente local wipe = table.wipe @@ -366,7 +364,7 @@ function _detalhes:SetDeathLogLimit (limit) end end end - + _detalhes:UpdateParserGears() end end @@ -376,7 +374,7 @@ end function _detalhes:TrackSpecsNow (track_everything) local spelllist = _detalhes.SpecSpellList - + if (not track_everything) then for _, actor in _detalhes.tabela_vigente[1]:ListActors() do if (actor:IsPlayer()) then @@ -408,7 +406,7 @@ function _detalhes:TrackSpecsNow (track_everything) end tinsert(combatlist, _detalhes.tabela_vigente) tinsert(combatlist, _detalhes.tabela_overall) - + for _, combat in ipairs(combatlist) do for _, actor in combat[1]:ListActors() do if (actor:IsPlayer()) then @@ -435,16 +433,16 @@ function _detalhes:TrackSpecsNow (track_everything) end end end - + end function _detalhes:ResetSpecCache (forced) local isininstance = IsInInstance() - + if (forced or (not isininstance and not _detalhes.in_group)) then table.wipe(_detalhes.cached_specs) - + if (_detalhes.track_specs) then local my_spec = DetailsFramework.GetSpecialization() if (type(my_spec) == "number") then @@ -457,10 +455,10 @@ function _detalhes:ResetSpecCache (forced) end end end - + elseif (_detalhes.in_group and not isininstance) then table.wipe(_detalhes.cached_specs) - + if (_detalhes.track_specs) then if (IsInRaid()) then local c_combat_dmg = _detalhes.tabela_vigente [1] @@ -486,17 +484,17 @@ function _detalhes:ResetSpecCache (forced) end end end - + end function _detalhes:RefreshUpdater(suggested_interval) local updateInterval = suggested_interval or _detalhes.update_speed - + if (_detalhes.streamer_config.faster_updates) then --force 60 updates per second updateInterval = 0.016 end - + if (_detalhes.atualizador) then --_detalhes:CancelTimer(_detalhes.atualizador) Details.Schedules.Cancel(_detalhes.atualizador) @@ -513,11 +511,11 @@ function _detalhes:SetWindowUpdateSpeed(interval, nosave) if (type(interval) ~= "number") then interval = _detalhes.update_speed or 0.3 end - + if (not nosave) then _detalhes.update_speed = interval end - + _detalhes:RefreshUpdater(interval) end @@ -525,11 +523,11 @@ function _detalhes:SetUseAnimations(enabled, nosave) if (enabled == nil) then enabled = _detalhes.use_row_animations end - + if (not nosave) then _detalhes.use_row_animations = enabled end - + _detalhes.is_using_row_animations = enabled end @@ -549,11 +547,11 @@ _detalhes.PerformanceIcons = { } function _detalhes:CheckForPerformanceProfile() - + local performanceType = _detalhes:GetPerformanceRaidType() - + local profile = _detalhes.performance_profiles [performanceType] - + if (profile and profile.enabled) then _detalhes:SetWindowUpdateSpeed(profile.update_speed, true) _detalhes:SetUseAnimations(profile.use_row_animations, true) @@ -562,11 +560,11 @@ function _detalhes:CheckForPerformanceProfile() _detalhes:CaptureSet(profile.energy, "energy") _detalhes:CaptureSet(profile.miscdata, "miscdata") _detalhes:CaptureSet(profile.aura, "aura") - + if (not _detalhes.performance_profile_lastenabled or _detalhes.performance_profile_lastenabled ~= performanceType) then _detalhes:InstanceAlert (Loc ["STRING_OPTIONS_PERFORMANCE_PROFILE_LOAD"] .. performanceType, {_detalhes.PerformanceIcons [performanceType].icon, 14, 14, false, 0, 1, 0, 1, unpack(_detalhes.PerformanceIcons [performanceType].color)} , 5, {_detalhes.empty_function}) end - + _detalhes.performance_profile_enabled = performanceType _detalhes.performance_profile_lastenabled = performanceType else @@ -579,7 +577,7 @@ function _detalhes:CheckForPerformanceProfile() _detalhes:CaptureSet(_detalhes.capture_real ["aura"], "aura") _detalhes.performance_profile_enabled = nil end - + end function _detalhes:GetPerformanceRaidType() @@ -589,7 +587,7 @@ function _detalhes:GetPerformanceRaidType() if (type == "none") then return nil end - + if (type == "pvp") then if (maxPlayers == 40) then return "Battleground40" @@ -599,7 +597,7 @@ function _detalhes:GetPerformanceRaidType() return nil end end - + if (type == "arena") then return "Arena" end @@ -609,12 +607,12 @@ function _detalhes:GetPerformanceRaidType() if (difficulty == 15) then return "Mythic" end - + --raid finder if (difficulty == 7) then return "RaidFinder" end - + --flex if (difficulty == 14) then if (GetNumGroupMembers() > 15) then @@ -623,7 +621,7 @@ function _detalhes:GetPerformanceRaidType() return "Raid15" end end - + --normal heroic if (maxPlayers == 10) then return "Raid15" @@ -631,11 +629,11 @@ function _detalhes:GetPerformanceRaidType() return "Raid30" end end - + if (type == "party") then return "Dungeon" end - + return nil end @@ -660,7 +658,7 @@ function _detalhes:RegisterBackgroundTask (name, func, priority, ...) else assert(type(func) == "function", "RegisterBackgroundTask param #2 expect a function or function name.") end - + priority = priority or "LOW" priority = string.upper (priority) if (not task_timers [priority]) then @@ -687,10 +685,10 @@ function _detalhes:DoBackgroundTasks() if (_detalhes:GetZoneType() ~= "none" or _detalhes:InGroup()) then return end - + local t = time() - - for taskName, taskTable in pairs(background_tasks) do + + for taskName, taskTable in pairs(background_tasks) do if (t > taskTable.nextexec) then if (type(taskTable.func) == "string") then taskTable.object [taskTable.func] (taskTable.object, unpack(taskTable.args, 1, taskTable.args_amt)) @@ -720,10 +718,10 @@ function _detalhes.storage:OpenRaidStorage() return end end - + --get the storage table local db = DetailsDataStorage - + if (not db and _detalhes.CreateStorageDB) then db = _detalhes:CreateStorageDB() if (not db) then @@ -738,15 +736,15 @@ end function _detalhes.storage:HaveDataForEncounter (diff, encounter_id, guild_name) local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - + if (guild_name and type(guild_name) == "boolean") then guild_name = GetGuildInfo ("player") end - + local table = db [diff] if (table) then local encounters = table [encounter_id] @@ -755,7 +753,7 @@ function _detalhes.storage:HaveDataForEncounter (diff, encounter_id, guild_name) if (not guild_name) then return true end - + --data for a specific guild is requested, check if there is data for the guild for index, encounter in ipairs(encounters) do if (encounter.guild == guild_name) then @@ -768,28 +766,28 @@ end function _detalhes.storage:GetBestFromGuild (diff, encounter_id, role, dps, guild_name) local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - + if (not guild_name) then guild_name = GetGuildInfo ("player") end - + if (not guild_name) then if (_detalhes.debug) then _detalhes:Msg("(debug) GetBestFromGuild() guild name invalid.") end return end - + local best = 0 local bestdps = 0 local bestplayername local onencounter local bestactor - + if (not role) then role = "damage" end @@ -799,7 +797,7 @@ function _detalhes.storage:GetBestFromGuild (diff, encounter_id, role, dps, guil elseif (role == "healer") then role = "healing" end - + local table = db [diff] if (table) then local encounters = table [encounter_id] @@ -831,29 +829,29 @@ function _detalhes.storage:GetBestFromGuild (diff, encounter_id, role, dps, guil end end end - + return t, onencounter end function _detalhes.storage:GetPlayerGuildRank (diff, encounter_id, role, playername, dps, guild_name) local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - + if (not guild_name) then guild_name = GetGuildInfo ("player") end - + if (not guild_name) then if (_detalhes.debug) then _detalhes:Msg("(debug) GetBestFromGuild() guild name invalid.") end return end - + if (not role) then role = "damage" end @@ -863,9 +861,9 @@ function _detalhes.storage:GetPlayerGuildRank (diff, encounter_id, role, playern elseif (role == "healer") then role = "healing" end - + local playerScore = {} - + local _table = db [diff] if (_table) then local encounters = _table [encounter_id] @@ -874,14 +872,14 @@ function _detalhes.storage:GetPlayerGuildRank (diff, encounter_id, role, playern if (encounter.guild == guild_name) then local roleTable = encounter [role] for playerName, playerTable in pairs(roleTable) do - + if (not playerScore [playerName]) then playerScore [playerName] = {0, 0, {}} end - + local total = playerTable[1] local persecond = total / encounter.elapsed - + if (dps) then if (persecond > playerScore [playerName][2]) then playerScore [playerName][1] = total @@ -900,19 +898,19 @@ function _detalhes.storage:GetPlayerGuildRank (diff, encounter_id, role, playern end end end - + if (not playerScore [playername]) then return end - + local t = {} for playerName, playerTable in pairs(playerScore) do playerTable [5] = playerName tinsert(t, playerTable) end - + table.sort (t, dps and _detalhes.Sort2 or _detalhes.Sort1) - + for i = 1, #t do if (t[i][5] == playername) then return t[i][3], t[i][4], i @@ -925,16 +923,16 @@ end function _detalhes.storage:GetBestFromPlayer (diff, encounter_id, role, playername, dps) local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then print("DB noot found on GetBestFromPlayer()") return end - + local best local onencounter local topdps - + if (not role) then role = "damage" end @@ -944,7 +942,7 @@ function _detalhes.storage:GetBestFromPlayer (diff, encounter_id, role, playerna elseif (role == "healer") then role = "healing" end - + local table = db [diff] if (table) then local encounters = table [encounter_id] @@ -974,14 +972,14 @@ function _detalhes.storage:GetBestFromPlayer (diff, encounter_id, role, playerna end end end - + return best, onencounter end function _detalhes.storage:DBGuildSync() _detalhes:SendGuildData ("GS", "R") - + end local OnlyFromCurrentRaidTier = true @@ -1000,13 +998,13 @@ local encounter_is_current_tier = function(encounterID) return true end -local have_encounter = function(db, ID) - local minTime = ID - 120 - local maxTime = ID + 120 - - for diff, diffTable in pairs(db or {}) do - if (type(diffTable) == "table") then - for encounterID, encounterTable in pairs(diffTable) do +local hasEncounterByEncounterSyncId = function(db, encounterSyncId) + local minTime = encounterSyncId - 120 + local maxTime = encounterSyncId + 120 + + for difficultyId, encounterIdTable in pairs(db or {}) do + if (type(encounterIdTable) == "table") then + for dungeonEncounterID, encounterTable in pairs(encounterIdTable) do for index, encounter in ipairs(encounterTable) do --check if the encounter fits in the timespam window if (encounter.time >= minTime and encounter.time <= maxTime) then @@ -1024,37 +1022,50 @@ local have_encounter = function(db, ID) return false end -local have_recent_requested_encounter = function(ID) - local minTime = ID - 120 - local maxTime = ID + 120 - - for requestedID, _ in pairs(_detalhes.RecentRequestedIDs) do +local hasRecentRequestedEncounterSyncId = function(encounterSyncId) + local minTime = encounterSyncId - 120 + local maxTime = encounterSyncId + 120 + + for requestedID in pairs(_detalhes.RecentRequestedIDs) do if (requestedID >= minTime and requestedID <= maxTime) then return true end end end +local getBossIdsForCurrentExpansion = function() + --make a list of raids and bosses that belong to the current expansion + local bossIndexedTable, bossInfoTable, raidInfoTable = Details:GetExpansionBossList() + local allowedBosses = {} + for bossId, bossTable in pairs(bossInfoTable) do + allowedBosses[bossTable.dungeonEncounterID] = true + end + return allowedBosses +end + --remote call RoS function _detalhes.storage:GetIDsToGuildSync() local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - - local IDs = {} - local myGuildName = GetGuildInfo("player") - --build the encounter ID list - for diff, diffTable in pairs(db or {}) do - if (type(diffTable) == "table") then - for encounterID, encounterTable in pairs(diffTable) do - if (encounter_is_current_tier (encounterID)) then + local encounterSyncIds = {} + local myGuildName = GetGuildInfo("player") + --myGuildName = "Patifaria" + + local allowedBosses = getBossIdsForCurrentExpansion() + + --build the encounter synchronized ID list + for difficultyId, encounterIdTable in pairs(db or {}) do + if (type(encounterIdTable) == "table") then + for dungeonEncounterID, encounterTable in pairs(encounterIdTable) do + if (allowedBosses[dungeonEncounterID]) then for index, encounter in ipairs(encounterTable) do if (encounter.servertime) then if (myGuildName == encounter.guild) then - tinsert(IDs, encounter.servertime) + tinsert(encounterSyncIds, encounter.servertime) end end end @@ -1062,149 +1073,145 @@ function _detalhes.storage:GetIDsToGuildSync() end end end - + if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] sending " .. #IDs .. " IDs.") + _detalhes:Msg("(debug) [RoS-EncounterSync] sending " .. #encounterSyncIds .. " IDs.") end - - return IDs + + return encounterSyncIds end - ---local call RoC - received the encounter IDS - need to know which fights is missing -function _detalhes.storage:CheckMissingIDsToGuildSync (IDsList) +--local call RoC - received the encounterSyncIds - need to know which fights is missing +function _detalhes.storage:CheckMissingIDsToGuildSync(encounterSyncIds) local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - - if (type(IDsList) ~= "table") then + + if (type(encounterSyncIds) ~= "table") then if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] RoC IDsList isn't a table.") + _detalhes:Msg("(debug) [RoS-EncounterSync] RoC encounterSyncIds isn't a table.") end return end - - --this will prevent to request the same fight from multiple people + + --prevent to request the same fight from multiple people _detalhes.RecentRequestedIDs = _detalhes.RecentRequestedIDs or {} - + --store the IDs which need to be sync - local RequestIDs = {} - + local requestEncounterSyncIds = {} + --check missing IDs - for index, ID in ipairs(IDsList) do - if (not have_encounter (db, ID)) then - if (not have_recent_requested_encounter (ID)) then - tinsert(RequestIDs, ID) - _detalhes.RecentRequestedIDs [ID] = true + for index, encounterSyncId in ipairs(encounterSyncIds) do + if (not hasEncounterByEncounterSyncId(db, encounterSyncId)) then + if (not hasRecentRequestedEncounterSyncId(encounterSyncId)) then + tinsert(requestEncounterSyncIds, encounterSyncId) + _detalhes.RecentRequestedIDs[encounterSyncId] = true end end end - + if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoC-EncounterSync] RoS found " .. #RequestIDs .. " encounters out dated.") + _detalhes:Msg("(debug) [RoC-EncounterSync] RoS found " .. #requestEncounterSyncIds .. " encounters out dated.") end - - return RequestIDs + + return requestEncounterSyncIds end ---remote call RoS - build the encounter list from the IDsList -function _detalhes.storage:BuildEncounterDataToGuildSync (IDsList) +--remote call RoS - build the encounter list from the encounterSyncIds +function _detalhes.storage:BuildEncounterDataToGuildSync(encounterSyncIds) local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - - if (type(IDsList) ~= "table") then + + if (type(encounterSyncIds) ~= "table") then if (_detalhes.debug) then _detalhes:Msg("(debug) [RoS-EncounterSync] IDsList isn't a table.") end return end - - local EncounterList = {} - local CurrentTable = {} - tinsert(EncounterList, CurrentTable) - - local AmtToSend = 0 - local MaxAmount = 0 - + + local amtToSend = 0 + local maxAmount = 0 + + local encounterList = {} + local currentTable = {} + tinsert(encounterList, currentTable) + if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] the client requested " .. #IDsList .. " encounters.") + _detalhes:Msg("(debug) [RoS-EncounterSync] the client requested " .. #encounterSyncIds .. " encounters.") end - - for index, ID in ipairs(IDsList) do - - for diff, diffTable in pairs(db or {}) do - if (type(diffTable) == "table") then - for encounterID, encounterTable in pairs(diffTable) do + + for index, encounterSyncId in ipairs(encounterSyncIds) do + for difficultyId, encounterIdTable in pairs(db or {}) do + if (type(encounterIdTable) == "table") then + for dungeonEncounterID, encounterTable in pairs(encounterIdTable) do for index, encounter in ipairs(encounterTable) do - - if (ID == encounter.time or ID == encounter.servertime) then --the time here is always exactly + if (encounterSyncId == encounter.time or encounterSyncId == encounter.servertime) then --the time here is always exactly --send this encounter - CurrentTable [diff] = CurrentTable [diff] or {} - CurrentTable [diff] [encounterID] = CurrentTable [diff] [encounterID] or {} - - tinsert(CurrentTable [diff] [encounterID], encounter) - - AmtToSend = AmtToSend + 1 - MaxAmount = MaxAmount + 1 - - if (MaxAmount == 3) then - CurrentTable = {} - tinsert(EncounterList, CurrentTable) - MaxAmount = 0 + currentTable[difficultyId] = currentTable[difficultyId] or {} + currentTable[difficultyId][dungeonEncounterID] = currentTable[difficultyId][dungeonEncounterID] or {} + + tinsert(currentTable[difficultyId][dungeonEncounterID], encounter) + + amtToSend = amtToSend + 1 + maxAmount = maxAmount + 1 + + if (maxAmount == 3) then + currentTable = {} + tinsert(encounterList, currentTable) + maxAmount = 0 end end end end end end - end - + if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] sending " .. AmtToSend .. " encounters.") + _detalhes:Msg("(debug) [RoS-EncounterSync] sending " .. amtToSend .. " encounters.") end - - return EncounterList + + return encounterList end --local call RoC - add the fights to the client db -function _detalhes.storage:AddGuildSyncData (data, source) +function _detalhes.storage:AddGuildSyncData(data, source) local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - - local AddedAmount = 0 + + local addedAmount = 0 _detalhes.LastGuildSyncReceived = GetTime() - - for diff, diffTable in pairs(data) do - if (type(diff) == "number" and type(diffTable) == "table") then - for encounterID, encounterTable in pairs(diffTable) do - if (type(encounterID) == "number" and type(encounterTable) == "table") then + local allowedBosses = getBossIdsForCurrentExpansion() + + for difficultyId, encounterIdTable in pairs(data) do + if (type(difficultyId) == "number" and type(encounterIdTable) == "table") then + for dungeonEncounterID, encounterTable in pairs(encounterIdTable) do + if (type(dungeonEncounterID) == "number" and type(encounterTable) == "table") then for index, encounter in ipairs(encounterTable) do --validate the encounter if (type(encounter.servertime) == "number" and type(encounter.time) == "number" and type(encounter.guild) == "string" and type(encounter.date) == "string" and type(encounter.healing) == "table" and type(encounter.elapsed) == "number" and type(encounter.damage) == "table") then --check if the encounter is from the current raiding tier - if (encounter_is_current_tier (encounterID)) then + if (allowedBosses[dungeonEncounterID]) then --check if this encounter already has been added from another sync - if (not have_encounter (db, encounter.servertime)) then - db [diff] = db [diff] or {} - db [diff] [encounterID] = db [diff] [encounterID] or {} - - tinsert(db [diff] [encounterID], encounter) - + if (not hasEncounterByEncounterSyncId(db, encounter.servertime)) then + db[difficultyId] = db[difficultyId] or {} + db[difficultyId][dungeonEncounterID] = db[difficultyId][dungeonEncounterID] or {} + tinsert(db[difficultyId][dungeonEncounterID], encounter) + if (_G.DetailsRaidHistoryWindow and _G.DetailsRaidHistoryWindow:IsShown()) then _G.DetailsRaidHistoryWindow:Refresh() end - - AddedAmount = AddedAmount + 1 + + addedAmount = addedAmount + 1 else if (_detalhes.debug) then _detalhes:Msg("(debug) [RoS-EncounterSync] received a duplicated encounter table.") @@ -1213,7 +1220,7 @@ function _detalhes.storage:AddGuildSyncData (data, source) else if (_detalhes.debug) then _detalhes:Msg("(debug) [RoS-EncounterSync] received an old tier encounter.") - end + end end else if (_detalhes.debug) then @@ -1225,11 +1232,11 @@ function _detalhes.storage:AddGuildSyncData (data, source) end end end - + if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] added " .. AddedAmount .. " to database.") + _detalhes:Msg("(debug) [RoS-EncounterSync] added " .. addedAmount .. " to database.") end - + if (_G.DetailsRaidHistoryWindow and _G.DetailsRaidHistoryWindow:IsShown()) then _G.DetailsRaidHistoryWindow:UpdateDropdowns() _G.DetailsRaidHistoryWindow:Refresh() @@ -1238,159 +1245,162 @@ end function _detalhes.storage:ListDiffs() local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - - local t = {} - for diff, _ in pairs(db) do - tinsert(t, diff) + + local resultTable = {} + for difficultyId in pairs(db) do + tinsert(resultTable, difficultyId) end - return t + return resultTable end -function _detalhes.storage:ListEncounters (diff) +function _detalhes.storage:ListEncounters(difficultyId) local db = _detalhes.storage:OpenRaidStorage() - + if (not db) then return end - - local t = {} - if (diff) then - local table = db [diff] - if (table) then - for encounter_id, _ in pairs(table) do - tinsert(t, {diff, encounter_id}) + + local resultTable = {} + if (difficultyId) then + local encounterIdTable = db[difficultyId] + if (encounterIdTable) then + for dungeonEncounterID in pairs(encounterIdTable) do + tinsert(resultTable, {difficultyId, dungeonEncounterID}) end end else - for diff, table in pairs(db) do - for encounter_id, _ in pairs(table) do - tinsert(t, {diff, encounter_id}) + for difficultyId, encounterIdTable in pairs(db) do + for dungeonEncounterID in pairs(encounterIdTable) do + tinsert(resultTable, {difficultyId, dungeonEncounterID}) end end end - - return t + + return resultTable end -function _detalhes.storage:GetPlayerData (diff, encounter_id, playername) +function _detalhes.storage:GetPlayerData(difficultyId, dungeonEncounterID, playerName) local db = _detalhes.storage:OpenRaidStorage() if (not db) then return end - - local t = {} - assert(type(playername) == "string", "PlayerName must be a string.") - - if (not diff) then - for diff, table in pairs(db) do - if (encounter_id) then - local encounters = table [encounter_id] + local resultTable = {} + assert(type(playerName) == "string", "playerName must be a string.") + + if (not difficultyId) then + for difficultyId, encounterIdTable in pairs(db) do + if (dungeonEncounterID) then + local encounters = encounterIdTable[dungeonEncounterID] if (encounters) then for i = 1, #encounters do - local encounter = encounters [i] - local player = encounter.healing [playername] or encounter.damage [playername] - if (player) then - tinsert(t, player) + local encounter = encounters[i] + local playerData = encounter.healing[playerName] or encounter.damage[playerName] + if (playerData) then + tinsert(resultTable, playerData) end end end else - for encounter_id, encounters in pairs(table) do + for dungeonEncounterID, encounters in pairs(encounterIdTable) do for i = 1, #encounters do - local encounter = encounters [i] - local player = encounter.healing [playername] or encounter.damage [playername] - if (player) then - tinsert(t, player) + local encounter = encounters[i] + local playerData = encounter.healing[playerName] or encounter.damage[playerName] + if (playerData) then + tinsert(resultTable, playerData) end end end end end else - local table = db [diff] - if (table) then - if (encounter_id) then - local encounters = table [encounter_id] + local encounterIdTable = db[difficultyId] + if (encounterIdTable) then + if (dungeonEncounterID) then + local encounters = encounterIdTable[dungeonEncounterID] if (encounters) then for i = 1, #encounters do - local encounter = encounters [i] - local player = encounter.healing [playername] or encounter.damage [playername] - if (player) then - tinsert(t, player) + local encounter = encounters[i] + local playerData = encounter.healing[playerName] or encounter.damage[playerName] + if (playerData) then + tinsert(resultTable, playerData) end end end else - for encounter_id, encounters in pairs(table) do + for dungeonEncounterID, encounters in pairs(encounterIdTable) do for i = 1, #encounters do - local encounter = encounters [i] - local player = encounter.healing [playername] or encounter.damage [playername] - if (player) then - tinsert(t, player) + local encounter = encounters[i] + local playerData = encounter.healing[playerName] or encounter.damage[playerName] + if (playerData) then + tinsert(resultTable, playerData) end end end end end end - - return t + + return resultTable end -function _detalhes.storage:GetEncounterData (diff, encounter_id, guild) +function _detalhes.storage:GetEncounterData(difficultyId, dungeonEncounterID, guildName) local db = _detalhes.storage:OpenRaidStorage() - if (not diff) then + if (not db) then + return + end + + if (not difficultyId) then return db end - local data = db [diff] - - assert(data, "Difficulty not found. Use: 14, 15 or 16.") - assert(type(encounter_id) == "number", "EncounterId must be a number.") - - data = data [encounter_id] - - local t = {} + local encounterIdTable = db[difficultyId] - if (not data) then - return t + assert(encounterIdTable, "Difficulty not found. Use: 14, 15 or 16.") + assert(type(dungeonEncounterID) == "number", "EncounterId must be a number.") + + local encounters = encounterIdTable[dungeonEncounterID] + local resultTable = {} + + if (not encounters) then + return resultTable end - - for i = 1, #data do - local encounter = data [i] - - if (guild) then - if (encounter.guild == guild) then - tinsert(t, encounter) + + for i = 1, #encounters do + local encounter = encounters[i] + + if (guildName) then + if (encounter.guild == guildName) then + tinsert(resultTable, encounter) end else - tinsert(t, encounter) + tinsert(resultTable, encounter) end end - - return t + + return resultTable end -local create_storage_tables = function() +local createStorageTables = function() --get the storage table local db = DetailsDataStorage - - if (not db and _detalhes.CreateStorageDB) then - db = _detalhes:CreateStorageDB() + + if (not db and Details.CreateStorageDB) then + db = Details:CreateStorageDB() if (not db) then return end + elseif (not db) then return end - + return db end @@ -1402,20 +1412,20 @@ function _detalhes.ScheduleLoadStorage() _detalhes.schedule_storage_load = true return else - if (not IsAddOnLoaded ("Details_DataStorage")) then - local loaded, reason = LoadAddOn ("Details_DataStorage") + if (not IsAddOnLoaded("Details_DataStorage")) then + local loaded, reason = LoadAddOn("Details_DataStorage") if (not loaded) then if (_detalhes.debug) then print("|cFFFFFF00Details! Storage|r: can't load storage, may be the addon is disabled.") end return end - - create_storage_tables() + + createStorageTables() end end - - if (IsAddOnLoaded ("Details_DataStorage")) then + + if (IsAddOnLoaded("Details_DataStorage")) then _detalhes.schedule_storage_load = nil _detalhes.StorageLoaded = true if (_detalhes.debug) then @@ -1437,7 +1447,7 @@ function _detalhes.OpenStorage() --if the player is in combat, this function return false, if failed to load by other reason it returns nil --check if the storage is already loaded - if (not IsAddOnLoaded ("Details_DataStorage")) then + if (not IsAddOnLoaded("Details_DataStorage")) then --can't open it during combat if (InCombatLockdown() or UnitAffectingCombat("player")) then if (_detalhes.debug) then @@ -1445,21 +1455,21 @@ function _detalhes.OpenStorage() end return false end - - local loaded, reason = LoadAddOn ("Details_DataStorage") + + local loaded, reason = LoadAddOn("Details_DataStorage") if (not loaded) then if (_detalhes.debug) then print("|cFFFFFF00Details! Storage|r: can't load storage, may be the addon is disabled.") end return end - - local db = create_storage_tables() - - if (db and IsAddOnLoaded ("Details_DataStorage")) then + + local db = createStorageTables() + + if (db and IsAddOnLoaded("Details_DataStorage")) then _detalhes.StorageLoaded = true end - + return DetailsDataStorage else return DetailsDataStorage @@ -1482,7 +1492,7 @@ function Details.Database.LoadDB() --get the storage table local db = _G.DetailsDataStorage - + if (not db and _detalhes.CreateStorageDB) then db = _detalhes:CreateStorageDB() if (not db) then @@ -1503,17 +1513,15 @@ end function Details.Database.GetBossKillsDB(db) --total kills in a boss on raid or dungeon - local totalkills_database = db["totalkills"] - if (not totalkills_database) then + local totalKillsDataBase = db["totalkills"] + if (not totalKillsDataBase) then db["totalkills"] = {} - totalkills_database = db["totalkills"] + totalKillsDataBase = db["totalkills"] end - - return totalkills_database + return totalKillsDataBase end function Details.Database.StoreWipe(combat) - combat = combat or _detalhes.tabela_vigente if (not combat) then @@ -1524,20 +1532,19 @@ function Details.Database.StoreWipe(combat) end local name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo() - local bossCLEUID = combat.boss_info and combat.boss_info.id - - if (not store_instances [mapID]) then + + if (not instancesToStoreData[mapID]) then if (_detalhes.debug) then print("|cFFFFFF00Details! Storage|r: instance not allowed.") end return end - local boss_info = combat:GetBossInfo() - local encounter_id = boss_info and boss_info.id - - if (not encounter_id) then + local bossInfo = combat:GetBossInfo() + local dungeonEncounterID = bossInfo and bossInfo.id + + if (not dungeonEncounterID) then if (_detalhes.debug) then print("|cFFFFFF00Details! Storage|r: encounter ID not found.") end @@ -1545,69 +1552,67 @@ function Details.Database.StoreWipe(combat) end --get the difficulty - local diff = combat:GetDifficulty() - + local difficultyId = combat:GetDifficulty() + --database - local db = Details.Database.LoadDB() - if (not db) then - return - end - - local diff_storage = db [diff] - if (not diff_storage) then - db [diff] = {} - diff_storage = db [diff] - end - - local encounter_database = diff_storage [encounter_id] - if (not encounter_database) then - diff_storage [encounter_id] = {} - encounter_database = diff_storage [encounter_id] - end - - --total kills in a boss on raid or dungeon - local totalkills_database = Details.Database.GetBossKillsDB(db) - - if (IsInRaid()) then - totalkills_database[encounter_id] = totalkills_database[encounter_id] or {} - totalkills_database[encounter_id][diff] = totalkills_database[encounter_id][diff] or {kills = 0, wipes = 0, time_fasterkill = 0, time_fasterkill_when = 0, time_incombat = 0, dps_best = 0, dps_best_when = 0, dps_best_raid = 0, dps_best_raid_when = 0} - - local bossData = totalkills_database[encounter_id][diff] - - --wipes amount - bossData.wipes = bossData.wipes + 1 - - Details:Msg("Wipe stored, you have now " .. bossData.wipes .. " wipes on this boss.") + local db = Details.Database.LoadDB() + if (not db) then + return + end + + local encounterIdTable = db[difficultyId] + if (not encounterIdTable) then + db [difficultyId] = {} + encounterIdTable = db[difficultyId] + end + + local encounters = encounterIdTable[dungeonEncounterID] + if (not encounters) then + encounterIdTable[dungeonEncounterID] = {} + encounters = encounterIdTable[dungeonEncounterID] + end + + --total kills in a boss on raid or dungeon + local totalKillsDataBase = Details.Database.GetBossKillsDB(db) + + if (IsInRaid()) then + totalKillsDataBase[dungeonEncounterID] = totalKillsDataBase[dungeonEncounterID] or {} + totalKillsDataBase[dungeonEncounterID][difficultyId] = totalKillsDataBase[dungeonEncounterID][difficultyId] or {kills = 0, wipes = 0, time_fasterkill = 0, time_fasterkill_when = 0, time_incombat = 0, dps_best = 0, dps_best_when = 0, dps_best_raid = 0, dps_best_raid_when = 0} + + local bossData = totalKillsDataBase[dungeonEncounterID][difficultyId] + bossData.wipes = bossData.wipes + 1 + + --wipes amount + if (bossData.wipes % 10 == 0) then + --nah player does not want to know that + --Details:Msg("Wipe stored, you have now " .. bossData.wipes .. " wipes on this boss.") end + end end function Details.Database.StoreEncounter(combat) - - --note: this only runs on boss kill - combat = combat or _detalhes.tabela_vigente - + if (not combat) then if (_detalhes.debug) then print("|cFFFFFF00Details! Storage|r: combat not found.") end return end - + local name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo() - local bossCLEUID = combat.boss_info and combat.boss_info.id - - if (not store_instances [mapID]) then + + if (not instancesToStoreData[mapID]) then if (_detalhes.debug) then print("|cFFFFFF00Details! Storage|r: instance not allowed.") end return end - + local boss_info = combat:GetBossInfo() local encounter_id = boss_info and boss_info.id - + if (not encounter_id) then if (_detalhes.debug) then print("|cFFFFFF00Details! Storage|r: encounter ID not found.") @@ -1617,19 +1622,19 @@ function Details.Database.StoreEncounter(combat) --get the difficulty local diff = combat:GetDifficulty() - + --database local db = Details.Database.LoadDB() if (not db) then return end - + local diff_storage = db [diff] if (not diff_storage) then db [diff] = {} diff_storage = db [diff] end - + local encounter_database = diff_storage [encounter_id] if (not encounter_database) then diff_storage [encounter_id] = {} @@ -1682,13 +1687,13 @@ function Details.Database.StoreEncounter(combat) --check for heroic and mythic - if (storageDebug or (diff == 15 or diff == 16 or diff == 14)) then --test on raid finder: ' or diff == 17' -- normal mode: diff == 14 or - + if (storageDebug or (diff == 15 or diff == 16 or diff == 14)) then --test on raid finder: ' or diff == 17' -- normal mode: diff == 14 or + --check the guild name local match = 0 local guildName = GetGuildInfo ("player") local raidSize = GetNumGroupMembers() or 0 - + if (not storageDebug) then if (guildName) then for i = 1, raidSize do @@ -1697,7 +1702,7 @@ function Details.Database.StoreEncounter(combat) match = match + 1 end end - + if (match < raidSize * 0.75 and not storageDebug) then if (_detalhes.debug) then print("|cFFFFFF00Details! Storage|r: can't save the encounter, need at least 75% of players be from your guild.") @@ -1713,7 +1718,7 @@ function Details.Database.StoreEncounter(combat) else guildName = "Test Guild" end - + local this_combat_data = { damage = {}, healing = {}, @@ -1723,26 +1728,26 @@ function Details.Database.StoreEncounter(combat) elapsed = combat:GetCombatTime(), guild = guildName, } - + local damage_container_hash = combat [1]._NameIndexTable local damage_container_pool = combat [1]._ActorTable - + local healing_container_hash = combat [2]._NameIndexTable local healing_container_pool = combat [2]._ActorTable for i = 1, GetNumGroupMembers() do - + local role = UnitGroupRolesAssigned("raid" .. i) - + if (UnitIsInMyGuild ("raid" .. i)) then if (role == "DAMAGER" or role == "TANK") then local player_name, player_realm = UnitName ("raid" .. i) if (player_realm and player_realm ~= "") then player_name = player_name .. "-" .. player_realm end - + local _, _, class = UnitClass(player_name) - + local damage_actor = damage_container_pool [damage_container_hash [player_name]] if (damage_actor) then local guid = UnitGUID(player_name) or UnitGUID(UnitName ("raid" .. i)) @@ -1753,9 +1758,9 @@ function Details.Database.StoreEncounter(combat) if (player_realm and player_realm ~= "") then player_name = player_name .. "-" .. player_realm end - + local _, _, class = UnitClass(player_name) - + local heal_actor = healing_container_pool [healing_container_hash [player_name]] if (heal_actor) then local guid = UnitGUID(player_name) or UnitGUID(UnitName ("raid" .. i)) @@ -1764,7 +1769,7 @@ function Details.Database.StoreEncounter(combat) end end end - + --add the encounter data tinsert(encounter_database, this_combat_data) if (_detalhes.debug) then @@ -1784,7 +1789,7 @@ function Details.Database.StoreEncounter(combat) elseif (myrole == "HEALER") then d_one = combat (2, _detalhes.playername) and combat (2, _detalhes.playername).total / combat:GetCombatTime() end - + if (myBestDps > d_one) then if (not _detalhes.deny_score_messages) then print(Loc ["STRING_DETAILS1"] .. format(Loc ["STRING_SCORE_NOTBEST"], _detalhes:ToK2 (d_one), _detalhes:ToK2 (myBestDps), onencounter.date, mybest[2])) @@ -1795,7 +1800,7 @@ function Details.Database.StoreEncounter(combat) end end end - + local lower_instance = _detalhes:GetLowerInstanceNumber() if (lower_instance) then local instance = _detalhes:GetInstance(lower_instance) @@ -1808,7 +1813,7 @@ function Details.Database.StoreEncounter(combat) local func = {_detalhes.OpenRaidHistoryWindow, _detalhes, raid_name, encounter_id, diff, my_role, guildName} --, 2, UnitName ("player") --local icon = {[[Interface\AddOns\Details\images\icons]], 16, 16, false, 434/512, 466/512, 243/512, 273/512} local icon = {[[Interface\PvPRankBadges\PvPRank08]], 16, 16, false, 0, 1, 0, 1} - + if (not _detalhes.deny_score_messages) then instance:InstanceAlert (Loc ["STRING_GUILDDAMAGERANK_WINDOWALERT"], icon, _detalhes.update_warning_timeout, func, true) end @@ -1873,7 +1878,7 @@ function _detalhes:IlvlFromNetwork (player, realm, core, serialNumber, itemLevel if (not player) then return end - + --older versions of details wont send serial nor talents nor spec if (not serialNumber or not itemLevel or not talentsSelected or not currentSpec) then --if any data is invalid, abort @@ -1882,7 +1887,7 @@ function _detalhes:IlvlFromNetwork (player, realm, core, serialNumber, itemLevel --won't inspect this actor _detalhes.trusted_characters [serialNumber] = true - + if (type(serialNumber) ~= "string") then return end @@ -1891,14 +1896,14 @@ function _detalhes:IlvlFromNetwork (player, realm, core, serialNumber, itemLevel if (type(itemLevel) == "number") then _detalhes.item_level_pool [serialNumber] = {name = player, ilvl = itemLevel, time = time()} end - + --store talents if (type(talentsSelected) == "table") then if (talentsSelected [1]) then _detalhes.cached_talents [serialNumber] = talentsSelected end end - + --store the spec the player is playing if (type(currentSpec) == "number") then _detalhes.cached_specs [serialNumber] = currentSpec @@ -1910,7 +1915,7 @@ end --/run wipe (_detalhes.item_level_pool) function ilvl_core:CalcItemLevel (unitid, guid, shout) - + if (type(unitid) == "table") then shout = unitid [3] guid = unitid [2] @@ -1923,7 +1928,7 @@ function ilvl_core:CalcItemLevel (unitid, guid, shout) local item_amount = 16 local item_level = 0 local failed = 0 - + for equip_id = 1, 17 do if (equip_id ~= 4) then --shirt slot local item = GetInventoryItemLink (unitid, equip_id) @@ -1947,32 +1952,32 @@ function ilvl_core:CalcItemLevel (unitid, guid, shout) end end end - + local average = item_level / item_amount --print(UnitName (unitid), "ILVL:", average, unitid, "items:", item_amount) - + --register if (average > 0) then if (shout) then _detalhes:Msg(UnitName(unitid) .. " item level: " .. average) end - + if (average > MIN_ILEVEL_TO_STORE) then local name = _detalhes:GetCLName(unitid) _detalhes.item_level_pool [guid] = {name = name, ilvl = average, time = time()} end end - + local spec local talents = {} - + if (not DetailsFramework.IsTimewalkWoW()) then spec = GetInspectSpecialization (unitid) if (spec and spec ~= 0) then _detalhes.cached_specs [guid] = spec Details:SendEvent("UNIT_SPEC", nil, unitid, spec, guid) end - + -------------------------------------------------------------------------------------------------------- for i = 1, 7 do @@ -1985,7 +1990,7 @@ function ilvl_core:CalcItemLevel (unitid, guid, shout) end end end - + if (talents [1]) then _detalhes.cached_talents [guid] = talents Details:SendEvent("UNIT_TALENTS", nil, unitid, talents, guid) @@ -2005,21 +2010,21 @@ function ilvl_core:CalcItemLevel (unitid, guid, shout) end -------------------------------------------------------------------------------------------------------- - + end end _detalhes.ilevel.CalcItemLevel = ilvl_core.CalcItemLevel inspect_frame:SetScript("OnEvent", function(self, event, ...) local guid = select(1, ...) - + if (inspecting [guid]) then local unitid, cancel_tread = inspecting [guid] [1], inspecting [guid] [2] inspecting [guid] = nil ilvl_core.amt_inspecting = ilvl_core.amt_inspecting - 1 - + ilvl_core:CancelTimer(cancel_tread) - + --do inspect stuff if (unitid) then local t = {unitid, guid} @@ -2088,7 +2093,7 @@ end local NotifyInspectHook = function(unitid) local unit = unitid:gsub("%d+", "") - + if ((IsInRaid() or IsInGroup()) and (_detalhes:GetZoneType() == "raid" or _detalhes:GetZoneType() == "party")) then local guid = UnitGUID(unitid) local name = _detalhes:GetCLName(unitid) @@ -2099,7 +2104,7 @@ local NotifyInspectHook = function(unitid) break end end - + inspecting [guid] = {unitid, ilvl_core:ScheduleTimer("InspectTimeOut", 12, guid)} ilvl_core.amt_inspecting = ilvl_core.amt_inspecting + 1 end @@ -2110,7 +2115,7 @@ end function ilvl_core:Reset() ilvl_core.raid_id = 1 ilvl_core.amt_inspecting = 0 - + for guid, t in pairs(inspecting) do ilvl_core:CancelTimer(t[2]) inspecting [guid] = nil @@ -2142,30 +2147,30 @@ function ilvl_core:QueryInspect (unitName, callback, param1) else unitid = unitName end - + if (not unitid) then return false end - + local guid = UnitGUID(unitid) if (not guid) then return false elseif (ilvl_core.forced_inspects [guid]) then return true end - + if (inspecting [guid]) then return true end - + ilvl_core.forced_inspects [guid] = {callback = callback, param1 = param1} ilvl_core:GetItemLevel (unitid, guid, true) - + if (ilvl_core.clear_queued_list) then ilvl_core:CancelTimer(ilvl_core.clear_queued_list) end ilvl_core.clear_queued_list = ilvl_core:ScheduleTimer("ClearQueryInspectQueue", 60) - + return true end @@ -2188,7 +2193,7 @@ function ilvl_core:Loop() if (ilvl_core.raid_id > members_amt) then ilvl_core.raid_id = 1 end - + local unitid if (IsInRaid()) then unitid = "raid" .. ilvl_core.raid_id @@ -2214,7 +2219,7 @@ function ilvl_core:Loop() ilvl_core.raid_id = ilvl_core.raid_id + 1 return end - + ilvl_core:GetItemLevel (unitid, guid) ilvl_core.raid_id = ilvl_core.raid_id + 1 end @@ -2256,7 +2261,7 @@ function ilvl_core:OnEnter() if (IsInRaid()) then _detalhes:SendCharacterData() end - + if (can_start_loop()) then ilvl_core:Reset() ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer ("Loop", LOOP_TIME) @@ -2343,7 +2348,7 @@ function Details:CompressData (data, dataType) if (dataType == "print") then local dataEncoded = LibDeflate:EncodeForPrint (dataCompressed) return dataEncoded - + elseif (dataType == "comm") then local dataEncoded = LibDeflate:EncodeForWoWAddonChannel (dataCompressed) return dataEncoded @@ -2356,15 +2361,15 @@ end function Details:DecompressData (data, dataType) local LibDeflate = LibStub:GetLibrary ("LibDeflate") local LibAceSerializer = LibStub:GetLibrary ("AceSerializer-3.0") - + if (LibDeflate and LibAceSerializer) then - + local dataCompressed - + if (dataType == "print") then - + data = DetailsFramework:Trim (data) - + dataCompressed = LibDeflate:DecodeForPrint (data) if (not dataCompressed) then Details:Msg("couldn't decode the data.") @@ -2379,18 +2384,18 @@ function Details:DecompressData (data, dataType) end end local dataSerialized = LibDeflate:DecompressDeflate (dataCompressed) - + if (not dataSerialized) then Details:Msg("couldn't uncompress the data.") return false end - + local okay, data = LibAceSerializer:Deserialize (dataSerialized) if (not okay) then Details:Msg("couldn't unserialize the data.") return false end - + return data end end @@ -2440,7 +2445,7 @@ Details.specToRole = { [71] = "DAMAGER", --ARMS [72] = "DAMAGER", --FURY [73] = "TANK", --PROT - + --DK [250] = "TANK", --Blood [251] = "DAMAGER", --Frost @@ -2457,7 +2462,7 @@ Details.specToRole = { --EVOKER [1467] = "DAMAGER", --Devastation Evoker - [1468] = "HEALER", --Preservation Evoker + [1468] = "HEALER", --Preservation Evoker } --oldschool talent tree @@ -2556,13 +2561,13 @@ if (DetailsFramework.IsWotLKWow()) then local item_amount = 16 local item_level = 0 local failed = 0 - + local two_hand = { ["INVTYPE_2HWEAPON"] = true, ["INVTYPE_RANGED"] = true, ["INVTYPE_RANGEDRIGHT"] = true, } - + for equip_id = 1, 17 do if (equip_id ~= 4) then --shirt slot, trinkets local item = GetInventoryItemLink("player", equip_id) @@ -2570,7 +2575,7 @@ if (DetailsFramework.IsWotLKWow()) then local _, _, itemRarity, iLevel, _, _, _, _, equipSlot = GetItemInfo(item) if (iLevel) then item_level = item_level + iLevel - + --16 = main hand 17 = off hand -- if using a two-hand, ignore the off hand slot if (equip_id == 16 and two_hand [equipSlot]) then @@ -2621,7 +2626,7 @@ if (DetailsFramework.IsWotLKWow()) then if (column == 3 and rank == 5) then tankTalents = tankTalents + 5 end - + if (tankTalents >= 10) then return "TANK" end @@ -2629,7 +2634,7 @@ if (DetailsFramework.IsWotLKWow()) then end end end - + return Details.specToRole [specId] or "NONE" end @@ -3130,18 +3135,18 @@ hooksecurefunc("ChatFrame_DisplayTimePlayed", function() if (Details.played_class_time) then C_Timer.After(0, function() local expansionName = _G["EXPANSION_NAME" .. GetExpansionLevel()] - for fontString in ChatFrame1.fontStringPool:EnumerateActive() do - if (fontString:GetText() and fontString:GetText():find(expansionName)) then + for fontString in ChatFrame1.fontStringPool:EnumerateActive() do + if (fontString:GetText() and fontString:GetText():find(expansionName)) then return - end + end end local levelText = TIME_PLAYED_LEVEL and TIME_PLAYED_LEVEL:gsub("%%s", "") or "" - for fontString in ChatFrame1.fontStringPool:EnumerateActive() do - if (fontString:GetText() and fontString:GetText():find(levelText)) then + for fontString in ChatFrame1.fontStringPool:EnumerateActive() do + if (fontString:GetText() and fontString:GetText():find(levelText)) then print(Details.GetPlayTimeOnClassString() .. " (/details playedclass)") break - end + end end end) end diff --git a/core/network.lua b/core/network.lua index 826177f7..3955a304 100644 --- a/core/network.lua +++ b/core/network.lua @@ -326,15 +326,15 @@ --guild sync G = requested a list of encounters --guild sync A = received missing encounters, add them - function Details.network.GuildSync(player, realm, coreVersion, type, data) - local characterName = Ambiguate(player, "none") + function Details.network.GuildSync(sourceName, realm, coreVersion, type, data) + local characterName = Ambiguate(sourceName, "none") - if (UnitName("player") == characterName) then - return + if (UnitName("player") == sourceName) then + --return end if (coreVersion ~= Details.realversion) then - return false + --return false end if (type == "R") then --RoS - somebody requested IDs of stored encounters @@ -345,22 +345,27 @@ end local IDs = Details.storage:GetIDsToGuildSync() + dumpt(IDs) + if (IDs and IDs [1]) then - local from = UnitName ("player") + local from = UnitName("player") local realm = GetRealmName() - Details:SendCommMessage(DETAILS_PREFIX_NETWORK, Details:Serialize(CONST_GUILD_SYNC, from, realm, Details.realversion, "L", IDs), "WHISPER", characterName) + Details:SendCommMessage(DETAILS_PREFIX_NETWORK, Details:Serialize(CONST_GUILD_SYNC, from, realm, Details.realversion, "L", IDs), "WHISPER", sourceName) end Details.LastGuildSyncDataTime1 = GetTime() + 60 return true elseif (type == "L") then --RoC - the player received the IDs list and send back which IDs he doesn't have - local MissingIDs = Details.storage:CheckMissingIDsToGuildSync(data) + local missingIds = Details.storage:CheckMissingIDsToGuildSync(data) - if (MissingIDs and MissingIDs[1]) then + print("data from:", sourceName, "missing ids", #missingIds) + dumpt(data) + + if (missingIds and missingIds[1]) then local from = UnitName ("player") local realm = GetRealmName() - Details:SendCommMessage(DETAILS_PREFIX_NETWORK, Details:Serialize(CONST_GUILD_SYNC, from, realm, Details.realversion, "G", MissingIDs), "WHISPER", characterName) + Details:SendCommMessage(DETAILS_PREFIX_NETWORK, Details:Serialize(CONST_GUILD_SYNC, from, realm, Details.realversion, "G", missingIds), "WHISPER", sourceName) end return true @@ -435,9 +440,6 @@ --register comm function Details:CommReceived(commPrefix, data, channel, source) - - --print("comm", source, data) - local deserializedTable = {Details:Deserialize(data)} if (not deserializedTable[1]) then if (Details.debugnet) then diff --git a/frames/window_statistics.lua b/frames/window_statistics.lua index afc0a090..653c72c3 100644 --- a/frames/window_statistics.lua +++ b/frames/window_statistics.lua @@ -1,5 +1,4 @@ - --todo: need to fix this file after pre-patch local Details = _G.Details @@ -27,23 +26,22 @@ function Details:InitializeRaidHistoryWindow() end end -function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild, _player_base, _player_name, _history_type) - +function Details:OpenRaidHistoryWindow(raidName, bossEncounterId, difficultyId, playerRole, guildName, playerBase, playerName, historyType) if (not DetailsRaidHistoryWindow or not DetailsRaidHistoryWindow.Initialized) then DetailsRaidHistoryWindow.Initialized = true - local f = DetailsRaidHistoryWindow or CreateFrame("frame", "DetailsRaidHistoryWindow", UIParent,"BackdropTemplate") --, "ButtonFrameTemplate" - f:SetPoint("center", UIParent, "center") - f:SetFrameStrata("HIGH") - f:SetToplevel(true) + local statisticsFrame = DetailsRaidHistoryWindow or CreateFrame("frame", "DetailsRaidHistoryWindow", UIParent, "BackdropTemplate") + statisticsFrame:SetPoint("center", UIParent, "center") + statisticsFrame:SetFrameStrata("HIGH") + statisticsFrame:SetToplevel(true) - f:SetMovable(true) - f:SetWidth(850) - f:SetHeight(500) + statisticsFrame:SetMovable(true) + statisticsFrame:SetWidth(850) + statisticsFrame:SetHeight(500) tinsert(UISpecialFrames, "DetailsRaidHistoryWindow") - function f.OpenDB() + function statisticsFrame.OpenDB() local db = Details.storage:OpenRaidStorage() if (not db) then Details:Msg(Loc ["STRING_GUILDDAMAGERANK_DATABASEERROR"]) @@ -52,67 +50,32 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild return db end - local db = f.OpenDB() + local db = statisticsFrame.OpenDB() if (not db) then return end - C_Timer.After(8, function() - --if (f:IsShown()) then - -- return Details:OpenRaidHistoryWindow(_raid, _boss, _difficulty, _role, _guild, _player_base, _player_name, _history_type) - --end - end) + statisticsFrame.Mode = 2 - f.Mode = 2 + DF:ApplyStandardBackdrop(statisticsFrame) - f.bg1 = f:CreateTexture(nil, "background") - f.bg1:SetTexture([[Interface\AddOns\Details\images\background]], true) - f.bg1:SetAlpha(0.7) - f.bg1:SetVertexColor(0.27, 0.27, 0.27) - f.bg1:SetVertTile(true) - f.bg1:SetHorizTile(true) - f.bg1:SetSize(790, 454) - f.bg1:SetAllPoints() - - f:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true}) - f:SetBackdropColor(.5, .5, .5, .5) - f:SetBackdropBorderColor(0, 0, 0, 1) - - local titlebar = DF:CreateTitleBar(f, "Details! " .. Loc ["STRING_STATISTICS"]) - - if (not Details:GetTutorialCVar("HISTORYPANEL_TUTORIAL")) then - local tutorialFrame = CreateFrame("frame", "$parentTutorialFrame",f,"BackdropTemplate") - tutorialFrame:SetPoint("center", f, "center") - tutorialFrame:SetFrameStrata("DIALOG") - tutorialFrame:SetSize(400, 300) - tutorialFrame:SetBackdrop({bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16, - insets = {left = 0, right = 0, top = 0, bottom = 0}, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize=1}) - tutorialFrame:SetBackdropColor(0, 0, 0, 1) - - tutorialFrame.Title = DF:CreateLabel(tutorialFrame, "Statistics" , 12, "orange") --curse localization isn't adding new strings (and I deleted the old one) - tutorialFrame.Title:SetPoint("top", tutorialFrame, "top", 0, -5) - - tutorialFrame.Desc = DF:CreateLabel(tutorialFrame, Loc ["STRING_GUILDDAMAGERANK_TUTORIAL_DESC"], 12) - tutorialFrame.Desc.width = 370 - tutorialFrame.Desc:SetPoint("topleft", tutorialFrame, "topleft", 10, -45) - - local closeButton = DF:CreateButton(tutorialFrame, function() Details:SetTutorialCVar ("HISTORYPANEL_TUTORIAL", true); tutorialFrame:Hide() end, 80, 20, Loc ["STRING_OPTIONS_CHART_CLOSE"]) - closeButton:SetPoint("bottom", tutorialFrame, "bottom", 0, 10) - closeButton:SetTemplate(DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) - end + --create title bar + local titlebar = DF:CreateTitleBar(statisticsFrame, "Details! " .. Loc ["STRING_STATISTICS"]) +--STRING_GUILDDAMAGERANK_TUTORIAL_DESC +--STRING_OPTIONS_CHART_CLOSE --background - local background = f:CreateTexture("$parentBackgroundImage", "border") - background:SetAlpha(0.3) - background:SetPoint("topleft", f, "topleft", 6, -65) - background:SetPoint("bottomright", f, "bottomright", -10, 28) + local background = statisticsFrame:CreateTexture("$parentBackgroundImage", "border") + background:SetAlpha(0.3) + background:SetPoint("topleft", statisticsFrame, "topleft", 6, -65) + background:SetPoint("bottomright", statisticsFrame, "bottomright", -10, 28) --separate menu and main list - local div = f:CreateTexture(nil, "artwork") - div:SetTexture([[Interface\ACHIEVEMENTFRAME\UI-Achievement-MetalBorder-Left]]) - div:SetAlpha(0.1) - div:SetPoint("topleft", f, "topleft", 180, -64) - div:SetHeight(574) + local div = statisticsFrame:CreateTexture(nil, "artwork") + div:SetTexture([[Interface\ACHIEVEMENTFRAME\UI-Achievement-MetalBorder-Left]]) + div:SetAlpha(0.1) + div:SetPoint("topleft", statisticsFrame, "topleft", 180, -64) + div:SetHeight(574) --select history or guild rank local options_switch_template = DF:GetTemplate("switch", "OPTIONS_CHECKBOX_TEMPLATE") @@ -120,185 +83,191 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild local options_button_template = DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE") local selectKillTimeline = function() - f.GuildRankCheckBox:SetValue(false) - f.HistoryCheckBox:SetValue(true) - f.Mode = 1 - _G.DetailsRaidHistoryWindow:Refresh() - f.ReportButton:Hide() + statisticsFrame.GuildRankCheckBox:SetValue(false) + statisticsFrame.HistoryCheckBox:SetValue(true) + statisticsFrame.Mode = 1 + statisticsFrame:Refresh() + statisticsFrame.ReportButton:Hide() end local selectGuildRank = function() - f.HistoryCheckBox:SetValue(false) - f.GuildRankCheckBox:SetValue(true) - _G.DetailsRaidHistoryWindow.select_player:Select(1, true) - f.select_player2:Hide() - f.select_player2_label:Hide() - f.Mode = 2 - _G.DetailsRaidHistoryWindow:Refresh() - f.ReportButton:Show() + statisticsFrame.HistoryCheckBox:SetValue(false) + statisticsFrame.GuildRankCheckBox:SetValue(true) + statisticsFrame.select_player:Select(1, true) + statisticsFrame.select_player2:Hide() + statisticsFrame.select_player2_label:Hide() + statisticsFrame.Mode = 2 + statisticsFrame:Refresh() + statisticsFrame.ReportButton:Show() end --kill timeline - local HistoryCheckBox, HistoryLabel = DF:CreateSwitch(f, selectKillTimeline, false, 18, 18, "", "", "HistoryCheckBox", nil, nil, nil, nil, Loc ["STRING_GUILDDAMAGERANK_SHOWHISTORY"], options_switch_template) --, options_text_template + local HistoryCheckBox, HistoryLabel = DF:CreateSwitch(statisticsFrame, selectKillTimeline, false, 18, 18, "", "", "HistoryCheckBox", nil, nil, nil, nil, Loc ["STRING_GUILDDAMAGERANK_SHOWHISTORY"], options_switch_template) --, options_text_template HistoryLabel:ClearAllPoints() HistoryCheckBox:ClearAllPoints() - HistoryCheckBox:SetPoint("topleft", f, "topleft", 100, -34) + HistoryCheckBox:SetPoint("topleft", statisticsFrame, "topleft", 100, -34) HistoryLabel:SetPoint("left", HistoryCheckBox, "right", 2, 0) HistoryCheckBox:SetAsCheckBox() --guildrank - local GuildRankCheckBox, GuildRankLabel = DF:CreateSwitch(f, selectGuildRank, true, 18, 18, "", "", "GuildRankCheckBox", nil, nil, nil, nil, Loc ["STRING_GUILDDAMAGERANK_SHOWRANK"], options_switch_template) --, options_text_template + local GuildRankCheckBox, GuildRankLabel = DF:CreateSwitch(statisticsFrame, selectGuildRank, true, 18, 18, "", "", "GuildRankCheckBox", nil, nil, nil, nil, Loc ["STRING_GUILDDAMAGERANK_SHOWRANK"], options_switch_template) --, options_text_template GuildRankLabel:ClearAllPoints() GuildRankCheckBox:ClearAllPoints() - GuildRankCheckBox:SetPoint("topleft", f, "topleft", 240, -34) + GuildRankCheckBox:SetPoint("topleft", statisticsFrame, "topleft", 240, -34) GuildRankLabel:SetPoint("left", GuildRankCheckBox, "right", 2, 0) GuildRankCheckBox:SetAsCheckBox() --guild sync - local doGuildSync = function() - f.RequestedAmount = 0 - f.DownloadedAmount = 0 - f.EstimateSize = 0 - f.DownloadedSize = 0 - f.SyncStartTime = time() + local doGuildSync = function() + statisticsFrame.RequestedAmount = 0 + statisticsFrame.DownloadedAmount = 0 + statisticsFrame.EstimateSize = 0 + statisticsFrame.DownloadedSize = 0 + statisticsFrame.SyncStartTime = time() - Details.storage:DBGuildSync() - f.GuildSyncButton:Disable() + Details.storage:DBGuildSync() + statisticsFrame.GuildSyncButton:Disable() - if (not f.SyncTexture) then - local workingFrame = CreateFrame("frame", nil, f,"BackdropTemplate") - f.WorkingFrame = workingFrame - workingFrame:SetSize(1, 1) - f.SyncTextureBackground = workingFrame:CreateTexture(nil, "border") - f.SyncTextureBackground:SetPoint("bottomright", f, "bottomright", -5, -1) - f.SyncTextureBackground:SetTexture([[Interface\COMMON\StreamBackground]]) - f.SyncTextureBackground:SetSize(32, 32) - f.SyncTextureCircle = workingFrame:CreateTexture(nil, "artwork") - f.SyncTextureCircle:SetPoint("center", f.SyncTextureBackground, "center", 0, 0) - f.SyncTextureCircle:SetTexture([[Interface\COMMON\StreamCircle]]) - f.SyncTextureCircle:SetSize(32, 32) - f.SyncTextureGrade = workingFrame:CreateTexture(nil, "overlay") - f.SyncTextureGrade:SetPoint("center", f.SyncTextureBackground, "center", 0, 0) - f.SyncTextureGrade:SetTexture([[Interface\COMMON\StreamFrame]]) - f.SyncTextureGrade:SetSize(32, 32) + if (not statisticsFrame.SyncTexture) then + local workingFrame = CreateFrame("frame", nil, statisticsFrame, "BackdropTemplate") + statisticsFrame.WorkingFrame = workingFrame + workingFrame:SetSize(1, 1) + statisticsFrame.SyncTextureBackground = workingFrame:CreateTexture(nil, "border") + statisticsFrame.SyncTextureBackground:SetPoint("bottomright", statisticsFrame, "bottomright", -5, -1) + statisticsFrame.SyncTextureBackground:SetTexture([[Interface\COMMON\StreamBackground]]) + statisticsFrame.SyncTextureBackground:SetSize(32, 32) - local animationHub = DF:CreateAnimationHub (workingFrame) - animationHub:SetLooping ("Repeat") - f.WorkingAnimation = animationHub + statisticsFrame.SyncTextureCircle = workingFrame:CreateTexture(nil, "artwork") + statisticsFrame.SyncTextureCircle:SetPoint("center", statisticsFrame.SyncTextureBackground, "center", 0, 0) + statisticsFrame.SyncTextureCircle:SetTexture([[Interface\COMMON\StreamCircle]]) + statisticsFrame.SyncTextureCircle:SetSize(32, 32) - local rotation = DF:CreateAnimation(animationHub, "ROTATION", 1, 3, -360) - rotation:SetTarget (f.SyncTextureCircle) + statisticsFrame.SyncTextureGrade = workingFrame:CreateTexture(nil, "overlay") + statisticsFrame.SyncTextureGrade:SetPoint("center", statisticsFrame.SyncTextureBackground, "center", 0, 0) + statisticsFrame.SyncTextureGrade:SetTexture([[Interface\COMMON\StreamFrame]]) + statisticsFrame.SyncTextureGrade:SetSize(32, 32) - f.SyncText = workingFrame:CreateFontString(nil, "border", "GameFontNormal") - f.SyncText:SetPoint("right", f.SyncTextureBackground, "left", 0, 0) - f.SyncText:SetText("working") + local animationHub = DF:CreateAnimationHub(workingFrame) + animationHub:SetLooping("Repeat") + statisticsFrame.WorkingAnimation = animationHub - local endAnimationHub = DF:CreateAnimationHub (workingFrame, nil, function() workingFrame:Hide() end) - DF:CreateAnimation(endAnimationHub, "ALPHA", 1, 0.5, 1, 0) - f.EndAnimationHub = endAnimationHub - end + local rotation = DF:CreateAnimation(animationHub, "ROTATION", 1, 3, -360) + rotation:SetTarget(statisticsFrame.SyncTextureCircle) - f.WorkingFrame:Show() - f.WorkingAnimation:Play() + statisticsFrame.SyncText = workingFrame:CreateFontString(nil, "border", "GameFontNormal") + statisticsFrame.SyncText:SetPoint("right", statisticsFrame.SyncTextureBackground, "left", 0, 0) + statisticsFrame.SyncText:SetText("working") - C_Timer.NewTicker(10, function(self) - if (not Details.LastGuildSyncReceived) then - f.GuildSyncButton:Enable() - f.EndAnimationHub:Play() - - elseif (Details.LastGuildSyncReceived+10 < GetTime()) then - f.GuildSyncButton:Enable() - f.EndAnimationHub:Play() - self:Cancel() - end - end) + local endAnimationHub = DF:CreateAnimationHub(workingFrame, nil, function() workingFrame:Hide() end) + DF:CreateAnimation(endAnimationHub, "ALPHA", 1, 0.5, 1, 0) + statisticsFrame.EndAnimationHub = endAnimationHub end - local GuildSyncButton = DF:CreateButton(f, doGuildSync, 130, 20, Loc ["STRING_GUILDDAMAGERANK_SYNCBUTTONTEXT"], nil, nil, nil, "GuildSyncButton", nil, nil, options_button_template, options_text_template) - GuildSyncButton:SetPoint("topright", f, "topright", -20, -34) - GuildSyncButton:SetIcon ([[Interface\GLUES\CharacterSelect\RestoreButton]], 12, 12, "overlay", {0.2, .8, 0.2, .8}, nil, 4) + statisticsFrame.WorkingFrame:Show() + statisticsFrame.WorkingAnimation:Play() + + C_Timer.NewTicker(10, function(self) + if (not Details.LastGuildSyncReceived) then + statisticsFrame.GuildSyncButton:Enable() + statisticsFrame.EndAnimationHub:Play() + + elseif (Details.LastGuildSyncReceived+10 < GetTime()) then + statisticsFrame.GuildSyncButton:Enable() + statisticsFrame.EndAnimationHub:Play() + self:Cancel() + end + end) + end + + local guildSyncButton = DF:CreateButton(statisticsFrame, doGuildSync, 130, 20, Loc ["STRING_GUILDDAMAGERANK_SYNCBUTTONTEXT"], nil, nil, nil, "GuildSyncButton", nil, nil, options_button_template, options_text_template) + guildSyncButton:SetPoint("topright", statisticsFrame, "topright", -20, -34) + guildSyncButton:SetIcon([[Interface\GLUES\CharacterSelect\RestoreButton]], 12, 12, "overlay", {0.2, .8, 0.2, .8}, nil, 4) --listen to comm events - local eventListener = Details:CreateEventListener() + local eventListener = Details:CreateEventListener() - function eventListener:OnCommReceived (event, length, prefix, playerName, realmName, detailsVersion, guildSyncID, data) - if (prefix == CONST_GUILD_SYNC) then - --received a list of encounter IDs - if (guildSyncID == "L") then + function eventListener:OnCommReceived(event, length, prefix, playerName, realmName, detailsVersion, guildSyncID, data) + if (prefix == CONST_GUILD_SYNC) then + --print(event, length, prefix, playerName, realmName, detailsVersion, guildSyncID, data) - --received one encounter table - elseif (guildSyncID == "A") then - if (not f.RequestedAmount) then - --if the receiving player reloads, f.RequestedAmount is nil - return - end - f.DownloadedAmount = (f.DownloadedAmount or 0) + 1 + --received a list of encounter IDs + if (guildSyncID == "L") then - --size = 1 byte per characters in the string - f.EstimateSize = length * f.RequestedAmount > f.EstimateSize and length * f.RequestedAmount or f.RequestedAmount - f.DownloadedSize = f.DownloadedSize + length - local downloadSpeed = f.DownloadedSize / (time() - f.SyncStartTime) - - f.SyncText:SetText("working [downloading " .. f.DownloadedAmount .. "/" .. f.RequestedAmount .. ", " .. format("%.2f", downloadSpeed/1024) .. "Kbps]") + --received one encounter table + elseif (guildSyncID == "A") then + if (not statisticsFrame.RequestedAmount) then + --if the receiving player reloads, f.RequestedAmount is nil + return end + statisticsFrame.DownloadedAmount = (statisticsFrame.DownloadedAmount or 0) + 1 + + --size = 1 byte per characters in the string + statisticsFrame.EstimateSize = length * statisticsFrame.RequestedAmount > statisticsFrame.EstimateSize and length * statisticsFrame.RequestedAmount or statisticsFrame.RequestedAmount + statisticsFrame.DownloadedSize = statisticsFrame.DownloadedSize + length + local downloadSpeed = statisticsFrame.DownloadedSize / (time() - statisticsFrame.SyncStartTime) + + statisticsFrame.SyncText:SetText("working [downloading " .. statisticsFrame.DownloadedAmount .. "/" .. statisticsFrame.RequestedAmount .. ", " .. format("%.2f", downloadSpeed/1024) .. "Kbps]") end end + end - function eventListener:OnCommSent(event, length, prefix, playerName, realmName, detailsVersion, guildSyncID, missingIDs, arg8, arg9) - if (prefix == CONST_GUILD_SYNC) then - --requested a list of encounters - if (guildSyncID == "R") then + function eventListener:OnCommSent(event, length, prefix, playerName, realmName, detailsVersion, guildSyncID, missingIDs, arg8, arg9) + if (prefix == CONST_GUILD_SYNC) then + --print(event, length, prefix, playerName, realmName, detailsVersion, guildSyncID, missingIDs, arg8, arg9) - --requested to download a selected list of encounter tables - elseif (guildSyncID == "G") then - f.RequestedAmount = f.RequestedAmount + #missingIDs - f.SyncText:SetText("working [downloading " .. f.DownloadedAmount .. "/" .. f.RequestedAmount .. "]") - end + --requested a list of encounters + if (guildSyncID == "R") then + + --requested to download a selected list of encounter tables + elseif (guildSyncID == "G") then + statisticsFrame.RequestedAmount = statisticsFrame.RequestedAmount + #missingIDs + statisticsFrame.SyncText:SetText("working [downloading " .. statisticsFrame.DownloadedAmount .. "/" .. statisticsFrame.RequestedAmount .. "]") end end + end - eventListener:RegisterEvent("COMM_EVENT_RECEIVED", "OnCommReceived") - eventListener:RegisterEvent("COMM_EVENT_SENT", "OnCommSent") + eventListener:RegisterEvent("COMM_EVENT_RECEIVED", "OnCommReceived") + eventListener:RegisterEvent("COMM_EVENT_SENT", "OnCommSent") --report results - function f.BuildReport() - if (f.LatestResourceTable) then - local reportFunc = function(IsCurrent, IsReverse, AmtLines) - local bossName = f.select_boss.label:GetText() - local bossDiff = f.select_diff.label:GetText() - local guildName = f.select_guild.label:GetText() - local reportTable = {"Details!: DPS Rank for: " .. (bossDiff or "") .. " " .. (bossName or "--x--x--") .. " <" .. (guildName or "") .. ">"} - local result = {} + function statisticsFrame.BuildReport() + if (statisticsFrame.LatestResourceTable) then + local reportFunc = function(IsCurrent, IsReverse, AmtLines) + local bossName = statisticsFrame.select_boss.label:GetText() + local bossDiff = statisticsFrame.select_diff.label:GetText() + local guildName = statisticsFrame.select_guild.label:GetText() + local reportTable = {"Details!: DPS Rank for: " .. (bossDiff or "") .. " " .. (bossName or "--x--x--") .. " <" .. (guildName or "") .. ">"} + local result = {} - for i = 1, AmtLines do - if (f.LatestResourceTable[i]) then - local playerName = f.LatestResourceTable[i][1] - playerName = playerName:gsub("%|c%x%x%x%x%x%x%x%x", "") - playerName = playerName:gsub("%|r", "") - playerName = playerName:gsub(".*%s", "") - tinsert(result, {playerName, f.LatestResourceTable[i][2]}) - else - break - end + for i = 1, AmtLines do + if (statisticsFrame.LatestResourceTable[i]) then + local playerName = statisticsFrame.LatestResourceTable[i][1] + playerName = playerName:gsub("%|c%x%x%x%x%x%x%x%x", "") + playerName = playerName:gsub("%|r", "") + playerName = playerName:gsub(".*%s", "") + tinsert(result, {playerName, statisticsFrame.LatestResourceTable[i][2]}) + else + break end - - Details:FormatReportLines (reportTable, result) - Details:SendReportLines (reportTable) end - Details:SendReportWindow (reportFunc, nil, nil, true) + Details:FormatReportLines(reportTable, result) + Details:SendReportLines(reportTable) end - end - local ReportButton = DF:CreateButton(f, f.BuildReport, 130, 20, Loc ["STRING_OPTIONS_REPORT_ANCHOR"]:gsub(":", ""), nil, nil, nil, "ReportButton", nil, nil, options_button_template, options_text_template) - ReportButton:SetPoint("right", GuildSyncButton, "left", -2, 0) - ReportButton:SetIcon ([[Interface\GLUES\CharacterSelect\RestoreButton]], 12, 12, "overlay", {0.2, .8, 0.2, .8}, nil, 4) + Details:SendReportWindow(reportFunc, nil, nil, true) + end + end + + local reportButton = DF:CreateButton(statisticsFrame, statisticsFrame.BuildReport, 130, 20, Loc ["STRING_OPTIONS_REPORT_ANCHOR"]:gsub(":", ""), nil, nil, nil, "ReportButton", nil, nil, options_button_template, options_text_template) + reportButton:SetPoint("right", guildSyncButton, "left", -2, 0) + reportButton:SetIcon([[Interface\GLUES\CharacterSelect\RestoreButton]], 12, 12, "overlay", {0.2, .8, 0.2, .8}, nil, 4) -- - function f:SetBackgroundImage (encounterId) - local instanceId = Details:GetInstanceIdFromEncounterId (encounterId) + function statisticsFrame:SetBackgroundImage(encounterId) + local instanceId = Details:GetInstanceIdFromEncounterId(encounterId) if (instanceId) then - local file, L, R, T, B = Details:GetRaidBackground (instanceId) + local file, L, R, T, B = Details:GetRaidBackground(instanceId) --print("file:", file) --can't get the image, looks to be restricted --[[ @@ -314,36 +283,36 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild end --window script handlers - f:SetScript("OnMouseDown", function(self, button) - if (self.isMoving) then - return - end - if (button == "RightButton") then - self:Hide() - else - self:StartMoving() - self.isMoving = true - end - end) + statisticsFrame:SetScript("OnMouseDown", function(self, button) + if (self.isMoving) then + return + end + if (button == "RightButton") then + self:Hide() + else + self:StartMoving() + self.isMoving = true + end + end) - f:SetScript("OnMouseUp", function(self, button) - if (self.isMoving and button == "LeftButton") then - self:StopMovingOrSizing() - self.isMoving = nil - end - end) + statisticsFrame:SetScript("OnMouseUp", function(self, button) + if (self.isMoving and button == "LeftButton") then + self:StopMovingOrSizing() + self.isMoving = nil + end + end) - f:SetScript("OnHide", function() - --save latest shown state - f.LatestSelection = f.LatestSelection or {} - f.LatestSelection.Raid = DetailsRaidHistoryWindow.select_raid.value - f.LatestSelection.Boss = DetailsRaidHistoryWindow.select_boss.value - f.LatestSelection.Diff = DetailsRaidHistoryWindow.select_diff.value - f.LatestSelection.Role = DetailsRaidHistoryWindow.select_role.value - f.LatestSelection.Guild = DetailsRaidHistoryWindow.select_guild.value - f.LatestSelection.PlayerBase = DetailsRaidHistoryWindow.select_player.value - f.LatestSelection.PlayerName = DetailsRaidHistoryWindow.select_player2.value - end) + statisticsFrame:SetScript("OnHide", function() + --save latest shown state + statisticsFrame.LatestSelection = statisticsFrame.LatestSelection or {} + statisticsFrame.LatestSelection.Raid = DetailsRaidHistoryWindow.select_raid.value + statisticsFrame.LatestSelection.Boss = DetailsRaidHistoryWindow.select_boss.value + statisticsFrame.LatestSelection.Diff = DetailsRaidHistoryWindow.select_diff.value + statisticsFrame.LatestSelection.Role = DetailsRaidHistoryWindow.select_role.value + statisticsFrame.LatestSelection.Guild = DetailsRaidHistoryWindow.select_guild.value + statisticsFrame.LatestSelection.PlayerBase = DetailsRaidHistoryWindow.select_player.value + statisticsFrame.LatestSelection.PlayerName = DetailsRaidHistoryWindow.select_player2.value + end) local dropdownWidth = 160 local icon = [[Interface\FriendsFrame\battlenet-status-offline]] @@ -353,126 +322,137 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild local bossList = {} local guildList = {} - local sort_alphabetical = function(a,b) return a[1] < b[1] end - local sort_alphabetical2 = function(a,b) return a.value < b.value end + local sortAlphabetical = function(a,b) return a.value < b.value end - local on_select = function() - if (f.Refresh) then - f:Refresh() + local onSelect = function() + if (statisticsFrame.Refresh) then + statisticsFrame:Refresh() end end --select raid: - local onRaidSelect = function(_, _, raid) - Details.rank_window.last_raid = raid - f:UpdateDropdowns (true) - on_select() - end - local buildRaidList = function() - return raidList - end - local raid_dropdown = DF:CreateDropDown (f, buildRaidList, 1, dropdownWidth, 20, "select_raid") - local raid_string = DF:CreateLabel(f, Loc ["STRING_GUILDDAMAGERANK_RAID"] .. ":", _, _, "GameFontNormal", "select_raid_label") - raid_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local onRaidSelect = function(_, _, raid) + Details.rank_window.last_raid = raid + statisticsFrame:UpdateDropdowns(true) + onSelect() + end + + local buildRaidList = function() + return raidList + end + + local raidDropdown = DF:CreateDropDown(statisticsFrame, buildRaidList, 1, dropdownWidth, 20, "select_raid") + local raidString = DF:CreateLabel(statisticsFrame, Loc ["STRING_GUILDDAMAGERANK_RAID"] .. ":", _, _, "GameFontNormal", "select_raid_label") + raidDropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) --select boss: - local on_boss_select = function(_, _, boss) - on_select() - end - local build_boss_list = function() - return bossList - end - local boss_dropdown = DF:CreateDropDown (f, build_boss_list, 1, dropdownWidth, 20, "select_boss") - local boss_string = DF:CreateLabel(f, Loc ["STRING_GUILDDAMAGERANK_BOSS"] .. ":", _, _, "GameFontNormal", "select_boss_label") - boss_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local onSelectBoss = function(_, _, boss) + onSelect() + end + + local buildBossList = function() + return bossList + end + + local bossDropdown = DF:CreateDropDown(statisticsFrame, buildBossList, 1, dropdownWidth, 20, "select_boss") + local bossString = DF:CreateLabel(statisticsFrame, Loc ["STRING_GUILDDAMAGERANK_BOSS"] .. ":", _, _, "GameFontNormal", "select_boss_label") + bossDropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) --select difficulty: - local on_diff_select = function(_, _, diff) - Details.rank_window.last_difficulty = diff - on_select() - end + local onDifficultySelect = function(_, _, diff) + Details.rank_window.last_difficulty = diff + onSelect() + end - local build_diff_list = function() - return difficultyList - end - local diff_dropdown = DF:CreateDropDown (f, build_diff_list, 1, dropdownWidth, 20, "select_diff") - local diff_string = DF:CreateLabel(f, Loc ["STRING_GUILDDAMAGERANK_DIFF"] .. ":", _, _, "GameFontNormal", "select_diff_label") - diff_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local buildDifficultyList = function() + return difficultyList + end + + local difficultyDropdown = DF:CreateDropDown(statisticsFrame, buildDifficultyList, 1, dropdownWidth, 20, "select_diff") + local difficultyString = DF:CreateLabel(statisticsFrame, Loc ["STRING_GUILDDAMAGERANK_DIFF"] .. ":", _, _, "GameFontNormal", "select_diff_label") + difficultyDropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) --select role: - local on_role_select = function(_, _, role) - on_select() - end - local build_role_list = function() - return { - {value = "damage", label = "Damager", icon = icon, onclick = on_role_select}, - {value = "healing", label = "Healer", icon = icon, onclick = on_role_select} - } - end - local role_dropdown = DF:CreateDropDown (f, build_role_list, 1, dropdownWidth, 20, "select_role") - local role_string = DF:CreateLabel(f, Loc ["STRING_GUILDDAMAGERANK_ROLE"] .. ":", _, _, "GameFontNormal", "select_role_label") - role_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local onRoleSelect = function(_, _, role) + onSelect() + end + + local buildRoleList = function() + return { + {value = "damage", label = "Damager", icon = icon, onclick = onRoleSelect}, + {value = "healing", label = "Healer", icon = icon, onclick = onRoleSelect} + } + end + + local role_dropdown = DF:CreateDropDown (statisticsFrame, buildRoleList, 1, dropdownWidth, 20, "select_role") + local role_string = DF:CreateLabel(statisticsFrame, Loc ["STRING_GUILDDAMAGERANK_ROLE"] .. ":", _, _, "GameFontNormal", "select_role_label") + role_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) --select guild: - local on_guild_select = function(_, _, guild) - on_select() - end - local build_guild_list = function() - return guildList - end - local guild_dropdown = DF:CreateDropDown (f, build_guild_list, 1, dropdownWidth, 20, "select_guild") - local guild_string = DF:CreateLabel(f, Loc ["STRING_GUILDDAMAGERANK_GUILD"] .. ":", _, _, "GameFontNormal", "select_guild_label") - guild_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local onGuildSelect = function(_, _, guild) + onSelect() + end + + local buildGuildList = function() + return guildList + end + + local guildDropdown = DF:CreateDropDown(statisticsFrame, buildGuildList, 1, dropdownWidth, 20, "select_guild") + local guildString = DF:CreateLabel(statisticsFrame, Loc ["STRING_GUILDDAMAGERANK_GUILD"] .. ":", _, _, "GameFontNormal", "select_guild_label") + guildDropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) --select playerbase: - local on_player_select = function(_, _, player) - on_select() - end - local build_player_list = function() - return { - {value = 1, label = Loc ["STRING_GUILDDAMAGERANK_PLAYERBASE_RAID"], icon = icon, onclick = on_player_select}, - {value = 2, label = Loc ["STRING_GUILDDAMAGERANK_PLAYERBASE_INDIVIDUAL"], icon = icon, onclick = on_player_select}, - } - end - local player_dropdown = DF:CreateDropDown (f, build_player_list, 1, dropdownWidth, 20, "select_player") - local player_string = DF:CreateLabel(f, Loc ["STRING_GUILDDAMAGERANK_PLAYERBASE"] .. ":", _, _, "GameFontNormal", "select_player_label") - player_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local onPlayerSelect = function(_, _, player) + onSelect() + end + + local buildPlayerList = function() + return { + {value = 1, label = Loc ["STRING_GUILDDAMAGERANK_PLAYERBASE_RAID"], icon = icon, onclick = onPlayerSelect}, + {value = 2, label = Loc ["STRING_GUILDDAMAGERANK_PLAYERBASE_INDIVIDUAL"], icon = icon, onclick = onPlayerSelect}, + } + end + + local player_dropdown = DF:CreateDropDown(statisticsFrame, buildPlayerList, 1, dropdownWidth, 20, "select_player") + local player_string = DF:CreateLabel(statisticsFrame, Loc ["STRING_GUILDDAMAGERANK_PLAYERBASE"] .. ":", _, _, "GameFontNormal", "select_player_label") + player_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) --select player: - local onPlayer2Select = function(_, _, player) - f.latest_player_selected = player - f:BuildPlayerTable (player) - end - local build_player2_list = function() - local encounterTable, guild, role = unpack(f.build_player2_data or {}) - local t = {} - local alreadyListed = {} - if (encounterTable) then - for encounterIndex, encounter in ipairs(encounterTable) do - if (encounter.guild == guild) then - local roleTable = encounter [role] - for playerName, _ in pairs(roleTable) do - if (not alreadyListed [playerName]) then - tinsert(t, {value = playerName, label = playerName, icon = icon, onclick = onPlayer2Select}) - alreadyListed [playerName] = true - end + local onPlayer2Select = function(_, _, player) + statisticsFrame.latest_player_selected = player + statisticsFrame:BuildPlayerTable(player) + end + + local buildPlayer2List = function() + local encounterTable, guild, role = unpack(statisticsFrame.build_player2_data or {}) + local t = {} + local alreadyListed = {} + if (encounterTable) then + for encounterIndex, encounter in ipairs(encounterTable) do + if (encounter.guild == guild) then + local roleTable = encounter [role] + for playerName, _ in pairs(roleTable) do + if (not alreadyListed [playerName]) then + tinsert(t, {value = playerName, label = playerName, icon = icon, onclick = onPlayer2Select}) + alreadyListed [playerName] = true end end end end - - table.sort(t, sort_alphabetical2) - return t end - local player2_dropdown = DF:CreateDropDown (f, build_player2_list, 1, dropdownWidth, 20, "select_player2") - local player2_string = DF:CreateLabel(f, Loc ["STRING_GUILDDAMAGERANK_PLAYERBASE_PLAYER"] .. ":", _, _, "GameFontNormal", "select_player2_label") - player2_dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) - function f:UpdateDropdowns(DoNotSelectRaid) + table.sort(t, sortAlphabetical) + return t + end - local currentGuild = guild_dropdown.value + local player2Dropdown = DF:CreateDropDown(statisticsFrame, buildPlayer2List, 1, dropdownWidth, 20, "select_player2") + local player2String = DF:CreateLabel(statisticsFrame, Loc ["STRING_GUILDDAMAGERANK_PLAYERBASE_PLAYER"] .. ":", _, _, "GameFontNormal", "select_player2_label") + player2Dropdown:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) - --difficulty + function statisticsFrame:UpdateDropdowns(bDoNotSelectRaid) + local currentGuild = guildDropdown.value + + --wipe data wipe(difficultyList) wipe(bossList) wipe(raidList) @@ -483,148 +463,212 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild local guildRepeated = {} local raidSelected = _G.DetailsRaidHistoryWindow.select_raid:GetValue() - db = f.OpenDB() + db = statisticsFrame.OpenDB() if (not db) then return end + --make a list of raids and bosses that belong to the current expansion + local bossIndexedTable, bossInfoTable, raidInfoTable = Details:GetExpansionBossList() + local allowedBosses = {} + for bossId, bossTable in pairs(bossInfoTable) do + allowedBosses[bossTable.dungeonEncounterID] = true --dungeonEncounterID is the id used in the encounter_start event + end + + local allowedKeysForDifficulty = { + [14] = true, --normal + [15] = true, --heroic + [16] = true, --mythic + --[17] = true, --raid finder + } + + local playerGuildName = GetGuildInfo("player") + --local playerGuildName = "Patifaria" --debug + for difficulty, encounterIdTable in pairs(db) do + if (type(difficulty) == "number" and allowedKeysForDifficulty[difficulty]) then + for dungeonEncounterID, encounterTable in pairs(encounterIdTable) do + if (allowedBosses[dungeonEncounterID]) then + if (not bossRepeated[dungeonEncounterID]) then + local encounter, instance = Details:GetBossEncounterDetailsFromEncounterId(nil, dungeonEncounterID) --deprecated - if (type(difficulty) == "number") then - if (difficulty == 14) then - --don't show normal encounters - --tinsert(difficultyList, {value = 14, label = "Normal", icon = icon, onclick = on_diff_select}) - --print("has normal encounter") + if (encounter) then + local instanceId = Details:GetInstanceIdFromEncounterId(dungeonEncounterID) + if (raidSelected == instanceId) then + tinsert(bossList, {value = dungeonEncounterID, label = encounter.boss, icon = icon, onclick = onSelectBoss}) + bossRepeated[dungeonEncounterID] = true + end - elseif (difficulty == 15) then - local alreadyHave = false - for i, t in ipairs(difficultyList) do - if (t.label == "Heroic") then - alreadyHave = true + if (not raidRepeated[instance.name]) then + local raidData + for raidInstanceID, thisRaidData in pairs(raidInfoTable) do + if (thisRaidData.raidName == instance.name) then + raidData = thisRaidData + break + end + end + + if (raidData) then + local instanceName = raidData.raidName + local raidIcon = raidData.raidIcon + local raidIconCoords = raidData.raidIconCoords + + tinsert(raidList, {value = instance.id, label = instanceName, icon = raidIcon, texcoord = raidIconCoords, onclick = onRaidSelect}) + raidRepeated[instance.name] = true + end + end + end end - end - if (not alreadyHave) then - tinsert(difficultyList, 1, {value = 15, label = "Heroic", icon = icon, onclick = on_diff_select}) - end - - elseif (difficulty == 16) then - local alreadyHave = false - for i, t in ipairs(difficultyList) do - if (t.label == "Mythic") then - alreadyHave = true + --add guild name to the dropdown + if (playerGuildName) then + if (not guildRepeated[playerGuildName]) then + tinsert(guildList, {value = playerGuildName, label = playerGuildName, icon = icon, onclick = onGuildSelect}) + guildRepeated[playerGuildName] = true + end + else + for index, encounter in ipairs(encounterTable) do + local guild = encounter.guild + if (not guildRepeated[guild]) then + tinsert(guildList, {value = guild, label = guild, icon = icon, onclick = onGuildSelect}) + guildRepeated[guild] = true + end + end end - end - if (not alreadyHave) then - tinsert(difficultyList, {value = 16, label = "Mythic", icon = icon, onclick = on_diff_select}) - end - end - - for encounterId, encounterTable in pairs(encounterIdTable) do - if (not bossRepeated[encounterId]) then - local encounter, instance = Details:GetBossEncounterDetailsFromEncounterId(nil, encounterId) - - if (encounter) then - local InstanceID = Details:GetInstanceIdFromEncounterId (encounterId) - if (raidSelected == InstanceID) then - tinsert(bossList, {value = encounterId, label = encounter.boss, icon = icon, onclick = on_boss_select}) - bossRepeated [encounterId] = true + --add the difficult to the dropdown + if (difficulty == 14) then + local alreadyHave = false + for i, t in ipairs(difficultyList) do + if (t.label == "Normal") then + alreadyHave = true + end + end + if (not alreadyHave) then + tinsert(difficultyList, 1, {value = difficulty, label = "Normal", icon = icon, onclick = onDifficultySelect}) end - if (not raidRepeated [instance.name]) then - tinsert(raidList, {value = instance.id, label = instance.name, icon = icon, onclick = onRaidSelect}) - raidRepeated [instance.name] = true + elseif (difficulty == 15) then + local alreadyHave = false + for i, t in ipairs(difficultyList) do + if (t.label == "Heroic") then + alreadyHave = true + end + end + if (not alreadyHave) then + tinsert(difficultyList, 1, {value = difficulty, label = "Heroic", icon = icon, onclick = onDifficultySelect}) end - end - end - - for index, encounter in ipairs(encounterTable) do - local guild = encounter.guild - if (not guildRepeated [guild]) then - tinsert(guildList, {value = guild, label = guild, icon = icon, onclick = on_guild_select}) - guildRepeated [guild] = true + elseif (difficulty == 16) then + local alreadyHave = false + for i, t in ipairs(difficultyList) do + if (t.label == "Mythic") then + alreadyHave = true + end + end + if (not alreadyHave) then + tinsert(difficultyList, {value = difficulty, label = "Mythic", icon = icon, onclick = onDifficultySelect}) + end end end end end end - table.sort (bossList, function(t1, t2) return t1.label < t2.label end) + table.sort(bossList, function(t1, t2) return t1.label < t2.label end) - - diff_dropdown:Refresh() - diff_dropdown:Select(1, true) - boss_dropdown:Refresh() - boss_dropdown:Select(1, true) - if (not DoNotSelectRaid) then - raid_dropdown:Refresh() - raid_dropdown:Select(1, true) + difficultyDropdown:Refresh() + guildDropdown:Refresh() + if (not bDoNotSelectRaid) then + raidDropdown:Refresh() end + bossDropdown:Refresh() - guild_dropdown:Refresh() - if (currentGuild) then - guild_dropdown:Select(currentGuild) - else - guild_dropdown:Select(1, true) - end + C_Timer.After(1, function() + if (not bDoNotSelectRaid) then + raidDropdown:Select(1, true) + end + + difficultyDropdown:Select(1, true) + + if (currentGuild) then + guildDropdown:Select(currentGuild) + else + guildDropdown:Select(1, true) + end + + bossDropdown:Select(1, true) + end) end - function f.UpdateBossDropdown() + function statisticsFrame.UpdateBossDropdown() + local allowedKeysForDifficulty = { + [14] = true, --normal + [15] = true, --heroic + [16] = true, --mythic + --[17] = true, --raid finder + } + + --make a list of raids and bosses that belong to the current expansion + local bossIndexedTable, bossInfoTable = Details:GetExpansionBossList() + local allowedBosses = {} + for bossId, bossTable in pairs(bossInfoTable) do + allowedBosses[bossTable.dungeonEncounterID] = true + end local raidSelected = DetailsRaidHistoryWindow.select_raid:GetValue() - local boss_repeated = {} - wipe (bossList) + local bossRepeated = {} + wipe(bossList) + wipe(difficultyList) for difficulty, encounterIdTable in pairs(db) do - if (type(difficulty) == "number") then - if (difficulty == 14) then - --tinsert(difficultyList, {value = 14, label = "Normal", icon = icon, onclick = on_diff_select}) - --print("has normal encounter") - elseif (difficulty == 15) then - local alreadyHave = false - for i, t in ipairs(difficultyList) do - if (t.label == "Heroic") then - alreadyHave = true - end - end - if (not alreadyHave) then - tinsert(difficultyList, 1, {value = 15, label = "Heroic", icon = icon, onclick = on_diff_select}) - end - elseif (difficulty == 16) then - local alreadyHave = false - for i, t in ipairs(difficultyList) do - if (t.label == "Mythic") then - alreadyHave = true - end - end - if (not alreadyHave) then - tinsert(difficultyList, {value = 16, label = "Mythic", icon = icon, onclick = on_diff_select}) - end - end + if (type(difficulty) == "number" and allowedKeysForDifficulty[difficulty]) then + for dungeonEncounterID, encounterTable in pairs(encounterIdTable) do + if (allowedBosses[dungeonEncounterID]) then + if (not bossRepeated[dungeonEncounterID]) then + local encounter, instance = Details:GetBossEncounterDetailsFromEncounterId(nil, dungeonEncounterID) --deprecated - for encounterId, encounterTable in pairs(encounterIdTable) do - if (not boss_repeated [encounterId]) then - local encounter, instance = Details:GetBossEncounterDetailsFromEncounterId (_, encounterId) - if (encounter) then - local InstanceID = Details:GetInstanceIdFromEncounterId (encounterId) - if (raidSelected == InstanceID) then - --[=[ - local bossIndex = Details:GetBossIndex (InstanceID, encounterId) - if (bossIndex) then - local l, r, t, b, texturePath = Details:GetBossIcon (InstanceID, bossIndex) - if (texturePath) then - tinsert(bossList, {value = encounterId, label = encounter.boss, icon = texturePath, texcoord = {l, r, t, b}, onclick = on_boss_select}) - else - tinsert(bossList, {value = encounterId, label = encounter.boss, icon = icon, onclick = on_boss_select}) - end - else - tinsert(bossList, {value = encounterId, label = encounter.boss, icon = icon, onclick = on_boss_select}) + if (encounter) then + local instanceId = Details:GetInstanceIdFromEncounterId(dungeonEncounterID) + if (raidSelected == instanceId) then + tinsert(bossList, {value = dungeonEncounterID, label = encounter.boss, icon = icon, onclick = onSelectBoss}) + bossRepeated[dungeonEncounterID] = true end - --]=] - tinsert(bossList, {value = encounterId, label = encounter.boss, icon = icon, onclick = on_boss_select}) - boss_repeated [encounterId] = true + end + end + + --add the difficult to the dropdown + if (difficulty == 14) then + local alreadyHave = false + for i, t in ipairs(difficultyList) do + if (t.label == "Normal") then + alreadyHave = true + end + end + if (not alreadyHave) then + tinsert(difficultyList, 1, {value = difficulty, label = "Normal", icon = icon, onclick = onDifficultySelect}) + end + + elseif (difficulty == 15) then + local alreadyHave = false + for i, t in ipairs(difficultyList) do + if (t.label == "Heroic") then + alreadyHave = true + end + end + if (not alreadyHave) then + tinsert(difficultyList, 1, {value = difficulty, label = "Heroic", icon = icon, onclick = onDifficultySelect}) + end + + elseif (difficulty == 16) then + local alreadyHave = false + for i, t in ipairs(difficultyList) do + if (t.label == "Mythic") then + alreadyHave = true + end + end + if (not alreadyHave) then + tinsert(difficultyList, {value = difficulty, label = "Mythic", icon = icon, onclick = onDifficultySelect}) end end end @@ -632,44 +676,43 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild end end - table.sort (bossList, function(t1, t2) return t1.label < t2.label end) - boss_dropdown:Refresh() + table.sort(bossList, function(t1, t2) return t1.label < t2.label end) + bossDropdown:Refresh() end --anchors: - raid_string:SetPoint("topleft", f, "topleft", 10, -70) - raid_dropdown:SetPoint("topleft", f, "topleft", 10, -85) + raidString:SetPoint("topleft", statisticsFrame, "topleft", 10, -70) + raidDropdown:SetPoint("topleft", statisticsFrame, "topleft", 10, -85) - boss_string:SetPoint("topleft", f, "topleft", 10, -110) - boss_dropdown:SetPoint("topleft", f, "topleft", 10, -125) + bossString:SetPoint("topleft", statisticsFrame, "topleft", 10, -110) + bossDropdown:SetPoint("topleft", statisticsFrame, "topleft", 10, -125) - diff_string:SetPoint("topleft", f, "topleft", 10, -150) - diff_dropdown:SetPoint("topleft", f, "topleft", 10, -165) + difficultyString:SetPoint("topleft", statisticsFrame, "topleft", 10, -150) + difficultyDropdown:SetPoint("topleft", statisticsFrame, "topleft", 10, -165) - role_string:SetPoint("topleft", f, "topleft", 10, -190) - role_dropdown:SetPoint("topleft", f, "topleft", 10, -205) + role_string:SetPoint("topleft", statisticsFrame, "topleft", 10, -190) + role_dropdown:SetPoint("topleft", statisticsFrame, "topleft", 10, -205) - guild_string:SetPoint("topleft", f, "topleft", 10, -230) - guild_dropdown:SetPoint("topleft", f, "topleft", 10, -245) + guildString:SetPoint("topleft", statisticsFrame, "topleft", 10, -230) + guildDropdown:SetPoint("topleft", statisticsFrame, "topleft", 10, -245) - player_string:SetPoint("topleft", f, "topleft", 10, -270) - player_dropdown:SetPoint("topleft", f, "topleft", 10, -285) + player_string:SetPoint("topleft", statisticsFrame, "topleft", 10, -270) + player_dropdown:SetPoint("topleft", statisticsFrame, "topleft", 10, -285) - player2_string:SetPoint("topleft", f, "topleft", 10, -310) - player2_dropdown:SetPoint("topleft", f, "topleft", 10, -325) - player2_string:Hide() - player2_dropdown:Hide() + player2String:SetPoint("topleft", statisticsFrame, "topleft", 10, -310) + player2Dropdown:SetPoint("topleft", statisticsFrame, "topleft", 10, -325) + player2String:Hide() + player2Dropdown:Hide() --refresh the window: - function f:BuildPlayerTable (playerName) + function statisticsFrame:BuildPlayerTable(playerName) - local encounterTable, guild, role = unpack(f.build_player2_data or {}) + local encounterTable, guild, role = unpack(statisticsFrame.build_player2_data or {}) local data = {} if (type(playerName) == "string" and string.len(playerName) > 1) then for encounterIndex, encounter in ipairs(encounterTable) do - if (encounter.guild == guild) then local roleTable = encounter [role] @@ -688,10 +731,10 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild end --update graphic - if (not f.gframe) then + if (not statisticsFrame.gframe) then local onenter = function(self) GameCooltip:Reset() - GameCooltip:SetType ("tooltip") + GameCooltip:SetType("tooltip") GameCooltip:Preset(2) GameCooltip:AddLine("Total Done:", Details:ToK2 (self.data.value), 1, "white") @@ -707,20 +750,19 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild GameCooltip:Hide() end - f.gframe = DF:CreateGFrame (f, 650, 400, 35, onenter, onleave, "gframe", "$parentGF") - f.gframe:SetPoint("topleft", f, "topleft", 190, -65) + statisticsFrame.gframe = DF:CreateGFrame(statisticsFrame, 650, 400, 35, onenter, onleave, "gframe", "$parentGF") + statisticsFrame.gframe:SetPoint("topleft", statisticsFrame, "topleft", 190, -65) end - f.gframe:Reset() - f.gframe:UpdateLines(data) + statisticsFrame.gframe:Reset() + statisticsFrame.gframe:UpdateLines(data) end end - local fillpanel = DF:NewFillPanel (f, {}, "$parentFP", "fillpanel", 710, 501, false, false, true, nil) - fillpanel:SetPoint("topleft", f, "topleft", 195, -65) + local fillpanel = DF:NewFillPanel(statisticsFrame, {}, "$parentFP", "fillpanel", 710, 501, false, false, true, nil) + fillpanel:SetPoint("topleft", statisticsFrame, "topleft", 195, -65) - - function f:BuildGuildRankTable (encounterTable, guild, role) + function statisticsFrame:BuildGuildRankTable(encounterTable, guild, role) local header = {{name = "Player Name", type = "text"}, {name = "Per Second", type = "text"}, {name = "Total", type = "text"}, {name = "Length", type = "text"}, {name = "Item Level", type = "text"}, {name = "Date", type = "text"}} local players = {} @@ -731,15 +773,14 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild --get the best of each player for encounterIndex, encounter in ipairs(encounterTable) do if (encounter.guild == guild) then - local roleTable = encounter [role] + local roleTable = encounter[role] local date = encounter.date date = date:gsub(".*%s", "") date = date:sub (1, -4) for playerName, playerTable in pairs(roleTable) do - - if (not playerScore [playerName]) then + if (not playerScore[playerName]) then playerScore [playerName] = { total = 0, ps = 0, @@ -754,13 +795,13 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild local dps = total / encounter.elapsed --if (total > playerScore [playerName].total) then - if (dps > playerScore [playerName].ps) then - playerScore [playerName].total = total - playerScore [playerName].ps = total / encounter.elapsed - playerScore [playerName].ilvl = playerTable [2] - playerScore [playerName].length = encounter.elapsed - playerScore [playerName].date = date - playerScore [playerName].class = playerTable [3] + if (dps > playerScore[playerName].ps) then + playerScore[playerName].total = total + playerScore[playerName].ps = total / encounter.elapsed + playerScore[playerName].ilvl = playerTable [2] + playerScore[playerName].length = encounter.elapsed + playerScore[playerName].date = date + playerScore[playerName].class = playerTable [3] end end end @@ -768,10 +809,10 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild local sortTable = {} for playerName, t in pairs(playerScore) do - local className = select(2, GetClassInfo (t.class or 0)) + local className = select(2, GetClassInfo(t.class or 0)) local classColor = "FFFFFFFF" if (className) then - classColor = RAID_CLASS_COLORS [className] and RAID_CLASS_COLORS [className].colorStr + classColor = RAID_CLASS_COLORS[className] and RAID_CLASS_COLORS[className].colorStr end local playerNameFormated = Details:GetOnlyName(playerName) @@ -787,26 +828,25 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild }) end - table.sort (sortTable, function(a, b) return a[8] > b[8] end) + table.sort(sortTable, function(a, b) return a[8] > b[8] end) --add the number before the player name for i = 1, #sortTable do local t = sortTable [i] - t [1] = i .. ". " .. t [1] + t[1] = i .. ". " .. t[1] end - fillpanel:SetFillFunction (function(index) return sortTable [index] end) - fillpanel:SetTotalFunction (function() return #sortTable end) - fillpanel:UpdateRows (header) + fillpanel:SetFillFunction(function(index) return sortTable [index] end) + fillpanel:SetTotalFunction(function() return #sortTable end) + fillpanel:UpdateRows(header) fillpanel:Refresh() - f.LatestResourceTable = sortTable + statisticsFrame.LatestResourceTable = sortTable end - function f:BuildRaidTable (encounterTable, guild, role) - - if (f.Mode == 2) then - f:BuildGuildRankTable (encounterTable, guild, role) + function statisticsFrame:BuildRaidTable(encounterTable, guild, role) + if (statisticsFrame.Mode == 2) then + statisticsFrame:BuildGuildRankTable(encounterTable, guild, role) return end @@ -876,111 +916,110 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild fillpanel:UpdateRows (header) fillpanel:Refresh() - fillpanel:SetPoint("topleft", f, "topleft", 200, -65) + fillpanel:SetPoint("topleft", statisticsFrame, "topleft", 200, -65) end - function f:Refresh (player_name) + function statisticsFrame:Refresh (player_name) --build the main table - local diff = diff_dropdown.value - local boss = boss_dropdown.value + local diff = difficultyDropdown.value + local boss = bossDropdown.value local role = role_dropdown.value - local guild = guild_dropdown.value + local guild = guildDropdown.value local player = player_dropdown.value local diffTable = db [diff] - f:SetBackgroundImage (boss) - --Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild, _player_base, _player_name) + statisticsFrame:SetBackgroundImage(boss) if (diffTable) then - local encounters = diffTable [boss] + local encounters = diffTable[boss] if (encounters) then if (player == 1) then --raid fillpanel:Show() - if (f.gframe) then - f.gframe:Hide() + if (statisticsFrame.gframe) then + statisticsFrame.gframe:Hide() end - player2_string:Hide() - player2_dropdown:Hide() - f:BuildRaidTable (encounters, guild, role) + player2String:Hide() + player2Dropdown:Hide() + statisticsFrame:BuildRaidTable(encounters, guild, role) elseif (player == 2) then --only one player fillpanel:Hide() - if (f.gframe) then - f.gframe:Show() + if (statisticsFrame.gframe) then + statisticsFrame.gframe:Show() end - player2_string:Show() - player2_dropdown:Show() - f.build_player2_data = {encounters, guild, role} - player2_dropdown:Refresh() + player2String:Show() + player2Dropdown:Show() + statisticsFrame.build_player2_data = {encounters, guild, role} + player2Dropdown:Refresh() - player_name = f.latest_player_selected or player_name + player_name = statisticsFrame.latest_player_selected or player_name if (player_name) then - player2_dropdown:Select(player_name) + player2Dropdown:Select(player_name) else - player2_dropdown:Select(1, true) + player2Dropdown:Select(1, true) end - f:BuildPlayerTable (player2_dropdown.value) + statisticsFrame:BuildPlayerTable (player2Dropdown.value) end else if (player == 1) then --raid fillpanel:Show() - if (f.gframe) then - f.gframe:Hide() + if (statisticsFrame.gframe) then + statisticsFrame.gframe:Hide() end - player2_string:Hide() - player2_dropdown:Hide() - f:BuildRaidTable ({}, guild, role) + player2String:Hide() + player2Dropdown:Hide() + statisticsFrame:BuildRaidTable ({}, guild, role) elseif (player == 2) then --only one player fillpanel:Hide() - if (f.gframe) then - f.gframe:Show() + if (statisticsFrame.gframe) then + statisticsFrame.gframe:Show() end - player2_string:Show() - player2_dropdown:Show() - f.build_player2_data = {{}, guild, role} - player2_dropdown:Refresh() - player2_dropdown:Select(1, true) - f:BuildPlayerTable (player2_dropdown.value) + player2String:Show() + player2Dropdown:Show() + statisticsFrame.build_player2_data = {{}, guild, role} + player2Dropdown:Refresh() + player2Dropdown:Select(1, true) + statisticsFrame:BuildPlayerTable (player2Dropdown.value) end end end end - f.FirstRun = true + statisticsFrame.FirstRun = true end --end of DetailsRaidHistoryWindow creation local statsWindow = _G.DetailsRaidHistoryWindow --table means some button send the request - nil for other ways - if (type(_raid) == "table" or (not _raid and not _boss and not _difficulty and not _role and not _guild and not _player_base and not _player_name)) then + if (type(raidName) == "table" or (not raidName and not bossEncounterId and not difficultyId and not playerRole and not guildName and not playerBase and not playerName)) then local f = statsWindow if (f.LatestSelection) then - _raid = f.LatestSelection.Raid - _boss = f.LatestSelection.Boss - _difficulty = f.LatestSelection.Diff - _role = f.LatestSelection.Role - _guild = f.LatestSelection.Guild - _player_base = f.LatestSelection.PlayerBase - _player_name = f.LatestSelection.PlayerBase + raidName = f.LatestSelection.Raid + bossEncounterId = f.LatestSelection.Boss + difficultyId = f.LatestSelection.Diff + playerRole = f.LatestSelection.Role + guildName = f.LatestSelection.Guild + playerBase = f.LatestSelection.PlayerBase + playerName = f.LatestSelection.PlayerBase end end if (statsWindow.FirstRun) then - _difficulty = Details.rank_window.last_difficulty or _difficulty + difficultyId = Details.rank_window.last_difficulty or difficultyId if (IsInGuild()) then local guildName = GetGuildInfo("player") if (guildName) then - _guild = guildName + guildName = guildName end end if (Details.rank_window.last_raid ~= "") then - _raid = Details.rank_window.last_raid or _raid + raidName = Details.rank_window.last_raid or raidName end end @@ -993,8 +1032,8 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild statsWindow:Refresh() statsWindow:Show() - if (_history_type == 1 or _history_type == 2) then - statsWindow.Mode = _history_type + if (historyType == 1 or historyType == 2) then + statsWindow.Mode = historyType if (statsWindow.Mode == 1) then --overall statsWindow.HistoryCheckBox:SetValue(true) @@ -1006,44 +1045,44 @@ function Details:OpenRaidHistoryWindow (_raid, _boss, _difficulty, _role, _guild end end - if (_raid) then - statsWindow.select_raid:Select(_raid) + if (raidName) then + statsWindow.select_raid:Select(raidName) statsWindow:Refresh() statsWindow.UpdateBossDropdown() end - if (_boss) then - statsWindow.select_boss:Select(_boss) + if (bossEncounterId) then + statsWindow.select_boss:Select(bossEncounterId) statsWindow:Refresh() end - if (_difficulty) then - statsWindow.select_diff:Select(_difficulty) + if (difficultyId) then + statsWindow.select_diff:Select(difficultyId) statsWindow:Refresh() end - if (_role) then - statsWindow.select_role:Select(_role) + if (playerRole) then + statsWindow.select_role:Select(playerRole) statsWindow:Refresh() end - if (_guild) then - if (type(_guild) == "boolean") then - _guild = GetGuildInfo ("player") + if (guildName) then + if (type(guildName) == "boolean") then + guildName = GetGuildInfo("player") end - statsWindow.select_guild:Select(_guild) + statsWindow.select_guild:Select(guildName) statsWindow:Refresh() end - if (_player_base) then - statsWindow.select_player:Select(_player_base) + if (playerBase) then + statsWindow.select_player:Select(playerBase) statsWindow:Refresh() end - if (_player_name) then + if (playerName) then statsWindow.select_player2:Refresh() - statsWindow.select_player2:Select(_player_name) - statsWindow:Refresh (_player_name) + statsWindow.select_player2:Select(playerName) + statsWindow:Refresh (playerName) end DetailsPluginContainerWindow.OpenPlugin(statsWindow) diff --git a/functions/boss.lua b/functions/boss.lua index 4b2d6ef8..66daeaf9 100644 --- a/functions/boss.lua +++ b/functions/boss.lua @@ -5,10 +5,10 @@ do local addonName, Details222 = ... _detalhes.EncounterInformation = {} local ipairs = ipairs --lua local - + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --details api functions - + --return if the player is inside a raid supported by details function _detalhes:IsInInstance() local _, _, _, _, _, _, _, zoneMapID = GetInstanceInfo() @@ -40,12 +40,12 @@ do end end end - + --return the ids of trash mobs in the instance function _detalhes:GetInstanceTrashInfo (mapid) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].trash_ids end - + function _detalhes:GetInstanceIdFromEncounterId (encounterid) for id, instanceTable in pairs(_detalhes.EncounterInformation) do --combatlog encounter id @@ -64,7 +64,7 @@ do end end end - + --return the boss table using a encounter id function _detalhes:GetBossEncounterDetailsFromEncounterId (mapid, encounterid) if (not mapid) then @@ -79,17 +79,17 @@ do end end end - + if (instance) then local bosses = instance.encounters if (bosses) then return bosses [bossIndex], instance end end - + return end - + local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid] if (bossindex) then return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex], bossindex @@ -100,12 +100,12 @@ do end end end - + --return the EJ boss id function _detalhes:GetEncounterIdFromBossIndex (mapid, index) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [index] end - + --return the table which contain information about the start of a encounter function _detalhes:GetEncounterStartInfo (mapid, encounterid) local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid] @@ -113,7 +113,7 @@ do return _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].encounter_start end end - + --return the table which contain information about the end of a encounter function _detalhes:GetEncounterEndInfo (mapid, encounterid) local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid] @@ -121,7 +121,7 @@ do return _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].encounter_end end end - + --return the function for the boss function _detalhes:GetEncounterEnd (mapid, bossindex) local t = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] @@ -131,52 +131,52 @@ do return unpack(_end) end end - return + return end - + --generic boss find function function _detalhes:GetRaidBossFindFunction (mapid) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].find_boss_encounter end - + --return if the boss need sync function _detalhes:GetEncounterEqualize (mapid, bossindex) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].equalize end - + --return the function for the boss function _detalhes:GetBossFunction (mapid, bossindex) local func = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].func if (func) then return func, _detalhes.EncounterInformation [mapid].encounters [bossindex].funcType end - return + return end - + --return the boss table with information about name, adds, spells, etc function _detalhes:GetBossDetails (mapid, bossindex) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] end - + --return a table with all names of boss enemies function _detalhes:GetEncounterActors (mapid, bossindex) - + end - + --return a table with spells id of specified encounter function _detalhes:GetEncounterSpells (mapid, bossindex) local encounter = _detalhes:GetBossDetails (mapid, bossindex) local habilidades_poll = {} if (encounter.continuo) then - for index, spellid in ipairs(encounter.continuo) do + for index, spellid in ipairs(encounter.continuo) do habilidades_poll [spellid] = true end end local fases = encounter.phases if (fases) then - for fase_id, fase in ipairs(fases) do + for fase_id, fase in ipairs(fases) do if (fase.spells) then - for index, spellid in ipairs(fase.spells) do + for index, spellid in ipairs(fase.spells) do habilidades_poll [spellid] = true end end @@ -184,34 +184,34 @@ do end return habilidades_poll end - + --return a table with all boss ids from a raid instance function _detalhes:GetBossIds (mapid) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_ids end - + function _detalhes:InstanceIsRaid (mapid) return _detalhes:InstanceisRaid (mapid) end function _detalhes:InstanceisRaid (mapid) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].is_raid end - + --return a table with all encounter names present in raid instance function _detalhes:GetBossNames (mapid) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_names end - + --return the encounter name function _detalhes:GetBossName (mapid, bossindex) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_names [bossindex] end - + --same thing as GetBossDetails, just a alias function _detalhes:GetBossEncounterDetails (mapid, bossindex) return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] end - + function _detalhes:GetEncounterInfoFromEncounterName (EJID, encountername) DetailsFramework.EncounterJournal.EJ_SelectInstance (EJID) for i = 1, 20 do @@ -224,7 +224,7 @@ do end end end - + --return the wallpaper for the raid instance function _detalhes:GetRaidBackground (mapid) local bosstables = _detalhes.EncounterInformation [mapid] @@ -241,7 +241,7 @@ do if (raidIcon) then return raidIcon end - + if (ejID and ejID ~= 0) then local name, description, bgImage, buttonImage, loreImage, dungeonAreaMapID, link = DetailsFramework.EncounterJournal.EJ_GetInstanceInfo (ejID) if (name) then @@ -252,10 +252,10 @@ do end end end - + return nil end - + function _detalhes:GetBossIndex (mapid, encounterCLID, encounterEJID, encounterName) local raidInfo = _detalhes.EncounterInformation [mapid] if (raidInfo) then @@ -271,7 +271,7 @@ do return index end end - + --return the boss icon function _detalhes:GetBossIcon (mapid, bossindex) if (_detalhes.EncounterInformation [mapid]) then @@ -280,7 +280,7 @@ do return x-0.25, x, 0.25 * (line-1), 0.25 * line, _detalhes.EncounterInformation [mapid].icons end end - + --return the boss portrit function _detalhes:GetBossPortrait(mapid, bossindex, encounterName, ejID) if (mapid and bossindex) then @@ -289,7 +289,7 @@ do return haveIcon end end - + if (encounterName and ejID and ejID ~= 0) then local index, name, description, encounterID, rootSectionID, link = _detalhes:GetEncounterInfoFromEncounterName (ejID, encounterName) if (index and name and encounterID) then @@ -299,20 +299,20 @@ do end end end - + return nil end - + --return a list with names of adds and bosses function _detalhes:GetEncounterActorsName (EJ_EncounterID) --code snippet from wowpedia local actors = {} local stack, encounter, _, _, curSectionID = {}, DetailsFramework.EncounterJournal.EJ_GetEncounterInfo (EJ_EncounterID) - + if (not curSectionID) then return actors end - + repeat local title, description, depth, abilityIcon, displayInfo, siblingID, nextSectionID, filteredByDifficulty, link, startsOpen, flag1, flag2, flag3, flag4 = DetailsFramework.EncounterJournal.EJ_GetSectionInfo (curSectionID) if (displayInfo ~= 0 and abilityIcon == "") then @@ -322,10 +322,10 @@ do table.insert(stack, nextSectionID) curSectionID = table.remove (stack) until not curSectionID - + return actors end - + function _detalhes:GetInstanceEJID (mapid) mapid = mapid or select(8, GetInstanceInfo()) if (mapid) then @@ -336,31 +336,31 @@ do end return 0 end - + function _detalhes:GetCurrentDungeonBossListFromEJ() - + local mapID = C_Map.GetBestMapForUnit ("player") - + if (not mapID) then --print("Details! exeption handled: zone has no map") return end - + local EJ_CInstance = DetailsFramework.EncounterJournal.EJ_GetInstanceForMap(mapID) - + if (EJ_CInstance and EJ_CInstance ~= 0) then if (_detalhes.encounter_dungeons [EJ_CInstance]) then return _detalhes.encounter_dungeons [EJ_CInstance] end - + DetailsFramework.EncounterJournal.EJ_SelectInstance (EJ_CInstance) - + local name, description, bgImage, buttonImage, loreImage, dungeonAreaMapID, link = DetailsFramework.EncounterJournal.EJ_GetInstanceInfo (EJ_CInstance) - + local boss_list = { [EJ_CInstance] = {name, description, bgImage, buttonImage, loreImage, dungeonAreaMapID, link} } - + for i = 1, 20 do local encounterName, description, encounterID, rootSectionID, link = DetailsFramework.EncounterJournal.EJ_GetEncounterInfoByIndex (i, EJ_CInstance) if (encounterName) then @@ -378,15 +378,72 @@ do end _detalhes.encounter_dungeons [EJ_CInstance] = boss_list - + return boss_list end end - - function _detalhes:IsRaidRegistered (mapid) + + function _detalhes:IsRaidRegistered(mapid) return _detalhes.EncounterInformation [mapid] and true end - + + + function Details:GetExpansionBossList() --~bosslist + local bossIndexedTable = {} + local bossInfoTable = {} --[bossId] = bossInfo + local raidInfoTable = {} + + if (not EncounterJournal) then + EncounterJournal_LoadUI() + end + + for instanceIndex = 10, 2, -1 do + local raidInstanceID, instanceName, description, bgImage, buttonImage1, loreImage, buttonImage2, dungeonAreaMapID = EJ_GetInstanceByIndex(instanceIndex, true) + if (raidInstanceID) then + EncounterJournal_DisplayInstance(raidInstanceID) + + raidInfoTable[raidInstanceID] = { + raidName = instanceName, + raidIcon = buttonImage1, + raidIconCoords = {0.01, .67, 0.025, .725}, + raidIconSize = {70, 36}, + raidIconTexture = buttonImage2, + raidIconTextureCoords = {0, 1, 0, 0.95}, + raidIconTextureSize = {70, 36}, + raidIconLore = loreImage, + raidIconLoreCoords = {0, 1, 0, 0.95}, + raidIconLoreSize = {70, 36}, + raidMapID = dungeonAreaMapID, + raidEncounters = {}, + } + + for i = 20, 1, -1 do + local name, description, journalEncounterID, rootSectionID, link, journalInstanceID, dungeonEncounterID, UiMapID = _G.EJ_GetEncounterInfoByIndex(i, raidInstanceID) + if (name) then + local id, creatureName, creatureDescription, displayInfo, iconImage = EJ_GetCreatureInfo(1, journalEncounterID) + local thisbossIndexedTable = { + bossName = name, + journalEncounterID = journalEncounterID, + bossRaidName = instanceName, + bossIcon = iconImage, + bossIconCoords = {0, 1, 0, 0.95}, + bossIconSize = {70, 36}, + instanceId = raidInstanceID, + uiMapId = UiMapID, + instanceIndex = instanceIndex, + journalInstanceId = journalInstanceID, + dungeonEncounterID = dungeonEncounterID, + } + bossIndexedTable[#bossIndexedTable+1] = thisbossIndexedTable + bossInfoTable[journalEncounterID] = thisbossIndexedTable + end + end + end + end + + return bossIndexedTable, bossInfoTable, raidInfoTable + end + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --core @@ -395,5 +452,3 @@ do return true end end - ---functionas diff --git a/functions/raidinfo.lua b/functions/raidinfo.lua index 5ed54b38..85edae50 100644 --- a/functions/raidinfo.lua +++ b/functions/raidinfo.lua @@ -1,5 +1,4 @@ - --install data for raiding tiers local C_Timer = _G.C_Timer @@ -8,6 +7,81 @@ local tinsert = _G.tinsert local addonName, Details222 = ... function Details.InstallRaidInfo() + do + local INSTANCE_EJID = 1200 + local INSTANCE_MAPID = 2522 + local HDIMAGESPATH = [[Details\images\raid]] + local HDFILEPREFIX = 'VaultoftheIncarnatesRaid' + local EJ_LOREBG = 'UI-EJ-LOREBG-VaultoftheIncarnates' + + local ENCOUNTER_ID_CL = { + [2587] = 1, --Eranog + [2639] = 2, --Terros + [2590] = 3, --The Primal Council + [2592] = 4, --Sennarth, the Cold Breath + [2635] = 5, --Dathea, Ascended + [2605] = 6, --Kurog Grimtotem + [2614] = 7, --Broodkeeper Diurna + [2607] = 8, --Raszageth the Storm-Eater + 2587, 2639, 2590, 2592, 2635, 2605, 2614, 2607, + } + + local ENCOUNTER_ID_EJ = { + [2480] = 1, --Eranog + [2500] = 2, --Terros + [2486] = 3, --The Primal Council + [2482] = 4, --Sennarth, the Cold Breath + [2502] = 5, --Dathea, Ascended + [2491] = 6, --Kurog Grimtotem + [2493] = 7, --Broodkeeper Diurna + [2499] = 8, --Raszageth the Storm-Eater + 2480, 2500, 2486, 2482, 2502, 2491, 2493, 2499, + } + + local BOSSNAMES = { + "Eranog", --1 + "Terros", --2 + "The Primal Council", --3 + "Sennarth, the Cold Breath", --4 + "Dathea, Ascended", --5 + "Kurog Grimtotem", --6 + "Broodkeeper Diurna", --7 + "Raszageth the Storm-Eater", --8 + } + + local ENCOUNTERS = { + {boss = "Eranog", portrait = 4757695}, + {boss = "Terros", portrait = 4757701}, + {boss = "The Primal Council", portrait = 4757702}, + {boss = "Sennarth, the Cold Breath", portrait = 4757699}, + {boss = "Dathea, Ascended", portrait = 4757694}, + {boss = "Kurog Grimtotem", portrait = 4757696}, + {boss = "Broodkeeper Diurna", portrait = 4757693}, + {boss = "Raszageth the Storm-Eater", portrait = 4757698}, + } + + --load encounter journal + DetailsFramework.EncounterJournal.EJ_SelectInstance(INSTANCE_EJID) + local InstanceName = DetailsFramework.EncounterJournal.EJ_GetInstanceInfo(INSTANCE_EJID) + + Details:InstallEncounter({ + id = INSTANCE_MAPID, --map id + ej_id = INSTANCE_EJID, --encounter journal id + name = InstanceName, + icons = "Interface\\AddOns\\" .. HDIMAGESPATH .. "\\" .. HDFILEPREFIX .. "_BossFaces", + icon = "Interface\\AddOns\\" .. HDIMAGESPATH .. "\\" .. HDFILEPREFIX .. "_Icon256x128", + is_raid = true, + backgroundEJ = "Interface\\EncounterJournal\\" .. EJ_LOREBG, + encounter_ids = ENCOUNTER_ID_EJ, + encounter_ids2 = ENCOUNTER_ID_CL, + boss_names = BOSSNAMES, + encounters = ENCOUNTERS, + boss_ids = { + --npc ids + }, + }) + + end do --data for Sanctum of Domination (Shadowlands tier 1) diff --git a/images/raid/CastleNathriaRaid_BossFaces.tga b/images/raid/CastleNathriaRaid_BossFaces.tga deleted file mode 100644 index 95751a8f..00000000 Binary files a/images/raid/CastleNathriaRaid_BossFaces.tga and /dev/null differ diff --git a/images/raid/CastleNathriaRaid_Icon256x128.tga b/images/raid/CastleNathriaRaid_Icon256x128.tga deleted file mode 100644 index 5b934796..00000000 Binary files a/images/raid/CastleNathriaRaid_Icon256x128.tga and /dev/null differ diff --git a/images/raid/VaultoftheIncarnatesRaid_BossFaces.tga b/images/raid/VaultoftheIncarnatesRaid_BossFaces.tga new file mode 100644 index 00000000..34129a33 Binary files /dev/null and b/images/raid/VaultoftheIncarnatesRaid_BossFaces.tga differ diff --git a/images/raid/VaultoftheIncarnatesRaid_Icon256x128.tga b/images/raid/VaultoftheIncarnatesRaid_Icon256x128.tga new file mode 100644 index 00000000..ddd4e806 Binary files /dev/null and b/images/raid/VaultoftheIncarnatesRaid_Icon256x128.tga differ