Mercurial > wow > askmrrobot
comparison ui/ExportTab.lua @ 0:ec731d2fe6ba
Version 1.2.12.0
author | Adam tegen <adam.tegen@gmail.com> |
---|---|
date | Tue, 20 May 2014 21:43:23 -0500 |
parents | |
children | ece9167c0d1c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ec731d2fe6ba |
---|---|
1 local _, AskMrRobot = ... | |
2 | |
3 -- initialize the ExportTab class | |
4 AskMrRobot.ExportTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame) | |
5 | |
6 -- helper to create text for this tab | |
7 local function CreateText(state, tab, font, relativeTo, xOffset, yOffset, text) | |
8 local t = tab:CreateFontString(nil, "ARTWORK", font) | |
9 t:SetPoint("TOPLEFT", relativeTo, "BOTTOMLEFT", xOffset, yOffset) | |
10 t:SetPoint("RIGHT", tab, "RIGHT", -25, 0) | |
11 t:SetWidth(t:GetWidth()) | |
12 t:SetJustifyH("LEFT") | |
13 t:SetText(text) | |
14 | |
15 if (state ~= nil) then | |
16 table.insert(state, t) | |
17 end | |
18 | |
19 return t | |
20 end | |
21 | |
22 function AskMrRobot.ExportTab:new(parent) | |
23 | |
24 local tab = AskMrRobot.Frame:new(nil, parent) | |
25 setmetatable(tab, { __index = AskMrRobot.ExportTab }) | |
26 tab:SetPoint("TOPLEFT") | |
27 tab:SetPoint("BOTTOMRIGHT") | |
28 tab:Hide() | |
29 | |
30 -- 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. | |
31 tab.manualElements = {} | |
32 tab.autoElements = {} | |
33 | |
34 local text = tab:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") | |
35 text:SetPoint("TOPLEFT", 0, -5) | |
36 text:SetText("Export Gear for Best in Bags") | |
37 | |
38 local chooseText = CreateText(nil, tab, "GameFontWhite", text, 0, -15, "Choose a method:") | |
39 chooseText:SetJustifyV("MIDDLE") | |
40 chooseText:SetHeight(30) | |
41 | |
42 local btn = CreateFrame("Button", "AmrExportManual", tab, "UIPanelButtonTemplate") | |
43 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 125, -15) | |
44 btn:SetText("Copy/Paste") | |
45 btn:SetWidth(120) | |
46 btn:SetHeight(30) | |
47 tab.btnManual = btn | |
48 | |
49 btn:SetScript("OnClick", function() | |
50 AmrOptions.exportToClient = false | |
51 tab:Update() | |
52 end) | |
53 | |
54 btn = CreateFrame("Button", "AmrExportAuto", tab, "UIPanelButtonTemplate") | |
55 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 275, -15) | |
56 btn:SetText("AMR Client") | |
57 btn:SetWidth(120) | |
58 btn:SetHeight(30) | |
59 tab.btnAuto = btn | |
60 | |
61 btn:SetScript("OnClick", function() | |
62 AmrOptions.exportToClient = true | |
63 tab:Update() | |
64 end) | |
65 | |
66 -- copy/paste | |
67 text = CreateText(tab.manualElements, tab, "GameFontNormalLarge", chooseText, 0, -20, "COPY/PASTE EXPORT") | |
68 local text2 = CreateText(tab.manualElements, tab, "GameFontWhite", text, 0, -15, "1. Open your bank") | |
69 text = CreateText(tab.manualElements, tab, "GameFontWhite", text2, 0, -15, "2. Copy the text below by pressing Ctrl+C (or Cmd+C on a Mac)") | |
70 | |
71 local txtExportString = CreateFrame("ScrollFrame", "AmrScrollFrame", tab, "InputScrollFrameTemplate") | |
72 txtExportString:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 12, -10) | |
73 txtExportString:SetPoint("RIGHT", -25, 0) | |
74 txtExportString:SetWidth(txtExportString:GetWidth()) | |
75 txtExportString:SetHeight(50) | |
76 txtExportString.EditBox:SetWidth(txtExportString:GetWidth()) | |
77 txtExportString.EditBox:SetMaxLetters(0) | |
78 txtExportString.CharCount:Hide() | |
79 tab.txtExportString = txtExportString | |
80 table.insert(tab.manualElements, txtExportString) | |
81 | |
82 txtExportString.EditBox:SetScript("OnEscapePressed", function() | |
83 AskMrRobot_ReforgeFrame:Hide() | |
84 end) | |
85 | |
86 text = CreateText(tab.manualElements, tab, "GameFontWhite", txtExportString, -12, -20, "3. Go to AskMrRobot.com and paste into the IMPORT window") | |
87 text2 = CreateText(tab.manualElements, tab, "GameFontWhite", text, 10, -5, "(located to the right of your character name near the top of the web page, see screenshot)") | |
88 | |
89 local image = tab:CreateTexture(nil, "BACKGROUND") | |
90 image:SetPoint("TOPLEFT", text2, "BOTTOMLEFT", 2, -10) | |
91 image:SetTexture("Interface\\AddOns\\AskMrRobot\\Media\\BiBScreen") | |
92 table.insert(tab.manualElements, image) | |
93 | |
94 text = CreateText(tab.manualElements, tab, "GameFontWhite", text2, 0, -120, "NOTE: If you change something while this window is open, press the Update button below to generate a new export string.") | |
95 | |
96 btn = CreateFrame("Button", "AmrUpdateExportString", tab, "UIPanelButtonTemplate") | |
97 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -5) | |
98 btn:SetText("Update") | |
99 btn:SetWidth(120) | |
100 btn:SetHeight(25) | |
101 table.insert(tab.manualElements, btn) | |
102 | |
103 btn:SetScript("OnClick", function() | |
104 tab:Update() | |
105 end) | |
106 | |
107 -- amr client | |
108 text = CreateText(tab.autoElements, tab, "GameFontNormalLarge", chooseText, 0, -20, "AMR CLIENT EXPORT") | |
109 text2 = CreateText(tab.autoElements, tab, "GameFontWhite", text, 0, -15, "1. Open your bank") | |
110 text = CreateText(tab.autoElements, tab, "GameFontWhite", text2, 0, -15, "2. Press the button below to update your AskMrRobot.lua file") | |
111 | |
112 btn = CreateFrame("Button", "AmrExportFile", tab, "UIPanelButtonTemplate") | |
113 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 12, -10) | |
114 btn:SetText("Export to File") | |
115 btn:SetWidth(180) | |
116 btn:SetHeight(25) | |
117 table.insert(tab.autoElements, btn) | |
118 | |
119 btn:SetScript("OnClick", function() | |
120 AskMrRobot.SaveAll() | |
121 ReloadUI() | |
122 end) | |
123 | |
124 text = CreateText(tab.autoElements, tab, "GameFontWhite", btn, -12, -20, "3. Go to AskMrRobot.com and press REFRESH") | |
125 text2 = CreateText(tab.autoElements, tab, "GameFontWhite", text, 10, -5, "(located to the right of your character name near the top of the web page, see screenshot:)") | |
126 | |
127 image = tab:CreateTexture(nil, "BACKGROUND") | |
128 image:SetPoint("TOPLEFT", text2, "BOTTOMLEFT", 2, -10) | |
129 image:SetTexture("Interface\\AddOns\\AskMrRobot\\Media\\BiBScreen") | |
130 table.insert(tab.autoElements, image) | |
131 | |
132 tab:SetScript("OnShow", function() | |
133 tab:Update() | |
134 end) | |
135 | |
136 return tab | |
137 end | |
138 | |
139 -- update the panel and state | |
140 function AskMrRobot.ExportTab:Update() | |
141 | |
142 if (AmrOptions.exportToClient) then | |
143 for i, v in ipairs(self.manualElements) do v:Hide() end | |
144 for i, v in ipairs(self.autoElements) do v:Show() end | |
145 self.btnManual:UnlockHighlight() | |
146 self.btnAuto:LockHighlight() | |
147 else | |
148 for i, v in ipairs(self.autoElements) do v:Hide() end | |
149 for i, v in ipairs(self.manualElements) do v:Show() end | |
150 self.btnAuto:UnlockHighlight() | |
151 self.btnManual:LockHighlight() | |
152 | |
153 AskMrRobot.SaveAll() | |
154 self.txtExportString.EditBox:SetText(AskMrRobot.ExportToString()) | |
155 self.txtExportString.EditBox:HighlightText() | |
156 self.txtExportString.EditBox:SetFocus() | |
157 end | |
158 end |