(Page créée avec « local p = {} local getLayerSize = function( data ) local width = 0 local height = #data for _, v in ipairs( data ) do width = math.max( #v, width ) end return wid... ») |
Will130 (discussion | contributions) (Annulation des modifications 254878 de Will130 (discussion)) Balise : Annulation |
||
(5 versions intermédiaires par 4 utilisateurs non affichées) | |||
Ligne 17 : | Ligne 17 : | ||
end |
end |
||
− | local blockGrid = require( [[Module: |
+ | local blockGrid = require( [[Module:GrilleSprite]] ).grid |
local keys = {} |
local keys = {} |
||
for k, v in pairs( args ) do |
for k, v in pairs( args ) do |
||
Ligne 52 : | Ligne 52 : | ||
for i, v in ipairs( layerNames ) do |
for i, v in ipairs( layerNames ) do |
||
body:wikitext( |
body:wikitext( |
||
− | f:callParserFunction( '#widget: |
+ | f:callParserFunction( '#widget:bouton radio', { |
radioClass = 'layered-blueprint-radio', |
radioClass = 'layered-blueprint-radio', |
||
labelClass = 'layered-blueprint-tab', |
labelClass = 'layered-blueprint-tab', |
Dernière version du 24 juillet 2021 à 02:09
[créer | historique | purger]Documentation
Ce module n'a pas de documentation. Si vous savez comment l'utiliser, merci de la créer.local p = {}
local getLayerSize = function( data )
local width = 0
local height = #data
for _, v in ipairs( data ) do
width = math.max( #v, width )
end
return width, height
end
p.main = function( f )
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local blockGrid = require( [[Module:GrilleSprite]] ).grid
local keys = {}
for k, v in pairs( args ) do
if type( k ) == 'string' and #k == 1 then
keys[k] = v
end
end
local layerNames = {}
local layers = {}
local width = 0
local height = 0
local scale = args.scale or 1
for _, v in ipairs( args ) do
if v:match( '%-%-%-%-' ) then
table.insert( layerNames, mw.text.trim( string.sub( v, 5 ) ) )
else
local data = mw.text.split( mw.text.trim( v, '\n' ), '\n' )
local layerWidth, layerHeight = getLayerSize( data )
width = math.max( layerWidth, width )
height = math.max( layerHeight, height )
data.keys = keys
data.scale = scale
table.insert( layers, blockGrid( data ) )
end
end
local name = args.name:gsub( ' ', '_' )
local defaultLayer = args.default
local body = mw.html.create( 'div' ):addClass( 'layered-blueprint' ):css( {
width = width * 16 * scale .. 'px',
['min-height'] = height * 16 * scale .. 'px'
} )
for i, v in ipairs( layerNames ) do
body:wikitext(
f:callParserFunction( '#widget:bouton radio', {
radioClass = 'layered-blueprint-radio',
labelClass = 'layered-blueprint-tab',
name = name,
id = name .. '-layer' .. i,
label = v,
checked = v == defaultLayer or not defaultLayer and i == 1
} )
)
body:tag( 'div' ):addClass( 'layered-blueprint-layer' ):newline():wikitext( layers[i] )
end
return body
end
return p