cleanup options and database layout
This commit is contained in:
@@ -150,7 +150,7 @@ function ActionBar:ApplyConfig(config)
|
||||
Bar.ApplyConfig(self, config)
|
||||
|
||||
config = self.config
|
||||
if not config.Position then initialPosition(self) end
|
||||
if not config.position then initialPosition(self) end
|
||||
|
||||
self:UpdateButtons()
|
||||
end
|
||||
@@ -158,9 +158,9 @@ end
|
||||
-- Update the number of buttons in our bar, creating new ones if necessary
|
||||
function ActionBar:UpdateButtons(numbuttons)
|
||||
if numbuttons then
|
||||
self.config.Buttons = numbuttons
|
||||
self.config.buttons = numbuttons
|
||||
else
|
||||
numbuttons = self.config.Buttons
|
||||
numbuttons = self.config.buttons
|
||||
end
|
||||
|
||||
local buttons = self.buttons or {}
|
||||
@@ -218,20 +218,20 @@ end
|
||||
|
||||
-- get the current padding
|
||||
function ActionBar:GetPadding()
|
||||
return self.config.Padding
|
||||
return self.config.padding
|
||||
end
|
||||
|
||||
-- set the padding and refresh layout
|
||||
function ActionBar:SetPadding(pad)
|
||||
if pad then
|
||||
self.config.Padding = pad
|
||||
self.config.padding = pad
|
||||
end
|
||||
self:UpdateButtonLayout()
|
||||
end
|
||||
|
||||
-- get the current number of buttons
|
||||
function ActionBar:GetButtons()
|
||||
return self.config.Buttons
|
||||
return self.config.buttons
|
||||
end
|
||||
|
||||
-- set the number of buttons and refresh layout
|
||||
@@ -239,13 +239,13 @@ ActionBar.SetButtons = ActionBar.UpdateButtons
|
||||
|
||||
-- get the current number of rows
|
||||
function ActionBar:GetRows()
|
||||
return self.config.Rows
|
||||
return self.config.rows
|
||||
end
|
||||
|
||||
-- set the number of rows and refresh layout
|
||||
function ActionBar:SetRows(rows)
|
||||
if rows then
|
||||
self.config.Rows = rows
|
||||
self.config.rows = rows
|
||||
end
|
||||
self:UpdateButtonLayout()
|
||||
end
|
||||
|
||||
+33
-24
@@ -12,34 +12,34 @@ local stancedefaults = {
|
||||
|
||||
local abdefaults = Bartender4:Merge({
|
||||
['**'] = {
|
||||
Enabled = true,
|
||||
Buttons = 12,
|
||||
Padding = 2,
|
||||
Rows = 1,
|
||||
HideMacrotext = false,
|
||||
enabled = true,
|
||||
buttons = 12,
|
||||
padding = 2,
|
||||
rows = 1,
|
||||
hidemacrotext = false,
|
||||
},
|
||||
[1] = {
|
||||
Stances = stancedefaults,
|
||||
stances = stancedefaults,
|
||||
},
|
||||
[7] = {
|
||||
Enabled = false,
|
||||
enabled = false,
|
||||
},
|
||||
[8] = {
|
||||
Enabled = false,
|
||||
enabled = false,
|
||||
},
|
||||
[9] = {
|
||||
Enabled = false,
|
||||
enabled = false,
|
||||
},
|
||||
[10] = {
|
||||
Enabled = false,
|
||||
enabled = false,
|
||||
},
|
||||
}, Bartender4.Bar.defaults)
|
||||
|
||||
local defaults = {
|
||||
profile = {
|
||||
OutOfRange = "button",
|
||||
Colors = { range = { r = 0.8, g = 0.1, b = 0.1 }, mana = { r = 0.5, g = 0.5, b = 1.0 } },
|
||||
ActionBars = abdefaults,
|
||||
outofrange = "button",
|
||||
colors = { range = { r = 0.8, g = 0.1, b = 0.1 }, mana = { r = 0.5, g = 0.5, b = 1.0 } },
|
||||
actionbars = abdefaults,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ function BT4ActionBars:OnEnable()
|
||||
self.playerclass = select(2, UnitClass("player"))
|
||||
self.actionbars = {}
|
||||
for i=1,10 do
|
||||
local config = self.db.profile.ActionBars[i]
|
||||
if config.Enabled then
|
||||
local config = self.db.profile.actionbars[i]
|
||||
if config.enabled then
|
||||
self.actionbars[i] = self:Create(i, config)
|
||||
else
|
||||
self:CreateBarOption(i, self.disabledoptions)
|
||||
@@ -75,8 +75,8 @@ end
|
||||
-- Applys the config in the current profile to all active Bars
|
||||
function BT4ActionBars:ApplyConfig()
|
||||
for i=1,10 do
|
||||
local config = self.db.profile.ActionBars[i]
|
||||
if config.Enabled then
|
||||
local config = self.db.profile.actionbars[i]
|
||||
if config.enabled then
|
||||
self:EnableBar(i)
|
||||
else
|
||||
self:DisableBar(i)
|
||||
@@ -84,7 +84,7 @@ function BT4ActionBars:ApplyConfig()
|
||||
end
|
||||
end
|
||||
|
||||
function BT4ActionBars:UpdateButtons()
|
||||
function BT4ActionBars:UpdateButtons(force)
|
||||
for i,v in ipairs(self.actionbars) do
|
||||
for j,button in ipairs(v.buttons) do
|
||||
button:UpdateAction(force)
|
||||
@@ -130,10 +130,10 @@ function BT4ActionBars:SetupOptions()
|
||||
type = "select",
|
||||
style = "dropdown",
|
||||
get = function()
|
||||
return BT4ActionBars.db.profile.OutOfRange
|
||||
return BT4ActionBars.db.profile.outofrange
|
||||
end,
|
||||
set = function(info, value)
|
||||
BT4ActionBars.db.profile.OutOfRange = value
|
||||
BT4ActionBars.db.profile.outofrange = value
|
||||
BT4ActionBars:ForAllButtons("UpdateUsable")
|
||||
end,
|
||||
values = { none = "No Display", button = "Full Button Mode", hotkey = "Hotkey Mode" },
|
||||
@@ -144,11 +144,11 @@ function BT4ActionBars:SetupOptions()
|
||||
guiInline = true,
|
||||
name = "Colors",
|
||||
get = function(info)
|
||||
local color = BT4ActionBars.db.profile.Colors[info[#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]]
|
||||
local color = BT4ActionBars.db.profile.colors[info[#info]]
|
||||
color.r, color.g, color.b = r, g, b
|
||||
BT4ActionBars:ForAllButtons("UpdateUsable")
|
||||
end,
|
||||
@@ -167,6 +167,15 @@ function BT4ActionBars:SetupOptions()
|
||||
},
|
||||
},
|
||||
},
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -225,7 +234,7 @@ function BT4ActionBars:DisableBar(id)
|
||||
local bar = self.actionbars[id]
|
||||
if not bar then return end
|
||||
|
||||
bar.config.Enabled = false
|
||||
bar.config.enabled = false
|
||||
bar.disabled = true
|
||||
bar:Hide()
|
||||
self:CreateBarOption(id, self.disabledoptions)
|
||||
@@ -235,7 +244,7 @@ function BT4ActionBars:EnableBar(id)
|
||||
id = tonumber(id)
|
||||
local bar = self.actionbars[id]
|
||||
local config = self.db.profile.ActionBars[id]
|
||||
config.Enabled = true
|
||||
config.enabled = true
|
||||
if not bar then
|
||||
bar = self:Create(id, config)
|
||||
self.actionbars[id] = bar
|
||||
|
||||
@@ -13,9 +13,9 @@ local Bar_MT = {__index = Bar}
|
||||
|
||||
local defaults = {
|
||||
['**'] = {
|
||||
Scale = 1,
|
||||
Alpha = 1,
|
||||
Show = true,
|
||||
scale = 1,
|
||||
alpha = 1,
|
||||
show = true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ function Bar:Unlock()
|
||||
|
||||
self:Show()
|
||||
self:SetFrameLevel(5)
|
||||
if not self.config.Show then
|
||||
if not self.config.show then
|
||||
self:SetBackdropColor(1, 0, 0, 0.5)
|
||||
else
|
||||
self:SetBackdropColor(0, 1, 0, 0.5)
|
||||
@@ -250,7 +250,7 @@ function Bar:Lock()
|
||||
self:SetScript("OnClick", nil)
|
||||
self.Text:Hide()
|
||||
|
||||
if not self.config.Show then
|
||||
if not self.config.show then
|
||||
self:Hide()
|
||||
end
|
||||
|
||||
@@ -259,8 +259,8 @@ function Bar:Lock()
|
||||
end
|
||||
|
||||
function Bar:LoadPosition()
|
||||
if not self.config.Position then return end
|
||||
local pos = self.config.Position
|
||||
if not self.config.position then return end
|
||||
local pos = self.config.position
|
||||
local x, y, s = pos.x, pos.y, self:GetEffectiveScale()
|
||||
local point, relPoint = pos.point, pos.relPoint
|
||||
x, y = x/s, y/s
|
||||
@@ -268,8 +268,8 @@ function Bar:LoadPosition()
|
||||
end
|
||||
|
||||
function Bar:SavePosition()
|
||||
if not self.config.Position then self.config.Position = {} end
|
||||
local pos = self.config.Position
|
||||
if not self.config.position then self.config.position = {} end
|
||||
local pos = self.config.position
|
||||
local point, parent, relPoint, x, y = self:GetPoint()
|
||||
local s = self:GetEffectiveScale()
|
||||
x, y = x*s, y*s
|
||||
@@ -283,17 +283,17 @@ function Bar:SetSize(width, height)
|
||||
end
|
||||
|
||||
function Bar:GetShow()
|
||||
return self.config.Show
|
||||
return self.config.show
|
||||
end
|
||||
|
||||
function Bar:SetShow(show)
|
||||
if show ~= nil then
|
||||
self.config.Show = show
|
||||
self.config.show = show
|
||||
end
|
||||
if not self.unlocked then
|
||||
self[self.config.Show and "Show" or "Hide"](self)
|
||||
self[self.config.show and "Show" or "Hide"](self)
|
||||
else
|
||||
if not self.config.Show then
|
||||
if not self.config.show then
|
||||
self:SetBackdropColor(1, 0, 0, 0.5)
|
||||
else
|
||||
self:SetBackdropColor(0, 1, 0, 0.5)
|
||||
@@ -302,25 +302,25 @@ function Bar:SetShow(show)
|
||||
end
|
||||
|
||||
function Bar:GetConfigAlpha()
|
||||
return self.config.Alpha
|
||||
return self.config.alpha
|
||||
end
|
||||
|
||||
function Bar:SetConfigAlpha(alpha)
|
||||
if alpha then
|
||||
self.config.Alpha = alpha
|
||||
self.config.alpha = alpha
|
||||
end
|
||||
self:SetAlpha(self.config.Alpha)
|
||||
self:SetAlpha(self.config.alpha)
|
||||
end
|
||||
|
||||
function Bar:GetConfigScale()
|
||||
return self.config.Scale
|
||||
return self.config.scale
|
||||
end
|
||||
|
||||
function Bar:SetConfigScale(scale)
|
||||
if scale then
|
||||
self.config.Scale = scale
|
||||
self.config.scale = scale
|
||||
end
|
||||
self:SetScale(self.config.Scale)
|
||||
self:SetScale(self.config.scale)
|
||||
self:LoadPosition()
|
||||
end
|
||||
|
||||
|
||||
+3
-2
@@ -4,12 +4,13 @@ Bartender4 = AceAddon:NewAddon("Bartender4", "AceConsole-3.0", "AceEvent-3.0")
|
||||
|
||||
local defaults = {
|
||||
profile = {
|
||||
|
||||
tooltip = "enabled",
|
||||
buttonlock = false,
|
||||
}
|
||||
}
|
||||
|
||||
function Bartender4:OnInitialize()
|
||||
self.db = LibStub("AceDB-3.0"):New("Bartender4DB")
|
||||
self.db = LibStub("AceDB-3.0"):New("Bartender4DB", defaults)
|
||||
self.db.RegisterCallback(self, "OnProfileChanged", "UpdateModuleConfigs")
|
||||
self.db.RegisterCallback(self, "OnProfileCopied", "UpdateModuleConfigs")
|
||||
self.db.RegisterCallback(self, "OnProfileReset", "UpdateModuleConfigs")
|
||||
|
||||
+6
-6
@@ -104,7 +104,7 @@ function onUpdate(self, elapsed)
|
||||
if ( self.rangeTimer <= 0 ) then
|
||||
local valid = IsActionInRange(self.action)
|
||||
local hotkey = self.hotkey
|
||||
local hkshown = (hotkey:GetText() == RANGE_INDICATOR and Bartender4.db.profile.OutOfRange == "hotkey")
|
||||
local hkshown = (hotkey:GetText() == RANGE_INDICATOR and self.settings.profile.outofrange == "hotkey")
|
||||
if valid and hkshown then
|
||||
hotkey:Show()
|
||||
elseif hkshown then
|
||||
@@ -147,7 +147,7 @@ function Button:Update()
|
||||
else
|
||||
self:UnregisterActionEvents()
|
||||
|
||||
if ( self.showgrid == 0 and not self.parent.config.ShowGrid ) then
|
||||
if ( self.showgrid == 0 and not self.parent.config.showgrid ) then
|
||||
self.normalTexture:Hide()
|
||||
if self.overlay then
|
||||
self.overlay:Hide()
|
||||
@@ -178,7 +178,7 @@ function Button:Update()
|
||||
self.UpdateTooltip = nil
|
||||
end
|
||||
|
||||
if self.parent.config.HideMacrotext then
|
||||
if self.parent.config.hidemacrotext then
|
||||
self.macroName:SetText("")
|
||||
else
|
||||
self.macroName:SetText(GetActionText(action))
|
||||
@@ -229,9 +229,9 @@ function Button:UpdateState()
|
||||
end
|
||||
|
||||
function Button:UpdateUsable()
|
||||
local oor = self.settings.profile.OutOfRange
|
||||
local oor = self.settings.profile.outofrange
|
||||
local isUsable, notEnoughMana = IsUsableAction(self.action)
|
||||
local oorcolor, oomcolor = self.settings.profile.Colors.range, self.settings.profile.Colors.mana
|
||||
local oorcolor, oomcolor = self.settings.profile.colors.range, self.settings.profile.colors.mana
|
||||
if ( oor ~= "button" or not self.outOfRange) then
|
||||
if ( oor == "none" or not self.outOfRange) then
|
||||
self.hotkey:SetVertexColor(1.0, 1.0, 1.0)
|
||||
@@ -318,7 +318,7 @@ end
|
||||
function Button:HideGrid()
|
||||
local button = self.frame
|
||||
self.showgrid = self.showgrid-1
|
||||
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()
|
||||
if self.overlay then
|
||||
self.overlay:Hide()
|
||||
|
||||
+25
-22
@@ -1,5 +1,7 @@
|
||||
--[[ $Id$ ]]
|
||||
|
||||
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
|
||||
|
||||
local getFunc, setFunc
|
||||
do
|
||||
function getFunc(info)
|
||||
@@ -20,33 +22,34 @@ function Bartender4:SetupOptions()
|
||||
childGroups = "tree",
|
||||
plugins = {},
|
||||
args = {
|
||||
general = {
|
||||
order = 10,
|
||||
type = "group",
|
||||
--cmdInline = true,
|
||||
name = "General Settings",
|
||||
lock = {
|
||||
order = 1,
|
||||
type = "toggle",
|
||||
name = "Lock",
|
||||
desc = "Lock all bars.",
|
||||
get = function() return Bartender4.Locked end,
|
||||
set = function(info, value) Bartender4[value and "Lock" or "Unlock"](Bartender4) end,
|
||||
},
|
||||
buttonlock = {
|
||||
order = 2,
|
||||
type = "toggle",
|
||||
name = "Button Lock",
|
||||
desc = "Lock the buttons.",
|
||||
get = getFunc,
|
||||
set = setFunc,
|
||||
args = {
|
||||
--[[ blue = {
|
||||
type = "toggle",
|
||||
name = "Test",
|
||||
get = function() end,
|
||||
set = function() end,
|
||||
} ]]
|
||||
},
|
||||
},
|
||||
lock = {
|
||||
dialogHidden = true,
|
||||
type = "toggle",
|
||||
name = "Lock/Unlock the bars.",
|
||||
get = function() return Bartender4.Locked end,
|
||||
set = function(info, value) Bartender4:ToggleLock(value) end,
|
||||
},
|
||||
},
|
||||
}
|
||||
LibStub("AceConfig-3.0"):RegisterOptionsTable("Bartender4", self.options)
|
||||
local optFunc = function() LibStub("AceConfigDialog-3.0"):Open("Bartender4") end
|
||||
LibStub("AceConfig-3.0"):RegisterOptionsTable("Bartender4", self.options, "bttest")
|
||||
local optFunc = function()
|
||||
AceConfigDialog:Open("Bartender4")
|
||||
--[[
|
||||
local status = AceConfigDialog:GetStatusTable("Bartender4")
|
||||
if not status.groups then status.groups = {} end
|
||||
if not status.groups.groups then status.groups.groups = {} end
|
||||
status.groups.groups["actionbars"] = true
|
||||
]]
|
||||
end
|
||||
LibStub("AceConsole-3.0"):RegisterChatCommand( "bar", optFunc)
|
||||
LibStub("AceConsole-3.0"):RegisterChatCommand( "bt", optFunc)
|
||||
LibStub("AceConsole-3.0"):RegisterChatCommand( "bt4", optFunc)
|
||||
|
||||
Reference in New Issue
Block a user