annotate classes/BagButton.lua @ 234:0e20f65375d5

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