From 826638416fde090241634c282076a3e35ed79854 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 13 Apr 2024 15:44:23 +0200 Subject: [PATCH] detect choice selection keys --- src/chat.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/chat.rs b/src/chat.rs index 42109cd..8d2f711 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -42,6 +42,7 @@ impl Plugin for ChatPlugin { app.add_systems(Update, ( handle_new_conversations.before(handle_chat_events), handle_chat_events, + handle_reply_keys, handle_chat_timer.before(handle_chat_events), )); app.add_event::(); @@ -275,3 +276,29 @@ pub fn handle_chat_events( } } } + +fn handle_reply_keys( + keyboard_input: Res>, + settings: ResMut, + q_choices: Query<&Choice>, + //mut evwriter_sendmsg: EventWriter, + mut evwriter_sfx: EventWriter, +) { + let mut selected_choice: usize = 0; + 'outer: for key in settings.get_reply_keys() { + if keyboard_input.just_pressed(key) { + for choice in &q_choices { + if choice.key == selected_choice { + evwriter_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click)); +// evwriter_sendmsg.send(SendMessageEvent { +// conv_id: choice.conv_id.clone(), +// conv_label: choice.conv_label.clone(), +// text: choice.text.clone(), +// }); + break 'outer; + } + } + } + selected_choice += 1; + } +}