madcatzinc@13
|
1 --~ Warcraft Plugin for Cyborg MMO7
|
madcatzinc@0
|
2 --~ Filename: RatPageController.lua
|
madcatzinc@0
|
3 --~ Description: Controller logic for the RatPage
|
madcatzinc@0
|
4 --~ Copyright (C) 2012 Mad Catz Inc.
|
madcatzinc@0
|
5 --~ Author: Christopher Hooks
|
madcatzinc@0
|
6
|
madcatzinc@0
|
7 --~ This program is free software; you can redistribute it and/or
|
madcatzinc@0
|
8 --~ modify it under the terms of the GNU General Public License
|
madcatzinc@0
|
9 --~ as published by the Free Software Foundation; either version 2
|
madcatzinc@0
|
10 --~ of the License, or (at your option) any later version.
|
madcatzinc@0
|
11
|
madcatzinc@0
|
12 --~ This program is distributed in the hope that it will be useful,
|
madcatzinc@0
|
13 --~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
madcatzinc@0
|
14 --~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
madcatzinc@0
|
15 --~ GNU General Public License for more details.
|
madcatzinc@0
|
16
|
madcatzinc@0
|
17 --~ You should have received a copy of the GNU General Public License
|
madcatzinc@0
|
18 --~ along with this program; if not, write to the Free Software
|
madcatzinc@0
|
19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
madcatzinc@0
|
20
|
madcatzinc@18
|
21 ------------------------------------------------------------------------------
|
madcatzinc@0
|
22
|
madcatzinc@18
|
23 local RatPageController_methods = {}
|
madcatzinc@18
|
24 local RatPageController_mt = {__index=RatPageController_methods}
|
madcatzinc@0
|
25
|
madcatzinc@18
|
26 local function RatPageController()
|
madcatzinc@18
|
27 local self = {}
|
madcatzinc@18
|
28 -- CyborgMMO_RatPageModel:SetMode(1)
|
madcatzinc@18
|
29 setmetatable(self, RatPageController_mt)
|
madcatzinc@18
|
30 return self
|
madcatzinc@18
|
31 end
|
madcatzinc@18
|
32
|
madcatzinc@18
|
33 function RatPageController_methods:SlotClicked(slot)
|
madcatzinc@18
|
34 local slotObject = nil
|
madcatzinc@18
|
35 slotObject = CyborgMMO_RatPageModel:GetObjectOnButton(slot.Id)
|
madcatzinc@18
|
36 CyborgMMO_RatPageModel:SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel:GetMode(), self:GetCursorObject())
|
madcatzinc@18
|
37
|
madcatzinc@18
|
38 if slotObject then
|
madcatzinc@18
|
39 slotObject.Pickup()
|
madcatzinc@18
|
40 end
|
madcatzinc@18
|
41 end
|
madcatzinc@18
|
42
|
madcatzinc@18
|
43 function RatPageController_methods:ModeClicked(mode)
|
madcatzinc@18
|
44 CyborgMMO_DPrint("Setting mode "..tostring(mode.Id))
|
madcatzinc@18
|
45 CyborgMMO_RatPageModel:SetMode(mode.Id)
|
madcatzinc@18
|
46 end
|
madcatzinc@18
|
47
|
madcatzinc@18
|
48 function RatPageController_methods:GetCursorObject()
|
madcatzinc@18
|
49 local cursorObject = nil
|
madcatzinc@18
|
50 if GetCursorInfo() then
|
madcatzinc@18
|
51 local type,detail,subdetail = GetCursorInfo()
|
madcatzinc@18
|
52 cursorObject = CyborgMMO_WowObject.Create(type, detail, subdetail)
|
madcatzinc@18
|
53 ClearCursor()
|
madcatzinc@18
|
54 end
|
madcatzinc@18
|
55 return cursorObject
|
madcatzinc@18
|
56 end
|
madcatzinc@18
|
57
|
madcatzinc@18
|
58 function RatPageController_methods:CallbackDropped(callbackObject)
|
madcatzinc@18
|
59 local slot = nil
|
madcatzinc@18
|
60 local observers = CyborgMMO_RatPageModel:GetAllObservers()
|
madcatzinc@18
|
61 for i=1,#observers do
|
madcatzinc@18
|
62 if MouseIsOver(observers[i]) then
|
madcatzinc@18
|
63 slot = observers[i]
|
madcatzinc@18
|
64 break
|
madcatzinc@0
|
65 end
|
madcatzinc@18
|
66 end
|
madcatzinc@18
|
67 if slot then
|
madcatzinc@18
|
68 CyborgMMO_RatPageModel:SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel:GetMode(), callbackObject.wowObject)
|
madcatzinc@18
|
69 end
|
madcatzinc@18
|
70 end
|
madcatzinc@0
|
71
|
madcatzinc@18
|
72 ------------------------------------------------------------------------------
|
madcatzinc@0
|
73
|
madcatzinc@18
|
74 CyborgMMO_RatPageController = RatPageController()
|
madcatzinc@13
|
75
|