diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RatPageView.lua	Tue Jan 24 17:14:21 2012 +0000
@@ -0,0 +1,157 @@
+--~ Warcraft Plugin for Cyborg MMO7 
+--~ Filename: RatPageView.lua
+--~ Description: Interaction logic for the RatPage
+--~ Copyright (C) 2012 Mad Catz Inc.
+--~ Author: Christopher Hooks
+
+--~ This program is free software; you can redistribute it and/or
+--~ modify it under the terms of the GNU General Public License
+--~ as published by the Free Software Foundation; either version 2
+--~ of the License, or (at your option) any later version.
+
+--~ This program is distributed in the hope that it will be useful,
+--~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+--~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+--~ GNU General Public License for more details.
+
+--~ You should have received a copy of the GNU General Public License
+--~ along with this program; if not, write to the Free Software
+--~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+RatPageView = {
+	new = function(self)
+		msg("new Rat Page View");
+		for _, child in ipairs(self:GetChildren()) do
+			child.Register();
+		end
+		
+		self.SlotClicked = function(slot)
+			msg("View Recieved Click")
+			RatPageController.Instance().SlotClicked(slot)
+		end
+
+		self.ModeClicked = function(mode)
+			msg("View Recieved Click")
+			RatPageController.Instance().ModeClicked(mode)
+		end
+
+		self.RegisterMode = function()
+			msg("ModeRegistered")
+		end
+
+		self.RegisterSlot = function()
+			msg("SlotRegistered")
+		end
+		return self;
+	end
+}
+
+RatQuickPageView = {
+	new = function(self)
+		for _, child in ipairs(self:GetChildren()) do
+			child.Register();
+		end
+
+		self.SlotClicked = function(slot)
+			RatPageController.Instance().SlotClicked(slot)
+		end
+
+		return self;
+	end
+}
+
+-- Slot Class --
+SlotView = {
+	new = function(self, parent)
+		self._assignedWowObject = nil;
+		self:RegisterForClicks("LeftButtonUp", "RightButtonUp");
+		self.Id = self:GetID();
+		RatPageModel.Instance().AddObserver(self);
+		self.UnCheckedTexture = self:GetNormalTexture();
+
+		-- Object Method --
+		self.Clicked = function()
+			self:GetParent().SlotClicked(self)
+
+			GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
+			--GameTooltip:SetText(self:GetID());
+		end
+
+		self.Update = function(data, activeMode)
+			local icon = _G[self:GetName().."Icon"];
+			if(nil ~= data[activeMode][self.Id]) then
+				self:SetChecked(true);
+				icon:SetTexture(data[activeMode][self.Id].Texture);
+			else
+				icon:SetTexture(nil);
+				self:SetChecked(false);
+			end
+
+
+		end
+
+		return self;
+	end,
+}
+
+SlotMiniView = {
+	new = function(self, parent)
+		self._assignedWowObject = nil;
+		self.Id = self:GetID();
+		RatPageModel.Instance().AddObserver(self);
+		self.UnCheckedTexture = self:GetNormalTexture();
+
+		self.Update = function(data, activeMode)
+			local icon = _G[self:GetName().."Icon"];
+			if(nil ~= data[activeMode][self.Id]) then
+				self:SetChecked(true);
+
+				icon:SetTexture(data[activeMode][self.Id].Texture);
+				icon:SetAlpha(.5);
+			else
+				icon:SetTexture(nil);
+				self:SetChecked(false);
+			end
+		end
+
+		return	self;
+	end
+}
+
+
+-- ModeButton --
+ModeView = {
+	new = function(self)
+	self.Id = self:GetID();
+	self.Name = self:GetName();
+	RatPageModel.Instance().AddObserver(self);
+	if(self.Id ~= 1) then
+		self:Hide()
+	end
+
+		self.Clicked = function()
+			local nextMode;
+			if(self.Id == 1) then
+				nextMode = getglobal("Mode2");
+			else
+				if(self.Id == 2) then
+					nextMode = getglobal("Mode3");
+				else
+					nextMode = getglobal("Mode1");
+				end
+			end
+			self:GetParent().ModeClicked(nextMode)
+		end
+
+		self.Update = function(data, activeMode)
+			if(self.Id == activeMode) then
+				self:Show()
+			else
+				self:Hide()
+			end
+
+		end
+
+	return self;
+	end
+}