Controls menu
This commit is contained in:
@@ -30,6 +30,7 @@ globals = {
|
|||||||
"MenuWindow",
|
"MenuWindow",
|
||||||
"GameWindow",
|
"GameWindow",
|
||||||
"PopupWindow",
|
"PopupWindow",
|
||||||
|
"ControlsWindow",
|
||||||
"AudioTestWindow",
|
"AudioTestWindow",
|
||||||
"MinigameButtonMashWindow",
|
"MinigameButtonMashWindow",
|
||||||
"MinigameRhythmWindow",
|
"MinigameRhythmWindow",
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ window/window.intro.title.lua
|
|||||||
window/window.intro.ttg.lua
|
window/window.intro.ttg.lua
|
||||||
window/window.intro.brief.lua
|
window/window.intro.brief.lua
|
||||||
window/window.menu.lua
|
window/window.menu.lua
|
||||||
|
window/window.controls.lua
|
||||||
window/window.audiotest.lua
|
window/window.audiotest.lua
|
||||||
window/window.popup.lua
|
window/window.popup.lua
|
||||||
window/window.minigame.mash.lua
|
window/window.minigame.mash.lua
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ local INPUT_KEY_UP = 0
|
|||||||
local INPUT_KEY_DOWN = 1
|
local INPUT_KEY_DOWN = 1
|
||||||
local INPUT_KEY_LEFT = 2
|
local INPUT_KEY_LEFT = 2
|
||||||
local INPUT_KEY_RIGHT = 3
|
local INPUT_KEY_RIGHT = 3
|
||||||
local INPUT_KEY_Y = 7
|
local INPUT_KEY_A = 4
|
||||||
|
local INPUT_KEY_B = 5
|
||||||
local INPUT_KEY_SPACE = 48
|
local INPUT_KEY_SPACE = 48
|
||||||
local INPUT_KEY_BACKSPACE = 51
|
local INPUT_KEY_BACKSPACE = 51
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ function Input.left() return btnp(INPUT_KEY_LEFT) end
|
|||||||
function Input.right() return btnp(INPUT_KEY_RIGHT) end
|
function Input.right() return btnp(INPUT_KEY_RIGHT) end
|
||||||
--- Checks if Select is pressed.
|
--- Checks if Select is pressed.
|
||||||
--- @within Input
|
--- @within Input
|
||||||
function Input.select() return btnp(INPUT_KEY_Y) or keyp(INPUT_KEY_SPACE) or Mouse.clicked() end
|
function Input.select() return btnp(INPUT_KEY_A) or keyp(INPUT_KEY_SPACE) or Mouse.clicked() end
|
||||||
--- Checks if Back is pressed.
|
--- Checks if Back is pressed.
|
||||||
--- @within Input
|
--- @within Input
|
||||||
function Input.back() return keyp(INPUT_KEY_BACKSPACE) end
|
function Input.back() return btnp(INPUT_KEY_B) or keyp(INPUT_KEY_BACKSPACE) end
|
||||||
|
|||||||
44
inc/window/window.controls.lua
Normal file
44
inc/window/window.controls.lua
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
--- @section ControlsWindow
|
||||||
|
local _controls = {
|
||||||
|
{ action = "Navigate", keyboard = "Arrow keys", gamepad = "D-pad" },
|
||||||
|
{ action = "Select / OK", keyboard = "Space", gamepad = "Z button" },
|
||||||
|
{ action = "Back", keyboard = "Backspace", gamepad = "B button" },
|
||||||
|
{ action = "Click", keyboard = "Mouse", gamepad = "" },
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Draws the controls window.
|
||||||
|
--- @within ControlsWindow
|
||||||
|
function ControlsWindow.draw()
|
||||||
|
UI.draw_top_bar("Controls")
|
||||||
|
|
||||||
|
local col_action = 4
|
||||||
|
local col_keyboard = 80
|
||||||
|
local col_gamepad = 170
|
||||||
|
local row_h = 10
|
||||||
|
local y_header = 18
|
||||||
|
local y_start = 30
|
||||||
|
|
||||||
|
Print.text("Action", col_action, y_header, Config.colors.light_grey)
|
||||||
|
Print.text("Keyboard", col_keyboard, y_header, Config.colors.light_grey)
|
||||||
|
Print.text("Gamepad", col_gamepad, y_header, Config.colors.light_grey)
|
||||||
|
line(col_action, y_header + 8, Config.screen.width - 4, y_header + 8, Config.colors.dark_grey)
|
||||||
|
|
||||||
|
for i, entry in ipairs(_controls) do
|
||||||
|
local y = y_start + (i - 1) * row_h
|
||||||
|
Print.text(entry.action, col_action, y, Config.colors.white)
|
||||||
|
Print.text(entry.keyboard, col_keyboard, y, Config.colors.light_blue)
|
||||||
|
if entry.gamepad ~= "" then
|
||||||
|
Print.text(entry.gamepad, col_gamepad, y, Config.colors.light_blue)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Print.text("Space / Z button or click to go back", col_action, Config.screen.height - 10, Config.colors.light_grey)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Updates the controls window logic.
|
||||||
|
--- @within ControlsWindow
|
||||||
|
function ControlsWindow.update()
|
||||||
|
if Input.back() or Input.select() then
|
||||||
|
Window.set_current("menu")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -84,6 +84,12 @@ function MenuWindow.exit()
|
|||||||
exit()
|
exit()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Opens the controls screen.
|
||||||
|
--- @within MenuWindow
|
||||||
|
function MenuWindow.controls()
|
||||||
|
Window.set_current("controls")
|
||||||
|
end
|
||||||
|
|
||||||
--- Opens the audio test menu.
|
--- Opens the audio test menu.
|
||||||
--- @within MenuWindow
|
--- @within MenuWindow
|
||||||
function MenuWindow.audio_test()
|
function MenuWindow.audio_test()
|
||||||
@@ -117,6 +123,7 @@ function MenuWindow.refresh_menu_items()
|
|||||||
|
|
||||||
table.insert(_menu_items, {label = "New Game", decision = MenuWindow.new_game})
|
table.insert(_menu_items, {label = "New Game", decision = MenuWindow.new_game})
|
||||||
table.insert(_menu_items, {label = "Load Game", decision = MenuWindow.load_game})
|
table.insert(_menu_items, {label = "Load Game", decision = MenuWindow.load_game})
|
||||||
|
table.insert(_menu_items, {label = "Controls", decision = MenuWindow.controls})
|
||||||
|
|
||||||
if Context.test_mode then
|
if Context.test_mode then
|
||||||
table.insert(_menu_items, {label = "Audio Test", decision = MenuWindow.audio_test})
|
table.insert(_menu_items, {label = "Audio Test", decision = MenuWindow.audio_test})
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ Window.register("game", GameWindow)
|
|||||||
PopupWindow = {}
|
PopupWindow = {}
|
||||||
Window.register("popup", PopupWindow)
|
Window.register("popup", PopupWindow)
|
||||||
|
|
||||||
|
ControlsWindow = {}
|
||||||
|
Window.register("controls", ControlsWindow)
|
||||||
|
|
||||||
AudioTestWindow = {}
|
AudioTestWindow = {}
|
||||||
Window.register("audiotest", AudioTestWindow)
|
Window.register("audiotest", AudioTestWindow)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user