2012-09-02 00:56:32 +00:00
|
|
|
--[[------------------------------------------------
|
2012-09-29 23:20:41 +00:00
|
|
|
-- Love Frames - A GUI library for LOVE --
|
|
|
|
-- Copyright (c) 2012 Kenny Shields --
|
2012-09-02 00:56:32 +00:00
|
|
|
--]]------------------------------------------------
|
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
-- skins library
|
2012-09-02 00:56:32 +00:00
|
|
|
loveframes.skins = {}
|
2012-10-22 14:19:02 +00:00
|
|
|
|
|
|
|
-- available skins
|
2012-09-02 00:56:32 +00:00
|
|
|
loveframes.skins.available = {}
|
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: Register(skin)
|
|
|
|
- desc: registers a skin
|
|
|
|
--]]---------------------------------------------------------
|
2012-09-02 00:56:32 +00:00
|
|
|
function loveframes.skins.Register(skin)
|
|
|
|
|
2012-11-20 21:04:57 +00:00
|
|
|
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.GetDirectoryContents(dir .. "/images")
|
2012-09-02 00:56:32 +00:00
|
|
|
local indeximages = loveframes.config["INDEXSKINIMAGES"]
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if name == "" or not name then
|
2012-10-22 14:19:02 +00:00
|
|
|
loveframes.util.Error("Could not register skin: Invalid or missing name data.")
|
2012-09-02 00:56:32 +00:00
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if author == "" or not author then
|
2012-10-22 14:19:02 +00:00
|
|
|
loveframes.util.Error("Could not register skin: Invalid or missing author data.")
|
2012-09-02 00:56:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if version == "" or version == nil then
|
2012-10-22 14:19:02 +00:00
|
|
|
loveframes.util.Error("Could not register skin: Invalid or missing version data.")
|
2012-09-02 00:56:32 +00:00
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if namecheck then
|
2012-10-22 14:19:02 +00:00
|
|
|
loveframes.util.Error("Could not register skin: A skin with the name '" ..name.. "' already exists.")
|
2012-09-02 00:56:32 +00:00
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not dircheck then
|
2012-10-22 14:19:02 +00:00
|
|
|
loveframes.util.Error("Could not register skin: Could not find a directory for skin '" ..name.. "'.")
|
2012-09-02 00:56:32 +00:00
|
|
|
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
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|