918
个编辑
Economy666(讨论 | 贡献) 小无编辑摘要 |
Economy666(讨论 | 贡献) 无编辑摘要 |
||
第39行: | 第39行: | ||
local function main(args, durArgs) | local function main(args, durArgs) | ||
local view = {} | local view = {} | ||
local plat = 'mobile' | -- local plat = 'mobile' | ||
-- 不对song下述提及的字段存在性做检验 | -- 不对song下述提及的字段存在性做检验 | ||
for _, song in ipairs(mad.listOf('songs', | |||
local multi_song={} | |||
local multi_id={} | |||
local mobile_id={} | |||
local ns_id={} | |||
for _, song in ipairs(mad.listOf('songs', 'mobile')) do | |||
mobile_id[song.id] = 1 | |||
multi_id[song.id] = 1 | |||
multi_song[song.id] = song | |||
end | |||
for _, song in ipairs(mad.listOf('songs', 'ns')) do | |||
ns_id[song.id] = 1 | |||
if not multi_id[song.id] then | |||
multi_id[song.id] = 1 | |||
multi_song[song.id] = song | |||
end | |||
end | |||
for _, song in pairs(multi_song) do | |||
local id = song.id | local id = song.id | ||
local function input(...) return args[table.concat({id, ...}, '.')] end | local function input(...) return args[table.concat({id, ...}, '.')] end | ||
local packItem = mad.packQueryWrap(song.set, | local packItem = mad.packQueryWrap(song.set, 'mobile') | ||
local data = setmetatable({}, {__index = table}) | local data = setmetatable({}, {__index = table}) | ||
if id ~= 'lasteternity' then | if id ~= 'lasteternity' then | ||
第52行: | 第70行: | ||
}) | }) | ||
end | end | ||
local display_plat = '' | |||
if mobile_id[song.id] then | |||
display_plat = display_plat .. '[[文件:Icon Smartphone.png|16px|link=曲目列表 (移动版)]]' | |||
end | |||
if ns_id[song.id] then | |||
display_plat = display_plat .. '[[文件:Icon Nintendo switch.png|16px|link=曲目列表 (Nintendo Switch版)]]' | |||
end | |||
if display_plat == '' then | |||
display_plat = '无' | |||
end | |||
data:insert(display_plat) | |||
data:insert(id) | data:insert(id) | ||
-- otherTitles | -- otherTitles | ||
第64行: | 第95行: | ||
data:insert((tonumber(song.bpm) ~= bpm and ('data-sort-value=%s|'):format(bpm) or '') .. song.bpm) | data:insert((tonumber(song.bpm) ~= bpm and ('data-sort-value=%s|'):format(bpm) or '') .. song.bpm) | ||
data:insert(durArgs[id] or ' @ ') | data:insert(durArgs[id] or ' @ ') | ||
data:insert(song.version .. '.' .. (input '收录版本' or verQuery(song.date))) | |||
-- diffs | -- diffs | ||
for i = 1, 4 do | for i = 1, 4 do | ||
第73行: | 第102行: | ||
end | end | ||
end | end | ||
table.sort(view, function(a, b) | table.sort(view, | ||
function(a, b) | |||
a, b = a.sort, b.sort | |||
for i = 1, 3 do | |||
local d = a[i] - b[i] | |||
if d ~= 0 then return d < 0 end | |||
end | |||
return false | |||
end) | |||
local res = {} | local res = {} | ||
local template = '|-\n|[[文件:Songs %s.jpg|75px]]' .. ('||%s'):rep( | local template = '|-\n|%s' .. '||[[文件:Songs %s.jpg|75px]]' .. ('||%s'):rep(10) | ||
for idx, value in ipairs(view) do | for idx, value in ipairs(view) do | ||
res[idx] = template:format(unpack(value.data)) | res[idx] = template:format(unpack(value.data)) |
个编辑