aboutsummaryrefslogtreecommitdiff
path: root/src/scenes
diff options
context:
space:
mode:
authorne_mene <[email protected]>2026-03-31 14:58:00 +0200
committerne_mene <[email protected]>2026-03-31 14:58:14 +0200
commit828eee340929573cfc4045f8c28d24b775f99e89 (patch)
treee347b11965c0662df94814f39017f6d54e52d1dd /src/scenes
parent74b6389c9ec8e37749afb641dfbebbf4c802e3eb (diff)
speck editor: saving
Diffstat (limited to 'src/scenes')
-rw-r--r--src/scenes/speck_editor.lua53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/scenes/speck_editor.lua b/src/scenes/speck_editor.lua
index 6dbc605..96176d0 100644
--- a/src/scenes/speck_editor.lua
+++ b/src/scenes/speck_editor.lua
@@ -1,22 +1,7 @@
-function start_speck_editor()
- local scn = new_scene()
- set_scene(scn)
-
- event_bind(scn.on_update, "Speck_System", speck_update_sys)
-
- event_bind(scn.on_draw, "Speck_System", speck_draw_sys)
-
- event_bind(scn.on_ui, "Speck_Editor", speck_editor_ui_sys)
-
- local editor = new_entity()
- add_comp(editor, "Position", SCR_WIDTH/2, SCR_HEIGHT/2)
- add_comp(editor, "Speck_Editor")
- return scn
-end
-
register_comp("Speck_Editor", function (editor)
- add_comp(editor, "Speck_System", "res/speck/test.speck.lua")
+ editor.filepath = "res/speck/test.speck.lua"
+ add_comp(editor, "Speck_System", editor.filepath)
end)
local PROPERTY_CUSTOM = {
@@ -64,12 +49,16 @@ local PROPERTY_TYPES = {
end
}
-function speck_editor_ui_sys(editor)
+local function save(editor)
+ export_speck_sys(editor.speck_sys, editor.filepath)
+end
+
+local function speck_editor_ui_sys(editor)
local system = editor.speck_sys
im.begin_window("Speck Editor", 5, 5, 256, 1024, {})
im.text("Properties:")
- for i, prop in ipairs(SPECK_EXPORTED_ARGS) do
+ for _, prop in ipairs(SPECK_EXPORTED_ARGS) do
local func = PROPERTY_TYPES[type(system[prop])]
if func then
system[prop] = func(prop, system[prop], PROPERTY_CUSTOM[prop])
@@ -77,10 +66,32 @@ function speck_editor_ui_sys(editor)
end
im.text("File:")
+ -- TODO: implement these guys
im.button("New")
im.button("Open")
- im.button("Save as")
- im.button("Save")
+
+ if im.button("Save as") then
+ save(editor)
+ end
+ if im.button("Save") then
+ save(editor)
+ end
im.end_window()
end
+
+function start_speck_editor()
+ local scn = new_scene()
+ set_scene(scn)
+
+ event_bind(scn.on_update, "Speck_System", speck_update_sys)
+
+ event_bind(scn.on_draw, "Speck_System", speck_draw_sys)
+
+ event_bind(scn.on_ui, "Speck_Editor", speck_editor_ui_sys)
+
+ local editor = new_entity()
+ add_comp(editor, "Position", SCR_WIDTH/2, SCR_HEIGHT/2)
+ add_comp(editor, "Speck_Editor")
+ return scn
+end