事件:修订间差异
来自卡厄思梦境WIKI
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local eventData = | local eventData = mw.loadData('模块:事件/data') | ||
function p.main(frame) | function p.main(frame) | ||
local | local output = mw.html.create('div') | ||
output:addClass('event-list-container') | |||
-- 添加RL模块 | |||
frame:extensionTag{ | |||
name = 'templatestyles', | |||
args = { src = 'MediaWiki:EventList.css' } | |||
} | |||
-- 遍历所有事件 | |||
for eventName, eventInfo in pairs(eventData) do | for eventName, eventInfo in pairs(eventData) do | ||
local eventDiv = p.createEventCard(eventName, eventInfo) | |||
output:node(eventDiv) | |||
end | end | ||
return tostring( | return tostring(output) | ||
end | end | ||
function p.createEventCard(eventName, eventInfo) | function p.createEventCard(eventName, eventInfo) | ||
local | local container = mw.html.create('div') | ||
:css('position', 'relative') | |||
:css('width', '375px') | |||
:css('height', '270px') | |||
:css('display', 'inline-block') | |||
:css('margin', '10px') | |||
:css('vertical-align', 'top') | |||
:attr('data-event-id', eventInfo.id) | |||
:addClass('event-card') | |||
-- | -- 底部背景 | ||
local | local bottomBg = mw.html.create('div') | ||
:css('position', 'absolute') | |||
:css('top', '160px') | |||
:css('left', '5px') | |||
:css('width', '365px') | |||
:css('height', '110px') | |||
:css('background-color', '#343434') | |||
:css('border-radius', '0px 0px 8px 8px') | |||
container:node(bottomBg) | |||
-- 图片 | -- 图片 | ||
local imageDiv = mw.html.create('div') | local imageDiv = mw.html.create('div') | ||
:css('position', 'absolute') | |||
:css('top', '0px') | |||
:css('left', '0px') | |||
:wikitext('[[File:cc_' .. eventInfo.id .. '.png|link=]]') | |||
container:node(imageDiv) | container:node(imageDiv) | ||
-- 标题背景 | -- 标题背景 | ||
local titleBg = mw.html.create('div') | local titleBg = mw.html.create('div') | ||
:css('position', 'absolute') | |||
:css('top', '135px') | |||
:css('left', '5px') | |||
:css('width', '365px') | |||
:css('height', '30px') | |||
:css('background-color', 'rgba(0,0,0,0.3)') | |||
:css('border-radius', '0px 0px 8px 8px') | |||
container:node(titleBg) | container:node(titleBg) | ||
-- | -- 标题文字 | ||
local | local titleText = mw.html.create('div') | ||
:css('position', 'absolute') | |||
:css('top', '140px') | |||
:css('left', '5px') | |||
:css('width', '365px') | |||
:css('height', '30px') | |||
:css('color', 'white') | |||
:css('text-align', 'center') | |||
:css('line-height', '30px') | |||
:wikitext(eventName) | |||
container:node(titleText) | |||
for i, | -- 选项列表 | ||
local optionCount = 0 | |||
for i, optionText in pairs(eventInfo.option) do | |||
optionCount = optionCount + 1 | |||
end | end | ||
for i = 1, optionCount do | |||
if eventInfo.option[i] then | |||
local optionDiv = mw.html.create('div') | |||
:addClass('event-option') | |||
:css('position', 'absolute') | |||
:css('top', (160 + (i-1)*35) .. 'px') | |||
:css('left', '10px') | |||
:css('width', '355px') | |||
:css('min-height', '30px') | |||
:css('color', 'white') | |||
:css('text-align', 'left') | |||
:css('padding', '5px 0px 5px 10px') | |||
:css('background-color', 'rgba(255,255,255,0.3)') | |||
:css('border-radius', '4px') | |||
:css('cursor', 'pointer') | |||
:attr('data-option-index', i) | |||
:wikitext(eventInfo.option[i]) | |||
container:node(optionDiv) | |||
-- 效果显示区域(默认隐藏) | |||
if eventInfo.effect[i] then | |||
local effectDiv = mw.html.create('div') | |||
:addClass('event-effect') | |||
:css('position', 'absolute') | |||
:css('top', (195 + (i-1)*35) .. 'px') | |||
:css('left', '10px') | |||
:css('width', '355px') | |||
:css('color', '#ffcc00') | |||
:css('text-align', 'left') | |||
:css('padding', '5px 10px') | |||
:css('background-color', 'rgba(0,0,0,0.7)') | |||
:css('border-radius', '4px') | |||
:css('font-size', '12px') | |||
:css('display', 'none') | |||
:attr('data-effect-index', i) | |||
:wikitext('→ ' .. eventInfo.effect[i]) | |||
container:node(effectDiv) | |||
end | |||
end | |||
end | end | ||
container | return container | ||
end | end | ||
return p | return p | ||
2025年10月18日 (六) 12:24的版本
此模块的文档可以在模块:事件/doc创建
local p = {}
local eventData = mw.loadData('模块:事件/data')
function p.main(frame)
local output = mw.html.create('div')
output:addClass('event-list-container')
-- 添加RL模块
frame:extensionTag{
name = 'templatestyles',
args = { src = 'MediaWiki:EventList.css' }
}
-- 遍历所有事件
for eventName, eventInfo in pairs(eventData) do
local eventDiv = p.createEventCard(eventName, eventInfo)
output:node(eventDiv)
end
return tostring(output)
end
function p.createEventCard(eventName, eventInfo)
local container = mw.html.create('div')
:css('position', 'relative')
:css('width', '375px')
:css('height', '270px')
:css('display', 'inline-block')
:css('margin', '10px')
:css('vertical-align', 'top')
:attr('data-event-id', eventInfo.id)
:addClass('event-card')
-- 底部背景
local bottomBg = mw.html.create('div')
:css('position', 'absolute')
:css('top', '160px')
:css('left', '5px')
:css('width', '365px')
:css('height', '110px')
:css('background-color', '#343434')
:css('border-radius', '0px 0px 8px 8px')
container:node(bottomBg)
-- 图片
local imageDiv = mw.html.create('div')
:css('position', 'absolute')
:css('top', '0px')
:css('left', '0px')
:wikitext('[[File:cc_' .. eventInfo.id .. '.png|link=]]')
container:node(imageDiv)
-- 标题背景
local titleBg = mw.html.create('div')
:css('position', 'absolute')
:css('top', '135px')
:css('left', '5px')
:css('width', '365px')
:css('height', '30px')
:css('background-color', 'rgba(0,0,0,0.3)')
:css('border-radius', '0px 0px 8px 8px')
container:node(titleBg)
-- 标题文字
local titleText = mw.html.create('div')
:css('position', 'absolute')
:css('top', '140px')
:css('left', '5px')
:css('width', '365px')
:css('height', '30px')
:css('color', 'white')
:css('text-align', 'center')
:css('line-height', '30px')
:wikitext(eventName)
container:node(titleText)
-- 选项列表
local optionCount = 0
for i, optionText in pairs(eventInfo.option) do
optionCount = optionCount + 1
end
for i = 1, optionCount do
if eventInfo.option[i] then
local optionDiv = mw.html.create('div')
:addClass('event-option')
:css('position', 'absolute')
:css('top', (160 + (i-1)*35) .. 'px')
:css('left', '10px')
:css('width', '355px')
:css('min-height', '30px')
:css('color', 'white')
:css('text-align', 'left')
:css('padding', '5px 0px 5px 10px')
:css('background-color', 'rgba(255,255,255,0.3)')
:css('border-radius', '4px')
:css('cursor', 'pointer')
:attr('data-option-index', i)
:wikitext(eventInfo.option[i])
container:node(optionDiv)
-- 效果显示区域(默认隐藏)
if eventInfo.effect[i] then
local effectDiv = mw.html.create('div')
:addClass('event-effect')
:css('position', 'absolute')
:css('top', (195 + (i-1)*35) .. 'px')
:css('left', '10px')
:css('width', '355px')
:css('color', '#ffcc00')
:css('text-align', 'left')
:css('padding', '5px 10px')
:css('background-color', 'rgba(0,0,0,0.7)')
:css('border-radius', '4px')
:css('font-size', '12px')
:css('display', 'none')
:attr('data-effect-index', i)
:wikitext('→ ' .. eventInfo.effect[i])
container:node(effectDiv)
end
end
end
return container
end
return p