annotate modules/ReAction_PetAction/ReAction_PetAction.lua @ 94:39265b16d208

Fixed handling of pet buttons past 10
author Flick <flickerstreak@gmail.com>
date Fri, 17 Oct 2008 23:46:30 +0000
parents 567a885cdfad
children 168cae4aa8bd
rev   line source
flickerstreak@28 1 --[[
flickerstreak@53 2 ReAction Pet Action button module
flickerstreak@53 3
flickerstreak@53 4 The button module implements standard action button functionality by wrapping Blizzard's
flickerstreak@77 5 PetActionButton frame and associated functions.
flickerstreak@28 6
flickerstreak@28 7 --]]
flickerstreak@28 8
flickerstreak@28 9 -- local imports
flickerstreak@28 10 local ReAction = ReAction
flickerstreak@28 11 local L = ReAction.L
flickerstreak@28 12 local _G = _G
flickerstreak@53 13 local CreateFrame = CreateFrame
flickerstreak@28 14
flickerstreak@80 15 ReAction:UpdateRevision("$Revision$")
flickerstreak@77 16
flickerstreak@93 17 -- libraries
flickerstreak@93 18 local KB = LibStub("LibKeyBound-1.0")
flickerstreak@93 19
flickerstreak@28 20 -- module declaration
flickerstreak@28 21 local moduleID = "PetAction"
flickerstreak@28 22 local module = ReAction:NewModule( moduleID )
flickerstreak@28 23
flickerstreak@77 24 -- Button class declaration
flickerstreak@77 25 local Button = { }
flickerstreak@77 26
flickerstreak@28 27 -- module methods
flickerstreak@28 28 function module:OnInitialize()
flickerstreak@53 29 self.db = ReAction.db:RegisterNamespace( moduleID,
flickerstreak@28 30 {
flickerstreak@28 31 profile = {
flickerstreak@28 32 buttons = { }
flickerstreak@28 33 }
flickerstreak@28 34 }
flickerstreak@28 35 )
flickerstreak@53 36 self.buttons = { }
flickerstreak@63 37
flickerstreak@63 38 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions")
flickerstreak@63 39
flickerstreak@63 40 ReAction.RegisterCallback(self, "OnCreateBar")
flickerstreak@63 41 ReAction.RegisterCallback(self, "OnDestroyBar")
flickerstreak@63 42 ReAction.RegisterCallback(self, "OnRefreshBar")
flickerstreak@63 43 ReAction.RegisterCallback(self, "OnEraseBar")
flickerstreak@63 44 ReAction.RegisterCallback(self, "OnRenameBar")
flickerstreak@63 45 ReAction.RegisterCallback(self, "OnConfigModeChanged")
flickerstreak@93 46
flickerstreak@93 47 KB.RegisterCallback(self, "LIBKEYBOUND_ENABLED")
flickerstreak@93 48 KB.RegisterCallback(self, "LIBKEYBOUND_DISABLED")
flickerstreak@93 49 KB.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED","LIBKEYBOUND_ENABLED")
flickerstreak@28 50 end
flickerstreak@28 51
flickerstreak@28 52 function module:OnEnable()
flickerstreak@53 53 ReAction:RegisterBarType(L["Pet Action Bar"],
flickerstreak@53 54 {
flickerstreak@53 55 type = moduleID ,
flickerstreak@53 56 defaultButtonSize = 30,
flickerstreak@53 57 defaultBarRows = 1,
flickerstreak@53 58 defaultBarCols = 10,
flickerstreak@53 59 defaultBarSpacing = 8
flickerstreak@53 60 })
flickerstreak@28 61 end
flickerstreak@28 62
flickerstreak@28 63 function module:OnDisable()
flickerstreak@53 64 ReAction:UnregisterBarType(L["Pet Action Bar"])
flickerstreak@28 65 end
flickerstreak@28 66
flickerstreak@63 67 function module:OnCreateBar(event, bar, name)
flickerstreak@53 68 if bar.config.type == moduleID then
flickerstreak@53 69 -- auto show/hide when pet exists
flickerstreak@53 70 bar:GetFrame():SetAttribute("unit","pet")
flickerstreak@90 71 if not ReAction:GetConfigMode() then
flickerstreak@90 72 RegisterUnitWatch(bar:GetFrame())
flickerstreak@90 73 end
flickerstreak@63 74 self:OnRefreshBar(event, bar, name)
flickerstreak@28 75 end
flickerstreak@28 76 end
flickerstreak@28 77
flickerstreak@63 78 function module:OnRefreshBar(event, bar, name)
flickerstreak@53 79 if bar.config.type == moduleID then
flickerstreak@53 80 if self.buttons[bar] == nil then
flickerstreak@53 81 self.buttons[bar] = { }
flickerstreak@53 82 end
flickerstreak@53 83 local btns = self.buttons[bar]
flickerstreak@53 84 local profile = self.db.profile
flickerstreak@63 85 if profile.buttons[name] == nil then
flickerstreak@63 86 profile.buttons[name] = {}
flickerstreak@53 87 end
flickerstreak@63 88 local btnCfg = profile.buttons[name]
flickerstreak@53 89
flickerstreak@53 90 local r, c = bar:GetButtonGrid()
flickerstreak@53 91 local n = r*c
flickerstreak@53 92 for i = 1, n do
flickerstreak@53 93 if btnCfg[i] == nil then
flickerstreak@53 94 btnCfg[i] = {}
flickerstreak@53 95 end
flickerstreak@53 96 if btns[i] == nil then
flickerstreak@94 97 local success, r = pcall(Button.New,Button,bar,i,btnCfg[i])
flickerstreak@94 98 if success and r then
flickerstreak@94 99 btns[i] = r
flickerstreak@94 100 bar:AddButton(i,r)
flickerstreak@94 101 else
flickerstreak@94 102 n = i - 1
flickerstreak@94 103 bar:ClipNButtons(n)
flickerstreak@94 104 break
flickerstreak@94 105 end
flickerstreak@53 106 end
flickerstreak@77 107 btns[i]:Refresh()
flickerstreak@53 108 end
flickerstreak@53 109 for i = n+1, #btns do
flickerstreak@53 110 if btns[i] then
flickerstreak@77 111 bar:RemoveButton(btns[i])
flickerstreak@53 112 btns[i] = btns[i]:Destroy()
flickerstreak@53 113 if btnCfg[i] then
flickerstreak@53 114 btnCfg[i] = nil
flickerstreak@53 115 end
flickerstreak@53 116 end
flickerstreak@53 117 end
flickerstreak@53 118 end
flickerstreak@53 119 end
flickerstreak@53 120
flickerstreak@63 121 function module:OnDestroyBar(event, bar, name)
flickerstreak@53 122 if self.buttons[bar] then
flickerstreak@53 123 local btns = self.buttons[bar]
flickerstreak@53 124 for _,b in pairs(btns) do
flickerstreak@53 125 if b then
flickerstreak@53 126 b:Destroy()
flickerstreak@53 127 end
flickerstreak@53 128 end
flickerstreak@53 129 self.buttons[bar] = nil
flickerstreak@53 130 end
flickerstreak@53 131 end
flickerstreak@53 132
flickerstreak@63 133 function module:OnEraseBar(event, bar, name)
flickerstreak@63 134 self.db.profile.buttons[name] = nil
flickerstreak@53 135 end
flickerstreak@53 136
flickerstreak@63 137 function module:OnRenameBar(event, bar, oldname, newname)
flickerstreak@53 138 local b = self.db.profile.buttons
flickerstreak@53 139 b[newname], b[oldname] = b[oldname], nil
flickerstreak@53 140 end
flickerstreak@53 141
flickerstreak@53 142
flickerstreak@63 143 function module:OnConfigModeChanged(event, mode)
flickerstreak@77 144 for _, buttons in pairs(self.buttons) do
flickerstreak@77 145 for _, b in pairs(buttons) do
flickerstreak@77 146 b:ShowActionIDLabel(mode)
flickerstreak@77 147 end
flickerstreak@77 148 end
flickerstreak@63 149 for _, bar in ReAction:IterateBars() do
flickerstreak@53 150 if bar and self.buttons[bar] then
flickerstreak@53 151 local f = bar:GetFrame()
flickerstreak@53 152 if mode then
flickerstreak@53 153 UnregisterUnitWatch(f)
flickerstreak@53 154 f:Show()
flickerstreak@53 155 else
flickerstreak@53 156 RegisterUnitWatch(f)
flickerstreak@53 157 end
flickerstreak@53 158 end
flickerstreak@53 159 end
flickerstreak@53 160 end
flickerstreak@53 161
flickerstreak@93 162 function module:LIBKEYBOUND_ENABLED(evt)
flickerstreak@93 163 for _, buttons in pairs(self.buttons) do
flickerstreak@93 164 for _, b in pairs(buttons) do
flickerstreak@93 165 b:SetKeybindMode(true)
flickerstreak@93 166 end
flickerstreak@93 167 end
flickerstreak@93 168 end
flickerstreak@93 169
flickerstreak@93 170 function module:LIBKEYBOUND_DISABLED(evt)
flickerstreak@93 171 for _, buttons in pairs(self.buttons) do
flickerstreak@93 172 for _, b in pairs(buttons) do
flickerstreak@93 173 b:SetKeybindMode(false)
flickerstreak@93 174 end
flickerstreak@93 175 end
flickerstreak@93 176 end
flickerstreak@93 177
flickerstreak@53 178
flickerstreak@60 179 ---- Options ----
flickerstreak@60 180 function module:GetBarOptions(bar)
flickerstreak@91 181 if bar.config.type == moduleID then
flickerstreak@91 182 return {
flickerstreak@91 183 type = "group",
flickerstreak@91 184 name = L["Pet Buttons"],
flickerstreak@91 185 args = {
flickerstreak@91 186 }
flickerstreak@60 187 }
flickerstreak@91 188 end
flickerstreak@59 189 end
flickerstreak@59 190
flickerstreak@53 191
flickerstreak@28 192
flickerstreak@77 193 ------ Button class ------
flickerstreak@77 194
flickerstreak@28 195 -- use-count of action IDs
flickerstreak@53 196 local nActionIDs = NUM_PET_ACTION_SLOTS
flickerstreak@28 197 local ActionIDList = setmetatable( {}, {
flickerstreak@28 198 __index = function(self, idx)
flickerstreak@28 199 if idx == nil then
flickerstreak@53 200 for i = 1, nActionIDs do
flickerstreak@28 201 if rawget(self,i) == nil then
flickerstreak@28 202 rawset(self,i,1)
flickerstreak@28 203 return i
flickerstreak@28 204 end
flickerstreak@28 205 end
flickerstreak@53 206 error("ran out of pet action IDs")
flickerstreak@28 207 else
flickerstreak@28 208 local c = rawget(self,idx) or 0
flickerstreak@28 209 rawset(self,idx,c+1)
flickerstreak@28 210 return idx
flickerstreak@28 211 end
flickerstreak@28 212 end,
flickerstreak@28 213 __newindex = function(self,idx,value)
flickerstreak@28 214 if value == nil then
flickerstreak@28 215 value = rawget(self,idx)
flickerstreak@28 216 if value == 1 then
flickerstreak@28 217 value = nil
flickerstreak@28 218 elseif value then
flickerstreak@28 219 value = value - 1
flickerstreak@28 220 end
flickerstreak@28 221 end
flickerstreak@28 222 rawset(self,idx,value)
flickerstreak@28 223 end
flickerstreak@28 224 })
flickerstreak@28 225
flickerstreak@53 226 local frameRecycler = {}
flickerstreak@93 227 local trash = CreateFrame("Frame")
flickerstreak@93 228 local KBAttach, GetActionName, GetHotkey, SetKey, FreeKey, ClearBindings, GetBindings
flickerstreak@93 229 do
flickerstreak@93 230 local buttonLookup = setmetatable({},{__mode="kv"})
flickerstreak@93 231
flickerstreak@93 232 -- Use KeyBound-1.0 for binding, but use Override bindings instead of
flickerstreak@93 233 -- regular bindings to support multiple profile use. This is a little
flickerstreak@93 234 -- weird with the KeyBound dialog box (which has per-char selector as well
flickerstreak@93 235 -- as an OK/Cancel box) but it's the least amount of effort to implement.
flickerstreak@93 236 function GetActionName(f)
flickerstreak@93 237 local b = buttonLookup[f]
flickerstreak@93 238 if b then
flickerstreak@93 239 return format("%s:%s", b.bar:GetName(), b.idx)
flickerstreak@93 240 end
flickerstreak@93 241 end
flickerstreak@93 242
flickerstreak@93 243 function GetHotkey(f)
flickerstreak@93 244 local b = buttonLookup[f]
flickerstreak@93 245 if b then
flickerstreak@93 246 return KB:ToShortKey(b:GetConfig().hotkey)
flickerstreak@93 247 end
flickerstreak@93 248 end
flickerstreak@93 249
flickerstreak@93 250 function SetKey(f, key)
flickerstreak@93 251 local b = buttonLookup[f]
flickerstreak@93 252 if b then
flickerstreak@93 253 local c = b:GetConfig()
flickerstreak@93 254 if c.hotkey then
flickerstreak@93 255 SetOverrideBinding(f, false, c.hotkey, nil)
flickerstreak@93 256 end
flickerstreak@93 257 if key then
flickerstreak@93 258 SetOverrideBindingClick(f, false, key, f:GetName(), nil)
flickerstreak@93 259 end
flickerstreak@93 260 c.hotkey = key
flickerstreak@93 261 b:DisplayHotkey(GetHotkey(f))
flickerstreak@93 262 end
flickerstreak@93 263 end
flickerstreak@93 264
flickerstreak@93 265 function FreeKey(f, key)
flickerstreak@93 266 local b = buttonLookup[f]
flickerstreak@93 267 if b then
flickerstreak@93 268 local c = b:GetConfig()
flickerstreak@93 269 if c.hotkey == key then
flickerstreak@93 270 local action = f:GetActionName()
flickerstreak@93 271 SetOverrideBinding(f, false, c.hotkey, nil)
flickerstreak@93 272 c.hotkey = nil
flickerstreak@93 273 b:DisplayHotkey(nil)
flickerstreak@93 274 return action
flickerstreak@93 275 end
flickerstreak@93 276 end
flickerstreak@93 277 return ReAction:FreeOverrideHotkey(key)
flickerstreak@93 278 end
flickerstreak@93 279
flickerstreak@93 280 function ClearBindings(f)
flickerstreak@93 281 SetKey(f, nil)
flickerstreak@93 282 end
flickerstreak@93 283
flickerstreak@93 284 function GetBindings(f)
flickerstreak@93 285 local b = buttonLookup[f]
flickerstreak@93 286 if b then
flickerstreak@93 287 return b:GetConfig().hotkey
flickerstreak@93 288 end
flickerstreak@93 289 end
flickerstreak@93 290
flickerstreak@93 291 function KBAttach( button )
flickerstreak@93 292 local f = button:GetFrame()
flickerstreak@93 293 f.GetActionName = GetActionName
flickerstreak@93 294 f.GetHotkey = GetHotkey
flickerstreak@93 295 f.SetKey = SetKey
flickerstreak@93 296 f.FreeKey = FreeKey
flickerstreak@93 297 f.ClearBindings = ClearBindings
flickerstreak@93 298 f.GetBindings = GetBindings
flickerstreak@93 299 buttonLookup[f] = button
flickerstreak@93 300 f:SetKey(button:GetConfig().hotkey)
flickerstreak@93 301 ReAction:RegisterKeybindFrame(f)
flickerstreak@93 302 if ReAction:GetKeybindMode() then
flickerstreak@93 303 button.border:SetVertexColor(KB:GetColorKeyBoundMode())
flickerstreak@93 304 button.border:Show()
flickerstreak@93 305 end
flickerstreak@93 306 end
flickerstreak@93 307 end
flickerstreak@93 308
flickerstreak@90 309 local meta = { __index = Button }
flickerstreak@28 310
flickerstreak@77 311 function Button:New( bar, idx, config )
flickerstreak@77 312 -- create new self
flickerstreak@90 313 self = setmetatable(
flickerstreak@90 314 {
flickerstreak@90 315 bar = bar,
flickerstreak@90 316 idx = idx,
flickerstreak@90 317 config = config,
flickerstreak@90 318 }, meta )
flickerstreak@28 319
flickerstreak@85 320 local name = config.name or ("ReAction_%s_%s_%d"):format(bar:GetName(),moduleID,idx)
flickerstreak@53 321 config.name = name
flickerstreak@77 322 self.name = name
flickerstreak@28 323 config.actionID = ActionIDList[config.actionID] -- gets a free one if none configured
flickerstreak@28 324
flickerstreak@53 325 -- have to recycle frames with the same name:
flickerstreak@53 326 -- otherwise you either get references to old textures because named CreateFrame()
flickerstreak@90 327 -- doesn't overwrite existing globals. Can't set them to nil in the global table,
flickerstreak@90 328 -- as it causes taint.
flickerstreak@90 329 local parent = bar:GetFrame()
flickerstreak@53 330 local f = frameRecycler[name]
flickerstreak@53 331 if f then
flickerstreak@77 332 f:SetParent(parent)
flickerstreak@53 333 else
flickerstreak@77 334 f = CreateFrame("CheckButton", name, parent, "PetActionButtonTemplate")
flickerstreak@93 335 -- ditch the old hotkey text because it's tied in ActionButton_Update() to the
flickerstreak@93 336 -- standard binding. We use override bindings.
flickerstreak@93 337 local hotkey = _G[name.."HotKey"]
flickerstreak@93 338 hotkey:SetParent(trash)
flickerstreak@93 339 hotkey = f:CreateFontString(nil, "ARTWORK", "NumberFontNormalSmallGray")
flickerstreak@93 340 hotkey:SetWidth(36)
flickerstreak@93 341 hotkey:SetHeight(18)
flickerstreak@93 342 hotkey:SetJustifyH("RIGHT")
flickerstreak@93 343 hotkey:SetJustifyV("TOP")
flickerstreak@93 344 hotkey:SetPoint("TOPLEFT",f,"TOPLEFT",-2,-2)
flickerstreak@93 345 f.hotkey = hotkey
flickerstreak@93 346 f:HookScript("OnDragStart", function() self:Update() end)
flickerstreak@93 347 f:HookScript("OnReceiveDrag", function() self:Update() end)
flickerstreak@53 348 end
flickerstreak@53 349 if config.actionID then
flickerstreak@53 350 f:SetID(config.actionID) -- PetActionButtonTemplate isn't a proper SecureActionButton
flickerstreak@53 351 end
flickerstreak@53 352 f:SetFrameStrata("MEDIUM")
flickerstreak@93 353 self.frame = f
flickerstreak@93 354 self.icon = _G[("%sIcon"):format(name)]
flickerstreak@93 355 self.acTex = _G[("%sAutoCastable"):format(name)]
flickerstreak@93 356 self.acModel = _G[("%sShine"):format(name)]
flickerstreak@53 357 self.cooldown = _G[("%sCooldown"):format(name)]
flickerstreak@93 358 self.hotkey = f.hotkey
flickerstreak@93 359 self.border = _G[("%sBorder"):format(name)]
flickerstreak@53 360
flickerstreak@53 361
flickerstreak@77 362 f:RegisterEvent("PLAYER_CONTROL_LOST");
flickerstreak@53 363 f:RegisterEvent("PLAYER_CONTROL_GAINED");
flickerstreak@53 364 f:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED");
flickerstreak@53 365 f:RegisterEvent("UNIT_PET");
flickerstreak@53 366 f:RegisterEvent("UNIT_FLAGS");
flickerstreak@53 367 f:RegisterEvent("UNIT_AURA");
flickerstreak@53 368 f:RegisterEvent("PET_BAR_UPDATE");
flickerstreak@53 369 f:RegisterEvent("PET_BAR_UPDATE_COOLDOWN");
flickerstreak@53 370
flickerstreak@53 371 f:SetScript("OnEvent",
flickerstreak@53 372 function(event,arg1)
flickerstreak@53 373 if event =="PET_BAR_UPDATE_COOLDOWN" then
flickerstreak@53 374 self:UpdateCooldown()
flickerstreak@53 375 elseif event == "UPDATE_BINDINGS" then
flickerstreak@53 376 self:UpdateHotkey()
flickerstreak@53 377 else
flickerstreak@53 378 self:Update()
flickerstreak@53 379 end
flickerstreak@53 380 end)
flickerstreak@28 381
flickerstreak@93 382 KBAttach(self)
flickerstreak@88 383
flickerstreak@77 384 self:Refresh()
flickerstreak@93 385 self:SetKeybindMode(ReAction:GetKeybindMode())
flickerstreak@93 386
flickerstreak@77 387 return self
flickerstreak@28 388 end
flickerstreak@28 389
flickerstreak@28 390 function Button:Destroy()
flickerstreak@28 391 local f = self.frame
flickerstreak@28 392 f:UnregisterAllEvents()
flickerstreak@28 393 f:Hide()
flickerstreak@28 394 f:SetParent(UIParent)
flickerstreak@28 395 f:ClearAllPoints()
flickerstreak@28 396 if self.name then
flickerstreak@53 397 frameRecycler[self.name] = f
flickerstreak@28 398 _G[self.name] = nil
flickerstreak@28 399 end
flickerstreak@53 400 if self.config.actionID then
flickerstreak@53 401 ActionIDList[self.config.actionID] = nil
flickerstreak@53 402 end
flickerstreak@28 403 self.frame = nil
flickerstreak@28 404 self.config = nil
flickerstreak@28 405 self.bar = nil
flickerstreak@28 406 end
flickerstreak@28 407
flickerstreak@77 408 function Button:Refresh()
flickerstreak@77 409 self.bar:PlaceButton(self, 30, 30)
flickerstreak@53 410 self:Update()
flickerstreak@53 411 self:UpdateHotkey()
flickerstreak@94 412 self.frame:Show()
flickerstreak@53 413 end
flickerstreak@53 414
flickerstreak@53 415 function Button:GetFrame()
flickerstreak@53 416 return self.frame
flickerstreak@53 417 end
flickerstreak@53 418
flickerstreak@53 419 function Button:GetName()
flickerstreak@53 420 return self.name
flickerstreak@53 421 end
flickerstreak@53 422
flickerstreak@88 423 function Button:GetConfig()
flickerstreak@88 424 return self.config
flickerstreak@88 425 end
flickerstreak@88 426
flickerstreak@53 427 function Button:GetActionID()
flickerstreak@53 428 return self.config.actionID
flickerstreak@53 429 end
flickerstreak@53 430
flickerstreak@53 431 function Button:Update()
flickerstreak@53 432 local id = self.frame:GetID()
flickerstreak@53 433 local name, subtext, texture, isToken, isActive, autoCastAllowed, autoCastEnabled = GetPetActionInfo(id);
flickerstreak@53 434 local f = self.frame
flickerstreak@53 435 --ReAction:Print(("id %d: '%s', '%s', '%s', '%s', '%s', '%s', '%s'"):format(tostring(id), tostring(name),tostring(subtext),tostring(texture),tostring(isToken),tostring(isActive),tostring(autoCastAllowed),tostring(autoCastEnabled)))
flickerstreak@53 436
flickerstreak@53 437 if isToken then
flickerstreak@53 438 self.icon:SetTexture(_G[texture]);
flickerstreak@53 439 f.tooltipName = _G[name];
flickerstreak@53 440 else
flickerstreak@53 441 self.icon:SetTexture(texture);
flickerstreak@53 442 f.tooltipName = name;
flickerstreak@53 443 end
flickerstreak@53 444
flickerstreak@53 445 f.isToken = isToken;
flickerstreak@53 446 f.tooltipSubtext = subtext;
flickerstreak@53 447 f:SetChecked( isActive and 1 or 0);
flickerstreak@53 448
flickerstreak@53 449 if autoCastAllowed then
flickerstreak@53 450 self.acTex:Show();
flickerstreak@53 451 else
flickerstreak@53 452 self.acTex:Hide();
flickerstreak@53 453 end
flickerstreak@53 454
flickerstreak@53 455 if autoCastEnabled then
flickerstreak@91 456 AutoCastShine_AutoCastStart(self.acModel)
flickerstreak@53 457 else
flickerstreak@91 458 AutoCastShine_AutoCastStop(self.acModel)
flickerstreak@53 459 end
flickerstreak@53 460
flickerstreak@53 461 if texture then
flickerstreak@91 462 if GetPetActionSlotUsable(id) then
flickerstreak@53 463 SetDesaturation(self.icon,nil)
flickerstreak@53 464 else
flickerstreak@53 465 SetDesaturation(self.icon,1)
flickerstreak@53 466 end
flickerstreak@53 467 self.icon:Show();
flickerstreak@53 468 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2");
flickerstreak@53 469 else
flickerstreak@53 470 self.icon:Hide();
flickerstreak@53 471 f:SetNormalTexture("Interface\\Buttons\\UI-Quickslot");
flickerstreak@53 472 end
flickerstreak@53 473
flickerstreak@53 474 self:UpdateCooldown()
flickerstreak@53 475 end
flickerstreak@53 476
flickerstreak@53 477 function Button:UpdateCooldown()
flickerstreak@53 478 local start, duration, enable = GetPetActionCooldown(self.frame:GetID());
flickerstreak@53 479 CooldownFrame_SetTimer(self.cooldown, start, duration, enable);
flickerstreak@53 480 end
flickerstreak@53 481
flickerstreak@53 482 function Button:UpdateHotkey()
flickerstreak@93 483 self:DisplayHotkey(GetHotkey(self.frame))
flickerstreak@53 484 end
flickerstreak@28 485
flickerstreak@77 486 function Button:ShowActionIDLabel(show)
flickerstreak@77 487 if show then
flickerstreak@77 488 -- store the action ID label in the frame due to frame recycling
flickerstreak@77 489 if not self.actionIDLabel and self:GetActionID() then
flickerstreak@77 490 local label = self.frame:CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
flickerstreak@77 491 label:SetAllPoints()
flickerstreak@77 492 label:SetJustifyH("CENTER")
flickerstreak@77 493 label:SetShadowColor(0,0,0,1)
flickerstreak@77 494 label:SetShadowOffset(2,-2)
flickerstreak@77 495 label:SetText(tostring(self:GetActionID()))
flickerstreak@77 496 self.actionIDLabel = label
flickerstreak@28 497 end
flickerstreak@77 498 self.actionIDLabel:Show()
flickerstreak@77 499 elseif self.actionIDLabel then
flickerstreak@77 500 self.actionIDLabel:Hide()
flickerstreak@28 501 end
flickerstreak@77 502 end
flickerstreak@93 503
flickerstreak@93 504
flickerstreak@93 505 function Button:SetKeybindMode(mode)
flickerstreak@93 506 if mode then
flickerstreak@93 507 self.border:SetVertexColor(KB:GetColorKeyBoundMode())
flickerstreak@93 508 self.border:Show()
flickerstreak@93 509 else
flickerstreak@93 510 self.border:Hide()
flickerstreak@93 511 end
flickerstreak@93 512 end
flickerstreak@93 513
flickerstreak@93 514 function Button:DisplayHotkey( key )
flickerstreak@93 515 self.hotkey:SetText(key or "")
flickerstreak@93 516 end