added specific action keybinds to the editor

This commit is contained in:
lustlion 2022-03-06 16:33:45 +01:00
parent 05bf757ea5
commit 5c9fc39fad
2 changed files with 58 additions and 23 deletions

View File

@ -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

View File

@ -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}}