Skip to main content

LayoutPickerScreen

Struct LayoutPickerScreen 

Source
pub struct LayoutPickerScreen<G: GameData> { /* private fields */ }
Expand description

Shows every layout and saves the one picked. Asked for by a key press while no layout is chosen, it can’t be cancelled with a key (the keyboard needs a layout), but any controller button closes it without choosing: that player is on the controller. Pops itself once a layout is picked.

Implementations§

Source§

impl<G: GameData> LayoutPickerScreen<G>

Source

pub const NAME: &'static str = "layout_picker"

Source

pub fn new(ctx: &Ctx<G>, legend: &'static Legend<G::Action>) -> Self

The picker with the first layout focused, its legend listing legend.

Source

pub fn change(ctx: &Ctx<G>, legend: &'static Legend<G::Action>) -> Self

The picker as the options open it, to switch layout: the layout in use focused, and Cancel backs out without changing anything.

Source

pub fn focused(&self) -> Option<Layout>

The focused layout (None only for a keymap with no layouts, which the loader refuses).

Source

pub fn help(ctx: &Ctx<G>) -> String

The bottom help line: every Cursor up and Cursor down key, then every Confirm key, from the active keymap (before any layout is chosen, the layout picker’s own keys).

Source

pub fn legend(&self, ctx: &Ctx<G>, km: &Keymap<G::Action>) -> Vec<LegendRow>

The legend for km, in ctx’s language: the keys and what they do; an action with no key shows ! not mapped. Always its keyboard keys: the screen is about the keyboard’s layouts.

Source

pub fn view(&self, ctx: &Ctx<G>) -> LayoutPickerView

The screen as it is now, as plain data for a skin to paint (glyph::paint): each layout with its legend and what every key of its keyboard does, the one in focus, and the help line.

Trait Implementations§

Source§

impl<G: GameData> Clone for LayoutPickerScreen<G>

Source§

fn clone(&self) -> Self

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<G: GameData> Debug for LayoutPickerScreen<G>

Source§

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

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

impl<G: GameData> Screen<G> for LayoutPickerScreen<G>

Source§

fn actions(&self) -> Option<Vec<G::Action>>

Its menu’s.

Source§

fn name(&self) -> &'static str

A stable, unique snake_case name, for tests and debugging.
Source§

fn update( &mut self, ctx: &mut Ctx<G>, input: &FrameInput<G::Action>, ) -> Transition<G>

Handles one frame: input holds this frame’s actions (often none) and elapsed time. Called only while this screen is on top.
Source§

fn draw(&self, ctx: &Ctx<G>, buf: &mut GlyphBuffer)

Paints the screen. An opaque screen must cover the whole buffer.
Source§

fn as_any(&self) -> Option<&dyn Any>

This screen as Any, for tests that look inside a screen on the stack (ScreenStack::find). None unless the screen opts in.
Source§

fn debug_draw(&self, ctx: &Ctx<G>, out: &mut Gizmos)

Hands in what the debug view shows of this screen (ADR-0085): its gizmos, each in its channel, in console pixels, built from self and ctx alone, so looking changes nothing. A channel’s helper (the grid kit’s layout_gizmos) does the work. Called after draw on every screen drawn, bottom up, only while debug tools are on (Ctx::debug_tools). Does nothing unless the screen has something to show.
Source§

fn is_overlay(&self) -> bool

Whether the screen below shows through (drawn first, then this one).
Source§

fn state_hash(&self) -> Option<StateHash>

The hash of the game’s state this screen holds, which goes in each frame’s hash in a session record (Game::state_hash), most simply shuyi_core::state_hash(&self.rules).ok(): so a playback that plays differently is found at the frame the state moved. None unless the screen opts in.
Source§

fn as_any_mut(&mut self) -> Option<&mut dyn Any>

Source§

fn covered(&mut self, _ctx: &mut Ctx<G>)

Called when a screen is pushed on top of this one (Transition::Push): it is no longer updated until it is uncovered. Not called when the screen above swaps itself for another (Transition::Replace). Does nothing unless the screen needs it.
Source§

fn uncovered( &mut self, ctx: &mut Ctx<G>, result: Option<ScreenResult>, ) -> Transition<G>

Called when the screen above pops and this one is on top again: result is what it popped with (Transition::PopWith), None after a plain Transition::Pop. The transition returned is applied at once, as if from update, so a screen can act on the answer in the same frame: push the next screen, or pop with an answer of its own. By default, nothing happens. Read more

Auto Trait Implementations§

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.