Mercurial > wow > cyborg-mmo7
comparison RatPageController.lua @ 18:cccc7661a2e6
Simplified the Rat page model and controller object models.
| author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 |
|---|---|
| date | Thu, 25 Apr 2013 01:30:11 +0000 |
| parents | 80192bc4a108 |
| children | b7074b47cfc7 |
comparison
equal
deleted
inserted
replaced
| 17:e4dec2d465f5 | 18:cccc7661a2e6 |
|---|---|
| 16 | 16 |
| 17 --~ You should have received a copy of the GNU General Public License | 17 --~ You should have received a copy of the GNU General Public License |
| 18 --~ along with this program; if not, write to the Free Software | 18 --~ along with this program; if not, write to the Free Software |
| 19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | 20 |
| 21 CyborgMMO_RatPageController = { | 21 ------------------------------------------------------------------------------ |
| 22 new = function() | |
| 23 local self = {} | |
| 24 CyborgMMO_RatPageModel.Instance().SetMode(1) | |
| 25 | 22 |
| 26 self.SlotClicked = function(slot) | 23 local RatPageController_methods = {} |
| 27 local slotObject = nil | 24 local RatPageController_mt = {__index=RatPageController_methods} |
| 28 slotObject = CyborgMMO_RatPageModel.Instance().GetObjectOnButton(slot.Id) | |
| 29 CyborgMMO_RatPageModel.Instance().SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel.Instance().GetMode(), self.GetCursorObject()) | |
| 30 | 25 |
| 31 if slotObject then | 26 local function RatPageController() |
| 32 slotObject.Pickup() | 27 local self = {} |
| 33 end | 28 -- CyborgMMO_RatPageModel:SetMode(1) |
| 29 setmetatable(self, RatPageController_mt) | |
| 30 return self | |
| 31 end | |
| 32 | |
| 33 function RatPageController_methods:SlotClicked(slot) | |
| 34 local slotObject = nil | |
| 35 slotObject = CyborgMMO_RatPageModel:GetObjectOnButton(slot.Id) | |
| 36 CyborgMMO_RatPageModel:SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel:GetMode(), self:GetCursorObject()) | |
| 37 | |
| 38 if slotObject then | |
| 39 slotObject.Pickup() | |
| 40 end | |
| 41 end | |
| 42 | |
| 43 function RatPageController_methods:ModeClicked(mode) | |
| 44 CyborgMMO_DPrint("Setting mode "..tostring(mode.Id)) | |
| 45 CyborgMMO_RatPageModel:SetMode(mode.Id) | |
| 46 end | |
| 47 | |
| 48 function RatPageController_methods:GetCursorObject() | |
| 49 local cursorObject = nil | |
| 50 if GetCursorInfo() then | |
| 51 local type,detail,subdetail = GetCursorInfo() | |
| 52 cursorObject = CyborgMMO_WowObject.Create(type, detail, subdetail) | |
| 53 ClearCursor() | |
| 54 end | |
| 55 return cursorObject | |
| 56 end | |
| 57 | |
| 58 function RatPageController_methods:CallbackDropped(callbackObject) | |
| 59 local slot = nil | |
| 60 local observers = CyborgMMO_RatPageModel:GetAllObservers() | |
| 61 for i=1,#observers do | |
| 62 if MouseIsOver(observers[i]) then | |
| 63 slot = observers[i] | |
| 64 break | |
| 34 end | 65 end |
| 66 end | |
| 67 if slot then | |
| 68 CyborgMMO_RatPageModel:SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel:GetMode(), callbackObject.wowObject) | |
| 69 end | |
| 70 end | |
| 35 | 71 |
| 36 self.ModeClicked = function(mode) | 72 ------------------------------------------------------------------------------ |
| 37 CyborgMMO_DPrint("Setting mode "..tostring(mode.Id)) | |
| 38 CyborgMMO_RatPageModel.Instance().SetMode(mode.Id) | |
| 39 end | |
| 40 | 73 |
| 41 self.GetCursorObject = function() | 74 CyborgMMO_RatPageController = RatPageController() |
| 42 local cursorObject = nil | |
| 43 if GetCursorInfo() then | |
| 44 local type,detail,subdetail = GetCursorInfo() | |
| 45 cursorObject = CyborgMMO_WowObject.Create(type, detail, subdetail) | |
| 46 ClearCursor() | |
| 47 end | |
| 48 return cursorObject | |
| 49 end | |
| 50 | 75 |
| 51 self.CallbackDropped = function(callbackObject) | |
| 52 local slot = nil | |
| 53 local observers = CyborgMMO_RatPageModel.Instance().GetAllObservers() | |
| 54 for i=1,#observers do | |
| 55 if MouseIsOver(observers[i]) then | |
| 56 slot = observers[i] | |
| 57 break | |
| 58 end | |
| 59 end | |
| 60 if slot then | |
| 61 CyborgMMO_RatPageModel.Instance().SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel.Instance().GetMode(), callbackObject.wowObject) | |
| 62 end | |
| 63 end | |
| 64 | |
| 65 self.Close = function() | |
| 66 end | |
| 67 | |
| 68 self.Open = function() | |
| 69 end | |
| 70 | |
| 71 return self | |
| 72 end, | |
| 73 | |
| 74 m_Instance = nil, | |
| 75 | |
| 76 Instance = function() | |
| 77 if not CyborgMMO_RatPageController.m_Instance then | |
| 78 CyborgMMO_RatPageController.m_Instance = CyborgMMO_RatPageController.new() | |
| 79 end | |
| 80 return CyborgMMO_RatPageController.m_Instance | |
| 81 end, | |
| 82 } | |
| 83 |
