pub struct KeyBindingsScreen<G: GameData> { /* private fields */ }Expand description
The Key bindings screen for one layout and the controller. Cancel saves and closes it, unless a required action has no key or no button.
Implementations§
Source§impl<G: GameData> KeyBindingsScreen<G>
impl<G: GameData> KeyBindingsScreen<G>
Sourcepub const NAME: &'static str = "key_bindings"
pub const NAME: &'static str = "key_bindings"
Name reported by Screen::name.
Sourcepub fn new(ctx: &Ctx<G>, rows: &'static [KeyRow<G::Action>]) -> Self
pub fn new(ctx: &Ctx<G>, rows: &'static [KeyRow<G::Action>]) -> Self
The screen listing rows, for the layout in use (the keymap file’s
first if none is chosen yet), focused on the first action’s first
slot, showing the side the player pressed last: the controller’s
buttons after a button press, else the keys. With no keyboard
(Keyboard::Absent) it shows the controller’s alone.
Sourcepub fn painted_by(self, paint: Paint<G>) -> Self
pub fn painted_by(self, paint: Paint<G>) -> Self
The same screen with its view painted by paint instead of
glyph::paint: a game’s look for a device of its own.
Sourcepub fn is_controller_only(&self) -> bool
pub fn is_controller_only(&self) -> bool
Whether only the controller side is shown: the platform has no keyboard, so there is no switch.
Sourcepub fn with_bindings(self, bindings: LayoutBindings<G::Action>) -> Self
pub fn with_bindings(self, bindings: LayoutBindings<G::Action>) -> Self
The same screen editing bindings instead of the saved ones.
Sourcepub fn bindings(&self) -> &LayoutBindings<G::Action>
pub fn bindings(&self) -> &LayoutBindings<G::Action>
The edited keys (saved when the screen closes).
Sourcepub fn pad_bindings(&self) -> &PadBindings<G::Action>
pub fn pad_bindings(&self) -> &PadBindings<G::Action>
The edited controller buttons (saved when the screen closes).
Sourcepub fn focus(&self) -> Option<(G::Action, usize)>
pub fn focus(&self) -> Option<(G::Action, usize)>
The focused action and slot; None on Restore defaults and on the
keyboard / controller switch.
Sourcepub fn is_on_switch(&self) -> bool
pub fn is_on_switch(&self) -> bool
Whether the focus is on the keyboard / controller switch.
Sourcepub fn is_capturing(&self) -> bool
pub fn is_capturing(&self) -> bool
Whether the focused slot is waiting for a key or button.
Sourcepub fn is_asking_restore(&self) -> bool
pub fn is_asking_restore(&self) -> bool
Whether the screen is asking before it restores the defaults.
Sourcepub fn restore_question(&self, ctx: &Ctx<G>) -> String
pub fn restore_question(&self, ctx: &Ctx<G>) -> String
The question asked before restoring the shown side’s defaults.
Sourcepub fn help(&self, ctx: &Ctx<G>) -> String
pub fn help(&self, ctx: &Ctx<G>) -> String
The bottom help line, naming the keys the screen was opened with
(or their buttons, on a controller): the same as ctx’s until the
screen closes.
Sourcepub fn view(&self, ctx: &Ctx<G>) -> KeyBindingsView<G::Action>
pub fn view(&self, ctx: &Ctx<G>) -> KeyBindingsView<G::Action>
The screen as it is now, as plain data for a skin to paint
(glyph::paint): the switch, the slot columns, every action with
what its slots hold, the restore row, the message, the question or
the choices open, and the help line, all in the player’s language
and naming their keys.
Trait Implementations§
Source§impl<G: GameData> Clone for KeyBindingsScreen<G>
impl<G: GameData> Clone for KeyBindingsScreen<G>
Source§impl<G: GameData> Debug for KeyBindingsScreen<G>
impl<G: GameData> Debug for KeyBindingsScreen<G>
Source§impl<G: GameData> Screen<G> for KeyBindingsScreen<G>
impl<G: GameData> Screen<G> for KeyBindingsScreen<G>
Source§fn actions(&self) -> Option<Vec<G::Action>>
fn actions(&self) -> Option<Vec<G::Action>>
Its rows and slots, and its questions; the keys and buttons it captures are not actions.
Source§fn update(
&mut self,
ctx: &mut Ctx<G>,
input: &FrameInput<G::Action>,
) -> Transition<G>
fn update( &mut self, ctx: &mut Ctx<G>, input: &FrameInput<G::Action>, ) -> Transition<G>
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)
fn draw(&self, ctx: &Ctx<G>, buf: &mut GlyphBuffer)
Source§fn as_any(&self) -> Option<&dyn Any>
fn as_any(&self) -> Option<&dyn Any>
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)
fn debug_draw(&self, ctx: &Ctx<G>, out: &mut Gizmos)
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
fn is_overlay(&self) -> bool
Source§fn state_hash(&self) -> Option<StateHash>
fn state_hash(&self) -> Option<StateHash>
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>
fn as_any_mut(&mut self) -> Option<&mut dyn Any>
as_any, mutable (ScreenStack::find_mut).Source§fn covered(&mut self, _ctx: &mut Ctx<G>)
fn covered(&mut self, _ctx: &mut Ctx<G>)
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>
fn uncovered( &mut self, ctx: &mut Ctx<G>, result: Option<ScreenResult>, ) -> Transition<G>
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