so we fixed up some bugs and restructured the level editor. master fiel.
This commit is contained in:
parent
01d272981e
commit
b071e117fa
3 changed files with 55 additions and 28 deletions
2
TODO
2
TODO
|
|
@ -1,5 +1,3 @@
|
||||||
FAILED lol -write ruby script to output json table for processed art
|
|
||||||
|
|
||||||
-flesh out full mythos, i.e.: where is the player, why is the player here, what is the player trying to get, who is here, what do they thin_ of the player's presence (are they happy? is the player an old face to them?)
|
-flesh out full mythos, i.e.: where is the player, why is the player here, what is the player trying to get, who is here, what do they thin_ of the player's presence (are they happy? is the player an old face to them?)
|
||||||
-decide on dialog trees
|
-decide on dialog trees
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ local gameAssets = getAllAssets()
|
||||||
local inputText = ""
|
local inputText = ""
|
||||||
local assetProperties = {}
|
local assetProperties = {}
|
||||||
|
|
||||||
|
local hierarchy = {}
|
||||||
|
|
||||||
local activeField = nil --this is for whenwe are doing text input things
|
local activeField = nil --this is for whenwe are doing text input things
|
||||||
|
|
||||||
local uiButtons = {}
|
local uiButtons = {}
|
||||||
|
|
@ -33,7 +35,15 @@ function _initLevelEditor()
|
||||||
|
|
||||||
--create folder buttons
|
--create folder buttons
|
||||||
local counter = 1
|
local counter = 1
|
||||||
for folder, object in pairs(gameAssets) do
|
|
||||||
|
for asset, attributes in pairs(gameAssets) do
|
||||||
|
if not hierarchy[gameAssets[asset].directory] then
|
||||||
|
hierarchy[gameAssets[asset].directory] = {}
|
||||||
|
end
|
||||||
|
table.insert(hierarchy[gameAssets[asset].directory], asset)
|
||||||
|
end
|
||||||
|
|
||||||
|
for folder, object in pairs(hierarchy) do
|
||||||
local button = createUIElement{
|
local button = createUIElement{
|
||||||
name = "folder",
|
name = "folder",
|
||||||
text = folder,
|
text = folder,
|
||||||
|
|
@ -137,7 +147,7 @@ function selectFolder(folder)
|
||||||
local counter = 1
|
local counter = 1
|
||||||
local limit = 10
|
local limit = 10
|
||||||
|
|
||||||
for asset, colorArray in pairs(gameAssets[selectedFolder]) do
|
for _, asset in pairs(hierarchy[selectedFolder]) do
|
||||||
if counter % limit == 0 then
|
if counter % limit == 0 then
|
||||||
counter = 1
|
counter = 1
|
||||||
|
|
||||||
|
|
@ -163,7 +173,7 @@ function selectFolder(folder)
|
||||||
|
|
||||||
local sprites = {}
|
local sprites = {}
|
||||||
|
|
||||||
for color, location in pairs(colorArray) do
|
for color, location in pairs(gameAssets[asset].sprites) do
|
||||||
sprites[color] = love.graphics.newImage(location)
|
sprites[color] = love.graphics.newImage(location)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -195,18 +205,12 @@ function selectAsset(asset)
|
||||||
end
|
end
|
||||||
|
|
||||||
function editAsset(asset)
|
function editAsset(asset)
|
||||||
assetProperties = {
|
|
||||||
class = "",
|
|
||||||
}
|
|
||||||
|
|
||||||
inputText = ""
|
inputText = ""
|
||||||
editorView = "asset"
|
editorView = "asset"
|
||||||
selectedAsset = asset
|
selectedAsset = asset
|
||||||
|
|
||||||
local filename = "art/" .. selectedFolder .. "/" .. selectedAsset .. ".prop"
|
assetProperties = gameAssets[selectedAsset]
|
||||||
if love.filesystem.exists(filename) then
|
|
||||||
assetProperties = TSerial.unpack(love.filesystem.read(filename))
|
|
||||||
end
|
|
||||||
|
|
||||||
local cancelButton = createUIElement{
|
local cancelButton = createUIElement{
|
||||||
name = "cancel",
|
name = "cancel",
|
||||||
|
|
@ -237,9 +241,8 @@ function editAsset(asset)
|
||||||
editingAssetButtons[cancelButton] = cancelButton
|
editingAssetButtons[cancelButton] = cancelButton
|
||||||
editingAssetButtons[confirmButton] = confirmButton
|
editingAssetButtons[confirmButton] = confirmButton
|
||||||
|
|
||||||
|
|
||||||
local assetSprites = {}
|
local assetSprites = {}
|
||||||
for color, path in pairs(gameAssets[selectedFolder][selectedAsset]) do
|
for color, path in pairs(assetProperties.sprites) do
|
||||||
assetSprites[color] = love.graphics.newImage(path)
|
assetSprites[color] = love.graphics.newImage(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -268,14 +271,34 @@ function editAsset(asset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local preloadLabel = {
|
||||||
|
draw = function() love.graphics.printf("preload", 0, 225, sideBarBox.w, "center") end
|
||||||
|
}
|
||||||
|
|
||||||
|
labels[preloadLabel] = preloadLabel
|
||||||
|
|
||||||
|
local preloadButton = createUIElement{
|
||||||
|
name = "preload",
|
||||||
|
text = tostring(assetProperties.preload),
|
||||||
|
x = 25,
|
||||||
|
y = 250,
|
||||||
|
onClic = {
|
||||||
|
left = function()
|
||||||
|
assetProperties.preload = not assetProperties.preload
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editingAssetButtons[assetButton] = assetButton
|
editingAssetButtons[assetButton] = assetButton
|
||||||
editingAssetButtons.class = classButton
|
editingAssetButtons.class = classButton
|
||||||
|
editingAssetButtons.preload = preloadButton
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function saveAsset()
|
function saveAsset()
|
||||||
local save = TSerial.pack(assetProperties, nil, true)
|
gameAssets[selectedAsset] = assetProperties
|
||||||
diditdoit = love.filesystem.write("art/" .. selectedFolder .. "/" .. selectedAsset .. ".prop", save)
|
local save = TSerial.pack(gameAssets, nil, true)
|
||||||
print("fdfdfdfd", diditdoit)
|
love.filesystem.write("assets.prop", save)
|
||||||
assetsView()
|
assetsView()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -350,8 +373,9 @@ end
|
||||||
function editorCompleteResponse()
|
function editorCompleteResponse()
|
||||||
if editorView == "asset" then
|
if editorView == "asset" then
|
||||||
assetProperties[activeField] = inputText
|
assetProperties[activeField] = inputText
|
||||||
|
print(assetProperties[activeField], "BLELERLLLRLRLRR")
|
||||||
end
|
end
|
||||||
print(assetProperties[activeField], "ass")
|
print(activeField, assetProperties[activeField], "ass")
|
||||||
activeField = nil
|
activeField = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ function get(folder)
|
||||||
end
|
end
|
||||||
|
|
||||||
function getAllAssets()
|
function getAllAssets()
|
||||||
|
local properties = TSerial.unpack(love.filesystem.read("assets.prop") or "{}")
|
||||||
local objectnames = {}
|
local objectnames = {}
|
||||||
local topFolder = "art"
|
local topFolder = "art"
|
||||||
local files = love.filesystem.getDirectoryItems(topFolder)
|
local files = love.filesystem.getDirectoryItems(topFolder)
|
||||||
|
|
@ -15,29 +16,33 @@ function getAllAssets()
|
||||||
-- we ignore directories which are prepended w/ an underscore
|
-- we ignore directories which are prepended w/ an underscore
|
||||||
if not string.find(folder, "%.") then
|
if not string.find(folder, "%.") then
|
||||||
objectnames[folder] = {}
|
objectnames[folder] = {}
|
||||||
love.filesystem.createDirectory("art/" .. folder)
|
-- love.filesystem.createDirectory("art/" .. folder)
|
||||||
-- this is a folder, probably
|
-- this is a folder, probably
|
||||||
local newFiles = love.filesystem.getDirectoryItems(topFolder .. "/" .. folder)
|
local newFiles = love.filesystem.getDirectoryItems(topFolder .. "/" .. folder)
|
||||||
for _, fileToAnalyze in pairs(newFiles) do
|
for _, fileToAnalyze in pairs(newFiles) do
|
||||||
if fileToAnalyze:find("_r.png") or fileToAnalyze:find("_g.png") or fileToAnalyze:find("_b.png")then
|
if fileToAnalyze:find("_r.png") or fileToAnalyze:find("_g.png") or fileToAnalyze:find("_b.png")then
|
||||||
local color
|
local color
|
||||||
|
|
||||||
if fileToAnalyze:find("_r.png") then color = "red"
|
if fileToAnalyze:find("_r.png") then color = "red"
|
||||||
elseif fileToAnalyze:find("_g.png") then color = "green"
|
elseif fileToAnalyze:find("_g.png") then color = "green"
|
||||||
elseif fileToAnalyze:find("_b.png") then color = "blue" end
|
elseif fileToAnalyze:find("_b.png") then color = "blue" end
|
||||||
|
|
||||||
local name = fileToAnalyze:sub(1, fileToAnalyze:len() - 6)
|
local name = fileToAnalyze:sub(1, fileToAnalyze:len() - 6)
|
||||||
if not objectnames[folder][name] then
|
|
||||||
objectnames[folder][name] = {}
|
if not properties[name] then
|
||||||
|
properties[name] = {}
|
||||||
|
properties[name].directory = folder
|
||||||
|
properties[name].sprites = {}
|
||||||
|
properties[name].class = "unmoveable"
|
||||||
|
properties[name].preload = false
|
||||||
end
|
end
|
||||||
objectnames[folder][name][color] = topFolder .. "/" .. folder .. "/" .. fileToAnalyze
|
properties[name].sprites[color] = topFolder .. "/" .. folder .. "/" .. fileToAnalyze
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
str = TSerial.pack(objectnames, nil, true)
|
str = TSerial.pack(properties, nil, true)
|
||||||
love.filesystem.write("great.sav", str)
|
love.filesystem.write("assets.prop", str)
|
||||||
return objectnames
|
return properties
|
||||||
end
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue