2015-03-25 01:38:53 -04:00
|
|
|
require "libs/TSerial"
|
|
|
|
|
|
|
|
|
|
local targetFolder = "art"
|
2015-03-25 04:42:43 -04:00
|
|
|
local reanalyzeCells = true
|
2015-03-25 01:38:53 -04:00
|
|
|
|
|
|
|
|
function getAllAssets()
|
|
|
|
|
local objectnames = {}
|
|
|
|
|
local topFolder = "art"
|
|
|
|
|
local files = love.filesystem.getDirectoryItems(topFolder)
|
|
|
|
|
for _, folder in pairs(files) do
|
|
|
|
|
if string.sub(folder, 1, 1) ~= "_" then
|
|
|
|
|
-- we ignore directories which are prepended w/ an underscore
|
|
|
|
|
if not string.find(folder, "%.") then
|
|
|
|
|
objectnames[folder] = {}
|
2015-03-25 03:58:37 -04:00
|
|
|
-- love.filesystem.createDirectory("art/" .. folder)
|
2015-03-25 01:38:53 -04:00
|
|
|
-- this is a folder, probably
|
|
|
|
|
local newFiles = love.filesystem.getDirectoryItems(topFolder .. "/" .. folder)
|
|
|
|
|
for _, fileToAnalyze in pairs(newFiles) do
|
|
|
|
|
if fileToAnalyze:find("_r.png") or fileToAnalyze:find("_g.png") or fileToAnalyze:find("_b.png")then
|
|
|
|
|
local color
|
|
|
|
|
if fileToAnalyze:find("_r.png") then color = "red"
|
|
|
|
|
elseif fileToAnalyze:find("_g.png") then color = "green"
|
|
|
|
|
elseif fileToAnalyze:find("_b.png") then color = "blue" end
|
|
|
|
|
|
|
|
|
|
local name = fileToAnalyze:sub(1, fileToAnalyze:len() - 6)
|
2015-03-25 03:58:37 -04:00
|
|
|
|
2015-03-25 04:22:10 -04:00
|
|
|
if not globalAssetProperties[name] then
|
|
|
|
|
globalAssetProperties[name] = {}
|
|
|
|
|
globalAssetProperties[name].directory = folder
|
|
|
|
|
globalAssetProperties[name].sprites = {}
|
|
|
|
|
globalAssetProperties[name].class = "unmoveable"
|
|
|
|
|
globalAssetProperties[name].preload = false
|
2015-03-25 01:38:53 -04:00
|
|
|
end
|
2015-03-25 04:42:43 -04:00
|
|
|
|
|
|
|
|
local sprite = topFolder .. "/" .. folder .. "/" .. fileToAnalyze
|
|
|
|
|
globalAssetProperties[name].sprites[color] = sprite
|
|
|
|
|
|
|
|
|
|
if not globalAssetProperties[name].cells or reanalyzeCells then
|
|
|
|
|
globalAssetProperties[name].cells = {}
|
|
|
|
|
globalAssetProperties[name].cells[color] = getCellsFromSprite(love.graphics.newImage(sprite))
|
|
|
|
|
end
|
2015-03-25 01:38:53 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-03-25 04:22:10 -04:00
|
|
|
str = TSerial.pack(globalAssetProperties, nil, true)
|
2015-03-25 03:58:37 -04:00
|
|
|
love.filesystem.write("assets.prop", str)
|
2015-03-25 04:22:10 -04:00
|
|
|
return globalAssetProperties
|
2015-03-25 01:38:53 -04:00
|
|
|
end
|