LoveFrames/skins.lua

52 lines
1.5 KiB
Lua
Raw Normal View History

2012-05-06 00:24:42 +00:00
--[[------------------------------------------------
-- L<>VE Frames --
-- By Nikolai Resokav --
--]]------------------------------------------------
loveframes.skins = {}
loveframes.skins.available = {}
function loveframes.skins.Register(skin)
local name = skin.name
local author = skin.author
local version = skin.version
local namecheck = loveframes.skins.available[name]
local dir = loveframes.config["DIRECTORY"] .. "/skins/" ..name
local dircheck = love.filesystem.isDirectory(dir)
local images = loveframes.util.GetDirContents(dir .. "/images")
local indeximages = loveframes.config["INDEXSKINIMAGES"]
if name == "" or name == nil then
error("Could not register skin: Invalid or missing name data.")
end
if author == "" or author == nil then
error("Could not register skin: Invalid or missing author data.")
end
if version == "" or version == nil then
error("Could not register skin: Invalid or missing version data.")
end
if namecheck ~= nil then
error("Could not register skin: A skin with the name '" ..name.. "' already exists.")
end
if dircheck == false then
error("Could not register skin: Could not find a directory for skin '" ..name.. "'.")
end
loveframes.skins.available[name] = skin
loveframes.skins.available[name].dir = dir
loveframes.skins.available[name].images = {}
if #images > 0 and indeximages == true then
for k, v in ipairs(images) do
loveframes.skins.available[name].images[v.name .. "." .. v.extension] = love.graphics.newImage(v.fullpath)
end
end
end