Skip to content

AavaGames/playdate-keyboard-based-menu-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Keyboard Based Menu

A menu that uses the playdate's keyboard to navigate and select. Created as an aesthetic homage to traditional roguelikes!

setting-menu-loop

Features

Commands, Bool, Options

Create menu items just like the playdate's menu system. Tie your callbacks and tweak your parameters to close the keyboard, menu/page or all menus when the item is selected.

Automatic Nested Pages

If your menu has too many options and will overflow the space it has, it will automatically create a sub page at the bottom.

Formats to your Font

Whatever font you give it will automatically adjust its dimensions to fit it properly.

setting-menu-og-font

LuaCATS Syntax

Added type and constructor definitions for LuaCATS used by Lua Language Server for the sumneko.lua VSCode extension. Highly recommend using with Playdate-LuaCATS by notpeter.

Limitations

  • You cannot change the font after the menu is created, you will need to recreate the menu if you wish to change the font.

Showcase / Example Project

debug-menu debug-menu-light

Try it out on the Playdate (download pdx) and peruse some code at this git https://github.com/AavaGames/playdate-keyboard-based-menu-ui-example

Installation

  1. Download the repo
  2. Add the keyboard-based-menu folder to your project
  3. import SOURCEFOLDER\keyboard-based-menu\imports
  4. Now you can create a MenuManager singleton and open Menus!

Use

Look through main.lua here to get a real example of its use.

  1. Create a MenuManager singleton
    1. Pass in your callback for what to do when a menu opens from gameplay and when all menus close. Example: Change GameManager state to menu so gameplay update stops running.
  2. Create a Menu: pass it the menu manager, a name and its items.
  3. menu:open()

Menu Item

--[[
    Initializes a menu item.

    Parameters:
        text (string): The text of the menu item.
        assignedGlyph (string): The preferred assigned glyph for the menu item. Nil assigns the next in the keyboard sequence. First come, first serve. To skip use nil or empty string ""
        closeKeyboardOnSelect (boolean): Whether to close the keyboard on selection.
        closeMenuOnSelect (boolean): Whether to close the menu on selection.
        allMenus (boolean): Whether to close all menus on selection. Requires closeMenuOnSelect.
        selectionFunction (function): The function to execute when the menu item is selected.
]]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages