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

Swarm.TUI.View

Description

Code for drawing the TUI.

Synopsis

Documentation

drawUI :: AppState -> [Widget Name] Source #

The main entry point for drawing the entire UI. Figures out which menu screen we should show (if any), or just the game itself.

drawTPS :: AppState -> Widget Name Source #

Draw info about the current number of ticks per second.

Dialog box

drawDialog :: AppState -> Widget Name Source #

Draw a dialog window, if one should be displayed right now.

chooseCursor :: AppState -> [CursorLocation n] -> Maybe (CursorLocation n) Source #

Hide the cursor when a modal is set

Key hint menu

drawKeyMenu :: AppState -> Widget Name Source #

Draw a menu explaining what key commands are available for the current panel. This menu is displayed as one or two lines in between the world panel and the REPL.

This excludes the F-key modals that are shown elsewhere.

drawModalMenu :: AppState -> Widget Name Source #

Draw the F-key modal menu. This is displayed in the top left world corner.

drawKeyCmd :: (KeyHighlight, Text, Text) -> Widget Name Source #

Draw a single key command in the menu.

World

drawWorldPane :: UIState -> GameState -> Widget Name Source #

Draw the current world view.

Robot panel

drawRobotPanel :: AppState -> Widget Name Source #

Draw info about the currently focused robot, such as its name, position, orientation, and inventory, as long as it is not too far away.

drawItem Source #

Arguments

:: Maybe Int

The index of the currently selected inventory entry

-> Int

The index of the entry we are drawing

-> Bool

Whether this entry is selected; we can ignore this because it will automatically have a special attribute applied to it.

-> InventoryListEntry

The entry to draw.

-> Widget Name 

Draw an inventory entry.

drawLabelledEntityName :: Entity -> Widget Name Source #

Draw the name of an entity, labelled with its visual representation as a cell in the world.

renderDutyCycle :: GameState -> Robot -> Widget Name Source #

Render the percentage of ticks that this robot was active. This indicator can take some time to "warm up" and stabilize due to the sliding window.

Use of previous tick

The gameTick function runs all robots, then increments the current tick. So at the time we are rendering a frame, the current tick will always be strictly greater than any ticks stored in the WindowedCounter for any robot; hence getOccupancy will never be 1 if we use the current tick directly as obtained from the ticks function. So we "rewind" it to the previous tick for the purpose of this display.

Info panel

drawInfoPanel :: AppState -> Widget Name Source #

Draw the info panel in the bottom-left corner, which shows info about the currently focused inventory item.

explainFocusedItem :: AppState -> Widget Name Source #

Display info about the currently focused inventory entity, such as its description and relevant recipes.

REPL

drawREPL :: AppState -> Widget Name Source #

Draw the REPL.