apply more duct tape
This commit is contained in:
+27
-5
@@ -1,19 +1,41 @@
|
|||||||
--[[ $Id: Bartender3.lua 49922 2007-09-26 20:15:15Z nevcairiel $ ]]
|
--[[ $Id$ ]]
|
||||||
|
|
||||||
local BT4ActionBars = Bartender4:NewModule("ActionBars")
|
local BT4ActionBars = Bartender4:NewModule("ActionBars")
|
||||||
|
|
||||||
local Bar = Bartender4.Bar
|
local Bar = Bartender4.Bar.prototype
|
||||||
local ActionBar = setmetatable({}, {__index = Bar})
|
local ActionBar = setmetatable({}, {__index = Bar})
|
||||||
|
|
||||||
local ActionBar_MT = {__index = ActionBar}
|
local ActionBar_MT = {__index = ActionBar}
|
||||||
|
|
||||||
|
local defaults = {
|
||||||
|
profile = {
|
||||||
|
Bars = {
|
||||||
|
['**'] = {
|
||||||
|
Scale = 1,
|
||||||
|
Alpha = 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
local actionbars = {}
|
local actionbars = {}
|
||||||
function BT4ActionBars:OnInitialize()
|
function BT4ActionBars:OnInitialize()
|
||||||
|
self.db = Bartender4.db:RegisterNamespace("ActionBars", defaults)
|
||||||
|
|
||||||
for i=1,10 do
|
for i=1,10 do
|
||||||
actionbars[i] = ActionBar:Create(i)
|
actionbars[i] = ActionBar:Create(i, self.db.profile.Bars[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ActionBar:Create(id)
|
function ActionBar:Create(id, config)
|
||||||
local bar = setmetatable(Bar:Create(id, "SecureStateDriverTemplate"), ActionBar_MT)
|
local bar = setmetatable(Bartender4.Bar:Create(id, "SecureStateDriverTemplate", config), ActionBar_MT)
|
||||||
|
if not config.x or not config.y then
|
||||||
|
bar:SetPoint("CENTER", 0, -250 + (id-1) * 38)
|
||||||
|
bar:SavePosition()
|
||||||
|
else
|
||||||
|
bar:LoadPosition()
|
||||||
|
end
|
||||||
|
bar:Unlock()
|
||||||
|
|
||||||
|
return bar
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
--[[ $Id$ ]]
|
--[[ $Id$ ]]
|
||||||
|
|
||||||
local Bar = CreateFrame("Frame")
|
local Bar = CreateFrame("Button")
|
||||||
local Bar_MT = {__index = Bar}
|
local Bar_MT = {__index = Bar}
|
||||||
|
|
||||||
local function createOptions(id)
|
local function createOptions(id)
|
||||||
@@ -12,8 +12,9 @@ local function createOptions(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Bartender4.Bar = {}
|
Bartender4.Bar = {}
|
||||||
function Bartender4.Bar:Create(id, template)
|
Bartender4.Bar.prototype = Bar
|
||||||
local bar = setmetatable(CreateFrame("Frame", ("BT4Bar%s"):format(id), UIParent, template), Bar_MT)
|
function Bartender4.Bar:Create(id, template, config)
|
||||||
|
local bar = setmetatable(CreateFrame("Button", ("BT4Bar%s"):format(id), UIParent, template), Bar_MT)
|
||||||
|
|
||||||
bar:EnableMouse(false)
|
bar:EnableMouse(false)
|
||||||
bar:SetMovable(true)
|
bar:SetMovable(true)
|
||||||
@@ -29,19 +30,20 @@ function Bartender4.Bar:Create(id, template)
|
|||||||
})
|
})
|
||||||
bar:SetBackdropColor(0, 0, 0, 0)
|
bar:SetBackdropColor(0, 0, 0, 0)
|
||||||
bar:SetBackdropBorderColor(0.5, 0.5, 0, 0)
|
bar:SetBackdropBorderColor(0.5, 0.5, 0, 0)
|
||||||
bar.Text = frame:CreateFontString(nil, "ARTWORK")
|
bar.Text = bar:CreateFontString(nil, "ARTWORK")
|
||||||
bar.Text:SetFontObject(GameFontNormal)
|
bar.Text:SetFontObject(GameFontNormal)
|
||||||
bar.Text:SetText("Bar "..id)
|
bar.Text:SetText("Bar "..id)
|
||||||
bar.Text:Hide()
|
bar.Text:Hide()
|
||||||
bar.Text:ClearAllPoints()
|
bar.Text:ClearAllPoints()
|
||||||
bar.Text:SetPoint("CENTER", bar, "CENTER")
|
bar.Text:SetPoint("CENTER", bar, "CENTER")
|
||||||
|
|
||||||
|
bar.config = config
|
||||||
bar.options = createOptions(id)
|
bar.options = createOptions(id)
|
||||||
|
|
||||||
return bar
|
return bar
|
||||||
end
|
end
|
||||||
|
|
||||||
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop
|
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick
|
||||||
do
|
do
|
||||||
function barOnEnter(self)
|
function barOnEnter(self)
|
||||||
self:SetBackdropBorderColor(0.5, 0.5, 0, 1)
|
self:SetBackdropBorderColor(0.5, 0.5, 0, 1)
|
||||||
@@ -54,11 +56,19 @@ do
|
|||||||
function barOnDragStart(self)
|
function barOnDragStart(self)
|
||||||
self:StartMoving()
|
self:StartMoving()
|
||||||
self:SetBackdropBorderColor(0, 0, 0, 0)
|
self:SetBackdropBorderColor(0, 0, 0, 0)
|
||||||
|
self.isMoving = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function barOnDragStop(self)
|
function barOnDragStop(self)
|
||||||
self:StopMovingOrSizing()
|
if self.isMoving then
|
||||||
self:SavePosition()
|
self:StopMovingOrSizing()
|
||||||
|
self:SavePosition()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function barOnClick(self)
|
||||||
|
-- TODO: Hide/Show bar on Click
|
||||||
|
-- TODO: Once dropdown config is stable, show dropdown on rightclick
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -68,7 +78,7 @@ function Bar:Unlock()
|
|||||||
self:SetScript("OnLeave", barOnLeave)
|
self:SetScript("OnLeave", barOnLeave)
|
||||||
self:SetScript("OnDragStart", barOnDragStart)
|
self:SetScript("OnDragStart", barOnDragStart)
|
||||||
self:SetScript("OnDragStop", barOnDragStop)
|
self:SetScript("OnDragStop", barOnDragStop)
|
||||||
self:SetScript("OnClick", nil)
|
self:SetScript("OnClick", barOnClick)
|
||||||
self.Text:Show()
|
self.Text:Show()
|
||||||
|
|
||||||
self:SetFrameLevel(5)
|
self:SetFrameLevel(5)
|
||||||
@@ -80,6 +90,7 @@ function Bar:Unlock()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Bar:Lock()
|
function Bar:Lock()
|
||||||
|
barOnDragStop(self)
|
||||||
self:EnableMouse(false)
|
self:EnableMouse(false)
|
||||||
self:SetScript("OnEnter", nil)
|
self:SetScript("OnEnter", nil)
|
||||||
self:SetScript("OnLeave", nil)
|
self:SetScript("OnLeave", nil)
|
||||||
@@ -93,7 +104,7 @@ function Bar:Lock()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Bar:LoadPosition()
|
function Bar:LoadPosition()
|
||||||
local x, y, s = self.config.PosX, self.config.PosY, self:GetEffectiveScale()
|
local x, y, s = self.config.x, self.config.y, self:GetEffectiveScale()
|
||||||
x, y = x/s, y/s
|
x, y = x/s, y/s
|
||||||
self:ClearAllPoints()
|
self:ClearAllPoints()
|
||||||
self:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", x, y)
|
self:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", x, y)
|
||||||
@@ -103,6 +114,11 @@ function Bar:SavePosition()
|
|||||||
local x, y = self:GetLeft(), self:GetBottom()
|
local x, y = self:GetLeft(), self:GetBottom()
|
||||||
local s = self:GetEffectiveScale()
|
local s = self:GetEffectiveScale()
|
||||||
x, y = x*s, y*s
|
x, y = x*s, y*s
|
||||||
self.config.PosX = x
|
self.config.x = x
|
||||||
self.config.PosY = y
|
self.config.y = y
|
||||||
|
end
|
||||||
|
|
||||||
|
function Bar:SetSize(width, height)
|
||||||
|
self:SetWidth(width)
|
||||||
|
self:SetHeight(height or width)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,4 +8,11 @@
|
|||||||
## X-License: BSD
|
## X-License: BSD
|
||||||
## Version: 4.0
|
## Version: 4.0
|
||||||
|
|
||||||
|
## Core ##
|
||||||
Bartender4.lua
|
Bartender4.lua
|
||||||
|
|
||||||
|
## Prototypes ##
|
||||||
|
Bar.lua
|
||||||
|
|
||||||
|
## Modules ##
|
||||||
|
ActionBars.lua
|
||||||
|
|||||||
Reference in New Issue
Block a user