madcatzinc@0
|
1 --~ Warcraft Plugin for Cyborg MMO7
|
madcatzinc@0
|
2 --~ Filename: RatPageView.lua
|
madcatzinc@0
|
3 --~ Description: Interaction 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@0
|
21 RatPageView = {
|
madcatzinc@0
|
22 new = function(self)
|
madcatzinc@0
|
23 msg("new Rat Page View");
|
madcatzinc@0
|
24 for _, child in ipairs(self:GetChildren()) do
|
madcatzinc@0
|
25 child.Register();
|
madcatzinc@0
|
26 end
|
madcatzinc@0
|
27
|
madcatzinc@0
|
28 self.SlotClicked = function(slot)
|
madcatzinc@0
|
29 msg("View Recieved Click")
|
madcatzinc@0
|
30 RatPageController.Instance().SlotClicked(slot)
|
madcatzinc@0
|
31 end
|
madcatzinc@0
|
32
|
madcatzinc@0
|
33 self.ModeClicked = function(mode)
|
madcatzinc@0
|
34 msg("View Recieved Click")
|
madcatzinc@0
|
35 RatPageController.Instance().ModeClicked(mode)
|
madcatzinc@0
|
36 end
|
madcatzinc@0
|
37
|
madcatzinc@0
|
38 self.RegisterMode = function()
|
madcatzinc@0
|
39 msg("ModeRegistered")
|
madcatzinc@0
|
40 end
|
madcatzinc@0
|
41
|
madcatzinc@0
|
42 self.RegisterSlot = function()
|
madcatzinc@0
|
43 msg("SlotRegistered")
|
madcatzinc@0
|
44 end
|
madcatzinc@0
|
45 return self;
|
madcatzinc@0
|
46 end
|
madcatzinc@0
|
47 }
|
madcatzinc@0
|
48
|
madcatzinc@0
|
49 RatQuickPageView = {
|
madcatzinc@0
|
50 new = function(self)
|
madcatzinc@0
|
51 for _, child in ipairs(self:GetChildren()) do
|
madcatzinc@0
|
52 child.Register();
|
madcatzinc@0
|
53 end
|
madcatzinc@0
|
54
|
madcatzinc@0
|
55 self.SlotClicked = function(slot)
|
madcatzinc@0
|
56 RatPageController.Instance().SlotClicked(slot)
|
madcatzinc@0
|
57 end
|
madcatzinc@0
|
58
|
madcatzinc@0
|
59 return self;
|
madcatzinc@0
|
60 end
|
madcatzinc@0
|
61 }
|
madcatzinc@0
|
62
|
madcatzinc@0
|
63 -- Slot Class --
|
madcatzinc@0
|
64 SlotView = {
|
madcatzinc@0
|
65 new = function(self, parent)
|
madcatzinc@0
|
66 self._assignedWowObject = nil;
|
madcatzinc@0
|
67 self:RegisterForClicks("LeftButtonUp", "RightButtonUp");
|
madcatzinc@0
|
68 self.Id = self:GetID();
|
madcatzinc@0
|
69 RatPageModel.Instance().AddObserver(self);
|
madcatzinc@0
|
70 self.UnCheckedTexture = self:GetNormalTexture();
|
madcatzinc@0
|
71
|
madcatzinc@0
|
72 -- Object Method --
|
madcatzinc@0
|
73 self.Clicked = function()
|
madcatzinc@0
|
74 self:GetParent().SlotClicked(self)
|
madcatzinc@0
|
75
|
madcatzinc@0
|
76 GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
|
madcatzinc@0
|
77 --GameTooltip:SetText(self:GetID());
|
madcatzinc@0
|
78 end
|
madcatzinc@0
|
79
|
madcatzinc@0
|
80 self.Update = function(data, activeMode)
|
madcatzinc@0
|
81 local icon = _G[self:GetName().."Icon"];
|
madcatzinc@0
|
82 if(nil ~= data[activeMode][self.Id]) then
|
madcatzinc@0
|
83 self:SetChecked(true);
|
madcatzinc@0
|
84 icon:SetTexture(data[activeMode][self.Id].Texture);
|
madcatzinc@0
|
85 else
|
madcatzinc@0
|
86 icon:SetTexture(nil);
|
madcatzinc@0
|
87 self:SetChecked(false);
|
madcatzinc@0
|
88 end
|
madcatzinc@0
|
89
|
madcatzinc@0
|
90
|
madcatzinc@0
|
91 end
|
madcatzinc@0
|
92
|
madcatzinc@0
|
93 return self;
|
madcatzinc@0
|
94 end,
|
madcatzinc@0
|
95 }
|
madcatzinc@0
|
96
|
madcatzinc@0
|
97 SlotMiniView = {
|
madcatzinc@0
|
98 new = function(self, parent)
|
madcatzinc@0
|
99 self._assignedWowObject = nil;
|
madcatzinc@0
|
100 self.Id = self:GetID();
|
madcatzinc@0
|
101 RatPageModel.Instance().AddObserver(self);
|
madcatzinc@0
|
102 self.UnCheckedTexture = self:GetNormalTexture();
|
madcatzinc@0
|
103
|
madcatzinc@0
|
104 self.Update = function(data, activeMode)
|
madcatzinc@0
|
105 local icon = _G[self:GetName().."Icon"];
|
madcatzinc@0
|
106 if(nil ~= data[activeMode][self.Id]) then
|
madcatzinc@0
|
107 self:SetChecked(true);
|
madcatzinc@0
|
108
|
madcatzinc@0
|
109 icon:SetTexture(data[activeMode][self.Id].Texture);
|
madcatzinc@0
|
110 icon:SetAlpha(.5);
|
madcatzinc@0
|
111 else
|
madcatzinc@0
|
112 icon:SetTexture(nil);
|
madcatzinc@0
|
113 self:SetChecked(false);
|
madcatzinc@0
|
114 end
|
madcatzinc@0
|
115 end
|
madcatzinc@0
|
116
|
madcatzinc@0
|
117 return self;
|
madcatzinc@0
|
118 end
|
madcatzinc@0
|
119 }
|
madcatzinc@0
|
120
|
madcatzinc@0
|
121
|
madcatzinc@0
|
122 -- ModeButton --
|
madcatzinc@0
|
123 ModeView = {
|
madcatzinc@0
|
124 new = function(self)
|
madcatzinc@0
|
125 self.Id = self:GetID();
|
madcatzinc@0
|
126 self.Name = self:GetName();
|
madcatzinc@0
|
127 RatPageModel.Instance().AddObserver(self);
|
madcatzinc@0
|
128 if(self.Id ~= 1) then
|
madcatzinc@0
|
129 self:Hide()
|
madcatzinc@0
|
130 end
|
madcatzinc@0
|
131
|
madcatzinc@0
|
132 self.Clicked = function()
|
madcatzinc@0
|
133 local nextMode;
|
madcatzinc@0
|
134 if(self.Id == 1) then
|
madcatzinc@0
|
135 nextMode = getglobal("Mode2");
|
madcatzinc@0
|
136 else
|
madcatzinc@0
|
137 if(self.Id == 2) then
|
madcatzinc@0
|
138 nextMode = getglobal("Mode3");
|
madcatzinc@0
|
139 else
|
madcatzinc@0
|
140 nextMode = getglobal("Mode1");
|
madcatzinc@0
|
141 end
|
madcatzinc@0
|
142 end
|
madcatzinc@0
|
143 self:GetParent().ModeClicked(nextMode)
|
madcatzinc@0
|
144 end
|
madcatzinc@0
|
145
|
madcatzinc@0
|
146 self.Update = function(data, activeMode)
|
madcatzinc@0
|
147 if(self.Id == activeMode) then
|
madcatzinc@0
|
148 self:Show()
|
madcatzinc@0
|
149 else
|
madcatzinc@0
|
150 self:Hide()
|
madcatzinc@0
|
151 end
|
madcatzinc@0
|
152
|
madcatzinc@0
|
153 end
|
madcatzinc@0
|
154
|
madcatzinc@0
|
155 return self;
|
madcatzinc@0
|
156 end
|
madcatzinc@0
|
157 }
|