模块:MusicTable

来自PRTS
跳到导航 跳到搜索

来源

本模块参考模块:VoiceTable修改而成

使用

使用时头部

{{#invoke:MusicTable|table|表格标题=

}}

对于中间每一项

|标题X=
|样式X=
|资源X=
  • X的范围为1-50。
  • 样式X可选,放标题的样式:
    • 非官方命名的标题请填入“非官方”。
    • 有官方命名,但与发行版有区别请填入“游戏版”。
    • Boss关卡的背景音乐请填入“Boss”。
    • 并非来自《明日方舟》的乐曲请填入“外源”。
    • 没有最好也留空。
  • 换行请使用<br>。个人意见尽量少用强制换行。
  • 资源X留空时,播放器会被替换为红色提示文字,同时生成分类:音乐文件缺失的页面

示例

{{#invoke:MusicTable|table|表格标题=[[文件:图标_战斗.png|64px|link=]] <span id="战斗"><big>战斗</big></span>
|标题1=逃亡 part2
|样式1=
|资源1=http://music.163.com/song/media/outer/url?id=1371760675.mp3

|标题2=天灾
|样式2=非官方
|资源2=https://prts.wiki/images/bgm/m_dia_calamity_combine.mp3

|标题3=病入膏肓
|样式3=非官方,Boss
|资源3=https://prts.wiki/images/bgm/m_bat_normal01_combine.mp3

|标题4=龙门作战-凌云<ref name="龙门EP">首发于明日方舟×网易云音乐SP专辑《龙门EP》。</ref>
|样式4=
|资源4=https://prts.wiki/images/bgm/m_bat_longmenbat_combine.mp3

|标题5=人性 其一
|样式5=非官方
|资源5=<!--资源名:m_dia_darkness01-->
}}
图标 战斗.png 战斗
标题 播放
逃亡 part2
逃亡 part2
天灾
天灾
BOSS
病入膏肓
BOSS
病入膏肓
龙门作战-凌云[1]
龙门作战-凌云[1]
人性 其一
人性 其一
音乐文件缺失

  1. 首发于明日方舟×网易云音乐SP专辑《龙门EP》。
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>&nbsp;"..piece_title.."&nbsp;</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>&nbsp;"..piece_title.."&nbsp;</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, frame:callParserFunction{name = '#Widget:Html5Audio', args = player_args})
			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