Add LSM callbacks so that the user can use custom media or media registered by other addons correctly.

This commit is contained in:
Xinhuan
2008-11-07 07:40:48 +08:00
parent 3c1ad20928
commit 75ad81d9e3
+26 -8
View File
@@ -442,6 +442,8 @@ function Omen:OnInitialize()
db = self.db.profile
self:SetSinkStorage(db.Warnings.SinkOptions)
LSM.RegisterCallback(self, "LibSharedMedia_Registered", "UpdateUsedMedia")
self:CreateFrames()
self:SetupOptions()
@@ -563,6 +565,7 @@ function Omen:OnProfileChanged(event, database, newProfileKey)
self:ReAnchorBars()
self:ReAnchorLabels()
self:UpdateBarLabelSettings()
self:UpdateBarTextureSettings()
self:UpdateFuBarSettings()
-- These remainder settings were not placed in functions
-- and were just updated directly from the config code.
@@ -590,15 +593,26 @@ function Omen:OnProfileChanged(event, database, newProfileKey)
else
bars[0].Text2:SetText(L["Threat"])
end
local texturepath = LSM:Fetch("statusbar", db.Bar.Texture)
for i = 0, #bars do
bars[i].texture:SetTexture(texturepath)
end
self:UpdateVisible()
self:UpdateBars()
end
function Omen:UpdateUsedMedia(event, mediatype, key)
if mediatype == "statusbar" then
if key == db.Bar.Texture then self:UpdateBarTextureSettings() end
elseif mediatype == "font" then
if key == db.TitleBar.Font then self:UpdateTitleBar() end
if key == db.Bar.Font then self:UpdateBarLabelSettings() end
elseif mediatype == "background" then
if key == db.Background.Texture then self:UpdateBackdrop() end
elseif mediatype == "border" then
if key == db.Background.BorderTexture then self:UpdateBackdrop() end
--elseif mediatype == "sound" then
-- Do nothing
end
end
function Omen:SetAnchors(useDB)
local x, y, w, h
@@ -1077,6 +1091,13 @@ function Omen:ReAnchorLabels()
end
end
function Omen:UpdateBarTextureSettings()
local texturepath = LSM:Fetch("statusbar", db.Bar.Texture)
for i = 0, #bars do
bars[i].texture:SetTexture(texturepath)
end
end
-----------------------------------------------------------------------------
-- Omen event functions
@@ -2459,10 +2480,7 @@ local options = {
values = AceGUIWidgetLSMlists.statusbar,
set = function(info, v)
db.Bar.Texture = v
local texturepath = LSM:Fetch("statusbar", v)
for i = 0, #bars do
bars[i].texture:SetTexture(texturepath)
end
Omen:UpdateBarTextureSettings()
end,
},
BarLabelsGroup = {