From f2bbd6e3dcf99226e19292cf249973163aea1caa Mon Sep 17 00:00:00 2001 From: LookImEcho-Rick <62575172+LookImEcho-Rick@users.noreply.github.com> Date: Thu, 15 Oct 2026 22:23:25 -0500 Subject: [PATCH] Keep arrow-key camera controls out of chat and menus --- crates/horizon-client/src/chat_tests.rs | 29 +++++++++++++++++++++++++ crates/horizon-client/src/game.rs | 24 +++++++++++++------- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/crates/horizon-client/src/chat_tests.rs b/crates/horizon-client/src/chat_tests.rs index dd6192edd..73e56af27 100644 --- a/crates/horizon-client/src/chat_tests.rs +++ b/crates/horizon-client/src/chat_tests.rs @@ -163,3 +163,32 @@ fn locate_coordinates_fill_chat_with_teleport_without_submitting() { ); } } + +#[test] +fn history_arrows_recall_messages_and_restore_the_draft() { + use winit::keyboard::KeyCode::{ArrowDown, ArrowUp}; + + let font = font(); + let m = Measure(&font); + let registries = Registries::default(); + let commands = Commands { + dispatcher: crate::command::vanilla::game_dispatcher(), + registries: ®istries, + }; + let history = vec!["first message".to_owned(), "latest message".to_owned()]; + let mut screen = ChatScreen::new(&m, &commands, "unfinished draft", history.len(), 640, 360); + for (key, expected) in [ + (ArrowUp, "latest message"), + (ArrowUp, "first message"), + (ArrowUp, "first message"), + (ArrowDown, "latest message"), + (ArrowDown, "unfinished draft"), + (ArrowDown, "unfinished draft"), + ] { + assert_eq!( + screen.key(&m, &commands, &history, key, false, false), + ChatAction::None + ); + assert_eq!(screen.value(), expected); + } +} diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 69dc63667..10be177b9 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -9400,14 +9400,22 @@ impl ApplicationHandler for Game<'_> { let elapsed = now.duration_since(self.previous); self.frame_ticks = elapsed.as_secs_f32() * 20.0; self.previous = now; - // Arrow keys turn the camera (accessibility / scripted testing). - let turn = |k| f32::from(u8::from(self.keys.contains(&k))); - let secs = elapsed.as_secs_f32().min(0.1); - self.yaw += - (turn(KeyCode::ArrowRight) - turn(KeyCode::ArrowLeft)) * 90.0 * secs; - self.pitch = (self.pitch - + (turn(KeyCode::ArrowDown) - turn(KeyCode::ArrowUp)) * 90.0 * secs) - .clamp(-90.0, 90.0); + // Arrow-key camera controls belong to gameplay; chat and + // other screens use the same keys for their own navigation. + if self.screen == Screen::Playing + && self.title.is_none() + && self.sign_edit.is_none() + && self.book.is_none() + && !self.remote_chat_open() + { + let turn = |k| f32::from(u8::from(self.keys.contains(&k))); + let secs = elapsed.as_secs_f32().min(0.1); + self.yaw += + (turn(KeyCode::ArrowRight) - turn(KeyCode::ArrowLeft)) * 90.0 * secs; + self.pitch = (self.pitch + + (turn(KeyCode::ArrowDown) - turn(KeyCode::ArrowUp)) * 90.0 * secs) + .clamp(-90.0, 90.0); + } self.update_backdrop()?; horizon_client::ui_theme::set_backdrop(self.backdrop_fade()); if self.screen != Screen::Paused {