cleaned up stepEditor()
This commit is contained in:
parent
9c070e161f
commit
5f48756e2e
108
code/editor.lua
108
code/editor.lua
@ -1,75 +1,55 @@
|
||||
assert(editor == nil)
|
||||
editor = {
|
||||
room_mode = false,
|
||||
palette_mode = false
|
||||
palette_mode = false,
|
||||
pan = { fixed = false, speed = 3 },
|
||||
}
|
||||
|
||||
function stepEditor()
|
||||
editor.palette_mode = editor.palette_mode or false
|
||||
animateTiles()
|
||||
if Prompt.active_prompt == nil then
|
||||
if Keybind:checkPressed(Keybind.editor.room_mode) then
|
||||
if love.keyboard.isDown("lshift") then
|
||||
editor.room_mode = "delete"
|
||||
else
|
||||
editor.room_mode = not editor.room_mode
|
||||
end
|
||||
editor.room_points = {}
|
||||
if Keybind:checkPressed(Keybind.editor.room_mode) then
|
||||
if love.keyboard.isDown("lshift") then
|
||||
editor.room_mode = "delete"
|
||||
else
|
||||
editor.room_mode = not editor.room_mode
|
||||
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
|
||||
|
||||
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
|
||||
editor.room_points = {}
|
||||
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:
|
||||
-- i changed this but i dont know what was to do here.
|
||||
-- - made specific action keybinds
|
||||
|
||||
local cvel = Point:new(0, 0)
|
||||
if Keybind:checkDown(Keybind.editor.left) then
|
||||
Camera.pos.x = Camera.pos.x - 3
|
||||
cvel.x = -1
|
||||
end
|
||||
if Keybind:checkDown(Keybind.editor.right) then
|
||||
Camera.pos.x = Camera.pos.x + 3
|
||||
cvel.x = 1
|
||||
end
|
||||
if Keybind:checkDown(Keybind.editor.up) then
|
||||
Camera.pos.y = Camera.pos.y - 3
|
||||
cvel.y = -1
|
||||
end
|
||||
if Keybind:checkDown(Keybind.editor.down) then
|
||||
Camera.pos.y = Camera.pos.y + 3
|
||||
cvel.y = 1
|
||||
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 Keybind:checkPressed(Keybind.editor.palette_change) then
|
||||
local next = false
|
||||
@ -98,19 +78,19 @@ function stepEditor()
|
||||
|
||||
if Keybind:checkPressed(Keybind.editor.save) then
|
||||
Prompt:new({
|
||||
name = "level name",
|
||||
input = "unnamed",
|
||||
func = function(name_prompt)
|
||||
if name_prompt.canceled then return end
|
||||
Prompt:new({
|
||||
name = "filename",
|
||||
input = "level.lua",
|
||||
func = function(file_prompt)
|
||||
if file_prompt.canceled then return end
|
||||
exportLevel(name_prompt.input, file_prompt.input)
|
||||
end,
|
||||
}):activate()
|
||||
end,
|
||||
name = "level name",
|
||||
input = "unnamed",
|
||||
func = function(name_prompt)
|
||||
if name_prompt.canceled then return end
|
||||
Prompt:new({
|
||||
name = "filename",
|
||||
input = "level.lua",
|
||||
func = function(file_prompt)
|
||||
if file_prompt.canceled then return end
|
||||
exportLevel(name_prompt.input, file_prompt.input)
|
||||
end,
|
||||
}):activate()
|
||||
end,
|
||||
}):activate()
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user