Crate n18ui

Crate n18ui 

Source
Expand description

Provides a user interface for managing 18xx game maps and calculating the optimal revenue for each company.

See the rusty_train binary for an example of using this crate.

§Overview

The UserInterface struct encapsulates map drawing and event handling. It is divided into several components:

  • Assets: the current Map and the available Games.
  • Canvas: the surface on which the map is drawn.
  • State: the current user interface state (or “mode”), which defines the actions available to the user and how the map is drawn.
  • Keymap: responds to keyboard and mouse input by triggering state actions.
  • Controller: manages user interface elements and collects input from the user (e.g., selecting a game file to load or save).

§Events and event handlers

There are three types of events that UserInterface handles:

Note that event details, such as key identifiers, are defined by the ButtonPress and KeyPress structs, which use types from the GDK 3 library.

§Responses to event handlers

Each of the UserInterface event handlers (listed above) return a UiResponse value, which indicates what actions the UserInterface should take (if any) once the event has been handled. These actions are performed by UserInterface::respond.

Modules§

canvas
Manage drawing surfaces.
control
Control UI elements.
keymap
Response to keyboard and mouse events.
state
The different states of the user interface.

Structs§

Assets
Defines the non-UI game state components.
ButtonPress
Describes a mouse button being clicked.
Canvas
Games
Ordered collections of available games.
KeyPress
Describes a keyboard key being pressed.
Keymap
UiAction
Global UI actions, which are not specific to the current State.
UserInterface
Defines the user interface.

Enums§

Controller
PingDest
Identify which part of the UI should respond to a “ping”.
PingSender
State
The different user interface states.
UiResponse
UI responses that may be required when the UI state changes.

Traits§

UiController
UiState
The methods that are required in order to manipulate the user interface.