Mercurial > wow > reaction
changeset 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 | 6e4a11b9d290 |
files | classes/ActionButton.lua classes/Button.lua locale/enUS.lua |
diffstat | 3 files changed, 31 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/classes/ActionButton.lua Thu Mar 05 01:28:48 2009 +0000 +++ b/classes/ActionButton.lua Fri Mar 06 23:44:33 2009 +0000 @@ -2,7 +2,6 @@ local L = ReAction.L local _G = _G local CreateFrame = CreateFrame -local GetBindingKey = GetBindingKey local format = string.format local IsUsableAction = IsUsableAction local IsEquippedAction = IsEquippedAction @@ -120,10 +119,10 @@ local _onReceiveDrag = -- function(self, button, kind, value, ...) [[ - if kind == "spell" or kind == "item" or kind == "macro" then - -- assume it's a valid action - self:SetAttribute("hasaction-"..self:GetAttribute("action"),true) + if kind ~= "spell" and kind ~= "item" and kind ~= "macro" then + return kind, value, ... end + self:SetAttribute("hasaction-"..self:GetAttribute("action"),true) return "action", self:GetAttribute("action") ]] @@ -162,7 +161,8 @@ function Action:New( idx, barConfig, bar, idHint ) local name = format("ReAction_%s_Action_%d",bar:GetName(),idx) - self = Super.New(self, name, barConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) + self = Super.New(self, name, barConfig.buttons[idx], bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) + self.barConfig = barConfig local f = self:GetFrame() local barFrame = bar:GetFrame() @@ -193,7 +193,6 @@ f:SetAttribute("type","action") f:SetAttribute("checkselfcast", true) f:SetAttribute("checkfocuscast", true) - f:SetAttribute("useparent-unit", true) f:SetAttribute("action", config.actionID) f:SetAttribute("default-action", config.actionID) f:SetAttribute("bar-idx",idx) @@ -258,8 +257,14 @@ Super.Destroy(self) end +function Action:GetBarConfig() + -- this is the per-bar Action module config structure, + -- not the config structure of the bar itself + return self.barConfig +end + function Action:Refresh() - self.bar:PlaceButton(self, 36, 36) + Super.Refresh(self) self:RefreshPages() self:InstallVehicle() self:ShowGrid(not self:GetBarConfig().hideEmpty) @@ -536,7 +541,8 @@ id = tonumber(id) page = tonumber(page) if id == nil or id < 1 or id > 120 then - error("Action:SetActionID - invalid action ID") + ReAction:UserError(L["Action ID range is 1-120"]) + return end if page and page ~= 1 then if not self.config.pageactions then @@ -574,12 +580,12 @@ else c[i] = self.config.actionID -- page 1 is the same as the base actionID end - f:SetAttribute(("action-page%d"):format(i),c[i]) + f:SetAttribute("action-page"..i,c[i]) end for i = nPages+1, #c do self:ReleaseActionID(c[i]) c[i] = nil - f:SetAttribute(("action-page%d"):format(i),nil) + f:SetAttribute("action-page"..i,nil) end self.nPages = nPages end
--- a/classes/Button.lua Thu Mar 05 01:28:48 2009 +0000 +++ b/classes/Button.lua Fri Mar 06 23:44:33 2009 +0000 @@ -30,7 +30,7 @@ ReAction.Button = Button -- export to ReAction -function Button:New( name, barConfig, bar, idx, inherits, buttonType ) +function Button:New( name, config, bar, idx, inherits, buttonType ) buttonType = buttonType or "CheckButton" -- create new self @@ -38,8 +38,7 @@ { bar = bar, idx = idx, - barConfig = barConfig, - config = barConfig.buttons[idx], + config = config, name = name, }, { __index = self } ) @@ -101,12 +100,6 @@ return self.config end -function Button:GetBarConfig() - -- this is the per-bar Button config structure, - -- not the config structure of the bar itself - return self.barConfig -end - function Button:GetActionID() -- derived classes should override this return nil @@ -179,7 +172,8 @@ end function Button:Refresh() - self.bar:PlaceButton( self, self.frame:GetWidth(), self.frame:GetHeight() ) + local f = self:GetFrame() + self.bar:PlaceButton( self, f:GetWidth(), f:GetHeight() ) end function Button:SetKeybindMode( mode ) @@ -210,7 +204,7 @@ function Button:UpdateHotkey( hotkey ) hotkey = hotkey or self.hotkey if not hotkey then - hotkey = _G[format("%sHotKey", tostring(self:GetName()))] + hotkey = _G[self:GetName().."HotKey"] self.hotkey = hotkey end if hotkey then @@ -225,7 +219,7 @@ end function Button:GetActionIDLabel( create ) - local f = self.frame + local f = self:GetFrame() if not f.actionIDLabel and create then local label = f:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") label:SetAllPoints() @@ -254,17 +248,17 @@ function Button:SetNormalVertexColor( r, g, b, a ) if LBF then - LBF:SetNormalVertexColor(self.frame, r, g, b, a) + LBF:SetNormalVertexColor(self:GetFrame(), r, g, b, a) else - self.frame:GetNormalTexture():SetVertexColor(r,g,b,a) + self:GetFrame():GetNormalTexture():SetVertexColor(r,g,b,a) end end function Button:GetNormalVertexColor() if LBF then - return LBF:GetNormalVertexColor(self.frame) + return LBF:GetNormalVertexColor(self:GetFrame()) else - return self.frame:GetNormalTexture():GetVertexColor() + return self:GetFrame():GetNormalTexture():GetVertexColor() end end