#[non_exhaustive]pub enum RowValue<G: GameData> {
#[non_exhaustive] Toggle {
get: fn(&Ctx<G>) -> bool,
set: fn(&mut Ctx<G>, bool) -> bool,
},
#[non_exhaustive] Choice {
values: fn(&Ctx<G>) -> Vec<&'static str>,
get: fn(&Ctx<G>) -> usize,
set: fn(&mut Ctx<G>, usize) -> bool,
shown: Option<fn(&Ctx<G>) -> String>,
},
#[non_exhaustive] Volume {
get: fn(&Ctx<G>) -> u8,
set: fn(&mut Ctx<G>, u8) -> bool,
},
#[non_exhaustive] Action {
value: fn(&Ctx<G>) -> Option<String>,
confirm: fn(&mut Ctx<G>) -> RowAction<G>,
help: fn(&Ctx<G>) -> &'static str,
},
}Expand description
What a row shows beside its label, and what changes it. Build it with
RowValue::toggle, choice,
volume or action: kinds of
row and their fields may come, and never break a game (ADR-0039).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
#[non_exhaustive]Toggle
On or off: the cursor’s left key turns it off, the right key on, Confirm the other way.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Choice
One of several values: the cursor’s keys step through them, stopping at the ends, and Confirm goes round.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Volume
A volume, 0 to MAX_VOLUME: the keys move its slider by
VOLUME_STEP, Confirm opens a box to type the number.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Action
Something Confirm does.
Fields
This variant is marked as non-exhaustive
Implementations§
Source§impl<G: GameData> RowValue<G>
impl<G: GameData> RowValue<G>
Sourcepub const fn toggle(
get: fn(&Ctx<G>) -> bool,
set: fn(&mut Ctx<G>, bool) -> bool,
) -> Self
pub const fn toggle( get: fn(&Ctx<G>) -> bool, set: fn(&mut Ctx<G>, bool) -> bool, ) -> Self
An on-or-off row: get says whether it is on, set turns it on or
off.
Sourcepub const fn choice(
values: fn(&Ctx<G>) -> Vec<&'static str>,
get: fn(&Ctx<G>) -> usize,
set: fn(&mut Ctx<G>, usize) -> bool,
) -> Self
pub const fn choice( values: fn(&Ctx<G>) -> Vec<&'static str>, get: fn(&Ctx<G>) -> usize, set: fn(&mut Ctx<G>, usize) -> bool, ) -> Self
A row of one of values: get says which it shows, set puts one
in.
Sourcepub const fn choice_shown(
values: fn(&Ctx<G>) -> Vec<&'static str>,
get: fn(&Ctx<G>) -> usize,
set: fn(&mut Ctx<G>, usize) -> bool,
shown: fn(&Ctx<G>) -> String,
) -> Self
pub const fn choice_shown( values: fn(&Ctx<G>) -> Vec<&'static str>, get: fn(&Ctx<G>) -> usize, set: fn(&mut Ctx<G>, usize) -> bool, shown: fn(&Ctx<G>) -> String, ) -> Self
A row of one of values, as choice is, that
shows what shown says rather than the text of its value’s key: a
value with a number in it.