comparison MultiCastButton.lua @ 286:77609bfa804e stable

Merge 1.1 beta 8 to stable
author Flick
date Sat, 11 Jun 2011 10:57:00 -0700
parents 7a9e82c0df15
children 276165a0e860
comparison
equal deleted inserted replaced
272:71d1a5e47e72 286:77609bfa804e
1 local addonName, addonTable = ... 1 local _, ns = ...
2 local ReAction = addonTable.ReAction 2 local ReAction = ns.ReAction
3 local L = ReAction.L 3 local L = ReAction.L
4 local _G = _G 4 local _G = _G
5 local CreateFrame = CreateFrame 5 local CreateFrame = CreateFrame
6 local format = string.format 6 local format = string.format
7 local unpack = unpack 7 local unpack = unpack
19 local GetActionCooldown = GetActionCooldown 19 local GetActionCooldown = GetActionCooldown
20 local GetSpellTexture = GetSpellTexture 20 local GetSpellTexture = GetSpellTexture
21 local GetActionTexture = GetActionTexture 21 local GetActionTexture = GetActionTexture
22 local GetMultiCastTotemSpells = GetMultiCastTotemSpells 22 local GetMultiCastTotemSpells = GetMultiCastTotemSpells
23 23
24 --@do-not-package@
24 --[[ 25 --[[
25 Blizzard Constants: 26 Blizzard Constants:
26 - NUM_MULTI_CAST_BUTTONS_PER_PAGE = 4 27 - NUM_MULTI_CAST_BUTTONS_PER_PAGE = 4
27 - NUM_MULTI_CAST_PAGES = 3 28 - NUM_MULTI_CAST_PAGES = 3
28 - SHAMAN_TOTEM_PRIORITIES = { } -- sets the order of the totems 29 - SHAMAN_TOTEM_PRIORITIES = { } -- sets the order of the totems
88 - The default UI has Call of the Elements always selected on UI load. This module remembers the last 89 - The default UI has Call of the Elements always selected on UI load. This module remembers the last
89 selected one and restores it. 90 selected one and restores it.
90 91
91 92
92 ]]-- 93 ]]--
93 94 --@end-do-not-package@
94 95
95 -- 96 --
96 -- Secure snippets 97 -- Secure snippets
97 -- 98 --
98 99
322 323
323 ReAction.Button.MultiCast = MultiCast 324 ReAction.Button.MultiCast = MultiCast
324 ReAction:RegisterBarType(MultiCast) 325 ReAction:RegisterBarType(MultiCast)
325 326
326 function MultiCast:New( btnConfig, bar, idx ) 327 function MultiCast:New( btnConfig, bar, idx )
327 local maxIndex = bar.nTotemSlots or 0 328 if idx < 1 or idx > NUM_MULTI_CAST_BUTTONS_PER_PAGE + 2 then
328 if bar.summonSlot then 329 ReAction:UserError(L["All %s buttons are in use for this bar, cannot create any more buttons"]:format(self.barType))
329 maxIndex = maxIndex + 1 330 error(nil)
330 end 331 end
331 if bar.recallSlot then 332
332 maxIndex = maxIndex + 1 333 self = Super.New(self, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
333 end 334
334 335 if not bar.hasMulticast or idx > bar.maxIndex then
335 if not bar.hasMulticast or idx > maxIndex then 336 -- Not enough multicast capability to use this button
336 return false 337 self:Refresh()
337 end 338 return self
338 339 end
339 if idx < 1 then
340 error("invalid index")
341 end
342
343 local name = format("ReAction_%s_Totem_%d",bar:GetName(),idx)
344
345 self = Super.New(self, name, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" )
346 340
347 local barFrame = bar:GetFrame() 341 local barFrame = bar:GetFrame()
348 local f = self:GetFrame() 342 local f = self:GetFrame()
349 343
350 -- attributes 344 -- attributes
448 end 442 end
449 443
450 function MultiCast:Refresh() 444 function MultiCast:Refresh()
451 Super.Refresh(self) 445 Super.Refresh(self)
452 self:UpdateAction() 446 self:UpdateAction()
447
448 local bar = self.bar
449 if bar.hasMulticast == true and self.idx <= bar.maxIndex or ReAction:GetConfigMode() then
450 self:GetFrame():Show()
451 else
452 self:GetFrame():Hide()
453 end
453 end 454 end
454 455
455 function MultiCast:ShowGrid( show ) 456 function MultiCast:ShowGrid( show )
456 end 457 end
457 458
610 frame.icon:SetTexCoord(0,1,0,1) 611 frame.icon:SetTexCoord(0,1,0,1)
611 end 612 end
612 end 613 end
613 614
614 function MultiCast:SetupBar( bar ) 615 function MultiCast:SetupBar( bar )
615 Super.SetupBar(self,bar)
616
617 local slot = 0 616 local slot = 0
618 local nTotemSlots = 0 617 local nTotemSlots = 0
619 local summonSlot = nil 618 local summonSlot = nil
620 local recallSlot = nil 619 local recallSlot = nil
621 620
640 if spell and IsSpellKnown(spell) then 639 if spell and IsSpellKnown(spell) then
641 recallSlot = slot 640 recallSlot = slot
642 end 641 end
643 end 642 end
644 643
645 if nTotemSlots == 0 then 644 local maxIndex = nTotemSlots
646 bar.hasMulticast = false -- no multicast capability 645 if summonSlot then
647 return 646 maxIndex = maxIndex + 1
648 end 647 end
649 648 if recallSlot then
650 bar.hasMulticast = true 649 maxIndex = maxIndex + 1
650 end
651
652 bar.hasMulticast = nTotemSlots > 0
651 bar.summonSlot = summonSlot 653 bar.summonSlot = summonSlot
652 bar.recallSlot = recallSlot 654 bar.recallSlot = recallSlot
653 bar.nTotemSlots = nTotemSlots 655 bar.nTotemSlots = nTotemSlots
654 656 bar.maxIndex = maxIndex
657
658 if bar.hasMulticast == false then
659 Super.SetupBar(self,bar)
660 return -- no multicast capability
661 end
655 662
656 local f = bar:GetFrame() 663 local f = bar:GetFrame()
657 664
658 -- init bar secure environment 665 -- init bar secure environment
659 f:SetAttribute("lastSummon", bar:GetConfig().lastSummon) 666 f:SetAttribute("lastSummon", bar:GetConfig().lastSummon)
770 end 777 end
771 end) 778 end)
772 f.events_registered = true 779 f.events_registered = true
773 end 780 end
774 781
775
776 f:Execute(_bar_init) 782 f:Execute(_bar_init)
777 end 783
778 784 Super.SetupBar(self,bar) -- create buttons after this is done
785 end
786