2022-01-18 19:47:55 +00:00
|
|
|
Keybind = {}
|
2022-02-17 22:39:31 +00:00
|
|
|
|
2022-01-18 19:47:55 +00:00
|
|
|
Keybind.move = {}
|
2022-02-17 22:39:31 +00:00
|
|
|
Keybind.move.left = { demo = "move_left"}
|
|
|
|
Keybind.move.right = { demo = "move_right"}
|
|
|
|
Keybind.move.up = { demo = "move_up"}
|
|
|
|
Keybind.move.down = { demo = "move_down"}
|
|
|
|
Keybind.move.jump = { demo = "move_jump"}
|
|
|
|
Keybind.move.hook = { demo = "move_hook"}
|
|
|
|
Keybind.move.dash = { demo = "move_dash"}
|
|
|
|
|
2022-01-18 19:47:55 +00:00
|
|
|
Keybind.menu = {}
|
2022-02-17 22:39:31 +00:00
|
|
|
Keybind.menu.pause = { demo = "menu_pause"}
|
|
|
|
Keybind.menu.confirm = { demo = "menu_confirm"}
|
|
|
|
|
2022-01-19 12:54:33 +00:00
|
|
|
Keybind.debug = {}
|
2022-01-19 15:13:13 +00:00
|
|
|
Keybind.editor = {}
|
2022-01-29 07:49:45 +00:00
|
|
|
Keybind.generic = {}
|
2022-01-17 23:14:54 +00:00
|
|
|
|
2022-01-19 13:55:15 +00:00
|
|
|
function Keybind:CheckDown(action)
|
2022-02-17 22:39:31 +00:00
|
|
|
if DemoPlayback then
|
|
|
|
for _, demo_action in pairs(DemoAction[CurrentDemoFrame]) do
|
|
|
|
if demo_action == action.demo then
|
|
|
|
return true
|
|
|
|
end
|
2022-01-18 15:49:49 +00:00
|
|
|
end
|
2022-02-17 22:39:31 +00:00
|
|
|
return false
|
|
|
|
else
|
|
|
|
for _, keyname in pairs(action.keys) do
|
2022-02-17 23:17:36 +00:00
|
|
|
local check = false
|
|
|
|
if type(keyname) == "string" then
|
|
|
|
check = love.keyboard.isDown(keyname)
|
|
|
|
else
|
|
|
|
check = love.mouse.isDown(keyname)
|
2022-02-17 22:39:31 +00:00
|
|
|
end
|
2022-02-17 23:17:36 +00:00
|
|
|
if check then
|
|
|
|
if action.demo ~= nil then
|
|
|
|
Demo:RecordAction(action.demo)
|
|
|
|
end
|
2022-02-17 22:39:31 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
2022-01-18 15:49:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-12 19:03:48 +00:00
|
|
|
function Keybind:CheckPressed(action)
|
2022-01-19 13:55:15 +00:00
|
|
|
if Keybind:CheckDown(action) then
|
|
|
|
if not action.pressed then
|
|
|
|
action.pressed = true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
else
|
2022-01-19 13:58:49 +00:00
|
|
|
action.pressed = nil
|
2022-01-19 13:55:15 +00:00
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Keybind:CheckCollision(cat, key)
|
2022-01-18 19:47:55 +00:00
|
|
|
for _, action in pairs(cat) do
|
2022-01-19 13:55:15 +00:00
|
|
|
for _, keyname in pairs(action.keys) do
|
2022-01-18 19:47:55 +00:00
|
|
|
if key == keyname then return true end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2022-01-19 13:55:15 +00:00
|
|
|
function Keybind:AddKey(action, key)
|
|
|
|
table.insert(action.keys, key)
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
|
|
|
|
2022-01-19 13:55:15 +00:00
|
|
|
function Keybind:ChangeKey(action, position, key)
|
|
|
|
action.keys[position] = key
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
|
|
|
|
2022-01-19 13:55:15 +00:00
|
|
|
function Keybind:RemoveKeys(action)
|
|
|
|
action.keys = {}
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function Keybind:Default()
|
2022-01-19 12:28:09 +00:00
|
|
|
--Menu
|
2022-02-17 22:39:31 +00:00
|
|
|
Keybind.menu.pause.keys = {"escape"}
|
|
|
|
Keybind.menu.confirm.keys = {"z", "space", 1}
|
2022-02-10 17:18:37 +00:00
|
|
|
|
2022-01-19 12:28:09 +00:00
|
|
|
--Move
|
2022-02-17 22:39:31 +00:00
|
|
|
Keybind.move.left.keys = {"left", "a"}
|
|
|
|
Keybind.move.right.keys = {"right", "d"}
|
|
|
|
Keybind.move.up.keys = {"up", "w"}
|
|
|
|
Keybind.move.down.keys = {"down", "s"}
|
|
|
|
Keybind.move.jump.keys = {"z", "space"}
|
|
|
|
Keybind.move.hook.keys = {"x", 1}
|
|
|
|
Keybind.move.dash.keys = {"c", 2}
|
2022-02-10 17:18:37 +00:00
|
|
|
|
2022-01-19 12:28:09 +00:00
|
|
|
--Debug
|
2022-01-19 13:55:15 +00:00
|
|
|
Keybind.debug.debug = { keys = {"f1"}}
|
|
|
|
Keybind.debug.reposition = { keys = {"f2"}}
|
|
|
|
Keybind.debug.reload = { keys = {"f3"}}
|
|
|
|
Keybind.debug.editor = { keys = {"f4"}}
|
2022-02-17 22:39:31 +00:00
|
|
|
Keybind.debug.recording = { keys = {"f5"}}
|
|
|
|
Keybind.debug.playback = { keys = {"f6"}}
|
2022-02-10 17:18:37 +00:00
|
|
|
|
2022-01-19 15:13:13 +00:00
|
|
|
-- Editor
|
|
|
|
Keybind.editor.palette = { keys = {"tab"}}
|
2022-01-29 07:49:45 +00:00
|
|
|
|
|
|
|
-- Generic
|
|
|
|
Keybind.generic.lclick = { keys = {1}}
|
|
|
|
Keybind.generic.rclick = { keys = {2}}
|
2022-01-31 00:22:15 +00:00
|
|
|
Keybind.generic.lshift = { keys = {"lshift"}}
|
|
|
|
Keybind.generic.lctrl = { keys = {"lctrl"}}
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
2022-01-18 15:49:49 +00:00
|
|
|
|
2022-01-18 19:47:55 +00:00
|
|
|
-- Set default values at start
|
|
|
|
Keybind:Default()
|