-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
47 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--@curseforge-project-slug: libsharedmedia-3-0@ | ||
--[[ | ||
Name: LibSharedMedia-3.0 | ||
Revision: $Revision: 91 $ | ||
Revision: $Revision: 151 $ | ||
Author: Elkano ([email protected]) | ||
Inspired By: SurfaceLib by Haste/Otravi ([email protected]) | ||
Website: http://www.wowace.com/projects/libsharedmedia-3-0/ | ||
|
@@ -9,7 +10,7 @@ Dependencies: LibStub, CallbackHandler-1.0 | |
License: LGPL v2.1 | ||
]] | ||
|
||
local MAJOR, MINOR = "LibSharedMedia-3.0", 6010002 -- 6.1.0 v2 / increase manually on changes | ||
local MAJOR, MINOR = "LibSharedMedia-3.0", 8020003 -- 8.2.0 v3 / increase manually on changes | ||
local lib = LibStub:NewLibrary(MAJOR, MINOR) | ||
|
||
if not lib then return end | ||
|
@@ -20,13 +21,11 @@ local pairs = _G.pairs | |
local type = _G.type | ||
|
||
local band = _G.bit.band | ||
|
||
local table_insert = _G.table.insert | ||
local table_sort = _G.table.sort | ||
|
||
local locale = GetLocale() | ||
local locale_is_western | ||
local LOCALE_MASK = 0 | ||
local LOCALE_MASK | ||
lib.LOCALE_BIT_koKR = 1 | ||
lib.LOCALE_BIT_ruRU = 2 | ||
lib.LOCALE_BIT_zhCN = 4 | ||
|
@@ -193,11 +192,12 @@ if not lib.MediaTable.statusbar then lib.MediaTable.statusbar = {} end | |
lib.MediaTable.statusbar["Blizzard"] = [[Interface\TargetingFrame\UI-StatusBar]] | ||
lib.MediaTable.statusbar["Blizzard Character Skills Bar"] = [[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]] | ||
lib.MediaTable.statusbar["Blizzard Raid Bar"] = [[Interface\RaidFrame\Raid-Bar-Hp-Fill]] | ||
lib.MediaTable.statusbar["Solid"] = [[Interface\Buttons\WHITE8X8]] | ||
lib.DefaultMedia.statusbar = "Blizzard" | ||
|
||
-- SOUND | ||
if not lib.MediaTable.sound then lib.MediaTable.sound = {} end | ||
lib.MediaTable.sound["None"] = [[Interface\Quiet.ogg]] -- Relies on the fact that PlaySound[File] doesn't error on non-existing input. | ||
lib.MediaTable.sound["None"] = 1 -- Relies on the fact that PlaySoundFile doesn't error on this value | ||
lib.DefaultMedia.sound = "None" | ||
|
||
local function rebuildMediaList(mediatype) | ||
|
@@ -222,18 +222,25 @@ function lib:Register(mediatype, key, data, langmask) | |
error(MAJOR..":Register(mediatype, key, data, langmask) - key must be string, got "..type(key)) | ||
end | ||
mediatype = mediatype:lower() | ||
if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then return false end | ||
if mediatype == lib.MediaType.SOUND and type(data) == "string" then | ||
if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then | ||
-- ignore fonts that aren't flagged as supporting local glyphs on non-western clients | ||
return false | ||
end | ||
if type(data) == "string" and (mediatype == lib.MediaType.BACKGROUND or mediatype == lib.MediaType.BORDER or mediatype == lib.MediaType.STATUSBAR or mediatype == lib.MediaType.SOUND) then | ||
local path = data:lower() | ||
-- Only ogg and mp3 are valid sounds. | ||
if not path:find(".ogg", nil, true) and not path:find(".mp3", nil, true) then | ||
if not path:find("^interface") then | ||
-- files accessed via path only allowed from interface folder | ||
return false | ||
end | ||
if mediatype == lib.MediaType.SOUND and not (path:find(".ogg", nil, true) or path:find(".mp3", nil, true)) then | ||
-- Only ogg and mp3 are valid sounds. | ||
return false | ||
end | ||
end | ||
if not mediaTable[mediatype] then mediaTable[mediatype] = {} end | ||
local mtable = mediaTable[mediatype] | ||
if mtable[key] then return false end | ||
|
||
mtable[key] = data | ||
rebuildMediaList(mediatype) | ||
self.callbacks:Fire("LibSharedMedia_Registered", mediatype, key) | ||
|