Permalink
Browse files

Added fancy new code to handle override states

  • Loading branch information...
1 parent 916ef1c commit b5878784970f4cbc0f71e06de428eb0e5e33059d @Tuller Tuller committed Sep 3, 2012
Showing with 72 additions and 48 deletions.
  1. +1 −0 Dominos.lua
  2. +1 −1 Dominos.toc
  3. +43 −43 actionBar.lua
  4. +11 −1 actionButton.lua
  5. +5 −1 barStates.lua
  6. +3 −0 frame.lua
  7. +8 −2 menuBar.lua
View
@@ -265,6 +265,7 @@ end
--[[ Blizzard Stuff Hiding ]]--
+--shamelessly pulled from Bartender4
function Dominos:HideBlizzard()
local noop = _G['Multibar_EmptyFunc'] or function() end
View
@@ -2,7 +2,7 @@
## Title: Dominos
## Notes: A main actionbar replacement
## Author: Tuller
-## Version: 5.0.10
+## Version: 5.0.11
## SavedVariables: DominosDB, DominosVersion
## OptionalDeps: Ace3, LibKeyBound-1.0, Masque, FlyPaper
embeds.xml
View
@@ -183,18 +183,17 @@ function ActionBar:UpdateStateDriver()
condition = state.value
end
- if condition then
- --possess bar: special case
- if stateId == 'possess' then
- if self:IsPossessBar() then
- header = header .. condition .. 'possess;'
- end
- elseif self:GetOffset(stateId) then
+ if state.type == 'override' then
+ if self:IsOverrideBar() then
+ header = header .. condition .. stateId .. ';'
+ end
+ else
+ if self:GetOffset(stateId) then
header = header .. condition .. 'S' .. i .. ';'
end
end
end
-
+
if header ~= '' then
RegisterStateDriver(self.header, 'page', header .. 0)
end
@@ -212,6 +211,8 @@ function ActionBar:UpdateAction(i)
local b = self.buttons[i]
local maxSize = self:MaxLength()
+ b:SetAttribute('button--index', i)
+
for i, state in Dominos.BarStates:getAll() do
local offset = self:GetOffset(state.id)
local actionId = nil
@@ -220,48 +221,47 @@ function ActionBar:UpdateAction(i)
end
b:SetAttribute('action--S' .. i, actionId)
end
-
- if self:IsPossessBar() and i <= NUM_POSSESS_BAR_BUTTONS then
- b:SetAttribute('action--possess', (12 * (GetVehicleBarIndex() - 1)) + i)
- else
- b:SetAttribute('action--possess', nil)
- end
end
--updates the actionID of all buttons for all states
function ActionBar:UpdateActions()
- local maxSize = self:MaxLength()
-
- for i, state in Dominos.BarStates:getAll() do
- local offset = self:GetOffset(state.id)
- if offset then
- for _, b in pairs(self.buttons) do
- local actionId = ToValidID(b:GetAttribute('action--base') + offset * maxSize)
- b:SetAttribute('action--S' .. i, actionId)
- end
- else
- for _, b in pairs(self.buttons) do
- b:SetAttribute('action--S' .. i, nil)
- end
- end
- end
-
- if self:IsPossessBar() then
- for i = 1, min(#self.buttons, NUM_POSSESS_BAR_BUTTONS) do
- self.buttons[i]:SetAttribute('action--possess', (12 * (GetVehicleBarIndex() - 1)) + i)
- end
- for i = NUM_POSSESS_BAR_BUTTONS + 1, #self.buttons do
- self.buttons[i]:SetAttribute('action--possess', nil)
- end
- else
- for _,b in pairs(self.buttons) do
- b:SetAttribute('action--possess', nil)
- end
+ for i = 1, #self.buttons do
+ self:UpdateAction(i)
end
end
function ActionBar:LoadStateController()
- self.header:SetAttribute('_onstate-page', [[ control:ChildUpdate('action', newstate) ]])
+ self.header:SetFrameRef('MainActionBarController', _G['MainMenuBarArtFrame'])
+ self.header:SetFrameRef('OverrideActionBarController', _G['OverrideActionBar'])
+
+ self.header:SetAttribute('_onstate-overrideui', [[
+ self:RunAttribute('updateShown')
+ self:RunAttribute('updateState')
+ ]])
+
+ self.header:SetAttribute('_onstate-page', [[
+ self:RunAttribute('updateState')
+ ]])
+
+ self.header:SetAttribute('updateState', [[
+ local state = self:GetAttribute('state-page')
+
+ --handle override states
+ if state == 'possess' or state == 'override' or state == 'vehicle' or state == 'sstemp' then
+ local pageController
+ if self:GetAttribute('state-overrideui') then
+ pageController = self:GetFrameRef('OverrideActionBarController')
+ else
+ pageController = self:GetFrameRef('MainActionBarController')
+ end
+
+ self:SetAttribute('override-page', pageController:GetAttribute('actionpage'))
+ control:ChildUpdate('action', 'override')
+ return
+ end
+
+ control:ChildUpdate('action', state)
+ ]])
end
function ActionBar:RefreshActions()
@@ -274,7 +274,7 @@ function ActionBar:RefreshActions()
end
--returns true if the possess bar, false otherwise
-function ActionBar:IsPossessBar()
+function ActionBar:IsOverrideBar()
return self == Dominos:GetOverrideBar()
end
View
@@ -19,7 +19,17 @@ function ActionButton:New(id)
b:SetAttribute('showgrid', 0)
b:SetAttribute('action--base', id)
b:SetAttribute('_childupdate-action', [[
- local id = message and self:GetAttribute('action--' .. message) or self:GetAttribute('action--base')
+ local state = message
+ if state == 'override' then
+ local buttonIndex = self:GetAttribute('button--index')
+ local overridePage = self:GetParent():GetAttribute('override-page')
+
+ self:SetAttribute('action', buttonIndex + (overridePage - 1) * 12)
+ self:CallMethod('UpdateState')
+ return
+ end
+
+ local id = state and self:GetAttribute('action--' .. state) or self:GetAttribute('action--base')
if id ~= self:GetAttribute('action') then
self:SetAttribute('action', id)
self:CallMethod('UpdateState')
View
@@ -77,7 +77,11 @@ addState('modifier', 'ctrl', '[mod:ctrl]', CTRL_KEY)
addState('modifier', 'shift', '[mod:shift]', SHIFT_KEY)
--possession
-addState('possess', 'possess', '[possessbar]')
+addState('override', 'petbattle', '[petbattle]')
+addState('override', 'possess', '[possessbar]')
+addState('override', 'override', '[overridebar]')
+addState('override', 'vehicle', '[vehicleui]')
+addState('override', 'sstemp', '[bonusbar:5]')
--paging
for i = 2, 6 do
View
@@ -88,7 +88,10 @@ function Frame:Create(id, alwaysVisible)
f:SetMovable(true)
f.id = id
+
f.header = CreateFrame('Frame', nil, f, 'SecureHandlerStateTemplate')
+
+ f.header:SetAttribute('id', id)
if alwaysVisible then
f.header:SetAttribute('state-showinpetbattleui', true)
View
@@ -58,9 +58,15 @@ function MenuBar:Create(frameId)
after a layout value is altered, set a dirty bit indicating that we need to adjust the bar's layout
--]]
- header:SetAttribute('_onstate-petbattleui', [[ self:RunAttribute('updateLayout') ]])
+ header:SetAttribute('_onstate-petbattleui', [[
+ self:RunAttribute('updateShown')
+ self:RunAttribute('updateLayout')
+ ]])
- header:SetAttribute('_onstate-overrideui', [[ self:RunAttribute('updateLayout') ]])
+ header:SetAttribute('_onstate-overrideui', [[
+ self:RunAttribute('updateShown')
+ self:RunAttribute('updateLayout')
+ ]])
header:SetAttribute('_onstate-forcelayout', [[ self:RunAttribute('updateLayout') ]])

0 comments on commit b587878

Please sign in to comment.