2025-04-17 19:04:49 +02:00
|
|
|
local _, addon = ...
|
|
|
|
|
|
|
|
local ENCOUNTER_TAB_ID = 9
|
|
|
|
|
|
|
|
local CURRENT_TAB_ID = 0
|
|
|
|
local PREVIOUS_TAB_ID = 0
|
|
|
|
|
|
|
|
local ENCOUNTER_ID = 0
|
|
|
|
local DIFFICULTY = 0
|
|
|
|
|
|
|
|
local TAG_TO_ICON = {
|
|
|
|
tank = 0,
|
|
|
|
dps = 1,
|
|
|
|
healer = 2,
|
|
|
|
important = 5,
|
|
|
|
mythic = 12,
|
|
|
|
interruptible = 6,
|
|
|
|
magic = 7,
|
|
|
|
curse = 8,
|
|
|
|
poison = 9,
|
|
|
|
heroic = 3,
|
|
|
|
disease = 10,
|
|
|
|
deadly = 4,
|
|
|
|
enrage = 11
|
|
|
|
}
|
|
|
|
|
2025-04-18 14:03:11 +02:00
|
|
|
local ORIGINALS = {}
|
|
|
|
|
2025-04-17 19:04:49 +02:00
|
|
|
local function HideOtherContent()
|
|
|
|
local frames = { "overviewScroll", "LootContainer", 'detailsScroll', 'model' }
|
|
|
|
for _, frame in ipairs(frames) do
|
|
|
|
EncounterJournal.encounter.info[frame]:Hide();
|
|
|
|
end
|
|
|
|
|
|
|
|
local tabs = { "overviewTab", "lootTab", "bossTab", "modelTab" }
|
|
|
|
for _, tab in ipairs(tabs) do
|
|
|
|
EncounterJournal.encounter.info[tab].selected:Hide();
|
|
|
|
EncounterJournal.encounter.info[tab].unselected:Show();
|
|
|
|
EncounterJournal.encounter.info[tab]:UnlockHighlight();
|
|
|
|
end
|
|
|
|
|
|
|
|
if EncounterJournal.encounter.info.creatureButtons then
|
|
|
|
for _, button in pairs(EncounterJournal.encounter.info.creatureButtons) do
|
|
|
|
button:Hide()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
addon.EncounterFrame:ClearHeaders()
|
|
|
|
end
|
|
|
|
|
2025-04-19 00:41:40 +02:00
|
|
|
local function SetAbilityTagIcon(header, tags)
|
2025-04-17 19:04:49 +02:00
|
|
|
local result = {}
|
|
|
|
for part in string.gmatch(tags, "([^,]+)") do
|
|
|
|
table.insert(result, part)
|
|
|
|
end
|
|
|
|
|
|
|
|
for i, tag in pairs(result) do
|
|
|
|
local tex = header.button:CreateTexture()
|
|
|
|
if i == 1 then
|
|
|
|
tex:SetAllPoints(header.button.icon1.icon)
|
|
|
|
elseif i == 2 then
|
|
|
|
tex:SetAllPoints(header.button.icon2.icon)
|
|
|
|
elseif i == 3 then
|
|
|
|
tex:SetAllPoints(header.button.icon3.icon)
|
|
|
|
end
|
|
|
|
tex:SetTexture("Interface/EncounterJournal/UI-EJ-Icons")
|
|
|
|
local index = TAG_TO_ICON[string.lower(tag)] or nil
|
|
|
|
if index ~= nil then
|
|
|
|
EncounterJournal_SetFlagIcon(tex, index)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2025-04-19 00:41:40 +02:00
|
|
|
local function SetAbilityIcon(header, name)
|
|
|
|
if ORIGINALS[name] == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local abilityIcon = ORIGINALS[name].abilityIcon or nil
|
|
|
|
if abilityIcon then
|
|
|
|
header.button.abilityIcon:SetTexture(abilityIcon)
|
|
|
|
header.button.abilityIcon:Show()
|
|
|
|
header.button.title:SetPoint("TOPLEFT", header, "TOPLEFT", 45, -7);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function SetEncounterPortraitIcon(header, name)
|
|
|
|
if ORIGINALS[name] == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local creatureDisplayID = ORIGINALS[name].creatureDisplayID or 0
|
|
|
|
local uiModelSceneID = ORIGINALS[name].uiModelSceneID or 0
|
|
|
|
|
|
|
|
if creatureDisplayID ~= 0 and uiModelSceneID ~= 0 then
|
|
|
|
header.button.portrait.displayInfo = creatureDisplayID;
|
|
|
|
header.button.portrait.uiModelSceneID = uiModelSceneID;
|
|
|
|
SetPortraitTextureFromCreatureDisplayID(header.button.portrait.icon, creatureDisplayID);
|
|
|
|
header.button.portrait:Show()
|
|
|
|
header.button.title:SetPoint("TOPLEFT", header, "TOPLEFT", 50, -7);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2025-04-17 19:04:49 +02:00
|
|
|
local function RenderBossAbilities(data, parent, layer)
|
|
|
|
local frame = addon.EncounterFrame
|
|
|
|
|
|
|
|
if not parent.children then
|
|
|
|
parent.children = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, node in ipairs(data) do
|
2025-04-18 14:03:11 +02:00
|
|
|
local abilityValue = addon.API.GetEncounterAbility(node.key)
|
2025-04-17 19:04:49 +02:00
|
|
|
|
|
|
|
if abilityValue then
|
2025-04-18 14:03:11 +02:00
|
|
|
local abilityParts = addon.API.ParseAbilities(abilityValue, "|")
|
2025-04-17 19:04:49 +02:00
|
|
|
local name = abilityParts[1]
|
|
|
|
local tag = abilityParts[3]
|
|
|
|
local description = abilityParts[5]
|
|
|
|
|
|
|
|
if name ~= "???" then
|
|
|
|
local header = frame:CreateHeader()
|
|
|
|
header:SetWidth(frame:GetWidth() - (layer * 20))
|
|
|
|
header.button.title:SetText(name)
|
|
|
|
|
2025-04-19 00:41:40 +02:00
|
|
|
SetAbilityIcon(header, name)
|
|
|
|
SetEncounterPortraitIcon(header, name)
|
|
|
|
|
2025-04-17 19:04:49 +02:00
|
|
|
if tag and tag ~= '???' then
|
2025-04-19 00:41:40 +02:00
|
|
|
SetAbilityTagIcon(header, tag)
|
2025-04-17 19:04:49 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
header.description:SetWidth(header:GetWidth() - 20)
|
2025-04-19 00:41:40 +02:00
|
|
|
header.description:SetText(
|
|
|
|
addon.API.FormatEncounterDescription(description, ORIGINALS[name].description)
|
|
|
|
)
|
2025-04-17 19:04:49 +02:00
|
|
|
if description == "" then header.empty = true end
|
|
|
|
|
|
|
|
table.insert(parent.children, header)
|
|
|
|
|
|
|
|
if node.children and #node.children > 0 then
|
|
|
|
RenderBossAbilities(node.children, header, layer + 1)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
RenderBossAbilities(node.children, parent, layer)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2025-04-19 12:15:35 +02:00
|
|
|
local function RenderBossEncounter(bossKey, encounterName)
|
2025-04-17 19:04:49 +02:00
|
|
|
local frame = addon.EncounterFrame
|
|
|
|
HideOtherContent()
|
|
|
|
|
|
|
|
local bossData = CzechQuestsAddon:GetData('encounter', bossKey)
|
|
|
|
|
|
|
|
frame.summary:SetText(
|
2025-04-19 00:41:40 +02:00
|
|
|
addon.API.FormatEncounterDescription(bossData.overview, ORIGINALS['Overview'].description)
|
2025-04-17 19:04:49 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
local tankHeader = frame:CreateHeader()
|
|
|
|
tankHeader.button.title:SetText("Tank")
|
2025-04-19 12:15:35 +02:00
|
|
|
local originalTank = ORIGINALS['Tanks'] or ORIGINALS['Tank']
|
|
|
|
local tankDescription = addon.API.FormatEncounterDescription(bossData.tank, originalTank.description)
|
2025-04-18 14:03:11 +02:00
|
|
|
tankHeader.description:SetText(tankDescription)
|
2025-04-17 19:04:49 +02:00
|
|
|
table.insert(frame.headers, tankHeader)
|
2025-04-19 00:41:40 +02:00
|
|
|
SetAbilityTagIcon(tankHeader, 'tank')
|
2025-04-17 19:04:49 +02:00
|
|
|
|
|
|
|
local healHeader = frame:CreateHeader()
|
|
|
|
healHeader.button.title:SetText("Healer")
|
2025-04-19 12:15:35 +02:00
|
|
|
local originalHealer = ORIGINALS['Healers'] or ORIGINALS['Healer']
|
|
|
|
local healerDescription = addon.API.FormatEncounterDescription(bossData.healer, originalHealer.description)
|
2025-04-18 14:03:11 +02:00
|
|
|
healHeader.description:SetText(healerDescription)
|
2025-04-17 19:04:49 +02:00
|
|
|
table.insert(frame.headers, healHeader)
|
2025-04-19 00:41:40 +02:00
|
|
|
SetAbilityTagIcon(healHeader, 'healer')
|
2025-04-17 19:04:49 +02:00
|
|
|
|
|
|
|
local dpsHeader = frame:CreateHeader()
|
|
|
|
dpsHeader.button.title:SetText("Damage Dealer")
|
2025-04-19 12:15:35 +02:00
|
|
|
local originalDps = ORIGINALS['Damage Dealers']
|
|
|
|
local dpsDescription = addon.API.FormatEncounterDescription(bossData.dps, originalDps.description)
|
2025-04-18 14:03:11 +02:00
|
|
|
dpsHeader.description:SetText(dpsDescription)
|
2025-04-17 19:04:49 +02:00
|
|
|
table.insert(frame.headers, dpsHeader)
|
2025-04-19 00:41:40 +02:00
|
|
|
SetAbilityTagIcon(dpsHeader, 'dps')
|
2025-04-17 19:04:49 +02:00
|
|
|
|
|
|
|
local bossHeader = frame:CreateHeader()
|
2025-04-19 00:41:40 +02:00
|
|
|
bossHeader.button.title:SetText(encounterName)
|
2025-04-17 19:04:49 +02:00
|
|
|
bossHeader.empty = true
|
|
|
|
table.insert(frame.headers, bossHeader)
|
|
|
|
RenderBossAbilities(bossData.abilities, bossHeader, 1)
|
|
|
|
|
|
|
|
frame:GetParent():Show()
|
|
|
|
frame:UpdateHeaderPositions()
|
2025-04-18 14:03:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function StoreBossAbilities()
|
|
|
|
ORIGINALS = {}
|
2025-04-19 00:41:40 +02:00
|
|
|
|
2025-04-18 14:03:11 +02:00
|
|
|
local stack, _, _, _, curSectionID = {}, EJ_GetEncounterInfo(ENCOUNTER_ID)
|
|
|
|
repeat
|
|
|
|
local info = C_EncounterJournal.GetSectionInfo(curSectionID)
|
|
|
|
if not info.filteredByDifficulty then
|
2025-04-19 00:41:40 +02:00
|
|
|
ORIGINALS[info.title] = {}
|
|
|
|
ORIGINALS[info.title].description = info.description
|
|
|
|
ORIGINALS[info.title].creatureDisplayID = info.creatureDisplayID
|
|
|
|
ORIGINALS[info.title].uiModelSceneID = info.uiModelSceneID
|
|
|
|
ORIGINALS[info.title].abilityIcon = info.abilityIcon
|
2025-04-18 14:03:11 +02:00
|
|
|
end
|
|
|
|
table.insert(stack, info.siblingSectionID)
|
2025-04-19 00:41:40 +02:00
|
|
|
|
2025-04-18 14:03:11 +02:00
|
|
|
if not info.filteredByDifficulty then
|
|
|
|
table.insert(stack, info.firstChildSectionID)
|
|
|
|
end
|
2025-04-19 00:41:40 +02:00
|
|
|
|
2025-04-18 14:03:11 +02:00
|
|
|
curSectionID = table.remove(stack)
|
|
|
|
until not curSectionID
|
|
|
|
end
|
2025-04-17 19:04:49 +02:00
|
|
|
|
|
|
|
local function DetectBossToRender()
|
|
|
|
local frame = addon.EncounterFrame
|
2025-04-18 14:03:11 +02:00
|
|
|
|
2025-04-17 19:04:49 +02:00
|
|
|
local encounterName = EJ_GetEncounterInfo(ENCOUNTER_ID)
|
|
|
|
|
|
|
|
local difficulty = 'lfg_raid' -- 17
|
|
|
|
if DIFFICULTY == 14 then
|
|
|
|
difficulty = 'normal_raid'
|
|
|
|
elseif DIFFICULTY == 15 then
|
|
|
|
difficulty = 'heroic_raid'
|
|
|
|
elseif DIFFICULTY == 16 then
|
|
|
|
difficulty = 'mythic_raid'
|
|
|
|
elseif DIFFICULTY == 1 then
|
|
|
|
difficulty = 'normal_dungeon'
|
|
|
|
elseif DIFFICULTY == 2 then
|
|
|
|
difficulty = 'heroic_dungeon'
|
|
|
|
elseif DIFFICULTY == 23 then
|
|
|
|
difficulty = 'mythic_dungeon'
|
|
|
|
end
|
|
|
|
|
|
|
|
local bossKey = nil
|
|
|
|
for i = 1, 10 do
|
|
|
|
local id, name = EJ_GetCreatureInfo(i);
|
|
|
|
if id then
|
|
|
|
local key = name .. "_" .. difficulty
|
|
|
|
if addon.data.encounter[key] then
|
|
|
|
bossKey = key
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if bossKey then
|
2025-04-18 14:03:11 +02:00
|
|
|
StoreBossAbilities()
|
2025-04-19 12:15:35 +02:00
|
|
|
RenderBossEncounter(bossKey, encounterName)
|
2025-04-17 19:04:49 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if bossKey == nil then
|
2025-04-19 00:41:40 +02:00
|
|
|
frame.summary:SetText("Pro souboj " .. encounterName .. " není vytvořen překlad.")
|
2025-04-17 19:04:49 +02:00
|
|
|
frame:GetParent():Show()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2025-04-18 14:03:11 +02:00
|
|
|
local function HideEncounterContent()
|
2025-04-17 19:04:49 +02:00
|
|
|
addon.EncounterFrame:GetParent():Hide()
|
|
|
|
end
|
|
|
|
|
2025-04-18 14:03:11 +02:00
|
|
|
local function ShowEncounterContent()
|
2025-04-17 19:04:49 +02:00
|
|
|
CURRENT_TAB_ID = ENCOUNTER_TAB_ID
|
|
|
|
HideOtherContent()
|
|
|
|
|
|
|
|
local frame = addon.EncounterFrame
|
|
|
|
|
|
|
|
frame.tab:SetHighlight(true);
|
|
|
|
|
|
|
|
EncounterJournal.encounter.info.rightShadow:Show()
|
|
|
|
EncounterJournal.encounter.info.difficulty:Show()
|
|
|
|
|
|
|
|
DetectBossToRender()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function SetupCustomTab()
|
|
|
|
addon.EncounterFrame.tab:SetScript("OnClick", function()
|
2025-04-18 14:03:11 +02:00
|
|
|
ShowEncounterContent()
|
2025-04-17 19:04:49 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournal_DisplayEncounter", function(encounterID)
|
|
|
|
ENCOUNTER_ID = encounterID
|
|
|
|
addon.EncounterFrame.tab:SetActive(true);
|
|
|
|
|
|
|
|
if CURRENT_TAB_ID == ENCOUNTER_TAB_ID then
|
2025-04-18 14:03:11 +02:00
|
|
|
ShowEncounterContent()
|
2025-04-17 19:04:49 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournal_DisplayInstance", function()
|
|
|
|
addon.EncounterFrame.tab:SetActive(false);
|
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournal_SetTab", function(tabId)
|
|
|
|
if CURRENT_TAB_ID ~= tabId then
|
|
|
|
addon.EncounterFrame.tab:SetHighlight(false);
|
|
|
|
end
|
|
|
|
|
|
|
|
PREVIOUS_TAB_ID = CURRENT_TAB_ID
|
|
|
|
CURRENT_TAB_ID = tabId
|
2025-04-18 14:03:11 +02:00
|
|
|
HideEncounterContent()
|
2025-04-17 19:04:49 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournalBossButton_OnClick", function(encounterID)
|
|
|
|
if PREVIOUS_TAB_ID == ENCOUNTER_TAB_ID then
|
2025-04-18 14:03:11 +02:00
|
|
|
ShowEncounterContent()
|
2025-04-17 19:04:49 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournal_UpdateDifficulty", function(difficulty)
|
|
|
|
DIFFICULTY = difficulty
|
|
|
|
if PREVIOUS_TAB_ID == ENCOUNTER_TAB_ID and ENCOUNTER_ID then
|
2025-04-18 14:03:11 +02:00
|
|
|
ShowEncounterContent()
|
2025-04-17 19:04:49 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function InitEncounters()
|
|
|
|
local frame = addon.EncounterFrame
|
|
|
|
|
|
|
|
frame:RegisterEvent("ADDON_LOADED")
|
|
|
|
|
|
|
|
frame:SetScript("OnEvent", function(self, event, addonName)
|
|
|
|
if not CzechQuestsAddon_Store.config.ENCOUNTER_ENABLED then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if addonName == 'Blizzard_EncounterJournal' then
|
|
|
|
addon.EncounterFrame:Init()
|
|
|
|
SetupCustomTab()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
addon.API.InitEncounters = InitEncounters
|