Module:AreaMapDisplay: Difference between revisions
From IdleOn MMO Wiki
mNo edit summary |
mNo edit summary |
||
Line 29: | Line 29: | ||
left = '0px', | left = '0px', | ||
top = '0px', | top = '0px', | ||
['z-index'] = 0, | |||
width = '808px', | width = '808px', | ||
height = '428px' | height = '428px' | ||
Line 43: | Line 43: | ||
right = '0px', | right = '0px', | ||
bottom = '0px', | bottom = '0px', | ||
['z-index'] = 1, | |||
['background-color'] = 'rgba(0, 0, 0, 0)' | |||
}) | }) | ||
Line 57: | Line 57: | ||
top = record.y .. 'px', | top = record.y .. 'px', | ||
transform = 'translate(-50%, -50%)', | transform = 'translate(-50%, -50%)', | ||
['line-height'] = '95%', | |||
['z-index'] = 2 | |||
}) | }) | ||
:wikitext('[[Worlds#' .. record.Area .. '|' .. tostring(p.createMapPoint(record.ID, record.Area, record.Size)) .. ']]') | :wikitext('[[Worlds#' .. record.Area .. '|' .. tostring(p.createMapPoint(record.ID, record.Area, record.Size)) .. ']]') | ||
Line 70: | Line 70: | ||
:css({ | :css({ | ||
display = 'inline-flex', | display = 'inline-flex', | ||
['justify-content'] = 'center', | |||
['align-items'] = 'center', | |||
width = size .. 'px', | width = size .. 'px', | ||
height = size .. 'px', | height = size .. 'px', | ||
['border-radius'] = '50%', | |||
['background-color'] = 'rgb(255, 255, 255)', | |||
border = '2px solid #000000' | border = '2px solid #000000' | ||
}) | }) | ||
Line 83: | Line 83: | ||
:css({ | :css({ | ||
color = 'rgb(0, 0, 0)', | color = 'rgb(0, 0, 0)', | ||
['font-size'] = '10px', | |||
['font-family'] = "'Helvetica', sans-serif", | |||
['font-weight'] = 'bold' | |||
}) | }) | ||
:wikitext(id) | :wikitext(id) |
Revision as of 17:03, 24 July 2024
Usage:
{{#invoke:AreaMapDisplay|map|WorldImage=Blunder Hills World Map.png}}
Lua error: Error: Table AreaMapDisplayData not found..
The data:
Special:CargoTables/AreaData (edit in Worlds)
local p = {}
local cargo = mw.ext.cargo
function p.map(frame)
local args = frame.args
local WorldImage = args.WorldImage
local results = cargo.query(
'AreaMapDisplayData',
'Area, WorldImage, x, y, Size, ID',
{where = 'WorldImage = "' .. mw.text.nowiki(WorldImage) .. '"'}
)
local root = mw.html.create('div')
:css({
position = 'relative',
left = '0px',
top = '0px',
width = '808px',
height = '428px'
})
-- ベースイメージの設定(繰り返さない)
root:tag('span')
:css({
position = 'absolute',
left = '0px',
top = '0px',
['z-index'] = 0,
width = '808px',
height = '428px'
})
:wikitext('[[File:' .. results[1].WorldImage .. '|808x428px]]')
-- 画像リンク無効化用DIV(繰り返さない)
root:tag('div')
:css({
position = 'absolute',
left = '0px',
top = '0px',
right = '0px',
bottom = '0px',
['z-index'] = 1,
['background-color'] = 'rgba(0, 0, 0, 0)'
})
-- 各エリアごとの地点を追加
for _, record in ipairs(results) do
-- リンク付きポイントを地図上に設置
root:tag('div')
:css({
position = 'absolute',
left = record.x .. 'px',
top = record.y .. 'px',
transform = 'translate(-50%, -50%)',
['line-height'] = '95%',
['z-index'] = 2
})
:wikitext('[[Worlds#' .. record.Area .. '|' .. tostring(p.createMapPoint(record.ID, record.Area, record.Size)) .. ']]')
end
return tostring(root)
end
function p.createMapPoint(id, text, size)
local innerdiv = mw.html.create('div')
:css({
display = 'inline-flex',
['justify-content'] = 'center',
['align-items'] = 'center',
width = size .. 'px',
height = size .. 'px',
['border-radius'] = '50%',
['background-color'] = 'rgb(255, 255, 255)',
border = '2px solid #000000'
})
innerdiv:tag('span')
:attr('title', text)
:css({
color = 'rgb(0, 0, 0)',
['font-size'] = '10px',
['font-family'] = "'Helvetica', sans-serif",
['font-weight'] = 'bold'
})
:wikitext(id)
return tostring(innerdiv)
end
return p