Mercurial > wow > askmrrobot
comparison AskMrRobotUi.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 | 6f1bb8fcf64d |
comparison
equal
deleted
inserted
replaced
16:9793e8b683d2 | 17:e77e01abce98 |
---|---|
1 local _, AskMrRobot = ... | 1 local _, AskMrRobot = ... |
2 local L = AskMrRobot.L; | 2 local L = AskMrRobot.L; |
3 | 3 |
4 local showImportDetailsError = nil | |
5 local showImportErrorTab = nil | |
6 | |
7 AskMrRobot.AmrUI = AskMrRobot.inheritsFrom(AskMrRobot.Frame) | 4 AskMrRobot.AmrUI = AskMrRobot.inheritsFrom(AskMrRobot.Frame) |
8 | 5 |
9 function AskMrRobot.AmrUI:swapSimilarSlotsIfNeeded(slotName1, slotName2) | 6 local _menuIds = { |
10 local slotId1 = GetInventorySlotInfo(slotName1) | 7 export = 1, |
11 local slotId2 = GetInventorySlotInfo(slotName2) | 8 gear = 2, |
12 local slotNum1 = AskMrRobot.slotIdToSlotNum[slotId1] | 9 combatLog = 3, |
13 local slotNum2 = AskMrRobot.slotIdToSlotNum[slotId2] | 10 help = 4 |
11 } | |
14 | 12 |
15 local itemLink1 = GetInventoryItemLink("player", slotId1) | 13 function AskMrRobot.AmrUI:new() |
16 local itemLink2 = GetInventoryItemLink("player", slotId2) | 14 local o = AskMrRobot.Frame:new("AskMrRobot_Dialog", nil, "BasicFrameTemplateWithInset") |
17 | 15 |
18 -- see how bad the items are in the original order | 16 -- use the AmrUI class |
19 AskMrRobot.populateItemDiffs(self.importedItems[slotNum1], itemLink1, slotNum1) | 17 setmetatable(o, { __index = AskMrRobot.AmrUI }) |
20 AskMrRobot.populateItemDiffs(self.importedItems[slotNum2], itemLink2, slotNum2) | |
21 | 18 |
22 local badCountOriginalOrder = 0 | 19 o:RegisterForDrag("LeftButton"); |
23 if AskMrRobot.itemDiffs.items[slotNum1] then badCountOriginalOrder = badCountOriginalOrder + 1 end | 20 o:SetWidth(615) |
24 if AskMrRobot.itemDiffs.items[slotNum2] then badCountOriginalOrder = badCountOriginalOrder + 1 end | 21 o:SetHeight(550) |
22 o.InsetBg:SetPoint("TOPLEFT", 140, -24) | |
25 | 23 |
26 -- try the order swapped | 24 o:SetParent("UIParent") |
27 AskMrRobot.populateItemDiffs(self.importedItems[slotNum1], itemLink2, slotNum1) | 25 o:SetPoint("CENTER") |
28 AskMrRobot.populateItemDiffs(self.importedItems[slotNum2], itemLink1, slotNum2) | 26 o:Hide() |
27 o:EnableMouse(true) | |
28 o:EnableKeyboard(true) | |
29 o.hideOnEscape = 1 | |
30 o:SetMovable(true) | |
31 o:SetToplevel(true) | |
29 | 32 |
30 local badCountNewOrder = 0 | 33 o:SetScript("OnDragStart", AskMrRobot.AmrUI.OnDragStart) |
31 if AskMrRobot.itemDiffs.items[slotNum1] then badCountNewOrder = badCountNewOrder + 1 end | 34 o:SetScript("OnDragStop", AskMrRobot.AmrUI.OnDragStop) |
32 if AskMrRobot.itemDiffs.items[slotNum2] then badCountNewOrder = badCountNewOrder + 1 end | 35 o:SetScript("OnHide", AskMrRobot.AmrUI.OnHide) |
36 o:SetScript("OnShow", AskMrRobot.AmrUI.OnShow) | |
33 | 37 |
34 -- if the items were less bad in the new order, swap the imported items | 38 o:RegisterEvent("AUCTION_HOUSE_CLOSED") |
35 if badCountNewOrder < badCountOriginalOrder then | 39 o:RegisterEvent("AUCTION_HOUSE_SHOW") |
36 local tempItem = self.importedItems[slotNum1] | 40 o:RegisterEvent("SOCKET_INFO_UPDATE") |
37 self.importedItems[slotNum1] = self.importedItems[slotNum2] | 41 o:RegisterEvent("SOCKET_INFO_CLOSE") |
38 self.importedItems[slotNum2] = tempItem | 42 |
39 end | 43 o:SetScript("OnEvent", function(...) |
44 o:OnEvent(...) | |
45 end) | |
46 | |
47 tinsert(UISpecialFrames, o:GetName()) | |
48 | |
49 -- initialize some fields | |
50 o.initialized = false | |
51 o.visible = false | |
52 | |
53 -- title | |
54 o.TitleText:SetText("--BETA-- Ask Mr. Robot v" .. GetAddOnMetadata(AskMrRobot.AddonName, "Version")) | |
55 | |
56 -- create the main menu | |
57 o.menu = o:createMainMenu() | |
58 | |
59 local tabArea = AskMrRobot.Frame:new(nil, o) | |
60 tabArea:SetPoint("TOPLEFT", 155, -30) | |
61 tabArea:SetPoint("BOTTOMRIGHT") | |
62 | |
63 o.exportTab = AskMrRobot.ExportTab:new(tabArea) | |
64 o.menu[_menuIds["export"]].element = o.exportTab | |
65 | |
66 o.gearComparisonTab = AskMrRobot.GearComparisonTab:new(tabArea) | |
67 o.menu[_menuIds["gear"]].element = o.gearComparisonTab | |
68 | |
69 o.combatLogTab = AskMrRobot.CombatLogTab:new(tabArea) | |
70 o.menu[_menuIds["combatLog"]].element = o.combatLogTab | |
71 | |
72 o.helpTab = AskMrRobot.HelpTab:new(tabArea) | |
73 o.menu[_menuIds["help"]].element = o.helpTab | |
74 | |
75 o:Hide() | |
76 o:ShowMenu("export") | |
77 | |
78 return o | |
40 end | 79 end |
41 | 80 |
42 function AskMrRobot.AmrUI:displayImportItems() | 81 function AskMrRobot.AmrUI:createMainMenu() |
43 if not self.importedItems then | |
44 return false | |
45 end | |
46 | |
47 --see if rings or trinkets are swapped, and alter self.importedItems accordingly | |
48 self:swapSimilarSlotsIfNeeded("Finger0Slot", "Finger1Slot") | |
49 self:swapSimilarSlotsIfNeeded("Trinket0Slot", "Trinket1Slot") | |
50 | |
51 for slotNum = 1, #AskMrRobot.slotIds do | |
52 if AskMrRobot.OptimizationSlots[slotNum] then | |
53 local slotId = AskMrRobot.slotIds[slotNum] | |
54 local itemLink = GetInventoryItemLink("player", slotId) | |
55 AskMrRobot.populateItemDiffs(self.importedItems[slotNum], itemLink, slotNum) | |
56 end | |
57 end | |
58 | |
59 self.summaryTab:showBadItems() | |
60 | |
61 -- if there are incorrect items equiped, display errors on other tabs | |
62 if AskMrRobot.itemDiffs and AskMrRobot.itemDiffs.items then | |
63 for k,v in pairs(AskMrRobot.itemDiffs.items) do | |
64 if not v.needsUpgrade then | |
65 self.hasImportError = true | |
66 end | |
67 end | |
68 end | |
69 | |
70 if self.hasImportError then | |
71 showImportDetailsError() | |
72 else | |
73 self.gemTab:Update() | |
74 self.enchantTab:showBadEnchants() | |
75 self.reforgeTab:Render() | |
76 self.shoppingTab:Update() | |
77 end | |
78 end | |
79 | |
80 function AskMrRobot.AmrUI:showImportError(text, ...) | |
81 self.summaryTab:showImportError(text, ...) | |
82 if text then | |
83 self.hasImportError = true | |
84 showImportDetailsError() | |
85 else | |
86 self.hasImportError = false | |
87 end | |
88 end | |
89 | |
90 function AskMrRobot.AmrUI:showImportWarning(text, ...) | |
91 self.summaryTab:showImportWarning(text, ...) | |
92 self.hasImportError = false | |
93 if text then | |
94 showImportDetailsError() | |
95 end | |
96 end | |
97 | |
98 function AskMrRobot.AmrUI:validateInput(input) | |
99 | |
100 self.importedItems = nil | |
101 self.mostlySuccess = false | |
102 | |
103 local parsed = AskMrRobot.parseAmr(input) | |
104 | |
105 if not parsed.realm then | |
106 self:showImportError(L.AMR_UI_IMPORT_ERROR_IMPROPER,L.AMR_UI_IMPORT_ERROR_IMPROPER_GOTO) | |
107 elseif not AskMrRobot.validateCharacterName(parsed.name) then | |
108 self:showImportError(L.AMR_UI_IMPORT_ERROR_CHARACTER:format(parsed.name), L.AMR_UI_IMPORT_ERROR_CHARACTER_GOTO) | |
109 elseif not AskMrRobot.validateRace(parsed.race) then | |
110 self:showImportError(L.AMR_UI_IMPORT_ERROR_RACE, L.AMR_UI_IMPORT_ERROR_RACE_CURRENT:format(parsed.race)) | |
111 elseif not AskMrRobot.validateFaction(parsed.faction) then | |
112 self:showImportError(L.AMR_UI_IMPORT_ERROR_FACTION, L.AMR_UI_IMPORT_ERROR_FACTION_CURRENT:format(parsed.faction)) | |
113 elseif not AskMrRobot.validateProfessions(parsed.professions) then | |
114 self:showImportError(L.AMR_UI_IMPORT_ERROR_PROFESSIONS, L.AMR_UI_IMPORT_ERROR_PROFESSIONS_GOTO) | |
115 elseif not AskMrRobot.validateSpec(parsed.spec) then | |
116 if parsed.spec and parsed.spec ~= 'nil' then | |
117 local _, specName = GetSpecializationInfoByID(parsed.spec) | |
118 self:showImportError(L.AMR_UI_IMPORT_ERROR_SPEC, L.AMR_UI_IMPORT_ERROR_SPEC_CHANGE:format(specName)) | |
119 else | |
120 self:showImportError(L.AMR_UI_IMPORT_ERROR_SPEC, L.AMR_UI_IMPORT_ERROR_SPEC_UNEXPECTED) | |
121 end | |
122 self.mostlySuccess = true | |
123 self.summaryTab.badRealm = nil | |
124 self.summaryTab.badTalents = nil | |
125 self.summaryTab.badGlyphs = nil | |
126 AmrImportString = input | |
127 else | |
128 self.summaryTab.badRealm = not AskMrRobot.validateRealm(parsed.realm) and parsed.realm | |
129 self.summaryTab.badTalents = not AskMrRobot.validateTalents(parsed.talents) | |
130 self.summaryTab.badGlyphs = not AskMrRobot.validateGlyphs(parsed.glyphs) | |
131 self.mostlySuccess = true | |
132 self:showImportError(nil) | |
133 AmrImportString = input | |
134 self.importedItems = parsed.items | |
135 return self:displayImportItems() | |
136 end | |
137 return false | |
138 end | |
139 | |
140 local function createImportDetailsErrorTab(reforgeFrame) | |
141 local tab = CreateFrame("Frame", nil, reforgeFrame) | |
142 tab:SetPoint("TOPLEFT") | |
143 tab:SetPoint("BOTTOMRIGHT") | |
144 tab:Hide() | |
145 | |
146 local text = tab:CreateFontString("AmrImportDetailsText1", "ARTWORK", "GameFontNormalLarge") | |
147 text:SetPoint("TOPLEFT", 0, -5) | |
148 text:SetText("Help") | |
149 | |
150 local errorText1 = tab:CreateFontString("AmrImportDetailsText2", "ARTWORK", "GameFontRed") | |
151 errorText1:SetPoint("TOPLEFT", "AmrImportDetailsText1", "BOTTOMLEFT", 0, -20) | |
152 errorText1:SetText(L.AMR_UI_IMPORT_ERROR_NO_IMPORT) | |
153 errorText1:SetPoint("RIGHT", -10, 0) | |
154 errorText1:SetWidth(errorText1:GetWidth()) | |
155 errorText1:SetJustifyH("LEFT") | |
156 | |
157 showImportDetailsError = function() | |
158 errorText1:SetText(L.AMR_UI_IMPORT_ERROR_CANT_OPTIMIZE) | |
159 end | |
160 | |
161 showImportErrorTab = function(tabName) | |
162 if not tabName then | |
163 tab:Hide() | |
164 else | |
165 text:SetText(tabName) | |
166 tab:Show() | |
167 end | |
168 end | |
169 | |
170 return tab | |
171 end | |
172 | |
173 function AskMrRobot.AmrUI:createTabButtons() | |
174 local importTabButton = CreateFrame("Button", "AmrImportTabButton", self, "OptionsListButtonTemplate") | |
175 | |
176 local buttons = {} | 82 local buttons = {} |
177 self.hasImportError = true | |
178 | 83 |
179 local function onTabButtonClick(clickedButton, event, ...) | 84 local function onTabButtonClick(clickedButton, event, ...) |
180 showImportErrorTab(nil) | |
181 for i = 1, #buttons do | 85 for i = 1, #buttons do |
182 local button = buttons[i] | 86 local button = buttons[i] |
183 if clickedButton == button then | 87 if clickedButton == button then |
184 button.highlight:SetVertexColor(1, 1, 0) | 88 button.highlight:SetVertexColor(1, 1, 0) |
185 button:LockHighlight() | 89 button:LockHighlight() |
186 if self.hasImportError and button.isImportDetails then | 90 if button.element then |
187 showImportErrorTab(button:GetText()) | 91 button.element:Show() |
188 elseif button.element then | 92 end |
189 button.element:Show() | |
190 end | |
191 else | 93 else |
192 button.highlight:SetVertexColor(.196, .388, .8) | 94 button.highlight:SetVertexColor(.196, .388, .8) |
193 button:UnlockHighlight() | 95 button:UnlockHighlight() |
194 if button.element then | 96 if button.element then |
195 button.element:Hide() | 97 button.element:Hide() |
196 end | 98 end |
197 end | 99 end |
198 end | 100 end |
199 end | 101 end |
200 | 102 |
201 local function createButton(text, spacing, isImportDetails) | 103 local function createButton(text, spacing) |
202 local lastButton = #buttons | 104 local lastButton = #buttons |
203 local i = lastButton + 1 | 105 local i = lastButton + 1 |
204 local tabButton = CreateFrame("Button", "AmrTabButton" .. i, self, "OptionsListButtonTemplate") | 106 local tabButton = CreateFrame("Button", "AmrTabButton" .. i, self, "OptionsListButtonTemplate") |
205 tabButton.isImportDetails = isImportDetails | |
206 tabButton:SetText(text) | 107 tabButton:SetText(text) |
207 tabText = tabButton:GetFontString() | 108 tabText = tabButton:GetFontString() |
208 tabText:SetPoint("LEFT", 6, 0) | 109 tabText:SetPoint("LEFT", 6, 0) |
209 if i == 1 then | 110 if i == 1 then |
210 tabButton:SetPoint("TOPLEFT", 2, spacing) | 111 tabButton:SetPoint("TOPLEFT", 2, spacing) |
211 else | 112 else |
212 tabButton:SetPoint("TOPLEFT", "AmrTabButton" .. lastButton, "BOTTOMLEFT", 0, spacing) | 113 tabButton:SetPoint("TOPLEFT", "AmrTabButton" .. lastButton, "BOTTOMLEFT", 0, spacing) |
213 end | 114 end |
214 tabButton:SetWidth(125) | 115 tabButton:SetWidth(140) |
215 tabButton:SetHeight(20) | 116 tabButton:SetHeight(20) |
216 tinsert(buttons, tabButton) | 117 tinsert(buttons, tabButton) |
217 tabButton:SetScript("OnClick", onTabButtonClick) | 118 tabButton:SetScript("OnClick", onTabButtonClick) |
218 end | 119 end |
219 | 120 |
220 createButton(L.AMR_UI_BUTTON_IMPORT, -35, false) | 121 createButton(L.AMR_UI_MENU_EXPORT, -35) |
221 createButton(L.AMR_UI_BUTTON_SUMMARY, -20, false) | 122 createButton(L.AMR_UI_MENU_GEAR, -20) |
222 createButton(L.AMR_UI_BUTTON_GEMS, 0, true) | 123 createButton(L.AMR_UI_MENU_COMBAT_LOG, 0) |
223 createButton(L.AMR_UI_BUTTON_ENCHANTS, 0, true) | 124 createButton(L.AMR_UI_MENU_HELP, 0) |
224 createButton(L.AMR_UI_BUTTON_REFORGES, 0, true) | |
225 createButton(L.AMR_UI_BUTTON_SHOPPING_LIST, 0, true) | |
226 createButton(L.AMR_UI_BUTTON_BEST_IN_BAGS, -20, false) | |
227 createButton(L.AMR_UI_BUTTON_COMBAT_LOG, 0, false) | |
228 createButton(L.AMR_UI_BUTTON_HELP, -20, false) | |
229 | 125 |
230 return buttons | 126 return buttons |
231 end | 127 end |
232 | 128 |
233 function AskMrRobot.AmrUI:new() | 129 function AskMrRobot.AmrUI:ShowMenu(menu) |
234 local o = AskMrRobot.Frame:new("AskMrRobot_Dialog", nil, "BasicFrameTemplateWithInset") | 130 local id = _menuIds[menu] |
235 | 131 if id then |
236 -- use the AmrUI class | 132 self.menu[id]:Click() |
237 setmetatable(o, { __index = AskMrRobot.AmrUI }) | 133 end |
238 | |
239 o:RegisterForDrag("LeftButton"); | |
240 o:SetWidth(600) | |
241 o:SetHeight(530) | |
242 o.InsetBg:SetPoint("TOPLEFT", 125, -24) | |
243 | |
244 o:SetParent("UIParent") | |
245 o:SetPoint("CENTER") | |
246 o:Hide() | |
247 o:EnableMouse(true) | |
248 o:EnableKeyboard(true) | |
249 o.hideOnEscape = 1 | |
250 o:SetMovable(true) | |
251 o:SetToplevel(true) | |
252 | |
253 --o:SetScript("OnEscapePressed", function) | |
254 o:SetScript("OnDragStart", AskMrRobot.AmrUI.OnDragStart) | |
255 o:SetScript("OnDragStop", AskMrRobot.AmrUI.OnDragStop) | |
256 o:SetScript("OnHide", AskMrRobot.AmrUI.OnHide) | |
257 -- make the UI show the first tab when its opened | |
258 o:SetScript("OnShow", AskMrRobot.AmrUI.OnShow) | |
259 | |
260 o:RegisterEvent("AUCTION_HOUSE_CLOSED") | |
261 o:RegisterEvent("AUCTION_HOUSE_SHOW") | |
262 o:RegisterEvent("FORGE_MASTER_OPENED") | |
263 o:RegisterEvent("FORGE_MASTER_CLOSED") | |
264 o:RegisterEvent("SOCKET_INFO_UPDATE") | |
265 o:RegisterEvent("SOCKET_INFO_CLOSE") | |
266 | |
267 o:SetScript("OnEvent", function(...) | |
268 o:OnEvent(...) | |
269 end) | |
270 | |
271 tinsert(UISpecialFrames, o:GetName()) | |
272 | |
273 -- title | |
274 o.TitleText:SetText("Ask Mr. Robot " .. GetAddOnMetadata(AskMrRobot.AddonName, "Version")) | |
275 | |
276 -- create the tab buttons | |
277 o.buttons = o:createTabButtons() | |
278 | |
279 local tabArea = AskMrRobot.Frame:new(nil, o) | |
280 tabArea:SetPoint("TOPLEFT", 140, -30) | |
281 tabArea:SetPoint("BOTTOMRIGHT") | |
282 | |
283 createImportDetailsErrorTab(tabArea) | |
284 | |
285 -- create the import tab and associated it with the import tab button | |
286 o.importTab = AskMrRobot.ImportTab:new(tabArea) | |
287 o.buttons[1].element = o.importTab | |
288 o.importTab.scrollFrame.EditBox:SetScript("OnEscapePressed", function() | |
289 o:Hide() | |
290 end) | |
291 | |
292 o.importTab.button:SetScript("OnClick", function(...) | |
293 o.summaryTab.importDate = date() | |
294 AmrImportDate = o.summaryTab.importDate | |
295 o:OnUpdate() | |
296 if o.mostlySuccess then | |
297 -- save import between sessions | |
298 AmrImportString = o.importTab.scrollFrame.EditBox:GetText() | |
299 AmrImportDate = o.summaryTab.importDate | |
300 end | |
301 o:ShowTab("summary") | |
302 end) | |
303 | |
304 o.summaryTab = AskMrRobot.SummaryTab:new(tabArea) | |
305 o.buttons[2].element = o.summaryTab | |
306 | |
307 o.gemTab = AskMrRobot.GemTab:new(nil, tabArea) | |
308 o.buttons[3].element = o.gemTab | |
309 | |
310 o.enchantTab = AskMrRobot.EnchantTab:new(tabArea) | |
311 o.buttons[4].element = o.enchantTab | |
312 | |
313 o.reforgeTab = AskMrRobot.ReforgesTab:new(tabArea) | |
314 o.buttons[5].element = o.reforgeTab | |
315 | |
316 o.shoppingTab = AskMrRobot.ShoppingListTab:new(tabArea) | |
317 o.buttons[6].element = o.shoppingTab | |
318 | |
319 o.shoppingTab.sendTo:SetScript("OnEscapePressed", function() | |
320 o:Hide() | |
321 end) | |
322 | |
323 o.exportTab = AskMrRobot.ExportTab:new(tabArea) | |
324 o.buttons[7].element = o.exportTab | |
325 | |
326 o.combatLogTab = AskMrRobot.CombatLogTab:new(tabArea) | |
327 o.buttons[8].element = o.combatLogTab | |
328 | |
329 o.helpTab = AskMrRobot.HelpTab:new(tabArea) | |
330 o.buttons[9].element = o.helpTab | |
331 | |
332 o.isSocketWindowVisible = false | |
333 o.isReforgeVisible = false | |
334 o.isAuctionHouseVisible = false | |
335 | |
336 --hide the UI | |
337 o:Hide() | |
338 | |
339 o:ShowTab("import") | |
340 | |
341 o.initialize = false | |
342 | |
343 return o | |
344 end | 134 end |
345 | 135 |
346 function AskMrRobot.AmrUI:OnUpdate() | 136 function AskMrRobot.AmrUI:Toggle() |
347 local input = self.importTab.scrollFrame.EditBox:GetText() | 137 if self.visible then |
348 if input and input:len() > 0 then | 138 self:Hide() |
349 self:validateInput(input) | 139 else |
140 self.visible = true | |
141 self:Show() | |
350 end | 142 end |
351 end | 143 end |
352 | 144 |
353 function AskMrRobot.AmrUI:OnShow() | 145 function AskMrRobot.AmrUI:OnShow() |
354 | 146 |
355 if not self.initialized then | |
356 -- remember the import settings between sessions | |
357 self.importTab.scrollFrame.EditBox:SetText(AmrImportString or "") | |
358 self.initialized = true | |
359 end | |
360 | |
361 self:OnUpdate() | |
362 end | 147 end |
363 | 148 |
364 function AskMrRobot.AmrUI:OnDragStart() | 149 function AskMrRobot.AmrUI:OnDragStart() |
365 if not self.isLocked then | 150 if not self.isLocked then |
366 self:StartMoving(); | 151 self:StartMoving(); |
374 function AskMrRobot.AmrUI:OnHide() | 159 function AskMrRobot.AmrUI:OnHide() |
375 self.visible = false | 160 self.visible = false |
376 self:StopMovingOrSizing() | 161 self:StopMovingOrSizing() |
377 end | 162 end |
378 | 163 |
379 function AskMrRobot.AmrUI:ShowReforgeFrame() | |
380 self.visible = true | |
381 self:Show() | |
382 end | |
383 | |
384 function AskMrRobot.AmrUI:Toggle() | |
385 if self.visible then | |
386 self:Hide() | |
387 else | |
388 self:ShowReforgeFrame() | |
389 end | |
390 end | |
391 | |
392 local nameToButtonNumber = { | |
393 import = 1, | |
394 summary = 2, | |
395 gems = 3, | |
396 enchants = 4, | |
397 reforges = 5, | |
398 shopping = 6, | |
399 export = 7, | |
400 combatLog = 8, | |
401 help = 9 | |
402 } | |
403 | |
404 function AskMrRobot.AmrUI:ShowTab(tabName) | |
405 local buttonNumber = nameToButtonNumber[tabName] | |
406 if buttonNumber then | |
407 self.buttons[buttonNumber]:Click() | |
408 end | |
409 end | |
410 | |
411 function AskMrRobot.AmrUI:OnEvent(frame, event, ...) | 164 function AskMrRobot.AmrUI:OnEvent(frame, event, ...) |
412 local handler = self["On_" .. event] | 165 local handler = self["On_" .. event] |
413 if handler then | 166 if handler then |
414 handler(self, ...) | 167 handler(self, ...) |
415 end | 168 end |
416 end | 169 end |
417 | |
418 function AskMrRobot.AmrUI:On_AUCTION_HOUSE_SHOW() | |
419 self.isAuctionHouseVisible = true | |
420 if self.mostlySuccess then | |
421 local showTab = self.visible | |
422 if not AmrOptions.manualShowShop and not self.visible then | |
423 | |
424 -- show if there is anything to buy | |
425 if self.shoppingTab:HasStuffToBuy() then | |
426 self:Show() | |
427 showTab = true | |
428 end | |
429 end | |
430 | |
431 if showTab then | |
432 self:ShowTab("shopping") | |
433 end | |
434 end | |
435 end | |
436 | |
437 function AskMrRobot.AmrUI:On_AUCTION_HOUSE_CLOSED() | |
438 self.isAuctionHouseVisible = false | |
439 if self.isReforgeVisible then | |
440 self:ShowTab("reforges") | |
441 elseif self.isSocketWindowVisible then | |
442 self:ShowTab("gems") | |
443 end | |
444 end | |
445 | |
446 function AskMrRobot.AmrUI:On_FORGE_MASTER_OPENED() | |
447 self.isReforgeVisible = true | |
448 if self.mostlySuccess then | |
449 local showTab = self.visible | |
450 if not AmrOptions.manualShowReforge and not self.visible then | |
451 | |
452 -- see if there are any reforges to do | |
453 local reforgeCount = 0 | |
454 for slotNum, badReforge in pairs(AskMrRobot.itemDiffs.reforges) do | |
455 reforgeCount = reforgeCount + 1 | |
456 end | |
457 | |
458 if reforgeCount > 0 then | |
459 self:Show() | |
460 showTab = true | |
461 end | |
462 end | |
463 | |
464 if showTab then | |
465 self:ShowTab("reforges") | |
466 end | |
467 end | |
468 end | |
469 | |
470 function AskMrRobot.AmrUI:On_FORGE_MASTER_CLOSED() | |
471 self.isReforgeVisible = false | |
472 if self.isAuctionHouseVisible then | |
473 self:ShowTab("shopping") | |
474 elseif self.isSocketWindowVisible then | |
475 self:ShowTab("gems") | |
476 end | |
477 end | |
478 | |
479 function AskMrRobot.AmrUI:On_SOCKET_INFO_UPDATE() | |
480 self.isSocketWindowVisible = true | |
481 if self.mostlySuccess then | |
482 if not self.visible then | |
483 self:Show() | |
484 end | |
485 self:ShowTab("gems") | |
486 end | |
487 end | |
488 | |
489 function AskMrRobot.AmrUI:On_SOCKET_INFO_CLOSE() | |
490 self.isSocketWindowVisible = false | |
491 if self.isAuctionHouseVisible then | |
492 self:ShowTab("shopping") | |
493 elseif self.isReforgeVisible then | |
494 self:ShowTab("reforges") | |
495 end | |
496 end |