annotate ui/ReforgesTab.lua @ 5:a457c832a294

Removed tag 1.2.12.0
author Adam tegen <adam.tegen@gmail.com>
date Tue, 20 May 2014 23:45:46 -0500
parents ec731d2fe6ba
children ece9167c0d1c
rev   line source
adam@0 1 local _, AskMrRobot = ...
adam@0 2
adam@0 3 --------------------------------------------------------------------
adam@0 4 -- Local Reforge Utility Code
adam@0 5 --------------------------------------------------------------------
adam@0 6
adam@0 7 StaticPopupDialogs["REFORGE_TAB_PLEASE_OPEN"] = {
adam@0 8 text = "You need to open the reforge window for this to work",
adam@0 9 button1 = "Ok",
adam@0 10 timeout = 0,
adam@0 11 whileDead = true,
adam@0 12 hideOnEscape = true,
adam@0 13 preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
adam@0 14 }
adam@0 15
adam@0 16 --from LibReforge
adam@0 17 local SPI = 1
adam@0 18 local DODGE = 2
adam@0 19 local PARRY = 3
adam@0 20 local HIT = 4
adam@0 21 local CRIT = 5
adam@0 22 local HASTE = 6
adam@0 23 local EXP = 7
adam@0 24 local MASTERY = 8
adam@0 25
adam@0 26 --from LibReforge
adam@0 27 local StatNames = {
adam@0 28 ITEM_MOD_SPIRIT_SHORT,
adam@0 29 ITEM_MOD_DODGE_RATING_SHORT,
adam@0 30 ITEM_MOD_PARRY_RATING_SHORT,
adam@0 31 ITEM_MOD_HIT_RATING_SHORT,
adam@0 32 ITEM_MOD_CRIT_RATING_SHORT,
adam@0 33 ITEM_MOD_HASTE_RATING_SHORT,
adam@0 34 ITEM_MOD_EXPERTISE_RATING_SHORT,
adam@0 35 ITEM_MOD_MASTERY_RATING_SHORT
adam@0 36 }
adam@0 37 StatNames[0] = NONE
adam@0 38 local StatToString = {
adam@0 39 "ITEM_MOD_SPIRIT_SHORT",
adam@0 40 "ITEM_MOD_DODGE_RATING_SHORT",
adam@0 41 "ITEM_MOD_PARRY_RATING_SHORT",
adam@0 42 "ITEM_MOD_HIT_RATING_SHORT",
adam@0 43 "ITEM_MOD_CRIT_RATING_SHORT",
adam@0 44 "ITEM_MOD_HASTE_RATING_SHORT",
adam@0 45 "ITEM_MOD_EXPERTISE_RATING_SHORT",
adam@0 46 "ITEM_MOD_MASTERY_RATING_SHORT"
adam@0 47 }
adam@0 48
adam@0 49
adam@0 50 local REFORGE_TABLE_BASE = 112
adam@0 51 local REFORGE_TABLE = {
adam@0 52 {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},
adam@0 53 {2, 1}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8},
adam@0 54 {3, 1}, {3, 2}, {3, 4}, {3, 5}, {3, 6}, {3, 7}, {3, 8},
adam@0 55 {4, 1}, {4, 2}, {4, 3}, {4, 5}, {4, 6}, {4, 7}, {4, 8},
adam@0 56 {5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 6}, {5, 7}, {5, 8},
adam@0 57 {6, 1}, {6, 2}, {6, 3}, {6, 4}, {6, 5}, {6, 7}, {6, 8},
adam@0 58 {7, 1}, {7, 2}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {7, 8},
adam@0 59 {8, 1}, {8, 2}, {8, 3}, {8, 4}, {8, 5}, {8, 6}, {8, 7},
adam@0 60 }
adam@0 61
adam@0 62 --------------- returns the index into the REFORGE_TABLE or nil
adam@0 63 -- returns the reforge id or 0
adam@0 64 local function GetReforgeIdForItem(item)
adam@0 65 local id = tonumber(item:match("item:%d+:%d+:%d+:%d+:%d+:%d+:%-?%d+:%-?%d+:%d+:(%d+)"))
adam@0 66 return (id and id ~= 0 and id or 0)
adam@0 67 end
adam@0 68
adam@0 69 local function GetReforgeIdFromStats(fromStat, toStat)
adam@0 70 if (toStat > fromStat) then
adam@0 71 return REFORGE_TABLE_BASE + 7 * (fromStat - 1) + toStat - 1;
adam@0 72 else
adam@0 73 return REFORGE_TABLE_BASE + 7 * (fromStat - 1) + toStat;
adam@0 74 end
adam@0 75 end
adam@0 76
adam@0 77
adam@0 78 --------------------------------------------------------------------
adam@0 79 -- Initialization
adam@0 80 --------------------------------------------------------------------
adam@0 81 AskMrRobot.ReforgesTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame)
adam@0 82
adam@0 83 function AskMrRobot.ReforgesTab:new(parent)
adam@0 84
adam@0 85 local tab = AskMrRobot.Frame:new(nil, parent)
adam@0 86 setmetatable(tab, { __index = AskMrRobot.ReforgesTab })
adam@0 87 tab:SetPoint("TOPLEFT")
adam@0 88 tab:SetPoint("BOTTOMRIGHT")
adam@0 89 tab:Hide()
adam@0 90
adam@0 91 local text = tab:CreateFontString("AmrReforgesHeader", "ARTWORK", "GameFontNormalLarge")
adam@0 92 text:SetPoint("TOPLEFT", 0, -5)
adam@0 93 text:SetText("Reforges")
adam@0 94
adam@0 95 tab.stamp = AskMrRobot.RobotStamp:new(nil, tab)
adam@0 96 tab.stamp:Hide()
adam@0 97 tab.stamp.smallText:SetText("Your reforges are 100% optimal!")
adam@0 98 tab.stamp:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 2, -15)
adam@0 99 tab.stamp:SetPoint("RIGHT", tab, "RIGHT", -20, 0)
adam@0 100
adam@0 101 tab.reforgeDetails = tab:CreateFontString("AmrReforgeDetails", "ARTWORK", "GameFontWhite")
adam@0 102 tab.reforgeDetails:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -15)
adam@0 103 tab.reforgeDetails:SetPoint("RIGHT", -30, 0)
adam@0 104 tab.reforgeDetails:SetWordWrap(true)
adam@0 105 tab.reforgeDetails:SetJustifyH("LEFT")
adam@0 106 tab.reforgeDetails:SetText('Open a reforge window, then click the "Reforge!" button to do it automatically.')
adam@0 107 tab.reforgeDetails:SetHeight(50)
adam@0 108
adam@0 109 tab.reforgeButton = CreateFrame("Button", "AmrReforgeButton", tab, "UIPanelButtonTemplate")
adam@0 110 tab.reforgeButton:SetText("Reforge!")
adam@0 111 tab.reforgeButton:SetPoint("TOPLEFT", 0, -80)
adam@0 112 tab.reforgeButton:SetWidth(140)
adam@0 113 tab.reforgeButton:SetHeight(20)
adam@0 114 tab.reforgeButton:SetScript("OnClick", function()
adam@0 115 tab:OnReforge()
adam@0 116 end)
adam@0 117
adam@0 118 tab.reforgeCost = tab:CreateFontString(nil, "ARTWORK", "GameFontNormal")
adam@0 119 tab.reforgeCost:SetPoint("TOPLEFT", tab.reforgeButton, "TOPRIGHT", 25, 0)
adam@0 120 tab.reforgeCost:SetPoint("BOTTOM", tab.reforgeButton, "BOTTOM", 0, 0)
adam@0 121 tab.reforgeCost:SetPoint("RIGHT", tab, "RIGHT", -30, 0)
adam@0 122 tab.reforgeCost:SetText('')
adam@0 123
adam@0 124 tab.slotHeader = tab:CreateFontString(nil, "ARTWORK", "GameFontNormal")
adam@0 125 tab.slotHeader:SetText("Slot")
adam@0 126 tab.slotHeader:SetPoint("TOPLEFT", tab.reforgeButton, "BOTTOMLEFT", 0, -30)
adam@0 127
adam@0 128 tab.reforgeHeader = tab:CreateFontString(nil, "ARTWORK", "GameFontNormal")
adam@0 129 tab.reforgeHeader:SetText("Optimal Reforge")
adam@0 130 tab.reforgeHeader:SetPoint("TOPLEFT", tab.slotHeader, "TOPLEFT", 100, 0)
adam@0 131
adam@0 132 -- pre-allocate a visual element for all possible slots; showBadReforges will set text and show the number that are needed, and hide the rest
adam@0 133 tab.slots = {}
adam@0 134 tab.optimized = {}
adam@0 135
adam@0 136 for i = 1, #AskMrRobot.slotNames do
adam@0 137 tab.slots[i] = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite")
adam@0 138 tab.slots[i]:SetPoint("TOPLEFT", tab.slotHeader, "TOPLEFT", 0, -20 * i)
adam@0 139 tab.slots[i]:Hide()
adam@0 140
adam@0 141 tab.optimized[i] = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite")
adam@0 142 tab.optimized[i]:SetPoint("TOPLEFT", tab.reforgeHeader, "TOPLEFT", 0, -20 * i)
adam@0 143 tab.optimized[i]:Hide()
adam@0 144 end
adam@0 145
adam@0 146 tab:RegisterEvent("FORGE_MASTER_ITEM_CHANGED")
adam@0 147 tab:RegisterEvent("FORGE_MASTER_SET_ITEM")
adam@0 148 tab:RegisterEvent("FORGE_MASTER_OPENED")
adam@0 149 tab:RegisterEvent("FORGE_MASTER_CLOSED")
adam@0 150
adam@0 151 tab:SetScript("OnEvent", function(...)
adam@0 152 tab:OnEvent(...)
adam@0 153 end)
adam@0 154
adam@0 155
adam@0 156 -- initialize stat required for performing the reforges
adam@0 157 tab.state = {}
adam@0 158 tab:ResetState()
adam@0 159
adam@0 160
adam@0 161 return tab
adam@0 162 end
adam@0 163
adam@0 164
adam@0 165 --------------------------------------------------------------------
adam@0 166 -- Rendering
adam@0 167 --------------------------------------------------------------------
adam@0 168
adam@0 169 local function GetReforgeString(fromId, toId)
adam@0 170 if toId == 0 then
adam@0 171 return "Restore"
adam@0 172 end
adam@0 173 local pair = REFORGE_TABLE[toId - REFORGE_TABLE_BASE]
adam@0 174
adam@0 175 local text = _G[StatToString[pair[1]]] .. ' -> ' .. _G[StatToString[pair[2]]]
adam@0 176 --print('from ' .. fromId)
adam@0 177 if fromId == 0 then
adam@0 178 return text
adam@0 179 end
adam@0 180 return 'Restore, then ' .. text
adam@0 181 end
adam@0 182
adam@0 183 -- draw all of the reforges that still need to be performed
adam@0 184 function AskMrRobot.ReforgesTab:Render()
adam@0 185
adam@0 186 local reforges = AskMrRobot.itemDiffs.reforges
adam@0 187 local i = 1
adam@0 188 local cost = 0
adam@0 189
adam@0 190 -- for all the bad items
adam@0 191 for slotNum, badReforge in AskMrRobot.sortSlots(reforges) do
adam@0 192
adam@0 193 self.optimized[i]:SetText(GetReforgeString(badReforge.current, badReforge.optimized))
adam@0 194 self.optimized[i]:Show()
adam@0 195
adam@0 196 self.slots[i]:SetText(_G[strupper(AskMrRobot.slotNames[slotNum])])
adam@0 197 self.slots[i]:Show()
adam@0 198
adam@0 199 -- Restore is free, so only add cost for non-restore reforges
adam@0 200 if badReforge.optimized > 0 then
adam@0 201 local slotId = AskMrRobot.slotIds[slotNum]
adam@0 202 local itemLink = GetInventoryItemLink("player", slotId)
adam@0 203 cost = cost + (itemLink and select (11, GetItemInfo(itemLink)) or 0)
adam@0 204 end
adam@0 205
adam@0 206 i = i + 1
adam@0 207 end
adam@0 208
adam@0 209 self.reforgeCost:SetText("Total reforge cost: ~" .. math.ceil(cost / 10000) .. " Gold")
adam@0 210
adam@0 211 -- hide / show the headers
adam@0 212 if i == 1 then
adam@0 213 self.reforgeHeader:Hide()
adam@0 214 self.slotHeader:Hide()
adam@0 215 self.reforgeButton:Hide()
adam@0 216 self.reforgeCost:Hide()
adam@0 217 self.reforgeDetails:Hide()
adam@0 218 self.stamp:Show()
adam@0 219 else
adam@0 220 self.stamp:Hide()
adam@0 221 self.reforgeButton:Show()
adam@0 222 self.reforgeCost:Show()
adam@0 223 self.reforgeHeader:Show()
adam@0 224 self.reforgeDetails:Show()
adam@0 225 self.slotHeader:Show()
adam@0 226 end
adam@0 227
adam@0 228 -- hide the remaining slots
adam@0 229 while i <= #self.slots do
adam@0 230 self.optimized[i]:Hide()
adam@0 231 self.slots[i]:Hide()
adam@0 232 i = i + 1
adam@0 233 end
adam@0 234 end
adam@0 235
adam@0 236 --------------------------------------------------------------------
adam@0 237 -- Reforge Logic
adam@0 238 --------------------------------------------------------------------
adam@0 239
adam@0 240 -- reset state for a fresh pass at automatic reforging
adam@0 241 function AskMrRobot.ReforgesTab:ResetState()
adam@0 242
adam@0 243 self.state.queue = {} -- list of all reforges actions that still need to be performed
adam@0 244 self.state.currentItem = nil -- the current item we are trying to reforge
adam@0 245 self.state.pendingSlot = nil -- the slot that we have requested to place into the reforger
adam@0 246 self.state.currentSlot = nil -- the current slot in the reforger
adam@0 247 self.state.pendingReforge = -1 -- the reforge that we have requested to perform on the current item
adam@0 248 end
adam@0 249
adam@0 250 -- refresh the queue of reforges that still need to be performed
adam@0 251 function AskMrRobot.ReforgesTab:RefreshQueue()
adam@0 252
adam@0 253 -- clear the queue
adam@0 254 self.state.queue = {}
adam@0 255
adam@0 256 local reforges = AskMrRobot.itemDiffs.reforges
adam@0 257
adam@0 258 -- add all reforges that need updating to the reforge queue
adam@0 259 for slotNum, badReforge in AskMrRobot.sortSlots(reforges) do
adam@0 260 self:AddToReforgeQueue(slotNum, badReforge.optimized);
adam@0 261 end
adam@0 262 end
adam@0 263
adam@0 264 function AskMrRobot.ReforgesTab:AddToReforgeQueue(itemSlot, reforgeId)
adam@0 265
adam@0 266 -- the game's slot id, not the same as the ids that we use on our servers
adam@0 267 local gameSlot = AskMrRobot.slotIds[itemSlot]
adam@0 268
adam@0 269 local item = GetInventoryItemLink("player", gameSlot)
adam@0 270 if item == nil then
adam@0 271 --print ('no item')
adam@0 272 return
adam@0 273 end
adam@0 274
adam@0 275 local current = GetReforgeIdForItem(item)
adam@0 276
adam@0 277 if current ~= reforgeId then
adam@0 278 -- restore first
adam@0 279 if current ~= 0 and reforgeId ~= 0 then
adam@0 280 tinsert(self.state.queue, { ["slot"] = gameSlot, ["reforge"] = 0 })
adam@0 281 end
adam@0 282
adam@0 283 -- then reforge to the specified reforge
adam@0 284 tinsert(self.state.queue, { ["slot"] = gameSlot, ["reforge"] = reforgeId })
adam@0 285 end
adam@0 286 end
adam@0 287
adam@0 288 function AskMrRobot.ReforgesTab:IsQueueEmpty()
adam@0 289 return self.state.queue == nil or #self.state.queue == 0 or self.state.queue == {};
adam@0 290 end
adam@0 291
adam@0 292 -- returns true if we are waiting on the game to finish a pending async reforge operation
adam@0 293 function AskMrRobot.ReforgesTab:HasPendingOperation()
adam@0 294
adam@0 295 -- waiting for an item to be placed into the reforger
adam@0 296 if self.state.pendingSlot then
adam@0 297 return true
adam@0 298 end
adam@0 299
adam@0 300 -- waiting for a reforge to be completed
adam@0 301 if self.state.pendingReforge ~= -1 then
adam@0 302 return true
adam@0 303 end
adam@0 304
adam@0 305 return false
adam@0 306 end
adam@0 307
adam@0 308 -- put the next item in the reforge queue into the game's reforge UI
adam@0 309 function AskMrRobot.ReforgesTab:PutNextItemInForge()
adam@0 310
adam@0 311 if self:IsQueueEmpty() or self:HasPendingOperation() then
adam@0 312 return
adam@0 313 end
adam@0 314
adam@0 315 -- get the first action in the queue
adam@0 316 local currentAction = self.state.queue[1]
adam@0 317 local itemSlot = currentAction.slot
adam@0 318
adam@0 319 local item = GetInventoryItemLink("player", itemSlot)
adam@0 320
adam@0 321 -- set current item that we are trying to reforge
adam@0 322 self.state.currentItem = item
adam@0 323
adam@0 324 -- if this item isn't already in the reforger, put it in
adam@0 325 if self.state.currentSlot ~= itemSlot then
adam@0 326 ClearCursor() -- make sure no item is selected
adam@0 327 SetReforgeFromCursorItem() -- pick up the old item (calling this with an item already in the reforger will put it back on the mouse cursor)
adam@0 328 ClearCursor() -- clear the cursor to finish removing any current item from the game reforge UI
adam@0 329 PickupInventoryItem(itemSlot) -- pick up the right equipped item
adam@0 330
adam@0 331 -- pending, listen for an event from the game to complete setting this item into the reforger
adam@0 332 self.state.pendingSlot = itemSlot
adam@0 333
adam@0 334 SetReforgeFromCursorItem() -- put the item into the reforger, and wait for the FORGE_MASTER_SET_ITEM event, which calls DoReforge
adam@0 335 end
adam@0 336
adam@0 337 end
adam@0 338
adam@0 339 -- an item is in the reforger, ready to be reforged, so do it
adam@0 340 function AskMrRobot.ReforgesTab:DoReforge()
adam@0 341
adam@0 342 if self:IsQueueEmpty() or self:HasPendingOperation() then
adam@0 343 return
adam@0 344 end
adam@0 345
adam@0 346 local currentAction = self.state.queue[1]
adam@0 347 local desiredReforge = currentAction.reforge
adam@0 348
adam@0 349 -- the index that needs to be provided to WoW's ReforgeItem method, corresponds to one of the options in the game reforge UI
adam@0 350 local reforgeIndex = -1
adam@0 351
adam@0 352 if desiredReforge ~= 0 then
adam@0 353 local targetFrom = REFORGE_TABLE[desiredReforge - REFORGE_TABLE_BASE][1];
adam@0 354 local targetTo = REFORGE_TABLE[desiredReforge - REFORGE_TABLE_BASE][2];
adam@0 355
adam@0 356 for i=1, GetNumReforgeOptions() do
adam@0 357 local from, _, _, to, _, _ = GetReforgeOptionInfo(i)
adam@0 358 --print(i .. ': ' .. from .. " -> " .. to)
adam@0 359 if StatNames[targetFrom] == from and StatNames[targetTo] == to then
adam@0 360 reforgeIndex = i
adam@0 361 break
adam@0 362 end
adam@0 363 end
adam@0 364 else
adam@0 365 reforgeIndex = 0
adam@0 366 end
adam@0 367
adam@0 368 if reforgeIndex == -1 then
adam@0 369 -- we couldn't do this reforge... we either had a bad reforge (wrong stats on an item), or the game had no options in the UI for some reason
adam@0 370
adam@0 371 -- remove the item from the reforge window
adam@0 372 ClearCursor()
adam@0 373 SetReforgeFromCursorItem()
adam@0 374 ClearCursor()
adam@0 375
adam@0 376 -- reset state and quit reforging (clears the queue)
adam@0 377 self:ResetState()
adam@0 378
adam@0 379 else
adam@0 380
adam@0 381 local currentReforge = GetReforgeIdForItem(self.state.currentItem);
adam@0 382 if currentReforge == desiredReforge then
adam@0 383 -- we already have this reforge on the item... probably shouldn't ever happen, but if it does, recalculate and start over
adam@0 384 tremove(self.state.queue, 1)
adam@0 385
adam@0 386 -- remove the item from the reforge window
adam@0 387 ClearCursor()
adam@0 388 SetReforgeFromCursorItem()
adam@0 389 ClearCursor()
adam@0 390
adam@0 391 -- update the state of the entire UI, and start again with the next required reforge
adam@0 392 AskMrRobot_ReforgeFrame:OnUpdate()
adam@0 393 self:OnReforge()
adam@0 394
adam@0 395 else
adam@0 396 -- we have a reforge (or restore) to do, kick it off and wait for CheckReforge to respond to completion
adam@0 397 self:TryReforge(reforgeIndex)
adam@0 398 end
adam@0 399
adam@0 400 end
adam@0 401
adam@0 402 end
adam@0 403
adam@0 404 -- wraps WoW API call to ReforgeItem, fires a manual timeout in case the UI does not raise an event
adam@0 405 function AskMrRobot.ReforgesTab:TryReforge(reforgeIndex)
adam@0 406
adam@0 407 -- we have a reforge (or restore) to do, kick it off and wait for FORGE_MASTER_ITEM_CHANGED, which calls CheckReforge
adam@0 408 self.state.pendingReforge = reforgeIndex
adam@0 409 ReforgeItem(reforgeIndex)
adam@0 410
adam@0 411 -- sometimes the game doesn't send the FORGE_MASTER_ITEM_CHANGED event, so also check after a delay also
adam@0 412 AskMrRobot.wait(0.250, AskMrRobot.ReforgesTab.CheckReforge, self)
adam@0 413
adam@0 414 end
adam@0 415
adam@0 416 -- check that a requested reforge has been completed
adam@0 417 function AskMrRobot.ReforgesTab:CheckReforge()
adam@0 418
adam@0 419 if self:IsQueueEmpty() or self.state.pendingReforge == -1 then
adam@0 420
adam@0 421 -- responding to a reforge that the user has manually performed, update the UI and terminate any automatic process that is going on
adam@0 422 AskMrRobot_ReforgeFrame:OnUpdate()
adam@0 423 self:ResetState()
adam@0 424
adam@0 425 else
adam@0 426 -- responding to a reforge that we have initiated
adam@0 427
adam@0 428 local currentReforge, icon, name, quality, bound, cost = GetReforgeItemInfo();
adam@0 429 if currentReforge == self.state.pendingReforge then
adam@0 430 tremove(self.state.queue, 1)
adam@0 431
adam@0 432 -- remove the item from the reforge window
adam@0 433 ClearCursor()
adam@0 434 SetReforgeFromCursorItem()
adam@0 435 ClearCursor()
adam@0 436
adam@0 437 -- update the state of the entire UI, and start again with the next required reforge
adam@0 438 AskMrRobot_ReforgeFrame:OnUpdate()
adam@0 439 self:OnReforge()
adam@0 440 else
adam@0 441 -- try again
adam@0 442 self:TryReforge(self.state.pendingReforge)
adam@0 443 end
adam@0 444 end
adam@0 445
adam@0 446 end
adam@0 447
adam@0 448
adam@0 449 --------------------------------------------------------------------
adam@0 450 -- Event Handling
adam@0 451 --------------------------------------------------------------------
adam@0 452
adam@0 453 -- event called when the Mr. Robot Reforge button is clicked, kicks off automatic reforge
adam@0 454 function AskMrRobot.ReforgesTab:OnReforge()
adam@0 455
adam@0 456 -- need to be at a reforger for this to work
adam@0 457 if not self.isReforgeOpen then
adam@0 458 StaticPopup_Show("REFORGE_TAB_PLEASE_OPEN")
adam@0 459 return
adam@0 460 end
adam@0 461
adam@0 462 -- reset state and refresh the queue of reforges that still need to be done
adam@0 463 self:ResetState()
adam@0 464 self:RefreshQueue()
adam@0 465
adam@0 466 -- get goin, put the first item in the reforger
adam@0 467 self:PutNextItemInForge()
adam@0 468 end
adam@0 469
adam@0 470 function AskMrRobot.ReforgesTab:On_FORGE_MASTER_SET_ITEM()
adam@0 471
adam@0 472 if self.state.pendingSlot then
adam@0 473
adam@0 474 -- we have successfully finished placing an item into the reforger
adam@0 475 self.state.currentSlot = self.state.pendingSlot
adam@0 476
adam@0 477 -- indicate that we are no longer waiting for an item
adam@0 478 self.state.pendingSlot = nil
adam@0 479
adam@0 480 -- now reforge it
adam@0 481 self:DoReforge()
adam@0 482 end
adam@0 483
adam@0 484 end
adam@0 485
adam@0 486 function AskMrRobot.ReforgesTab:On_FORGE_MASTER_ITEM_CHANGED()
adam@0 487 self:CheckReforge()
adam@0 488 end
adam@0 489
adam@0 490 function AskMrRobot.ReforgesTab:On_FORGE_MASTER_OPENED()
adam@0 491 self.isReforgeOpen = true
adam@0 492 end
adam@0 493
adam@0 494 function AskMrRobot.ReforgesTab:On_FORGE_MASTER_CLOSED()
adam@0 495 self.isReforgeOpen = false
adam@0 496 end
adam@0 497
adam@0 498 function AskMrRobot.ReforgesTab:OnEvent(frame, event, ...)
adam@0 499 --print("EVENT " .. event)
adam@0 500 local handler = self["On_" .. event]
adam@0 501 if handler then
adam@0 502 handler(self, ...)
adam@0 503 end
adam@0 504 end