diff options
Diffstat (limited to 'src/scenes/speck_editor.lua')
| -rw-r--r-- | src/scenes/speck_editor.lua | 62 |
1 files changed, 60 insertions, 2 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 |
