@@ -25,26 +25,27 @@ struct TextChanges;
25
25
fn infotext_system ( mut commands : Commands , asset_server : Res < AssetServer > ) {
26
26
let font = asset_server. load ( "fonts/FiraSans-Bold.ttf" ) ;
27
27
commands. spawn_bundle ( Camera2dBundle :: default ( ) ) ;
28
- commands. spawn_bundle (
29
- TextBundle :: from_section (
30
- "This is\n text with\n line breaks\n in the top left" ,
31
- TextStyle {
32
- font : font. clone ( ) ,
33
- font_size : 50.0 ,
34
- color : Color :: WHITE ,
35
- } ,
36
- )
37
- . with_layout ( FlexLayout {
38
- align_self : AlignSelf :: FlexEnd ,
39
- position_type : PositionType :: Absolute ,
40
- position : UiRect {
41
- top : Val :: Px ( 5.0 ) ,
42
- left : Val :: Px ( 15.0 ) ,
28
+ commands
29
+ . spawn_bundle (
30
+ TextBundle :: from_section (
31
+ "This is\n text with\n line breaks\n in the top left" ,
32
+ TextStyle {
33
+ font : font. clone ( ) ,
34
+ font_size : 50.0 ,
35
+ color : Color :: WHITE ,
36
+ } ,
37
+ )
38
+ . with_layout ( FlexLayout {
39
+ align_self : AlignSelf :: FlexEnd ,
43
40
..default ( )
44
- } ,
41
+ } ) ,
42
+ )
43
+ . insert ( PositionType :: Absolute )
44
+ . insert ( Offset ( UiRect {
45
+ top : Val :: Px ( 5.0 ) ,
46
+ left : Val :: Px ( 15.0 ) ,
45
47
..default ( )
46
- } ) ,
47
- ) ;
48
+ } ) ) ;
48
49
commands. spawn_bundle ( TextBundle :: from_section (
49
50
"This text is very long, has a limited width, is centred, is positioned in the top right and is also coloured pink." ,
50
51
TextStyle {
@@ -56,19 +57,15 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
56
57
. with_text_alignment ( TextAlignment :: CENTER )
57
58
. with_layout ( FlexLayout {
58
59
align_self : AlignSelf :: FlexEnd ,
59
- position_type : PositionType :: Absolute ,
60
- position : UiRect {
61
- top : Val :: Px ( 5.0 ) ,
62
- right : Val :: Px ( 15.0 ) ,
63
- ..default ( )
64
- } ,
65
- max_size : Size {
66
- width : Val :: Px ( 400. ) ,
67
- height : Val :: Undefined ,
68
- } ,
69
60
..default ( )
70
- } )
71
- ) ;
61
+ } ) )
62
+ . insert ( PositionType :: Absolute )
63
+ . insert ( Offset ( UiRect {
64
+ top : Val :: Px ( 5.0 ) ,
65
+ right : Val :: Px ( 15.0 ) ,
66
+ ..default ( )
67
+ } ) )
68
+ . insert ( SizeConstraints :: max ( Val :: Px ( 400. ) , Val :: Undefined ) ) ;
72
69
commands
73
70
. spawn_bundle (
74
71
TextBundle :: from_sections ( [
@@ -117,40 +114,38 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
117
114
] )
118
115
. with_layout ( FlexLayout {
119
116
align_self : AlignSelf :: FlexEnd ,
120
- position_type : PositionType :: Absolute ,
121
- position : UiRect {
122
- bottom : Val :: Px ( 5.0 ) ,
123
- right : Val :: Px ( 15.0 ) ,
124
- ..default ( )
125
- } ,
126
117
..default ( )
127
118
} ) ,
128
119
)
120
+ . insert ( PositionType :: Absolute )
121
+ . insert ( Offset ( UiRect {
122
+ bottom : Val :: Px ( 5.0 ) ,
123
+ right : Val :: Px ( 15.0 ) ,
124
+ ..default ( )
125
+ } ) )
129
126
. insert ( TextChanges ) ;
130
- commands. spawn_bundle (
131
- TextBundle :: from_section (
132
- "This\n text has\n line breaks and also a set width in the bottom left" ,
133
- TextStyle {
134
- font,
135
- font_size : 50.0 ,
136
- color : Color :: WHITE ,
137
- } ,
138
- )
139
- . with_layout ( FlexLayout {
140
- align_self : AlignSelf :: FlexEnd ,
141
- position_type : PositionType :: Absolute ,
142
- position : UiRect {
143
- bottom : Val :: Px ( 5.0 ) ,
144
- left : Val :: Px ( 15.0 ) ,
145
- ..default ( )
146
- } ,
147
- size : Size {
148
- width : Val :: Px ( 200.0 ) ,
127
+ commands
128
+ . spawn_bundle (
129
+ TextBundle :: from_section (
130
+ "This\n text has\n line breaks and also a set width in the bottom left" ,
131
+ TextStyle {
132
+ font,
133
+ font_size : 50.0 ,
134
+ color : Color :: WHITE ,
135
+ } ,
136
+ )
137
+ . with_layout ( FlexLayout {
138
+ align_self : AlignSelf :: FlexEnd ,
149
139
..default ( )
150
- } ,
140
+ } ) ,
141
+ )
142
+ . insert ( PositionType :: Absolute )
143
+ . insert ( Offset ( UiRect {
144
+ bottom : Val :: Px ( 5.0 ) ,
145
+ left : Val :: Px ( 15.0 ) ,
151
146
..default ( )
152
- } ) ,
153
- ) ;
147
+ } ) )
148
+ . insert ( SizeConstraints :: suggested ( Val :: Px ( 200. ) , Val :: default ( ) ) ) ;
154
149
}
155
150
156
151
fn change_text_system (
0 commit comments