Use standard instruction text / position in various examples (#13583)
## Objective Use the "standard" text size / placement for the new text in these examples. Continuation of an effort started here: https://github.com/bevyengine/bevy/pull/8478 This is definitely not comprehensive. I did the ones that were easy to find and relatively straightforward updates. I meant to just do `3d_shapes` and `2d_shapes`, but one thing lead to another. ## Solution Use `font_size: 20.0`, the default (built-in) font, `Color::WHITE` (default), and `Val::Px(12.)` from the edges of the screen. There are a few little drive-by cleanups of defaults not being used, etc. ## Testing Ran the changed examples, verified that they still look reasonable.
This commit is contained in:
parent
ed042e5f9a
commit
06f733b16f
@ -61,14 +61,14 @@ fn setup(
|
|||||||
TextBundle::from_section(
|
TextBundle::from_section(
|
||||||
"Press space to toggle wireframes",
|
"Press space to toggle wireframes",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 24.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -69,15 +69,14 @@ fn setup(
|
|||||||
TextBundle::from_section(
|
TextBundle::from_section(
|
||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 18.0,
|
font_size: 20.0,
|
||||||
color: Color::WHITE,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -83,7 +83,7 @@ fn update_text(mut text: Query<&mut Text>, cur_state: Res<State<Test>>) {
|
|||||||
let s = if **cur_state == test { "*" } else { " " };
|
let s = if **cur_state == test { "*" } else { " " };
|
||||||
text.push_str(&format!(" {s} {test:?} {s}\n"));
|
text.push_str(&format!(" {s} {test:?} {s}\n"));
|
||||||
}
|
}
|
||||||
text.push_str("\npress Space to cycle");
|
text.push_str("\nPress space to cycle");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
@ -195,7 +195,7 @@ struct Intersects(bool);
|
|||||||
const OFFSET_X: f32 = 125.;
|
const OFFSET_X: f32 = 125.;
|
||||||
const OFFSET_Y: f32 = 75.;
|
const OFFSET_Y: f32 = 75.;
|
||||||
|
|
||||||
fn setup(mut commands: Commands, loader: Res<AssetServer>) {
|
fn setup(mut commands: Commands) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2dBundle::default());
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
SpatialBundle {
|
SpatialBundle {
|
||||||
@ -270,15 +270,14 @@ fn setup(mut commands: Commands, loader: Res<AssetServer>) {
|
|||||||
TextBundle::from_section(
|
TextBundle::from_section(
|
||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: loader.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 26.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -99,10 +99,17 @@ fn setup(
|
|||||||
|
|
||||||
// Text used to show controls
|
// Text used to show controls
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle::from_section("", TextStyle::default()).with_style(Style {
|
TextBundle::from_section(
|
||||||
|
"",
|
||||||
|
TextStyle {
|
||||||
|
font_size: 20.,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -116,8 +123,7 @@ fn update_colors(
|
|||||||
mut text: Query<&mut Text>,
|
mut text: Query<&mut Text>,
|
||||||
) {
|
) {
|
||||||
text.single_mut().sections[0].value = format!(
|
text.single_mut().sections[0].value = format!(
|
||||||
"
|
"Controls
|
||||||
Controls
|
|
||||||
---------------
|
---------------
|
||||||
Z - Toggle global
|
Z - Toggle global
|
||||||
X - Change global color
|
X - Change global color
|
||||||
@ -126,8 +132,7 @@ C - Change color of the circle wireframe
|
|||||||
Wireframe2dConfig
|
Wireframe2dConfig
|
||||||
-------------
|
-------------
|
||||||
Global: {}
|
Global: {}
|
||||||
Color: {:?}
|
Color: {:?}",
|
||||||
",
|
|
||||||
config.global, config.default_color,
|
config.global, config.default_color,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -100,14 +100,14 @@ fn setup(
|
|||||||
TextBundle::from_section(
|
TextBundle::from_section(
|
||||||
"Press space to toggle wireframes",
|
"Press space to toggle wireframes",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 24.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -132,20 +132,19 @@ fn setup(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let text_style = TextStyle {
|
let text_style = TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 18.0,
|
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
|
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle::from_section(
|
TextBundle::from_section(
|
||||||
"Left / Right — Rotate Camera\nC — Toggle Compensation Curve\nM — Toggle Metering Mask\nV — Visualize Metering Mask",
|
"Left / Right - Rotate Camera\nC - Toggle Compensation Curve\nM - Toggle Metering Mask\nV - Visualize Metering Mask",
|
||||||
text_style.clone(),
|
text_style.clone(),
|
||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -181,7 +181,7 @@ fn setup(
|
|||||||
// Controls Text
|
// Controls Text
|
||||||
let text_style = TextStyle {
|
let text_style = TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
||||||
font_size: 18.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -198,8 +198,8 @@ fn setup(
|
|||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -207,8 +207,8 @@ fn setup(
|
|||||||
commands.spawn((
|
commands.spawn((
|
||||||
TextBundle::from_section("", text_style).with_style(Style {
|
TextBundle::from_section("", text_style).with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
right: Val::Px(10.0),
|
right: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
ExampleDisplay,
|
ExampleDisplay,
|
||||||
|
@ -93,7 +93,6 @@ fn setup_scene(
|
|||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 20.0,
|
font_size: 20.0,
|
||||||
color: Color::WHITE,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -74,7 +74,7 @@ fn setup(
|
|||||||
|
|
||||||
spawn_light(&mut commands);
|
spawn_light(&mut commands);
|
||||||
spawn_camera(&mut commands, &asset_server);
|
spawn_camera(&mut commands, &asset_server);
|
||||||
spawn_text(&mut commands, &asset_server, &light_mode);
|
spawn_text(&mut commands, &light_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a sphere.
|
/// Generates a sphere.
|
||||||
@ -232,16 +232,16 @@ fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Spawns the help text.
|
/// Spawns the help text.
|
||||||
fn spawn_text(commands: &mut Commands, asset_server: &AssetServer, light_mode: &LightMode) {
|
fn spawn_text(commands: &mut Commands, light_mode: &LightMode) {
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle {
|
TextBundle {
|
||||||
text: light_mode.create_help_text(asset_server),
|
text: light_mode.create_help_text(),
|
||||||
..TextBundle::default()
|
..TextBundle::default()
|
||||||
}
|
}
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -304,13 +304,9 @@ fn handle_input(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the help text at the bottom of the screen.
|
/// Updates the help text at the bottom of the screen.
|
||||||
fn update_help_text(
|
fn update_help_text(mut text_query: Query<&mut Text>, light_mode: Res<LightMode>) {
|
||||||
mut text_query: Query<&mut Text>,
|
|
||||||
light_mode: Res<LightMode>,
|
|
||||||
asset_server: Res<AssetServer>,
|
|
||||||
) {
|
|
||||||
for mut text in text_query.iter_mut() {
|
for mut text in text_query.iter_mut() {
|
||||||
*text = light_mode.create_help_text(&asset_server);
|
*text = light_mode.create_help_text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +330,7 @@ fn create_directional_light() -> DirectionalLight {
|
|||||||
|
|
||||||
impl LightMode {
|
impl LightMode {
|
||||||
/// Creates the help text at the bottom of the screen.
|
/// Creates the help text at the bottom of the screen.
|
||||||
fn create_help_text(&self, asset_server: &AssetServer) -> Text {
|
fn create_help_text(&self) -> Text {
|
||||||
let help_text = match *self {
|
let help_text = match *self {
|
||||||
LightMode::Point => "Press Space to switch to a directional light",
|
LightMode::Point => "Press Space to switch to a directional light",
|
||||||
LightMode::Directional => "Press Space to switch to a point light",
|
LightMode::Directional => "Press Space to switch to a point light",
|
||||||
@ -343,8 +339,7 @@ impl LightMode {
|
|||||||
Text::from_section(
|
Text::from_section(
|
||||||
help_text,
|
help_text,
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 24.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -95,13 +95,13 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: R
|
|||||||
// Spawn the help text.
|
// Spawn the help text.
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle {
|
TextBundle {
|
||||||
text: create_text(&asset_server, &app_settings),
|
text: create_text(&app_settings),
|
||||||
..TextBundle::default()
|
..TextBundle::default()
|
||||||
}
|
}
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -212,23 +212,18 @@ fn tweak_scene(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update the help text entity per the current app settings.
|
/// Update the help text entity per the current app settings.
|
||||||
fn update_text(
|
fn update_text(mut texts: Query<&mut Text>, app_settings: Res<AppSettings>) {
|
||||||
mut texts: Query<&mut Text>,
|
|
||||||
asset_server: Res<AssetServer>,
|
|
||||||
app_settings: Res<AppSettings>,
|
|
||||||
) {
|
|
||||||
for mut text in texts.iter_mut() {
|
for mut text in texts.iter_mut() {
|
||||||
*text = create_text(&asset_server, &app_settings);
|
*text = create_text(&app_settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Regenerates the app text component per the current app settings.
|
/// Regenerates the app text component per the current app settings.
|
||||||
fn create_text(asset_server: &AssetServer, app_settings: &AppSettings) -> Text {
|
fn create_text(app_settings: &AppSettings) -> Text {
|
||||||
Text::from_section(
|
Text::from_section(
|
||||||
app_settings.help_text(),
|
app_settings.help_text(),
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 24.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -209,12 +209,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spawns all the scene objects.
|
// Spawns all the scene objects.
|
||||||
fn setup(
|
fn setup(mut commands: Commands, assets: Res<ExampleAssets>, app_status: Res<AppStatus>) {
|
||||||
mut commands: Commands,
|
|
||||||
assets: Res<ExampleAssets>,
|
|
||||||
app_status: Res<AppStatus>,
|
|
||||||
asset_server: Res<AssetServer>,
|
|
||||||
) {
|
|
||||||
spawn_main_scene(&mut commands, &assets);
|
spawn_main_scene(&mut commands, &assets);
|
||||||
spawn_camera(&mut commands, &assets);
|
spawn_camera(&mut commands, &assets);
|
||||||
spawn_irradiance_volume(&mut commands, &assets);
|
spawn_irradiance_volume(&mut commands, &assets);
|
||||||
@ -222,7 +217,7 @@ fn setup(
|
|||||||
spawn_sphere(&mut commands, &assets);
|
spawn_sphere(&mut commands, &assets);
|
||||||
spawn_voxel_cube_parent(&mut commands);
|
spawn_voxel_cube_parent(&mut commands);
|
||||||
spawn_fox(&mut commands, &assets);
|
spawn_fox(&mut commands, &assets);
|
||||||
spawn_text(&mut commands, &app_status, &asset_server);
|
spawn_text(&mut commands, &app_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_main_scene(commands: &mut Commands, assets: &ExampleAssets) {
|
fn spawn_main_scene(commands: &mut Commands, assets: &ExampleAssets) {
|
||||||
@ -301,36 +296,32 @@ fn spawn_fox(commands: &mut Commands, assets: &ExampleAssets) {
|
|||||||
.insert(MainObject);
|
.insert(MainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_text(commands: &mut Commands, app_status: &AppStatus, asset_server: &AssetServer) {
|
fn spawn_text(commands: &mut Commands, app_status: &AppStatus) {
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle {
|
TextBundle {
|
||||||
text: app_status.create_text(asset_server),
|
text: app_status.create_text(),
|
||||||
..TextBundle::default()
|
..default()
|
||||||
}
|
}
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A system that updates the help text.
|
// A system that updates the help text.
|
||||||
fn update_text(
|
fn update_text(mut text_query: Query<&mut Text>, app_status: Res<AppStatus>) {
|
||||||
mut text_query: Query<&mut Text>,
|
|
||||||
app_status: Res<AppStatus>,
|
|
||||||
asset_server: Res<AssetServer>,
|
|
||||||
) {
|
|
||||||
for mut text in text_query.iter_mut() {
|
for mut text in text_query.iter_mut() {
|
||||||
*text = app_status.create_text(&asset_server);
|
*text = app_status.create_text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppStatus {
|
impl AppStatus {
|
||||||
// Constructs the help text at the bottom of the screen based on the
|
// Constructs the help text at the bottom of the screen based on the
|
||||||
// application status.
|
// application status.
|
||||||
fn create_text(&self, asset_server: &AssetServer) -> Text {
|
fn create_text(&self) -> Text {
|
||||||
let irradiance_volume_help_text = if self.irradiance_volume_present {
|
let irradiance_volume_help_text = if self.irradiance_volume_present {
|
||||||
DISABLE_IRRADIANCE_VOLUME_HELP_TEXT
|
DISABLE_IRRADIANCE_VOLUME_HELP_TEXT
|
||||||
} else {
|
} else {
|
||||||
@ -364,8 +355,7 @@ impl AppStatus {
|
|||||||
switch_mesh_help_text
|
switch_mesh_help_text
|
||||||
),
|
),
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 24.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -253,7 +253,7 @@ fn spawn_trees(
|
|||||||
|
|
||||||
fn setup_ui(mut commands: Commands) {
|
fn setup_ui(mut commands: Commands) {
|
||||||
let style = TextStyle {
|
let style = TextStyle {
|
||||||
font_size: 24.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
|
@ -92,7 +92,7 @@ fn setup(
|
|||||||
spawn_camera(&mut commands);
|
spawn_camera(&mut commands);
|
||||||
spawn_sphere(&mut commands, &mut meshes, &mut materials);
|
spawn_sphere(&mut commands, &mut meshes, &mut materials);
|
||||||
spawn_reflection_probe(&mut commands, &cubemaps);
|
spawn_reflection_probe(&mut commands, &cubemaps);
|
||||||
spawn_text(&mut commands, &asset_server, &app_status);
|
spawn_text(&mut commands, &app_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawns the cubes, light, and camera.
|
// Spawns the cubes, light, and camera.
|
||||||
@ -156,17 +156,17 @@ fn spawn_reflection_probe(commands: &mut Commands, cubemaps: &Cubemaps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spawns the help text.
|
// Spawns the help text.
|
||||||
fn spawn_text(commands: &mut Commands, asset_server: &AssetServer, app_status: &AppStatus) {
|
fn spawn_text(commands: &mut Commands, app_status: &AppStatus) {
|
||||||
// Create the text.
|
// Create the text.
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle {
|
TextBundle {
|
||||||
text: app_status.create_text(asset_server),
|
text: app_status.create_text(),
|
||||||
..TextBundle::default()
|
..default()
|
||||||
}
|
}
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -241,13 +241,9 @@ fn toggle_rotation(keyboard: Res<ButtonInput<KeyCode>>, mut app_status: ResMut<A
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A system that updates the help text.
|
// A system that updates the help text.
|
||||||
fn update_text(
|
fn update_text(mut text_query: Query<&mut Text>, app_status: Res<AppStatus>) {
|
||||||
mut text_query: Query<&mut Text>,
|
|
||||||
app_status: Res<AppStatus>,
|
|
||||||
asset_server: Res<AssetServer>,
|
|
||||||
) {
|
|
||||||
for mut text in text_query.iter_mut() {
|
for mut text in text_query.iter_mut() {
|
||||||
*text = app_status.create_text(&asset_server);
|
*text = app_status.create_text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +274,7 @@ impl Display for ReflectionMode {
|
|||||||
impl AppStatus {
|
impl AppStatus {
|
||||||
// Constructs the help text at the bottom of the screen based on the
|
// Constructs the help text at the bottom of the screen based on the
|
||||||
// application status.
|
// application status.
|
||||||
fn create_text(&self, asset_server: &AssetServer) -> Text {
|
fn create_text(&self) -> Text {
|
||||||
let rotation_help_text = if self.rotating {
|
let rotation_help_text = if self.rotating {
|
||||||
STOP_ROTATION_HELP_TEXT
|
STOP_ROTATION_HELP_TEXT
|
||||||
} else {
|
} else {
|
||||||
@ -291,8 +287,7 @@ impl AppStatus {
|
|||||||
self.reflection_mode, rotation_help_text, REFLECTION_MODE_HELP_TEXT
|
self.reflection_mode, rotation_help_text, REFLECTION_MODE_HELP_TEXT
|
||||||
),
|
),
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 24.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -98,14 +98,14 @@ fn setup(
|
|||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
||||||
font_size: 26.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -136,7 +136,7 @@ fn setup(
|
|||||||
&mut water_materials,
|
&mut water_materials,
|
||||||
);
|
);
|
||||||
spawn_camera(&mut commands, &asset_server);
|
spawn_camera(&mut commands, &asset_server);
|
||||||
spawn_text(&mut commands, &asset_server, &app_settings);
|
spawn_text(&mut commands, &app_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawns the rotating cube.
|
// Spawns the rotating cube.
|
||||||
@ -248,23 +248,23 @@ fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spawns the help text.
|
// Spawns the help text.
|
||||||
fn spawn_text(commands: &mut Commands, asset_server: &AssetServer, app_settings: &AppSettings) {
|
fn spawn_text(commands: &mut Commands, app_settings: &AppSettings) {
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle {
|
TextBundle {
|
||||||
text: create_text(asset_server, app_settings),
|
text: create_text(app_settings),
|
||||||
..TextBundle::default()
|
..TextBundle::default()
|
||||||
}
|
}
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates or recreates the help text.
|
// Creates or recreates the help text.
|
||||||
fn create_text(asset_server: &AssetServer, app_settings: &AppSettings) -> Text {
|
fn create_text(app_settings: &AppSettings) -> Text {
|
||||||
Text::from_section(
|
Text::from_section(
|
||||||
format!(
|
format!(
|
||||||
"{}\n{}\n{}",
|
"{}\n{}\n{}",
|
||||||
@ -280,8 +280,7 @@ fn create_text(asset_server: &AssetServer, app_settings: &AppSettings) -> Text {
|
|||||||
MOVE_CAMERA_HELP_TEXT
|
MOVE_CAMERA_HELP_TEXT
|
||||||
),
|
),
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 24.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -350,7 +349,6 @@ fn move_camera(
|
|||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn adjust_app_settings(
|
fn adjust_app_settings(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
asset_server: Res<AssetServer>,
|
|
||||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||||
mut app_settings: ResMut<AppSettings>,
|
mut app_settings: ResMut<AppSettings>,
|
||||||
mut cameras: Query<Entity, With<Camera>>,
|
mut cameras: Query<Entity, With<Camera>>,
|
||||||
@ -413,7 +411,7 @@ fn adjust_app_settings(
|
|||||||
|
|
||||||
// Update the help text.
|
// Update the help text.
|
||||||
for mut text in text.iter_mut() {
|
for mut text in text.iter_mut() {
|
||||||
*text = create_text(&asset_server, &app_settings);
|
*text = create_text(&app_settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,14 +83,14 @@ fn setup(
|
|||||||
TextBundle::from_section(
|
TextBundle::from_section(
|
||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 18.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -366,15 +366,15 @@ fn setup(
|
|||||||
|
|
||||||
// Controls Text
|
// Controls Text
|
||||||
let text_style = TextStyle {
|
let text_style = TextStyle {
|
||||||
font_size: 18.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
TextBundle::from_section("", text_style).with_style(Style {
|
TextBundle::from_section("", text_style).with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
ExampleDisplay,
|
ExampleDisplay,
|
||||||
|
@ -153,13 +153,13 @@ fn setup(
|
|||||||
// Create the text.
|
// Create the text.
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle {
|
TextBundle {
|
||||||
text: app_status.create_text(&asset_server),
|
text: app_status.create_text(),
|
||||||
..TextBundle::default()
|
..TextBundle::default()
|
||||||
}
|
}
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
bottom: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -290,19 +290,15 @@ fn update_mode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A system that updates the help text.
|
// A system that updates the help text.
|
||||||
fn update_help_text(
|
fn update_help_text(mut text_query: Query<&mut Text>, app_status: Res<AppStatus>) {
|
||||||
mut text_query: Query<&mut Text>,
|
|
||||||
app_status: Res<AppStatus>,
|
|
||||||
asset_server: Res<AssetServer>,
|
|
||||||
) {
|
|
||||||
for mut text in text_query.iter_mut() {
|
for mut text in text_query.iter_mut() {
|
||||||
*text = app_status.create_text(&asset_server);
|
*text = app_status.create_text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppStatus {
|
impl AppStatus {
|
||||||
// Creates and returns help text reflecting the app status.
|
// Creates and returns help text reflecting the app status.
|
||||||
fn create_text(&self, asset_server: &AssetServer) -> Text {
|
fn create_text(&self) -> Text {
|
||||||
Text::from_section(
|
Text::from_section(
|
||||||
format!(
|
format!(
|
||||||
"\
|
"\
|
||||||
@ -328,8 +324,7 @@ Press WASD or use the mouse wheel to move the camera",
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 24.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -62,8 +62,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
text: Text::from_section(
|
text: Text::from_section(
|
||||||
"Press WASD or the arrow keys to change the light direction",
|
"Press WASD or the arrow keys to change the light direction",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
font_size: 20.0,
|
||||||
font_size: 24.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -71,8 +70,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
}
|
}
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
bottom: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -113,10 +113,17 @@ fn setup(
|
|||||||
|
|
||||||
// Text used to show controls
|
// Text used to show controls
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle::from_section("", TextStyle::default()).with_style(Style {
|
TextBundle::from_section(
|
||||||
|
"",
|
||||||
|
TextStyle {
|
||||||
|
font_size: 20.0,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -130,8 +137,7 @@ fn update_colors(
|
|||||||
mut text: Query<&mut Text>,
|
mut text: Query<&mut Text>,
|
||||||
) {
|
) {
|
||||||
text.single_mut().sections[0].value = format!(
|
text.single_mut().sections[0].value = format!(
|
||||||
"
|
"Controls
|
||||||
Controls
|
|
||||||
---------------
|
---------------
|
||||||
Z - Toggle global
|
Z - Toggle global
|
||||||
X - Change global color
|
X - Change global color
|
||||||
@ -140,8 +146,7 @@ C - Change color of the green cube wireframe
|
|||||||
WireframeConfig
|
WireframeConfig
|
||||||
-------------
|
-------------
|
||||||
Global: {}
|
Global: {}
|
||||||
Color: {:?}
|
Color: {:?}",
|
||||||
",
|
|
||||||
config.global, config.default_color,
|
config.global, config.default_color,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,10 +24,16 @@ fn setup(mut commands: Commands) {
|
|||||||
text: Text::from_section(
|
text: Text::from_section(
|
||||||
"Press P to panic",
|
"Press P to panic",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 60.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
style: Style {
|
||||||
|
position_type: PositionType::Absolute,
|
||||||
|
top: Val::Px(12.0),
|
||||||
|
left: Val::Px(12.0),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ fn setup(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let style = TextStyle {
|
let style = TextStyle {
|
||||||
font_size: 18.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -147,8 +147,8 @@ fn setup(
|
|||||||
])
|
])
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -87,13 +87,21 @@ fn setup(mut commands: Commands) {
|
|||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.spawn(TextBundle::from_section(
|
commands.spawn(
|
||||||
"",
|
TextBundle::from_section(
|
||||||
TextStyle {
|
"",
|
||||||
font_size: 30.,
|
TextStyle {
|
||||||
|
font_size: 20.,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.with_style(Style {
|
||||||
|
position_type: PositionType::Absolute,
|
||||||
|
top: Val::Px(12.0),
|
||||||
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
}),
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ui_system(mut query: Query<&mut Text>, config: Res<Config>, diag: Res<DiagnosticsStore>) {
|
fn ui_system(mut query: Query<&mut Text>, config: Res<Config>, diag: Res<DiagnosticsStore>) {
|
||||||
|
@ -16,7 +16,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2dBundle::default());
|
||||||
|
|
||||||
let text_style = TextStyle {
|
let text_style = TextStyle {
|
||||||
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
|
|
||||||
font_size: 20.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
};
|
};
|
||||||
|
@ -65,14 +65,14 @@ fn setup(
|
|||||||
TextBundle::from_section(
|
TextBundle::from_section(
|
||||||
"Press <spacebar> to save a screenshot to disk",
|
"Press <spacebar> to save a screenshot to disk",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 25.0,
|
font_size: 20.0,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_style(Style {
|
.with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
top: Val::Px(10.0),
|
top: Val::Px(12.0),
|
||||||
left: Val::Px(10.0),
|
left: Val::Px(12.0),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user