2023年政策修订增补工作正在进行中,欢迎参与!
Module:Musictable from PRTS
跳转到导航
跳转到搜索
这个模块用于解决明日方舟音乐一览页面排版问题,原始内容来自PRTS,根据CC-BY-NC-SA 4.0引用至此
目前经过本地化调试已经可用,只是不知何种原因会在左右两侧重复填入内容,待后续研究。
使用方法
使用时头部
{{#invoke:MusicTable|table|表格标题= }}
对于中间每一项
|标题X= |样式X= |资源X=
- X的范围为1-50。
- 样式X可选,放标题的样式:
- 非官方命名的标题请填入“非官方”。
- 有官方命名,但与发行版有区别请填入“游戏版”。
- Boss关卡的背景音乐请填入“Boss”。
- 并非来自《明日方舟》的乐曲请填入“外源”。
- 没有最好也留空
- 资源X留空时,播放器会被替换为红色提示文字,同时生成分类:音乐文件缺失的页面
例如
代码为:
{{#invoke:Musictable from PRTS|table|表格标题=[[File:明日方舟_tx_system_100_mys.png|100px|link=明日方舟/音乐#罗德岛设施]] <span id="系统"><big>系统</big></span> |标题1=Rhodes Island<ref>公测开始至第十章更新前登录界面用曲。</ref> |样式1=非官方,已弃用 |资源1=[[file:m_sys_title_intro.ogg]] |标题2=Rhodes Island (2nd Edition)<ref>第十章更新后登录界面用曲。</ref> |样式2=非官方 |资源2= |标题3=生命流 |样式3= |资源3=[[File:m_sys_void_intro.ogg]] |标题4=泛用型自动化解决方案0.3.2.9f2 |样式4= |资源4=[[File:m_sys_science_intro.ogg]] }}
显示为:
系统 | ||
---|---|---|
标题 | 播放 | |
Rhodes Island (2nd Edition)[2] | Rhodes Island (2nd Edition)[2] 音乐文件缺失
| |
生命流 | 生命流
| |
泛用型自动化解决方案0.3.2.9f2 | 泛用型自动化解决方案0.3.2.9f2
|
local p = {}
function p.class()
if (mw.title.getCurrentTitle().text == "音乐鉴赏") then
local class = " mw-collapsed"
return class
end
end
function p.table(frame)
local max_pieces = 50
local args = (frame == mw.getCurrentFrame() and frame.args) or frame
res_table = {}
local title = mw.text.trim(args["表格标题"] or "")
local have_album = ((mw.text.trim(args["专辑栏"] or ""))~="")
local lack_file = false
local table_class = "wikitable mw-collapsible mw-collapsible-dark mw-collapsible-title-center"..(p.class() or '')
table.insert(res_table, string.format("\n{|class=\"%s\" ", table_class))
table.insert(res_table, "style=\"width:850px;max-width:100%;line-height:18px;text-align:center;display:table;white-space:normal;\"\n")
table.insert(res_table, string.format("!style=\"font-size:14px;\" colspan=3| %s\n", title))
table.insert(res_table, string.format("|-\n%s!class=\"nomobile\"|标题\n! width=\"450px\"|播放\n", (have_album and "!class=\"nomobile\" width=\"64px\"|专辑封面\n" or "")))
for i = 1, max_pieces do
local piece_title = mw.text.trim(args["标题" .. i] or "")
if piece_title ~= "" then
local piece_style = mw.text.trim(args["样式" .. i] or "")
local piece_file = mw.text.trim(args["资源" .. i] or "")
local piece_album = mw.text.trim(args["专辑" .. i] or "")
local piece_title_hl = ((string.find(piece_style, "非官方") or "")~="")
local piece_title_game = ((string.find(piece_style, "游戏版") or "")~="")
local piece_title_noAK = ((string.find(piece_style, "外源") or "")~="")
local piece_title_boss = ((string.find(piece_style, "Boss") or "")~="")
local piece_title_dep = ((string.find(piece_style, "已弃用") or "")~="")
local piece_title_already = ((string.find(piece_style, "旧曲") or "")~="")
local piece_lack_file = (piece_file == "")
local piece_lack_album = (piece_album == "")
if piece_title_boss then
piece_title = "<span style=\"color:white;background: linear-gradient(90deg,#c1470e,#9e2626,#5b2400);border-radius:20px;padding-left:8px;padding-right:8px\">'''BOSS'''</span><br>"..piece_title
end
table.insert(res_table, "\n|-\n")
if have_album then
if not(piece_lack_album) then
table.insert(res_table, string.format("| class=\"nomobile\"| <img width=\"64px\" src=\"%s\">\n", piece_album))
else
table.insert(res_table, "| class=\"nomobile\"| 暂无\n")
end
end
table.insert(res_table, string.format("| class=\"nomobile\" style=\"%s\"|%s\n", ((piece_title_hl and "color:#ff8f00;") or (piece_title_game and "color:#1e88e5;") or (piece_title_noAK and "color:#00897b;") or (piece_title_already and "color:#ababab;") or ""), (piece_title_dep and "<del> "..piece_title.." </del>" or piece_title)))
table.insert(res_table, string.format("|<div class=\"nodesktop\">%s%s%s</div>", ((piece_title_hl and "<span style=\"color:#ff8f00;\">") or (piece_title_game and "<span style=\"color:#1e88e5;\">") or (piece_title_noAK and "<span style=\"color:#00897b;\">") or (piece_title_already and "<span style=\"color:#ababab;\">") or ""), (piece_title_dep and "<del> "..piece_title.." </del>" or piece_title), ((piece_title_hl or piece_title_game) and "</span>" or "")))
if not(piece_lack_file) then
local player_args = {attr = 'preload="none"', src=piece_file}
table.insert(res_table,'' .. player_args.src .. '')
else
table.insert(res_table, "<span style=\"color:red;line-height:54px;\">音乐文件缺失</span>")
end
lack_file = lack_file or piece_lack_file
end
end
table.insert(res_table, "\n|}")
if lack_file then
table.insert(res_table, "[[分类:音乐文件缺失的页面]]")
end
return table.concat(res_table)
end
return p