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; + } +}