Added very basic Reputation/XP Bar modules
Support for the XP and Reputation Bar, Bartender4 hides them so it can show them again. Disabled by default. Note: The XP Bar hides itself when you reach max-level, and the Reputation Bar hides itself if you are not tracking any reputation.
This commit is contained in:
+103
@@ -0,0 +1,103 @@
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
|
||||
-- register module
|
||||
local XPBarMod = Bartender4:NewModule("RepXPBar")
|
||||
|
||||
-- create prototype information
|
||||
local XPBar = setmetatable({}, {__index = Bar})
|
||||
|
||||
-- fetch upvalues
|
||||
local Bar = Bartender4.Bar.prototype
|
||||
|
||||
|
||||
|
||||
local table_insert = table.insert
|
||||
|
||||
local defaults = { profile = Bartender4:Merge({
|
||||
enabled = false,
|
||||
}, Bartender4.Bar.defaults) }
|
||||
|
||||
-- register module
|
||||
local RepBarMod = Bartender4:NewModule("RepBar")
|
||||
|
||||
-- create prototype information
|
||||
local RepBar = setmetatable({}, {__index = Bar})
|
||||
|
||||
function RepBarMod:OnInitialize()
|
||||
self.db = Bartender4.db:RegisterNamespace("RepBar", defaults)
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
|
||||
function RepBarMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.Bar:Create("Rep", self.db.profile, L["Reputation Bar"]), {__index = RepBar})
|
||||
self.bar.content = ReputationWatchBar
|
||||
|
||||
hooksecurefunc("ReputationWatchBar_Update", function() self.bar:PerformLayout() end)
|
||||
|
||||
self.bar.content:SetParent(self.bar)
|
||||
self.bar.content:Show()
|
||||
self.bar.content:SetFrameLevel(self.bar:GetFrameLevel() + 1)
|
||||
|
||||
-- TODO: real start position
|
||||
self.bar:SetPoint("CENTER")
|
||||
end
|
||||
self.bar:Enable()
|
||||
self:ToggleOptions()
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
end
|
||||
|
||||
function RepBarMod:OnDisable()
|
||||
if not self.bar then return end
|
||||
self.bar:Disable()
|
||||
self:ToggleOptions()
|
||||
end
|
||||
|
||||
function RepBarMod:ApplyConfig()
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
end
|
||||
|
||||
function RepBar:ApplyConfig(config)
|
||||
Bar.ApplyConfig(self, config)
|
||||
self:PerformLayout()
|
||||
end
|
||||
|
||||
function RepBar:PerformLayout()
|
||||
self:SetSize(1032, 21)
|
||||
local bar = self.content
|
||||
bar:ClearAllPoints()
|
||||
bar:SetPoint("TOPLEFT", self, "TOPLEFT", 5, -3)
|
||||
end
|
||||
|
||||
-- register module
|
||||
local XPBarMod = Bartender4:NewModule("XPBar")
|
||||
|
||||
-- create prototype information
|
||||
local XPBar = setmetatable({}, {__index = Bar})
|
||||
|
||||
function XPBarMod:OnInitialize()
|
||||
self.db = Bartender4.db:RegisterNamespace("XPBar", defaults)
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
|
||||
function XPBarMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.Bar:Create("XP", self.db.profile, L["XP Bar"]), {__index = XPBar})
|
||||
self.bar.content= MainMenuExpBar
|
||||
|
||||
self.bar.content:SetParent(self.bar)
|
||||
self.bar.content:Show()
|
||||
self.bar.content:SetFrameLevel(self.bar:GetFrameLevel() + 1)
|
||||
|
||||
-- TODO: real start position
|
||||
self.bar:SetPoint("CENTER")
|
||||
end
|
||||
self.bar:Enable()
|
||||
self:ToggleOptions()
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
end
|
||||
|
||||
XPBarMod.OnDisable = RepBarMod.OnDisable
|
||||
XPBarMod.ApplyConfig = RepBarMod.ApplyConfig
|
||||
XPBar.ApplyConfig = RepBar.ApplyConfig
|
||||
XPBar.PerformLayout = RepBar.PerformLayout
|
||||
Reference in New Issue
Block a user