From 5cfc60da50276a97bb067614a222d1db82899a5e Mon Sep 17 00:00:00 2001 From: Monty Marz Date: Mon, 29 Jul 2019 14:40:46 +0000 Subject: [PATCH] Small chat fixes --- assets/voxygen/voxel/object/carpet.vox | 4 +-- common/src/lib.rs | 5 ++++ common/src/msg/client.rs | 6 ++++ common/src/msg/server.rs | 6 ++++ server/src/cmd.rs | 38 ++++++++++++-------------- server/src/lib.rs | 11 +++++--- voxygen/src/hud/chat.rs | 8 +++++- voxygen/src/hud/mod.rs | 11 ++++++-- 8 files changed, 59 insertions(+), 30 deletions(-) diff --git a/assets/voxygen/voxel/object/carpet.vox b/assets/voxygen/voxel/object/carpet.vox index 8929e0cf53..952eb56040 100644 --- a/assets/voxygen/voxel/object/carpet.vox +++ b/assets/voxygen/voxel/object/carpet.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd7bc5401d7b1f2dec05f6c306940c08bfdbdc9b685b64eb3a869f391b4f7c47 -size 58661 +oid sha256:9f6cec067f42eeced17be10965f24823e1f5e920e564c4d5172481fe5cab461c +size 47340 diff --git a/common/src/lib.rs b/common/src/lib.rs index adb734a5b7..42f30e0e23 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -58,4 +58,9 @@ pub enum ChatType { GameUpdate, Private, Tell, + Say, + Group, + Faction, + Meta, + Kill, } diff --git a/common/src/msg/client.rs b/common/src/msg/client.rs index 08cddaa2f3..6f3919159b 100644 --- a/common/src/msg/client.rs +++ b/common/src/msg/client.rs @@ -65,4 +65,10 @@ impl ClientMsg { message, } } + pub fn kill(message: String) -> ClientMsg { + ClientMsg::ChatMsg { + chat_type: ChatType::Private, + message, + } + } } diff --git a/common/src/msg/server.rs b/common/src/msg/server.rs index 5cfe7f178d..ff5ab2e346 100644 --- a/common/src/msg/server.rs +++ b/common/src/msg/server.rs @@ -93,4 +93,10 @@ impl ServerMsg { message, } } + pub fn kill(message: String) -> ServerMsg { + ServerMsg::ChatMsg { + chat_type: ChatType::Kill, + message, + } + } } diff --git a/server/src/cmd.rs b/server/src/cmd.rs index e98c2400f6..7a46857395 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -92,7 +92,7 @@ lazy_static! { ChatCommand::new( "time", "{} {s}", - "/time : Set the time of day", + "/time or [Time of day] : Set the time of day", handle_time, ), ChatCommand::new( @@ -104,7 +104,7 @@ lazy_static! { ChatCommand::new( "players", "{}", - "/players : Show the online players list", + "/players : Lists players currently online", handle_players, ), ChatCommand::new( @@ -142,7 +142,7 @@ lazy_static! { ChatCommand::new( "light", "{} {} {} {} {} {} {}", - "/light > < > <>>: Spawn entity with light", + "/light > < > <>>: Spawn entity with light", handle_light, ), ChatCommand::new( @@ -563,9 +563,10 @@ fn handle_object(server: &mut Server, entity: EcsEntity, args: String, _action: Ok("carpet_human_square_2") => comp::object::Body::CarpetHumanSquare2, Ok("carpet_human_squircle") => comp::object::Body::CarpetHumanSquircle, _ => { - return server - .clients - .notify(entity, ServerMsg::chat(String::from("Object not found!"))); + return server.clients.notify( + entity, + ServerMsg::private(String::from("Object not found!")), + ); } }; server @@ -585,11 +586,11 @@ fn handle_object(server: &mut Server, entity: EcsEntity, args: String, _action: .build(); server .clients - .notify(entity, ServerMsg::chat(format!("Spawned object."))); + .notify(entity, ServerMsg::private(format!("Spawned object."))); } else { server .clients - .notify(entity, ServerMsg::chat(format!("You have no position!"))); + .notify(entity, ServerMsg::private(format!("You have no position!"))); } } @@ -628,11 +629,11 @@ fn handle_light(server: &mut Server, entity: EcsEntity, args: String, action: &C .build(); server .clients - .notify(entity, ServerMsg::chat(format!("Spawned object."))); + .notify(entity, ServerMsg::private(format!("Spawned object."))); } else { server .clients - .notify(entity, ServerMsg::chat(format!("You have no position!"))); + .notify(entity, ServerMsg::private(format!("You have no position!"))); } } @@ -655,7 +656,7 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action: light.strength = s.max(0.1).min(20.0); server.clients.notify( entity, - ServerMsg::chat(String::from("You played with the lantern intensity.")), + ServerMsg::private(String::from("You played with flame strength.")), ); } } else { @@ -666,7 +667,7 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action: .remove(entity); server.clients.notify( entity, - ServerMsg::chat(String::from("You snuff out your lantern.")), + ServerMsg::private(String::from("You put out the lantern.")), ); } } else { @@ -685,7 +686,7 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action: server.clients.notify( entity, - ServerMsg::chat(String::from("You light your lantern.")), + ServerMsg::private(String::from("You lighted your lantern.")), ); } } @@ -712,27 +713,24 @@ fn handle_tell(server: &mut Server, entity: EcsEntity, args: String, action: &Ch Some(name) => { server.clients.notify( player, - ServerMsg::tell(format!("{} tells you:{}", name, msg)), + ServerMsg::tell(format!("[{}] tells you:{}", name, msg)), ); server.clients.notify( entity, - ServerMsg::tell(format!("You tell {}:{}", alias, msg)), + ServerMsg::tell(format!("You tell [{}]:{}", alias, msg)), ); } None => { server.clients.notify( entity, - ServerMsg::private(String::from("You do not exist!")), + ServerMsg::private(String::from("Failed to send message.")), ); } } } else { server.clients.notify( entity, - ServerMsg::private(format!( - "You really should say something to {}!", - alias - )), + ServerMsg::private(format!("[{}] wants to talk to you.", alias)), ); } } else { diff --git a/server/src/lib.rs b/server/src/lib.rs index ea25fef7d0..fd66034b79 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -512,7 +512,10 @@ impl Server { { new_chat_msgs.push(( None, - ServerMsg::broadcast(format!("{} joined", &player.alias)), + ServerMsg::broadcast(format!( + "[{}] is now online.", + &player.alias + )), )); } } @@ -613,7 +616,7 @@ impl Server { if let Some(player) = state.ecs().read_storage::().get(entity) { new_chat_msgs.push(( None, - ServerMsg::broadcast(format!("{} disconnected", &player.alias)), + ServerMsg::broadcast(format!("{} went offline.", &player.alias)), )); } disconnected_clients.push(entity); @@ -637,7 +640,7 @@ impl Server { let message = match self.state.ecs().read_storage::().get(entity) { Some(player) => format!("[{}] {}", &player.alias, message), - None => format!("[] {}", message), + None => format!("[] {}", message), }; self.clients .notify_registered(ServerMsg::ChatMsg { chat_type, message }); @@ -737,7 +740,7 @@ impl Server { } .unwrap_or(format!("{} died", &player.alias)); - clients.notify_registered(ServerMsg::chat(msg)); + clients.notify_registered(ServerMsg::kill(msg)); } // Give EXP to the client diff --git a/voxygen/src/hud/chat.rs b/voxygen/src/hud/chat.rs index 76568a636c..fcdcbb470a 100644 --- a/voxygen/src/hud/chat.rs +++ b/voxygen/src/hud/chat.rs @@ -1,5 +1,6 @@ use super::{ - img_ids::Imgs, Fonts, BROADCAST_COLOR, GAME_UPDATE_COLOR, PRIVATE_COLOR, TELL_COLOR, TEXT_COLOR, + img_ids::Imgs, Fonts, BROADCAST_COLOR, FACTION_COLOR, GAME_UPDATE_COLOR, GROUP_COLOR, + KILL_COLOR, META_COLOR, PRIVATE_COLOR, SAY_COLOR, TELL_COLOR, TEXT_COLOR, }; use client::Event as ClientEvent; use common::ChatType; @@ -191,11 +192,16 @@ impl<'a> Widget for Chat<'a> { match msg { ClientEvent::Chat { chat_type, message } => { let color = match chat_type { + ChatType::Meta => META_COLOR, ChatType::Tell => TELL_COLOR, ChatType::Chat => TEXT_COLOR, ChatType::Private => PRIVATE_COLOR, ChatType::Broadcast => BROADCAST_COLOR, ChatType::GameUpdate => GAME_UPDATE_COLOR, + ChatType::Say => SAY_COLOR, + ChatType::Group => GROUP_COLOR, + ChatType::Faction => FACTION_COLOR, + ChatType::Kill => KILL_COLOR, }; let text = Text::new(&message) .font_size(15) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 9921b4425c..689f1f5668 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -52,10 +52,15 @@ const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0); const TEXT_COLOR_2: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); const HP_COLOR: Color = Color::Rgba(0.33, 0.63, 0.0, 1.0); const MANA_COLOR: Color = Color::Rgba(0.42, 0.41, 0.66, 1.0); -const TELL_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0); -const PRIVATE_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0); -const BROADCAST_COLOR: Color = Color::Rgba(0.0, 1.0, 0.0, 1.0); +const META_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0); +const TELL_COLOR: Color = Color::Rgba(0.98, 0.71, 1.0, 1.0); +const PRIVATE_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0); // Difference between private and tell? +const BROADCAST_COLOR: Color = Color::Rgba(0.28, 0.83, 0.71, 1.0); const GAME_UPDATE_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0); +const SAY_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0); +const GROUP_COLOR: Color = Color::Rgba(0.47, 0.84, 1.0, 1.0); +const FACTION_COLOR: Color = Color::Rgba(0.24, 1.0, 0.48, 1.0); +const KILL_COLOR: Color = Color::Rgba(1.0, 0.17, 0.17, 1.0); widget_ids! { struct Ids {