6,354
次編輯
小 (优化代码) |
小 (修复Tempestissimo byd标记bug;修复ID设置为空报错的bug) |
||
(未顯示由 4 位使用者於中間所作的 17 次修訂) | |||
第1行: | 第1行: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local link = require('Module:Link')._link | local link = require('Module:Link')._link | ||
local getData = require("Module: | local getData = require("Module:Arcaea Data") | ||
local p = {} | local p = {} | ||
第40行: | 第40行: | ||
end | end | ||
function bydMark(byd, name) | function bydMark(byd, name, inNs) | ||
local diff, mark = mw.html.create('div'), mw.html.create('div') | local diff, mark = mw.html.create('div'), mw.html.create('div') | ||
diff:wikitext('[Beyond]') | diff:wikitext('[Beyond]') | ||
mark:wikitext('仅移动版') | mark:wikitext('仅移动版') | ||
if byd and name ~= | if byd and inNs and name ~= "Tempestissimo" | ||
then | then | ||
return tostring(tostring(diff)..tostring(mark)) | return tostring(tostring(diff)..tostring(mark)) | ||
第59行: | 第59行: | ||
end | end | ||
function getImage(id, all, pst, prs, ftr, byd, second, normalJacketArgs, bydJacketArgs, normalJacketData, bydJacketData, bydyes, | function getImage(id, all, pst, prs, ftr, byd, second, normalJacketArgs, bydJacketArgs, normalJacketData, bydJacketData, bydyes, mold, imageConfig) | ||
--谢邀,这写的什么东西我自己都看不懂了 | --谢邀,这写的什么东西我自己都看不懂了 ———Star0 | ||
if not(id or all) then return nil end | if not(id or all) then return nil end | ||
第66行: | 第66行: | ||
local tab1, tab2, tab3, part1, part2, part3, jacket1, jacket2 | local tab1, tab2, tab3, part1, part2, part3, jacket1, jacket2 | ||
container:addClass('container') | container:addClass('container') | ||
tab:attr('id', 'tab-'.. | tab:attr('id', 'tab-'..mold) tab:addClass('img-tab') | ||
local normalJacket, bydJacket | local normalJacket, bydJacket | ||
第85行: | 第85行: | ||
end | end | ||
end | end | ||
--Last判断 | |||
if id == 'last' | |||
then | |||
tab1, tab2, tab3, part1, part2, part3 = mw.html.create('div'), mw.html.create('div'), mw.html.create('div'), mw.html.create('div'), mw.html.create('div'), mw.html.create('div') | |||
tab1:wikitext('Normal') tab2:wikitext('Moment') tab3:wikitext('Eternity') | |||
tab1:addClass('img-tab-part ftr') tab2:addClass('img-tab-part byd') tab3:addClass('img-tab-part byd') | |||
tab:wikitext(tostring(tab1)) tab:wikitext(tostring(tab2)) tab:wikitext(tostring(tab3)) | |||
container:wikitext(tostring(tab)) | |||
part1:wikitext('[[文件:Songs last.jpg|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:Songs last byd.jpg|256px|none]]'..labelText('画师')..normalJacket) part3:wikitext('[[文件:Songs last byd2.jpg|256px|none]]'..labelText('画师')..normalJacket) | |||
part1:addClass('active tab-text-'..mold) part2:addClass('tab-text-'..mold) part3:addClass('tab-text-'..mold) | |||
container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) container:wikitext(tostring(part3)) | |||
return tostring(container) | |||
end | |||
if pst and prs and ftr | if pst and prs and ftr | ||
then | then | ||
第96行: | 第114行: | ||
part1:wikitext('[[文件:'..pst..'|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:'..prs..'|256px|none]]'..labelText('画师')..normalJacket) part3:wikitext('[[文件:'..ftr..'|256px|none]]'..labelText('画师')..normalJacket) | part1:wikitext('[[文件:'..pst..'|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:'..prs..'|256px|none]]'..labelText('画师')..normalJacket) part3:wikitext('[[文件:'..ftr..'|256px|none]]'..labelText('画师')..normalJacket) | ||
part1:addClass('tab-text-'.. | part1:addClass('tab-text-'..mold) part2:addClass('tab-text-'..mold) part3:addClass('active tab-text-'..mold) | ||
container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) container:wikitext(tostring(part3)) | container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) container:wikitext(tostring(part3)) | ||
第102行: | 第120行: | ||
end | end | ||
if byd | if byd and imageConfig~='nobyd' | ||
then | then | ||
tab1, tab2, part1, part2 = mw.html.create('div'), mw.html.create('div'), mw.html.create('div'), mw.html.create('div') | tab1, tab2, part1, part2 = mw.html.create('div'), mw.html.create('div'), mw.html.create('div'), mw.html.create('div') | ||
第112行: | 第130行: | ||
part1:wikitext('[[文件:'..all..'|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:'..byd..'|256px|none]]'..labelText('画师')..tostring(bydJacket)) | part1:wikitext('[[文件:'..all..'|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:'..byd..'|256px|none]]'..labelText('画师')..tostring(bydJacket)) | ||
part1:addClass('active tab-text-'.. | part1:addClass('active tab-text-'..mold) part2:addClass('tab-text-'..mold) | ||
container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) | container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) | ||
第128行: | 第146行: | ||
part1:wikitext('[[文件:'..all..'|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:'..second..'|256px|none]]'..labelText('画师')..normalJacket) | part1:wikitext('[[文件:'..all..'|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:'..second..'|256px|none]]'..labelText('画师')..normalJacket) | ||
part1:addClass('active tab-text-'.. | part1:addClass('active tab-text-'..mold) part2:addClass('tab-text-'..mold) | ||
container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) | container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) | ||
第134行: | 第152行: | ||
end | end | ||
if id and bydyes | if id and bydyes and imageConfig~='nobyd' | ||
then | then | ||
tab1, tab2, part1, part2 = mw.html.create('div'), mw.html.create('div'), mw.html.create('div'), mw.html.create('div') | tab1, tab2, part1, part2 = mw.html.create('div'), mw.html.create('div'), mw.html.create('div'), mw.html.create('div') | ||
第144行: | 第162行: | ||
part1:wikitext('[[文件:Songs '..id..'.jpg|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:Songs '..id..' byd.jpg|256px|none]]'..labelText('画师')..tostring(bydJacket)) | part1:wikitext('[[文件:Songs '..id..'.jpg|256px|none]]'..labelText('画师')..normalJacket) part2:wikitext('[[文件:Songs '..id..' byd.jpg|256px|none]]'..labelText('画师')..tostring(bydJacket)) | ||
part1:addClass('active tab-text-'.. | part1:addClass('active tab-text-'..mold) part2:addClass('tab-text-'..mold) | ||
container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) | container:wikitext(tostring(part1)) container:wikitext(tostring(part2)) | ||
第181行: | 第199行: | ||
return merge | return merge | ||
end | |||
function title(name,nameSecond,online) | |||
local result=name | |||
if nameSecond then result = result .. "<br>" .. nameSecond end | |||
if not(online) then result = result .. "<br>" .. '此曲目暂未上线' end | |||
return result | |||
end | end | ||
第190行: | 第215行: | ||
function p._main(args) | function p._main(args) | ||
local data, dataNs = getData. | -- 获取数据查找函数 | ||
local data, dataNs | |||
if args["id"] and args["id"] ~= "" | |||
then | |||
data, dataNs = getData.singleSongInformation(args['id'], "id", "mobile"), getData.singleSongInformation(args['id'], "id", "ns") | |||
elseif args["曲名"] | |||
then | |||
data, dataNs = getData.singleSongInformation(args['曲名'], "name", "mobile"), getData.singleSongInformation(args['曲名'], "name", "ns") | |||
end | |||
-- 判断曲目在哪个平台存在。 | |||
local inMobile,inNs = false, false | |||
if data("id") or args["更新时间"] then | |||
inMobile = true | |||
end | |||
if dataNs("id") or args["更新时间NS"] then | |||
inNs = true | |||
end | |||
-- 判断byd谱面是否存在;先假定NS不会有beyond等级。 | |||
local byd | local byd | ||
if args['Beyond等级'] or data('bydRating') then byd = true else byd = false end | if args['Beyond等级'] or data('bydRating') then byd = true else byd = false end | ||
-- 处理谱师参数,未填写的等级谱师向前级复制(向下兼容) | |||
local getChartDesigner = { | local getChartDesigner = { | ||
[1] = {'mobile', 'PastNote编写', 'note编写', 'pstChartDesigner'}, | [1] = | ||
[2] = {'mobile', 'PresentNote编写', 'note编写', 'prsChartDesigner'}, | {'mobile', 'PastNote编写', 'note编写', 'pstChartDesigner'}, | ||
[3] = {'mobile', 'FutureNote编写', 'note编写', 'ftrChartDesigner'}, | [2] = | ||
[4] = {'mobile', 'BeyondNote编写', 'note编写', 'bydChartDesigner'}} | {'mobile', 'PresentNote编写', 'note编写', 'prsChartDesigner'}, | ||
[3] = | |||
{'mobile', 'FutureNote编写', 'note编写', 'ftrChartDesigner'}, | |||
[4] = | |||
{'mobile', 'BeyondNote编写', 'note编写', 'bydChartDesigner'}} | |||
local chartDesigner = {} | local chartDesigner = {} | ||
第217行: | 第266行: | ||
end | end | ||
-- 依据byd是否存在处理单元格合并参数。 | |||
local span | local span | ||
if byd then | if byd then | ||
第226行: | 第276行: | ||
-- if args['曲名'] == 'Tempestissimo' then spanNs = {'grid-column-start: span 1', 'grid-column-start: span 1', 'grid-column-start: span 1', 'grid-column-start: span 1'} end | -- if args['曲名'] == 'Tempestissimo' then spanNs = {'grid-column-start: span 1', 'grid-column-start: span 1', 'grid-column-start: span 1', 'grid-column-start: span 1'} end | ||
local imageA = getImage(data('id'), args['图片'], args['Past曲绘'], args['Present曲绘'], args['Future曲绘'], args['Beyond曲绘'], args['第二曲绘图片'], args['画师'], args['Beyond画师'], data('ftrJacketDesigner'), data('bydJacketDesigner'), byd, 'a') | local imageA = getImage(data('id'), args['图片'], args['Past曲绘'], args['Present曲绘'], args['Future曲绘'], args['Beyond曲绘'], args['第二曲绘图片'], args['画师'], args['Beyond画师'], data('ftrJacketDesigner'), data('bydJacketDesigner'), byd, 'a', args['图片显示控制']) | ||
local imageB = getImage(data('id'), args['图片'], args['Past曲绘'], args['Present曲绘'], args['Future曲绘'], args['Beyond曲绘'], args['第二曲绘图片'], args['画师'], args['Beyond画师'], data('ftrJacketDesigner'), data('bydJacketDesigner'), byd, 'b') | local imageB = getImage(data('id'), args['图片'], args['Past曲绘'], args['Present曲绘'], args['Future曲绘'], args['Beyond曲绘'], args['第二曲绘图片'], args['画师'], args['Beyond画师'], data('ftrJacketDesigner'), data('bydJacketDesigner'), byd, 'b', args['图片显示控制']) | ||
-- 生成Grid表格的信息表;在后文中依据格式进行生成。 | |||
-- | |||
local infoList = { | local infoList = { | ||
[1] = { | [1] = | ||
{ title(args['曲名'] or data('title') or dataNs('title'), args['第二曲名'], data('id') or dataNs('id') or #args > 1), { id = 'title'}}, | |||
[2] = | |||
{ imageA or choice('[[文件:Songs '..tostring(data('id')) .. '.jpg|点 此 上传图片]]', data('id'), '[[文件:Songs '..tostring(dataNs('id')) .. '.jpg|点此上传图片]]', dataNs('id')), { id = 'top-image'}}, | |||
[3] = | |||
{ imageB or choice('[[文件:Songs '..tostring(data('id')) .. '.jpg|点此上传图片]]', data('id'), '[[文件:Songs '..tostring(dataNs('id')) .. '.jpg|点此上传图片]]', dataNs('id')), { id = 'right-image'}}, | |||
[4] = | |||
{ ' 曲目信息', {class = 'header'} }, | |||
[5] = | |||
{ '曲 师', { class = 'label'}}, | |||
[6] = | |||
{ args[' 编 曲'] or choice(link({'曲师', tostring(data('artist'))}) or link({'曲师', tostring(dataNs('artist'))}), data('artist') or dataNs('artist'), '', true), { class = 'data'}}, | |||
[ | [7] = | ||
{ '曲包', { class = 'label'}}, | |||
[8] = | |||
{ args['曲包'] or choice('[['..tostring(choice(getData.packName(data('set')), data('set'), getData.packName(dataNs('set')), dataNs('set')))..']]',data('set') or dataNs('set'),'',true), { class = 'data'}}, | |||
[9] = | |||
{ '时长', { class = 'label'}}, | |||
[7] = | [10] = | ||
{ args['时长'] or '空', { class = 'data'}}, | |||
[11] = | |||
[8] = { | { 'BPM', { class = 'label'}}, | ||
[12] = | |||
{ args['BPM'] or data('bpm') or dataNs('bpm'), { class = 'data'}}, | |||
[9] = { | [13] = | ||
{ '谱面信息', { class = 'header'}}, | |||
[14] = | |||
[10] = { | { '难度', { class = 'label'}}, | ||
[15] = | |||
{ '[Past]', { class = 'pst-label'}}, | |||
[11] = { | [16] = | ||
{ '[Present]', { class = 'prs-label'}}, | |||
[17] = | |||
[12] = { | { '[Future]', { class = 'ftr-label'}}, | ||
[18] = | |||
{ bydMark(byd, args['曲名'], inNs), { class = 'byd-label'}}, | |||
[13] = { | [19] = | ||
{ '等级', { class = 'label'}}, | |||
[20] = | |||
[14] = { | { args['Past等级'] or data('pstRating'), { class = 'pst-data'}}, | ||
[21] = | |||
{ args['Present等级'] or data('prsRating'), { class = 'prs-data'}}, | |||
[15] = { | [22] = | ||
{ args['Future等级'] or data('ftrRating'), { class = 'ftr-data'}}, | |||
[23] = | |||
[16] = { | { args['Beyond等级'] or data('bydRating'), { class = 'byd-data'}}, | ||
[24] = | |||
{ 'note数量', { class = 'label'}}, | |||
[17] = { | [25] = | ||
{ args['PastNote'] or '空', { class = 'pst-data'}}, | |||
[26] = | |||
[18] = { | { args['PresentNote'] or '空', { class = 'prs-data'}}, | ||
[27] = | |||
{ args['FutureNote'] or '空', {class = 'ftr-data'}}, | |||
[19] = { | [28] = | ||
{ args['BeyondNote'] or '空', { class = 'byd-data'}}, | |||
[29] = | |||
[20] = { | { '谱面设计', { class = 'label'}}, | ||
[30] = | |||
{ chartDesigner[1] or '空', { class = 'pst-data'}, span[1]}, | |||
[21] = { | [31] = | ||
{ chartDesigner[2] or '空', { class = 'prs-data'}, span[2]}, | |||
[32] = | |||
[22] = { | { chartDesigner[3] or '空', { class = 'ftr-data'}, span[3]}, | ||
[33] = | |||
{ chartDesigner[4] or '空', { class = 'byd-data'}, span[4]}, | |||
[23] = { | [34] = | ||
{ '谱面信息(Joy-Con)', { class = 'header ns', id = 'ns-play-header'}}, | |||
[35] = | |||
[24] = { | { '难度', { class = 'label ns'}}, | ||
[36] = | |||
{ '[Past]', { class = 'pst-label ns'}}, | |||
[25] = { | [37] = | ||
{ '[Present]', { class = 'prs-label ns'}}, | |||
[38] = | |||
[26] = { | { '[Future]', { class = 'ftr-label ns'}}, | ||
[39] = | |||
{ bydMark(byd, args['曲名'], inNs), { class = 'byd-label ns'}}, | |||
[27] = | [40] = | ||
args['FutureNote'] or '空', {class = 'ftr-data'}}, | { 'note数量', { class = 'label ns'}}, | ||
[28] = { | [41] = | ||
{ args['PastNoteNS'] or args['PastNote'], { class = 'pst-data ns'}}, | |||
[42] = | |||
[29] = { | { args['PresentNoteNS'] or args['PresentNote'], { class = 'prs-data ns'}}, | ||
[43] = | |||
{ args['FutureNoteNS'] or args['FutureNote'], { class = 'ftr-data ns'}}, | |||
[30] = { | [44] = | ||
{ args['BeyondNoteNS'] or '空', { class = 'byd-data ns'}}, | |||
[45] = | |||
[31] = | { '背景', { class = 'label'}}, | ||
[46] = | |||
{ bgCov(args['背景']) or bgCov(data('bg')) or bgCov(dataNs('bg')), { class = 'data' , id = 'bg-normal' }}, | |||
[32] = { | [47] = | ||
{ bgCov(args['Future背景']) , { class = 'data' , id = 'bg-ftr' }}, | |||
[48] = | |||
[33] = { | { '更新时间', { id = 'update-data-label', class = 'label'}}, | ||
[49] = | |||
{ dateCov(args['更新版本'], args['更新时间'], labelText('移动版'), 'arg') or dateCov(data('version'), tonumber(data('date')), labelText('移动版'), 'data'), { id = 'mobile-date-normal', class = 'data'}}, | |||
[34] = { | [50] = | ||
{ dateCov(args['Beyond更新版本'], args['Beyond更新时间'], labelText('移动版'), 'arg') or '空', { id = 'mobile-date-byd', class = 'data'}}, | |||
[51] = | |||
[35] = { | { dateCov(args['更新版本NS'], args['更新时间NS'], labelText('NS版'), 'arg') or dateCov(dataNs('version'), tonumber(dataNs('date')), labelText('NS版'), 'data'), { id = 'ns-date-normal', class = 'data ns'}}, | ||
[52] = | |||
{ '空', { id = 'ns-date-byd', class = 'data ns'}} | |||
[36] = { | } | ||
[37] = { | |||
[38] = { | |||
[39] = { | |||
[40] = { | |||
[41] = { | |||
[42] = { | |||
[43] = { | |||
[44] = { | |||
[45] = { | |||
[46] = { | |||
[47] = { | |||
[48] = { | |||
[ | |||
[ | |||
[ | |||
local box = mw.html.create('div') | local box = mw.html.create('div') | ||
--样式控制 | --样式控制 | ||
box:addClass(" | box:addClass("arcaeabox") | ||
if byd then box:addClass("byd") end | if byd then box:addClass("byd") end | ||
if dataNs('side') == 1 or args['侧'] == '1' then box:addClass("conflict") else box:addClass("light") end | if dataNs('side') == 1 or args['侧'] == '1' | ||
then | |||
box:addClass("conflict") | |||
else if dataNs('side') == 2 or args['侧'] == '2' then box:addClass("colorless") else box:addClass("light") end | |||
end | |||
if args['更新版本NS'] or dataNs('id') | if args['更新版本NS'] or dataNs('id') | ||
then | then | ||
第400行: | 第409行: | ||
if args['曲名'] == 'Tempestissimo' then box:addClass('ns-byd-date') box:addClass('ns-date-span') end | if args['曲名'] == 'Tempestissimo' then box:addClass('ns-byd-date') box:addClass('ns-date-span') end | ||
if not(args['更新版本'] or args['更新时间'] or data('id')) then box:addClass('no-mobile') end | if not(args['更新版本'] or args['更新时间'] or data('id')) then box:addClass('no-mobile') end | ||
if args['Future背景'] then box:addClass('bg-ftr') end | |||
--分类添加 | --分类添加 | ||
第420行: | 第430行: | ||
if not(data('id') or dataNs('id') or #args > 1) then category = category..'[[分类:未登陆的曲目]]' end | if not(data('id') or dataNs('id') or #args > 1) then category = category..'[[分类:未登陆的曲目]]' end | ||
if data('id') or dataNs('id') | if (data('id') or dataNs('id')) and not(args['unset']) | ||
then | then | ||
category = category..'[[分类:'..tostring(choice(getData. | |||
-- 如果没有更新packlist,不自动进行分类。 | |||
if choice(getData.packName(data('set')), data('set'), getData.packName(dataNs('set')), dataNs('set')) | |||
then | |||
category = category..'[[分类:'..tostring(choice(getData.packName(data('set')), data('set'), getData.packName(dataNs('set')), dataNs('set'))) .. '曲包曲目]]' | |||
end | |||
if dataNs('side') == 1 or args['侧'] == '1' | if data('side') == 1 or dataNs('side') == 1 or args['侧'] == '1' | ||
then | then | ||
category = category..'[[分类:纷争侧曲目]]' | category = category..'[[分类:纷争侧曲目]]' | ||
elseif data('side') == 0 or dataNs('side') == 0 or args['侧'] == '0' | |||
then | |||
category = category..'[[分类:光芒侧曲目]]' | |||
else | else | ||
category = category..'[[分类: 消色 侧曲目]]' | |||
end | end | ||
第455行: | 第473行: | ||
then | then | ||
noticeText = noticeText..'<li>在Songlist中无法检查到此曲目。请尝试更新[[模板:Songlist]],检查页面名或填写正确的<code>曲名</code>参数。</li>' | noticeText = noticeText..'<li>在Songlist中无法检查到此曲目。请尝试更新[[模板:Songlist]],检查页面名或填写正确的<code>曲名</code>参数。</li>' | ||
end | |||
if not(choice(getData.packName(data('set')), data('set'), getData.packName(dataNs('set')), dataNs('set'))) | |||
then | |||
noticeText = noticeText..'<li>未更新Packlist。曲目信息模板无法进行曲包分类。</li>' | |||
end | end | ||
第486行: | 第509行: | ||
if noticeText ~= '' | if noticeText ~= '' | ||
then | then | ||
notice = mw.getCurrentFrame():expandTemplate {title = 'Collapse', args = { | notice = mw.getCurrentFrame():expandTemplate {title = 'Collapse', args = { ['标题'] = '曲目信息模板提示信息', ['状态'] = '折叠', | ||
['标题文字方向'] = 'center', ['标题颜色'] = '#dddddd', | ['标题文字方向'] = 'center', ['标题颜色'] = '#dddddd', | ||
['内容颜色'] = '#eeeeee', ['内容样式'] = 'width:800px', | ['内容颜色'] = '#eeeeee', ['内容样式'] = 'width:800px', |