Compare commits

..

6 Commits

Author SHA1 Message Date
9512dcd28e Explicitly add TBC support
Some checks failed
Test Commit / create-release (push) Failing after 1m5s
2026-02-17 14:29:59 +01:00
4da5c93c02 Fix typo in default background paths 2026-02-17 14:29:13 +01:00
e461245ca6 Update formatting to use stylua 2026-02-17 14:28:20 +01:00
6a73506161 Bump version number to 0.1.1
Some checks failed
Test Commit / create-release (push) Failing after 1m0s
Create Release / create-release (push) Failing after 9s
2023-11-24 21:58:42 +01:00
999de90942 Auto format the code 2023-11-24 21:33:43 +01:00
5a3f29344b Fix compatibility issue with LibSharedMedia
It appears LibSharedMedia does not always initialize the media lists from
the media tables. To fix this we make sure the media lists match the
media tables when the table already exists upon addon initialization.
2023-11-24 21:26:25 +01:00
4 changed files with 55 additions and 37 deletions

3
.stylua.toml Normal file
View File

@@ -0,0 +1,3 @@
indent_type = "Spaces"
indent_width = 4
column_width = 120

View File

@@ -1,47 +1,49 @@
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",
["Friz Quadrata TT"] = "Fonts\\FRIZQT__.TTF",
["Morpheus"] = "Fonts\\MORPHEUS.TTF",
["Skurri"] = "Fonts\\SKURRI.TTF",
["Arial Narrow"] = "Fonts\\ARIALN.TTF",
["Friz Quadrata TT"] = "Fonts\\FRIZQT__.TTF",
["Morpheus"] = "Fonts\\MORPHEUS.TTF",
["Skurri"] = "Fonts\\SKURRI.TTF",
},
border = {
["None"] = "Interface\\None",
["Achievement Wood"] = "Interface\\AchievementFrame\\UI-Achievement-WoodBorder",
["Chat Bubble"] = "Interface\\Tooltips\\ChatBubble-Backdrop",
["Blizzard Dialog"] = "Interface\\DialogFrame\\UI-DialogBox-Border",
["Blizzard Dialog Gold"] = "Interface\\DialogFrame\\UI-DialogBox-Gold-Border",
["Blizzard Party"] = "Interface\\CHARACTERFRAME\\UI-Party-Border",
["Blizzard Tooltip"] = "Interface\\Tooltips\\UI-Tooltip-Border",
["None"] = "Interface\\None",
["Achievement Wood"] = "Interface\\AchievementFrame\\UI-Achievement-WoodBorder",
["Chat Bubble"] = "Interface\\Tooltips\\ChatBubble-Backdrop",
["Blizzard Dialog"] = "Interface\\DialogFrame\\UI-DialogBox-Border",
["Blizzard Dialog Gold"] = "Interface\\DialogFrame\\UI-DialogBox-Gold-Border",
["Blizzard Party"] = "Interface\\CHARACTERFRAME\\UI-Party-Border",
["Blizzard Tooltip"] = "Interface\\Tooltips\\UI-Tooltip-Border",
},
statusbar = {
["Blizzard"] = "Interface\\TargetingFrame\\UI-StatusBar",
["Blizzard Character Skills Bar"] = "Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar",
["Blizzard"] = "Interface\\TargetingFrame\\UI-StatusBar",
["Blizzard Character Skills Bar"] = "Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar",
},
sound = {
["None"] = "Interface\\Quiet.ogg",
["None"] = "Interface\\Quiet.ogg",
}
}
-- 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,15 +67,26 @@ 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>>
---@type table<string, table<string, any>>
lib.media = libsm.MediaTable
---@type table<string, string[]>
---@type table<string, string[]>
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

View File

@@ -1,7 +1,7 @@
## Interface: 100100
## Title: LibFreeMedia
## Notes: Freely share media between addons
## Version: 0.1.0
## Version: 0.1.1
libs/LibStub.lua
LibFreeMedia.lua

7
src/LibFreeMedia_TBC.toc Normal file
View File

@@ -0,0 +1,7 @@
## Interface: 20505
## Title: LibFreeMedia
## Notes: Freely share media between addons
## Version: 0.1.1
libs/LibStub.lua
LibFreeMedia.lua