Controls menu
This commit is contained in:
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()
|
||||
end
|
||||
|
||||
--- Opens the controls screen.
|
||||
--- @within MenuWindow
|
||||
function MenuWindow.controls()
|
||||
Window.set_current("controls")
|
||||
end
|
||||
|
||||
--- Opens the audio test menu.
|
||||
--- @within MenuWindow
|
||||
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 = "Load Game", decision = MenuWindow.load_game})
|
||||
table.insert(_menu_items, {label = "Controls", decision = MenuWindow.controls})
|
||||
|
||||
if Context.test_mode then
|
||||
table.insert(_menu_items, {label = "Audio Test", decision = MenuWindow.audio_test})
|
||||
|
||||
@@ -16,6 +16,9 @@ Window.register("game", GameWindow)
|
||||
PopupWindow = {}
|
||||
Window.register("popup", PopupWindow)
|
||||
|
||||
ControlsWindow = {}
|
||||
Window.register("controls", ControlsWindow)
|
||||
|
||||
AudioTestWindow = {}
|
||||
Window.register("audiotest", AudioTestWindow)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user