Commit 0134b2ab by Phil Hagelberg

Save width and height of characters.

1 parent 4e1074da
Showing with 8 additions and 7 deletions
......@@ -17,8 +17,8 @@ end
local is_on_edge = function(card, ch)
if(ch.y <= 0) then return "top"
elseif(ch.x <= 0) then return "left"
elseif(ch.y + ch.h > card.stack_meta.h) then return "bottom"
elseif(ch.x + ch.w > card.stack_meta.w) then return "right" end
elseif(ch.y + (ch.h or 32) > card.stack_meta.h) then return "bottom"
elseif(ch.x + (ch.w or 32) > card.stack_meta.w) then return "right" end
end
local event_handler = function(event)
......
......@@ -3,7 +3,8 @@ local card = require("card")
local fields = {"name", "buttons", "image_file", "code", "type", "meta"}
local button_fields = {"label", "code", "meta", "x", "y", "w", "h", "type",
"bg", "color"}
local character_fields = {"name", "code", "meta", "x", "y", "type", "costume"}
local character_fields = {"name", "code", "meta", "x", "y", "w", "h",
"type", "costume"}
-- Heads up! This module is stateful.
......@@ -32,10 +33,10 @@ local state = function(c)
return lume.serialize(s)
end
local save = function(undoing, save_card)
local save = function(undoing, save_card, force)
local c = save_card or card.current()
if(c.image_changed) then c.image_file = c.name..".png" end
if(c.changed) then
if(c.image_changed or force) then c.image_file = c.name..".png" end
if(c.changed or force) then
love.filesystem.write(c.stack_meta.dir .. "/" .. c.name .. ".lua",
"return " .. state(c))
c.changed = false
......@@ -44,7 +45,7 @@ local save = function(undoing, save_card)
push(pre_state)
end
end
if(c.image_changed) then
if(c.image_changed or force) then
local data = c.image:getData():encode("png")
love.filesystem.write(c.stack_meta.dir .. "/" .. c.name .. ".png",
data:getString())
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!