◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“模块:VoiceTable”的版本间的差异
(1个标签:撤销) |
(测试 filepath 消耗) |
||
第61行: | 第61行: | ||
table.insert(res_table, "—") | table.insert(res_table, "—") | ||
else | else | ||
− | local piece_file_url = (path == "") and frame:callParserFunction{name = 'filepath:' .. piece_file} or (path .. piece_file) | + | -- local piece_file_url = (path == "") and frame:callParserFunction{name = 'filepath:' .. piece_file} or (path .. piece_file) |
+ | local piece_file_url = "" | ||
local player_args = {icon_width = '36px', src = piece_file_url} | local player_args = {icon_width = '36px', src = piece_file_url} | ||
if piece_file_url == "" then | if piece_file_url == "" then | ||
第104行: | 第105行: | ||
if piece_file ~= "" then | if piece_file ~= "" then | ||
− | local piece_file_url = frame:callParserFunction{name = 'filepath:' .. piece_file} | + | --local piece_file_url = frame:callParserFunction{name = 'filepath:' .. piece_file} |
+ | local piece_file_url = "" | ||
local player_args = {icon_width = '27px', src = piece_file_url} | local player_args = {icon_width = '27px', src = piece_file_url} | ||
if piece_file_url == "" then | if piece_file_url == "" then | ||
第136行: | 第138行: | ||
local piece_file = mw.text.trim(args["语音" .. i] or "") | local piece_file = mw.text.trim(args["语音" .. i] or "") | ||
if piece_file ~= "" then | if piece_file ~= "" then | ||
− | local piece_file_url = (path == "") and frame:callParserFunction{name = 'filepath:' .. piece_file} or (path .. piece_file) | + | -- local piece_file_url = (path == "") and frame:callParserFunction{name = 'filepath:' .. piece_file} or (path .. piece_file) |
+ | local piece_file_url = "" | ||
if piece_file_url == "" then set_args["VoiceFileLost"] = set_args["VoiceFileLost"] .. piece_file .. ", " end | if piece_file_url == "" then set_args["VoiceFileLost"] = set_args["VoiceFileLost"] .. piece_file .. ", " end | ||
end | end |
2021年10月23日 (六) 15:38的版本
- 该模块引用自mooncell 赞美R先生和友站的编辑
备注
实际使用需要参考已使用该模板的页面:分类:人形语音
该模板会生成以下三种分类: 分类:文本不全的人形语音 需要收集或听写日文语音文本 分类:语音不全的人形语音 需要上传语音文件
有信息缺失时,标题会显示为红色。
模板内每个条目:
|标题X= |日文X= |中文X= |条件X= |语音X=
- 条件X可选,放语音的开放条件,不需要加括号。其他的就算没有最好也留空。
- 换行请使用<br />
工具
local p = {} function p.table(frame) local max_pieces = 50 local args = (frame == mw.getCurrentFrame() and frame.args) or frame res_table = {} table.insert(res_table, frame:callParserFunction{name = '#Widget:MiniAudioPlayerJS'}) local playable = ((args["可播放"] or "") ~= "") local title = mw.text.trim(args["表格标题"] or "") local path = mw.text.trim(args["目录"] or "") local lack_file = false local lack_text = false local lack_tran = false local table_class = playable and "stattable voiceTable" or "stattable voiceTable mw-collapsible mw-collapsed" -- Desktop Table table.insert(res_table, string.format("\n{|class=\"%s %s\" ", table_class, "nomobile")) table.insert(res_table, "style=\"width:835px;max-width:100%;line-height:18px;text-align:center;display:table;white-space:normal;\"\n") if not playable then table.insert(res_table, string.format("|-\n! colspan=\"3\" |'''%s'''", title)) end for i = 1, max_pieces do local piece_title = mw.text.trim(args["标题" .. i] or "") local sort_title = mw.text.trim(args["分类标题" .. i] or "") if sort_title ~= "" then table.insert(res_table, string.format("\n|-\n!colspan=\"3\" style=\"height:30px; color:black;\"|'''%s'''\n", sort_title)) end if piece_title ~= "" then local piece_jp = mw.text.trim(args["日文" .. i] or "") local piece_cn = mw.text.trim(args["中文" .. i] or "") local piece_cond = mw.text.trim(args["条件" .. i] or "") local piece_file = mw.text.trim(args["语音" .. i] or "") local piece_lack_file = (piece_file == "") local piece_lack_text = (piece_jp == "" and piece_cn == "") local piece_lack_tran = (piece_jp ~= "" and piece_cn == "") local piece_lack_info = piece_lack_file or piece_lack_text or piece_lack_tran table.insert(res_table, string.format("\n|-\n!style=\"width:120px;%s\"|'''%s'''\n", (piece_lack_info and "color:#3F3F3F;" or ""), piece_title)) table.insert(res_table, "|style=\"text-align:left;\"|") if playable and piece_jp ~= "" and piece_cn ~= "" then table.insert(res_table, "<p lang=\"ja\" style=\"margin:5px;margin-bottom:10px\">" .. piece_jp .. "</p><p style=\"margin:5px;\">" .. piece_cn) elseif piece_cn ~= "" then table.insert(res_table, "<p style=\"margin:5px;\">" .. piece_cn) else table.insert(res_table, "<p lang=\"ja\" style=\"margin:5px;\">" .. piece_jp) end table.insert(res_table, ((piece_cond ~= "") and string.format("'''(%s)'''</p>", piece_cond) or "</p>")) table.insert(res_table, string.format("\n|style=\"width:%dpx;\"|", playable and 80 or 40)) if piece_file ~= "" then if piece_file == "-" then table.insert(res_table, "—") else -- local piece_file_url = (path == "") and frame:callParserFunction{name = 'filepath:' .. piece_file} or (path .. piece_file) local piece_file_url = "" local player_args = {icon_width = '36px', src = piece_file_url} if piece_file_url == "" then player_args["download_style"] = "display:none;" player_args["play_style"] = "display:none;" end if not playable then player_args["download_style"] = "display:none;" end table.insert(res_table, frame:callParserFunction{name = '#Widget:MiniAudioPlayer', args = player_args}) end end lack_file = lack_file or piece_lack_file lack_text = lack_text or piece_lack_text lack_tran = lack_tran or piece_lack_tran end end table.insert(res_table, "\n|}") -- Mobile Table table.insert(res_table, string.format("\n{|class=\"%s %s\" ", table_class, "nodesktop")) table.insert(res_table, "style=\"width:100%;line-height:18px;text-align:center;display:table;white-space:normal;font-size:unset;\"\n") if not playable then table.insert(res_table, string.format("|-\n! colspan=\"2\" |'''%s'''", title)) end for i = 1, max_pieces do local piece_title = mw.text.trim(args["标题" .. i] or "") local sort_title = mw.text.trim(args["分类标题" .. i] or "") if sort_title ~= "" then table.insert(res_table, string.format("\n|-\n!colspan=\"2\" style=\"height:30px; color:black;\"|'''%s'''\n", sort_title)) end if piece_title ~= "" then local piece_jp = mw.text.trim(args["日文" .. i] or "") local piece_cn = mw.text.trim(args["中文" .. i] or "") local piece_cond = mw.text.trim(args["条件" .. i] or "") local piece_file = mw.text.trim(args["语音" .. i] or "") table.insert(res_table, string.format("\n|-\n!'''%s'''\n", piece_title)) table.insert(res_table, string.format("\n!style=\"width:%dpx;\"|", playable and 60 or 30)) if piece_file ~= "" then --local piece_file_url = frame:callParserFunction{name = 'filepath:' .. piece_file} local piece_file_url = "" local player_args = {icon_width = '27px', src = piece_file_url} if piece_file_url == "" then player_args["download_style"] = "display:none;" player_args["play_style"] = "display:none;" end if not playable then player_args["download_style"] = "display:none;" end table.insert(res_table, frame:callParserFunction{name = '#Widget:MiniAudioPlayer', args = player_args}) end table.insert(res_table, string.format("\n|-\n|colspan=\"%d\" style=\"text-align:left;\"|", (playable and 3 or 2))) if playable and piece_jp ~= "" and piece_cn ~= "" then table.insert(res_table, "<p lang=\"ja\" style=\"margin:5px;margin-bottom:10px\">" .. piece_jp .. "</p><p style=\"margin:5px;\">" .. piece_cn) elseif piece_cn ~= "" then table.insert(res_table, "<p style=\"margin:5px;\">" .. piece_cn) else table.insert(res_table, "<p lang=\"ja\" style=\"margin:5px;\">" .. piece_jp) end table.insert(res_table, ((piece_cond ~= "") and string.format("'''(%s)'''</p>", piece_cond) or "</p>")) end end table.insert(res_table, "\n|}") if playable then local set_args = {VoiceFileLost = ""} for i = 1, max_pieces do local piece_file = mw.text.trim(args["语音" .. i] or "") if piece_file ~= "" then -- local piece_file_url = (path == "") and frame:callParserFunction{name = 'filepath:' .. piece_file} or (path .. piece_file) local piece_file_url = "" if piece_file_url == "" then set_args["VoiceFileLost"] = set_args["VoiceFileLost"] .. piece_file .. ", " end end end table.insert(res_table, frame:callParserFunction{name = '#set:', args = set_args}) local category = (string.find(frame:getParent():getTitle(), "用户:") == 1) and "用户自定义语音" or "人形语音" category = mw.text.trim(args["类别"] or category) table.insert(res_table, string.format("[[分类:%s]]", category)) if set_args["VoiceFileLost"] ~= "" then table.insert(res_table, string.format("[[分类:缺少语音文件的%s]]", category)) end if lack_file then table.insert(res_table, string.format("[[分类:语音不全的%s]]", category)) end if lack_text then table.insert(res_table, string.format("[[分类:文本不全的%s]]", category)) end end return table.concat(res_table) end return p