Copyright | Brent Yorgey |
---|---|
License | BSD-3-Clause |
Maintainer | byorgey@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Event handlers for the TUI.
Synopsis
- handleEvent :: BrickEvent Name AppEvent -> EventM Name AppState ()
- quitGame :: EventM Name AppState ()
- runFrameUI :: EventM Name AppState ()
- runFrame :: EventM Name AppState ()
- runFrameTicks :: TimeSpec -> EventM Name AppState ()
- runGameTickUI :: EventM Name AppState ()
- runGameTick :: EventM Name AppState ()
- updateUI :: EventM Name AppState Bool
- handleREPLEvent :: BrickEvent Name AppEvent -> EventM Name AppState ()
- validateREPLForm :: AppState -> AppState
- adjReplHistIndex :: TimeDir -> AppState -> AppState
- data TimeDir
- handleWorldEvent :: BrickEvent Name AppEvent -> EventM Name AppState ()
- keyToDir :: Key -> V2 Int64
- scrollView :: (V2 Int64 -> V2 Int64) -> EventM Name AppState ()
- adjustTPS :: (Int -> Int -> Int) -> AppState -> AppState
- handleInfoPanelEvent :: ViewportScroll Name -> BrickEvent Name AppEvent -> EventM Name AppState ()
Event handling
handleEvent :: BrickEvent Name AppEvent -> EventM Name AppState () Source #
The top-level event handler for the TUI.
quitGame :: EventM Name AppState () Source #
Quit a game.
- writes out the updated REPL history to a
.swarm_history
file - saves current scenario status (InProgress/Completed)
- returns to the previous menu
Handling Frame
events
runFrameUI :: 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).
runFrame :: EventM Name AppState () Source #
Run the game for a single frame, without updating the UI.
runFrameTicks :: TimeSpec -> EventM Name AppState () Source #
Do zero or more ticks, with each tick notionally taking the given timestep, until we have used up all available accumulated time, OR until we have hit the cap on ticks per frame, whichever comes first.
runGameTick :: EventM Name AppState () Source #
Run the game for a single tick (without updating the UI). Every robot is given a certain amount of maximum computation to perform a single world action (like moving, turning, grabbing, etc.).
updateUI :: EventM Name AppState Bool Source #
Update the UI. This function is used after running the game for some number of ticks.
REPL panel
handleREPLEvent :: BrickEvent Name AppEvent -> EventM Name AppState () Source #
Handle a user input event for the REPL.
validateREPLForm :: AppState -> AppState Source #
Validate the REPL input when it changes: see if it parses and typechecks, and set the color accordingly.
adjReplHistIndex :: TimeDir -> AppState -> AppState Source #
Update our current position in the REPL history.
World panel
handleWorldEvent :: BrickEvent Name AppEvent -> EventM Name AppState () Source #
Handle a user input event in the world view panel.
scrollView :: (V2 Int64 -> V2 Int64) -> EventM Name AppState () Source #
Manually scroll the world view.
Info panel
handleInfoPanelEvent :: ViewportScroll Name -> BrickEvent Name AppEvent -> EventM Name AppState () Source #
Handle user events in the info panel (just scrolling).