Mercurial > wow > reaction
comparison classes/Button.lua @ 129:28b430de5875
More fixes for new action button
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 06 Mar 2009 23:44:33 +0000 |
parents | 729232aeeb5e |
children | e39d80bb0b7a |
comparison
equal
deleted
inserted
replaced
128:729232aeeb5e | 129:28b430de5875 |
---|---|
28 -- Button class | 28 -- Button class |
29 local Button = { } | 29 local Button = { } |
30 | 30 |
31 ReAction.Button = Button -- export to ReAction | 31 ReAction.Button = Button -- export to ReAction |
32 | 32 |
33 function Button:New( name, barConfig, bar, idx, inherits, buttonType ) | 33 function Button:New( name, config, bar, idx, inherits, buttonType ) |
34 buttonType = buttonType or "CheckButton" | 34 buttonType = buttonType or "CheckButton" |
35 | 35 |
36 -- create new self | 36 -- create new self |
37 self = setmetatable( | 37 self = setmetatable( |
38 { | 38 { |
39 bar = bar, | 39 bar = bar, |
40 idx = idx, | 40 idx = idx, |
41 barConfig = barConfig, | 41 config = config, |
42 config = barConfig.buttons[idx], | |
43 name = name, | 42 name = name, |
44 }, | 43 }, |
45 { __index = self } ) | 44 { __index = self } ) |
46 | 45 |
47 -- have to recycle frames with the same name: CreateFrame() doesn't overwrite | 46 -- have to recycle frames with the same name: CreateFrame() doesn't overwrite |
97 return self.name | 96 return self.name |
98 end | 97 end |
99 | 98 |
100 function Button:GetConfig() | 99 function Button:GetConfig() |
101 return self.config | 100 return self.config |
102 end | |
103 | |
104 function Button:GetBarConfig() | |
105 -- this is the per-bar Button config structure, | |
106 -- not the config structure of the bar itself | |
107 return self.barConfig | |
108 end | 101 end |
109 | 102 |
110 function Button:GetActionID() | 103 function Button:GetActionID() |
111 -- derived classes should override this | 104 -- derived classes should override this |
112 return nil | 105 return nil |
177 pool.nWraps = min(pool.useCount[id], pool.nWraps) | 170 pool.nWraps = min(pool.useCount[id], pool.nWraps) |
178 end | 171 end |
179 end | 172 end |
180 | 173 |
181 function Button:Refresh() | 174 function Button:Refresh() |
182 self.bar:PlaceButton( self, self.frame:GetWidth(), self.frame:GetHeight() ) | 175 local f = self:GetFrame() |
176 self.bar:PlaceButton( self, f:GetWidth(), f:GetHeight() ) | |
183 end | 177 end |
184 | 178 |
185 function Button:SetKeybindMode( mode ) | 179 function Button:SetKeybindMode( mode ) |
186 local f = self.frame | 180 local f = self.frame |
187 if mode then | 181 if mode then |
208 end | 202 end |
209 | 203 |
210 function Button:UpdateHotkey( hotkey ) | 204 function Button:UpdateHotkey( hotkey ) |
211 hotkey = hotkey or self.hotkey | 205 hotkey = hotkey or self.hotkey |
212 if not hotkey then | 206 if not hotkey then |
213 hotkey = _G[format("%sHotKey", tostring(self:GetName()))] | 207 hotkey = _G[self:GetName().."HotKey"] |
214 self.hotkey = hotkey | 208 self.hotkey = hotkey |
215 end | 209 end |
216 if hotkey then | 210 if hotkey then |
217 local txt = self.frame:GetHotkey() | 211 local txt = self.frame:GetHotkey() |
218 hotkey:SetText( txt ) | 212 hotkey:SetText( txt ) |
223 end | 217 end |
224 end | 218 end |
225 end | 219 end |
226 | 220 |
227 function Button:GetActionIDLabel( create ) | 221 function Button:GetActionIDLabel( create ) |
228 local f = self.frame | 222 local f = self:GetFrame() |
229 if not f.actionIDLabel and create then | 223 if not f.actionIDLabel and create then |
230 local label = f:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") | 224 local label = f:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") |
231 label:SetAllPoints() | 225 label:SetAllPoints() |
232 label:SetJustifyH("CENTER") | 226 label:SetJustifyH("CENTER") |
233 label:SetShadowColor(0,0,0,1) | 227 label:SetShadowColor(0,0,0,1) |
252 end | 246 end |
253 end | 247 end |
254 | 248 |
255 function Button:SetNormalVertexColor( r, g, b, a ) | 249 function Button:SetNormalVertexColor( r, g, b, a ) |
256 if LBF then | 250 if LBF then |
257 LBF:SetNormalVertexColor(self.frame, r, g, b, a) | 251 LBF:SetNormalVertexColor(self:GetFrame(), r, g, b, a) |
258 else | 252 else |
259 self.frame:GetNormalTexture():SetVertexColor(r,g,b,a) | 253 self:GetFrame():GetNormalTexture():SetVertexColor(r,g,b,a) |
260 end | 254 end |
261 end | 255 end |
262 | 256 |
263 function Button:GetNormalVertexColor() | 257 function Button:GetNormalVertexColor() |
264 if LBF then | 258 if LBF then |
265 return LBF:GetNormalVertexColor(self.frame) | 259 return LBF:GetNormalVertexColor(self:GetFrame()) |
266 else | 260 else |
267 return self.frame:GetNormalTexture():GetVertexColor() | 261 return self:GetFrame():GetNormalTexture():GetVertexColor() |
268 end | 262 end |
269 end | 263 end |
270 | 264 |
271 function Button:UpdateShowGrid() | 265 function Button:UpdateShowGrid() |
272 -- does nothing by default | 266 -- does nothing by default |