Bindings class final
What each thing on a device does, and the only place that answers it.
Two properties it has to have, and both come from the same requirement — that a player can change this and keep the change:
- Many sources, one action.
Wand the up arrow both walk forward, and a pad's stick and the keyboard have to coexist rather than replace each other. - Round-trips as text. toJson and Bindings.fromJson are how the change survives the process, and they name actions and sources rather than numbering them, so a saved file read by a later build with more actions in it still means what it said.
Unknown names read back are kept, not dropped. A config written by a
build that had a grapple and read by one that does not should still have
its grapple when the feature comes back, and a reader that silently prunes
what it does not recognise is a reader that quietly destroys the file every
time it loads it.
Constructors
-
Bindings([Map<
InputSource, GameAction> ? initial]) -
Bindings.fromJson(Map<
String, Object?> json) -
Reads a table written by toJson.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- length → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sources
→ Iterable<
InputSource> -
Every source bound to anything.
no setter
Methods
-
bind(
InputSource source, GameAction action) → void -
Points
sourceataction, replacing whatever it did before. -
clearAction(
GameAction action) → void -
Frees every source pointing at
action. -
copy(
) → Bindings -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sourcesFor(
GameAction action) → Iterable< InputSource> -
Everything currently bound to
action, for a screen that lists them. -
takeFrom(
Bindings other) → void -
Becomes a copy of
other, in place. -
toJson(
) → Map< String, Object?> -
toString(
) → String -
A string representation of this object.
inherited
-
unbind(
InputSource source) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
InputSource source) → GameAction? -
What
sourcedoes, or null if it does nothing.