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

Swarm.TUI.Controller

Description

Event handlers for the TUI.

Synopsis

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)
  • advances the menu to the next scenario IF the current one was won
  • 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.

runGameTickUI :: EventM Name AppState () Source #

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

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.

data TimeDir Source #

Constructors

Newer 
Older 

Instances

Instances details
Show TimeDir Source # 
Instance details

Defined in Swarm.TUI.Model.Repl

Eq TimeDir Source # 
Instance details

Defined in Swarm.TUI.Model.Repl

Methods

(==) :: TimeDir -> TimeDir -> Bool #

(/=) :: TimeDir -> TimeDir -> Bool #

Ord TimeDir Source # 
Instance details

Defined in Swarm.TUI.Model.Repl

World panel

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

Handle a user input event in the world view panel.

keyToDir :: Key -> Heading Source #

Convert a directional key into a direction.

scrollView :: (Location -> Location) -> EventM Name AppState () Source #

Manually scroll the world view.

adjustTPS :: (Int -> Int -> Int) -> AppState -> AppState Source #

Adjust the ticks per second speed.

Info panel

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

Handle user events in the info panel (just scrolling).

Utils