From 75ad81d9e35ce57126f43cf15ac7888e165bea30 Mon Sep 17 00:00:00 2001 From: Xinhuan Date: Fri, 7 Nov 2008 07:40:48 +0800 Subject: [PATCH] Add LSM callbacks so that the user can use custom media or media registered by other addons correctly. --- Omen.lua | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Omen.lua b/Omen.lua index 60103c5..f07699b 100644 --- a/Omen.lua +++ b/Omen.lua @@ -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 = {