add tower selection UI, cancellable actions, and pause UI
This commit is contained in:
parent
138a524abd
commit
918b4884b2
18 changed files with 468 additions and 23 deletions
|
|
@ -3,7 +3,11 @@
|
|||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use bevy::prelude::*;
|
||||
use input::{actions::InputAction, conditions::action_just_pressed};
|
||||
use bevy_egui::{
|
||||
EguiContexts, EguiPrimaryContextPass,
|
||||
egui::{self, Align2, RichText},
|
||||
};
|
||||
use input::{Cancellable, actions::InputAction, conditions::action_just_pressed};
|
||||
use state::GameState;
|
||||
|
||||
pub struct UiPausePlugin;
|
||||
|
|
@ -13,11 +17,35 @@ impl Plugin for UiPausePlugin {
|
|||
app.add_systems(
|
||||
Update,
|
||||
toggle_pause.run_if(action_just_pressed::<Update>(InputAction::TogglePause)),
|
||||
)
|
||||
.add_systems(
|
||||
EguiPrimaryContextPass,
|
||||
pause_screen.run_if(in_state(GameState::Paused)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_pause(state: Res<State<GameState>>, mut next_state: ResMut<NextState<GameState>>) {
|
||||
fn pause_screen(mut contexts: EguiContexts) {
|
||||
let ctx = contexts.ctx_mut().unwrap();
|
||||
egui::Window::new("Pause")
|
||||
.resizable(false)
|
||||
.collapsible(false)
|
||||
.title_bar(false)
|
||||
.anchor(Align2::CENTER_CENTER, [0., 0.])
|
||||
.show(ctx, |ui| {
|
||||
ui.label(RichText::new(format!("Paused")).size(64.));
|
||||
});
|
||||
}
|
||||
|
||||
fn toggle_pause(
|
||||
state: Res<State<GameState>>,
|
||||
mut next_state: ResMut<NextState<GameState>>,
|
||||
query: Query<(), With<Cancellable>>,
|
||||
) {
|
||||
if !query.is_empty() {
|
||||
// cancelling takes priority over pausing
|
||||
return;
|
||||
}
|
||||
let next = match state.get() {
|
||||
GameState::Loading => GameState::Loading,
|
||||
GameState::Running => GameState::Paused,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue