1 unstable release

0.1.0 Oct 8, 2021

#12 in #18xx

22 downloads per month
Used in navig18xx

MIT/Apache

1MB
18K SLoC

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.

Dependencies

~22MB
~492K SLoC