forked from Brickworks/yahs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: sim state monitoring, play/pause
- Loading branch information
1 parent
b087019
commit 88ce33b
Showing
15 changed files
with
386 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
mod scene; | ||
mod ui; | ||
mod controls; | ||
|
||
// Re-export the plugins so they can be added to the app with `app.add_plugins`. | ||
pub use scene::ScenePlugin; | ||
pub use ui::InterfacePlugins; | ||
pub use controls::{ControlsPlugin, KeyBindingsConfig}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use bevy::{app::PluginGroupBuilder, prelude::*}; | ||
use iyes_perf_ui::prelude::*; | ||
|
||
use crate::controls::KeyBindingsConfig; | ||
use crate::simulator::SimState; | ||
|
||
use super::*; | ||
|
||
/// A plugin group that includes all interface-related plugins | ||
pub struct InterfacePlugins; | ||
|
||
impl PluginGroup for InterfacePlugins { | ||
fn build(self) -> PluginGroupBuilder { | ||
PluginGroupBuilder::start::<Self>() | ||
.add(CoreUiPlugin) | ||
.add(PausePlayPlugin) | ||
.add(monitors::MonitorsPlugin) | ||
} | ||
} | ||
|
||
/// Base UI plugin. This sets up the base plugins that all other ui plugins | ||
/// need. .Placeholder for now | ||
pub struct CoreUiPlugin; | ||
|
||
impl Plugin for CoreUiPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_plugins(( | ||
PerfUiPlugin, | ||
#[cfg(feature = "dev")] | ||
dev_tools::plugin, | ||
)); | ||
} | ||
} | ||
|
||
pub struct PausePlayPlugin; | ||
|
||
impl Plugin for PausePlayPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_systems(Update, toggle_pause); | ||
} | ||
} | ||
|
||
fn toggle_pause( | ||
sim_state: Res<State<SimState>>, | ||
mut next_state: ResMut<NextState<SimState>>, | ||
key_input: Res<ButtonInput<KeyCode>>, | ||
key_bindings: Res<KeyBindingsConfig>, | ||
) { | ||
if key_input.just_pressed(key_bindings.time_controls.toggle_pause) { | ||
match sim_state.as_ref().get() { | ||
SimState::Stopped => next_state.set(SimState::Running), | ||
SimState::Running => next_state.set(SimState::Stopped), | ||
_ => () | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,7 @@ | ||
// mod monitors; | ||
mod core; | ||
mod monitors; | ||
|
||
#[cfg(feature = "dev")] | ||
mod dev_tools; | ||
|
||
use bevy::{app::PluginGroupBuilder, prelude::*}; | ||
use iyes_perf_ui::prelude::*; | ||
|
||
/// A plugin group that includes all interface-related plugins | ||
pub struct InterfacePlugins; | ||
|
||
impl PluginGroup for InterfacePlugins { | ||
fn build(self) -> PluginGroupBuilder { | ||
PluginGroupBuilder::start::<Self>() | ||
.add(CoreUiPlugin) | ||
.add(monitors::ForceMonitorPlugin) | ||
} | ||
} | ||
|
||
/// Base UI plugin. This sets up the base plugins that all other ui plugins | ||
/// need. .Placeholder for now | ||
pub struct CoreUiPlugin; | ||
|
||
impl Plugin for CoreUiPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_plugins(( | ||
PerfUiPlugin, | ||
#[cfg(feature = "dev")] | ||
dev_tools::plugin, | ||
)); | ||
} | ||
} | ||
pub use core::InterfacePlugins; |
Oops, something went wrong.