Mercurial > wow > cyborg-mmo7
diff RatPageView.lua @ 13:6cb9a2936580
Miscellanous Lua code consistency improvements:
- no semicolon except between statements on same line
- use of implicit cast to bool in if/while conditions, instead of various eq/neq against true, false or nil
- no parenthesis around if/while conditions (C-ism)
- avoid long function calls in if conditions
- removed space in comma-separated expressions lists in multiple assignments
- added spaces between arguments of functions calls
- use tabs for indentation (in Lua files only)
- don't reverse == in if conditions, like "if 42==foo then" (C-ism)
- removed some extra parenthesis in complex expressions (C-ism)
- added spaces around operators in most expressions for ease of reading
- added comma after last element of table initializers
- removed space after # operator
- moved comment prefix of disabled code into tab (to keep disabled code aligned)
author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 |
---|---|
date | Thu, 25 Apr 2013 01:29:45 +0000 |
parents | 8428fa7cf0e4 |
children | 80192bc4a108 |
line wrap: on
line diff
--- a/RatPageView.lua Tue Apr 16 15:19:23 2013 +0000 +++ b/RatPageView.lua Thu Apr 25 01:29:45 2013 +0000 @@ -1,4 +1,4 @@ ---~ Warcraft Plugin for Cyborg MMO7 +--~ Warcraft Plugin for Cyborg MMO7 --~ Filename: RatPageView.lua --~ Description: Interaction logic for the RatPage --~ Copyright (C) 2012 Mad Catz Inc. @@ -20,11 +20,11 @@ CyborgMMO_RatPageView = { new = function(self) - msg("new Rat Page View"); - for _, child in ipairs(self:GetChildren()) do - child.Register(); + msg("new Rat Page View") + for _,child in ipairs(self:GetChildren()) do + child.Register() end - + self.SlotClicked = function(slot) msg("View Recieved Click") CyborgMMO_RatPageController.Instance().SlotClicked(slot) @@ -42,116 +42,114 @@ self.RegisterSlot = function() msg("SlotRegistered") end - return self; - end + + return self + end, } CyborgMMO_RatQuickPageView = { new = function(self) - for _, child in ipairs(self:GetChildren()) do - child.Register(); + for _,child in ipairs(self:GetChildren()) do + child.Register() end self.SlotClicked = function(slot) CyborgMMO_RatPageController.Instance().SlotClicked(slot) end - return self; - end + return self + end, } -- Slot Class -- CyborgMMO_SlotView = { new = function(self, parent) - self._assignedWowObject = nil; - self:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - self.Id = self:GetID(); - CyborgMMO_RatPageModel.Instance().AddObserver(self); - self.UnCheckedTexture = self:GetNormalTexture(); + self._assignedWowObject = nil + self:RegisterForClicks("LeftButtonUp", "RightButtonUp") + self.Id = self:GetID() + CyborgMMO_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()); + 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); + local icon = _G[self:GetName().."Icon"] + if data[activeMode][self.Id] then + self:SetChecked(true) + icon:SetTexture(data[activeMode][self.Id].Texture) else - icon:SetTexture(nil); - self:SetChecked(false); + icon:SetTexture(nil) + self:SetChecked(false) end end - return self; + return self end, } CyborgMMO_SlotMiniView = { new = function(self, parent) - self._assignedWowObject = nil; - self.Id = self:GetID(); - CyborgMMO_RatPageModel.Instance().AddObserver(self); - self.UnCheckedTexture = self:GetNormalTexture(); + self._assignedWowObject = nil + self.Id = self:GetID() + CyborgMMO_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); + local icon = _G[self:GetName().."Icon"] + if data[activeMode][self.Id] then + self:SetChecked(true) - icon:SetTexture(data[activeMode][self.Id].Texture); - icon:SetAlpha(.5); + icon:SetTexture(data[activeMode][self.Id].Texture) + icon:SetAlpha(.5) else - icon:SetTexture(nil); - self:SetChecked(false); + icon:SetTexture(nil) + self:SetChecked(false) end end - return self; - end + return self + end, } -- ModeButton -- CyborgMMO_ModeView = { new = function(self) - self.Id = self:GetID(); - self.Name = self:GetName(); - CyborgMMO_RatPageModel.Instance().AddObserver(self); - if(self.Id ~= 1) then - self:Hide() - end + self.Id = self:GetID() + self.Name = self:GetName() + CyborgMMO_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"); + local nextMode + if self.Id == 1 then + nextMode = getglobal("Mode2") + elseif self.Id == 2 then + nextMode = getglobal("Mode3") else - if(self.Id == 2) then - nextMode = getglobal("Mode3"); - else - nextMode = getglobal("Mode1"); - end + nextMode = getglobal("Mode1") end self:GetParent().ModeClicked(nextMode) end self.Update = function(data, activeMode) - if(self.Id == activeMode) then + if self.Id == activeMode then self:Show() else self:Hide() end - end - return self; - end + return self + end, }