语音:修订间差异
来自卡厄思梦境WIKI
无编辑摘要 |
无编辑摘要 |
||
| 第42行: | 第42行: | ||
row:tag('td'):wikitext(voice.type) | row:tag('td'):wikitext(voice.type) | ||
-- | -- 韩语播放按钮(使用 div) | ||
local krPath = "/voice/kr/" .. characterId .. "/" .. voice.file | local krPath = "/voice/kr/" .. characterId .. "/" .. voice.file | ||
local krButton = mw.html.create('div') | |||
:addClass('voice-play-button') | |||
:attr('onclick', "VoicePlayer.play('" .. krPath .. "', this)") | |||
:wikitext('▶') | |||
row:tag('td') | row:tag('td') | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
: | :node(krButton) | ||
-- | -- 日语播放按钮(使用 div) | ||
local jpPath = "/voice/jp/" .. characterId .. "/" .. voice.file | local jpPath = "/voice/jp/" .. characterId .. "/" .. voice.file | ||
local jpButton = mw.html.create('div') | |||
:addClass('voice-play-button') | |||
:attr('onclick', "VoicePlayer.play('" .. jpPath .. "', this)") | |||
:wikitext('▶') | |||
row:tag('td') | row:tag('td') | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
: | :node(jpButton) | ||
-- 文本内容 | -- 文本内容 | ||
local | local textDiv = mw.html.create('div') | ||
:addClass('voice-text') | |||
:wikitext( | |||
(voice.text_cn or "") .. "<br>" .. | |||
(voice.text_kr or "") .. "<br>" .. | |||
row:tag('td'): | (voice.text_jp or "") | ||
) | |||
row:tag('td'):node(textDiv) | |||
end | end | ||
2025年11月8日 (六) 12:06的版本
此模块的文档可以在模块:语音/doc创建
local p = {}
function p.main(frame)
local characterName = frame.args[1] or frame:getParent().args[1]
if not characterName or characterName == "" then
return "错误:请提供战斗员名称"
end
-- 尝试加载语音数据模块
local success, voiceData = pcall(require, "模块:语音/" .. characterName)
if not success then
return "错误:未找到战斗员 " .. characterName .. " 的语音数据"
end
-- 从文件名中提取角色ID
local characterId = ""
if voiceData[1] and voiceData[1].file then
characterId = voiceData[1].file:match("vo_(%d+)_")
end
-- 引入 Widget
local widgetCode = frame:extensionTag('widget', 'VoicePlayer')
-- 创建表格
local html = mw.html.create('table')
:addClass('wikitable voice-table')
-- 表头
local headerRow = html:tag('tr')
headerRow:tag('th'):wikitext('类型'):css('width', '15%')
headerRow:tag('th'):wikitext('韩语'):css('width', '5%'):css('text-align', 'center')
headerRow:tag('th'):wikitext('日语'):css('width', '5%'):css('text-align', 'center')
headerRow:tag('th'):wikitext('文本'):css('width', '75%')
-- 数据行
for _, voice in ipairs(voiceData) do
local row = html:tag('tr')
-- 类型
row:tag('td'):wikitext(voice.type)
-- 韩语播放按钮(使用 div)
local krPath = "/voice/kr/" .. characterId .. "/" .. voice.file
local krButton = mw.html.create('div')
:addClass('voice-play-button')
:attr('onclick', "VoicePlayer.play('" .. krPath .. "', this)")
:wikitext('▶')
row:tag('td')
:css('text-align', 'center')
:node(krButton)
-- 日语播放按钮(使用 div)
local jpPath = "/voice/jp/" .. characterId .. "/" .. voice.file
local jpButton = mw.html.create('div')
:addClass('voice-play-button')
:attr('onclick', "VoicePlayer.play('" .. jpPath .. "', this)")
:wikitext('▶')
row:tag('td')
:css('text-align', 'center')
:node(jpButton)
-- 文本内容
local textDiv = mw.html.create('div')
:addClass('voice-text')
:wikitext(
(voice.text_cn or "") .. "<br>" ..
(voice.text_kr or "") .. "<br>" ..
(voice.text_jp or "")
)
row:tag('td'):node(textDiv)
end
return widgetCode .. tostring(html)
end
return p