Use AceGUI-3.0-SharedMediaWidgets. Add a ton of background and title bar options.

Note that LibSharedMedia-3.0 may fail to load if you use disembedded libs due to a LoD issue. Either edit the TOC of LibSharedMedia-3.0 so that it is no longer LoD, or get a copy of Omen3 with embedded libs.
This commit is contained in:
Xinhuan
2008-10-10 21:26:49 +08:00
parent 20a3f19019
commit 64e45cacbf
4 changed files with 312 additions and 35 deletions
+281 -33
View File
@@ -8,6 +8,7 @@
-- its their own addons.
LoadAddOn("Ace3")
LoadAddOn("LibSharedMedia-3.0")
LoadAddOn("AceGUI-3.0-SharedMediaWidgets")
-----------------------------------------------------------------------------
@@ -40,6 +41,9 @@ LSM:Register("sound", "Fel Portal", [[Sound\Spells\Sunwell_Fel_PortalStand.wav]]
LSM:Register("sound", "Fel Nova", [[Sound\Spells\SeepingGaseous_Fel_Nova.wav]])
LSM:Register("sound", "You Will Die!", [[Sound\Creature\CThun\CThunYouWillDIe.wav]])
LSM:Register("background", "Blizzard Parchment", [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]])
LSM:Register("background", "Blizzard Parchment 2", [[Interface\AchievementFrame\UI-Achievement-Parchment]])
-----------------------------------------------------------------------------
-- Localize some global functions
@@ -64,6 +68,23 @@ local defaults = {
NumBars = 10,
CollapseHide = false,
Locked = false,
Background = {
Texture = "Blizzard Parchment",
BorderTexture = "Blizzard Dialog",
Color = {r = 1, g = 1, b = 1, a = 1,},
BorderColor = {r = 0.8, g = 0.6, b = 0, a = 1,},
Tile = false,
TileSize = 32,
EdgeSize = 8,
BarInset = 3,
},
TitleBar = {
Height = 16,
Font = "Friz Quadrata TT",
FontOutline = "",
FontColor = {r = 1, g = 1, b = 1, a = 1,},
FontSize = 10,
},
Bar = {
Texture = "Blizzard",
Height = 16,
@@ -173,7 +194,7 @@ function Omen:CreateFrames()
-- Create anchor
self.Anchor = CreateFrame("Frame", "OmenAnchor", UIParent)
self.Anchor:SetResizable(true)
self.Anchor:SetMinResize(90, 16)
self.Anchor:SetMinResize(90, db.Background.EdgeSize * 2)
self.Anchor:SetMovable(true)
self.Anchor:SetPoint("CENTER", UIParent, "CENTER")
self.Anchor:SetWidth(225)
@@ -186,18 +207,16 @@ function Omen:CreateFrames()
self.Title:SetPoint("TOPLEFT", self.Anchor, "TOPLEFT")
self.Title:SetPoint("TOPRIGHT", self.Anchor, "TOPRIGHT")
self.Title:SetHeight(16)
self.Title:SetMinResize(90, db.Background.EdgeSize * 2)
self.Title:EnableMouse(true)
self.Title:SetScript("OnMouseDown", startmoving)
self.Title:SetScript("OnMouseUp", stopmoving)
self.Title.Texture = self.Title:CreateTexture()
self.Title.Texture:SetAllPoints()
self.Title.Texture:SetTexture(0, 0, 0, 0.8)
-- Create Title text
self.TitleText = self.Title:CreateFontString(nil, nil, "GameFontNormal")
self.TitleText:SetPoint("LEFT", self.Title, "LEFT", 10, 0)
self.TitleText:SetJustifyH("LEFT")
self.TitleText:SetTextColor(1, 1, 1, 0.95)
self.TitleText:SetTextColor(1, 1, 1, 1)
self.defaultTitle = "Omen|cffffcc003|r"
self.TitleText:SetText(self.defaultTitle)
@@ -209,9 +228,6 @@ function Omen:CreateFrames()
self.BarList:SetPoint("TOPRIGHT", self.Title, "BOTTOMRIGHT")
self.BarList:SetPoint("BOTTOMLEFT", self.Anchor, "BOTTOMLEFT")
self.BarList:SetPoint("BOTTOMRIGHT", self.Anchor, "BOTTOMRIGHT")
self.BarList.Texture = self.BarList:CreateTexture()
self.BarList.Texture:SetAllPoints()
self.BarList.Texture:SetTexture(0, 0, 0, 0.8)
self.BarList:SetScript("OnMouseDown", startmoving)
self.BarList:SetScript("OnMouseUp", stopmoving)
@@ -255,6 +271,9 @@ function Omen:OnInitialize()
self:CreateFrames()
self:SetupOptions()
self:UpdateBackdrop()
self:UpdateTitleBar()
-- Register events that are "always on". The rest are in :OnEnable()
self:RegisterEvent("PLAYER_LOGIN")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
@@ -315,6 +334,8 @@ end
function Omen:OnProfileChanged(event, database, newProfileKey)
db = database.profile
self:SetAnchors(true)
self:UpdateBackdrop()
self:UpdateTitleBar()
self:ResizeBars()
self:ReAnchorBars()
self:UpdateBarLabelSettings()
@@ -388,6 +409,61 @@ function Omen:UpdateVisible()
self:Toggle(show)
end
local bgFrame = {
tile = true,
tileSize = 32,
edgeSize = 8,
insets = {left = 2, right = 2, top = 2, bottom = 2}
}
function Omen:UpdateBackdrop()
bgFrame.bgFile = LSM:Fetch("background", db.Background.Texture)
bgFrame.edgeFile = LSM:Fetch("border", db.Background.BorderTexture)
bgFrame.tile = db.Background.Tile
bgFrame.tileSize = db.Background.TileSize
bgFrame.edgeSize = db.Background.EdgeSize
local inset = floor(db.Background.EdgeSize / 4)
bgFrame.insets.left = inset
bgFrame.insets.right = inset
bgFrame.insets.top = inset
bgFrame.insets.bottom = inset
self.Title:SetBackdrop(bgFrame)
self.BarList:SetBackdrop(bgFrame)
local c = db.Background.Color
self.Title:SetBackdropColor(c.r, c.g, c.b, c.a)
self.BarList:SetBackdropColor(c.r, c.g, c.b, c.a)
c = db.Background.BorderColor
self.Title:SetBackdropBorderColor(c.r, c.g, c.b, c.a)
self.BarList:SetBackdropBorderColor(c.r, c.g, c.b, c.a)
local h = db.Background.EdgeSize * 2
self.Anchor:SetMinResize(90, h)
self.Title:SetMinResize(90, h)
if h > db.TitleBar.Height then
self.Title:SetHeight(h)
else
self.Title:SetHeight(db.TitleBar.Height)
end
self.Options.args.TitleBar.args.Height.min = h
self:ResizeBars()
self:ReAnchorBars()
self:UpdateBars()
end
function Omen:UpdateTitleBar()
local font = LSM:Fetch("font", db.TitleBar.Font)
local size = db.TitleBar.FontSize
local flags = db.TitleBar.FontOutline
local color = db.TitleBar.FontColor
self.TitleText:SetFont(font, size, flags)
self.TitleText:SetTextColor(color.r, color.g, color.b, color.a)
if db.Background.EdgeSize * 2 > db.TitleBar.Height then
self.Title:SetHeight(db.Background.EdgeSize * 2)
else
self.Title:SetHeight(db.TitleBar.Height)
end
end
-----------------------------------------------------------------------------
-- Omen bar stuff
@@ -430,12 +506,14 @@ do
local bar = CreateFrame("Frame", nil, Omen.BarList)
self[barID] = bar
bar:SetWidth(Omen.BarList:GetWidth())
bar:SetHeight(db.Bar.Height)
bar:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", 0, (barID-1) * -(db.Bar.Height + db.Bar.Spacing))
local inset = db.Background.BarInset
local inset2 = db.Background.BarInset * 2
local color = db.Bar.FontColor
bar:SetWidth(Omen.BarList:GetWidth() - inset2)
bar:SetHeight(db.Bar.Height)
bar:SetPoint("TOPLEFT", Omen.BarList, "TOPLEFT", inset, -inset + (barID-1) * -(db.Bar.Height + db.Bar.Spacing))
bar.Text1 = bar:CreateFontString(nil, nil, "GameFontNormalSmall")
bar.Text1:SetPoint("LEFT", bar, "LEFT", 5, 0)
bar.Text1:SetJustifyH("LEFT")
@@ -463,7 +541,8 @@ do
end
function Omen:ResizeBars()
local w = Omen.BarList:GetWidth()
local inset = db.Background.BarInset * 2
local w = Omen.BarList:GetWidth() - inset
for i = 1, #bars do
bars[i]:SetWidth(w)
bars[i]:SetHeight(db.Bar.Height)
@@ -471,8 +550,9 @@ function Omen:ResizeBars()
end
function Omen:ReAnchorBars()
local inset = db.Background.BarInset
for i = 1, #bars do
bars[i]:SetPoint("TOPLEFT", self.BarList, "TOPLEFT", 0, (i-1) * -(db.Bar.Height + db.Bar.Spacing))
bars[i]:SetPoint("TOPLEFT", self.BarList, "TOPLEFT", inset, -inset + (i-1) * -(db.Bar.Height + db.Bar.Spacing))
end
end
@@ -720,6 +800,15 @@ function Omen:UpdateBars()
updatethreat("mouseover", mob)
updatethreat("mouseovertarget", mob)
-- This is for testing purposes
--[[for k, v in pairs(threatTable) do
threatTable[k] = nil
end
for i = 1, 25 do
threatTable[i] = i*5000
end
tankGUID = 25]]
-- Sort the threatTable
local i = 1
for k, v in pairs(threatTable) do
@@ -739,8 +828,9 @@ function Omen:UpdateBars()
sort(sortTable, sortfunction)
-- Now update the bars on screen
local w = self.BarList:GetWidth()
local h = self.BarList:GetHeight()
local inset = db.Background.BarInset * 2
local w = self.BarList:GetWidth() - inset
local h = self.BarList:GetHeight() - inset
local topthreat = threatTable[sortTable[1]]
if topthreat == 0 then topthreat = 1 end
local tankThreat = threatTable[tankGUID or mobTargetGUID or sortTable[1]]
@@ -764,11 +854,13 @@ function Omen:UpdateBars()
end
local c = (class == "PET" and pet_color) or RAID_CLASS_COLORS[class] or default_color
bar.texture:SetVertexColor(c.r, c.g, c.b)
local width = w * threat / topthreat
if width == 0 then width = 1 end
if db.Bar.AnimateBars and self.Anchor.IsMovingOrSizing ~= 2 then
bar:AnimateTo(w * threat / topthreat)
bar:AnimateTo(width)
else
bar.texture:SetWidth(w * threat / topthreat)
end
bar.texture:SetWidth(width)
end
bar:Show()
i = i + 1
end
@@ -778,9 +870,10 @@ function Omen:UpdateBars()
bars[j]:Hide()
end
if db.Autocollapse then
self.Anchor:SetHeight((i-1)*db.Bar.Height + (i-2)*db.Bar.Spacing + 16)
self.Anchor:SetHeight((i-1)*db.Bar.Height + (i-2)*db.Bar.Spacing + 16 + inset)
end
self.Anchor:Show()
self.BarList:Show()
end
function Omen:ClearAll()
@@ -789,7 +882,8 @@ function Omen:ClearAll()
end
self.TitleText:SetText(self.defaultTitle)
if db.Autocollapse then
self.Anchor:SetHeight(16)
self.Anchor:SetHeight(self.Title:GetHeight())
self.BarList:Hide()
if db.CollapseHide and not self.Anchor.IsMovingOrSizing then
self.Anchor:Hide()
end
@@ -877,6 +971,7 @@ local options = {
order = 10,
set = function(info, value)
db.Autocollapse = value
Omen.BarList:Show()
Omen:UpdateVisible()
Omen:UpdateBars()
end,
@@ -918,6 +1013,93 @@ local options = {
},
},
},
Background = {
type = "group",
name = L["Background Options"],
guiInline = true,
order = 21,
get = function(info) return db.Background[ info[#info] ] end,
set = function(info, value)
db.Background[ info[#info] ] = value
Omen:UpdateBackdrop()
end,
args = {
Texture = {
type = "select", dialogControl = 'LSM30_Background',
order = 1,
name = L["Background Texture"],
desc = L["Texture to use for the frame's background"],
values = AceGUIWidgetLSMlists.background,
},
BorderTexture = {
type = "select", dialogControl = 'LSM30_Border',
order = 2,
name = L["Border Texture"],
desc = L["Texture to use for the frame's border"],
values = AceGUIWidgetLSMlists.border,
},
Color = {
type = "color",
order = 3,
name = L["Background Color"],
desc = L["Frame's background color"],
hasAlpha = true,
get = function(info)
local t = db.Background.Color
return t.r, t.g, t.b, t.a
end,
set = function(info, r, g, b, a)
local t = db.Background.Color
t.r, t.g, t.b, t.a = r, g, b, a
Omen:UpdateBackdrop()
end,
},
BorderColor = {
type = "color",
order = 4,
name = L["Border Color"],
desc = L["Frame's border color"],
hasAlpha = true,
get = function(info)
local t = db.Background.BorderColor
return t.r, t.g, t.b, t.a
end,
set = function(info, r, g, b, a)
local t = db.Background.BorderColor
t.r, t.g, t.b, t.a = r, g, b, a
Omen:UpdateBackdrop()
end,
},
Tile = {
type = "toggle",
order = 5,
name = L["Tile Background"],
desc = L["Tile the background texture"],
},
TileSize = {
type = "range",
order = 6,
name = L["Background Tile Size"],
desc = L["The size used to tile the background texture"],
min = 16, max = 256, step = 1,
disabled = function() return not db.Background.Tile end,
},
EdgeSize = {
type = "range",
order = 7,
name = L["Border Thickness"],
desc = L["The thickness of the border"],
min = 1, max = 16, step = 1,
},
BarInset = {
type = "range",
order = 8,
name = L["Bar Inset"],
desc = L["Sets how far inside the frame the threat bars will display from the 4 borders of the frame"],
min = 1, max = 16, step = 1,
},
},
},
},
},
ShowWhen = {
@@ -973,6 +1155,75 @@ local options = {
},
},
},
TitleBar = {
type = "group",
name = L["Title Bar Settings"],
desc = L["Title Bar Settings"],
get = function(info) return db.TitleBar[ info[#info] ] end,
set = function(info, value)
db.TitleBar[ info[#info] ] = value
Omen:UpdateTitleBar()
end,
args = {
intro = {
order = 1,
type = "description",
name = L["Configure title bar settings."],
},
Height = {
type = "range",
order = 2,
name = L["Title Bar Height"],
desc = L["Height of the title bar. The minimum height allowed is twice the background border thickness."],
min = 2, max = 32, step = 1,
},
TitleText = {
type = "group",
name = L["Title Text Options"],
guiInline = true,
order = 20,
args = {
Font = {
type = "select", dialogControl = 'LSM30_Font',
order = 1,
name = L["Font"],
desc = L["The font that the title text will use"],
values = AceGUIWidgetLSMlists.font,
},
FontOutline = {
type = "select",
order = 2,
name = L["Font Outline"],
desc = L["The outline that the title text will use"],
values = outlines,
},
FontColor = {
type = "color",
order = 3,
name = L["Font Color"],
desc = L["The color of the title text"],
hasAlpha = true,
get = function(info)
local t = db.TitleBar.FontColor
return t.r, t.g, t.b, t.a
end,
set = function(info, r, g, b, a)
local t = db.TitleBar.FontColor
t.r, t.g, t.b, t.a = r, g, b, a
Omen:UpdateTitleBar()
end,
},
FontSize = {
type = "range",
order = 4,
name = L["Font Size"],
desc = L["Control the font size of the title text"],
min = 4, max = 30, step = 1,
},
},
},
},
},
Bars = {
type = "group",
name = L["Bar Settings"],
@@ -1026,15 +1277,14 @@ local options = {
end,
},
Texture = {
type = "select",
type = "select", dialogControl = 'LSM30_Statusbar',
order = 10,
name = L["Bar Texture"],
desc = L["The texture that the bar will use"],
values = function() return LSM:List("statusbar") end,
get = function(info) return GetLSMIndex("statusbar", db.Bar.Texture) end,
values = AceGUIWidgetLSMlists.statusbar,
set = function(info, v)
db.Bar.Texture = LSM:List("statusbar")[v]
local texturepath = LSM:Fetch("statusbar", db.Bar.Texture)
db.Bar.Texture = v
local texturepath = LSM:Fetch("statusbar", v)
for i = 1, #bars do
bars[i].texture:SetTexture(texturepath)
end
@@ -1051,16 +1301,11 @@ local options = {
end,
args = {
Font = {
type = "select",
type = "select", dialogControl = 'LSM30_Font',
order = 1,
name = L["Font"],
desc = L["The font that the labels will use"],
values = function() return LSM:List("font") end,
get = function(info) return GetLSMIndex("font", db.Bar.Font) end,
set = function(info, v)
db.Bar.Font = LSM:List("font")[v]
Omen:UpdateBarLabelSettings()
end,
values = AceGUIWidgetLSMlists.font,
},
FontOutline = {
type = "select",
@@ -1138,6 +1383,7 @@ local options = {
},
},
}
Omen.Options = options
local optionsSlash = {
type = "group",
@@ -1178,6 +1424,7 @@ local optionsSlash = {
},
},
}
Omen.OptionsSlash = optionsSlash
function Omen:SetupOptions()
@@ -1193,6 +1440,7 @@ function Omen:SetupOptions()
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)