Mercurial > wow > askmrrobot
comparison ui/ExportTab.lua @ 17:e77e01abce98
Warlords of Draenor pre-patch
author | Adam tegen <adam.tegen@gmail.com> |
---|---|
date | Mon, 13 Oct 2014 21:28:32 -0500 |
parents | ece9167c0d1c |
children | 90175bdc50e6 |
comparison
equal
deleted
inserted
replaced
16:9793e8b683d2 | 17:e77e01abce98 |
---|---|
3 | 3 |
4 -- initialize the ExportTab class | 4 -- initialize the ExportTab class |
5 AskMrRobot.ExportTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame) | 5 AskMrRobot.ExportTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame) |
6 | 6 |
7 -- helper to create text for this tab | 7 -- helper to create text for this tab |
8 local function CreateText(state, tab, font, relativeTo, xOffset, yOffset, text) | 8 local function CreateText(tab, font, relativeTo, xOffset, yOffset, text) |
9 local t = tab:CreateFontString(nil, "ARTWORK", font) | 9 local t = tab:CreateFontString(nil, "ARTWORK", font) |
10 t:SetPoint("TOPLEFT", relativeTo, "BOTTOMLEFT", xOffset, yOffset) | 10 t:SetPoint("TOPLEFT", relativeTo, "BOTTOMLEFT", xOffset, yOffset) |
11 t:SetPoint("RIGHT", tab, "RIGHT", -25, 0) | 11 t:SetPoint("RIGHT", tab, "RIGHT", -25, 0) |
12 t:SetWidth(t:GetWidth()) | 12 t:SetWidth(t:GetWidth()) |
13 t:SetJustifyH("LEFT") | 13 t:SetJustifyH("LEFT") |
14 t:SetText(text) | 14 t:SetText(text) |
15 | |
16 if (state ~= nil) then | |
17 table.insert(state, t) | |
18 end | |
19 | 15 |
20 return t | 16 return t |
21 end | 17 end |
22 | 18 |
23 function AskMrRobot.ExportTab:new(parent) | 19 function AskMrRobot.ExportTab:new(parent) |
26 setmetatable(tab, { __index = AskMrRobot.ExportTab }) | 22 setmetatable(tab, { __index = AskMrRobot.ExportTab }) |
27 tab:SetPoint("TOPLEFT") | 23 tab:SetPoint("TOPLEFT") |
28 tab:SetPoint("BOTTOMRIGHT") | 24 tab:SetPoint("BOTTOMRIGHT") |
29 tab:Hide() | 25 tab:Hide() |
30 | 26 |
31 -- used to toggle between the two states... could use like, tabs or a UI panel or something, but then I would have to read more pseudo-documentation. | |
32 tab.manualElements = {} | |
33 tab.autoElements = {} | |
34 | |
35 local text = tab:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") | 27 local text = tab:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") |
36 text:SetPoint("TOPLEFT", 0, -5) | 28 text:SetPoint("TOPLEFT", 0, -5) |
37 text:SetText(L.AMR_EXPORTTAB_EXPORT_BB) | 29 text:SetText(L.AMR_EXPORTTAB_EXPORT_TITLE) |
38 | 30 |
39 local chooseText = CreateText(nil, tab, "GameFontWhite", text, 0, -15, "Choose a method:") | |
40 chooseText:SetJustifyV("MIDDLE") | |
41 chooseText:SetHeight(30) | |
42 | |
43 local btn = CreateFrame("Button", "AmrExportManual", tab, "UIPanelButtonTemplate") | |
44 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 125, -15) | |
45 btn:SetText(L.AMR_EXPORTTAB_COPY_PASTE) | |
46 btn:SetWidth(120) | |
47 btn:SetHeight(30) | |
48 tab.btnManual = btn | |
49 | |
50 btn:SetScript("OnClick", function() | |
51 AmrOptions.exportToClient = false | |
52 tab:Update() | |
53 end) | |
54 | |
55 btn = CreateFrame("Button", "AmrExportAuto", tab, "UIPanelButtonTemplate") | |
56 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 275, -15) | |
57 btn:SetText(L.AMR_EXPORTTAB_AMR_CLIENT) | |
58 btn:SetWidth(120) | |
59 btn:SetHeight(30) | |
60 tab.btnAuto = btn | |
61 | |
62 btn:SetScript("OnClick", function() | |
63 AmrOptions.exportToClient = true | |
64 tab:Update() | |
65 end) | |
66 | |
67 -- copy/paste | 31 -- copy/paste |
68 text = CreateText(tab.manualElements, tab, "GameFontNormalLarge", chooseText, 0, -20, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT) | 32 local text2 = CreateText(tab, "GameFontWhite", text, 0, -15, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_1) |
69 local text2 = CreateText(tab.manualElements, tab, "GameFontWhite", text, 0, -15, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_1) | 33 text = CreateText(tab, "GameFontWhite", text2, 0, -15, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_2) |
70 text = CreateText(tab.manualElements, tab, "GameFontWhite", text2, 0, -15, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_2) | |
71 | 34 |
72 local txtExportString = CreateFrame("ScrollFrame", "AmrScrollFrame", tab, "InputScrollFrameTemplate") | 35 local txtExportString = CreateFrame("ScrollFrame", "AmrScrollFrame", tab, "InputScrollFrameTemplate") |
73 txtExportString:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 12, -10) | 36 txtExportString:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 12, -10) |
74 txtExportString:SetPoint("RIGHT", -25, 0) | 37 txtExportString:SetPoint("RIGHT", -25, 0) |
75 txtExportString:SetWidth(txtExportString:GetWidth()) | 38 txtExportString:SetWidth(txtExportString:GetWidth()) |
76 txtExportString:SetHeight(50) | 39 txtExportString:SetHeight(50) |
77 txtExportString.EditBox:SetWidth(txtExportString:GetWidth()) | 40 txtExportString.EditBox:SetWidth(txtExportString:GetWidth()) |
78 txtExportString.EditBox:SetMaxLetters(0) | 41 txtExportString.EditBox:SetMaxLetters(0) |
79 txtExportString.CharCount:Hide() | 42 txtExportString.CharCount:Hide() |
80 tab.txtExportString = txtExportString | 43 tab.txtExportString = txtExportString |
81 table.insert(tab.manualElements, txtExportString) | |
82 | 44 |
83 txtExportString.EditBox:SetScript("OnEscapePressed", function() | 45 txtExportString.EditBox:SetScript("OnEscapePressed", function() |
84 AskMrRobot_ReforgeFrame:Hide() | 46 AskMrRobot.mainWindow:Hide() |
85 end) | 47 end) |
86 | 48 |
87 text = CreateText(tab.manualElements, tab, "GameFontWhite", txtExportString, -12, -20, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_3) | 49 text = CreateText(tab, "GameFontWhite", txtExportString, -12, -20, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_3) |
88 text2 = CreateText(tab.manualElements, tab, "GameFontWhite", text, 10, -5, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_4) | 50 |
89 | 51 text = CreateText(tab, "GameFontWhite", text, 0, -10, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_NOTE) |
90 local image = tab:CreateTexture(nil, "BACKGROUND") | |
91 image:SetPoint("TOPLEFT", text2, "BOTTOMLEFT", 2, -10) | |
92 image:SetTexture("Interface\\AddOns\\AskMrRobot\\Media\\BiBScreen") | |
93 table.insert(tab.manualElements, image) | |
94 | |
95 text = CreateText(tab.manualElements, tab, "GameFontWhite", text2, 0, -120, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_NOTE) | |
96 | 52 |
97 btn = CreateFrame("Button", "AmrUpdateExportString", tab, "UIPanelButtonTemplate") | 53 btn = CreateFrame("Button", "AmrUpdateExportString", tab, "UIPanelButtonTemplate") |
98 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -5) | 54 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", -2, -10) |
99 btn:SetText("Update") | 55 btn:SetText("Update") |
100 btn:SetWidth(120) | 56 btn:SetWidth(110) |
101 btn:SetHeight(25) | 57 btn:SetHeight(30) |
102 table.insert(tab.manualElements, btn) | |
103 | 58 |
104 btn:SetScript("OnClick", function() | 59 btn:SetScript("OnClick", function() |
105 tab:Update() | 60 tab:Update() |
106 end) | 61 end) |
107 | |
108 -- amr client | |
109 text = CreateText(tab.autoElements, tab, "GameFontNormalLarge", chooseText, 0, -20, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT) | |
110 text2 = CreateText(tab.autoElements, tab, "GameFontWhite", text, 0, -15, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT_1) | |
111 text = CreateText(tab.autoElements, tab, "GameFontWhite", text2, 0, -15, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT_2) | |
112 | |
113 btn = CreateFrame("Button", "AmrExportFile", tab, "UIPanelButtonTemplate") | |
114 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 12, -10) | |
115 btn:SetText("Export to File") | |
116 btn:SetWidth(180) | |
117 btn:SetHeight(25) | |
118 table.insert(tab.autoElements, btn) | |
119 | |
120 btn:SetScript("OnClick", function() | |
121 AskMrRobot.SaveAll() | |
122 ReloadUI() | |
123 end) | |
124 | |
125 text = CreateText(tab.autoElements, tab, "GameFontWhite", btn, -12, -20, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT_3) | |
126 text2 = CreateText(tab.autoElements, tab, "GameFontWhite", text, 10, -5, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT_4) | |
127 | |
128 image = tab:CreateTexture(nil, "BACKGROUND") | |
129 image:SetPoint("TOPLEFT", text2, "BOTTOMLEFT", 2, -10) | |
130 image:SetTexture("Interface\\AddOns\\AskMrRobot\\Media\\BiBScreen") | |
131 table.insert(tab.autoElements, image) | |
132 | 62 |
133 tab:SetScript("OnShow", function() | 63 tab:SetScript("OnShow", function() |
134 tab:Update() | 64 tab:Update() |
135 end) | 65 end) |
136 | 66 |
137 return tab | 67 return tab |
138 end | 68 end |
139 | 69 |
140 -- update the panel and state | 70 -- update the panel and state |
141 function AskMrRobot.ExportTab:Update() | 71 function AskMrRobot.ExportTab:Update() |
142 | 72 AskMrRobot.SaveAll() |
143 if (AmrOptions.exportToClient) then | 73 self.txtExportString.EditBox:SetText(AskMrRobot.ExportToString()) |
144 for i, v in ipairs(self.manualElements) do v:Hide() end | 74 self.txtExportString.EditBox:HighlightText() |
145 for i, v in ipairs(self.autoElements) do v:Show() end | 75 self.txtExportString.EditBox:SetFocus() |
146 self.btnManual:UnlockHighlight() | |
147 self.btnAuto:LockHighlight() | |
148 else | |
149 for i, v in ipairs(self.autoElements) do v:Hide() end | |
150 for i, v in ipairs(self.manualElements) do v:Show() end | |
151 self.btnAuto:UnlockHighlight() | |
152 self.btnManual:LockHighlight() | |
153 | |
154 AskMrRobot.SaveAll() | |
155 self.txtExportString.EditBox:SetText(AskMrRobot.ExportToString()) | |
156 self.txtExportString.EditBox:HighlightText() | |
157 self.txtExportString.EditBox:SetFocus() | |
158 end | |
159 end | 76 end |