142 lines
5.0 KiB
Lua
142 lines
5.0 KiB
Lua
SFrames.Media = {
|
|
-- Default ElvUI-like texture
|
|
-- Default ElvUI-like texture
|
|
-- Using the standard flat Vanilla UI status bar texture for a clean flat aesthetic
|
|
statusbar = "Interface\\TargetingFrame\\UI-StatusBar",
|
|
|
|
-- Fonts
|
|
-- We can use a default WoW font, or eventually load a custom one here.
|
|
font = "Fonts\\ARIALN.TTF",
|
|
fontOutline = "OUTLINE",
|
|
}
|
|
|
|
-- Built-in font choices (includes Nanami-Plates bundled fonts)
|
|
SFrames.FontChoices = {
|
|
{ key = "default", label = "默认 (ARIALN)", path = "Fonts\\ARIALN.TTF" },
|
|
{ key = "frizqt", label = "FRIZQT", path = "Fonts\\FRIZQT__.TTF" },
|
|
{ key = "morpheus", label = "Morpheus", path = "Fonts\\MORPHEUS.TTF" },
|
|
{ key = "skurri", label = "Skurri", path = "Fonts\\SKURRI.TTF" },
|
|
{ key = "np_handwrite", label = "手写DF+DB", path = "Interface\\AddOns\\Nanami-Plates\\fonts\\手写DF+DB.ttf" },
|
|
{ key = "np_pangwa", label = "胖娃方正英文数字", path = "Interface\\AddOns\\Nanami-Plates\\fonts\\胖娃方正英文数字.ttf" },
|
|
{ key = "np_yahei_star", label = "雅黑+一星球", path = "Interface\\AddOns\\Nanami-Plates\\fonts\\雅黑+一星球.ttf" },
|
|
{ key = "np_yahei_hand", label = "雅黑手写英文", path = "Interface\\AddOns\\Nanami-Plates\\fonts\\雅黑手写英文.ttf" },
|
|
}
|
|
|
|
SFrames._fontLookup = {}
|
|
for _, entry in ipairs(SFrames.FontChoices) do
|
|
SFrames._fontLookup[entry.key] = entry.path
|
|
end
|
|
|
|
function SFrames:GetSharedMedia()
|
|
if LibStub then
|
|
local ok, LSM = pcall(function() return LibStub("LibSharedMedia-3.0", true) end)
|
|
if ok and LSM then return LSM end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
SFrames.BarTextures = {
|
|
{ key = "default", label = "默认", path = "Interface\\TargetingFrame\\UI-StatusBar" },
|
|
{ key = "bar_elvui", label = "ElvUI", path = "Interface\\AddOns\\Nanami-UI\\img\\bar\\bar_elvui.tga" },
|
|
{ key = "bar_gradient", label = "渐变", path = "Interface\\AddOns\\Nanami-UI\\img\\bar\\bar_gradient.tga" },
|
|
{ key = "bar_tukui", label = "TukUI", path = "Interface\\AddOns\\Nanami-UI\\img\\bar\\bar_tukui.tga" },
|
|
{ key = "flat", label = "纯色", path = "Interface\\Buttons\\WHITE8X8" },
|
|
}
|
|
|
|
SFrames._barTextureLookup = {}
|
|
for _, entry in ipairs(SFrames.BarTextures) do
|
|
SFrames._barTextureLookup[entry.key] = entry.path
|
|
end
|
|
|
|
function SFrames:GetTexture()
|
|
if SFramesDB and SFramesDB.barTexture then
|
|
local builtin = self._barTextureLookup[SFramesDB.barTexture]
|
|
if builtin then return builtin end
|
|
|
|
local LSM = self:GetSharedMedia()
|
|
if LSM then
|
|
local path = LSM:Fetch("statusbar", SFramesDB.barTexture, true)
|
|
if path then return path end
|
|
end
|
|
end
|
|
return self.Media.statusbar
|
|
end
|
|
|
|
function SFrames:ResolveBarTexture(settingKey, fallbackKey)
|
|
local key
|
|
if SFramesDB and settingKey then
|
|
key = SFramesDB[settingKey]
|
|
end
|
|
if (not key or key == "") and SFramesDB and fallbackKey then
|
|
key = SFramesDB[fallbackKey]
|
|
end
|
|
if key and key ~= "" then
|
|
local builtin = self._barTextureLookup[key]
|
|
if builtin then return builtin end
|
|
|
|
local LSM = self:GetSharedMedia()
|
|
if LSM then
|
|
local path = LSM:Fetch("statusbar", key, true)
|
|
if path then return path end
|
|
end
|
|
end
|
|
return self:GetTexture()
|
|
end
|
|
|
|
function SFrames:GetFont()
|
|
-- 1. Check built-in font key
|
|
if SFramesDB and SFramesDB.fontKey then
|
|
local builtin = self._fontLookup[SFramesDB.fontKey]
|
|
if builtin then return builtin end
|
|
end
|
|
-- 2. Fallback: LibSharedMedia font name
|
|
if SFramesDB and SFramesDB.fontName then
|
|
local LSM = self:GetSharedMedia()
|
|
if LSM then
|
|
local path = LSM:Fetch("font", SFramesDB.fontName, true)
|
|
if path then return path end
|
|
end
|
|
end
|
|
return self.Media.font
|
|
end
|
|
|
|
function SFrames:ResolveFont(settingKey, fallbackKey)
|
|
local key
|
|
if SFramesDB and settingKey then
|
|
key = SFramesDB[settingKey]
|
|
end
|
|
if (not key or key == "") and SFramesDB and fallbackKey then
|
|
key = SFramesDB[fallbackKey]
|
|
end
|
|
if key and key ~= "" then
|
|
local builtin = self._fontLookup[key]
|
|
if builtin then return builtin end
|
|
local LSM = self:GetSharedMedia()
|
|
if LSM then
|
|
local path = LSM:Fetch("font", key, true)
|
|
if path then return path end
|
|
end
|
|
end
|
|
return self:GetFont()
|
|
end
|
|
|
|
function SFrames:ResolveFontOutline(settingKey, fallbackKey)
|
|
local outline
|
|
if SFramesDB and settingKey then
|
|
outline = SFramesDB[settingKey]
|
|
end
|
|
if (not outline or outline == "") and SFramesDB and fallbackKey then
|
|
outline = SFramesDB[fallbackKey]
|
|
end
|
|
if outline and outline ~= "" then
|
|
return outline
|
|
end
|
|
return self.Media.fontOutline or "OUTLINE"
|
|
end
|
|
|
|
function SFrames:GetSharedMediaList(mediaType)
|
|
local LSM = self:GetSharedMedia()
|
|
if LSM and LSM.List then return LSM:List(mediaType) end
|
|
return nil
|
|
end
|