feat: add log and hotkey list

This commit is contained in:
Evan Carroll 2026-01-20 19:25:58 -06:00
parent 7852790a1e
commit 41ea9d13cb
5 changed files with 415 additions and 4 deletions

View file

@ -13,9 +13,9 @@ use uuid::Uuid;
use crate::components::{
ActiveBubble, AvatarEditorPopup, Card, ChatInput, ConversationModal, EmotionKeybindings,
FadingMember, InventoryPopup, KeybindingsPopup, MessageLog, NotificationHistoryModal,
NotificationMessage, NotificationToast, RealmHeader, RealmSceneViewer, ReconnectionOverlay,
SettingsPopup, ViewerSettings,
FadingMember, HotkeyHelp, InventoryPopup, KeybindingsPopup, LogPopup, MessageLog,
NotificationHistoryModal, NotificationMessage, NotificationToast, RealmHeader,
RealmSceneViewer, ReconnectionOverlay, SettingsPopup, ViewerSettings,
};
#[cfg(feature = "hydrate")]
use crate::components::{
@ -74,6 +74,12 @@ pub fn RealmPage() -> impl IntoView {
let (settings_open, set_settings_open) = signal(false);
let viewer_settings = RwSignal::new(ViewerSettings::load());
// Log popup state
let (log_open, set_log_open) = signal(false);
// Hotkey help overlay state (shown while ? is held)
let (hotkey_help_visible, set_hotkey_help_visible) = signal(false);
// Keybindings popup state
let keybindings = RwSignal::new(EmotionKeybindings::load());
let (keybindings_open, set_keybindings_open) = signal(false);
@ -794,6 +800,20 @@ pub fn RealmPage() -> impl IntoView {
return;
}
// Handle 'l' to toggle message log
if key == "l" || key == "L" {
set_log_open.update(|v| *v = !*v);
ev.prevent_default();
return;
}
// Handle '?' to show hotkey help (while held)
if key == "?" {
set_hotkey_help_visible.set(true);
ev.prevent_default();
return;
}
// Check if 'e' key was pressed
if key == "e" || key == "E" {
*e_pressed_clone.borrow_mut() = true;
@ -830,6 +850,25 @@ pub fn RealmPage() -> impl IntoView {
// Store the closure for cleanup
*closure_holder_clone.borrow_mut() = Some(closure);
// Add keyup handler for releasing '?' (hotkey help)
let keyup_closure = Closure::<dyn Fn(web_sys::KeyboardEvent)>::new(
move |ev: web_sys::KeyboardEvent| {
if ev.key() == "?" {
set_hotkey_help_visible.set(false);
}
},
);
if let Some(window) = web_sys::window() {
let _ = window.add_event_listener_with_callback(
"keyup",
keyup_closure.as_ref().unchecked_ref(),
);
}
// Forget the keyup closure (it lives for the duration of the page)
keyup_closure.forget();
});
// Save position on page unload (beforeunload event)
@ -982,6 +1021,9 @@ pub fn RealmPage() -> impl IntoView {
let on_open_inventory_cb = Callback::new(move |_: ()| {
set_inventory_open.set(true);
});
let on_open_log_cb = Callback::new(move |_: ()| {
set_log_open.set(true);
});
let whisper_target_signal = Signal::derive(move || whisper_target.get());
let on_whisper_request_cb = Callback::new(move |target: String| {
set_whisper_target.set(Some(target));
@ -1031,6 +1073,7 @@ pub fn RealmPage() -> impl IntoView {
on_focus_change=on_chat_focus_change.clone()
on_open_settings=on_open_settings_cb
on_open_inventory=on_open_inventory_cb
on_open_log=on_open_log_cb
whisper_target=whisper_target_signal
scenes=scenes_signal
allow_user_teleport=teleport_enabled_signal
@ -1088,6 +1131,15 @@ pub fn RealmPage() -> impl IntoView {
scene_dimensions=scene_dimensions.get()
/>
// Log popup
<LogPopup
open=Signal::derive(move || log_open.get())
message_log=message_log
on_close=Callback::new(move |_: ()| {
set_log_open.set(false);
})
/>
// Keybindings popup
<KeybindingsPopup
open=Signal::derive(move || keybindings_open.get())
@ -1226,6 +1278,9 @@ pub fn RealmPage() -> impl IntoView {
/>
}
}
// Hotkey help overlay (shown while ? is held)
<HotkeyHelp visible=Signal::derive(move || hotkey_help_visible.get()) />
}
.into_any()
}