swarm-0.6.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.TUI.Controller.EventHandlers

Description

Swarm (abstract) event handlers allow players to customize some keybindings. This all comes together in Controller which calls the handlers for parts of UI and also handles mouse events and frame updates.

Synopsis

Documentation

createKeyDispatchers :: Has (Throw SystemFailure) sig m => KeyConfig SwarmEvent -> m SwarmKeyDispatchers Source #

Create key dispatchers that call (abstract) event handlers based on given key config.

Fails if any key events have conflict within one dispatcher or when a main dispatcher has conflict with one of the subdispatchers.

Main game handler

mainEventHandlers :: [KeyEventHandler SwarmEvent (EventM Name AppState)] Source #

Main keybindings event handler while running the game itself.

See handleMainEvent.

REPL panel handler

replEventHandlers :: [KeyEventHandler SwarmEvent (EventM Name AppState)] Source #

Handle a user input key event for the REPL.

See handleREPLEvent.

World panel handler

worldEventHandlers :: [KeyEventHandler SwarmEvent (EventM Name AppState)] Source #

Handle a user input event in the world view panel.

Robot panel handler

robotEventHandlers :: [KeyEventHandler SwarmEvent (EventM Name AppState)] Source #

Handle key events in the robot panel.

handleRobotPanelEvent :: BrickEvent Name AppEvent -> EventM Name AppState () Source #

Handle user input events in the robot panel.

Frame

runFrameUI :: Bool -> EventM Name AppState () Source #

Run the game for a single frame (i.e. screen redraw), then update the UI. Depending on how long it is taking to draw each frame, and how many ticks per second we are trying to achieve, this may involve stepping the game any number of ticks (including zero).

runGameTickUI :: EventM Name AppState () Source #

Run the game for a single tick, and update the UI.