License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Code for drawing the TUI.
Synopsis
- drawUI :: AppState -> [Widget Name]
- drawTPS :: AppState -> Widget Name
- drawDialog :: AppState -> Widget Name
- chooseCursor :: AppState -> [CursorLocation n] -> Maybe (CursorLocation n)
- drawKeyMenu :: AppState -> Widget Name
- drawModalMenu :: AppState -> Widget Name
- drawKeyCmd :: (KeyHighlight, Text, Text) -> Widget Name
- drawWorldPane :: UIState -> GameState -> Widget Name
- drawRobotPanel :: AppState -> Widget Name
- drawItem :: Maybe Int -> Int -> Bool -> InventoryListEntry -> Widget Name
- drawLabelledEntityName :: Entity -> Widget Name
- renderDutyCycle :: GameState -> Robot -> Widget Name
- drawInfoPanel :: AppState -> Widget Name
- explainFocusedItem :: AppState -> Widget Name
- drawREPL :: AppState -> Widget Name
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.
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
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.
:: 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.