diff --git a/ActionBarPrototype.lua b/ActionBarPrototype.lua index 95886a0..2e46bbd 100644 --- a/ActionBarPrototype.lua +++ b/ActionBarPrototype.lua @@ -21,6 +21,7 @@ do buttons = "Buttons", rows = "Rows", enabled = "Enabled", + grid = "Grid", } -- retrieves a valid bar object from the modules actionbars table @@ -79,6 +80,7 @@ function module:GetOptionsTable() -- order = inherited (5) args = { padding = { + order = 30, type = "range", name = "Padding", desc = "Configure the padding of the buttons.", @@ -86,6 +88,14 @@ function module:GetOptionsTable() set = optSetter, get = optGetter, }, + grid = { + order = 5, + type = "toggle", + name = "Button Grid", + desc = "Toggle the button grid.", + set = optSetter, + get = optGetter, + }, }, }, layout = { @@ -184,6 +194,7 @@ function ActionBar:UpdateButtons(numbuttons) self.buttons = buttons self:UpdateButtonLayout() + self:SetGrid() end -- align the buttons and correct the size of the bar overlay frame @@ -223,7 +234,7 @@ end -- set the padding and refresh layout function ActionBar:SetPadding(pad) - if pad then + if pad ~= nil then self.config.padding = pad end self:UpdateButtonLayout() @@ -244,7 +255,7 @@ end -- set the number of rows and refresh layout function ActionBar:SetRows(rows) - if rows then + if rows ~= nil then self.config.rows = rows end self:UpdateButtonLayout() @@ -260,6 +271,21 @@ function ActionBar:SetEnabled(state) end end +function ActionBar:GetGrid() + return self.config.showgrid +end + +function ActionBar:SetGrid(state) + if state ~= nil then + self.config.showgrid = state + end + if self.config.showgrid then + self:ForAll("ShowGrid", true) + else + self:ForAll("HideGrid", true) + end +end + --[[=================================================================================== Utility function ===================================================================================]]-- diff --git a/ActionBars.lua b/ActionBars.lua index d87ffbb..78e42b1 100644 --- a/ActionBars.lua +++ b/ActionBars.lua @@ -17,6 +17,7 @@ local abdefaults = Bartender4:Merge({ padding = 2, rows = 1, hidemacrotext = false, + showgrid = false, }, [1] = { stances = stancedefaults, @@ -117,67 +118,59 @@ function BT4ActionBars:SetupOptions() name = "Action Bars", get = getFunc, args = { - general = { + range = { order = 1, + name = "Out of Range Indicator", + desc = "Configure how the Out of Range Indicator should display on the buttons.", + type = "select", + style = "dropdown", + get = function() + return BT4ActionBars.db.profile.outofrange + end, + set = function(info, value) + BT4ActionBars.db.profile.outofrange = value + BT4ActionBars:ForAllButtons("UpdateUsable") + end, + values = { none = "No Display", button = "Full Button Mode", hotkey = "Hotkey Mode" }, + }, + colors = { + order = 3, type = "group", guiInline = true, - name = "General Options", + name = "Colors", + get = function(info) + local color = BT4ActionBars.db.profile.colors[info[#info]] + return color.r, color.g, color.b + end, + set = function(info, r, g, b) + local color = BT4ActionBars.db.profile.colors[info[#info]] + color.r, color.g, color.b = r, g, b + BT4ActionBars:ForAllButtons("UpdateUsable") + end, args = { range = { order = 1, + type = "color", name = "Out of Range Indicator", - desc = "Configure how the Out of Range Indicator should display on the buttons.", - type = "select", - style = "dropdown", - get = function() - return BT4ActionBars.db.profile.outofrange - end, - set = function(info, value) - BT4ActionBars.db.profile.outofrange = value - BT4ActionBars:ForAllButtons("UpdateUsable") - end, - values = { none = "No Display", button = "Full Button Mode", hotkey = "Hotkey Mode" }, + desc = "Specify the Color of the Out of Range Indicator", }, - colors = { + mana = { order = 2, - type = "group", - guiInline = true, - name = "Colors", - get = function(info) - local color = BT4ActionBars.db.profile.colors[info[#info]] - return color.r, color.g, color.b - end, - set = function(info, r, g, b) - local color = BT4ActionBars.db.profile.colors[info[#info]] - color.r, color.g, color.b = r, g, b - BT4ActionBars:ForAllButtons("UpdateUsable") - end, - args = { - range = { - order = 1, - type = "color", - name = "Out of Range Indicator", - desc = "Specify the Color of the Out of Range Indicator", - }, - mana = { - order = 2, - type = "color", - name = "Out of Mana Indicator", - desc = "Specify the Color of the Out of Mana Indicator", - }, - }, - }, - tooltip = { - order = 3, - name = "Button Tooltip", - type = "select", - desc = "Configure the Button Tooltip.", - values = { ["disabled"] = "Disabled", ["nocombat"] = "Disabled in Combat", ["enabled"] = "Enabled" }, - get = function() return Bartender4.db.profile.tooltip end, - set = function(info, value) Bartender4.db.profile.tooltip = value end, + type = "color", + name = "Out of Mana Indicator", + desc = "Specify the Color of the Out of Mana Indicator", }, }, }, + tooltip = { + order = 2, + name = "Button Tooltip", + type = "select", + desc = "Configure the Button Tooltip.", + values = { ["disabled"] = "Disabled", ["nocombat"] = "Disabled in Combat", ["enabled"] = "Enabled" }, + get = function() return Bartender4.db.profile.tooltip end, + set = function(info, value) Bartender4.db.profile.tooltip = value end, + }, }, } Bartender4:RegisterModuleOptions("actionbars", self.options) diff --git a/Bar.lua b/Bar.lua index ac7ff06..c9a3a0a 100644 --- a/Bar.lua +++ b/Bar.lua @@ -139,6 +139,7 @@ function Bar:GetOptionTable() order = 5, args = { alpha = { + order = 10, name = "Alpha", desc = "Configure the alpha of the bar.", type = "range", @@ -147,6 +148,7 @@ function Bar:GetOptionTable() set = optSetter, }, scale = { + order = 20, name = "Scale", desc = "Configure the scale of the bar.", type = "range", diff --git a/Button.lua b/Button.lua index 13896f8..006f971 100644 --- a/Button.lua +++ b/Button.lua @@ -7,7 +7,7 @@ local Button = CreateFrame("CheckButton") local Button_MT = {__index = Button} -local onLeave, onUpdate +local onLeave, onUpdate, onDragStart, onReceiveDrag Bartender4.Button = {} Bartender4.Button.prototype = Button @@ -23,7 +23,8 @@ function Bartender4.Button:Create(id, parent) button:SetScript("OnEnter", button.SetTooltip) button:SetScript("OnLeave", onLeave) button:SetScript("OnAttributeChanged", button.UpdateAction) - --button:SetScript("OnDragStart", button.OnDragStart) + button:SetScript("OnDragStart", onDragStart) + button:SetScript("OnReceiveDrag", onReceiveDrag) button:SetScript("PostClick", button.UpdateState) button.icon = _G[("%sIcon"):format(name)] @@ -74,6 +75,21 @@ function Bartender4.Button:Create(id, parent) return button end +function onDragStart(button) + if InCombatLockdown() then return end + if not Bartender4.db.profile.buttonlock or IsModifiedClick("PICKUPACTION") then + PickupAction(button.action) + button:UpdateState() + button:UpdateFlash() + end +end + +function onReceiveDrag(button) + PlaceAction(button.action) + button:UpdateState() + button:UpdateFlash() +end + function onLeave() GameTooltip:Hide() end @@ -306,8 +322,8 @@ function Button:HideButton() self.highlightTexture:SetTexture("") end -function Button:ShowGrid() - self.showgrid = self.showgrid+1 +function Button:ShowGrid(override) + if not override then self.showgrid = self.showgrid+1 end self.normalTexture:Show() if self.overlay then @@ -315,9 +331,9 @@ function Button:ShowGrid() end end -function Button:HideGrid() +function Button:HideGrid(override) local button = self.frame - self.showgrid = self.showgrid-1 + if not override then self.showgrid = self.showgrid-1 end if ( self.showgrid == 0 and not HasAction(self.action) and not self.parent.config.showgrid ) then self.normalTexture:Hide() if self.overlay then @@ -386,6 +402,8 @@ function Button:EventHandler(event, arg1) self:HideGrid() elseif ( event == "UPDATE_BINDINGS" ) then self:UpdateHotkeys() + elseif not self.eventsregistered then + return -- Action Event Handlers, only set when the button actually has an action elseif ( event == "PLAYER_TARGET_CHANGED" ) then self.rangeTimer = -1