From 9ea199d89a222d99f027cb9d8b4d3b11e4c1065f Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Mon, 22 May 2023 14:08:28 +0300 Subject: [PATCH] feat(client): show amount left on supply piles * also removes piles from dev details --- client/src/plugins/game/card/mod.rs | 2 +- client/src/plugins/game/supply/mod.rs | 21 +++++++++++++++++++-- client/src/plugins/game/ui/mod.rs | 12 ------------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/client/src/plugins/game/card/mod.rs b/client/src/plugins/game/card/mod.rs index d0828b3..a47feaa 100644 --- a/client/src/plugins/game/card/mod.rs +++ b/client/src/plugins/game/card/mod.rs @@ -104,7 +104,7 @@ impl Default for VisualCardBundle { pub struct VisualCardData { font_normal: Handle, font_medium: Handle, - font_bold: Handle, + pub font_bold: Handle, mesh: Handle, card_background: Handle, } diff --git a/client/src/plugins/game/supply/mod.rs b/client/src/plugins/game/supply/mod.rs index a329b99..3aa4c65 100644 --- a/client/src/plugins/game/supply/mod.rs +++ b/client/src/plugins/game/supply/mod.rs @@ -9,6 +9,7 @@ use bevy::prelude::*; use bevy_mod_picking::prelude::*; use bevy_rapier3d::prelude::*; +use bevy_text_mesh::prelude::*; use crate::{ api::game::{Action, Command}, @@ -18,7 +19,7 @@ use crate::{ }; use super::{ - card::{visual_card_kind, ClickedCard, VisualCard, VisualCardBundle}, + card::{visual_card_kind, ClickedCard, VisualCard, VisualCardBundle, VisualCardData}, GameData, }; @@ -47,6 +48,7 @@ fn spawn_supply_piles( game_data: Res, mut psp_ev_w: EventWriter, pile_query: Query>, + card_data: Res, ) { let Some(status) = &game_data.game_status else { warn!("game_status was none"); @@ -77,7 +79,22 @@ fn spawn_supply_piles( |_over, transform| { transform.translation.y -= 0.1; }, - )); + )).with_children(|parent| { + parent.spawn(TextMeshBundle { + text_mesh: TextMesh { + text: format!("left: {}", pile.amount), + style: TextMeshStyle { + font: card_data.font_bold.clone(), + font_size: SizeUnit::NonStandard(7.), + color: Color::rgb(1., 1., 1.), + ..Default::default() + }, + ..Default::default() + }, + transform: Transform::from_xyz(-0.25, -0.725, 0.), + ..Default::default() + }); + }); } psp_ev_w.send(PositionSupplyPilesEvent); diff --git a/client/src/plugins/game/ui/mod.rs b/client/src/plugins/game/ui/mod.rs index 529d6d0..ec43355 100644 --- a/client/src/plugins/game/ui/mod.rs +++ b/client/src/plugins/game/ui/mod.rs @@ -375,18 +375,6 @@ pub fn dev_details_ui( ui.label(format!("State: {:?}", game.state)); }); - - egui::CollapsingHeader::new("Supply Piles") - .default_open(false) - .show(ui, |ui| { - for pile in &status.supply_piles { - egui::CollapsingHeader::new(&pile.card.name) - .default_open(true) - .show(ui, |ui| { - ui.label(format!("Amount: {}", pile.amount)); - }); - } - }); }); } -- 2.44.1