swarm-0.3.0.1: 2D resource gathering game with programmable robots
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.TUI.Model.UI

Synopsis

Documentation

data GoalDisplay Source #

Constructors

GoalDisplay 

Fields

uiMenu :: Lens' UIState Menu Source #

The current menu state.

uiPlaying :: Lens' UIState Bool Source #

Are we currently playing the game? True = we are playing, and should thus display a world, REPL, etc.; False = we should display the current menu.

uiCheatMode :: Lens' UIState Bool Source #

Cheat mode, i.e. are we allowed to turn creative mode on and off?

uiFocusRing :: Lens' UIState (FocusRing Name) Source #

The focus ring is the set of UI panels we can cycle among using the Tab key.

uiWorldCursor :: Lens' UIState (Maybe Coords) Source #

The last clicked position on the world view.

uiREPL :: Lens' UIState REPLState Source #

The state of REPL panel.

uiInventory :: Lens' UIState (Maybe (Int, List Name InventoryListEntry)) Source #

The hash value of the focused robot entity (so we can tell if its inventory changed) along with a list of the items in the focused robot's inventory.

uiInventorySort :: Lens' UIState InventorySortOptions Source #

The order and direction of sorting inventory list.

uiMoreInfoTop :: Lens' UIState Bool Source #

Does the info panel contain more content past the top of the panel?

uiMoreInfoBot :: Lens' UIState Bool Source #

Does the info panel contain more content past the bottom of the panel?

uiScrollToEnd :: Lens' UIState Bool Source #

A flag telling the UI to scroll the info panel to the very end (used when a new log message is appended).

uiError :: Lens' UIState (Maybe Text) Source #

When this is Just, it represents a popup box containing an error message that is shown on top of the rest of the UI.

uiModal :: Lens' UIState (Maybe Modal) Source #

When this is Just, it represents a modal to be displayed on top of the UI, e.g. for the Help screen.

uiGoal :: Lens' UIState GoalDisplay Source #

Status of the scenario goal: whether there is one, and whether it has been displayed to the user initially.

uiAchievements :: Lens' UIState (Map CategorizedAchievement Attainment) Source #

Map of achievements that were attained

lgTicksPerSecond :: Lens' UIState Int Source #

The base-2 logarithm of the current game speed in ticks/second. Note that we cap this value to the range of +/- log2 INTMAX.

lastFrameTime :: Lens' UIState TimeSpec Source #

The time of the last Frame event.

accumulatedTime :: Lens' UIState TimeSpec Source #

The amount of accumulated real time. Every time we get a Frame event, we accumulate the amount of real time that happened since the last frame, then attempt to take an appropriate number of ticks to "catch up", based on the target tick rate.

See https://gafferongames.com/post/fix_your_timestep/ .

tickCount :: Lens' UIState Int Source #

A counter used to track how many ticks have happened since the last time we updated the ticks/frame statistics.

frameCount :: Lens' UIState Int Source #

A counter used to track how many frames have been rendered since the last time we updated the ticks/frame statistics.

frameTickCount :: Lens' UIState Int Source #

A counter used to track how many ticks have happened in the current frame, so we can stop when we get to the tick cap.

lastInfoTime :: Lens' UIState TimeSpec Source #

The time of the last info widget update

uiShowFPS :: Lens' UIState Bool Source #

A toggle to show the FPS by pressing f

uiShowZero :: Lens' UIState Bool Source #

A toggle to show or hide inventory items with count 0 by pressing `0`

uiShowRobots :: Getter UIState Bool Source #

Whether to show or hide robots on the world map.

uiHideRobotsUntil :: Lens' UIState TimeSpec Source #

Hide robots on the world map.

uiInventoryShouldUpdate :: Lens' UIState Bool Source #

Whether the Inventory ui panel should update

uiTPF :: Lens' UIState Double Source #

Computed ticks per milli seconds

uiFPS :: Lens' UIState Double Source #

Computed frames per milli seconds

scenarioRef :: Lens' UIState (Maybe ScenarioInfoPair) Source #

The currently active Scenario description, useful for starting over.

appData :: Lens' UIState (Map Text Text) Source #

Free-form data loaded from the data directory, for things like the logo, about page, tutorial story, etc.

Initialization

initFocusRing :: FocusRing Name Source #

The initial state of the focus ring.

initLgTicksPerSecond :: Int Source #

The initial tick speed.

initUIState :: Bool -> Bool -> ExceptT Text IO ([SystemFailure], UIState) Source #

Initialize the UI state. This needs to be in the IO monad since it involves reading a REPL history file, getting the current time, and loading text files from the data directory. The Bool parameter indicates whether we should start off by showing the main menu.