1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
use amethyst::{ ecs::prelude::*, renderer::Blink, }; use amethyst_imgui::imgui; use crate::Inspect; use imgui::im_str; impl<'a> Inspect<'a> for Blink { type SystemData = (ReadStorage<'a, Self>, Read<'a, LazyUpdate>); fn can_add(_: &mut Self::SystemData, _: ::amethyst::ecs::Entity) -> bool { true } fn inspect((storage, lazy): &mut Self::SystemData, entity: Entity) { amethyst_imgui::with(|ui| { let &Blink { mut delay, timer, mut absolute_time, } = if let Some(x) = storage.get(entity) { x } else { return; }; ui.push_id(im_str!("blink")); let mut changed = ui.drag_float(im_str!("delay"), &mut delay) .speed(0.1) .build(); changed = ui.checkbox(im_str!("absolute time"), &mut absolute_time) || changed; if changed { lazy.insert( entity, Blink { delay, timer, absolute_time, }, ); } ui.pop_id(); }); } fn add((_storage, lazy): &mut Self::SystemData, entity: Entity) { lazy.insert( entity, Blink { delay: 0.5, timer: 0., absolute_time: false, }, ); } }