2025-08-30 23:39:18 -04:00
|
|
|
//bevy system signatures often violate these rules
|
|
|
|
|
#![allow(clippy::type_complexity)]
|
|
|
|
|
#![allow(clippy::too_many_arguments)]
|
|
|
|
|
|
|
|
|
|
use bevy::prelude::*;
|
2025-08-31 12:08:44 -04:00
|
|
|
use bevy_egui::{
|
|
|
|
|
EguiContexts, EguiPrimaryContextPass,
|
|
|
|
|
egui::{self, Align2, RichText},
|
|
|
|
|
};
|
|
|
|
|
use building::BuildingInfo;
|
|
|
|
|
use building_placement::SelectBuildingPreview;
|
|
|
|
|
use resources::{Cost, Resources};
|
|
|
|
|
use ui_state::GameUIState;
|
2025-08-30 23:39:18 -04:00
|
|
|
|
|
|
|
|
pub struct UiIngamePlugin;
|
|
|
|
|
|
|
|
|
|
impl Plugin for UiIngamePlugin {
|
2025-08-31 12:08:44 -04:00
|
|
|
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)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-08-30 23:39:18 -04:00
|
|
|
}
|