More progress on caching stuff; journal links; cooltip hotfixes; code cleanups

This commit is contained in:
Tercio Jose
2022-12-23 20:33:29 -03:00
parent ce9a3b875b
commit 7d5d80073b
10 changed files with 416 additions and 161 deletions
+16 -3
View File
@@ -547,6 +547,8 @@ do
EncounterJournal_LoadUI()
end
hooksecurefunc("EncounterJournal_OpenJournalLink", Details222.EJCache.OnClickEncounterJournalLink)
do
--iterate among all raid instances, by passing true in the second argument of EJ_GetInstanceByIndex, indicates to the API we want to get raid instances
local bGetRaidInstances = true
@@ -770,9 +772,20 @@ do
end
--reset the dungeon journal to the default state
if (EncounterJournalSuggestTab) then
EncounterJournalSuggestTab:Click()
end
C_Timer.After(0.5, function()
EncounterJournal_ResetDisplay(nil, "none")
end)
C_Timer.After(1, function()
if (EncounterJournalSuggestTab) then
EncounterJournalSuggestTab:Click()
end
end)
--EncounterJournal_OpenJournalLink(tag, jtype, id, difficultyID)
--EncounterJournal_OpenJournal(difficultyID, instanceID, encounterID, sectionID, creatureID, itemID, tierIndex)
--local tooltipInfo = CreateBaseTooltipInfo("GetHyperlink", link, classID, specID);
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+141
View File
@@ -0,0 +1,141 @@
local Details = _G.Details
local DF = _G.DetailsFramework
local C_Timer = _G.C_Timer
local addonName, Details222 = ...
--get the sectionInfo and try to extract the spellID from it
--sectionInfo is always a valid table
local parseSectionInfoForSpellID = function(sectionInfo)
local spellId = sectionInfo.spellID
if (spellId) then
spellId = tonumber(spellId)
if (spellId) then
local spellName = GetSpellInfo(spellId)
if (spellName) then
return spellId
end
end
end
end
--this function is called when the player clicks on a link in the chat window to open a section in the encounter journal
function Details222.EJCache.OnClickEncounterJournalLink(tag, journalType, id, difficultyId)
journalType = tonumber(journalType)
id = tonumber(id)
difficultyId = tonumber(difficultyId)
local instanceId, encounterId, sectionId, tierIndex = EJ_HandleLinkPath(journalType, id)
if (sectionId) then
local sectionInfo = C_EncounterJournal.GetSectionInfo(sectionId)
if (sectionInfo and type(sectionInfo) == "table") then
local spellId = parseSectionInfoForSpellID(sectionInfo)
--spellId is guaranteed to be a valid spellId or nil
if (spellId) then
local damageDoneTable = Details222.DamageSpells.GetDamageDoneToPlayersBySpell(spellId)
local topDamage = damageDoneTable[1] and damageDoneTable[1][2]
if (topDamage and topDamage > 0) then
--build a cooltip with the damage done to players by the spellId
local gameCooltip = GameCooltip
gameCooltip:Preset(2)
gameCooltip:SetType("tooltip")
gameCooltip:SetOption("LeftPadding", -5)
gameCooltip:SetOption("RightPadding", 5)
gameCooltip:SetOption("LinePadding", 1)
gameCooltip:SetOption("StatusBarTexture", [[Interface\AddOns\Details\images\bar_hyanda]])
for i = 1, #damageDoneTable do
local targetName, damageDone = unpack(damageDoneTable[i])
local nameWithoutRealm = DF:RemoveRealmName(targetName)
local formattedDamage = Details:ToK2(damageDone)
local className = Details222.ClassCache.GetClass(targetName)
local classTexture, left, right, top, bottom = Details:GetClassIcon(className)
gameCooltip:AddLine(nameWithoutRealm, formattedDamage)
gameCooltip:AddIcon(classTexture, 1, 1, 14, 14, left, right, top, bottom)
gameCooltip:AddStatusBar(damageDone / topDamage * 100, 1, .5, .5, .5, 1, false, {value = 100, color = {.2, .2, .2, 0.9}, texture = [[Interface\AddOns\Details\images\bar_hyanda]]})
end
local abilityString = DF:MakeStringFromSpellId(spellId)
if (abilityString) then
abilityString = abilityString .. " (damage to)"
end
local anchor = {"bottom", "top", 0, 0}
gameCooltip:SetBannerImage(1, 2, [[Interface\PetBattles\Weather-Blizzard]], 220, 55, anchor, {0.85, 0.189609375, 1, 0}, {0, 0, 0, 1})
gameCooltip:SetBannerText(1, 2, abilityString or "Ability Damage Done", {"bottomleft", "topleft", 0, 2}, "white", 14)
gameCooltip:SetOwner(EncounterJournal, "topleft", "topright", 50, -10)
gameCooltip:Show()
end
end
end
end
if (not Details222.EJCache.HasJournalOnHideHooked) then
Details222.EJCache.HasJournalOnHideHooked = true
EncounterJournal:HookScript("OnHide", function()
GameCooltip:Hide()
end)
end
end
--search the damage container within the combatObject index[1] for actor that used the spellId passed and inflicted damage to players
---@param spellId number
---@param combatId any
---@return table
function Details222.DamageSpells.GetDamageDoneToPlayersBySpell(spellId, combatId)
local combatObject = Details:GetCombat(combatId)
if (not combatObject) then
return {}
end
local damageContainer = combatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE)
if (not damageContainer) then
return {}
end
local damageDoneTable = {}
for index, actorObject in damageContainer:ListActors() do
if (actorObject:IsNeutralOrEnemy()) then
local spellTable = actorObject:GetSpell(spellId)
if (spellTable) then
for targetName, damageDone in pairs(spellTable.targets) do
damageDoneTable[targetName] = (damageDoneTable[targetName] or 0) + damageDone
end
end
end
end
local sortedResult = {}
for targetName, damageDone in pairs(damageDoneTable) do
local className = Details222.ClassCache.GetClass(targetName)
sortedResult[#sortedResult + 1] = {targetName, damageDone, className}
end
table.sort(sortedResult, function(a, b) return a[2] > b[2] end)
return sortedResult
end
--[=[
["description"] = "Eranog wreathes several players in flames. Upon expiration a Flamerift forms at each player's location, inflicting 144,550 Fire damage to players within 4 yards.
A Flamescale Tarasek spills forth from each Flamerift, leaving behind a Lava Flow.
On Mythic difficulty, Eranog also opens a Greater Flamerift that creates a Flamescale Captain.",
["link"] = "[Flamerift]",
["siblingSectionID"] = 26037,
["startsOpen"] = false,
["creatureDisplayID"] = 0,
["headerType"] = 2,
["title"] = "Flamerift",
["firstChildSectionID"] = 26036,
["uiModelSceneID"] = 0,
["filteredByDifficulty"] = false,
["abilityIcon"] = 134153,
["spellID"] = 390715,
--]=]
+12 -12
View File
@@ -72,28 +72,28 @@ do
return [[Interface\AddOns\Details\images\icons2]], unpack(roles [role])
end
function _detalhes:GetClassIcon (class)
local c
function _detalhes:GetClassIcon(class)
if (self.classe) then
c = self.classe
class = self.classe
elseif (type(class) == "table" and class.classe) then
c = class.classe
class = class.classe
elseif (type(class) == "string") then
c = class
class = class
else
c = "UNKNOW"
class = "UNKNOW"
end
if (c == "UNKNOW") then
if (class == "UNKNOW") then
return [[Interface\LFGFRAME\LFGROLE_BW]], 0.25, 0.5, 0, 1
elseif (c == "UNGROUPPLAYER") then
elseif (class == "UNGROUPPLAYER") then
return [[Interface\ICONS\Achievement_Character_Orc_Male]], 0, 1, 0, 1
elseif (c == "PET") then
elseif (class == "PET") then
return [[Interface\AddOns\Details\images\classes_small]], 0.25, 0.49609375, 0.75, 1
else
return [[Interface\AddOns\Details\images\classes_small]], unpack(_detalhes.class_coords [c])
return [[Interface\AddOns\Details\images\classes_small]], unpack(_detalhes.class_coords[class])
end
end