-- AscensionExporter - Export UI local function CreateOrGetFrame() if AscensionExporterFrame then return AscensionExporterFrame end local frame = CreateFrame("Frame", "AscensionExporterFrame", UIParent, "DialogBoxFrame") frame:SetSize(700, 500) frame:SetPoint("CENTER") frame:SetMovable(true) frame:EnableMouse(true) frame:RegisterForDrag("LeftButton") frame:SetScript("OnDragStart", frame.StartMoving) frame:SetScript("OnDragStop", frame.StopMovingOrSizing) -- Title text local title = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge") title:SetPoint("TOP", 0, -8) frame.title = title -- Action buttons row local function makeBtn(label, x, click) local btn = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate") btn:SetSize(90, 22) btn:SetPoint("TOPLEFT", 16 + x, -36) btn:SetText(label) btn:SetScript("OnClick", click) return btn end local x = 0 makeBtn("All", x, function() if AscensionExporter and AscensionExporter.Export then local data = AscensionExporter:AssembleExport("all") local encoder = _G.AscensionExporter_Json_Encode local json if encoder then json = encoder(data) else -- very small fallback mirroring Core's behavior local function E(v) local t=type(v) if t=='nil' then return 'null' end if t=='boolean' then return v and 'true' or 'false' end if t=='number' then return tostring(v) end if t=='string' then v=v:gsub('\\','\\\\'):gsub('"','\\"'):gsub('\n','\\n'):gsub('\r','\\r'):gsub('\t','\\t'); return '"'..v..'"' end if t=='table' then local n=0 for k,_ in pairs(v) do if type(k)~='number' then n=-1 break else if k>n then n=k end end end if n>=1 then local p={} for i=1,n do p[#p+1]=E(v[i]) end return '['..table.concat(p,',')..']' else local p={} for k,val in pairs(v) do p[#p+1]=E(tostring(k))..':'..E(val) end return '{'..table.concat(p,',')..'}' end end return 'null' end json = E(data) end AscensionExporter_ShowExportFrame(json, "Ascension Export - all - Copy All (Ctrl+C)") end end) x = x + 95 makeBtn("Talents", x, function() if AscensionExporter then AscensionExporter:Export("talents") end end) x = x + 95 makeBtn("Gear", x, function() if AscensionExporter then AscensionExporter:Export("gear") end end) x = x + 95 makeBtn("Enchants", x, function() if AscensionExporter then AscensionExporter:Export("enchants") end end) x = x + 95 makeBtn("MD Gear", x, function() if AscensionExporter and AscensionExporter.GenerateMarkdownGear then local md = AscensionExporter:GenerateMarkdownGear() or "" AscensionExporter_ShowExportFrame(md, "Ascension Export - Markdown Gear - Copy All (Ctrl+C)") end end) -- ScrollFrame + EditBox local scrollFrame = CreateFrame("ScrollFrame", "AscensionExporterScrollFrame", frame, "UIPanelScrollFrameTemplate") scrollFrame:SetPoint("TOPLEFT", 16, -64) scrollFrame:SetPoint("BOTTOMRIGHT", -32, 16) local editBox = CreateFrame("EditBox", "AscensionExporterEditBox", scrollFrame) editBox:SetMultiLine(true) editBox:SetAutoFocus(true) editBox:SetFontObject(ChatFontNormal) editBox:SetWidth(640) 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 -- Close button local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") close:SetPoint("TOPRIGHT", -4, -4) AscensionExporterFrame = frame return frame end function AscensionExporter_ShowExportFrame(text, titleText) local f = CreateOrGetFrame() f:Show() f.editBox:SetText(text or "") f.title:SetText(titleText or "Ascension Export - Copy All (Ctrl+C)") f.editBox:HighlightText() f.editBox:SetFocus() end