Add optional LibFuBarPlugin-3.0 support (if detected).

This commit is contained in:
Xinhuan
2008-10-11 00:03:53 +08:00
parent 64e45cacbf
commit 89715aa336
2 changed files with 125 additions and 18 deletions
+13
View File
@@ -120,6 +120,19 @@ L["Center Omen"] = true
L["Configure"] = true
L["Open the configuration dialog"] = true
-- For Fubar
L["Click|r to toggle the Omen window"] = true
L["Right-click|r to open the options menu"] = true
L["FuBar Options"] = true
L["Attach to minimap"] = true
L["Hide minimap/FuBar icon"] = true
L["Show icon"] = true
L["Show text"] = true
L["Position"] = true
L["Left"] = true
L["Center"] = true
L["Right"] = true
-- FAQ
L["Help File"] = true
L["A collection of help pages"] = true
+112 -18
View File
@@ -118,6 +118,10 @@ local defaults = {
["WARLOCK"] = true,
["WARRIOR"] = true
},
FuBar = {
HideMinimapButton = true,
AttachMinimap = false,
},
},
}
local guidNameLookup = {} -- Format: guidNameLookup[guid] = "Unit Name"
@@ -300,6 +304,34 @@ function Omen:PLAYER_LOGIN()
end,
})
end
-- Optional launcher support for LFBP-3.0 if present, this code is placed here so
-- that it runs after all other addons have loaded since we don't embed LFBP-3.0
-- Yes, this is one big hack since LFBP-3.0 is a Rock library, and we embed it
-- via Ace3. OnEmbedInitialize() needs to be called manually.
if LibStub:GetLibrary("LibFuBarPlugin-3.0", true) then
local LFBP = LibStub:GetLibrary("LibFuBarPlugin-3.0")
LibStub("AceAddon-3.0"):EmbedLibrary(self, "LibFuBarPlugin-3.0")
self:SetFuBarOption("tooltipType", "GameTooltip")
self:SetFuBarOption("hasNoColor", true)
self:SetFuBarOption("cannotDetachTooltip", true)
self:SetFuBarOption("hideWithoutStandby", true)
self:SetFuBarOption("iconPath", [[Interface\AddOns\Omen\icon]])
self:SetFuBarOption("hasIcon", true)
self:SetFuBarOption("defaultPosition", "RIGHT")
self:SetFuBarOption("tooltipHiddenWhenEmpty", true)
LFBP:OnEmbedInitialize(self)
function Omen:OnUpdateFuBarTooltip()
GameTooltip:AddLine("|cffffff00" .. L["Click|r to toggle the Omen window"])
GameTooltip:AddLine("|cffffff00" .. L["Right-click|r to open the options menu"])
end
function Omen:OnFuBarClick(button)
self:Toggle()
end
self.OpenMenu = self.ShowConfig
self.optionsFrames["FuBar"] = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["FuBar Options"], "Omen", "FuBar")
self:UpdateFuBarSettings()
end
end
function Omen:OnEnable()
@@ -341,6 +373,7 @@ function Omen:OnProfileChanged(event, database, newProfileKey)
self:UpdateBarLabelSettings()
self:UpdateVisible()
self:UpdateBars()
self:UpdateFuBarSettings()
end
function Omen:SetAnchors(useDB)
@@ -409,12 +442,7 @@ function Omen:UpdateVisible()
self:Toggle(show)
end
local bgFrame = {
tile = true,
tileSize = 32,
edgeSize = 8,
insets = {left = 2, right = 2, top = 2, bottom = 2}
}
local bgFrame = {insets = {}}
function Omen:UpdateBackdrop()
bgFrame.bgFile = LSM:Fetch("background", db.Background.Texture)
bgFrame.edgeFile = LSM:Fetch("border", db.Background.BorderTexture)
@@ -465,6 +493,16 @@ function Omen:UpdateTitleBar()
end
end
function Omen:UpdateFuBarSettings()
if LibStub:GetLibrary("LibFuBarPlugin-3.0", true) then
if self:IsFuBarMinimapAttached() ~= db.FuBar.AttachMinimap then
self:ToggleFuBarMinimapAttached()
end
if db.FuBar.HideMinimapButton then self:Hide() else self:Show() end
end
end
-----------------------------------------------------------------------------
-- Omen bar stuff
@@ -900,13 +938,8 @@ local outlines = {
["THICKOUTLINE"] = L["Thick Outline"],
}
local function GetLSMIndex(t, value)
for k, v in pairs(LSM:List(t)) do
if v == value then
return k
end
end
return nil
local function GetFuBarMinimapAttachedStatus(info)
return Omen:IsFuBarMinimapAttached() or db.FuBar.HideMinimapButton
end
local options = {
@@ -1341,6 +1374,68 @@ local options = {
},
},
},
FuBar = {
type = "group",
name = L["FuBar Options"],
desc = L["FuBar Options"],
hidden = function() return Omen.IsFuBarMinimapAttached == nil end,
args = {
attachMinimap = {
type = "toggle",
order = 1,
name = L["Attach to minimap"],
desc = L["Attach to minimap"],
get = function(info) return Omen:IsFuBarMinimapAttached() end,
set = function(info, v)
Omen:ToggleFuBarMinimapAttached()
db.FuBar.AttachMinimap = Omen:IsFuBarMinimapAttached()
end,
},
hideIcon = {
type = "toggle",
order = 2,
name = L["Hide minimap/FuBar icon"],
desc = L["Hide minimap/FuBar icon"],
get = function(info) return db.FuBar.HideMinimapButton end,
set = function(info, v)
db.FuBar.HideMinimapButton = v
if v then Omen:Hide() else Omen:Show() end
end,
},
showIcon = {
type = "toggle",
order = 3,
name = L["Show icon"],
desc = L["Show icon"],
get = function(info) return Omen:IsFuBarIconShown() end,
set = function(info, v) Omen:ToggleFuBarIconShown() end,
disabled = GetFuBarMinimapAttachedStatus,
},
showText = {
type = "toggle",
order = 4,
name = L["Show text"],
desc = L["Show text"],
get = function(info) return Omen:IsFuBarTextShown() end,
set = function(info, v) Omen:ToggleFuBarTextShown() end,
disabled = GetFuBarMinimapAttachedStatus,
},
position = {
type = "select",
order = 5,
name = L["Position"],
desc = L["Position"],
values = {LEFT = L["Left"], CENTER = L["Center"], RIGHT = L["Right"]},
get = function() return Omen:GetPanel() and Omen:GetPanel():GetPluginSide(Omen) end,
set = function(info, val)
if Omen:GetPanel() and Omen:GetPanel().SetPluginSide then
Omen:GetPanel():SetPluginSide(Omen, val)
end
end,
disabled = GetFuBarMinimapAttachedStatus,
}
}
},
Help = {
type = "group",
name = L["Help File"],
@@ -1434,13 +1529,12 @@ function Omen:SetupOptions()
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("Omen", options)
LibStub("AceConfig-3.0"):RegisterOptionsTable("OmenSlashCommand", optionsSlash, "omen")
self.optionsFrames.Omen = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", nil, nil, "general")
self.optionsFrames.Help = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Help File"], "Omen", "Help")
self.optionsFrames.ShowWhen = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Show When..."], "Omen", "ShowWhen")
self.optionsFrames.Bars = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Bar Settings"], "Omen", "Bars")
self.optionsFrames.TitleBar = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Title Bar Settings"], "Omen", "TitleBar")
self:RegisterModuleOptions("Profiles", LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db), L["Profiles"])
self:RegisterModuleOptions("OmenSlashCommand", optionsSlash, L["Slash Command"])
self.optionsFrames["Help"] = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Help File"], "Omen", "Help")
self.optionsFrames["ShowWhen"] = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Show When..."], "Omen", "ShowWhen")
self.optionsFrames["Bars"] = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Bar Settings"], "Omen", "Bars")
self.optionsFrames["TitleBar"] = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Omen", L["Title Bar Settings"], "Omen", "TitleBar")
end
function Omen:RegisterModuleOptions(name, optionTbl, displayName)