annotate BagButton.lua @ 264:d2e55b61e5e6 stable

Merge 1.1 beta 6 to stable
author Flick
date Fri, 06 May 2011 15:52:21 -0700
parents c918ff9ac787
children 36a29870bf34
rev   line source
flickerstreak@175 1 local addonName, addonTable = ...
flickerstreak@175 2 local ReAction = addonTable.ReAction
flickerstreak@146 3 local L = ReAction.L
flickerstreak@146 4 local _G = _G
flickerstreak@146 5 local CreateFrame = CreateFrame
flickerstreak@146 6 local format = string.format
flickerstreak@146 7 local GetCVar = GetCVar
flickerstreak@146 8 local ContainerIDToInventoryID = ContainerIDToInventoryID
flickerstreak@146 9 local NUM_CONTAINER_FRAMES = NUM_CONTAINER_FRAMES
flickerstreak@146 10 local IsModifiedClick = IsModifiedClick
flickerstreak@146 11 local CursorHasItem = CursorHasItem
flickerstreak@146 12 local GetInventoryItemTexture = GetInventoryItemTexture
flickerstreak@146 13 local GetInventorySlotInfo = GetInventorySlotInfo
flickerstreak@146 14 local PickupBagFromSlot = PickupBagFromSlot
flickerstreak@146 15 local CursorCanGoInSlot = CursorCanGoInSlot
flickerstreak@146 16
flickerstreak@146 17 -- class declarations
flickerstreak@218 18 local buttonTypeID = "Bag"
Flick@234 19 local weak = { __mode = "k" }
flickerstreak@146 20 local Super = ReAction.Button
flickerstreak@218 21 local BagBase = setmetatable(
flickerstreak@218 22 {
flickerstreak@218 23 defaultBarConfig = {
flickerstreak@218 24 type = buttonTypeID,
flickerstreak@218 25 btnWidth = 30,
flickerstreak@218 26 btnHeight = 30,
flickerstreak@218 27 btnRows = 1,
flickerstreak@218 28 btnColumns = 6,
flickerstreak@221 29 spacing = 4,
flickerstreak@221 30 buttons = { }
flickerstreak@218 31 },
flickerstreak@218 32
flickerstreak@218 33 barType = L["Bag Bar"],
Flick@234 34 buttonTypeID = buttonTypeID,
Flick@234 35
Flick@234 36 allButtons = setmetatable( { }, weak )
flickerstreak@218 37 },
flickerstreak@218 38 { __index = Super } )
flickerstreak@218 39
flickerstreak@146 40 local Bag = setmetatable( { }, { __index = BagBase } )
flickerstreak@146 41 local Backpack = setmetatable( { }, { __index = BagBase } )
flickerstreak@146 42 local Keyring = setmetatable( { }, { __index = BagBase } )
flickerstreak@146 43
flickerstreak@146 44 ReAction.Button.Bag = BagBase
flickerstreak@223 45 ReAction:RegisterBarType(BagBase)
flickerstreak@146 46
flickerstreak@146 47 --
flickerstreak@146 48 -- Bag Button base class
flickerstreak@146 49 --
flickerstreak@146 50
Flick@234 51 function BagBase:New( btnCfg, bar, idx, idHint )
flickerstreak@146 52 local name = format("ReAction_%s_Bag_%d",bar:GetName(),idx)
flickerstreak@146 53
flickerstreak@146 54 -- use a variable private leaf implementation class
flickerstreak@146 55 -- unlike traditional OO programming, we can initialize the leaf
flickerstreak@221 56 -- class before initializing its parent
flickerstreak@146 57 local class = Bag
flickerstreak@146 58 if idx == 1 then
flickerstreak@146 59 class = Backpack
flickerstreak@146 60 elseif idx == 6 then
flickerstreak@146 61 class = Keyring
flickerstreak@146 62 end
flickerstreak@221 63 self = class:New(name, btnCfg, bar, idx)
flickerstreak@146 64
flickerstreak@146 65 local f = self:GetFrame()
flickerstreak@146 66 local config = self:GetConfig()
flickerstreak@146 67
flickerstreak@146 68 -- set up the bag ID pool
flickerstreak@146 69 self:SetActionIDPool("bag",6)
flickerstreak@146 70 config.bagID = self:AcquireActionID(config.bagID, idHint, true)
flickerstreak@146 71
flickerstreak@146 72 -- non secure scripts
flickerstreak@146 73 f:SetScript("OnEvent", function(frame, ...) self:OnEvent(...) end)
flickerstreak@146 74 f:SetScript("OnEnter", function(frame) self:OnEnter() end)
flickerstreak@146 75 f:SetScript("OnLeave", function(frame) self:OnLeave() end)
flickerstreak@146 76 f:SetScript("OnReceiveDrag", function(frame, ...) self:OnReceiveDrag(...) end)
flickerstreak@146 77 f:SetScript("OnClick", function(frame, ...) self:OnClick(...) end)
flickerstreak@146 78
flickerstreak@146 79 -- secure handlers
flickerstreak@146 80 -- (none)
flickerstreak@146 81
flickerstreak@146 82 -- event registration
flickerstreak@146 83 f:RegisterEvent("UPDATE_BINDINGS")
flickerstreak@146 84
flickerstreak@146 85 -- frame setup
flickerstreak@146 86 f:SetID(self:GetBagID())
flickerstreak@146 87
flickerstreak@146 88 if not f.hotkey then
flickerstreak@146 89 local h = f:CreateFontString(name.."HotKey","ARTWORK","NumberFontNormalSmallGray")
flickerstreak@152 90 h:SetWidth(30)
flickerstreak@146 91 h:SetHeight(10)
flickerstreak@146 92 h:SetJustifyH("RIGHT")
flickerstreak@146 93 h:SetPoint("TOPLEFT",f,"TOPLEFT",-2,-2)
flickerstreak@146 94 h:Show()
flickerstreak@146 95 f.hotkey = h
flickerstreak@146 96 end
flickerstreak@146 97
flickerstreak@146 98 if not _G[name.."ItemAnim"] then
flickerstreak@146 99 local anim = CreateFrame("Model",name.."ItemAnim",f,"ItemAnimTemplate")
flickerstreak@146 100 anim:SetPoint("BOTTOMRIGHT",f,"BOTTOMRIGHT",-10,0)
flickerstreak@146 101 anim:Hide()
flickerstreak@146 102 end
flickerstreak@146 103
flickerstreak@152 104 if not f.border then
flickerstreak@152 105 local b = f:CreateTexture(name.."Border","OVERLAY")
flickerstreak@152 106 b:SetAllPoints()
flickerstreak@152 107 b:SetWidth(f:GetWidth()*(62/36))
flickerstreak@152 108 b:SetHeight(f:GetHeight()*(62/36))
flickerstreak@152 109 b:SetTexture("Interface\\Buttons\UI-ActionButton-Border")
flickerstreak@152 110 b:SetBlendMode("ADD")
flickerstreak@152 111 b:Hide()
flickerstreak@152 112 f.border = b
flickerstreak@152 113 end
flickerstreak@152 114
flickerstreak@146 115 self.frames.count:SetDrawLayer("ARTWORK")
flickerstreak@146 116
flickerstreak@146 117 self.frames.hotkey = f.hotkey
flickerstreak@152 118 self.frames.border = _G[name.."Border"]
flickerstreak@146 119 self.frames.icon = _G[name.."IconTexture"]
flickerstreak@146 120 self.frames.anim = _G[name.."ItemAnim"]
flickerstreak@146 121
flickerstreak@146 122 -- initial display
flickerstreak@146 123 if ReAction:GetConfigMode() then
flickerstreak@146 124 self:GetFrame():Show()
flickerstreak@146 125 end
flickerstreak@146 126
flickerstreak@146 127 self:Refresh()
flickerstreak@146 128
Flick@234 129 BagBase.allButtons[self] = true
Flick@234 130
flickerstreak@146 131 return self
flickerstreak@146 132 end
flickerstreak@146 133
Flick@234 134 function BagBase:Destroy()
Flick@234 135 BagBase.allButtons[self] = nil
Flick@234 136 Super.Destroy(self)
Flick@234 137 end
Flick@234 138
Flick@234 139
flickerstreak@146 140 function BagBase:GetActionID()
flickerstreak@146 141 return self.config.bagID
flickerstreak@146 142 end
flickerstreak@146 143
flickerstreak@146 144 function BagBase:GetBagID()
flickerstreak@146 145 return self:GetActionID() - 1
flickerstreak@146 146 end
flickerstreak@146 147
flickerstreak@146 148 function BagBase:Refresh()
flickerstreak@146 149 Super.Refresh(self)
flickerstreak@146 150 self:UpdateHotkey()
flickerstreak@146 151 self:Update()
flickerstreak@146 152 end
flickerstreak@146 153
flickerstreak@146 154 function BagBase:Update()
flickerstreak@146 155 self:UpdateChecked()
flickerstreak@146 156 end
flickerstreak@146 157
flickerstreak@146 158 function BagBase:UpdateChecked(force)
flickerstreak@146 159 if force == nil then
flickerstreak@146 160 for i=1, NUM_CONTAINER_FRAMES do
flickerstreak@146 161 local c = _G["ContainerFrame"..i]
flickerstreak@146 162 if c:GetID() == self:GetBagID() and c:IsShown() then
flickerstreak@146 163 self:GetFrame():SetChecked(1)
flickerstreak@146 164 return
flickerstreak@146 165 end
flickerstreak@146 166 end
flickerstreak@146 167 self:GetFrame():SetChecked(0)
flickerstreak@146 168 end
flickerstreak@146 169 self:GetFrame():SetChecked(force)
flickerstreak@146 170 end
flickerstreak@146 171
flickerstreak@146 172 function BagBase:OnEvent(evt, ...)
flickerstreak@146 173 if self[evt] then
flickerstreak@146 174 self[evt](self, ...)
flickerstreak@146 175 end
flickerstreak@146 176 end
flickerstreak@146 177
flickerstreak@146 178 function BagBase:OnEnter()
flickerstreak@146 179 self:SetTooltip()
flickerstreak@146 180 end
flickerstreak@146 181
flickerstreak@146 182 function BagBase:OnLeave()
flickerstreak@146 183 GameTooltip:Hide()
flickerstreak@146 184 end
flickerstreak@146 185
flickerstreak@146 186 function BagBase:UPDATE_BINDINGS()
flickerstreak@146 187 self:UpdateHotkey()
flickerstreak@146 188 end
flickerstreak@146 189
Flick@234 190 function BagBase:IterateAllButtons()
Flick@234 191 return pairs(self.allButtons)
Flick@234 192 end
Flick@234 193
flickerstreak@146 194
flickerstreak@146 195 --
flickerstreak@146 196 -- Bag Button class
flickerstreak@146 197 --
flickerstreak@146 198 function Bag:New(name, cfg, bar, idx)
flickerstreak@146 199 self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" )
flickerstreak@146 200
flickerstreak@146 201 local f = self:GetFrame()
flickerstreak@146 202
flickerstreak@146 203 f:SetCheckedTexture("Interface\\Buttons\\CheckButtonHilight")
flickerstreak@146 204
flickerstreak@146 205 f:RegisterEvent("CURSOR_UPDATE")
flickerstreak@151 206 f:RegisterEvent("BAG_UPDATE")
flickerstreak@146 207 f:RegisterEvent("BAG_CLOSED")
flickerstreak@146 208 f:SetScript("OnDragStart", function(frame, ...) self:OnDragStart(...) end)
flickerstreak@146 209 f:RegisterForDrag("LeftButton")
flickerstreak@146 210
flickerstreak@146 211 -- attach to skinner
flickerstreak@146 212 bar:SkinButton(self,
flickerstreak@146 213 {
flickerstreak@146 214 Icon = _G[name.."IconTexture"]
flickerstreak@146 215 }
flickerstreak@146 216 )
flickerstreak@146 217
flickerstreak@146 218 return self
flickerstreak@146 219 end
flickerstreak@146 220
flickerstreak@146 221 function Bag:GetInventorySlot()
flickerstreak@146 222 return ContainerIDToInventoryID(self:GetBagID())
flickerstreak@146 223 end
flickerstreak@146 224
flickerstreak@146 225 function Bag:GetInventorySlotName()
flickerstreak@146 226 return "Bag"..(self:GetBagID()-1).."Slot"
flickerstreak@146 227 end
flickerstreak@146 228
flickerstreak@146 229 function Bag:SetTooltip()
flickerstreak@146 230 GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_LEFT")
flickerstreak@146 231 if not GameTooltip:SetInventoryItem("player", self:GetInventorySlot()) then
flickerstreak@146 232 GameTooltip:SetText(EQUIP_CONTAINER, 1.0, 1.0, 1.0)
flickerstreak@146 233 end
flickerstreak@146 234 end
flickerstreak@146 235
flickerstreak@146 236 function Bag:Update()
flickerstreak@146 237 local texture = GetInventoryItemTexture("player", self:GetInventorySlot())
flickerstreak@146 238 if texture then
flickerstreak@146 239 self.frames.icon:SetTexture(texture)
flickerstreak@146 240 self.frames.icon:Show()
flickerstreak@146 241 self:GetFrame():SetNormalTexture("Interface\\Buttons\\UI-Quickslot2")
flickerstreak@146 242 else
flickerstreak@146 243 local _, bgTex = GetInventorySlotInfo(self:GetInventorySlotName())
flickerstreak@146 244 self.frames.icon:SetTexture(bgTex)
flickerstreak@146 245 self:GetFrame():SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
flickerstreak@146 246 end
flickerstreak@146 247 self:UpdateChecked()
flickerstreak@146 248 end
flickerstreak@146 249
flickerstreak@146 250 function Bag:OnClick()
flickerstreak@146 251 if IsModifiedClick("OPENALLBAGS") then
flickerstreak@146 252 OpenAllBags()
flickerstreak@146 253 else
flickerstreak@146 254 if not PutItemInBag(self:GetInventorySlot()) then
flickerstreak@146 255 ToggleBag(self:GetBagID())
flickerstreak@146 256 end
flickerstreak@146 257 end
flickerstreak@146 258 self:UpdateChecked()
flickerstreak@146 259 end
flickerstreak@146 260
flickerstreak@146 261 function Bag:OnReceiveDrag()
flickerstreak@146 262 if CursorHasItem() then
flickerstreak@146 263 PutItemInBag(self:GetInventorySlot())
flickerstreak@146 264 end
flickerstreak@146 265 end
flickerstreak@146 266
flickerstreak@146 267 function Bag:OnDragStart()
flickerstreak@146 268 PickupBagFromSlot(self:GetInventorySlot())
flickerstreak@146 269 self:Update()
flickerstreak@146 270 end
flickerstreak@146 271
flickerstreak@151 272 function Bag:BAG_UPDATE(bag)
flickerstreak@151 273 if bag == self:GetBagID() then
flickerstreak@146 274 self:Update()
flickerstreak@146 275 end
flickerstreak@146 276 end
flickerstreak@146 277
flickerstreak@146 278 function Bag:CURSOR_UPDATE()
flickerstreak@146 279 if CursorCanGoInSlot(self:GetInventorySlot()) then
flickerstreak@146 280 self:GetFrame():LockHighlight()
flickerstreak@146 281 else
flickerstreak@146 282 self:GetFrame():UnlockHighlight()
flickerstreak@146 283 end
flickerstreak@146 284 end
flickerstreak@146 285
flickerstreak@146 286 function Bag:BAG_CLOSED(bag)
flickerstreak@146 287 if bag == self:GetBagID() then
flickerstreak@146 288 self:Update()
flickerstreak@146 289 end
flickerstreak@146 290 end
flickerstreak@146 291
flickerstreak@146 292
flickerstreak@146 293 --
flickerstreak@146 294 -- Backpack Button class
flickerstreak@146 295 --
flickerstreak@146 296 function Backpack:New(name, cfg, bar, idx)
flickerstreak@146 297 self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" )
flickerstreak@146 298
flickerstreak@146 299 local f = self:GetFrame()
flickerstreak@146 300 local icon = _G[name.."IconTexture"]
flickerstreak@146 301 icon:SetTexture("Interface\\Buttons\\Button-Backpack-Up")
flickerstreak@146 302 icon:Show()
flickerstreak@146 303 f:SetCheckedTexture("Interface\\Buttons\\CheckButtonHilight")
flickerstreak@146 304 f:RegisterEvent("PLAYER_ENTERING_WORLD");
flickerstreak@146 305 f:RegisterEvent("CVAR_UPDATE");
flickerstreak@146 306 f:SetScript("OnShow", function(frame, ...) self:OnShow(...) end)
flickerstreak@146 307
flickerstreak@146 308 -- attach to skinner
flickerstreak@146 309 bar:SkinButton(self,
flickerstreak@146 310 {
flickerstreak@146 311 Icon = _G[name.."IconTexture"]
flickerstreak@146 312 }
flickerstreak@146 313 )
flickerstreak@146 314
flickerstreak@146 315 return self
flickerstreak@146 316 end
flickerstreak@146 317
flickerstreak@146 318 function Backpack:Update()
flickerstreak@146 319 self:UpdateFreeSlots()
flickerstreak@146 320 self:UpdateChecked()
flickerstreak@146 321 end
flickerstreak@146 322
flickerstreak@146 323 function Backpack:UpdateFreeSlots()
flickerstreak@146 324 if GetCVar("displayFreeBagSlots") == "1" then
flickerstreak@146 325 local total = 0
flickerstreak@146 326 for i = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
flickerstreak@146 327 local free, family = GetContainerNumFreeSlots(i)
flickerstreak@146 328 if family == 0 then
flickerstreak@146 329 total = total + free
flickerstreak@146 330 end
flickerstreak@146 331 end
flickerstreak@146 332
flickerstreak@146 333 self.freeSlots = total
flickerstreak@146 334 self.frames.count:SetText(format("(%s)", self.freeSlots))
flickerstreak@146 335 self.frames.count:Show()
flickerstreak@146 336 elseif self.frames.count:IsShown() then
flickerstreak@146 337 self.frames.count:Hide()
flickerstreak@146 338 end
flickerstreak@146 339 end
flickerstreak@146 340
flickerstreak@146 341 function Backpack:SetTooltip()
flickerstreak@146 342 GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_LEFT")
flickerstreak@146 343 GameTooltip:SetText(BACKPACK_TOOLTIP, 1.0, 1.0, 1.0)
flickerstreak@146 344 GameTooltip:AddLine(string.format(NUM_FREE_SLOTS, (self.freeSlots or 0)))
flickerstreak@146 345 GameTooltip:Show();
flickerstreak@146 346 end
flickerstreak@146 347
flickerstreak@146 348 function Backpack:OnShow()
flickerstreak@146 349 self:UpdateFreeSlots()
flickerstreak@146 350 end
flickerstreak@146 351
flickerstreak@146 352 function Backpack:OnClick()
flickerstreak@146 353 if IsModifiedClick("OPENALLBAGS") then
flickerstreak@146 354 OpenAllBags()
flickerstreak@146 355 else
flickerstreak@146 356 if not PutItemInBackpack() then
flickerstreak@146 357 ToggleBackpack()
flickerstreak@146 358 end
flickerstreak@146 359 end
flickerstreak@146 360 self:UpdateChecked()
flickerstreak@146 361 end
flickerstreak@146 362
flickerstreak@146 363 function Backpack:OnReceiveDrag()
flickerstreak@146 364 if CursorHasItem() then
flickerstreak@146 365 PutItemInBackpack()
flickerstreak@146 366 end
flickerstreak@146 367 end
flickerstreak@146 368
flickerstreak@146 369 function Backpack:PLAYER_ENTERING_WORLD()
flickerstreak@146 370 self:CVAR_UPDATE("DISPLAY_FREE_BAG_SLOTS", GetCVar("displayFreeBagSlots"))
flickerstreak@146 371 end
flickerstreak@146 372
flickerstreak@146 373 function Backpack:CVAR_UPDATE( cvar, value )
flickerstreak@146 374 if cvar == "DISPLAY_FREE_BAG_SLOTS" then
flickerstreak@146 375 if value == "1" then
flickerstreak@146 376 self:GetFrame():RegisterEvent("BAG_UPDATE")
flickerstreak@146 377 else
flickerstreak@146 378 self:GetFrame():UnregisterEvent("BAG_UPDATE")
flickerstreak@146 379 end
flickerstreak@146 380 self:UpdateFreeSlots()
flickerstreak@146 381 end
flickerstreak@146 382 end
flickerstreak@146 383
flickerstreak@146 384 function Backpack:BAG_UPDATE(bag)
flickerstreak@146 385 if bag >= BACKPACK_CONTAINER and bag <= NUM_BAG_SLOTS then
flickerstreak@146 386 self:UpdateFreeSlots()
flickerstreak@146 387 end
flickerstreak@146 388 end
flickerstreak@146 389
flickerstreak@146 390
flickerstreak@146 391 --
flickerstreak@146 392 -- Keyring Button class
flickerstreak@146 393 --
flickerstreak@146 394 function Keyring:New(name, cfg, bar, idx)
flickerstreak@146 395 self = Super.New(self, name, cfg, bar, idx, "ItemButtonTemplate" )
flickerstreak@146 396
flickerstreak@146 397 local f = self:GetFrame()
flickerstreak@146 398
flickerstreak@146 399 f:SetWidth(18)
flickerstreak@146 400 f:SetHeight(39)
flickerstreak@146 401
flickerstreak@146 402 local tex = f:GetNormalTexture()
flickerstreak@146 403 tex:ClearAllPoints()
flickerstreak@152 404 tex:SetAllPoints()
flickerstreak@146 405
flickerstreak@146 406 f:SetNormalTexture("Interface\\Buttons\\UI-Button-KeyRing")
flickerstreak@146 407 f:SetHighlightTexture("Interface\\Buttons\\UI-Button-KeyRing-Highlight")
flickerstreak@146 408 f:SetPushedTexture("Interface\\Buttons\\UI-Button-KeyRing-Down")
flickerstreak@146 409 f:GetNormalTexture():SetTexCoord(0,0.5625,0,0.609375)
flickerstreak@146 410 f:GetHighlightTexture():SetTexCoord(0,0.5625,0,0.609375)
flickerstreak@146 411 f:GetPushedTexture():SetTexCoord(0,0.5625,0,0.609375)
flickerstreak@146 412
flickerstreak@146 413 if not HasKey() then
flickerstreak@146 414 f:Hide()
flickerstreak@146 415 end
flickerstreak@146 416
flickerstreak@146 417 -- DO NOT attach to skinner
flickerstreak@146 418
flickerstreak@146 419 return self
flickerstreak@146 420 end
flickerstreak@146 421
flickerstreak@146 422 function Keyring:GetBagID()
flickerstreak@146 423 return KEYRING_CONTAINER
flickerstreak@146 424 end
flickerstreak@146 425
flickerstreak@146 426 function Keyring:Refresh()
flickerstreak@146 427 local f = self:GetFrame()
flickerstreak@146 428 self.bar:PlaceButton( self, f:GetHeight(), f:GetHeight() ) -- use height x height since it's an odd size
flickerstreak@146 429 self:UpdateHotkey()
flickerstreak@146 430 self:Update()
flickerstreak@146 431 end
flickerstreak@146 432
flickerstreak@146 433 function Keyring:SetTooltip()
flickerstreak@146 434 GameTooltip:SetOwner(self:GetFrame(), "ANCHOR_RIGHT");
flickerstreak@146 435 GameTooltip:SetText(KEYRING, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
flickerstreak@146 436 GameTooltip:AddLine();
flickerstreak@146 437 end
flickerstreak@146 438
flickerstreak@146 439 function Keyring:OnReceiveDrag()
flickerstreak@146 440 if CursorHasItem() then
flickerstreak@146 441 PutKeyInKeyRing()
flickerstreak@146 442 end
flickerstreak@146 443 end
flickerstreak@146 444
flickerstreak@146 445 function Keyring:OnClick()
flickerstreak@146 446 if CursorHasItem() then
flickerstreak@146 447 PutKeyInKeyRing()
flickerstreak@146 448 else
flickerstreak@146 449 ToggleKeyRing()
flickerstreak@146 450 end
flickerstreak@146 451 self:UpdateChecked()
flickerstreak@146 452 end
flickerstreak@146 453
flickerstreak@146 454 function Keyring:ShowGridTemp(show)
flickerstreak@146 455 if not HasKey() then
flickerstreak@146 456 if show then
flickerstreak@146 457 self:GetFrame():Show()
flickerstreak@146 458 else
flickerstreak@146 459 self:GetFrame():Hide()
flickerstreak@146 460 end
flickerstreak@146 461 end
flickerstreak@146 462 end
flickerstreak@146 463
Flick@234 464
Flick@234 465
Flick@234 466 -- hook some functions to propagate to our bag buttons
Flick@234 467 hooksecurefunc("Disable_BagButtons",
Flick@234 468 function()
Flick@234 469 for b in BagBase:IterateAllButtons() do
Flick@234 470 local f = b:GetFrame()
Flick@234 471 f:Disable()
Flick@234 472 SetDesaturation(b.frames.icon,1)
Flick@234 473 end
Flick@234 474 end)
Flick@234 475
Flick@234 476 hooksecurefunc("Enable_BagButtons",
Flick@234 477 function()
Flick@234 478 for b in BagBase:IterateAllButtons() do
Flick@234 479 local f = b:GetFrame()
Flick@234 480 f:Enable()
Flick@234 481 SetDesaturation(b.frames.icon,nil)
Flick@234 482 end
Flick@234 483 end)
Flick@234 484
Flick@234 485 hooksecurefunc("ContainerFrame_OnHide",
Flick@234 486 function()
Flick@234 487 for b in BagBase:IterateAllButtons() do
Flick@234 488 b:Update()
Flick@234 489 end
Flick@234 490 end)
Flick@234 491
Flick@234 492 hooksecurefunc("ContainerFrame_OnShow",
Flick@234 493 function()
Flick@234 494 for b in BagBase:IterateAllButtons() do
Flick@234 495 b:Update()
Flick@234 496 end
Flick@234 497 end)