feat: add log and hotkey list
This commit is contained in:
parent
7852790a1e
commit
41ea9d13cb
5 changed files with 415 additions and 4 deletions
|
|
@ -109,6 +109,7 @@ fn parse_whisper_command(cmd: &str) -> Option<(String, String)> {
|
|||
/// - `on_focus_change`: Callback when focus state changes
|
||||
/// - `on_open_settings`: Callback to open settings popup
|
||||
/// - `on_open_inventory`: Callback to open inventory popup
|
||||
/// - `on_open_log`: Callback to open message log popup
|
||||
/// - `whisper_target`: Signal containing the display name to whisper to (triggers pre-fill)
|
||||
/// - `scenes`: List of available scenes for teleport command
|
||||
/// - `allow_user_teleport`: Whether teleporting is enabled for this realm
|
||||
|
|
@ -123,6 +124,9 @@ pub fn ChatInput(
|
|||
on_focus_change: Callback<bool>,
|
||||
#[prop(optional)] on_open_settings: Option<Callback<()>>,
|
||||
#[prop(optional)] on_open_inventory: Option<Callback<()>>,
|
||||
/// Callback to open message log popup.
|
||||
#[prop(optional)]
|
||||
on_open_log: Option<Callback<()>>,
|
||||
/// Signal containing the display name to whisper to. When set, pre-fills the input.
|
||||
#[prop(optional, into)]
|
||||
whisper_target: Option<Signal<Option<String>>>,
|
||||
|
|
@ -324,9 +328,11 @@ pub fn ChatInput(
|
|||
|| "inventory".starts_with(&cmd)
|
||||
|| "whisper".starts_with(&cmd)
|
||||
|| "teleport".starts_with(&cmd)
|
||||
|| "log".starts_with(&cmd)
|
||||
|| cmd == "setting"
|
||||
|| cmd == "settings"
|
||||
|| cmd == "inventory"
|
||||
|| cmd == "log"
|
||||
|| cmd.starts_with("w ")
|
||||
|| cmd.starts_with("whisper ")
|
||||
|| cmd.starts_with("t ")
|
||||
|
|
@ -348,6 +354,7 @@ pub fn ChatInput(
|
|||
let apply_emotion = apply_emotion.clone();
|
||||
let on_open_settings = on_open_settings.clone();
|
||||
let on_open_inventory = on_open_inventory.clone();
|
||||
let on_open_log = on_open_log.clone();
|
||||
move |ev: web_sys::KeyboardEvent| {
|
||||
let key = ev.key();
|
||||
let current_mode = command_mode.get_untracked();
|
||||
|
|
@ -484,6 +491,20 @@ pub fn ChatInput(
|
|||
ev.prevent_default();
|
||||
return;
|
||||
}
|
||||
// Autocomplete to /log if /l, /lo (but not if it could be /list or /teleport)
|
||||
// Only match /l if it's exactly /l (not /li which would match /list)
|
||||
if !cmd.is_empty()
|
||||
&& "log".starts_with(&cmd)
|
||||
&& cmd != "log"
|
||||
&& !cmd.starts_with("li")
|
||||
{
|
||||
set_message.set("/log".to_string());
|
||||
if let Some(input) = input_ref.get() {
|
||||
input.set_value("/log");
|
||||
}
|
||||
ev.prevent_default();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Always prevent Tab from moving focus when in input
|
||||
ev.prevent_default();
|
||||
|
|
@ -527,6 +548,21 @@ pub fn ChatInput(
|
|||
return;
|
||||
}
|
||||
|
||||
// /l, /lo, /log - open message log
|
||||
if !cmd.is_empty() && "log".starts_with(&cmd) {
|
||||
if let Some(ref callback) = on_open_log {
|
||||
callback.run(());
|
||||
}
|
||||
set_message.set(String::new());
|
||||
set_command_mode.set(CommandMode::None);
|
||||
if let Some(input) = input_ref.get() {
|
||||
input.set_value("");
|
||||
let _ = input.blur();
|
||||
}
|
||||
ev.prevent_default();
|
||||
return;
|
||||
}
|
||||
|
||||
// /w NAME message or /whisper NAME message
|
||||
if let Some((target_name, whisper_content)) = parse_whisper_command(&msg) {
|
||||
if !whisper_content.trim().is_empty() {
|
||||
|
|
@ -702,7 +738,7 @@ pub fn ChatInput(
|
|||
</div>
|
||||
</Show>
|
||||
|
||||
// Slash command hint bar (/s[etting], /i[nventory], /w[hisper], /t[eleport])
|
||||
// Slash command hint bar (/s[etting], /i[nventory], /w[hisper], /l[og], /t[eleport])
|
||||
<Show when=move || command_mode.get() == CommandMode::ShowingSlashHint>
|
||||
<div class="absolute bottom-full left-0 mb-1 px-3 py-1 bg-gray-700/90 backdrop-blur-sm rounded text-sm">
|
||||
<span class="text-gray-400">"/"</span>
|
||||
|
|
@ -716,6 +752,10 @@ pub fn ChatInput(
|
|||
<span class="text-gray-400">"/"</span>
|
||||
<span class="text-blue-400">"w"</span>
|
||||
<span class="text-gray-500">"[hisper] name"</span>
|
||||
<span class="text-gray-600 mx-2">"|"</span>
|
||||
<span class="text-gray-400">"/"</span>
|
||||
<span class="text-blue-400">"l"</span>
|
||||
<span class="text-gray-500">"[og]"</span>
|
||||
<Show when=move || allow_user_teleport.get()>
|
||||
<span class="text-gray-600 mx-2">"|"</span>
|
||||
<span class="text-gray-400">"/"</span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue