Mercurial > wow > cyborg-mmo7
comparison 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 |
comparison
equal
deleted
inserted
replaced
12:72b92b3e476e | 13:6cb9a2936580 |
---|---|
1 --~ Warcraft Plugin for Cyborg MMO7 | 1 --~ Warcraft Plugin for Cyborg MMO7 |
2 --~ Filename: RatPageView.lua | 2 --~ Filename: RatPageView.lua |
3 --~ Description: Interaction logic for the RatPage | 3 --~ Description: Interaction logic for the RatPage |
4 --~ Copyright (C) 2012 Mad Catz Inc. | 4 --~ Copyright (C) 2012 Mad Catz Inc. |
5 --~ Author: Christopher Hooks | 5 --~ Author: Christopher Hooks |
6 | 6 |
18 --~ along with this program; if not, write to the Free Software | 18 --~ along with this program; if not, write to the Free Software |
19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | 20 |
21 CyborgMMO_RatPageView = { | 21 CyborgMMO_RatPageView = { |
22 new = function(self) | 22 new = function(self) |
23 msg("new Rat Page View"); | 23 msg("new Rat Page View") |
24 for _, child in ipairs(self:GetChildren()) do | 24 for _,child in ipairs(self:GetChildren()) do |
25 child.Register(); | 25 child.Register() |
26 end | 26 end |
27 | 27 |
28 self.SlotClicked = function(slot) | 28 self.SlotClicked = function(slot) |
29 msg("View Recieved Click") | 29 msg("View Recieved Click") |
30 CyborgMMO_RatPageController.Instance().SlotClicked(slot) | 30 CyborgMMO_RatPageController.Instance().SlotClicked(slot) |
31 end | 31 end |
32 | 32 |
40 end | 40 end |
41 | 41 |
42 self.RegisterSlot = function() | 42 self.RegisterSlot = function() |
43 msg("SlotRegistered") | 43 msg("SlotRegistered") |
44 end | 44 end |
45 return self; | 45 |
46 end | 46 return self |
47 end, | |
47 } | 48 } |
48 | 49 |
49 CyborgMMO_RatQuickPageView = { | 50 CyborgMMO_RatQuickPageView = { |
50 new = function(self) | 51 new = function(self) |
51 for _, child in ipairs(self:GetChildren()) do | 52 for _,child in ipairs(self:GetChildren()) do |
52 child.Register(); | 53 child.Register() |
53 end | 54 end |
54 | 55 |
55 self.SlotClicked = function(slot) | 56 self.SlotClicked = function(slot) |
56 CyborgMMO_RatPageController.Instance().SlotClicked(slot) | 57 CyborgMMO_RatPageController.Instance().SlotClicked(slot) |
57 end | 58 end |
58 | 59 |
59 return self; | 60 return self |
60 end | 61 end, |
61 } | 62 } |
62 | 63 |
63 -- Slot Class -- | 64 -- Slot Class -- |
64 CyborgMMO_SlotView = { | 65 CyborgMMO_SlotView = { |
65 new = function(self, parent) | 66 new = function(self, parent) |
66 self._assignedWowObject = nil; | 67 self._assignedWowObject = nil |
67 self:RegisterForClicks("LeftButtonUp", "RightButtonUp"); | 68 self:RegisterForClicks("LeftButtonUp", "RightButtonUp") |
68 self.Id = self:GetID(); | 69 self.Id = self:GetID() |
69 CyborgMMO_RatPageModel.Instance().AddObserver(self); | 70 CyborgMMO_RatPageModel.Instance().AddObserver(self) |
70 self.UnCheckedTexture = self:GetNormalTexture(); | 71 self.UnCheckedTexture = self:GetNormalTexture() |
71 | 72 |
72 -- Object Method -- | 73 -- Object Method -- |
73 self.Clicked = function() | 74 self.Clicked = function() |
74 self:GetParent().SlotClicked(self) | 75 self:GetParent().SlotClicked(self) |
75 | 76 |
76 GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); | 77 GameTooltip:SetOwner(self, "ANCHOR_RIGHT") |
77 --GameTooltip:SetText(self:GetID()); | 78 -- GameTooltip:SetText(self:GetID()) |
78 end | 79 end |
79 | 80 |
80 self.Update = function(data, activeMode) | 81 self.Update = function(data, activeMode) |
81 local icon = _G[self:GetName().."Icon"]; | 82 local icon = _G[self:GetName().."Icon"] |
82 if(nil ~= data[activeMode][self.Id]) then | 83 if data[activeMode][self.Id] then |
83 self:SetChecked(true); | 84 self:SetChecked(true) |
84 icon:SetTexture(data[activeMode][self.Id].Texture); | 85 icon:SetTexture(data[activeMode][self.Id].Texture) |
85 else | 86 else |
86 icon:SetTexture(nil); | 87 icon:SetTexture(nil) |
87 self:SetChecked(false); | 88 self:SetChecked(false) |
88 end | 89 end |
89 | 90 |
90 | 91 |
91 end | 92 end |
92 | 93 |
93 return self; | 94 return self |
94 end, | 95 end, |
95 } | 96 } |
96 | 97 |
97 CyborgMMO_SlotMiniView = { | 98 CyborgMMO_SlotMiniView = { |
98 new = function(self, parent) | 99 new = function(self, parent) |
99 self._assignedWowObject = nil; | 100 self._assignedWowObject = nil |
100 self.Id = self:GetID(); | 101 self.Id = self:GetID() |
101 CyborgMMO_RatPageModel.Instance().AddObserver(self); | 102 CyborgMMO_RatPageModel.Instance().AddObserver(self) |
102 self.UnCheckedTexture = self:GetNormalTexture(); | 103 self.UnCheckedTexture = self:GetNormalTexture() |
103 | 104 |
104 self.Update = function(data, activeMode) | 105 self.Update = function(data, activeMode) |
105 local icon = _G[self:GetName().."Icon"]; | 106 local icon = _G[self:GetName().."Icon"] |
106 if(nil ~= data[activeMode][self.Id]) then | 107 if data[activeMode][self.Id] then |
107 self:SetChecked(true); | 108 self:SetChecked(true) |
108 | 109 |
109 icon:SetTexture(data[activeMode][self.Id].Texture); | 110 icon:SetTexture(data[activeMode][self.Id].Texture) |
110 icon:SetAlpha(.5); | 111 icon:SetAlpha(.5) |
111 else | 112 else |
112 icon:SetTexture(nil); | 113 icon:SetTexture(nil) |
113 self:SetChecked(false); | 114 self:SetChecked(false) |
114 end | 115 end |
115 end | 116 end |
116 | 117 |
117 return self; | 118 return self |
118 end | 119 end, |
119 } | 120 } |
120 | 121 |
121 | 122 |
122 -- ModeButton -- | 123 -- ModeButton -- |
123 CyborgMMO_ModeView = { | 124 CyborgMMO_ModeView = { |
124 new = function(self) | 125 new = function(self) |
125 self.Id = self:GetID(); | 126 self.Id = self:GetID() |
126 self.Name = self:GetName(); | 127 self.Name = self:GetName() |
127 CyborgMMO_RatPageModel.Instance().AddObserver(self); | 128 CyborgMMO_RatPageModel.Instance().AddObserver(self) |
128 if(self.Id ~= 1) then | 129 if self.Id ~= 1 then |
129 self:Hide() | 130 self:Hide() |
130 end | 131 end |
131 | 132 |
132 self.Clicked = function() | 133 self.Clicked = function() |
133 local nextMode; | 134 local nextMode |
134 if(self.Id == 1) then | 135 if self.Id == 1 then |
135 nextMode = getglobal("Mode2"); | 136 nextMode = getglobal("Mode2") |
137 elseif self.Id == 2 then | |
138 nextMode = getglobal("Mode3") | |
136 else | 139 else |
137 if(self.Id == 2) then | 140 nextMode = getglobal("Mode1") |
138 nextMode = getglobal("Mode3"); | |
139 else | |
140 nextMode = getglobal("Mode1"); | |
141 end | |
142 end | 141 end |
143 self:GetParent().ModeClicked(nextMode) | 142 self:GetParent().ModeClicked(nextMode) |
144 end | 143 end |
145 | 144 |
146 self.Update = function(data, activeMode) | 145 self.Update = function(data, activeMode) |
147 if(self.Id == activeMode) then | 146 if self.Id == activeMode then |
148 self:Show() | 147 self:Show() |
149 else | 148 else |
150 self:Hide() | 149 self:Hide() |
151 end | 150 end |
152 | |
153 end | 151 end |
154 | 152 |
155 return self; | 153 return self |
156 end | 154 end, |
157 } | 155 } |