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