Skip to main content

ActionSet

Trait ActionSet 

Source
pub trait ActionSet:
    Copy
    + Ord
    + Eq
    + Hash
    + Debug
    + 'static {
    type Group: Copy + Ord + Eq + Debug;

    const ALL: &'static [Self];

    // Required methods
    fn name(self) -> &'static str;
    fn is_repeatable(self) -> bool;
    fn is_required(self) -> bool;
    fn is_rebindable(self) -> bool;
    fn group(self) -> Self::Group;
    fn ui(self) -> Option<UiAction>;
    fn fixed_keys() -> &'static [(Chord, Self)];

    // Provided methods
    fn from_name(name: &str) -> Option<Self> { ... }
    fn for_ui(ui: UiAction) -> Option<Self> { ... }
}
Expand description

Everything a player can ask for in one game: the game’s action enum. The keymap file, the keymap, held keys and repeat, the player’s saved bindings and help text are all built on it, never on one game’s actions.

Required Associated Constants§

Source

const ALL: &'static [Self]

Every action, in the order the game lists them (the order a repair of the saved bindings keeps the first of two claims in).

Required Associated Types§

Source

type Group: Copy + Ord + Eq + Debug

Which actions may share a key or button: a key is on at most one action of each group (game ADR-0068). () for a game where no two actions share one.

Required Methods§

Source

fn name(self) -> &'static str

The name used in keymap files and the saved bindings.

Source

fn is_repeatable(self) -> bool

Whether holding its key or button re-emits it.

Source

fn is_required(self) -> bool

Whether the player must always keep at least one key (and one button) on it.

Source

fn is_rebindable(self) -> bool

Whether the player can rebind it. One that can’t keeps the keymap file’s keys and has no controller button.

Source

fn group(self) -> Self::Group

Its Group.

Source

fn ui(self) -> Option<UiAction>

What a generic widget or screen takes it for, if anything.

Source

fn fixed_keys() -> &'static [(Chord, Self)]

The keys every keymap has on top of its own bindings, which the player can’t move or remove (this game: plain Escape cancels). Shown after an action’s own keys in help text, but never counted as a key of its own. A game with none returns &[].

Provided Methods§

Source

fn from_name(name: &str) -> Option<Self>

Looks an action up by its name (exact match).

Source

fn for_ui(ui: UiAction) -> Option<Self>

The first action that ui maps to ui, if any.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ActionSet for UiAction

The ready-made action set of a game that plays with the six moves: its keymap file names Up, Down, Left, Right, Confirm and Cancel, every one required and rebindable. UiAction::Debug is no action of the set: a game with a debug key writes its own action enum. A UiAction added later stays out of ALL too, so no game’s keymap file must name it (ADR-0036).

Source§

const ALL: &'static [UiAction]

Source§

type Group = ()