From 5c9fc39fad605f9b19de8bc03811f24b2bc17572 Mon Sep 17 00:00:00 2001 From: lustlion Date: Sun, 6 Mar 2022 16:33:45 +0100 Subject: [PATCH] added specific action keybinds to the editor --- code/editor.lua | 73 +++++++++++++++++++++++++++++++++--------------- code/keybind.lua | 8 +++++- 2 files changed, 58 insertions(+), 23 deletions(-) diff --git a/code/editor.lua b/code/editor.lua index bd46b15..6595584 100644 --- a/code/editor.lua +++ b/code/editor.lua @@ -1,8 +1,11 @@ assert(editor == nil) -editor = { room_mode = false } +editor = { + room_mode = false, + palette_mode = false +} function stepEditor() - palette = palette or false + editor.palette_mode = editor.palette_mode or false animateTiles() if Keybind:checkPressed(Keybind.editor.room_mode) then if love.keyboard.isDown("lshift") then @@ -13,35 +16,61 @@ function stepEditor() editor.room_points = {} end - if Keybind:checkPressed(Keybind.editor.palette) then - if palette then - palette = false + if Keybind:checkPressed(Keybind.editor.palette_mode) then + if editor.palette_mode then + editor.palette_mode = false palette_scroll_x = nil palette_scroll_y = nil else - palette = true + editor.palette_mode = true palette_scroll_x = 0 palette_scroll_y = 0 end end + if Keybind:checkPressed(Keybind.editor.palette_mode) then + if editor.palette_mode then + editor.palette_mode = false + palette_scroll_x = nil + palette_scroll_y = nil + else + editor.palette_mode = true + palette_scroll_x = 0 + palette_scroll_y = 0 + end + end + + + if Keybind:checkPressed(Keybind.editor.palette_mode) then + if editor.palette_mode then + editor.palette_mode = false + palette_scroll_x = nil + palette_scroll_y = nil + else + editor.palette_mode = true + palette_scroll_x = 0 + palette_scroll_y = 0 + end + end + -- TODO: - - if love.keyboard.isDown('a',"left") then - Camera.pos.x = Camera.pos.x - 3/game.scale + -- i changed this but i dont know what was to do here. + -- - made specific action keybinds + if Keybind:checkDown(Keybind.editor.left) then + Camera.pos.x = Camera.pos.x - 3 end - if love.keyboard.isDown('d',"right") then - Camera.pos.x = Camera.pos.x + 3/game.scale + if Keybind:checkDown(Keybind.editor.right) then + Camera.pos.x = Camera.pos.x + 3 end - if love.keyboard.isDown("up", "w") then - Camera.pos.y = Camera.pos.y - 3/game.scale + if Keybind:checkDown(Keybind.editor.up) then + Camera.pos.y = Camera.pos.y - 3 end - if love.keyboard.isDown("down", "s") then - Camera.pos.y = Camera.pos.y + 3/game.scale + if Keybind:checkDown(Keybind.editor.down) then + Camera.pos.y = Camera.pos.y + 3 end - if palette then - if Keybind:checkPressed(Keybind.debug.debug) then + if editor.palette_mode then + if Keybind:checkPressed(Keybind.editor.palette_change) then local next = false local export = nil for k, v in pairs(tileset) do @@ -66,7 +95,7 @@ function stepEditor() end end - if Keybind:checkPressed(Keybind.debug.reload) then + if Keybind:checkPressed(Keybind.editor.save) then Prompt:new({ name = "level name", input = "unnamed", @@ -85,13 +114,13 @@ function stepEditor() end if Keybind:checkPressed(Keybind.debug.editor) then - editor_mode = false + editor_mode = editor_mode createTileObjects() end end function scrollEditor(y) - if palette then + if editor.palette_mode then if love.keyboard.isDown("lshift") then palette_scroll_y = palette_scroll_y + y else @@ -114,7 +143,7 @@ function drawEditor() drawEditorRooms() drawSelectingPaletteTile() - if palette then + if editor.palette_mode then doEditorPalette() end end @@ -171,7 +200,7 @@ function doEditorEdit() else love.graphics.print("Select bottom right of new room", 0, 20) end - elseif not palette then + elseif not editor.palette_mode then if LevelTiles[vertical] ~= nil and LevelTiles[vertical][horizontal] ~= nil and love.keyboard.isDown("lshift") ~= true diff --git a/code/keybind.lua b/code/keybind.lua index a6cf363..b1cfe27 100644 --- a/code/keybind.lua +++ b/code/keybind.lua @@ -112,10 +112,16 @@ function Keybind:default() Keybind.debug.playback = { keys = {"f6"}} -- Editor - Keybind.editor.palette = { keys = {"tab"}} + Keybind.editor.palette_mode = { keys = {"tab"}} Keybind.editor.room_mode = { keys = {"r"}} Keybind.editor.entity_mode = { keys = {"e"}} Keybind.editor.properties_mode = { keys = {"p"}} + Keybind.editor.left = { keys = {"left", "a"}} + Keybind.editor.right = { keys = {"right", "d"}} + Keybind.editor.up = { keys = {"up", "w"}} + Keybind.editor.down = { keys = {"down", "s"}} + Keybind.editor.palette_change = { keys = {"f1"}} + Keybind.editor.save = { keys = {"f3"}} -- Generic Keybind.generic.lclick = { keys = {1}}