All checks were successful
forgejo/Czech Quests/addon/pipeline/head This commit looks good
201 lines
6 KiB
Lua
Executable file
201 lines
6 KiB
Lua
Executable file
local _, addon = ...
|
|
|
|
local TacticFrame = CreateFrame("Frame", nil)
|
|
TacticFrame:Hide()
|
|
|
|
addon.TacticFrame = TacticFrame
|
|
TacticFrame.headers = {}
|
|
|
|
local NEXT_HEADER_ID = 0
|
|
|
|
function TacticFrame:Init()
|
|
local frame = self
|
|
|
|
if not EncounterJournal or not EncounterJournal.encounter or not EncounterJournal.encounter.info then
|
|
return
|
|
end
|
|
|
|
local scrollFrame = CreateFrame("ScrollFrame", "$parentOverviewScrollFrame", EncounterJournal.encounter.info, "ScrollFrameTemplate")
|
|
|
|
scrollFrame:SetSize(330, 370)
|
|
scrollFrame:SetPoint("TOPLEFT", EncounterJournal.encounter.info.overviewScroll, "TOPLEFT", 0, -7)
|
|
|
|
scrollFrame.scrollBarX = -25
|
|
scrollFrame.scrollBarTopY = -6
|
|
scrollFrame.scrollBarBottomY = 6
|
|
|
|
frame:SetParent(scrollFrame)
|
|
frame:SetSize(scrollFrame:GetWidth() - 10, 1)
|
|
frame:Show()
|
|
|
|
scrollFrame:SetScrollChild(frame)
|
|
|
|
frame.summary = addon.API.CreateCzechFont(
|
|
frame,
|
|
CzechQuestsAddon_Store.config.TACTIC_TEXT_FONT_NAME,
|
|
CzechQuestsAddon_Store.config.TACTIC_TEXT_FONT_SIZE
|
|
)
|
|
frame.summary:SetTextColor(0.251, 0.145, 0.012)
|
|
frame.summary:SetPoint("TOPLEFT", frame, "TOPLEFT", 2, 0)
|
|
frame.summary:SetWidth(scrollFrame:GetWidth() - 10)
|
|
|
|
local dropdown = CreateFrame("DropdownButton", nil, EncounterJournal.encounter.info, "WowStyle1DropdownTemplate")
|
|
dropdown:SetPoint("BOTTOMRIGHT", EncounterJournal.encounter.info.encounterTitle, "BOTTOMRIGHT", 2, -2)
|
|
dropdown:SetWidth(200)
|
|
dropdown:Hide()
|
|
frame.dropdown = dropdown
|
|
|
|
frame:UpdateSettings()
|
|
|
|
frame:InitTab()
|
|
end
|
|
|
|
function TacticFrame:UpdateSettings()
|
|
local frame = self
|
|
|
|
addon.API.UpdateCzechFont(
|
|
frame.summary,
|
|
CzechQuestsAddon_Store.config.TACTIC_TEXT_FONT_NAME,
|
|
CzechQuestsAddon_Store.config.TACTIC_TEXT_FONT_SIZE
|
|
)
|
|
|
|
for _, header in ipairs(self.headers) do
|
|
addon.API.UpdateCzechFont(
|
|
header.description,
|
|
CzechQuestsAddon_Store.config.TACTIC_TEXT_FONT_NAME,
|
|
CzechQuestsAddon_Store.config.TACTIC_TEXT_FONT_SIZE
|
|
)
|
|
end
|
|
end
|
|
|
|
function TacticFrame:InitTab()
|
|
local frame = self
|
|
|
|
local tab = CreateFrame("Button", "EncounterJournalCustomTab", EncounterJournal.encounter.info, "EncounterTabTemplate")
|
|
tab:SetPoint("TOP", EncounterJournal.encounter.info.modelTab, "BOTTOM", -3, -12)
|
|
tab:SetSize(50, 40)
|
|
tab.tooltip = "Taktika"
|
|
|
|
local selected = tab:CreateTexture(nil, "BACKGROUND")
|
|
selected:SetTexture("Interface\\EncounterJournal\\UI-EncounterJournalTextures")
|
|
selected:SetAllPoints(tab)
|
|
selected:SetBlendMode("ADD")
|
|
selected:SetDrawLayer("OVERLAY")
|
|
selected:SetTexCoord(0, 0.126953125, 0.90234375, 0.9599609375)
|
|
selected:Hide()
|
|
tab.selected = selected
|
|
|
|
function tab:SetActive(enable)
|
|
self:SetEnabled(enable);
|
|
self:GetDisabledTexture():SetDesaturated(not enable);
|
|
end
|
|
|
|
function tab:SetHighlight(enable)
|
|
if not enable then
|
|
self.selected:Hide();
|
|
else
|
|
self.selected:Show();
|
|
end
|
|
end
|
|
|
|
frame.tab = tab
|
|
end
|
|
|
|
function TacticFrame:CreateHeader()
|
|
local frame = self
|
|
local id = NEXT_HEADER_ID + 1
|
|
NEXT_HEADER_ID = id
|
|
|
|
local HeaderFrame = CreateFrame("FRAME", "CzechQuestsTacticHeader" .. id, frame, "EncounterInfoTemplate")
|
|
HeaderFrame:SetSize(self:GetParent():GetWidth() - 10, 30)
|
|
|
|
addon.API.UpdateCzechFont(
|
|
HeaderFrame.description,
|
|
CzechQuestsAddon_Store.config.TACTIC_TEXT_FONT_NAME,
|
|
CzechQuestsAddon_Store.config.TACTIC_TEXT_FONT_SIZE
|
|
)
|
|
|
|
HeaderFrame.button.abilityIcon:Hide()
|
|
HeaderFrame.button.portrait:Hide()
|
|
HeaderFrame.button.icon2:Hide()
|
|
HeaderFrame.button.icon3:Hide()
|
|
HeaderFrame.button.icon4:Hide()
|
|
|
|
HeaderFrame.button.expandedIcon:SetPoint("TOPLEFT", HeaderFrame.button, "TOPLEFT", 10, -6);
|
|
HeaderFrame.button.expandedIcon:SetText("+")
|
|
HeaderFrame.expanded = false
|
|
|
|
HeaderFrame.button.title:SetPoint("TOPLEFT", HeaderFrame, "TOPLEFT", 40, -7);
|
|
HeaderFrame.button.title:SetWidth(self:GetParent():GetWidth() - 110)
|
|
|
|
for i = 1, #HeaderFrame.Bullets do
|
|
HeaderFrame.Bullets[i]:Hide()
|
|
end
|
|
wipe(HeaderFrame.Bullets)
|
|
|
|
for _, icon in ipairs(HeaderFrame.button.icons) do
|
|
icon:Hide();
|
|
end
|
|
|
|
HeaderFrame.description:SetWidth(HeaderFrame:GetWidth() - 20)
|
|
HeaderFrame.description:Hide()
|
|
HeaderFrame.overviewDescription:Hide()
|
|
HeaderFrame.descriptionBG:Hide()
|
|
HeaderFrame.descriptionBGBottom:Hide()
|
|
|
|
function HeaderFrame:Open()
|
|
local parent = self
|
|
parent.button.expandedIcon:SetText("-")
|
|
parent.button.expandedIcon:SetPoint("TOPLEFT", HeaderFrame.button, "TOPLEFT", 10, -5);
|
|
parent.description:Show()
|
|
parent.descriptionBG:Show()
|
|
parent.descriptionBGBottom:Show()
|
|
end
|
|
|
|
function HeaderFrame:Close()
|
|
local parent = self
|
|
parent.button.expandedIcon:SetText("+")
|
|
parent.button.expandedIcon:SetPoint("TOPLEFT", HeaderFrame.button, "TOPLEFT", 10, -6);
|
|
parent.description:Hide()
|
|
parent.descriptionBG:Hide()
|
|
parent.descriptionBGBottom:Hide()
|
|
end
|
|
|
|
HeaderFrame.button:SetScript("OnClick", function(self)
|
|
local parent = self:GetParent()
|
|
parent.expanded = not parent.expanded
|
|
|
|
if parent.expanded then
|
|
parent:Open()
|
|
else
|
|
parent:Close()
|
|
end
|
|
|
|
frame:UpdateHeaderPositions()
|
|
end)
|
|
|
|
table.insert(self.headers, HeaderFrame)
|
|
|
|
return HeaderFrame
|
|
end
|
|
|
|
function TacticFrame:UpdateHeaderPositions()
|
|
local yOffset = -40
|
|
for _, header in ipairs(self.headers) do
|
|
header:SetPoint("BOTTOMLEFT", self.summary, "BOTTOMLEFT", 0, yOffset)
|
|
if header.expanded then
|
|
yOffset = yOffset - header.description:GetHeight() - 50
|
|
else
|
|
yOffset = yOffset - 30
|
|
end
|
|
end
|
|
end
|
|
|
|
function TacticFrame:ClearHeaders()
|
|
for _, header in ipairs(self.headers) do
|
|
header:Hide()
|
|
header:SetParent(nil)
|
|
header = nil
|
|
end
|
|
wipe(self.headers)
|
|
end
|