Mercurial > wow > reaction
diff 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 |
line wrap: on
line diff
--- a/MultiCastButton.lua Wed May 11 09:53:48 2011 -0700 +++ b/MultiCastButton.lua Sat Jun 11 10:57:00 2011 -0700 @@ -1,5 +1,5 @@ -local addonName, addonTable = ... -local ReAction = addonTable.ReAction +local _, ns = ... +local ReAction = ns.ReAction local L = ReAction.L local _G = _G local CreateFrame = CreateFrame @@ -21,6 +21,7 @@ local GetActionTexture = GetActionTexture local GetMultiCastTotemSpells = GetMultiCastTotemSpells +--@do-not-package@ --[[ Blizzard Constants: - NUM_MULTI_CAST_BUTTONS_PER_PAGE = 4 @@ -90,7 +91,7 @@ ]]-- - +--@end-do-not-package@ -- -- Secure snippets @@ -324,26 +325,19 @@ ReAction:RegisterBarType(MultiCast) function MultiCast:New( btnConfig, bar, idx ) - local maxIndex = bar.nTotemSlots or 0 - if bar.summonSlot then - maxIndex = maxIndex + 1 - end - if bar.recallSlot then - maxIndex = maxIndex + 1 + if idx < 1 or idx > NUM_MULTI_CAST_BUTTONS_PER_PAGE + 2 then + ReAction:UserError(L["All %s buttons are in use for this bar, cannot create any more buttons"]:format(self.barType)) + error(nil) end - if not bar.hasMulticast or idx > maxIndex then - return false + self = Super.New(self, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) + + if not bar.hasMulticast or idx > bar.maxIndex then + -- Not enough multicast capability to use this button + self:Refresh() + return self end - if idx < 1 then - error("invalid index") - end - - local name = format("ReAction_%s_Totem_%d",bar:GetName(),idx) - - self = Super.New(self, name, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) - local barFrame = bar:GetFrame() local f = self:GetFrame() @@ -450,6 +444,13 @@ function MultiCast:Refresh() Super.Refresh(self) self:UpdateAction() + + local bar = self.bar + if bar.hasMulticast == true and self.idx <= bar.maxIndex or ReAction:GetConfigMode() then + self:GetFrame():Show() + else + self:GetFrame():Hide() + end end function MultiCast:ShowGrid( show ) @@ -612,8 +613,6 @@ end function MultiCast:SetupBar( bar ) - Super.SetupBar(self,bar) - local slot = 0 local nTotemSlots = 0 local summonSlot = nil @@ -642,16 +641,24 @@ end end - if nTotemSlots == 0 then - bar.hasMulticast = false -- no multicast capability - return + local maxIndex = nTotemSlots + if summonSlot then + maxIndex = maxIndex + 1 + end + if recallSlot then + maxIndex = maxIndex + 1 end - bar.hasMulticast = true + bar.hasMulticast = nTotemSlots > 0 bar.summonSlot = summonSlot bar.recallSlot = recallSlot bar.nTotemSlots = nTotemSlots + bar.maxIndex = maxIndex + if bar.hasMulticast == false then + Super.SetupBar(self,bar) + return -- no multicast capability + end local f = bar:GetFrame() @@ -772,7 +779,8 @@ f.events_registered = true end + f:Execute(_bar_init) - f:Execute(_bar_init) + Super.SetupBar(self,bar) -- create buttons after this is done end