跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
推荐的人材
游戏数据集
势力
人材
相关网站
日文WIKI
日文MOD库
日文攻略版
创作相关
幻想迫真战记
同人图等
攻略版
视频攻略版
迫真战记中文WIKI
搜索
搜索
创建账号
登录
个人工具
创建账号
登录
未登录编辑者的页面
了解详情
贡献
讨论
编辑“
模块:Sprite
”
模块
讨论
English
阅读
编辑源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
编辑源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
ECUsam
(
讨论
|
贡献
)
2024年4月20日 (六) 16:24的版本
(
差异
)
←上一版本
|
最后版本
(
差异
) |
下一版本→
(
差异
)
警告:您正在编辑的是本页面的旧版本。
如果您发布该更改,该版本后的所有更改都会丢失。
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
local p = {} function p.base( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) else f = mw.getCurrentFrame() end local data = args.data and mw.loadData( 'Module:' .. args.data ) or {} local settings = data.settings -- Default settings local default = { scale = 1, sheetsize = 256, size = 16, pos = 1, align = 'text-top' } local defaultStyle = default if settings then if not settings.stylesheet then -- Make a separate clone of the current default settings defaultStyle = { scale = 1, sheetsize = 256, size = 16, pos = 1, align = 'text-top' } end for k, v in pairs( settings ) do default[k] = v end end setmetatable( args, { __index = default } ) local sprite = mw.html.create( 'span' ):addClass( 'sprite' ) -- mw.html's css method performs very slow escaping, which doubles the time it takes -- to run, so we'll construct the styles manually, and put them in the cssText -- method, which only does html escaping (which isn't slow) local styles = {} -- for tint local classname = args['classname'] or mw.ustring.lower( args['name'] :gsub( ' ', '-' ) ) .. '-sprite' local css_image = "background" if args['formask'] then classname = classname .. '-mask' css_image = "mask" end sprite:addClass( classname ) local class = args['class'] if class then sprite:addClass( class ) end local width = args['width'] or args['size'] local height = args['height'] or args['size'] local sheetWidth = args['sheetsize'] local tiles = sheetWidth / width local pos = args['pos'] - 1 local scale = args['scale'] local autoScale = args['autoscale'] if pos then local left = pos % tiles * width * scale local top = math.floor( pos / tiles ) * height * scale if css_image == 'mask' then styles[#styles + 1] = '-webkit-mask-position:-' .. left .. 'px -' .. top .. 'px' end styles[#styles + 1] = css_image .. '-position:-' .. left .. 'px -' .. top .. 'px' end if not autoScale and scale ~= defaultStyle.scale then if css_image == 'mask' then styles[#styles + 1] = '-webkit-mask-size:' .. sheetWidth * scale .. 'px auto' end styles[#styles + 1] = css_image .. '-size:' .. sheetWidth * scale .. 'px auto' end if height ~= defaultStyle.size or width ~= defaultStyle.size or ( not autoScale and scale ~= defaultStyle.scale ) then styles[#styles + 1] = 'height:' .. height * scale .. 'px' styles[#styles + 1] = 'width:' .. width * scale .. 'px' end local align = args['align'] if align ~= defaultStyle.align then styles[#styles + 1] = 'vertical-align:' .. align end styles[#styles + 1] = args['css'] sprite:cssText( table.concat( styles, ';' ) ) local text = args['text'] local root local spriteText if text then if not args['wrap'] then root = mw.html.create( 'span' ):addClass( 'nowrap' ) end local autolinkText if args['no-autolink'] then autolinkText = text else autolinkText = text end spriteText = mw.html.create( 'span' ):addClass( 'sprite-text' ):wikitext( autolinkText ) end local title = args['title'] if title then ( root or sprite ):attr( 'title', title ) end if not root then root = mw.html.create( '' ) end root:node( sprite ) if spriteText then root:node( spriteText ) end local link = args['link'] or '' if link ~= '' and mw.ustring.lower( link ) ~= 'none' then -- External link if link:find( '//' ) then return '[' .. link .. ' ' .. tostring( root ) .. ']' end -- Internal link Autolink.invlink( link, 'linkonly', args.data ) local linkPrefix = args['linkprefix'] or '' return '[[' .. linkPrefix .. link .. args.data .. '|' .. tostring( root ) .. ']]' end return tostring( root ) end function p.sprite( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) else f = mw.getCurrentFrame() end local data = args.data and mw.loadData( 'Module:' .. args.data ) or {} local categories = {} local idData = args.iddata if not idData then local name = args.name or data.settings.name local id = mw.text.trim( tostring( args[1] or '' ) ) idData = data.ids[id] or data.ids[mw.ustring.lower( id ):gsub( '[%s%+]', '-' )] end local title = mw.title.getCurrentTitle() -- Remove categories on language pages, talk pages, and in User/UserWiki/UserProfile namespaces local disallowCats = args.nocat or title.isTalkPage or title.nsText:find( '^User' ) if idData then if idData.deprecated then args.class = ( args.class or '' ) .. ' sprite-deprecated' if not disallowCats then categories[#categories + 1] = '[[Category:使用已弃用Sprite的页面]]' end end args.pos = idData.pos elseif not disallowCats then categories[#categories + 1] = '[[Category:含有错误Sprite的页面]]' end return p.base( args ), table.concat( categories ) end function p.link( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) end local link = args[1] if args[1] and not args.id then link = args[1]:match( '^(.-)%+' ) or args[1] end local text if not args.notext then text = args.text or args[2] or link end args[1] = args.id or args[1] args.link = args.link or link args.text = text return p.sprite( args ) end return p
摘要:
请注意您对迫真战记中文WIKI的所有贡献都被认为是在知识共享署名-非商业性使用-相同方式共享下发布,请查看在
迫真战记中文WIKI:版权
的细节。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)
本页使用的模板:
模块:Sprite/doc
(
编辑
)
开关有限宽度模式