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
|
|
@ -5,6 +5,12 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
bevy = { workspace = true }
|
||||
bevy_egui = { workspace = true }
|
||||
|
||||
ui_state = { path = "../ui_state" }
|
||||
resources = { path = "../resources" }
|
||||
building = { path = "../building" }
|
||||
building_placement = { path = "../building_placement" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -3,9 +3,59 @@
|
|||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::{
|
||||
EguiContexts, EguiPrimaryContextPass,
|
||||
egui::{self, Align2, RichText},
|
||||
};
|
||||
use building::BuildingInfo;
|
||||
use building_placement::SelectBuildingPreview;
|
||||
use resources::{Cost, Resources};
|
||||
use ui_state::GameUIState;
|
||||
|
||||
pub struct UiIngamePlugin;
|
||||
|
||||
impl Plugin for UiIngamePlugin {
|
||||
fn build(&self, app: &mut App) {}
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
EguiPrimaryContextPass,
|
||||
resource_ui.run_if(in_state(GameUIState::Default)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn resource_ui(
|
||||
mut contexts: EguiContexts,
|
||||
resources: Res<Resources>,
|
||||
buildings: Query<(&BuildingInfo, &Cost, &Name)>,
|
||||
mut select_writer: EventWriter<SelectBuildingPreview>,
|
||||
) {
|
||||
let ctx = contexts.ctx_mut().unwrap();
|
||||
let large_font_size = 24.;
|
||||
let font_size = 16.;
|
||||
egui::Window::new("Resources")
|
||||
.resizable(false)
|
||||
.collapsible(false)
|
||||
.title_bar(false)
|
||||
.anchor(Align2::RIGHT_TOP, [0., 0.])
|
||||
.show(ctx, |ui| {
|
||||
ui.label(RichText::new(format!("Souls: {}", resources.souls)).size(large_font_size));
|
||||
ui.heading(RichText::new("Buildings").underline());
|
||||
for (info, cost, name) in buildings.iter() {
|
||||
if !info.unlocked {
|
||||
continue;
|
||||
}
|
||||
if ui
|
||||
.button(
|
||||
RichText::new(format!(
|
||||
"{} - {} souls, {} bones",
|
||||
name, cost.souls, cost.bones
|
||||
))
|
||||
.size(font_size),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
select_writer.write(SelectBuildingPreview(Some(info.preview)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue