Struct bevy_quickmenu::QuickMenuPlugin
source · pub struct QuickMenuPlugin<S>where
S: ScreenTrait + 'static,{ /* private fields */ }Expand description
The quickmenu plugin. It requires multiple generic parameters in order to setup. A minimal example. For a full explanation refer to the examples or the README.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
enum Actions {
SoundOn,
SoundOff,
}
#[derive(Debug)]
enum MyEvent { SoundChanged }
impl ActionTrait for Actions {
type State = CustomState;
type Event = MyEvent;
fn handle(&self, state: &mut CustomState, event_writer: &mut EventWriter<MyEvent>) {
// handle action
}
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
enum Screens {
Root,
Sound,
}
impl ScreenTrait for Screens {
fn resolve(&self, state: &CustomState) -> Menu<Actions, Screens, CustomState> {
root_menu(state)
}
}
fn root_menu(_state: &CustomState) -> Menu<Actions, Screens, CustomState> {
Menu {
id: "root",
entries: vec![
MenuItem::headline("Sound Control"),
MenuItem::action("Sound On", Actions::SoundOn),
MenuItem::screen("Sound Off", Actions::SoundOff),
]
}
}
#[derive(Debug, Clone)]
struct CustomState { sound_on: bool }
impl Plugin for MyApp {
fn build(&self, app: &mut App) {
app
.add_event::<MyEvent>()
.add_plugin(QuickMenuPlugin::<CustomState, Actions, Screens>::default())
}
}Implementations§
source§impl<S> QuickMenuPlugin<S>where
S: ScreenTrait + 'static,
impl<S> QuickMenuPlugin<S>where
S: ScreenTrait + 'static,
pub fn new() -> Self
pub fn with_options(options: MenuOptions) -> Self
Trait Implementations§
source§impl<State, A, S> Plugin for QuickMenuPlugin<S>where
State: 'static + Send + Sync,
A: ActionTrait<State = State> + 'static,
S: ScreenTrait<Action = A, State = State> + 'static,
impl<State, A, S> Plugin for QuickMenuPlugin<S>where
State: 'static + Send + Sync,
A: ActionTrait<State = State> + 'static,
S: ScreenTrait<Action = A, State = State> + 'static,
Auto Trait Implementations§
impl<S> RefUnwindSafe for QuickMenuPlugin<S>where
S: RefUnwindSafe,
impl<S> Send for QuickMenuPlugin<S>
impl<S> Sync for QuickMenuPlugin<S>
impl<S> Unpin for QuickMenuPlugin<S>where
S: Unpin,
impl<S> UnwindSafe for QuickMenuPlugin<S>where
S: UnwindSafe,
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T [ShaderType] for self. When used in [AsBindGroup]
derives, it is safe to assume that all images in self exist. Read more§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more