Mercurial > wow > reaction
changeset 163:ab5c37989986
- totem bar now stores which page was selected across sessions
- totem bar shouldn't be messed up if resized around on non-shaman toons now
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Sat, 22 Aug 2009 00:12:44 +0000 |
parents | fc08372f0c7a |
children | 363dd8130205 |
files | classes/MultiCastButton.lua modules/Totem.lua |
diffstat | 2 files changed, 26 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/classes/MultiCastButton.lua Fri Aug 21 23:50:17 2009 +0000 +++ b/classes/MultiCastButton.lua Sat Aug 22 00:12:44 2009 +0000 @@ -104,7 +104,7 @@ flyoutChildren = newtable() nMultiCastSlots = self:GetAttribute("nMultiCastSlots") baseActionID = self:GetAttribute("baseActionID") - currentMultiCastPage = currentMultiCastPage or 1 + currentMultiCastPage = currentMultiCastPage or self:GetAttribute("lastSummon") or 1 multiCastSpellList = newtable() for i = 1, nMultiCastSlots do tinsert(multiCastSpellList, newtable()) @@ -114,6 +114,7 @@ local _onstate_multispellpage = -- function(self, stateid, newstate) [[ currentMultiCastPage = tonumber(newstate) + control:CallMethod("UpdateLastSummon",currentMultiCastPage) control:ChildUpdate() ]] @@ -261,6 +262,10 @@ error("Multicast button index out of range") end + if idx > bar.nMultiCastSlots then + return false + end + local name = format("ReAction_%s_Action_%d",bar:GetName(),idx) self = Super.New(self, name, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) @@ -269,22 +274,20 @@ local f = self:GetFrame() -- attributes + local page = (idx == NUM_MULTI_CAST_BUTTONS_PER_PAGE + 2) and 1 or (bar:GetConfig().lastSummon or 1) if idx == 1 or idx == NUM_MULTI_CAST_BUTTONS_PER_PAGE + 2 then f:SetAttribute("type","spell") local spells = idx == 1 and TOTEM_MULTI_CAST_SUMMON_SPELLS or TOTEM_MULTI_CAST_RECALL_SPELLS + f:SetAttribute("spell",spells[page]) for i, spell in ipairs(spells) do if spell and IsSpellKnown(spell) then f:SetAttribute("spell-page"..i, spell) - if i == 1 then - -- TODO: store/restore last used summon - f:SetAttribute("spell",spell) - end end end else local baseAction = barFrame:GetAttribute("baseActionID") + TOTEM_PRIORITIES[idx-1] f:SetAttribute("type","action") - f:SetAttribute("action", baseAction) + f:SetAttribute("action", baseAction + (page - 1) * NUM_MULTI_CAST_BUTTONS_PER_PAGE) for i = 1, NUM_MULTI_CAST_PAGES do f:SetAttribute("action-page"..i, baseAction + (i-1) * NUM_MULTI_CAST_BUTTONS_PER_PAGE) end @@ -537,7 +540,8 @@ end if #summon == 0 and #recall == 0 then - return 0 -- no multicast capability + bar.nMultiCastSlots = 0 -- no multicast capability + return end local slots = { } @@ -555,11 +559,16 @@ local barFrame = bar:GetFrame() -- init bar secure environment + barFrame:SetAttribute("lastSummon",bar:GetConfig().lastSummon) barFrame:SetAttribute("nMultiCastSlots",#slots) barFrame:SetAttribute("baseActionID", (NUM_ACTIONBAR_PAGES + GetMultiCastBarOffset() - 1)*NUM_ACTIONBAR_BUTTONS) barFrame:SetAttribute("_onstate-multispellpage", _onstate_multispellpage) barFrame:Execute(_bar_init) + function barFrame:UpdateLastSummon(value) + bar:GetConfig().lastSummon = value + end + for i, p in ipairs(TOTEM_PRIORITIES) do barFrame:SetAttribute("TOTEM_PRIORITY_"..i,p) end @@ -629,6 +638,6 @@ end end - return #slots + bar.nMultiCastSlots = #slots end
--- a/modules/Totem.lua Fri Aug 21 23:50:17 2009 +0000 +++ b/modules/Totem.lua Sat Aug 22 00:12:44 2009 +0000 @@ -83,17 +83,19 @@ local btnCfg = profile.buttons[name] local r, c = bar:GetButtonGrid() - local n = r*c - n = min(n,Button.SetupBarHeader(bar)) + local n = min(r*c,6) + Button.SetupBarHeader(bar) for i = 1, n do if btnCfg[i] == nil then btnCfg[i] = {} end if btns[i] == nil then local success, r = pcall(Button.New,Button,i,btnCfg,bar) - if success and r then + if success then btns[i] = r - bar:AddButton(i,r) + if r then + bar:AddButton(i,r) + end else geterrorhandler()(r) n = i - 1 @@ -101,7 +103,9 @@ break end end - btns[i]:Refresh() + if btns[i] then + btns[i]:Refresh() + end end for i = n+1, #btns do if btns[i] then