local p = {}
local function wikitext(text1)
return mw.getCurrentFrame():preprocess(text1)
end
function p.main(frame)
local width = tonumber(frame.args.width) or 480
local character = frame.args.character or ''
local class = frame.args.class or 'Ciallo'
-- 角色配置数据(使用英文键名)
local config = {
Lena = { -- 蕾娜
costumes = {
{label = "校服A", prefix = "A0", expressions = {"0_微笑","1_在意","2_害羞","3_冷眼","4_惊讶","5_得意"}},
{label = "私服A", prefix = "A1", expressions = {"0_微笑","1_在意","2_害羞","3_冷眼","4_惊讶","5_得意"}},
{label = "浴衣A", prefix = "A2", expressions = {"0_微笑","1_在意","2_害羞","3_冷眼","4_惊讶","5_得意"}},
{label = "校服B", prefix = "B0", expressions = {"0_微笑","1_在意","2_害羞","3_冷眼","4_惊讶","5_得意"}},
{label = "私服B", prefix = "B1", expressions = {"0_微笑","1_在意","2_害羞","3_冷眼","4_惊讶","5_得意"}},
{label = "浴衣B", prefix = "B2", expressions = {"0_微笑","1_在意","2_害羞","3_冷眼","4_惊讶","5_得意"}}
}
},
Yoshino = { -- 芳乃
costumes = {
{label = "校服A", prefix = "A0", expressions = {"0_微笑","1_害羞","2_冷眼","3_在意","4_生气","5_哭泣"}},
{label = "巫女姬服A", prefix = "A1", expressions = {"0_微笑","1_害羞","2_冷眼","3_在意","4_生气","5_哭泣"}},
{label = "私服A", prefix = "A2", expressions = {"0_微笑","1_害羞","2_冷眼","3_在意","4_生气","5_哭泣"}},
{label = "校服B", prefix = "B0", expressions = {"0_微笑","1_害羞","2_冷眼","3_在意","4_生气","5_哭泣"}},
{label = "巫女姬服B", prefix = "B1", expressions = {"0_微笑","1_害羞","2_冷眼","3_在意","4_生气","5_哭泣"}},
{label = "私服B", prefix = "B2", expressions = {"0_微笑","1_害羞","2_冷眼","3_在意","4_生气","5_哭泣"}}
}
},
Mako = { -- 茉子
costumes = {
{label = "校服A", prefix = "A0", expressions = {"0_微笑","1_注意","2_冷眼","3_在意","4_有趣","5_为难"}},
{label = "忍者服A", prefix = "A1", expressions = {"0_微笑","1_注意","2_冷眼","3_在意","4_有趣","5_为难"}},
{label = "私服A", prefix = "A2", expressions = {"0_微笑","1_注意","2_冷眼","3_在意","4_有趣","5_为难"}}
}
},
Murasame = { -- 丛雨
costumes = {
{label = "校服A", prefix = "A0", expressions = {"0_微笑","1_害羞","2_冷眼","3_赌气","4_在意","5_生气"}},
{label = "和服A", prefix = "A1", expressions = {"0_微笑","1_害羞","2_冷眼","3_赌气","4_在意","5_生气"}},
{label = "校服B", prefix = "B0", expressions = {"0_null","1_null","2_null","3_null","4_null","5_null"}},
{label = "和服B", prefix = "B1", expressions = {"0_null","1_null","2_null","3_null","4_null","5_null"}},
{label = "校服C", prefix = "C0", expressions = {"0_null","1_null","2_null","3_null","4_null","5_null"}},
{label = "和服C", prefix = "C1", expressions = {"0_null","1_null","2_null","3_null","4_null","5_null"}},
}
}
}
-- 角色名称映射
local charMap = {
["蕾娜"] = "Lena",
["芳乃"] = "Yoshino",
["茉子"] = "Mako",
["丛雨"] = "Murasame"
}
local charKey = charMap[character] or ""
if charKey == "" or not config[charKey] then
return "角色配置错误: " .. character
end
-- 场景数据
local scenes = {
{name = "和室", file = "场景00_和室.jpg"},
{name = "浴场", file = "场景01_浴场.jpg"},
{name = "田心屋", file = "场景02_食堂.jpg"},
{name = "道场", file = "场景03_道场.jpg"},
{name = "朝武家", file = "场景04_旅馆.jpg"},
{name = "神社", file = "场景05_神社.jpg"}
}
-- 计算尺寸
local height = math.floor(width * 1.775)
local topPos = math.floor(width * (1.775 - 1280/832))
-- 生成场景标签
local sceneTabs = {}
for i, scene in ipairs(scenes) do
table.insert(sceneTabs, string.format(
'|label%d= %s |text%d=<div style="position:absolute;width:%dpx;height:30px;top:60px;z-index:1;">[[File:千恋万花_%s|%dpx|link=]]</div>',
i, scene.name, i, width, scene.file, width
))
end
-- 生成服装标签
local costumeTabs = {}
for i, costume in ipairs(config[charKey].costumes) do
local expressions = {}
for j, expr in ipairs(costume.expressions) do
local exprWidth = math.floor(width * j / 6)
local leftWidth = math.floor(width * (j-1) / 6)
table.insert(expressions, string.format([=[
<div style="position:absolute;width:0;height:30px;left:0;z-index:%d">
{{hover|before=<div style="width:%dpx;height:30px;background:transparent;"></div>
|after=<div style="width:0;height:30px;border-left:%dpx solid transparent;border-right:%dpx solid #66ccff;"></div>
<div style="position:absolute;top:%dpx;left:0">[[File:千恋万花_%s%s%s.png|%dpx|link=]]</div>}}
</div>]=],
8 - j, exprWidth, leftWidth, math.floor(width/6), topPos,
character, costume.prefix, expr, width
))
end
-- 默认表情处理
local defaultSuffix = "微笑"
if charKey == "Murasame" and not costume.prefix:match("^A") then
defaultSuffix = "null"
end
table.insert(costumeTabs, string.format(
'|label%d= %s |text%d=<div style="display:inline-block;position:relative;width:%dpx;height:%dpx;top:30px">'..
'<div style="position:absolute;top:%dpx;width:%dpx;height:30px;z-index:1;">[[File:千恋万花_%s%s0_%s.png|%dpx]]</div>%s</div>',
i, costume.label, i, width, height, topPos, width,
character, costume.prefix, defaultSuffix,
width, table.concat(expressions)))
end
local fullheight = width*(950-60)/480+60
-- 组合最终输出
return wikitext(string.format([=[
<div class="%s" style="height:%dpx;position:relative;">
<div style="width:100%%;height:100px;position:absolute;top:0;left:0">
{{tabs/core
%s
|DefaultTab=1|LabelPadding=0|LabelBorderColor=transparent|LabelBackgroundColor=transparent|LabelColor=transparent
|TextPadding=0|TextBorderColor=transparent|TextBackgroundColor=transparent|AutoWidth=yes}}
</div>
<div style="width:100%%;height:100px;position:absolute;top:30px;left:0">
{{tabs/core
%s
|DefaultTab=1|LabelPadding=0|LabelBorderColor=transparent|LabelBackgroundColor=transparent|LabelColor=transparent
|TextPadding=0|TextBorderColor=transparent|TextBackgroundColor=transparent|AutoWidth=yes}}
</div>
</div>
]=],
class, fullheight, table.concat(sceneTabs, "\n"), table.concat(costumeTabs, "\n")))
end
return p