aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorne_mene <[email protected]>2026-03-31 23:02:40 +0200
committerne_mene <[email protected]>2026-03-31 23:02:40 +0200
commit0cf536b2ba3854d4ee58c06227c1266870829b6c (patch)
tree791388bff86be24c8f1d8eab112e48e0e798b1f4
parent100063ec501ca94773810c4bb5d55e457b0f3f54 (diff)
speck editor: file buttons
-rw-r--r--res/speck/savetest.speck.lua1
-rw-r--r--res/speck/savetest2.speck.lua1
-rw-r--r--res/speck/test.speck.lua2
-rw-r--r--src/scenes/speck_editor.lua22
-rw-r--r--src/specks.lua4
-rw-r--r--src/utils.lua7
6 files changed, 33 insertions, 4 deletions
diff --git a/res/speck/savetest.speck.lua b/res/speck/savetest.speck.lua
new file mode 100644
index 0000000..953e0e6
--- /dev/null
+++ b/res/speck/savetest.speck.lua
@@ -0,0 +1 @@
+return {["initial_vely"]=77.8,["spread"]=360,["lifetime_min"]=0.3,["interval"]=0.05,["spawn_width"]=100,["spawn_height"]=100,["lifetime_max"]=3.6,["gradient"]="res/img/test_gradient.png",["texture_path"]="res/img/speck.png",["spawn_shape"]="Point",["spawn_amount_min"]=3,["spawn_amount_max"]=4,["scale_curve"]="Lerp",["scale_start_min"]=0.8,["scale_start_max"]=1.3,["scale_end_min"]=0,["scale_end_max"]=0,["forcex"]=0,["forcey"]=-32.7,["initial_velx"]=0,} \ No newline at end of file
diff --git a/res/speck/savetest2.speck.lua b/res/speck/savetest2.speck.lua
new file mode 100644
index 0000000..953e0e6
--- /dev/null
+++ b/res/speck/savetest2.speck.lua
@@ -0,0 +1 @@
+return {["initial_vely"]=77.8,["spread"]=360,["lifetime_min"]=0.3,["interval"]=0.05,["spawn_width"]=100,["spawn_height"]=100,["lifetime_max"]=3.6,["gradient"]="res/img/test_gradient.png",["texture_path"]="res/img/speck.png",["spawn_shape"]="Point",["spawn_amount_min"]=3,["spawn_amount_max"]=4,["scale_curve"]="Lerp",["scale_start_min"]=0.8,["scale_start_max"]=1.3,["scale_end_min"]=0,["scale_end_max"]=0,["forcex"]=0,["forcey"]=-32.7,["initial_velx"]=0,} \ No newline at end of file
diff --git a/res/speck/test.speck.lua b/res/speck/test.speck.lua
index d237b7c..8bbf940 100644
--- a/res/speck/test.speck.lua
+++ b/res/speck/test.speck.lua
@@ -1 +1 @@
-return {["bounce"]=true,["forcey"]=1000,["spawn_shape"]="Point",["spawn_width"]=100,["spawn_height"]=100,["texture_path"]="res/img/speck.png",["interval"]=0.05,["lifetime_max"]=0.6,["spawn_amount_max"]=4,["forcex"]=0,["scale_end_max"]=0,["scale_end_min"]=0,["spawn_amount_min"]=3,["scale_curve"]="Lerp",["scale_start_min"]=0.8,["scale_start_max"]=1.25,["lifetime_min"]=0.3,["initial_velx"]=100,["initial_vely"]=0,["spread"]=360,}
+return {["scale_start_max"]=1.3,["scale_end_min"]=0,["scale_end_max"]=0,["forcex"]=0,["forcey"]=502.1,["initial_velx"]=100,["initial_vely"]=0,["spread"]=360,["lifetime_min"]=0.3,["interval"]=0.05,["spawn_width"]=100,["spawn_height"]=100,["lifetime_max"]=0.6,["gradient"]="res/img/test_gradient.png",["texture_path"]="res/img/speck.png",["spawn_shape"]="Point",["spawn_amount_min"]=3,["spawn_amount_max"]=4,["scale_curve"]="Lerp",["scale_start_min"]=0.8,} \ No newline at end of file
diff --git a/src/scenes/speck_editor.lua b/src/scenes/speck_editor.lua
index 96176d0..355bcd1 100644
--- a/src/scenes/speck_editor.lua
+++ b/src/scenes/speck_editor.lua
@@ -68,10 +68,28 @@ local function speck_editor_ui_sys(editor)
im.text("File:")
-- TODO: implement these guys
im.button("New")
- im.button("Open")
+
+ if im.button("Open") then
+ editor.filepath = lw.showFileDialog("savefile", function (files, _, _)
+ if not files[1] or files[1] == "" then
+ return
+ end
+
+ editor.filepath = trunc_filename_to_res(files[1])
+ editor.speck_sys = load_speck_sys_non_cached(editor.filepath)
+
+ end, {defaultname = "res/speck/"})
+ end
if im.button("Save as") then
- save(editor)
+ editor.filepath = lw.showFileDialog("savefile", function (files, _, _)
+ if not files[1] or files[1] == "" then
+ return
+ end
+
+ editor.filepath = trunc_filename_to_res(files[1])
+ save(editor)
+ end, {defaultname = "res/speck/"})
end
if im.button("Save") then
save(editor)
diff --git a/src/specks.lua b/src/specks.lua
index 318bfdd..7c0ef11 100644
--- a/src/specks.lua
+++ b/src/specks.lua
@@ -285,3 +285,7 @@ function load_speck_sys(filename)
return sys
end
+function load_speck_sys_non_cached(filename)
+ speck_bank[filename] = lf.load(filename)()
+ return load_speck_sys(filename)
+end
diff --git a/src/utils.lua b/src/utils.lua
index 5b8258c..e20c88a 100644
--- a/src/utils.lua
+++ b/src/utils.lua
@@ -120,7 +120,7 @@ end
function table.deep_copy(datatable)
local tblRes={}
if type(datatable)=="table" then
- for k,v in pairs(datatable) do
+ for k,v in pairs(datatable) do
tblRes[table.deep_copy(k)] = table.deep_copy(v)
end
else
@@ -129,6 +129,11 @@ function table.deep_copy(datatable)
return tblRes
end
+function trunc_filename_to_res(filename)
+ local index = filename:find("res/", 1, true)
+ return filename:sub(index)
+end
+
EASING_FUNCTIONS = {
Lerp = lerp
}