changeset 282:7a9e82c0df15

Show empty totem buttons in config mode when character doesn't have totems
author Flick
date Wed, 11 May 2011 17:21:04 -0700
parents 2098dba4baf5
children f2ed8a8e2320
files Button.lua MultiCastButton.lua locale/enUS.lua
diffstat 3 files changed, 33 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/Button.lua	Wed May 11 16:20:48 2011 -0700
+++ b/Button.lua	Wed May 11 17:21:04 2011 -0700
@@ -237,7 +237,7 @@
       end
       if id == nil then
         if unique then
-          ReAction:UserError(("All action IDs for bars of type '%s' are in use, cannot create any more buttons"):format(self.barType))
+          ReAction:UserError(L["All action IDs for bars of type '%s' are in use, cannot create any more buttons"]:format(self.barType))
           error(nil) -- no error message, user has already been notified, so don't put in Lua error handler
         end
         pool.nWraps = nWraps + 1
--- a/MultiCastButton.lua	Wed May 11 16:20:48 2011 -0700
+++ b/MultiCastButton.lua	Wed May 11 17:21:04 2011 -0700
@@ -325,24 +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
-  end
-
-  if not bar.hasMulticast or idx > maxIndex then
-    return false
-  end
-
-  if idx < 1 then
-    error("invalid index")
+  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
 
   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
+
   local barFrame = bar:GetFrame()
   local f = self:GetFrame()
 
@@ -449,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 )
@@ -611,8 +613,6 @@
 end
 
 function MultiCast:SetupBar( bar )
-  Super.SetupBar(self,bar)
-
   local slot = 0
   local nTotemSlots = 0
   local summonSlot = nil
@@ -641,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()
 
@@ -771,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
 
--- a/locale/enUS.lua	Wed May 11 16:20:48 2011 -0700
+++ b/locale/enUS.lua	Wed May 11 17:21:04 2011 -0700
@@ -215,6 +215,7 @@
 
 -- Button.lua --
 "Button Bar",
+"All action IDs for bars of type '%s' are in use, cannot create any more buttons",
 
 -- Overlay.lua
 "Hold Shift",
@@ -234,6 +235,7 @@
 
 -- MultiCastButton.lua
 "Totem Bar",
+"All %s buttons are in use for this bar, cannot create any more buttons",
 
 -- PetActionButton.lua
 "Pet Action Bar",