diff options
| author | ne_mene <[email protected]> | 2026-03-31 12:58:42 +0200 |
|---|---|---|
| committer | ne_mene <[email protected]> | 2026-03-31 12:58:42 +0200 |
| commit | 644050d9fc341e3963b27e30016c367bb4aeb609 (patch) | |
| tree | f5b119507c8c95fd2e5458afb0a5bb1a5cb588d3 /src | |
| parent | 7a66b465b46bd1507a9b8b746dc5182ee4055f93 (diff) | |
edit speck properties
Diffstat (limited to 'src')
| -rw-r--r-- | src/scenes/speck_editor.lua | 62 | ||||
| -rw-r--r-- | src/specks.lua | 52 |
2 files changed, 86 insertions, 28 deletions
diff --git a/src/scenes/speck_editor.lua b/src/scenes/speck_editor.lua index d36443e..ce59a79 100644 --- a/src/scenes/speck_editor.lua +++ b/src/scenes/speck_editor.lua @@ -7,6 +7,8 @@ function start_speck_editor() 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") @@ -17,6 +19,62 @@ register_comp("Speck_Editor", function (editor) add_comp(editor, "Speck_System", "res/speck/test.speck.lua") end) -function speck_editor_update_sys(editor) - +local PROPERTY_CUSTOM = { + spawn_shape = {"Point", "Circle", "Rectangle"}, + spawn_amount_min = {min = 1, max = 64, step = 1}, + spawn_amount_max = {min = 1, max = 64, step = 1}, + spawn_width = {min = 0, max = 1024, step = 1}, + spawn_height = {min = 0, max = 1024, step = 1}, + spawn_radius = {min = 0, max = 1024, step = 1}, + scale_curve = {}, + scale_start_min = {min = 0, max = 16}, + scale_start_max = {min = 0, max = 16}, + forcex = {min = -2048, max = 2048}, + forcey = {min = -2048, max = 2048}, + initial_velx = {min = 0, max = 2048}, + initial_vely = {min = 0, max = 2048}, + spread = {min = 0, max = 360}, + lifetime_min = {min = 0, max = 32}, + lifetime_max = {min = 0, max = 32}, + interval = {min = 0, max = 32, step = 0.01}, + texture_path = {}, + gradient = {}, +} + +for key, _ in pairs(EASING_FUNCTIONS) do + PROPERTY_CUSTOM.scale_curve[#PROPERTY_CUSTOM.scale_curve+1] = key +end + +local PROPERTY_TYPES = { + ["number"] = function (name, value, custom) + custom = custom or {} + im.layout({0.5, 1}) + im.text(name) + im.text(tostring(value)) + im.layout() + return im.slider(value, custom.min or 0, custom.max or 1, custom.step or 0.1) + end, + ["boolean"] = function (name, value, _) + im.layout({0.25, 0.5, 1}) + im.text(name) + im.text(tostring(value)) + if im.button("Toggle") then + return not value + end + end +} + +function speck_editor_ui_sys(editor) + local system = editor.speck_sys + + im.begin_window("Speck Editor", 5, 5, 180, 180, {}) + im.text("Properties") + for i, 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]) + end + end + + im.end_window() end diff --git a/src/specks.lua b/src/specks.lua index 7f16c51..85f8c4e 100644 --- a/src/specks.lua +++ b/src/specks.lua @@ -222,36 +222,36 @@ function Speck_Sys:draw() end end +SPECK_EXPORTED_ARGS = { + "spawn_shape", + "spawn_amount_min", + "spawn_amount_max", + "spawn_width", + "spawn_height", + "spawn_radius", + "scale_curve", + "scale_start_min", + "scale_start_max", + "scale_end_min", + "scale_end_max", + "forcex", + "forcey", + "initial_velx", + "initial_vely", + "spread", + "lifetime_min", + "lifetime_max", + "interval", + "texture_path", + "gradient", + "oneshot", + "bounce", +} function export_speck_sys(sys, filename) - local EXPORTED_ARGS = { - "spawn_shape", - "spawn_amount_min", - "spawn_amount_max", - "spawn_width", - "spawn_height", - "spawn_radius", - "scale_curve", - "scale_start_min", - "scale_start_max", - "scale_end_min", - "scale_end_max", - "forcex", - "forcey", - "initial_velx", - "initial_vely", - "spread", - "lifetime_min", - "lifetime_max", - "interval", - "texture_path", - "gradient", - "oneshot", - "bounce", - } local exp = {} - for i, arg in ipairs(EXPORTED_ARGS) do + for i, arg in ipairs(SPECK_EXPORTED_ARGS) do exp[arg] = sys[arg] end export_to_source(exp, filename) |
