From 2b3245f44fecbf2e426bb28f522a24e00662c610 Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Thu, 12 Mar 2026 18:10:06 -0400 Subject: Make the room editor un-hacked in --- src/objs/room_editor.lua | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/objs/room_editor.lua (limited to 'src/objs/room_editor.lua') diff --git a/src/objs/room_editor.lua b/src/objs/room_editor.lua new file mode 100644 index 0000000..baee368 --- /dev/null +++ b/src/objs/room_editor.lua @@ -0,0 +1,71 @@ +register_input("Next_Tileset", {{"key", "t"}}) +register_input("Prev_Tileset", {{"key", "r"}}) + +register_comp("Room_Editor", function(ent) + ent.room_editor = { + tile = 1, + } +end) + +function tile_place_sys(ent) + local room_editor = ent.room_editor + + if not im.has_focus() then + if is_input_pressed("Right_Click") then + local scn = get_current_scene() + assert(scn, "no scene set.") + + local mx, my = get_mouse_pos() + local tx, ty = to_tile_coords(mx, my) + set_tile(scn.tilemap, tx, ty, room_editor.tile) + end + if is_input_pressed("Left_Click") then + local scn = get_current_scene() + assert(scn, "no scene set.") + + local mx, my = get_mouse_pos() + local tx, ty = to_tile_coords(mx, my) + remove_tile(scn.tilemap, tx, ty) + end + end + + if is_input_just_pressed("Next_Tileset") then + room_editor.tile = math.min(room_editor.tile + 1, get_tileset_count()) + end + if is_input_just_pressed("Prev_Tileset") then + room_editor.tile = math.max(room_editor.tile - 1, 1) + end +end + +function room_editor_ui_sys(ent) + local room_editor = ent.room_editor + im.begin_window("Room Editor", 120, 5, 180, 320, {}) + -- im.layout({0.5, 0.75, 1}) + im.text("Tile: " .. tostring(room_editor.tile)) + -- if im.button(" - ") then + -- tile = math.max(tile - 1, 1) + -- end + -- if im.button("+ ") then + -- tile = tile + 1 + -- end + im.layout({0.1, 0.6, 1}) + + for tileset_id=1, get_tileset_count() do + local text = " " + if tileset_id == room_editor.tile then + text = "*" + elseif tileset_id == room_editor.tile - 1 then + text = "r" + elseif tileset_id == room_editor.tile + 1 then + text = "t" + end + im.text(text) + if im.button("select") then + room_editor.tile = tileset_id + end + im.image(TILE_TEX, get_tileset_quad(tileset_id)) + end + + im.layout() + im.end_window() +end -- cgit v1.3-2-g0d8e From f5d00397e02fde75e3c63e9872ac5625bd961794 Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Thu, 12 Mar 2026 18:16:46 -0400 Subject: increase ui scroll speed --- src/im.lua | 2 +- src/objs/room_editor.lua | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'src/objs/room_editor.lua') diff --git a/src/im.lua b/src/im.lua index 2737ed5..cb583ff 100644 --- a/src/im.lua +++ b/src/im.lua @@ -9,7 +9,7 @@ im = { text = {0.8, 0.8, 0.8}, }, padding = 1, - scroll_speed = 5, + scroll_speed = 15, slider_handle_width = 5, resize_handle_size = 5, } diff --git a/src/objs/room_editor.lua b/src/objs/room_editor.lua index baee368..70f0a86 100644 --- a/src/objs/room_editor.lua +++ b/src/objs/room_editor.lua @@ -40,14 +40,8 @@ end function room_editor_ui_sys(ent) local room_editor = ent.room_editor im.begin_window("Room Editor", 120, 5, 180, 320, {}) - -- im.layout({0.5, 0.75, 1}) im.text("Tile: " .. tostring(room_editor.tile)) - -- if im.button(" - ") then - -- tile = math.max(tile - 1, 1) - -- end - -- if im.button("+ ") then - -- tile = tile + 1 - -- end + im.separator() im.layout({0.1, 0.6, 1}) for tileset_id=1, get_tileset_count() do -- cgit v1.3-2-g0d8e