Mercurial > wow > reaction
diff BagButton.lua @ 298:d1a56601267b
Fix bag buttons and remove keyring
author | Flick |
---|---|
date | Wed, 14 Nov 2012 16:35:18 -0800 |
parents | 4e325f1ea6e1 |
children |
line wrap: on
line diff
--- a/BagButton.lua Wed Nov 14 16:34:14 2012 -0800 +++ b/BagButton.lua Wed Nov 14 16:35:18 2012 -0800 @@ -25,7 +25,7 @@ btnWidth = 30, btnHeight = 30, btnRows = 1, - btnColumns = 6, + btnColumns = 5, spacing = 4, buttons = { } }, @@ -39,7 +39,6 @@ local Bag = setmetatable( { }, { __index = BagBase } ) local Backpack = setmetatable( { }, { __index = BagBase } ) -local Keyring = setmetatable( { }, { __index = BagBase } ) ReAction.Button.Bag = BagBase ReAction:RegisterBarType(BagBase) @@ -55,8 +54,6 @@ local class = Bag if idx == 1 then class = Backpack - elseif idx == 6 then - class = Keyring end self = class:New(btnCfg, bar, idx) @@ -64,7 +61,7 @@ local config = self:GetConfig() -- set up the bag ID pool - self:SetActionIDPool("bag",6) + self:SetActionIDPool("bag",5) config.bagID = self:AcquireActionID(config.bagID, idHint, true) -- non secure scripts @@ -84,7 +81,7 @@ f:SetID(self:GetBagID()) if not f.hotkey then - local h = f:CreateFontString(name.."HotKey","ARTWORK","NumberFontNormalSmallGray") + local h = f:CreateFontString(self:GetName().."HotKey","ARTWORK","NumberFontNormalSmallGray") h:SetWidth(30) h:SetHeight(10) h:SetJustifyH("RIGHT") @@ -93,14 +90,14 @@ f.hotkey = h end - if not _G[name.."ItemAnim"] then - local anim = CreateFrame("Model",name.."ItemAnim",f,"ItemAnimTemplate") + if not _G[self:GetName().."ItemAnim"] then + local anim = CreateFrame("Model",self:GetName().."ItemAnim",f,"ItemAnimTemplate") anim:SetPoint("BOTTOMRIGHT",f,"BOTTOMRIGHT",-10,0) anim:Hide() end if not f.border then - local b = f:CreateTexture(name.."Border","OVERLAY") + local b = f:CreateTexture(self:GetName().."Border","OVERLAY") b:SetAllPoints() b:SetWidth(f:GetWidth()*(62/36)) b:SetHeight(f:GetHeight()*(62/36)) @@ -113,9 +110,9 @@ self.frames.count:SetDrawLayer("ARTWORK") self.frames.hotkey = f.hotkey - self.frames.border = _G[name.."Border"] - self.frames.icon = _G[name.."IconTexture"] - self.frames.anim = _G[name.."ItemAnim"] + self.frames.border = _G[self:GetName().."Border"] + self.frames.icon = _G[self:GetName().."IconTexture"] + self.frames.anim = _G[self:GetName().."ItemAnim"] -- initial display if ReAction:GetConfigMode() then @@ -193,8 +190,8 @@ -- -- Bag Button class -- -function Bag:New(name, cfg, bar, idx) - self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" ) +function Bag:New(cfg, bar, idx) + self = Super.New(self, cfg, bar, idx, "ItemButtonTemplate" ) local f = self:GetFrame() @@ -209,7 +206,7 @@ -- attach to skinner bar:SkinButton(self, { - Icon = _G[name.."IconTexture"] + Icon = _G[self:GetName().."IconTexture"] } ) @@ -291,11 +288,11 @@ -- -- Backpack Button class -- -function Backpack:New(name, cfg, bar, idx) - self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" ) +function Backpack:New(cfg, bar, idx) + self = Super.New(self, cfg, bar, idx, "ItemButtonTemplate" ) local f = self:GetFrame() - local icon = _G[name.."IconTexture"] + local icon = _G[self:GetName().."IconTexture"] icon:SetTexture("Interface\\Buttons\\Button-Backpack-Up") icon:Show() f:SetCheckedTexture("Interface\\Buttons\\CheckButtonHilight") @@ -306,7 +303,7 @@ -- attach to skinner bar:SkinButton(self, { - Icon = _G[name.."IconTexture"] + Icon = _G[self:GetName().."IconTexture"] } ) @@ -386,78 +383,6 @@ end --- --- Keyring Button class --- -function Keyring:New(name, cfg, bar, idx) - self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" ) - - local f = self:GetFrame() - - f:SetWidth(18) - f:SetHeight(39) - - local tex = f:GetNormalTexture() - tex:ClearAllPoints() - tex:SetAllPoints() - - f:SetNormalTexture("Interface\\Buttons\\UI-Button-KeyRing") - f:SetHighlightTexture("Interface\\Buttons\\UI-Button-KeyRing-Highlight") - f:SetPushedTexture("Interface\\Buttons\\UI-Button-KeyRing-Down") - f:GetNormalTexture():SetTexCoord(0,0.5625,0,0.609375) - f:GetHighlightTexture():SetTexCoord(0,0.5625,0,0.609375) - f:GetPushedTexture():SetTexCoord(0,0.5625,0,0.609375) - - if not HasKey() then - f:Hide() - end - - -- DO NOT attach to skinner - - return self -end - -function Keyring:GetBagID() - return KEYRING_CONTAINER -end - -function Keyring:Refresh() - local f = self:GetFrame() - self.bar:PlaceButton( self, f:GetHeight(), f:GetHeight() ) -- use height x height since it's an odd size - self:UpdateHotkey() - self:Update() -end - -function Keyring:SetTooltip() - GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_RIGHT"); - GameTooltip:SetText(KEYRING, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); - GameTooltip:AddLine(); -end - -function Keyring:OnReceiveDrag() - if CursorHasItem() then - PutKeyInKeyRing() - end -end - -function Keyring:OnClick() - if CursorHasItem() then - PutKeyInKeyRing() - else - ToggleKeyRing() - end - self:UpdateChecked() -end - -function Keyring:ShowGridTemp(show) - if not HasKey() then - if show then - self:GetFrame():Show() - else - self:GetFrame():Hide() - end - end -end