adam@0
|
1 local _, AskMrRobot = ...
|
yellowfive@11
|
2 local L = AskMrRobot.L;
|
adam@0
|
3
|
adam@0
|
4 -- initialize the ImportTab class
|
adam@0
|
5 AskMrRobot.ImportTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame)
|
adam@0
|
6
|
adam@0
|
7 function AskMrRobot.ImportTab:new(parent)
|
adam@0
|
8
|
adam@0
|
9 local tab = AskMrRobot.Frame:new(nil, parent)
|
adam@0
|
10 setmetatable(tab, { __index = AskMrRobot.ImportTab })
|
adam@0
|
11 tab:SetPoint("TOPLEFT")
|
adam@0
|
12 tab:SetPoint("BOTTOMRIGHT")
|
adam@0
|
13 tab:Hide()
|
adam@0
|
14
|
adam@0
|
15 local text = tab:CreateFontString("AmrImportText1", "ARTWORK", "GameFontNormalLarge")
|
adam@0
|
16 text:SetPoint("TOPLEFT", 0, -5)
|
yellowfive@11
|
17 text:SetFormattedText(L.AMR_IMPORTTAB_TITLE)
|
adam@0
|
18
|
adam@0
|
19 text = tab:CreateFontString("AmrImportText2", "ARTWORK", "GameFontWhite")
|
adam@0
|
20 text:SetPoint("TOPLEFT", "AmrImportText1", "BOTTOMLEFT", 0, -20)
|
adam@17
|
21 text:SetPoint("RIGHT", -15, 0)
|
adam@0
|
22 text:SetWidth(text:GetWidth())
|
adam@0
|
23 text:SetJustifyH("LEFT")
|
yellowfive@11
|
24 text:SetText(L.AMR_IMPORTTAB_INSTRUCTIONS_1)
|
adam@0
|
25
|
adam@0
|
26 text = tab:CreateFontString("AmrImportText3", "ARTWORK", "GameFontWhite")
|
adam@17
|
27 text:SetPoint("TOPLEFT", "AmrImportText2", "BOTTOMLEFT", 0, -10)
|
adam@17
|
28 text:SetPoint("RIGHT", -15, 0)
|
adam@0
|
29 text:SetWidth(text:GetWidth())
|
adam@0
|
30 text:SetJustifyH("LEFT")
|
yellowfive@11
|
31 text:SetText(L.AMR_IMPORTTAB_INSTRUCTIONS_2)
|
adam@0
|
32
|
adam@0
|
33 local scrollFrame = CreateFrame("ScrollFrame", "AmrImportScrollFrame", tab, "InputScrollFrameTemplate")
|
adam@0
|
34 scrollFrame:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 5, -10)
|
adam@0
|
35 scrollFrame:SetPoint("RIGHT", -30, 0)
|
adam@0
|
36 scrollFrame:SetWidth(430)
|
adam@17
|
37 scrollFrame:SetHeight(60);
|
adam@0
|
38 scrollFrame.EditBox:SetWidth(scrollFrame:GetWidth())
|
adam@17
|
39 scrollFrame.EditBox:SetMaxLetters(2400)
|
adam@0
|
40 scrollFrame.CharCount:Hide()
|
adam@0
|
41 scrollFrame.EditBox:SetFocus()
|
adam@0
|
42 scrollFrame.EditBox:HighlightText()
|
adam@0
|
43 tab.scrollFrame = scrollFrame
|
adam@17
|
44
|
adam@17
|
45 tab.button = CreateFrame("Button", "AmrImportButton", tab, "UIPanelButtonTemplate")
|
adam@17
|
46 tab.button:SetText(L.AMR_IMPORTTAB_BUTTON)
|
adam@17
|
47 tab.button:SetWidth(100)
|
adam@17
|
48 tab.button:SetHeight(20)
|
adam@17
|
49 tab.button:SetPoint("BOTTOM", tab, "BOTTOM", 0, 20)
|
adam@17
|
50 scrollFrame:SetPoint("BOTTOM", tab.button, "TOP", 0, 15)
|
adam@17
|
51
|
adam@0
|
52 tab:SetScript("OnShow", function()
|
adam@0
|
53 tab.scrollFrame.EditBox:HighlightText()
|
adam@0
|
54 tab.scrollFrame.EditBox:SetFocus()
|
adam@17
|
55 tab:Update()
|
adam@0
|
56 end)
|
adam@0
|
57
|
adam@0
|
58 return tab
|
adam@0
|
59 end
|
adam@17
|
60
|
adam@17
|
61 function AskMrRobot.ImportTab:GetImportText()
|
adam@17
|
62 return self.scrollFrame.EditBox:GetText()
|
adam@17
|
63 end
|
adam@17
|
64
|
adam@17
|
65 function AskMrRobot.ImportTab:SetImportText(text)
|
adam@17
|
66 self.scrollFrame.EditBox:SetText(text)
|
adam@17
|
67 self.scrollFrame.EditBox:HighlightText()
|
adam@17
|
68 end
|
adam@17
|
69
|
adam@17
|
70 -- update the panel and state
|
adam@17
|
71 function AskMrRobot.ImportTab:Update()
|
adam@17
|
72 end |