Mercurial > wow > cyborg-mmo7
comparison RatPageView.lua @ 0:bf9220814fb5
The first version of the Cyborg MMO7 addon for warcraft
author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 |
---|---|
date | Tue, 24 Jan 2012 17:14:21 +0000 |
parents | |
children | d186f8cd5000 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf9220814fb5 |
---|---|
1 --~ Warcraft Plugin for Cyborg MMO7 | |
2 --~ Filename: RatPageView.lua | |
3 --~ Description: Interaction logic for the RatPage | |
4 --~ Copyright (C) 2012 Mad Catz Inc. | |
5 --~ Author: Christopher Hooks | |
6 | |
7 --~ This program is free software; you can redistribute it and/or | |
8 --~ modify it under the terms of the GNU General Public License | |
9 --~ as published by the Free Software Foundation; either version 2 | |
10 --~ of the License, or (at your option) any later version. | |
11 | |
12 --~ This program is distributed in the hope that it will be useful, | |
13 --~ but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 --~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 --~ GNU General Public License for more details. | |
16 | |
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 | |
19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | |
21 RatPageView = { | |
22 new = function(self) | |
23 msg("new Rat Page View"); | |
24 for _, child in ipairs(self:GetChildren()) do | |
25 child.Register(); | |
26 end | |
27 | |
28 self.SlotClicked = function(slot) | |
29 msg("View Recieved Click") | |
30 RatPageController.Instance().SlotClicked(slot) | |
31 end | |
32 | |
33 self.ModeClicked = function(mode) | |
34 msg("View Recieved Click") | |
35 RatPageController.Instance().ModeClicked(mode) | |
36 end | |
37 | |
38 self.RegisterMode = function() | |
39 msg("ModeRegistered") | |
40 end | |
41 | |
42 self.RegisterSlot = function() | |
43 msg("SlotRegistered") | |
44 end | |
45 return self; | |
46 end | |
47 } | |
48 | |
49 RatQuickPageView = { | |
50 new = function(self) | |
51 for _, child in ipairs(self:GetChildren()) do | |
52 child.Register(); | |
53 end | |
54 | |
55 self.SlotClicked = function(slot) | |
56 RatPageController.Instance().SlotClicked(slot) | |
57 end | |
58 | |
59 return self; | |
60 end | |
61 } | |
62 | |
63 -- Slot Class -- | |
64 SlotView = { | |
65 new = function(self, parent) | |
66 self._assignedWowObject = nil; | |
67 self:RegisterForClicks("LeftButtonUp", "RightButtonUp"); | |
68 self.Id = self:GetID(); | |
69 RatPageModel.Instance().AddObserver(self); | |
70 self.UnCheckedTexture = self:GetNormalTexture(); | |
71 | |
72 -- Object Method -- | |
73 self.Clicked = function() | |
74 self:GetParent().SlotClicked(self) | |
75 | |
76 GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); | |
77 --GameTooltip:SetText(self:GetID()); | |
78 end | |
79 | |
80 self.Update = function(data, activeMode) | |
81 local icon = _G[self:GetName().."Icon"]; | |
82 if(nil ~= data[activeMode][self.Id]) then | |
83 self:SetChecked(true); | |
84 icon:SetTexture(data[activeMode][self.Id].Texture); | |
85 else | |
86 icon:SetTexture(nil); | |
87 self:SetChecked(false); | |
88 end | |
89 | |
90 | |
91 end | |
92 | |
93 return self; | |
94 end, | |
95 } | |
96 | |
97 SlotMiniView = { | |
98 new = function(self, parent) | |
99 self._assignedWowObject = nil; | |
100 self.Id = self:GetID(); | |
101 RatPageModel.Instance().AddObserver(self); | |
102 self.UnCheckedTexture = self:GetNormalTexture(); | |
103 | |
104 self.Update = function(data, activeMode) | |
105 local icon = _G[self:GetName().."Icon"]; | |
106 if(nil ~= data[activeMode][self.Id]) then | |
107 self:SetChecked(true); | |
108 | |
109 icon:SetTexture(data[activeMode][self.Id].Texture); | |
110 icon:SetAlpha(.5); | |
111 else | |
112 icon:SetTexture(nil); | |
113 self:SetChecked(false); | |
114 end | |
115 end | |
116 | |
117 return self; | |
118 end | |
119 } | |
120 | |
121 | |
122 -- ModeButton -- | |
123 ModeView = { | |
124 new = function(self) | |
125 self.Id = self:GetID(); | |
126 self.Name = self:GetName(); | |
127 RatPageModel.Instance().AddObserver(self); | |
128 if(self.Id ~= 1) then | |
129 self:Hide() | |
130 end | |
131 | |
132 self.Clicked = function() | |
133 local nextMode; | |
134 if(self.Id == 1) then | |
135 nextMode = getglobal("Mode2"); | |
136 else | |
137 if(self.Id == 2) then | |
138 nextMode = getglobal("Mode3"); | |
139 else | |
140 nextMode = getglobal("Mode1"); | |
141 end | |
142 end | |
143 self:GetParent().ModeClicked(nextMode) | |
144 end | |
145 | |
146 self.Update = function(data, activeMode) | |
147 if(self.Id == activeMode) then | |
148 self:Show() | |
149 else | |
150 self:Hide() | |
151 end | |
152 | |
153 end | |
154 | |
155 return self; | |
156 end | |
157 } |