From 61b63a55d2a5c25808ff17c55be3296739521e94 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Thu, 25 Apr 2024 17:49:12 +0200 Subject: [PATCH] rename `ChatManager` to `ChatHistory` --- kubi/src/chat.rs | 6 +++--- kubi/src/networking/handshake.rs | 4 ++-- kubi/src/networking/player.rs | 6 +++--- kubi/src/ui/chat_ui.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kubi/src/chat.rs b/kubi/src/chat.rs index d6c9e0f..862aa46 100644 --- a/kubi/src/chat.rs +++ b/kubi/src/chat.rs @@ -19,11 +19,11 @@ pub enum ChatMessage { } #[derive(Unique, Default)] -pub struct ChatManager { +pub struct ChatHistory { pub messages: Vec, } -impl ChatManager { +impl ChatHistory { pub fn add_message(&mut self, message: ChatMessage) { self.messages.push(message); } @@ -52,7 +52,7 @@ impl ChatManager { pub fn init_chat_manager( storages: AllStoragesView, ) { - let mut chat_manager = ChatManager::default(); + let mut chat_manager = ChatHistory::default(); chat_manager.add_system_message("Welcome to Kubi! Chat messages will appear here".to_string()); storages.add_unique(chat_manager); } diff --git a/kubi/src/networking/handshake.rs b/kubi/src/networking/handshake.rs index f929e53..c83d50a 100644 --- a/kubi/src/networking/handshake.rs +++ b/kubi/src/networking/handshake.rs @@ -6,7 +6,7 @@ use kubi_shared::networking::{ channels::Channel, }; use rand::prelude::*; -use crate::{chat::ChatManager, player::{spawn_local_player_multiplayer, spawn_remote_player_multiplayer}}; +use crate::{chat::ChatHistory, player::{spawn_local_player_multiplayer, spawn_remote_player_multiplayer}}; use super::{UdpClient, NetworkEvent}; const USERNAME_BANK: &[&str] = &[ @@ -96,7 +96,7 @@ pub fn check_server_hello_response( log::info!("Joined the server!"); // Send chat message - let mut chat = storages.borrow::>().unwrap(); + let mut chat = storages.borrow::>().unwrap(); chat.add_player_join(client_id, username); } diff --git a/kubi/src/networking/player.rs b/kubi/src/networking/player.rs index 300b0e8..0090ed7 100644 --- a/kubi/src/networking/player.rs +++ b/kubi/src/networking/player.rs @@ -10,7 +10,7 @@ use kubi_shared::{ }, }; use crate::{ - chat::ChatManager, + chat::ChatHistory, events::player_actions::PlayerActionEvent, player::spawn_remote_player_multiplayer, }; @@ -97,7 +97,7 @@ pub fn receive_player_connect_events( for message in messages { let ServerToClientMessage::PlayerConnected { init } = message else { unreachable!() }; log::info!("player connected: {} (id {})", init.username, init.client_id); - let mut chat = storages.borrow::>().unwrap(); + let mut chat = storages.borrow::>().unwrap(); chat.add_player_join(init.client_id, init.username.clone()); drop(chat); spawn_remote_player_multiplayer(&mut storages, init); @@ -132,7 +132,7 @@ pub fn receive_player_disconnect_events( }; let username = storages.get::<&Username>(ent_id).unwrap(); - let mut chat = storages.borrow::>().unwrap(); + let mut chat = storages.borrow::>().unwrap(); chat.add_player_leave(id, username.0.to_string()); drop(chat); diff --git a/kubi/src/ui/chat_ui.rs b/kubi/src/ui/chat_ui.rs index c461df3..d419ed6 100644 --- a/kubi/src/ui/chat_ui.rs +++ b/kubi/src/ui/chat_ui.rs @@ -1,11 +1,11 @@ use hui::{color, element::{container::Container, text::Text, UiElementExt}, layout::Alignment, size}; use shipyard::{NonSendSync, UniqueView, UniqueViewMut}; -use crate::{chat::{ChatManager, ChatMessage}, hui_integration::UiState, rendering::WindowSize}; +use crate::{chat::{ChatHistory, ChatMessage}, hui_integration::UiState, rendering::WindowSize}; pub fn render_chat( mut hui: NonSendSync>, size: UniqueView, - chat: UniqueView, + chat: UniqueView, ) { let messages = chat.get_messages(); if messages.is_empty() { return }