cleaned up stepEditor()

This commit is contained in:
binarycat 2022-03-11 15:35:59 -05:00
parent 9c070e161f
commit 5f48756e2e

View File

@ -1,75 +1,55 @@
assert(editor == nil) assert(editor == nil)
editor = { editor = {
room_mode = false, room_mode = false,
palette_mode = false palette_mode = false,
pan = { fixed = false, speed = 3 },
} }
function stepEditor() function stepEditor()
editor.palette_mode = editor.palette_mode or false editor.palette_mode = editor.palette_mode or false
animateTiles() animateTiles()
if Prompt.active_prompt == nil then if Keybind:checkPressed(Keybind.editor.room_mode) then
if Keybind:checkPressed(Keybind.editor.room_mode) then if love.keyboard.isDown("lshift") then
if love.keyboard.isDown("lshift") then editor.room_mode = "delete"
editor.room_mode = "delete" else
else editor.room_mode = not editor.room_mode
editor.room_mode = not editor.room_mode
end
editor.room_points = {}
end end
editor.room_points = {}
if Keybind:checkPressed(Keybind.editor.palette_mode) then end
if editor.palette_mode then if Keybind:checkPressed(Keybind.editor.palette_mode) then
editor.palette_mode = false if editor.palette_mode then
palette_scroll_x = nil editor.palette_mode = false
palette_scroll_y = nil palette_scroll_x = nil
else palette_scroll_y = nil
editor.palette_mode = true else
palette_scroll_x = 0 editor.palette_mode = true
palette_scroll_y = 0 palette_scroll_x = 0
end palette_scroll_y = 0
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 end
end end
-- TODO:
-- i changed this but i dont know what was to do here. local cvel = Point:new(0, 0)
-- - made specific action keybinds
if Keybind:checkDown(Keybind.editor.left) then if Keybind:checkDown(Keybind.editor.left) then
Camera.pos.x = Camera.pos.x - 3 cvel.x = -1
end end
if Keybind:checkDown(Keybind.editor.right) then if Keybind:checkDown(Keybind.editor.right) then
Camera.pos.x = Camera.pos.x + 3 cvel.x = 1
end end
if Keybind:checkDown(Keybind.editor.up) then if Keybind:checkDown(Keybind.editor.up) then
Camera.pos.y = Camera.pos.y - 3 cvel.y = -1
end end
if Keybind:checkDown(Keybind.editor.down) then if Keybind:checkDown(Keybind.editor.down) then
Camera.pos.y = Camera.pos.y + 3 cvel.y = 1
end end
cvel = cvel * editor.pan.speed
if not editor.pan.fixed then
cvel = cvel / game.scale
end
Camera.pos = Camera.pos + cvel
if editor.palette_mode then if editor.palette_mode then
if Keybind:checkPressed(Keybind.editor.palette_change) then if Keybind:checkPressed(Keybind.editor.palette_change) then
local next = false local next = false
@ -98,19 +78,19 @@ function stepEditor()
if Keybind:checkPressed(Keybind.editor.save) then if Keybind:checkPressed(Keybind.editor.save) then
Prompt:new({ Prompt:new({
name = "level name", name = "level name",
input = "unnamed", input = "unnamed",
func = function(name_prompt) func = function(name_prompt)
if name_prompt.canceled then return end if name_prompt.canceled then return end
Prompt:new({ Prompt:new({
name = "filename", name = "filename",
input = "level.lua", input = "level.lua",
func = function(file_prompt) func = function(file_prompt)
if file_prompt.canceled then return end if file_prompt.canceled then return end
exportLevel(name_prompt.input, file_prompt.input) exportLevel(name_prompt.input, file_prompt.input)
end, end,
}):activate() }):activate()
end, end,
}):activate() }):activate()
end end