@@ -2,7 +2,7 @@ use bevy::{
22 prelude:: * ,
33 render:: render_resource:: { Extent3d , TextureDimension , TextureFormat } ,
44} ;
5- use de_core:: { baseset:: GameSet , cleanup :: DespawnOnGameExit , gamestate:: GameState } ;
5+ use de_core:: { baseset:: GameSet , gamestate:: GameState } ;
66use de_map:: size:: MapBounds ;
77
88use crate :: hud:: { interaction:: InteractionBlocker , HUD_COLOR } ;
@@ -11,65 +11,55 @@ pub(super) struct NodesPlugin;
1111
1212impl Plugin for NodesPlugin {
1313 fn build ( & self , app : & mut App ) {
14- app. add_system ( setup. in_schedule ( OnEnter ( GameState :: Playing ) ) )
15- . add_system (
16- update_resolution
17- . in_base_set ( GameSet :: PreMovement )
18- . run_if ( in_state ( GameState :: Playing ) ) ,
19- ) ;
14+ app. add_system (
15+ update_resolution
16+ . in_base_set ( GameSet :: PreMovement )
17+ . run_if ( in_state ( GameState :: Playing ) ) ,
18+ ) ;
2019 }
2120}
2221
2322#[ derive( Component ) ]
2423pub ( super ) struct MinimapNode ;
2524
26- fn setup ( mut commands : Commands , mut images : ResMut < Assets < Image > > , map_bounds : Res < MapBounds > ) {
27- let handle = images. add ( new_image ( UVec2 :: splat ( 128 ) ) ) ;
25+ pub ( crate ) fn setup_minimap (
26+ commands : & mut Commands ,
27+ mut images : ResMut < Assets < Image > > ,
28+ map_bounds : Res < MapBounds > ,
29+ ) -> Entity {
30+ let handle = images. add ( new_image ( UVec2 :: new ( 256 , 128 ) ) ) ;
2831 let map_size = map_bounds. size ( ) ;
2932 let aspect = map_size. x / map_size. y ;
3033
3134 commands
32- . spawn ( NodeBundle {
33- style : Style {
34- position_type : PositionType :: Absolute ,
35- position : UiRect :: bottom ( Val :: Px ( 0. ) ) ,
36- size : Size :: new ( Val :: Percent ( 100. ) , Val :: Percent ( 30. ) ) ,
37- justify_content : JustifyContent :: End ,
35+ . spawn ( (
36+ NodeBundle {
37+ style : Style {
38+ max_size : Size :: new ( Val :: Percent ( 20. ) , Val :: Percent ( 100. ) ) ,
39+ size : Size :: height ( Val :: Percent ( 100. ) ) ,
40+ padding : UiRect :: all ( Val :: Percent ( 1. ) ) ,
41+ ..default ( )
42+ } ,
43+ background_color : HUD_COLOR . into ( ) ,
3844 ..default ( )
3945 } ,
40- ..default ( )
41- } )
42- . insert ( DespawnOnGameExit )
46+ InteractionBlocker ,
47+ ) )
4348 . with_children ( |parent| {
4449 parent
45- . spawn ( NodeBundle {
50+ . spawn ( ImageBundle {
4651 style : Style {
47- size : Size :: width ( Val :: Percent ( 20. ) ) ,
48- padding : UiRect :: all ( Val :: Percent ( 1. ) ) ,
49- align_items : AlignItems :: Center ,
50- justify_content : JustifyContent :: Center ,
52+ size : Size :: all ( Val :: Percent ( 100. ) ) ,
53+ aspect_ratio : Some ( aspect) ,
5154 ..default ( )
5255 } ,
53- background_color : HUD_COLOR . into ( ) ,
56+ background_color : Color :: WHITE . into ( ) ,
57+ image : handle. into ( ) ,
5458 ..default ( )
5559 } )
56- . insert ( InteractionBlocker )
57- . with_children ( |parent| {
58- parent
59- . spawn ( ImageBundle {
60- style : Style {
61- max_size : Size :: all ( Val :: Percent ( 100. ) ) ,
62- size : Size :: height ( Val :: Percent ( 100. ) ) ,
63- aspect_ratio : Some ( aspect) ,
64- ..default ( )
65- } ,
66- background_color : Color :: WHITE . into ( ) ,
67- image : handle. into ( ) ,
68- ..default ( )
69- } )
70- . insert ( MinimapNode ) ;
71- } ) ;
72- } ) ;
60+ . insert ( MinimapNode ) ;
61+ } )
62+ . id ( )
7363}
7464
7565type ChangedMinimap = ( Changed < Node > , With < MinimapNode > ) ;
0 commit comments