[][src]Trait game::common::SimpleState

pub trait SimpleState {
    fn on_click(
        &mut self,
        ctx: &mut EventCtx<'_>,
        app: &mut App,
        action: &str,
        panel: &Panel
    ) -> Transition<App>; fn panel_changed(
        &mut self,
        _: &mut EventCtx<'_>,
        _: &mut App,
        _: &Panel
    ) -> Option<Transition<App>> { ... }
fn on_mouseover(&mut self, _: &mut EventCtx<'_>, _: &mut App) { ... }
fn other_event(
        &mut self,
        _: &mut EventCtx<'_>,
        _: &mut App
    ) -> Transition<App> { ... }
fn draw(&self, _: &mut GfxCtx<'_>, _: &App) { ... }
fn draw_baselayer(&self) -> DrawBaselayer { ... } }

Many game states fit a pattern of managing a single panel, handling mouseover events, and other interactions on the map. Implementing this instead of State reduces some boilerplate.

Required methods

fn on_click(
    &mut self,
    ctx: &mut EventCtx<'_>,
    app: &mut App,
    action: &str,
    panel: &Panel
) -> Transition<App>

Called when something on the panel has been clicked. Since the action is just a string, the fallback case can just use unreachable!().

Loading content...

Provided methods

fn panel_changed(
    &mut self,
    _: &mut EventCtx<'_>,
    _: &mut App,
    _: &Panel
) -> Option<Transition<App>>

Called when something on the panel has changed. If a transition is returned, stop handling the event and immediately apply the transition.

fn on_mouseover(&mut self, _: &mut EventCtx<'_>, _: &mut App)

Called when the mouse has moved.

fn other_event(&mut self, _: &mut EventCtx<'_>, _: &mut App) -> Transition<App>

If a panel on_click event didn't occur and panel_changed didn't return transition, then call this to handle all other events.

fn draw(&self, _: &mut GfxCtx<'_>, _: &App)

fn draw_baselayer(&self) -> DrawBaselayer

Loading content...

Implementations

impl dyn SimpleState[src]

pub fn new(panel: Panel, inner: Box<dyn SimpleState>) -> Box<dyn State<App>>[src]

Implementors

impl SimpleState for LaneEditor[src]

impl SimpleState for StopSignEditor[src]

impl SimpleState for ChangeDuration[src]

impl SimpleState for ShowAbsolute[src]

impl SimpleState for ShowRelative[src]

impl SimpleState for TuneRelative[src]

impl SimpleState for UberTurnPicker[src]

impl SimpleState for UberTurnViewer[src]

Loading content...