2025-03-29 07:44:17 +01:00
|
|
|
local _, addon = ...
|
|
|
|
|
|
|
|
local TACTIC_TAB_ID = 9
|
|
|
|
|
|
|
|
local CURRENT_TAB_ID = 0
|
|
|
|
local PREVIOUS_TAB_ID = 0
|
|
|
|
|
|
|
|
local ENCOUNTER_ID = 0
|
|
|
|
local DIFFICULTY = 0
|
|
|
|
|
|
|
|
local function HideOtherContent()
|
|
|
|
local frames = { "overviewScroll", "LootContainer", 'detailsScroll', 'model', 'encounterTitle' }
|
|
|
|
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.TacticFrame:ClearHeaders()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function RenderBossTactics(frame, bossName)
|
|
|
|
HideOtherContent()
|
|
|
|
|
2025-03-30 22:00:13 +02:00
|
|
|
local instanceType = 'raidu'
|
2025-03-30 17:56:47 +02:00
|
|
|
local difficulty = 'lfg_raid' -- 17
|
2025-03-29 07:44:17 +01:00
|
|
|
if DIFFICULTY == 14 then
|
2025-03-30 17:56:47 +02:00
|
|
|
difficulty = 'normal_raid'
|
2025-03-29 07:44:17 +01:00
|
|
|
elseif DIFFICULTY == 15 then
|
2025-03-30 17:56:47 +02:00
|
|
|
difficulty = 'heroic_raid'
|
2025-03-29 07:44:17 +01:00
|
|
|
elseif DIFFICULTY == 16 then
|
2025-03-30 17:56:47 +02:00
|
|
|
difficulty = 'mythic_raid'
|
2025-03-29 07:44:17 +01:00
|
|
|
elseif DIFFICULTY == 1 then
|
2025-03-30 17:56:47 +02:00
|
|
|
difficulty = 'normal_dungeon'
|
2025-03-30 22:00:13 +02:00
|
|
|
instanceType = 'dungeonu'
|
2025-03-29 07:44:17 +01:00
|
|
|
elseif DIFFICULTY == 2 then
|
2025-03-30 17:56:47 +02:00
|
|
|
difficulty = 'heroic_dungeon'
|
2025-03-30 22:00:13 +02:00
|
|
|
instanceType = 'dungeonu'
|
2025-03-29 07:44:17 +01:00
|
|
|
elseif DIFFICULTY == 23 then
|
2025-03-30 17:56:47 +02:00
|
|
|
difficulty = 'mythic_dungeon'
|
2025-03-30 22:00:13 +02:00
|
|
|
instanceType = 'dungeonu'
|
2025-03-30 17:56:47 +02:00
|
|
|
elseif DIFFICULTY == 8 then
|
2025-03-30 22:00:13 +02:00
|
|
|
difficulty = 'mythicplus_dungeon'
|
|
|
|
instanceType = 'dungeonu'
|
2025-03-29 07:44:17 +01:00
|
|
|
end
|
|
|
|
|
2025-03-30 17:56:47 +02:00
|
|
|
local bossData = CzechQuestsAddon:GetData('tactic', bossName)
|
|
|
|
local tactic = bossData and bossData[difficulty] or nil
|
2025-03-29 07:44:17 +01:00
|
|
|
|
|
|
|
if not tactic then
|
|
|
|
frame.summary:SetText("Boss " .. bossName .. " nemá pro tuto obtížnost přeloženou taktiku.")
|
2025-03-30 22:08:53 +02:00
|
|
|
frame.inform:Hide()
|
2025-03-29 07:44:17 +01:00
|
|
|
frame:GetParent():Show()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local function CreateHeaderDescription(data)
|
|
|
|
local description = ""
|
|
|
|
for _, item in ipairs(data) do
|
|
|
|
description = description
|
2025-03-30 22:00:13 +02:00
|
|
|
.. "|cff003366" .. item[1] .. "|r\n"
|
|
|
|
.. "" .. item[3] .. " "
|
|
|
|
.. "|cff004400" .. item[4] .. "|r"
|
2025-03-29 07:44:17 +01:00
|
|
|
.. "\n\n"
|
|
|
|
end
|
|
|
|
return description
|
|
|
|
end
|
|
|
|
|
|
|
|
frame.summary:SetText(tactic.summary)
|
2025-03-30 22:00:13 +02:00
|
|
|
frame.inform:SetText("|cffffffffVždy dodržuj pokyny leadera " .. instanceType .. ".|r")
|
2025-03-29 07:44:17 +01:00
|
|
|
|
|
|
|
local tankHeader = frame:CreateHeader()
|
|
|
|
tankHeader.button.title:SetText("Tank")
|
|
|
|
tankHeader.description:SetText(CreateHeaderDescription(tactic.tank))
|
|
|
|
|
|
|
|
local healHeader = frame:CreateHeader()
|
|
|
|
healHeader.button.title:SetText("Healer")
|
|
|
|
healHeader.description:SetText(CreateHeaderDescription(tactic.heal))
|
|
|
|
|
|
|
|
local dpsHeader = frame:CreateHeader()
|
|
|
|
dpsHeader.button.title:SetText("DPS")
|
|
|
|
dpsHeader.description:SetText(CreateHeaderDescription(tactic.dps))
|
|
|
|
|
|
|
|
frame:GetParent():Show()
|
|
|
|
frame:UpdateHeaderPositions()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function CreateCreaturesDropdown()
|
|
|
|
local frame = addon.TacticFrame
|
|
|
|
local encounterName = EJ_GetEncounterInfo(ENCOUNTER_ID)
|
|
|
|
|
|
|
|
local options = {}
|
|
|
|
local selectedValue = nil
|
|
|
|
|
|
|
|
for i = 1, 10 do
|
|
|
|
local id, name = EJ_GetCreatureInfo(i);
|
|
|
|
if id then
|
|
|
|
if addon.data.tactic[name] then
|
|
|
|
table.insert(options, { name, name })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if #options > 0 then
|
|
|
|
selectedValue = options[1][2]
|
|
|
|
end
|
|
|
|
|
|
|
|
local function IsSelected(value)
|
|
|
|
return value == selectedValue
|
|
|
|
end
|
|
|
|
|
|
|
|
local function SetSelected(value)
|
|
|
|
if value then
|
|
|
|
RenderBossTactics(addon.TacticFrame, value)
|
|
|
|
end
|
|
|
|
selectedValue = value
|
|
|
|
end
|
|
|
|
|
|
|
|
MenuUtil.CreateRadioMenu(frame.dropdown, IsSelected, SetSelected, unpack(options))
|
|
|
|
|
|
|
|
if #options > 0 then
|
|
|
|
SetSelected(selectedValue)
|
|
|
|
end
|
|
|
|
|
|
|
|
if #options == 0 then
|
|
|
|
frame.summary:SetText("V souboji " .. encounterName .. " není boss, který má přeloženou taktikou.")
|
|
|
|
frame:GetParent():Show()
|
|
|
|
frame.dropdown:Hide()
|
2025-03-30 22:08:53 +02:00
|
|
|
frame.inform:Hide()
|
2025-03-29 07:44:17 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function HideTacticNpcs()
|
|
|
|
addon.TacticFrame:GetParent():Hide()
|
|
|
|
addon.TacticFrame.dropdown:Hide()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function ShowTacticNpcs()
|
|
|
|
CURRENT_TAB_ID = TACTIC_TAB_ID
|
|
|
|
HideOtherContent()
|
|
|
|
|
|
|
|
local frame = addon.TacticFrame
|
|
|
|
|
|
|
|
frame.tab:SetHighlight(true);
|
|
|
|
frame.dropdown:Show()
|
|
|
|
|
|
|
|
EncounterJournal.encounter.info.rightShadow:Show()
|
|
|
|
EncounterJournal.encounter.info.difficulty:Show()
|
|
|
|
|
|
|
|
CreateCreaturesDropdown()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function SetupCustomTab()
|
|
|
|
addon.TacticFrame.tab:SetScript("OnClick", function()
|
|
|
|
ShowTacticNpcs()
|
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournal_DisplayEncounter", function(encounterID)
|
|
|
|
ENCOUNTER_ID = encounterID
|
|
|
|
addon.TacticFrame.tab:SetActive(true);
|
|
|
|
|
|
|
|
if CURRENT_TAB_ID == TACTIC_TAB_ID then
|
|
|
|
ShowTacticNpcs()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournal_DisplayInstance", function()
|
|
|
|
addon.TacticFrame.tab:SetActive(false);
|
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournal_SetTab", function(tabId)
|
|
|
|
if CURRENT_TAB_ID ~= tabId then
|
|
|
|
addon.TacticFrame.tab:SetHighlight(false);
|
|
|
|
end
|
|
|
|
|
|
|
|
PREVIOUS_TAB_ID = CURRENT_TAB_ID
|
|
|
|
CURRENT_TAB_ID = tabId
|
|
|
|
HideTacticNpcs()
|
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournalBossButton_OnClick", function(encounterID)
|
|
|
|
if PREVIOUS_TAB_ID == TACTIC_TAB_ID then
|
|
|
|
ShowTacticNpcs()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
hooksecurefunc("EncounterJournal_UpdateDifficulty", function(difficulty)
|
|
|
|
DIFFICULTY = difficulty
|
|
|
|
if PREVIOUS_TAB_ID == TACTIC_TAB_ID and ENCOUNTER_ID then
|
|
|
|
ShowTacticNpcs()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function InitTactics()
|
|
|
|
local frame = addon.TacticFrame
|
|
|
|
|
|
|
|
-- Register EncounterJournal events
|
|
|
|
frame:RegisterEvent("ADDON_LOADED")
|
|
|
|
|
|
|
|
frame:SetScript("OnEvent", function(self, event, addonName)
|
|
|
|
if not CzechQuestsAddon_Store.config.TACTIC_ENABLED then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if addonName == 'Blizzard_EncounterJournal' then
|
|
|
|
addon.TacticFrame:Init()
|
|
|
|
SetupCustomTab()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
addon.API.InitTactics = InitTactics
|