Skip to main content

Ask

Struct Ask 

Source
pub struct Ask<T> { /* private fields */ }
Expand description

A question and its answers, each a T the screen acts on.

Implementations§

Source§

impl<T: Copy + PartialEq> Ask<T>

Source

pub const ACTIONS: &'static [UiAction] = crate::input::NAVIGATION

What a question reacts to (handle), for the screen that shows it to declare (Screen::actions).

Source

pub fn new( key: &'static str, answers: impl IntoIterator<Item = (T, &'static str)>, ) -> Self

The question of the text key key with answers (each an answer and the text key of its name), the first in focus. Cancel does nothing until cancelled_by names an answer.

Source

pub fn focused_on(self, answer: T) -> Self

The same question focused on answer (on the first while it isn’t one of the answers).

Source

pub fn cancelled_by(self, answer: T) -> Self

The same question, which Cancel answers with answer (going back, say).

Source

pub fn key(&self) -> &'static str

The text key of the question; also what names it.

Source

pub fn focus(&self) -> Option<T>

The answer in focus; None with no answers.

Source

pub fn cancel(&self) -> Option<T>

What Cancel answers, if anything.

Source

pub fn handle<A: ActionSet, V>( &mut self, action: A, audio: &mut AudioQueue<V>, ) -> Option<T>

An action while the question is open. The cursor’s keys move the focus to the next answer (right and down) or the one before (left and up), going round at the ends, with the menu’s move sound on audio. Confirm gives the answer in focus, Cancel the answer it stands for (cancelled_by); anything else gives nothing. An answer’s own sound is the screen’s to play: what it does may still be refused.

Source

pub fn view<G: GameData>(&self, ctx: &Ctx<G>) -> AskView<T>

The question as it is now, as plain data for a skin to paint (glyph::paint): its text and its answers, or the line naming its keys, in the player’s language naming the active keys.

Source

pub fn view_with_keys<G: GameData>( &self, ctx: &Ctx<G>, keys: HelpKeys<'_, G::Action>, args: &[(&str, &dyn Display)], ) -> AskView<T>

view, naming the keys keys has rather than the active ones, and filling the question’s placeholders from args (Ctx::text_with_keys).

Source§

impl Ask<bool>

Source

pub fn yes_no(key: &'static str, keys: &'static str) -> Self

A yes/no question of the text key key: Confirm answers yes (true) and Cancel no (false). It shows no answers to move between, but the line of the text key keys, which names the keys for yes and no.

Trait Implementations§

Source§

impl<T: Clone> Clone for Ask<T>

Source§

fn clone(&self) -> Ask<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Ask<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq> Eq for Ask<T>

Source§

impl<T: PartialEq> PartialEq for Ask<T>

Source§

fn eq(&self, other: &Ask<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for Ask<T>

Auto Trait Implementations§

§

impl<T> Freeze for Ask<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Ask<T>
where T: RefUnwindSafe,

§

impl<T> Send for Ask<T>
where T: Send,

§

impl<T> Sync for Ask<T>
where T: Sync,

§

impl<T> Unpin for Ask<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Ask<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Ask<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.