adam@0
|
1 local _, AskMrRobot = ...
|
yellowfive@11
|
2 local L = AskMrRobot.L;
|
adam@0
|
3
|
adam@0
|
4 -- initialize the ExportTab class
|
adam@0
|
5 AskMrRobot.ExportTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame)
|
adam@0
|
6
|
adam@0
|
7 -- helper to create text for this tab
|
adam@17
|
8 local function CreateText(tab, font, relativeTo, xOffset, yOffset, text)
|
adam@0
|
9 local t = tab:CreateFontString(nil, "ARTWORK", font)
|
adam@0
|
10 t:SetPoint("TOPLEFT", relativeTo, "BOTTOMLEFT", xOffset, yOffset)
|
adam@0
|
11 t:SetPoint("RIGHT", tab, "RIGHT", -25, 0)
|
adam@0
|
12 t:SetWidth(t:GetWidth())
|
adam@0
|
13 t:SetJustifyH("LEFT")
|
adam@0
|
14 t:SetText(text)
|
adam@0
|
15
|
adam@0
|
16 return t
|
adam@0
|
17 end
|
adam@0
|
18
|
adam@0
|
19 function AskMrRobot.ExportTab:new(parent)
|
adam@0
|
20
|
adam@0
|
21 local tab = AskMrRobot.Frame:new(nil, parent)
|
adam@0
|
22 setmetatable(tab, { __index = AskMrRobot.ExportTab })
|
adam@0
|
23 tab:SetPoint("TOPLEFT")
|
adam@0
|
24 tab:SetPoint("BOTTOMRIGHT")
|
adam@0
|
25 tab:Hide()
|
adam@0
|
26
|
adam@0
|
27 local text = tab:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
|
adam@0
|
28 text:SetPoint("TOPLEFT", 0, -5)
|
adam@17
|
29 text:SetText(L.AMR_EXPORTTAB_EXPORT_TITLE)
|
adam@17
|
30
|
adam@0
|
31 -- copy/paste
|
adam@17
|
32 local text2 = CreateText(tab, "GameFontWhite", text, 0, -15, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_1)
|
adam@17
|
33 text = CreateText(tab, "GameFontWhite", text2, 0, -15, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_2)
|
adam@0
|
34
|
adam@0
|
35 local txtExportString = CreateFrame("ScrollFrame", "AmrScrollFrame", tab, "InputScrollFrameTemplate")
|
adam@0
|
36 txtExportString:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 12, -10)
|
adam@0
|
37 txtExportString:SetPoint("RIGHT", -25, 0)
|
adam@0
|
38 txtExportString:SetWidth(txtExportString:GetWidth())
|
adam@0
|
39 txtExportString:SetHeight(50)
|
adam@0
|
40 txtExportString.EditBox:SetWidth(txtExportString:GetWidth())
|
adam@0
|
41 txtExportString.EditBox:SetMaxLetters(0)
|
adam@0
|
42 txtExportString.CharCount:Hide()
|
adam@0
|
43 tab.txtExportString = txtExportString
|
adam@0
|
44
|
adam@0
|
45 txtExportString.EditBox:SetScript("OnEscapePressed", function()
|
adam@17
|
46 AskMrRobot.mainWindow:Hide()
|
adam@0
|
47 end)
|
adam@0
|
48
|
adam@17
|
49 text = CreateText(tab, "GameFontWhite", txtExportString, -12, -20, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_3)
|
adam@17
|
50
|
adam@17
|
51 text = CreateText(tab, "GameFontWhite", text, 0, -10, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_NOTE)
|
adam@0
|
52
|
adam@0
|
53 btn = CreateFrame("Button", "AmrUpdateExportString", tab, "UIPanelButtonTemplate")
|
adam@17
|
54 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", -2, -10)
|
yellowfive@49
|
55 btn:SetText(L.AMR_EXPORTTAB_UPDATE)
|
adam@17
|
56 btn:SetWidth(110)
|
adam@17
|
57 btn:SetHeight(30)
|
adam@0
|
58
|
adam@0
|
59 btn:SetScript("OnClick", function()
|
adam@0
|
60 tab:Update()
|
adam@0
|
61 end)
|
adam@0
|
62
|
adam@0
|
63 tab:SetScript("OnShow", function()
|
adam@0
|
64 tab:Update()
|
adam@0
|
65 end)
|
adam@0
|
66
|
adam@0
|
67 return tab
|
adam@0
|
68 end
|
adam@0
|
69
|
adam@0
|
70 -- update the panel and state
|
adam@0
|
71 function AskMrRobot.ExportTab:Update()
|
adam@17
|
72 AskMrRobot.SaveAll()
|
adam@17
|
73 self.txtExportString.EditBox:SetText(AskMrRobot.ExportToString())
|
adam@17
|
74 self.txtExportString.EditBox:HighlightText()
|
adam@17
|
75 self.txtExportString.EditBox:SetFocus()
|
adam@0
|
76 end
|