Files
coa-exporter/CoaExporter/UI/ExportFrame.lua
T
florian.berthold f9a7ab5beb UI/Markdown: surface spellbook in MD output and sidebar
- New AE:GenerateMarkdownSpellbook(): one section per spell tab
  (General, class, pet) with icon + name + db.ascension.gg link + rank.
  Skips empty tabs.
- /coae export mdspellbook        new slash subcommand
- /coae export md                 now appends a Spellbook section after
                                  Talents in the full wiki page
- UI sidebar: "MD Spellbook" button added under Markdown (Wiki)
2026-05-07 12:20:44 +02:00

177 lines
6.8 KiB
Lua

-- CoaExporter - Export UI
--
-- Layout: title bar on top, left-side nav with grouped buttons, large
-- copy-out edit box on the right. Nav sections wrap the existing slash
-- dispatcher so the button paths and the slash paths run the same code.
local SIDEBAR_W = 160
local BUTTON_H = 22
local SECTION_GAP = 8
local function ce()
return _G.CoaExporter
end
local function showExport(text, title)
if _G.CoaExporter_ShowExportFrame then
_G.CoaExporter_ShowExportFrame(text, title)
end
end
local function runSlash(args)
local fn = SlashCmdList and SlashCmdList["COAE"]
if fn then fn(args) end
end
local function buildSections()
return {
{ title = "Character", items = {
{ "All", function() local ae = ce(); if ae then ae:Export("all") end end },
{ "Talents", function() local ae = ce(); if ae then ae:Export("talents") end end },
{ "Spellbook", function() local ae = ce(); if ae then ae:Export("spellbook") end end },
{ "Gear", function() local ae = ce(); if ae then ae:Export("gear") end end },
{ "Enchants", function() local ae = ce(); if ae then ae:Export("enchants") end end },
}},
{ title = "Markdown (Wiki)", items = {
{ "MD Gear", function()
local ae = ce()
if ae and ae.GenerateMarkdownGear then
showExport(ae:GenerateMarkdownGear() or "", "CoaExporter - Markdown Gear (Ctrl+C)")
end
end },
{ "MD Enchants", function()
local ae = ce()
if ae and ae.GenerateMarkdownEnchants then
showExport(ae:GenerateMarkdownEnchants() or "", "CoaExporter - Markdown Enchants (Ctrl+C)")
end
end },
{ "MD Spellbook", function()
local ae = ce()
if ae and ae.GenerateMarkdownSpellbook then
showExport(ae:GenerateMarkdownSpellbook() or "", "CoaExporter - Markdown Spellbook (Ctrl+C)")
end
end },
{ "MD Full", function()
local ae = ce()
if ae and ae.GenerateMarkdownFull then
showExport(ae:GenerateMarkdownFull() or "", "CoaExporter - Wiki Markdown (Ctrl+C)")
end
end },
}},
{ title = "Catalog", items = {
{ "Skills", function()
if CoaExporter and CoaExporter.Catalog then CoaExporter.Catalog.Run("skills") end
end },
{ "Talents", function()
if CoaExporter and CoaExporter.Catalog then CoaExporter.Catalog.Run("talents") end
end },
{ "All", function()
if CoaExporter and CoaExporter.Catalog then CoaExporter.Catalog.Run("all") end
end },
}},
{ title = "Scrolls", items = {
{ "Scan", function()
if CoaExporter and CoaExporter.ScrollsStartScan then
CoaExporter.ScrollsStartScan(function(stats)
DEFAULT_CHAT_FRAME:AddMessage(string.format(
"CoaExporter scrolls: scan complete - %d resolved, %d unresolved",
stats.total - stats.unresolved, stats.unresolved))
end)
end
end },
{ "Status", function() runSlash("scrolls status") end },
}},
{ title = "Tools", items = {
{ "Reload UI", function() ReloadUI() end },
{ "Debug", function() runSlash("debug") end },
{ "Help", function() runSlash("help") end },
}},
}
end
local function CreateOrGetFrame()
if CoaExporterFrame then return CoaExporterFrame end
local frame = CreateFrame("Frame", "CoaExporterFrame", UIParent, "DialogBoxFrame")
frame:SetSize(720, 500)
frame:SetPoint("CENTER")
frame:SetMovable(true)
frame:EnableMouse(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", frame.StartMoving)
frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
-- Title
local title = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
title:SetPoint("TOP", 0, -8)
frame.title = title
-- Close button (top-right)
local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", -4, -4)
-- Sidebar background (subtle backdrop so the nav reads as a panel)
local nav = CreateFrame("Frame", nil, frame)
nav:SetPoint("TOPLEFT", 12, -32)
nav:SetPoint("BOTTOMLEFT", 12, 16)
nav:SetWidth(SIDEBAR_W)
nav:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 12,
insets = { left = 3, right = 3, top = 3, bottom = 3 },
})
if nav.SetBackdropColor then nav:SetBackdropColor(0, 0, 0, 0.5) end
-- Build nav contents
local sections = buildSections()
local y = -10
for _, sec in ipairs(sections) do
local hdr = nav:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
hdr:SetPoint("TOPLEFT", nav, "TOPLEFT", 10, y)
hdr:SetText(sec.title)
hdr:SetTextColor(1, 0.82, 0)
y = y - 16
for _, item in ipairs(sec.items) do
local label, click = item[1], item[2]
local btn = CreateFrame("Button", nil, nav, "UIPanelButtonTemplate")
btn:SetSize(SIDEBAR_W - 16, BUTTON_H)
btn:SetPoint("TOPLEFT", nav, "TOPLEFT", 8, y)
btn:SetText(label)
btn:SetScript("OnClick", click)
y = y - (BUTTON_H + 2)
end
y = y - SECTION_GAP
end
-- Right pane: scrollable copy-out edit box
local scrollFrame = CreateFrame("ScrollFrame", "CoaExporterScrollFrame", frame, "UIPanelScrollFrameTemplate")
scrollFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 12 + SIDEBAR_W + 12, -32)
scrollFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -32, 16)
local editBox = CreateFrame("EditBox", "CoaExporterEditBox", scrollFrame)
editBox:SetMultiLine(true)
editBox:SetAutoFocus(true)
editBox:SetFontObject(ChatFontNormal)
editBox:SetWidth(720 - (12 + SIDEBAR_W + 12) - 32 - 20)
editBox:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
editBox:SetScript("OnEditFocusGained", function(self) self:HighlightText() end)
scrollFrame:SetScrollChild(editBox)
frame.scrollFrame = scrollFrame
frame.editBox = editBox
CoaExporterFrame = frame
return frame
end
function CoaExporter_ShowExportFrame(text, titleText)
local f = CreateOrGetFrame()
f:Show()
f.editBox:SetText(text or "")
f.title:SetText(titleText or "CoaExporter (Ctrl+C)")
f.editBox:HighlightText()
f.editBox:SetFocus()
end