From 56275fecf9df6ef39583d0fc225ab6f4d7b647a6 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Wed, 5 Jul 2023 00:24:08 -0300 Subject: [PATCH] Added Details:GetBossEncounterTexture(encounterName); Added combat.bossIcon; Added combat.bossTimers --- Definitions.lua | 1 + classes/class_combat.lua | 2 + core/parser.lua | 3 ++ core/plugins.lua | 3 -- .../window_playerbreakdown.lua | 3 ++ functions/boss.lua | 53 +++++++++++++++++++ functions/bossmods.lua | 9 ++++ functions/profiles.lua | 3 ++ 8 files changed, 74 insertions(+), 3 deletions(-) diff --git a/Definitions.lua b/Definitions.lua index 3ea472f6..2454053b 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -117,6 +117,7 @@ ---@field is_boss table ---@field is_world_trash_combat boolean when true this combat is a regular combat done in the world, not in a dungeon, raid, battleground, arena, ... ---@field player_last_events table record the latest events of each player, latter used to build the death log +---@field GetCombatUID fun(combat: combat) : uniquecombatid ---@field GetTimeData fun(combat: combat, dataName: string) : table ---@field GetPhases fun(combat: combat) : table ---@field GetCombatTime fun(combat) : number diff --git a/classes/class_combat.lua b/classes/class_combat.lua index a0b5a3f3..ad0507b3 100644 --- a/classes/class_combat.lua +++ b/classes/class_combat.lua @@ -626,6 +626,8 @@ function classCombat:NovaTabela(bTimeStarted, overallCombatObject, combatId, ... combatObject.data_inicio = 0 combatObject.tempo_start = _tempo + combatObject.bossTimers = {} + ---store trinket procs combatObject.trinketProcs = {} diff --git a/core/parser.lua b/core/parser.lua index f24a1b8f..dcfaf0d4 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -5072,6 +5072,9 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 local _, _, _, _, _, _, _, zoneMapID = GetInstanceInfo() + local bossIcon = Details:GetBossEncounterTexture(encounterName) + _current_combat.bossIcon = bossIcon + if (_in_combat) then if (endStatus == 1) then Details.encounter_table.kill = true diff --git a/core/plugins.lua b/core/plugins.lua index c69eb867..0e5a0fad 100644 --- a/core/plugins.lua +++ b/core/plugins.lua @@ -633,9 +633,6 @@ end local highlightPluginButtonOnBreakdownWindow = function(pluginAbsoluteName) - ---@type breakdownwindow - local breakdownWindowFrame = Details.BreakdownWindowFrame - for index, button in ipairs(breakdownWindowFrame.RegisteredPluginButtons) do ---@cast button df_button button:Show() diff --git a/frames/window_breakdown/window_playerbreakdown.lua b/frames/window_breakdown/window_playerbreakdown.lua index b0ba118d..4449d4fc 100644 --- a/frames/window_breakdown/window_playerbreakdown.lua +++ b/frames/window_breakdown/window_playerbreakdown.lua @@ -24,6 +24,7 @@ breakdownWindowFrame.RegisteredPluginButtons = {} ---register a plugin button to be shown in the breakdown window ---@param button button function breakdownWindowFrame.RegisterPluginButton(button) + button:SetParent(DetailsBreakdownLeftMenuPluginsFrame) table.insert(breakdownWindowFrame.RegisteredPluginButtons, button) end @@ -51,6 +52,8 @@ breakdownWindowFrame.BreakdownSideMenuFrame = breakdownSideMenu local pluginsFrame = CreateFrame("frame", "DetailsBreakdownLeftMenuPluginsFrame", breakdownSideMenu, "BackdropTemplate") breakdownWindowFrame.BreakdownPluginSelectionFrame = pluginsFrame + + --create the frame to hold tab buttons local tabButtonsFrame = CreateFrame("frame", "DetailsBreakdownTabsFrame", breakdownWindowFrame, "BackdropTemplate") breakdownWindowFrame.BreakdownTabsFrame = tabButtonsFrame diff --git a/functions/boss.lua b/functions/boss.lua index 9f3dc496..409481d4 100644 --- a/functions/boss.lua +++ b/functions/boss.lua @@ -5,6 +5,7 @@ do local addonName, Details222 = ... Details.EncounterInformation = {} local ipairs = ipairs --lua local + local detailsFramework = DetailsFramework ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --details api functions @@ -212,7 +213,59 @@ do return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex] end + ---return a textureId, width, height, left, right, top, bottom coords + ---@param encounterName string + ---@return any + ---@return width + ---@return height + ---@return number + ---@return number + ---@return number + ---@return number + function Details:GetBossEncounterTexture(encounterName) + assert(type(encounterName) == "string", "bad argument #1 to 'GetBossEncounterTexture' (string expected, got " .. type(encounterName) .. ")") + encounterName = string.lower(encounterName) + if (Details.boss_icon_cache[encounterName]) then + return Details.boss_icon_cache[encounterName], 32, 20, 0, 1, 0, 0.9 + end + + local EJ_GetInstanceByIndex = EJ_GetInstanceByIndex or function(instanceIndex, bIsRaidInstance) return nil end + local EJ_GetEncounterInfoByIndex = EJ_GetEncounterInfoByIndex or function(index, instanceID) return nil end + local EJ_GetCreatureInfo = EJ_GetCreatureInfo or function(index, bossId) return nil end + + ---@type boolean + local bIsRaidInstance = true + + ---starts on DragonIsles world bosses > Vault of Incarnates > Aberrus, The Shadowed Crucible + ---could go to 10 for less maintenance + ---@type number + local maxInstancesInCurrentPath = 3 + for instanceIndex = 1, maxInstancesInCurrentPath do + local instanceID = EJ_GetInstanceByIndex(instanceIndex, bIsRaidInstance) + if (instanceID) then + detailsFramework.EncounterJournal.EJ_SelectInstance(instanceID) + --we don't know how many bosses are in the instance, so we'll just loop through them all + for i = 1, 20 do + local name, description, bossID, rootSectionID, link, journalInstanceID, dungeonEncounterID, UiMapID = EJ_GetEncounterInfoByIndex(i, instanceID) + --print(name, bossID) + if (name) then + name = name:lower() + if (name == encounterName) then + local id, creatureName, creatureDescription, displayInfo, iconImage = EJ_GetCreatureInfo(1, bossID) + Details.boss_icon_cache[encounterName] = iconImage + return iconImage, 32, 20, 0, 1, 0, 0.9 + end + else + --no more bosses in this instance, go to the next one + break + end + end + end + end + + return "" + end function Details:GetEncounterInfoFromEncounterName (EJID, encountername) DetailsFramework.EncounterJournal.EJ_SelectInstance (EJID) --11ms per call diff --git a/functions/bossmods.lua b/functions/bossmods.lua index e923b765..346e1443 100644 --- a/functions/bossmods.lua +++ b/functions/bossmods.lua @@ -137,12 +137,17 @@ function Details:CreateCallbackListeners() Details:Destroy(current_table_bigwigs) end end) + event_frame:RegisterEvent("ENCOUNTER_START") event_frame:RegisterEvent("ENCOUNTER_END") event_frame:RegisterEvent("PLAYER_REGEN_ENABLED") if (_G.DBM) then local dbm_timer_callback = function(bar_type, id, msg, timer, icon, bartype, spellId, colorId, modid) + local currentCombat = Details:GetCurrentCombat() + table.insert(currentCombat.bossTimers, {"dbm", bar_type, id, msg, timer, icon, bartype, spellId, colorId, modid}) + --print("dbm event", bar_type, id, msg, timer, icon, bartype, spellId, colorId, modid) + local spell = tostring(spellId) if (spell and not current_table_dbm [spell]) then current_table_dbm [spell] = {spell, id, msg, timer, icon, bartype, spellId, colorId, modid} @@ -156,6 +161,10 @@ function Details:CreateCallbackListeners() function Details:RegisterBigWigsCallBack() if (BigWigsLoader) then function Details:BigWigs_StartBar (event, module, spellid, bar_text, time, icon, ...) + local currentCombat = Details:GetCurrentCombat() + table.insert(currentCombat.bossTimers, {"bw", event, spellid, bar_text, time, icon}) + --print("bw event", event, spellid, bar_text, time, icon) + spellid = tostring(spellid) if (not current_table_bigwigs [spellid]) then current_table_bigwigs [spellid] = {(type(module) == "string" and module) or (module and module.moduleName) or "", spellid or "", bar_text or "", time or 0, icon or ""} diff --git a/functions/profiles.lua b/functions/profiles.lua index 67b23785..6d4e51f8 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1377,6 +1377,9 @@ local default_global_data = { played_class_time = true, check_stuttering = true, + --[bossname] = texture + boss_icon_cache = {}, + --spell category feedback spell_category_savedtable = {}, spell_category_latest_query = 0,