From b2a22cbe55a68cba277fc57b3442c097c85ce506 Mon Sep 17 00:00:00 2001 From: CoCo_Sol Date: Mon, 1 Apr 2024 13:49:01 +0000 Subject: [PATCH 1/2] Improve mouse movement on the map (#95) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.tipragot.fr/fish-cannard/border-wars/pulls/95 Reviewed-by: Raphaël Co-authored-by: CoCo_Sol Co-committed-by: CoCo_Sol --- crates/border-wars/src/camera.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/border-wars/src/camera.rs b/crates/border-wars/src/camera.rs index c19a3e2..b22dd92 100644 --- a/crates/border-wars/src/camera.rs +++ b/crates/border-wars/src/camera.rs @@ -107,7 +107,7 @@ fn keyboard_movement_system( /// Moves the camera with mouse input. fn mouse_movement_system( mouse_button_input: Res>, - mut query: Query<&mut Transform, With>, + mut query: Query<(&mut Transform, &OrthographicProjection), With>, windows: Query<&Window>, mut last_position: Local>, ) { @@ -125,9 +125,9 @@ fn mouse_movement_system( } if let Some(old_position) = *last_position { - for mut transform in query.iter_mut() { + for (mut transform, projection) in query.iter_mut() { let offset = (old_position - position).extend(0.0) * Vec3::new(1., -1., 1.); - transform.translation += offset; + transform.translation += offset * projection.scale; } *last_position = Some(position); } From 45b47947deccac51129e859dad9d3d57304031e3 Mon Sep 17 00:00:00 2001 From: CoCo_Sol Date: Mon, 1 Apr 2024 14:28:25 +0000 Subject: [PATCH 2/2] Change visibility of HoveredTexture to public (#97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.tipragot.fr/fish-cannard/border-wars/pulls/97 Reviewed-by: Raphaël Co-authored-by: CoCo_Sol Co-committed-by: CoCo_Sol --- crates/border-wars/src/ui/hover.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/border-wars/src/ui/hover.rs b/crates/border-wars/src/ui/hover.rs index 632dc07..2d82f18 100644 --- a/crates/border-wars/src/ui/hover.rs +++ b/crates/border-wars/src/ui/hover.rs @@ -13,12 +13,12 @@ impl Plugin for HoverPlugin { /// A component that stores the hover texture and the original texture. #[derive(Component, Clone)] -struct HoveredTexture { +pub struct HoveredTexture { /// The original texture. - texture: Handle, + pub texture: Handle, /// The hovered texture. - hovered_texture: Handle, + pub hovered_texture: Handle, } /// The system that applies the hover logic by changing the texture.