display sent message in chat log

This commit is contained in:
yuni 2024-11-14 21:39:34 +01:00
parent b5ab422017
commit cc34c9b21b
3 changed files with 15 additions and 0 deletions

View file

@ -775,6 +775,9 @@ pub fn handle_chat_events(
chat.talker.name.clone().unwrap_or("".to_string()),
);
}
hud::LogLevel::Send => {
log.send(message.into());
}
hud::LogLevel::Info => {
log.info(message.into());
}
@ -851,6 +854,7 @@ pub fn handle_chat_events(
fn handle_reply_keys(
keyboard_input: Res<ButtonInput<KeyCode>>,
settings: Res<var::Settings>,
mut log: ResMut<hud::Log>,
q_choices: Query<&Choice>,
mut q_chats: Query<&mut Chat>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
@ -871,6 +875,9 @@ fn handle_reply_keys(
if let Ok(mut chat) = q_chats.get_single_mut() {
// Advance the chat.
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
if choice.text != TEXT_CONTINUE {
log.send(choice.text.clone());
}
chat.timer = time.elapsed_seconds_f64();
chat.position = choice.goto.clone();
chat.message_open = false;

View file

@ -228,6 +228,7 @@ pub enum LogLevel {
Info,
//Debug,
Chat,
Send,
//Ping,
}
@ -295,6 +296,10 @@ impl Log {
self.add(message, sender, LogLevel::Chat);
}
pub fn send(&mut self, message: String) {
self.add(message, "Me".to_string(), LogLevel::Send);
}
pub fn warning(&mut self, message: String) {
self.add(message, "WARNING".to_string(), LogLevel::Warning);
}
@ -1040,6 +1045,7 @@ fn update_hud(
LogLevel::Achievement => settings.hud_color_console_achievement,
LogLevel::Warning => settings.hud_color_console_warn,
LogLevel::Info => settings.hud_color_console_system,
LogLevel::Send => settings.hud_color_console_send,
_ => settings.hud_color_console,
};
chat.sections[row].style.color.set_alpha(opacity);

View file

@ -69,6 +69,7 @@ pub struct Settings {
pub hud_color: Color,
pub hud_color_fps: Color,
pub hud_color_console: Color,
pub hud_color_console_send: Color,
pub hud_color_console_warn: Color,
pub hud_color_console_system: Color,
pub hud_color_console_achievement: Color,
@ -213,6 +214,7 @@ impl Default for Settings {
hud_color: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
hud_color_fps: Srgba::hex("#181818").unwrap().into(),
hud_color_console: Srgba::hex(COLOR_PRIMARY).unwrap().into(),
hud_color_console_send: Srgba::hex(COLOR_SECONDARY).unwrap().into(),
hud_color_console_achievement: Srgba::hex(COLOR_SUCCESS).unwrap().into(),
hud_color_console_warn: Srgba::hex(COLOR_WARNING).unwrap().into(),
hud_color_console_system: Srgba::hex(COLOR_SECONDARY).unwrap().into(),