diff --git a/assets/resources.apack b/assets/resources.apack index bfc8a3e5a34ea718c989465f9af5cf66f3b07eef..3a58606d63933002d84ec36009055b0bb10e0347 100644 --- a/assets/resources.apack +++ b/assets/resources.apack @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1edb177ccd8eef0f5b3cdcb4ea5e2804c88a62bf4e5cee12f98a7bfbc1b5261 -size 1579824 +oid sha256:3d2dab5fb4b4a900bcb5a9eee1e01cf5a143441de1a424c9f4b120377de915f1 +size 1581436 diff --git a/game_core/src/ui/utilities.rs b/game_core/src/ui/utilities.rs index f8607ff27ca95399f87f9a43ac8d2504d04017cf..bf32736adc79f7b6d7784b7d6973328df7ab46a5 100644 --- a/game_core/src/ui/utilities.rs +++ b/game_core/src/ui/utilities.rs @@ -121,9 +121,9 @@ macro_rules! register_widget_with_many_resources { $ctx.add_widget_system( ::kayak_ui::prelude::Widget::get_name(&$props::default()), | - In((widget_context, entity, previous_entity)): In<(KayakWidgetContext, Entity, Entity)>, - $( $name: bevy::prelude::Res<$resource> ),+, - widget_param: WidgetParam<$props, $state>, + ::bevy::prelude::In((widget_context, entity, previous_entity)): ::bevy::prelude::In<(::kayak_ui::prelude::KayakWidgetContext, ::bevy::prelude::Entity, ::bevy::prelude::Entity)>, + $( $name: ::bevy::prelude::Res<$resource> ),+, + widget_param: ::kayak_ui::prelude::WidgetParam<$props, $state>, | { widget_param.has_changed(&widget_context, entity, previous_entity) $( || $name.is_changed() )+ @@ -227,12 +227,13 @@ pub mod context { EmptyState, render_panel_stat_widget ); - register_widget_with_resource!( + register_widget_with_many_resources!( widget_context, TownMenuPanelProps, TownMenuPanelState, - UITravelInfo, - render_town_menu_panel + render_town_menu_panel, + travelinfo: UITravelInfo, + statsinfo: UIStatsData ); register_widget_with_resource!( widget_context, diff --git a/game_core/src/ui/widgets/shop_panel.rs b/game_core/src/ui/widgets/shop_panel.rs index f3d95d107acf897f37826f598aab5a23d022d7d7..93ed7cc6fe2780b5e96ec9808eb37df5a05e1526 100644 --- a/game_core/src/ui/widgets/shop_panel.rs +++ b/game_core/src/ui/widgets/shop_panel.rs @@ -8,6 +8,7 @@ use kayak_ui::widgets::{ use crate::states::Player; use crate::ui::components::*; use crate::ui::prelude::*; +use crate::ui::sync::UIStatsData; use crate::ui::widgets::*; use crate::world::{CurrentResidence, MapQuery, TownPaths}; use crate::{basic_widget, empty_props, on_button_click}; @@ -57,6 +58,7 @@ pub fn render_shop_panel( In((widget_context, entity)): In<(KayakWidgetContext, Entity)>, mut commands: Commands, query: Query<&ShopPanelProps>, + ui_data: Res<UIStatsData>, ) -> bool { let parent_id = Some(entity); @@ -67,18 +69,13 @@ pub fn render_shop_panel( ("Ale", 11, 6, 14, 2), ("Milk", 2, 5, 14, 2), ("Cheese", 3, 6, 14, 2), - ("Armour", 12usize, 12, 14, 2), - ("Weapons", 1, 13, 14, 2), - ("Luxury Goods", 13, 27, 14, 2), - ("Ale", 11, 6, 14, 2), - ("Milk", 2, 5, 14, 2), - ("Cheese", 3, 6, 14, 2), - ("Armour", 12usize, 12, 14, 2), - ("Weapons", 1, 13, 14, 2), - ("Luxury Goods", 13, 27, 14, 2), - ("Ale", 11, 6, 14, 2), - ("Milk", 2, 5, 14, 2), - ("Cheese", 3, 6, 14, 2), + ("Spare Wheel", 28, 125, 14, 2), + ("Berries", 27, 4, 14, 2), + ("Corn", 26, 5, 14, 2), + ("Tomato", 25, 6, 14, 2), + ("Chili", 24, 8, 14, 2), + ("Grapes", 23, 9, 14, 2), + ("Wheat", 22, 3, 14, 2), ]; log::info!("{:?}", items); @@ -107,27 +104,30 @@ pub fn render_shop_panel( track_color: Some(Color::rgb(0.827, 0.482, 0.353)), thumb_color: Some(Color::rgb(0.451, 0.224, 0.063)), ..Default::default() - } } styles={KStyle { padding: edge_px(5.0), ..Default::default() }}> + } } styles={KStyle { pointer_events: value(PointerEvents::None), padding: edge_px(5.0), ..Default::default() }}> { for (name, idx, cost, shop_amount, player_amount) in items.iter() { constructor! { <BackgroundBundle styles={KStyle { + pointer_events: value(PointerEvents::ChildrenOnly), layout_type: value(LayoutType::Row), col_between: stretch(0.5), height: px(40.0), - bottom: px(5.0), - padding_top: px(4.0), - padding_bottom: px(4.0), + bottom: px(15.0), + padding_top: px(4.0), + padding_bottom: px(4.0), color: value(Color::BLACK), ..Default::default() }} > <InsetIconWidget props={InsetIconProps { image: IconContent::Atlas(String::from("icons"), *idx), size: 32.0}} /> - <TextWidgetBundle styles={KStyle { width: stretch(1.0), ..Default::default() }} text={TextProps { content: String::from(*name), size: 30.0, line_height: Some(32.0), ..Default::default() } }/> + <TextWidgetBundle styles={KStyle { width: stretch(1.5), ..Default::default() }} text={TextProps { content: String::from(*name), size: 30.0, line_height: Some(32.0), ..Default::default() } }/> <TextWidgetBundle styles={KStyle { width: stretch(1.0), ..Default::default() }} text={TextProps { content: format!("{}g", cost), size: 30.0, line_height: Some(32.0), ..Default::default() } }/> - <TextWidgetBundle styles={KStyle { width: stretch(1.0), ..Default::default() }} text={TextProps { content: format!("{}", shop_amount), size: 30.0, line_height: Some(32.0), ..Default::default() } }/> - <TextWidgetBundle styles={KStyle { width: stretch(1.0), ..Default::default() }} text={TextProps { content: format!("{}", player_amount), size: 30.0, line_height: Some(32.0), ..Default::default() } }/> + <TextWidgetBundle styles={KStyle { width: stretch(0.5), ..Default::default() }} text={TextProps { content: format!("{}", shop_amount), size: 30.0, line_height: Some(32.0), ..Default::default() } }/> + <TextWidgetBundle styles={KStyle { width: stretch(0.5), ..Default::default() }} text={TextProps { content: format!("{}", player_amount), size: 30.0, line_height: Some(32.0), ..Default::default() } }/> + <ButtonWidget props={ButtonWidgetProps { font_size: 20.0, text: String::from("Buy"), ..Default::default() }} /> + <ButtonWidget props={ButtonWidgetProps { font_size: 20.0, text: String::from("Sell"), ..Default::default() }} /> </BackgroundBundle> }; } diff --git a/game_core/src/ui/widgets/town_menu.rs b/game_core/src/ui/widgets/town_menu.rs index 0e2c7d701cc6119322d9ea22dfc37aa325254f36..b4240a706da56afd2f3b4dd905877241b95a991a 100644 --- a/game_core/src/ui/widgets/town_menu.rs +++ b/game_core/src/ui/widgets/town_menu.rs @@ -9,7 +9,7 @@ use crate::assets::AssetHandles; use crate::states::Player; use crate::ui::components::*; use crate::ui::prelude::*; -use crate::ui::sync::UITravelInfo; +use crate::ui::sync::{UIStatsData, UITravelInfo}; use crate::ui::widgets::*; use crate::world::{CurrentResidence, MapQuery, TownPaths}; use crate::{basic_widget, empty_props, on_button_click}; @@ -37,6 +37,7 @@ pub fn render_town_menu_panel( mut commands: Commands, mut state_query: Query<&mut TownMenuPanelState>, ui_data: Res<UITravelInfo>, + stats_data: Res<UIStatsData>, places: Res<TownPaths>, mut next_state: Local<TownMenuTab>, ) -> bool { @@ -100,81 +101,118 @@ pub fn render_town_menu_panel( state_query.get_mut(state_entity).ok(), ) { rsx! { - <PanelWidget - styles={panel_style} - > - <TextWidgetBundle - text={TextProps { - font: Some(String::from("header")), - content: format!("Hark! You enter {}", &place), - size: 48.0, - ..Default::default() - }} - styles={KStyle { - color: value(Color::BLACK), - padding: edge_px(20.0), - left: stretch(1.0), - right: stretch(1.0), - ..Default::default() - }} - /> - - <VDividerWidget props={VDividerWidgetProps { height: 4.0, padding: 5.0, color: Color::rgb(0.52, 0.369, 0.18)}} /> - - <ElementBundle styles={KStyle { - layout_type: value(LayoutType::Row), - padding_top: stretch(1.0), - padding_bottom: stretch(1.0), - padding_left: stretch(1.0), - padding_right: stretch(1.0), - height: px(60.0), - col_between: px(15.0), - ..Default::default() - }}> - <ButtonWidget - props={ButtonWidgetProps { - left_icon: IconContent::Atlas(String::from("icons"), 4), - ..ButtonWidgetProps::text("Travel", 28.0) + <ElementBundle styles={panel_style}> + <PanelWidget> + <TextWidgetBundle + text={TextProps { + font: Some(String::from("header")), + content: format!("Hark! You enter {}", &place), + size: 48.0, + ..Default::default() }} - on_event={click_tab_travel} - /> - <ButtonWidget - props={ButtonWidgetProps { - left_icon: IconContent::Atlas(String::from("icons"), 9), - ..ButtonWidgetProps::text("Merchant", 28.0) + styles={KStyle { + color: value(Color::BLACK), + padding: edge_px(20.0), + left: stretch(1.0), + right: stretch(1.0), + ..Default::default() }} - on_event={click_tab_merchant} /> - <ButtonWidget - props={ButtonWidgetProps { - left_icon: IconContent::Atlas(String::from("icons"), 11), - ..ButtonWidgetProps::text("Tavern", 28.0) - }} - on_event={click_tab_tavern} - /> - </ElementBundle> - - <VDividerWidget props={VDividerWidgetProps { height: 4.0, padding: 5.0, color: Color::rgb(0.52, 0.369, 0.18)}} /> - - - { - log::info!("Town menu is showing: {:?}", &state.tab); - match state.tab { - TownMenuTab::Travel => { - constructor! { - <TransitPanel /> - }; - }, - TownMenuTab::Merchant => { - constructor! { - <ShopPanel /> + + <VDividerWidget props={VDividerWidgetProps { height: 4.0, padding: 5.0, color: Color::rgb(0.52, 0.369, 0.18)}} /> + + <ElementBundle styles={KStyle { + layout_type: value(LayoutType::Row), + padding_top: stretch(1.0), + padding_bottom: stretch(1.0), + padding_left: stretch(1.0), + padding_right: stretch(1.0), + height: px(60.0), + col_between: px(15.0), + ..Default::default() + }}> + <ButtonWidget + props={ButtonWidgetProps { + left_icon: IconContent::Atlas(String::from("icons"), 4), + ..ButtonWidgetProps::text("Travel", 28.0) + }} + on_event={click_tab_travel} + /> + <ButtonWidget + props={ButtonWidgetProps { + left_icon: IconContent::Atlas(String::from("icons"), 9), + ..ButtonWidgetProps::text("Merchant", 28.0) + }} + on_event={click_tab_merchant} + /> + <ButtonWidget + props={ButtonWidgetProps { + left_icon: IconContent::Atlas(String::from("icons"), 11), + ..ButtonWidgetProps::text("Tavern", 28.0) + }} + on_event={click_tab_tavern} + /> + </ElementBundle> + + <VDividerWidget props={VDividerWidgetProps { height: 4.0, padding: 5.0, color: Color::rgb(0.52, 0.369, 0.18)}} /> + + + { + log::info!("Town menu is showing: {:?}", &state.tab); + match state.tab { + TownMenuTab::Travel => { + constructor! { + <TransitPanel /> + }; + }, + TownMenuTab::Merchant => { + constructor! { + <ShopPanel /> + } + } + TownMenuTab::Tavern => { + constructor! { + <TextWidgetBundle + styles={KStyle { + left: stretch(1.0), + right: stretch(1.0), + color: value(Color::BLACK), + ..Default::default() + }} + text={TextProps { + size: 32.0, + content: String::from("A strange bartender eyes you suspiciously"), + ..Default::default() + }} + /> + } } + TownMenuTab::None => {} } - TownMenuTab::Tavern => {} - TownMenuTab::None => {} } - } - </PanelWidget> + </PanelWidget> + + <PanelWidget styles={KStyle { layout_type: value(LayoutType::Row), height: px(45.0), ..Default::default() }}> + <PanelStatWidget + styles={KStyle { + position_type: value(KPositionType::SelfDirected), + left: stretch(1.0), + top: stretch(0.8), + bottom: stretch(1.0), + right: px(40.0), + ..Default::default() + }} + props={PanelStatProps { + fill: false, + text: format!("{}g", stats_data.money), + font_size: 24.0, + icon: IconContent::Atlas(String::from("icons"), 8), + color: Color::BLACK + }} + /> + </PanelWidget> + </ElementBundle> + }; if let Some(next) = state.next_tab {