From fe2cc6f24b2497eecf8020c0106b0c0e62b3d3a9 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Tue, 24 Feb 2009 17:07:28 +0100 Subject: [PATCH] Further cleanup and seperation --- ActionBar.lua | 11 +---------- ActionButton.lua | 4 ---- Options/Options.lua | 2 +- StateBar.lua | 21 ++++++++++----------- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/ActionBar.lua b/ActionBar.lua index 66c560f..cf9776d 100644 --- a/ActionBar.lua +++ b/ActionBar.lua @@ -22,8 +22,7 @@ function ActionBar:ApplyConfig(config) if not self.config.position.x then initialPosition(self) end self:UpdateButtons() - self:UpdateSelfCast(true) - self:UpdateStates() + self:UpdateSelfCast() -- also calls UpdateStates end -- Update the number of buttons in our bar, creating new ones if necessary @@ -68,9 +67,6 @@ function ActionBar:UpdateButtons(numbuttons) -- need to re-set clickthrough after creating new buttons self:SetClickThrough() - - -- Also need to re-apply state fun to the new buttons, just to be sure. - self:UpdateStates() end function ActionBar:SkinChanged(...) @@ -117,8 +113,3 @@ function ActionBar:SetGrid(state) end self:ForAll("UpdateGrid") end - -function ActionBar:UpdateSelfCast() - self:ForAll("UpdateSelfCast") - self:UpdateStates() -end diff --git a/ActionButton.lua b/ActionButton.lua index da4abf3..4eba511 100644 --- a/ActionButton.lua +++ b/ActionButton.lua @@ -295,15 +295,11 @@ function Button:RefreshStateAction(state) end end end - self:UpdateRightClickSelfCast() end function Button:UpdateSelfCast() self:SetAttribute("checkselfcast", Bartender4.db.profile.selfcastmodifier and true or nil) self:SetAttribute("checkfocuscast", Bartender4.db.profile.focuscastmodifier and true or nil) -end - -function Button:UpdateRightClickSelfCast() self:SetAttribute("unit2", Bartender4.db.profile.selfcastrightclick and "player" or nil) end diff --git a/Options/Options.lua b/Options/Options.lua index 5a6634f..a4d655a 100644 --- a/Options/Options.lua +++ b/Options/Options.lua @@ -142,7 +142,7 @@ local function getOptions() get = getFunc, set = function(info, value) Bartender4.db.profile.selfcastrightclick = value - Bartender4.Bar:ForAll("ForAll", "UpdateRightClickSelfCast") + Bartender4.Bar:ForAll("UpdateSelfCast") end, }, rightclickselfcast_nl = { diff --git a/StateBar.lua b/StateBar.lua index 45e9715..7655806 100644 --- a/StateBar.lua +++ b/StateBar.lua @@ -33,6 +33,7 @@ end function StateBar:ApplyConfig(config) ButtonBar.ApplyConfig(self, config) + -- We cannot call UpdateStates or UpdateSelfCast now, because the buttons are not yet created *sad* end -------------------------------------------------------------- @@ -44,13 +45,6 @@ local fmt = string.format local modifiers = { "ctrl", "alt", "shift" } -local function tfind(haystack, needle, searchfunc) - for i,v in pairs(haystack) do - if (searchfunc and searchfunc(v, needle) or (v == needle)) then return i end - end - return nil -end - local _, playerclass = UnitClass("player") -- specifiy the available stances for each class @@ -90,8 +84,6 @@ local DefaultStanceMap = setmetatable({}, { __index = function(t,k) end}) Bartender4.StanceMap = DefaultStanceMap -local searchFunc = function(h, n) return (h.match == n or h.match2 == n or h.id == n) end - local stancemap function StateBar:UpdateStates(returnOnly) if not self.buttons then return end @@ -110,6 +102,7 @@ function StateBar:UpdateStates(returnOnly) local stateconfig = self.config.states -- arguments will be parsed from left to right, so we have a priority here + -- possessing will always be the most important change, if enabled if self:GetStateOption("possess") then table_insert(statedriver, "[bonusbar:5]11") end @@ -122,8 +115,8 @@ function StateBar:UpdateStates(returnOnly) end end - -- second priority the manual changes using the StateBar options - if self:GetStateOption("StateBar") then + -- second priority the manual changes using the ActionBar options + if self:GetStateOption("actionbar") then for i=2,6 do table_insert(statedriver, fmt("[bar:%s]%s", i, i)) end @@ -135,6 +128,7 @@ function StateBar:UpdateStates(returnOnly) for i,v in pairs(stancemap) do local state = self:GetStanceState(v) if state and state ~= 0 and v.index then + -- hack for druid prowl, since its no real "stance", but we want to handle it anyway if playerclass == "DRUID" and v.id == "cat" then local prowl = self:GetStanceState("prowl") if prowl and prowl ~= 0 then @@ -246,3 +240,8 @@ function StateBar:SetCopyCustomConditionals() self.config.states.custom = self:UpdateStates(true) self:UpdateStates() end + +function StateBar:UpdateSelfCast() + self:ForAll("UpdateSelfCast") + self:UpdateStates() +end