X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/15537570216afe28cc3a04cd6a41e5fd7ba4cc7f..3dca925710d145ea5b6fc4ce1c0b230e81001305:/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua diff --git a/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua b/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua index 44f6c09..ce5ff14 100644 --- a/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua +++ b/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua @@ -1,6 +1,6 @@ ---[[ +--[[ Name: LibSharedMedia-3.0 -Revision: $Revision: 58 $ +Revision: $Revision: 91 $ Author: Elkano (elkano@gmx.de) Inspired By: SurfaceLib by Haste/Otravi (troeks@gmail.com) Website: http://www.wowace.com/projects/libsharedmedia-3-0/ @@ -9,7 +9,7 @@ Dependencies: LibStub, CallbackHandler-1.0 License: LGPL v2.1 ]] -local MAJOR, MINOR = "LibSharedMedia-3.0", 90000 + tonumber(("$Revision: 58 $"):match("(%d+)")) +local MAJOR, MINOR = "LibSharedMedia-3.0", 6010002 -- 6.1.0 v2 / increase manually on changes local lib = LibStub:NewLibrary(MAJOR, MINOR) if not lib then return end @@ -59,28 +59,69 @@ lib.MediaType.SOUND = "sound" -- sound files -- populate lib with default Blizzard data -- BACKGROUND if not lib.MediaTable.background then lib.MediaTable.background = {} end -lib.MediaTable.background["Blizzard Dialog Background"] = [[Interface\DialogFrame\UI-DialogBox-Background]] -lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]] -lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]] -lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]] -lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-Achievement-Parchment]] -lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]] -lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]] -lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]] +lib.MediaTable.background["None"] = [[]] +lib.MediaTable.background["Blizzard Collections Background"] = [[Interface\Collections\CollectionsBackgroundTile]] +lib.MediaTable.background["Blizzard Dialog Background"] = [[Interface\DialogFrame\UI-DialogBox-Background]] +lib.MediaTable.background["Blizzard Dialog Background Dark"] = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]] +lib.MediaTable.background["Blizzard Dialog Background Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]] +lib.MediaTable.background["Blizzard Garrison Background"] = [[Interface\Garrison\GarrisonUIBackground]] +lib.MediaTable.background["Blizzard Garrison Background 2"] = [[Interface\Garrison\GarrisonUIBackground2]] +lib.MediaTable.background["Blizzard Garrison Background 3"] = [[Interface\Garrison\GarrisonMissionUIInfoBoxBackgroundTile]] +lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]] +lib.MediaTable.background["Blizzard Marble"] = [[Interface\FrameGeneral\UI-Background-Marble]] +lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]] +lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]] +lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-GuildAchievement-Parchment-Horizontal]] +lib.MediaTable.background["Blizzard Rock"] = [[Interface\FrameGeneral\UI-Background-Rock]] +lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]] +lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]] +lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]] +lib.DefaultMedia.background = "None" -- BORDER if not lib.MediaTable.border then lib.MediaTable.border = {} end -lib.MediaTable.border["None"] = [[Interface\None]] +lib.MediaTable.border["None"] = [[]] lib.MediaTable.border["Blizzard Achievement Wood"] = [[Interface\AchievementFrame\UI-Achievement-WoodBorder]] lib.MediaTable.border["Blizzard Chat Bubble"] = [[Interface\Tooltips\ChatBubble-Backdrop]] lib.MediaTable.border["Blizzard Dialog"] = [[Interface\DialogFrame\UI-DialogBox-Border]] lib.MediaTable.border["Blizzard Dialog Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Border]] lib.MediaTable.border["Blizzard Party"] = [[Interface\CHARACTERFRAME\UI-Party-Border]] lib.MediaTable.border["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Border]] +lib.DefaultMedia.border = "None" -- FONT if not lib.MediaTable.font then lib.MediaTable.font = {} end local SML_MT_font = lib.MediaTable.font +--[[ +All font files are currently in all clients, the following table depicts which font supports which charset as of 5.0.4 +Fonts were checked using langcover.pl from DejaVu fonts (http://sourceforge.net/projects/dejavu/) and FontForge (http://fontforge.org/) +latin means check for: de, en, es, fr, it, pt + +file name latin koKR ruRU zhCN zhTW +2002.ttf 2002 X X X - - +2002B.ttf 2002 Bold X X X - - +ARHei.ttf AR CrystalzcuheiGBK Demibold X - X X X +ARIALN.TTF Arial Narrow X - X - - +ARKai_C.ttf AR ZhongkaiGBK Medium (Combat) X - X X X +ARKai_T.ttf AR ZhongkaiGBK Medium X - X X X +bHEI00M.ttf AR Heiti2 Medium B5 - - - - X +bHEI01B.ttf AR Heiti2 Bold B5 - - - - X +bKAI00M.ttf AR Kaiti Medium B5 - - - - X +bLEI00D.ttf AR Leisu Demi B5 - - - - X +FRIZQT__.TTF Friz Quadrata TT X - - - - +FRIZQT___CYR.TTF FrizQuadrataCTT x - X - - +K_Damage.TTF YDIWingsM - X X - - +K_Pagetext.TTF MoK X X X - - +MORPHEUS.TTF Morpheus X - - - - +MORPHEUS_CYR.TTF Morpheus X - X - - +NIM_____.ttf Nimrod MT X - X - - +SKURRI.TTF Skurri X - - - - +SKURRI_CYR.TTF Skurri X - X - - + +WARNING: Although FRIZQT___CYR is available on western clients, it doesn't support special European characters e.g. é, ï, ö +Due to this, we cannot use it as a replacement for FRIZQT__.TTF +]] + if locale == "koKR" then LOCALE_MASK = lib.LOCALE_BIT_koKR -- @@ -94,9 +135,9 @@ if locale == "koKR" then elseif locale == "zhCN" then LOCALE_MASK = lib.LOCALE_BIT_zhCN -- - SML_MT_font["伤害数字"] = [[Fonts\ZYKai_C.ttf]] - SML_MT_font["默认"] = [[Fonts\ZYKai_T.ttf]] - SML_MT_font["聊天"] = [[Fonts\ZYHei.ttf]] + SML_MT_font["伤害数字"] = [[Fonts\ARKai_C.ttf]] + SML_MT_font["默认"] = [[Fonts\ARKai_T.ttf]] + SML_MT_font["聊天"] = [[Fonts\ARHei.ttf]] -- lib.DefaultMedia["font"] = "默认" -- someone from zhCN please adjust if needed -- @@ -113,11 +154,17 @@ elseif locale == "zhTW" then elseif locale == "ruRU" then LOCALE_MASK = lib.LOCALE_BIT_ruRU -- - SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]] - SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]] - SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS.TTF]] - SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]] - SML_MT_font["Skurri"] = [[Fonts\SKURRI.TTF]] + SML_MT_font["2002"] = [[Fonts\2002.TTF]] + SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]] + SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]] + SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]] + SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]] + SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]] + SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT___CYR.TTF]] + SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]] + SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]] + SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]] + SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]] -- lib.DefaultMedia.font = "Friz Quadrata TT" -- @@ -125,10 +172,17 @@ else LOCALE_MASK = lib.LOCALE_BIT_western locale_is_western = true -- - SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]] - SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]] - SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS.TTF]] - SML_MT_font["Skurri"] = [[Fonts\SKURRI.TTF]] + SML_MT_font["2002"] = [[Fonts\2002.TTF]] + SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]] + SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]] + SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]] + SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]] + SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]] + SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]] + SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]] + SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]] + SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]] + SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]] -- lib.DefaultMedia.font = "Friz Quadrata TT" -- @@ -137,11 +191,13 @@ end -- STATUSBAR 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.DefaultMedia.statusbar = "Blizzard" -- SOUND if not lib.MediaTable.sound then lib.MediaTable.sound = {} end -lib.MediaTable.sound["None"] = [[Interface\Quiet.mp3]] -- Relies on the fact that PlaySound[File] doesn't error on non-existing input. +lib.MediaTable.sound["None"] = [[Interface\Quiet.ogg]] -- Relies on the fact that PlaySound[File] doesn't error on non-existing input. lib.DefaultMedia.sound = "None" local function rebuildMediaList(mediatype) @@ -165,8 +221,15 @@ function lib:Register(mediatype, key, data, langmask) if type(key) ~= "string" then error(MAJOR..":Register(mediatype, key, data, langmask) - key must be string, got "..type(key)) end - if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then return false 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 + 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 + return false + end + end if not mediaTable[mediatype] then mediaTable[mediatype] = {} end local mtable = mediaTable[mediatype] if mtable[key] then return false end @@ -181,8 +244,7 @@ function lib:Fetch(mediatype, key, noDefault) local mtt = mediaTable[mediatype] local overridekey = overrideMedia[mediatype] local result = mtt and ((overridekey and mtt[overridekey] or mtt[key]) or (not noDefault and defaultMedia[mediatype] and mtt[defaultMedia[mediatype]])) or nil - - return result + return result ~= "" and result or nil end function lib:IsValid(mediatype, key)