Refactor encounter handling and placeholder logic
All checks were successful
forgejo/Czech Quests/addon/pipeline/head This commit looks good
All checks were successful
forgejo/Czech Quests/addon/pipeline/head This commit looks good
This commit is contained in:
parent
c2eda51d7d
commit
a32b698ebf
10 changed files with 278 additions and 421 deletions
|
@ -24,6 +24,8 @@ local TAG_TO_ICON = {
|
|||
enrage = 11
|
||||
}
|
||||
|
||||
local ORIGINALS = {}
|
||||
|
||||
local function HideOtherContent()
|
||||
local frames = { "overviewScroll", "LootContainer", 'detailsScroll', 'model' }
|
||||
for _, frame in ipairs(frames) do
|
||||
|
@ -67,15 +69,6 @@ local function SetAbilityIcon(header, tags)
|
|||
EncounterJournal_SetFlagIcon(tex, index)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
local function ColorSpellNames(text, color)
|
||||
return text:gsub("%[(.-)%]", function(match)
|
||||
return string.format("|c%s[%s]|r", color or "FF0000FF", match)
|
||||
end)
|
||||
end
|
||||
|
||||
local function RenderBossAbilities(data, parent, layer)
|
||||
|
@ -86,10 +79,10 @@ local function RenderBossAbilities(data, parent, layer)
|
|||
end
|
||||
|
||||
for _, node in ipairs(data) do
|
||||
local abilityValue = addon.API.ResolveGender(addon.API.GetEncounterAbility(node.key))
|
||||
local abilityValue = addon.API.GetEncounterAbility(node.key)
|
||||
|
||||
if abilityValue then
|
||||
local abilityParts = addon.API.SplitAbilityParts(abilityValue, "|")
|
||||
local abilityParts = addon.API.ParseAbilities(abilityValue, "|")
|
||||
local name = abilityParts[1]
|
||||
local tag = abilityParts[3]
|
||||
local description = abilityParts[5]
|
||||
|
@ -104,7 +97,7 @@ local function RenderBossAbilities(data, parent, layer)
|
|||
end
|
||||
|
||||
header.description:SetWidth(header:GetWidth() - 20)
|
||||
header.description:SetText(description)
|
||||
header.description:SetText(addon.API.SetAbilityDescription(description, ORIGINALS[name]))
|
||||
if description == "" then header.empty = true end
|
||||
|
||||
table.insert(parent.children, header)
|
||||
|
@ -119,49 +112,34 @@ local function RenderBossAbilities(data, parent, layer)
|
|||
end
|
||||
end
|
||||
|
||||
local function RenderBossEncounter(bossName, bossKey)
|
||||
local function RenderBossEncounter(bossKey, bossName)
|
||||
local frame = addon.EncounterFrame
|
||||
HideOtherContent()
|
||||
|
||||
local bossData = CzechQuestsAddon:GetData('encounter', bossKey)
|
||||
|
||||
local function CreateHeaderDescription(data)
|
||||
local value = addon.API.ResolveGender(data)
|
||||
local result = {}
|
||||
for part in string.gmatch(value, "([^\n]+)") do
|
||||
table.insert(result, part)
|
||||
end
|
||||
local description = ""
|
||||
for i, part in pairs(result) do
|
||||
description = description
|
||||
.. "- "
|
||||
.. ColorSpellNames(part)
|
||||
.. (i == #result and "" or "\n\n")
|
||||
end
|
||||
return description
|
||||
end
|
||||
|
||||
frame.summary:SetText(
|
||||
ColorSpellNames(
|
||||
addon.API.ResolveGender(bossData.overview)
|
||||
)
|
||||
addon.API.SetAbilityDescription(bossData.overview, ORIGINALS['Overview'])
|
||||
)
|
||||
|
||||
local tankHeader = frame:CreateHeader()
|
||||
tankHeader.button.title:SetText("Tank")
|
||||
tankHeader.description:SetText(CreateHeaderDescription(bossData.tank))
|
||||
local tankDescription = addon.API.SetSummaryDescription(bossData.tank, ORIGINALS['Tanks'])
|
||||
tankHeader.description:SetText(tankDescription)
|
||||
table.insert(frame.headers, tankHeader)
|
||||
SetAbilityIcon(tankHeader, 'tank')
|
||||
|
||||
local healHeader = frame:CreateHeader()
|
||||
healHeader.button.title:SetText("Healer")
|
||||
healHeader.description:SetText(CreateHeaderDescription(bossData.healer))
|
||||
local healerDescription = addon.API.SetSummaryDescription(bossData.healer, ORIGINALS['Healers'])
|
||||
healHeader.description:SetText(healerDescription)
|
||||
table.insert(frame.headers, healHeader)
|
||||
SetAbilityIcon(healHeader, 'healer')
|
||||
|
||||
local dpsHeader = frame:CreateHeader()
|
||||
dpsHeader.button.title:SetText("Damage Dealer")
|
||||
dpsHeader.description:SetText(CreateHeaderDescription(bossData.dps))
|
||||
local dpsDescription = addon.API.SetSummaryDescription(bossData.dps, ORIGINALS['Damage Dealers'])
|
||||
dpsHeader.description:SetText(dpsDescription)
|
||||
table.insert(frame.headers, dpsHeader)
|
||||
SetAbilityIcon(dpsHeader, 'dps')
|
||||
|
||||
|
@ -169,16 +147,31 @@ local function RenderBossEncounter(bossName, bossKey)
|
|||
bossHeader.button.title:SetText(bossName)
|
||||
bossHeader.empty = true
|
||||
table.insert(frame.headers, bossHeader)
|
||||
|
||||
-- abilities
|
||||
RenderBossAbilities(bossData.abilities, bossHeader, 1)
|
||||
|
||||
frame:GetParent():Show()
|
||||
frame:UpdateHeaderPositions()
|
||||
end
|
||||
end
|
||||
|
||||
local function StoreBossAbilities()
|
||||
ORIGINALS = {}
|
||||
local stack, _, _, _, curSectionID = {}, EJ_GetEncounterInfo(ENCOUNTER_ID)
|
||||
repeat
|
||||
local info = C_EncounterJournal.GetSectionInfo(curSectionID)
|
||||
if not info.filteredByDifficulty then
|
||||
ORIGINALS[info.title] = info.description
|
||||
end
|
||||
table.insert(stack, info.siblingSectionID)
|
||||
if not info.filteredByDifficulty then
|
||||
table.insert(stack, info.firstChildSectionID)
|
||||
end
|
||||
curSectionID = table.remove(stack)
|
||||
until not curSectionID
|
||||
end
|
||||
|
||||
local function DetectBossToRender()
|
||||
local frame = addon.EncounterFrame
|
||||
|
||||
local encounterName = EJ_GetEncounterInfo(ENCOUNTER_ID)
|
||||
|
||||
local difficulty = 'lfg_raid' -- 17
|
||||
|
@ -196,14 +189,12 @@ local function DetectBossToRender()
|
|||
difficulty = 'mythic_dungeon'
|
||||
end
|
||||
|
||||
local bossName = nil
|
||||
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
|
||||
bossName = name
|
||||
bossKey = key
|
||||
break
|
||||
end
|
||||
|
@ -211,7 +202,8 @@ local function DetectBossToRender()
|
|||
end
|
||||
|
||||
if bossKey then
|
||||
RenderBossEncounter(bossName, bossKey)
|
||||
StoreBossAbilities()
|
||||
RenderBossEncounter(bossKey, encounterName)
|
||||
end
|
||||
|
||||
if bossKey == nil then
|
||||
|
@ -220,11 +212,11 @@ local function DetectBossToRender()
|
|||
end
|
||||
end
|
||||
|
||||
local function HideEncounterFrame()
|
||||
local function HideEncounterContent()
|
||||
addon.EncounterFrame:GetParent():Hide()
|
||||
end
|
||||
|
||||
local function ShowEncounterFrame()
|
||||
local function ShowEncounterContent()
|
||||
CURRENT_TAB_ID = ENCOUNTER_TAB_ID
|
||||
HideOtherContent()
|
||||
|
||||
|
@ -240,7 +232,7 @@ end
|
|||
|
||||
local function SetupCustomTab()
|
||||
addon.EncounterFrame.tab:SetScript("OnClick", function()
|
||||
ShowEncounterFrame()
|
||||
ShowEncounterContent()
|
||||
end)
|
||||
|
||||
hooksecurefunc("EncounterJournal_DisplayEncounter", function(encounterID)
|
||||
|
@ -248,7 +240,7 @@ local function SetupCustomTab()
|
|||
addon.EncounterFrame.tab:SetActive(true);
|
||||
|
||||
if CURRENT_TAB_ID == ENCOUNTER_TAB_ID then
|
||||
ShowEncounterFrame()
|
||||
ShowEncounterContent()
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -263,19 +255,19 @@ local function SetupCustomTab()
|
|||
|
||||
PREVIOUS_TAB_ID = CURRENT_TAB_ID
|
||||
CURRENT_TAB_ID = tabId
|
||||
HideEncounterFrame()
|
||||
HideEncounterContent()
|
||||
end)
|
||||
|
||||
hooksecurefunc("EncounterJournalBossButton_OnClick", function(encounterID)
|
||||
if PREVIOUS_TAB_ID == ENCOUNTER_TAB_ID then
|
||||
ShowEncounterFrame()
|
||||
ShowEncounterContent()
|
||||
end
|
||||
end)
|
||||
|
||||
hooksecurefunc("EncounterJournal_UpdateDifficulty", function(difficulty)
|
||||
DIFFICULTY = difficulty
|
||||
if PREVIOUS_TAB_ID == ENCOUNTER_TAB_ID and ENCOUNTER_ID then
|
||||
ShowEncounterFrame()
|
||||
ShowEncounterContent()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@ -283,7 +275,6 @@ end
|
|||
local function InitEncounters()
|
||||
local frame = addon.EncounterFrame
|
||||
|
||||
-- Register EncounterJournal events
|
||||
frame:RegisterEvent("ADDON_LOADED")
|
||||
|
||||
frame:SetScript("OnEvent", function(self, event, addonName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue