Skip to content

Development source guide ยท workspace 0.1.0

Build menus and interfaces

The engine includes immediate-mode UI tools. Your game supplies the menu state, draws the widgets, passes input and turns an accepted action into a game-state change. A new project does not include a complete settings, inventory or dialogue editor.

Begin with one action

For a first interface, choose a single action with a visible result, such as opening a panel or returning to gameplay. Define:

  1. Which game state makes the widget visible.
  2. The label the player will read.
  3. What counts as acceptance: pointer click, keyboard selection or a game-specific binding.
  4. What changes when the action is accepted.
  5. What happens when it is cancelled or unavailable.

Implement that action and check it before adding a multi-page menu. Rendering a button does not prove it changes the intended state.

The available UI path

The implemented UI API includes beginning a UI frame, panels, buttons and menus. It must be integrated into the game's drawing and input flow.

Responsibility What the game supplies
Visibility Which screen, panel or dialog is active
Input Pointer position, click state and any keyboard/gamepad navigation
Meaning What a button or menu result does
Persistent selection Current page, selected item and other game-owned state
Presentation Placement, labels and the relationship to the game's rendering resolution

Do not assume a visual menu automatically has arrow-key navigation, remappable shortcuts, controller support or saved settings. Add and verify the paths you intend to support.

Keep coordinates in the same space

If a game renders to a fixed logical resolution or letterboxes the view, the mouse position in the window is not necessarily the position inside the game view.

The context's view-coordinate helper maps window coordinates into ctx.fixed_res; without a fixed resolution it returns the input unchanged. If the UI uses a different logical resolution from that internal render resolution, apply the additional scale too before hit testing. Then check the same action after changing the window size. A correct-looking button that responds beside its label often indicates a coordinate-space mismatch.

Tip. Test near the edges of a button, not only its center. This helps reveal a scale or offset problem before the menu becomes more complex.

Connect the menu to updates

Opening a menu is a state transition. Decide whether gameplay continues behind it, whether movement inputs should be consumed or released, and how the player returns.

The template specification proposes an Escape menu with Resume, Settings, Graphics, Audio and Controls. Those are design requirements in the template, not widgets that the empty scaffold already creates. Implement the actual screens and actions before documenting them as player controls.

If a menu action changes audio or presentation, apply that setting to the subsystem it controls. If the setting should survive restart, include it in the appropriate persistence policy. Storing a number without reapplying it at startup does not restore the behavior.

Use feedback and recovery

For each action, make the outcome visible. If an action fails because of missing data, unavailable resources or a game rule, preserve enough context for the player to try a supported remedy.

When investigating an interface problem:

  1. Check whether the intended screen is actually active.
  2. Check the coordinates and click/press edge the game receives.
  3. Check that the selected widget's result reaches the action handler.
  4. Check the state change separately from its drawing.
  5. Inspect again after the next rendered frame.

The harness can inject input, but a textual frame description is only useful if the game implements that description. Its default is empty. Do not assume a generic UI tree or widget search is available from every game.

Features not to assume

Design material describes richer retained-widget ideas: packed widget identities, mounting, callback registries, advanced dragging, permission bits, cooldown bindings and undo history. Those ideas are not the implemented immediate-mode API merely because they appear in a document.

Likewise, a game-specific dialogue menu is not a general dialogue authoring service. Build the smallest working interface with the actual API, then extend it with explicit state and tests.

For a visual mismatch, see scenes and presentation. For input that repeats or stays held, see time and input.