Bureaucrats, emailconfirmed, Interface administrators, staff, Administrators, translation-admin, translator, Widget editors
154
edits
(add "spriteSheet = " support) |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
local types = { | local types = { | ||
inventory = [[Module:InvSprite]], | inventory = [[Module:InvSprite]], | ||
gm4 = [[Module:Gm4Sprite]] | gm4 = [[Module:Gm4Sprite]], | ||
effect = [[Module:EffectSprite]] | |||
} | } | ||
Line 75: | Line 76: | ||
local size = image.width | local size = image.width | ||
o = { | o = { | ||
__source = { | __source = { | ||
settings={ | settings = {} | ||
}, | |||
__settings={ | |||
size = size, | |||
sheetsize = 1, | |||
image = image, | |||
sheetWidth = size, | |||
tiles = 1, | |||
name = name | |||
} | } | ||
} | } | ||
setmetatable(o, {__index = self}) | setmetatable(o, {__index = self}) | ||
o | setmetatable(o.__settings, {__index=defaultSettings}) | ||
return o | return o | ||
end | end | ||
Line 144: | Line 149: | ||
function append(key, value) if value ~= nil then styles[#styles+1]=key .. ": " .. value end end | function append(key, value) if value ~= nil then styles[#styles+1]=key .. ": " .. value end end | ||
local settings = self.__settings | local settings = self.__settings | ||
-- has to be done first, otherwise the possition is overriden in chrome | |||
if settings.image then | |||
append("background", settings.image.url) | |||
end | |||
append ("background-size", settings.sheetWidth * settings.scale .. 'px auto') | append ("background-size", settings.sheetWidth * settings.scale .. 'px auto') | ||
Line 157: | Line 167: | ||
local top = math.floor( pos / settings.tiles ) * settings.size * settings.scale | local top = math.floor( pos / settings.tiles ) * settings.size * settings.scale | ||
append("background-position", '-' .. left .. 'px -' .. top .. 'px') | append("background-position", '-' .. left .. 'px -' .. top .. 'px') | ||
return table.concat( styles, "; " ) | return table.concat( styles, "; " ) |
edits