|
|
|
|
@@ -1,22 +1,23 @@
|
|
|
|
|
local lib = LibStub:NewLibrary("LibFreeMedia", 100)
|
|
|
|
|
local lib = LibStub:NewLibrary("LibFreeMedia", 101)
|
|
|
|
|
if not lib then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- stylua: ignore
|
|
|
|
|
local DEFAULT_MEDIA_TABLE = {
|
|
|
|
|
background = {
|
|
|
|
|
["Blizzard Dialog Background"] = "Interfacee\\DialogFrame\\UI-DialogBox-Background",
|
|
|
|
|
["Blizzard Dialog Background Dark"] = "Interfacee\\DialogFrame\\UI-DialogBox-Background-Dark",
|
|
|
|
|
["Blizzard Dialog Background Gold"] = "Interfacee\\DialogFrame\\UI-DialogBox-Gold-Background",
|
|
|
|
|
["Blizzard Low Health"] = "Interfacee\\FullScreenTextures\\LowHealth",
|
|
|
|
|
["Blizzard Marble"] = "Interfacee\\FrameGeneral\\UI-Background-Marble",
|
|
|
|
|
["Blizzard Out of Control"] = "Interfacee\\FullScreenTextures\\OutOfControl",
|
|
|
|
|
["Blizzard Parchment"] = "Interfacee\\AchievementFrame\\UI-Achievement-Parchment-Horizontal",
|
|
|
|
|
["Blizzard Parchment 2"] = "Interfacee\\AchievementFrame\\UI-GuildAchievement-Parchment-Horizontal",
|
|
|
|
|
["Blizzard Rock"] = "Interfacee\\FrameGeneral\\UI-Background-Rock",
|
|
|
|
|
["Blizzard Tabard Background"] = "Interfacee\\TabardFrame\\TabardFrameBackground",
|
|
|
|
|
["Blizzard Tooltip"] = "Interfacee\\Tooltips\\UI-Tooltip-Background",
|
|
|
|
|
["Solid"] = "Interfacee\\Buttons\\WHITE8X8",
|
|
|
|
|
["Blizzard Dialog Background"] = "Interface\\DialogFrame\\UI-DialogBox-Background",
|
|
|
|
|
["Blizzard Dialog Background Dark"] = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
|
|
|
|
|
["Blizzard Dialog Background Gold"] = "Interface\\DialogFrame\\UI-DialogBox-Gold-Background",
|
|
|
|
|
["Blizzard Low Health"] = "Interface\\FullScreenTextures\\LowHealth",
|
|
|
|
|
["Blizzard Marble"] = "Interface\\FrameGeneral\\UI-Background-Marble",
|
|
|
|
|
["Blizzard Out of Control"] = "Interface\\FullScreenTextures\\OutOfControl",
|
|
|
|
|
["Blizzard Parchment"] = "Interface\\AchievementFrame\\UI-Achievement-Parchment-Horizontal",
|
|
|
|
|
["Blizzard Parchment 2"] = "Interface\\AchievementFrame\\UI-GuildAchievement-Parchment-Horizontal",
|
|
|
|
|
["Blizzard Rock"] = "Interface\\FrameGeneral\\UI-Background-Rock",
|
|
|
|
|
["Blizzard Tabard Background"] = "Interface\\TabardFrame\\TabardFrameBackground",
|
|
|
|
|
["Blizzard Tooltip"] = "Interface\\Tooltips\\UI-Tooltip-Background",
|
|
|
|
|
["Solid"] = "Interface\\Buttons\\WHITE8X8",
|
|
|
|
|
},
|
|
|
|
|
font = {
|
|
|
|
|
["Arial Narrow"] = "Fonts\\ARIALN.TTF",
|
|
|
|
|
@@ -42,6 +43,7 @@ local DEFAULT_MEDIA_TABLE = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- Build default media lists from the default media table
|
|
|
|
|
local function MakeDefaultList()
|
|
|
|
|
local lists = {}
|
|
|
|
|
for kind, media in pairs(DEFAULT_MEDIA_TABLE) do
|
|
|
|
|
@@ -57,7 +59,6 @@ end
|
|
|
|
|
|
|
|
|
|
local DEFAULT_MEDIA_LIST = MakeDefaultList()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Interopability with a proprietary alternative is contained in this block
|
|
|
|
|
do
|
|
|
|
|
local libsm = LibStub:GetLibrary("LibSharedMedia-3.0", true)
|
|
|
|
|
@@ -66,6 +67,18 @@ do
|
|
|
|
|
libsm = LibStub:NewLibrary("LibSharedMedia-3.0", 0)
|
|
|
|
|
libsm.MediaTable = DEFAULT_MEDIA_TABLE
|
|
|
|
|
libsm.MediaList = DEFAULT_MEDIA_LIST
|
|
|
|
|
else
|
|
|
|
|
-- Ensure the lists match the tables if we didn't create them
|
|
|
|
|
for kind, media in pairs(libsm.MediaTable) do
|
|
|
|
|
if libsm.MediaList[kind] == nil then
|
|
|
|
|
local mediaList = {}
|
|
|
|
|
for identifier, _ in pairs(media) do
|
|
|
|
|
table.insert(mediaList, identifier)
|
|
|
|
|
end
|
|
|
|
|
table.sort(mediaList)
|
|
|
|
|
libsm.MediaList[kind] = mediaList
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
---@type table<string, table<string, any>>
|
|
|
|
|
@@ -74,7 +87,6 @@ do
|
|
|
|
|
lib.mediaList = libsm.MediaList
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param kind string The kind of media you are registering. E.g. "font" or "background"
|
|
|
|
|
---@param identifier string Named identifier for the media
|
|
|
|
|
---@param data any
|
|
|
|
|
@@ -94,11 +106,10 @@ local function RegisterOne(kind, identifier, data)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
media[identifier] = data
|
|
|
|
|
table.insert(lib.mediaList[kind], identifier)
|
|
|
|
|
table.insert(mediaList, identifier)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param kind string The kind of media you are registering. E.g. "font" or "background"
|
|
|
|
|
---@param identifier string Named identifier for the media
|
|
|
|
|
---@param data any
|
|
|
|
|
@@ -111,7 +122,6 @@ function lib:Register(kind, identifier, data)
|
|
|
|
|
return retval
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---Return the media that matches the given kind and identifier. May return nil if the media does not exist.
|
|
|
|
|
---@param kind string The kind of media you are requesting. E.g. "font" or "background"
|
|
|
|
|
---@param identifier string Named identifier for the media
|
|
|
|
|
@@ -123,7 +133,6 @@ function lib:Get(kind, identifier)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---Return a sorted list of identifiers. May return nil if there is no media of that kind.
|
|
|
|
|
---@param kind string The kind of media you are requesting. E.g. "font" or "background"
|
|
|
|
|
---@return string[] | nil
|
|
|
|
|
@@ -131,7 +140,6 @@ function lib:GetList(kind)
|
|
|
|
|
return self.mediaList[kind]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---Return a table with identifier keys and media data values
|
|
|
|
|
---@param kind string The kind of media you are requesting. E.g. "font" or "background"
|
|
|
|
|
---@return table<string,any> | nil
|
|
|
|
|
|