From 2951ddf3d85d8675377d33b41db7e32719782a0a Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Mon, 22 Jan 2024 23:27:43 -0700 Subject: [PATCH] Tweak gamepad viewer example style (#11484) # Objective Since #10339, the contrast in this example has been very low. While I was in there, I made a few other tweaks to the style. Alternative to #10102. ## Solution - Increase brightness of inactive buttons for higher contrast on the new clear color - Combine `DEAD_COLOR` and `EXTENT_COLOR`. These were using the same value, and combining them might make the intent a little clearer. (This is the single color for "not the live zone.") - Make the "stick buttons" slightly smaller, so it's a bit more obvious that they are sitting inside of the default dead zone. - Remove explicit text color -- it was the same as the default - Add top-left margin to the text in the top left, and change the font size to better match other examples with text in the corner. ## Screenshots
With Bevy's default dead / live zones. Before / After ![default](https://github.com/bevyengine/bevy/assets/200550/67bf1f5c-7fc9-4e74-87cf-2a94fcf59a50)
With Bevy's old dead / live zones. (with the upper live zone boundary != 1.0) Before / After ![old](https://github.com/bevyengine/bevy/assets/200550/3aab6a2a-ad57-4749-b2e5-51ed34072b2c)
--- examples/tools/gamepad_viewer.rs | 44 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/examples/tools/gamepad_viewer.rs b/examples/tools/gamepad_viewer.rs index 359dbcff22c9a..ee5a537d47665 100644 --- a/examples/tools/gamepad_viewer.rs +++ b/examples/tools/gamepad_viewer.rs @@ -21,12 +21,10 @@ const BUTTONS_Y: f32 = 80.; const STICKS_X: f32 = 150.; const STICKS_Y: f32 = -135.; -const NORMAL_BUTTON_COLOR: Color = Color::rgb(0.2, 0.2, 0.2); +const NORMAL_BUTTON_COLOR: Color = Color::rgb(0.3, 0.3, 0.3); const ACTIVE_BUTTON_COLOR: Color = Color::PURPLE; const LIVE_COLOR: Color = Color::rgb(0.4, 0.4, 0.4); -const DEAD_COLOR: Color = Color::rgb(0.3, 0.3, 0.3); -const EXTENT_COLOR: Color = Color::rgb(0.3, 0.3, 0.3); -const TEXT_COLOR: Color = Color::WHITE; +const DEAD_COLOR: Color = Color::rgb(0.13, 0.13, 0.13); #[derive(Component, Deref)] struct ReactTo(GamepadButtonType); @@ -290,7 +288,7 @@ fn setup_sticks( parent.spawn(SpriteBundle { sprite: Sprite { custom_size: Some(Vec2::splat(STICK_BOUNDS_SIZE * 2.)), - color: EXTENT_COLOR, + color: DEAD_COLOR, ..default() }, ..default() @@ -318,7 +316,6 @@ fn setup_sticks( // text let style = TextStyle { font_size: 16., - color: TEXT_COLOR, ..default() }; parent.spawn(( @@ -349,7 +346,7 @@ fn setup_sticks( mesh: meshes.circle.clone(), material: materials.normal.clone(), transform: Transform::from_xyz(0., 0., 5.) - .with_scale(Vec2::splat(0.2).extend(1.)), + .with_scale(Vec2::splat(0.15).extend(1.)), ..default() }, MoveWithAxes { @@ -400,7 +397,6 @@ fn setup_triggers( format!("{:.3}", 0.), TextStyle { font_size: 16., - color: TEXT_COLOR, ..default() }, ), @@ -424,22 +420,30 @@ fn setup_triggers( } fn setup_connected(mut commands: Commands) { - let style = TextStyle { - color: TEXT_COLOR, - font_size: 30., + let text_style = TextStyle { + font_size: 20., ..default() }; commands.spawn(( - TextBundle::from_sections([ - TextSection { - value: "Connected Gamepads:\n".to_string(), - style: style.clone(), - }, - TextSection { - value: "None".to_string(), - style, + TextBundle { + text: Text::from_sections([ + TextSection { + value: "Connected Gamepads:\n".to_string(), + style: text_style.clone(), + }, + TextSection { + value: "None".to_string(), + style: text_style, + }, + ]), + style: Style { + position_type: PositionType::Absolute, + top: Val::Px(12.), + left: Val::Px(12.), + ..default() }, - ]), + ..default() + }, ConnectedGamepadsText, )); }