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@25
|
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@34
|
49 local type,a,b,c = GetCursorInfo()
|
madcatzinc@34
|
50 ClearCursor()
|
madcatzinc@34
|
51 if type=='item' then
|
madcatzinc@34
|
52 local id,link = a,b
|
madcatzinc@34
|
53 return CyborgMMO_CreateWowObject('item', id)
|
madcatzinc@34
|
54 elseif type=='spell' then
|
madcatzinc@34
|
55 local index,book,id = a,b,c
|
madcatzinc@34
|
56 return CyborgMMO_CreateWowObject('spell', id)
|
madcatzinc@34
|
57 elseif type=='macro' then
|
madcatzinc@34
|
58 local index = a
|
madcatzinc@34
|
59 local name = GetMacroInfo(index)
|
madcatzinc@34
|
60 return CyborgMMO_CreateWowObject('macro', name)
|
madcatzinc@34
|
61 elseif type=='companion' then
|
madcatzinc@34
|
62 local index,subtype = a,b
|
madcatzinc@34
|
63 local spellID = select(3, GetCompanionInfo(subtype, index))
|
madcatzinc@34
|
64 return CyborgMMO_CreateWowObject('companion', spellID)
|
madcatzinc@34
|
65 elseif type=='battlepet' then
|
madcatzinc@34
|
66 local petID = a
|
madcatzinc@34
|
67 return CyborgMMO_CreateWowObject('battlepet', petID)
|
madcatzinc@49
|
68 elseif type=='equipmentset' then
|
madcatzinc@49
|
69 local name = a
|
madcatzinc@49
|
70 return CyborgMMO_CreateWowObject('equipmentset', name)
|
madcatzinc@34
|
71 elseif type=='petaction' then
|
madcatzinc@34
|
72 return nil
|
madcatzinc@34
|
73 elseif type=='money' then
|
madcatzinc@34
|
74 return nil
|
madcatzinc@34
|
75 elseif type=='merchant' then
|
madcatzinc@34
|
76 return nil
|
madcatzinc@34
|
77 elseif type==nil then
|
madcatzinc@34
|
78 return nil
|
madcatzinc@34
|
79 else
|
madcatzinc@34
|
80 CyborgMMO_DPrint("unexpected cursor info:", type, a, b, c)
|
madcatzinc@34
|
81 return nil
|
madcatzinc@18
|
82 end
|
madcatzinc@18
|
83 end
|
madcatzinc@18
|
84
|
madcatzinc@18
|
85 function RatPageController_methods:CallbackDropped(callbackObject)
|
madcatzinc@18
|
86 local slot = nil
|
madcatzinc@18
|
87 local observers = CyborgMMO_RatPageModel:GetAllObservers()
|
madcatzinc@18
|
88 for i=1,#observers do
|
madcatzinc@18
|
89 if MouseIsOver(observers[i]) then
|
madcatzinc@18
|
90 slot = observers[i]
|
madcatzinc@18
|
91 break
|
madcatzinc@0
|
92 end
|
madcatzinc@18
|
93 end
|
madcatzinc@18
|
94 if slot then
|
madcatzinc@18
|
95 CyborgMMO_RatPageModel:SetObjectOnButton(slot.Id, CyborgMMO_RatPageModel:GetMode(), callbackObject.wowObject)
|
madcatzinc@18
|
96 end
|
madcatzinc@18
|
97 end
|
madcatzinc@0
|
98
|
madcatzinc@18
|
99 ------------------------------------------------------------------------------
|
madcatzinc@0
|
100
|
madcatzinc@18
|
101 CyborgMMO_RatPageController = RatPageController()
|
madcatzinc@13
|
102
|