- Button: added action drag support
- Button: added show grid option - Options: cleanup and sorting
This commit is contained in:
+28
-2
@@ -21,6 +21,7 @@ do
|
|||||||
buttons = "Buttons",
|
buttons = "Buttons",
|
||||||
rows = "Rows",
|
rows = "Rows",
|
||||||
enabled = "Enabled",
|
enabled = "Enabled",
|
||||||
|
grid = "Grid",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- retrieves a valid bar object from the modules actionbars table
|
-- retrieves a valid bar object from the modules actionbars table
|
||||||
@@ -79,6 +80,7 @@ function module:GetOptionsTable()
|
|||||||
-- order = inherited (5)
|
-- order = inherited (5)
|
||||||
args = {
|
args = {
|
||||||
padding = {
|
padding = {
|
||||||
|
order = 30,
|
||||||
type = "range",
|
type = "range",
|
||||||
name = "Padding",
|
name = "Padding",
|
||||||
desc = "Configure the padding of the buttons.",
|
desc = "Configure the padding of the buttons.",
|
||||||
@@ -86,6 +88,14 @@ function module:GetOptionsTable()
|
|||||||
set = optSetter,
|
set = optSetter,
|
||||||
get = optGetter,
|
get = optGetter,
|
||||||
},
|
},
|
||||||
|
grid = {
|
||||||
|
order = 5,
|
||||||
|
type = "toggle",
|
||||||
|
name = "Button Grid",
|
||||||
|
desc = "Toggle the button grid.",
|
||||||
|
set = optSetter,
|
||||||
|
get = optGetter,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
layout = {
|
layout = {
|
||||||
@@ -184,6 +194,7 @@ function ActionBar:UpdateButtons(numbuttons)
|
|||||||
self.buttons = buttons
|
self.buttons = buttons
|
||||||
|
|
||||||
self:UpdateButtonLayout()
|
self:UpdateButtonLayout()
|
||||||
|
self:SetGrid()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- align the buttons and correct the size of the bar overlay frame
|
-- align the buttons and correct the size of the bar overlay frame
|
||||||
@@ -223,7 +234,7 @@ end
|
|||||||
|
|
||||||
-- set the padding and refresh layout
|
-- set the padding and refresh layout
|
||||||
function ActionBar:SetPadding(pad)
|
function ActionBar:SetPadding(pad)
|
||||||
if pad then
|
if pad ~= nil then
|
||||||
self.config.padding = pad
|
self.config.padding = pad
|
||||||
end
|
end
|
||||||
self:UpdateButtonLayout()
|
self:UpdateButtonLayout()
|
||||||
@@ -244,7 +255,7 @@ end
|
|||||||
|
|
||||||
-- set the number of rows and refresh layout
|
-- set the number of rows and refresh layout
|
||||||
function ActionBar:SetRows(rows)
|
function ActionBar:SetRows(rows)
|
||||||
if rows then
|
if rows ~= nil then
|
||||||
self.config.rows = rows
|
self.config.rows = rows
|
||||||
end
|
end
|
||||||
self:UpdateButtonLayout()
|
self:UpdateButtonLayout()
|
||||||
@@ -260,6 +271,21 @@ function ActionBar:SetEnabled(state)
|
|||||||
end
|
end
|
||||||
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
|
Utility function
|
||||||
===================================================================================]]--
|
===================================================================================]]--
|
||||||
|
|||||||
+42
-49
@@ -17,6 +17,7 @@ local abdefaults = Bartender4:Merge({
|
|||||||
padding = 2,
|
padding = 2,
|
||||||
rows = 1,
|
rows = 1,
|
||||||
hidemacrotext = false,
|
hidemacrotext = false,
|
||||||
|
showgrid = false,
|
||||||
},
|
},
|
||||||
[1] = {
|
[1] = {
|
||||||
stances = stancedefaults,
|
stances = stancedefaults,
|
||||||
@@ -117,67 +118,59 @@ function BT4ActionBars:SetupOptions()
|
|||||||
name = "Action Bars",
|
name = "Action Bars",
|
||||||
get = getFunc,
|
get = getFunc,
|
||||||
args = {
|
args = {
|
||||||
general = {
|
range = {
|
||||||
order = 1,
|
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",
|
type = "group",
|
||||||
guiInline = true,
|
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 = {
|
args = {
|
||||||
range = {
|
range = {
|
||||||
order = 1,
|
order = 1,
|
||||||
|
type = "color",
|
||||||
name = "Out of Range Indicator",
|
name = "Out of Range Indicator",
|
||||||
desc = "Configure how the Out of Range Indicator should display on the buttons.",
|
desc = "Specify the Color of the Out of Range Indicator",
|
||||||
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 = {
|
mana = {
|
||||||
order = 2,
|
order = 2,
|
||||||
type = "group",
|
type = "color",
|
||||||
guiInline = true,
|
name = "Out of Mana Indicator",
|
||||||
name = "Colors",
|
desc = "Specify the Color of the Out of Mana Indicator",
|
||||||
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,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
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)
|
Bartender4:RegisterModuleOptions("actionbars", self.options)
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ function Bar:GetOptionTable()
|
|||||||
order = 5,
|
order = 5,
|
||||||
args = {
|
args = {
|
||||||
alpha = {
|
alpha = {
|
||||||
|
order = 10,
|
||||||
name = "Alpha",
|
name = "Alpha",
|
||||||
desc = "Configure the alpha of the bar.",
|
desc = "Configure the alpha of the bar.",
|
||||||
type = "range",
|
type = "range",
|
||||||
@@ -147,6 +148,7 @@ function Bar:GetOptionTable()
|
|||||||
set = optSetter,
|
set = optSetter,
|
||||||
},
|
},
|
||||||
scale = {
|
scale = {
|
||||||
|
order = 20,
|
||||||
name = "Scale",
|
name = "Scale",
|
||||||
desc = "Configure the scale of the bar.",
|
desc = "Configure the scale of the bar.",
|
||||||
type = "range",
|
type = "range",
|
||||||
|
|||||||
+24
-6
@@ -7,7 +7,7 @@
|
|||||||
local Button = CreateFrame("CheckButton")
|
local Button = CreateFrame("CheckButton")
|
||||||
local Button_MT = {__index = Button}
|
local Button_MT = {__index = Button}
|
||||||
|
|
||||||
local onLeave, onUpdate
|
local onLeave, onUpdate, onDragStart, onReceiveDrag
|
||||||
|
|
||||||
Bartender4.Button = {}
|
Bartender4.Button = {}
|
||||||
Bartender4.Button.prototype = Button
|
Bartender4.Button.prototype = Button
|
||||||
@@ -23,7 +23,8 @@ function Bartender4.Button:Create(id, parent)
|
|||||||
button:SetScript("OnEnter", button.SetTooltip)
|
button:SetScript("OnEnter", button.SetTooltip)
|
||||||
button:SetScript("OnLeave", onLeave)
|
button:SetScript("OnLeave", onLeave)
|
||||||
button:SetScript("OnAttributeChanged", button.UpdateAction)
|
button:SetScript("OnAttributeChanged", button.UpdateAction)
|
||||||
--button:SetScript("OnDragStart", button.OnDragStart)
|
button:SetScript("OnDragStart", onDragStart)
|
||||||
|
button:SetScript("OnReceiveDrag", onReceiveDrag)
|
||||||
button:SetScript("PostClick", button.UpdateState)
|
button:SetScript("PostClick", button.UpdateState)
|
||||||
|
|
||||||
button.icon = _G[("%sIcon"):format(name)]
|
button.icon = _G[("%sIcon"):format(name)]
|
||||||
@@ -74,6 +75,21 @@ function Bartender4.Button:Create(id, parent)
|
|||||||
return button
|
return button
|
||||||
end
|
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()
|
function onLeave()
|
||||||
GameTooltip:Hide()
|
GameTooltip:Hide()
|
||||||
end
|
end
|
||||||
@@ -306,8 +322,8 @@ function Button:HideButton()
|
|||||||
self.highlightTexture:SetTexture("")
|
self.highlightTexture:SetTexture("")
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:ShowGrid()
|
function Button:ShowGrid(override)
|
||||||
self.showgrid = self.showgrid+1
|
if not override then self.showgrid = self.showgrid+1 end
|
||||||
self.normalTexture:Show()
|
self.normalTexture:Show()
|
||||||
|
|
||||||
if self.overlay then
|
if self.overlay then
|
||||||
@@ -315,9 +331,9 @@ function Button:ShowGrid()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:HideGrid()
|
function Button:HideGrid(override)
|
||||||
local button = self.frame
|
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
|
if ( self.showgrid == 0 and not HasAction(self.action) and not self.parent.config.showgrid ) then
|
||||||
self.normalTexture:Hide()
|
self.normalTexture:Hide()
|
||||||
if self.overlay then
|
if self.overlay then
|
||||||
@@ -386,6 +402,8 @@ function Button:EventHandler(event, arg1)
|
|||||||
self:HideGrid()
|
self:HideGrid()
|
||||||
elseif ( event == "UPDATE_BINDINGS" ) then
|
elseif ( event == "UPDATE_BINDINGS" ) then
|
||||||
self:UpdateHotkeys()
|
self:UpdateHotkeys()
|
||||||
|
elseif not self.eventsregistered then
|
||||||
|
return
|
||||||
-- Action Event Handlers, only set when the button actually has an action
|
-- Action Event Handlers, only set when the button actually has an action
|
||||||
elseif ( event == "PLAYER_TARGET_CHANGED" ) then
|
elseif ( event == "PLAYER_TARGET_CHANGED" ) then
|
||||||
self.rangeTimer = -1
|
self.rangeTimer = -1
|
||||||
|
|||||||
Reference in New Issue
Block a user