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@4
|
21 CyborgMMO_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@4
|
30 CyborgMMO_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@4
|
35 CyborgMMO_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@4
|
49 CyborgMMO_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@4
|
56 CyborgMMO_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@4
|
64 CyborgMMO_SlotView = {
|
madcatzinc@0
|
65 new = function(self, parent)
|
madcatzinc@0
|
66 self._assignedWowObject = nil;
|
madcatzinc@4
|
67 self.UnCheckedTexture = self:GetNormalTexture();
|
madcatzinc@0
|
68 self:RegisterForClicks("LeftButtonUp", "RightButtonUp");
|
madcatzinc@0
|
69 self.Id = self:GetID();
|
madcatzinc@4
|
70 CyborgMMO_RatPageModel.Instance().AddObserver(self);
|
madcatzinc@0
|
71 -- Object Method --
|
madcatzinc@0
|
72 self.Clicked = function()
|
madcatzinc@0
|
73 self:GetParent().SlotClicked(self)
|
madcatzinc@0
|
74
|
madcatzinc@0
|
75 GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
|
madcatzinc@0
|
76 --GameTooltip:SetText(self:GetID());
|
madcatzinc@0
|
77 end
|
madcatzinc@0
|
78
|
madcatzinc@0
|
79 self.Update = function(data, activeMode)
|
madcatzinc@0
|
80 local icon = _G[self:GetName().."Icon"];
|
madcatzinc@0
|
81 if(nil ~= data[activeMode][self.Id]) then
|
madcatzinc@0
|
82 self:SetChecked(true);
|
madcatzinc@0
|
83 icon:SetTexture(data[activeMode][self.Id].Texture);
|
madcatzinc@0
|
84 else
|
madcatzinc@0
|
85 icon:SetTexture(nil);
|
madcatzinc@0
|
86 self:SetChecked(false);
|
madcatzinc@0
|
87 end
|
madcatzinc@0
|
88
|
madcatzinc@0
|
89
|
madcatzinc@0
|
90 end
|
madcatzinc@0
|
91
|
madcatzinc@0
|
92 return self;
|
madcatzinc@0
|
93 end,
|
madcatzinc@0
|
94 }
|
madcatzinc@0
|
95
|
madcatzinc@4
|
96 CyborgMMO_SlotMiniView = {
|
madcatzinc@0
|
97 new = function(self, parent)
|
madcatzinc@0
|
98 self._assignedWowObject = nil;
|
madcatzinc@0
|
99 self.Id = self:GetID();
|
madcatzinc@4
|
100 CyborgMMO_RatPageModel.Instance().AddObserver(self);
|
madcatzinc@0
|
101 self.UnCheckedTexture = self:GetNormalTexture();
|
madcatzinc@0
|
102
|
madcatzinc@0
|
103 self.Update = function(data, activeMode)
|
madcatzinc@0
|
104 local icon = _G[self:GetName().."Icon"];
|
madcatzinc@0
|
105 if(nil ~= data[activeMode][self.Id]) then
|
madcatzinc@0
|
106 self:SetChecked(true);
|
madcatzinc@0
|
107
|
madcatzinc@0
|
108 icon:SetTexture(data[activeMode][self.Id].Texture);
|
madcatzinc@0
|
109 icon:SetAlpha(.5);
|
madcatzinc@0
|
110 else
|
madcatzinc@0
|
111 icon:SetTexture(nil);
|
madcatzinc@0
|
112 self:SetChecked(false);
|
madcatzinc@0
|
113 end
|
madcatzinc@0
|
114 end
|
madcatzinc@0
|
115
|
madcatzinc@0
|
116 return self;
|
madcatzinc@0
|
117 end
|
madcatzinc@0
|
118 }
|
madcatzinc@0
|
119
|
madcatzinc@0
|
120
|
madcatzinc@0
|
121 -- ModeButton --
|
madcatzinc@4
|
122 CyborgMMO_ModeView = {
|
madcatzinc@0
|
123 new = function(self)
|
madcatzinc@0
|
124 self.Id = self:GetID();
|
madcatzinc@0
|
125 self.Name = self:GetName();
|
madcatzinc@4
|
126 CyborgMMO_RatPageModel.Instance().AddObserver(self);
|
madcatzinc@0
|
127 if(self.Id ~= 1) then
|
madcatzinc@0
|
128 self:Hide()
|
madcatzinc@0
|
129 end
|
madcatzinc@0
|
130
|
madcatzinc@0
|
131 self.Clicked = function()
|
madcatzinc@0
|
132 local nextMode;
|
madcatzinc@0
|
133 if(self.Id == 1) then
|
madcatzinc@0
|
134 nextMode = getglobal("Mode2");
|
madcatzinc@0
|
135 else
|
madcatzinc@0
|
136 if(self.Id == 2) then
|
madcatzinc@0
|
137 nextMode = getglobal("Mode3");
|
madcatzinc@0
|
138 else
|
madcatzinc@0
|
139 nextMode = getglobal("Mode1");
|
madcatzinc@0
|
140 end
|
madcatzinc@0
|
141 end
|
madcatzinc@0
|
142 self:GetParent().ModeClicked(nextMode)
|
madcatzinc@0
|
143 end
|
madcatzinc@0
|
144
|
madcatzinc@0
|
145 self.Update = function(data, activeMode)
|
madcatzinc@0
|
146 if(self.Id == activeMode) then
|
madcatzinc@0
|
147 self:Show()
|
madcatzinc@0
|
148 else
|
madcatzinc@0
|
149 self:Hide()
|
madcatzinc@0
|
150 end
|
madcatzinc@0
|
151
|
madcatzinc@0
|
152 end
|
madcatzinc@0
|
153
|
madcatzinc@0
|
154 return self;
|
madcatzinc@0
|
155 end
|
madcatzinc@0
|
156 }
|