forked from eledot/LoveFrames
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skins.lua
68 lines (53 loc) · 2.09 KB
/
skins.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2013 Kenny Shields --
--]]------------------------------------------------
-- skins library
loveframes.skins = {}
-- available skins
loveframes.skins.available = {}
--[[---------------------------------------------------------
- func: Register(skin)
- desc: registers a skin
--]]---------------------------------------------------------
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.GetDirectoryContents(dir .. "/images")
local indeximages = loveframes.config["INDEXSKINIMAGES"]
if name == "" or not name then
loveframes.util.Error("Could not register skin: Invalid or missing name data.")
end
if author == "" or not author then
loveframes.util.Error("Could not register skin: Invalid or missing author data.")
end
if version == "" or not version then
loveframes.util.Error("Could not register skin: Invalid or missing version data.")
end
if namecheck then
loveframes.util.Error("Could not register skin: A skin with the name '" ..name.. "' already exists.")
end
if not dircheck then
loveframes.util.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 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
--[[---------------------------------------------------------
- func: GetAvailable()
- desc: gets all available skins
--]]---------------------------------------------------------
function loveframes.skins.GetAvailable()
local available = loveframes.skins.available
return available
end