Small chat fixes

This commit is contained in:
Monty Marz 2019-07-29 14:40:46 +00:00 committed by Forest Anderson
parent 6cad01324a
commit 5cfc60da50
8 changed files with 59 additions and 30 deletions

BIN
assets/voxygen/voxel/object/carpet.vox (Stored with Git LFS)

Binary file not shown.

View File

@ -58,4 +58,9 @@ pub enum ChatType {
GameUpdate,
Private,
Tell,
Say,
Group,
Faction,
Meta,
Kill,
}

View File

@ -65,4 +65,10 @@ impl ClientMsg {
message,
}
}
pub fn kill(message: String) -> ClientMsg {
ClientMsg::ChatMsg {
chat_type: ChatType::Private,
message,
}
}
}

View File

@ -93,4 +93,10 @@ impl ServerMsg {
message,
}
}
pub fn kill(message: String) -> ServerMsg {
ServerMsg::ChatMsg {
chat_type: ChatType::Kill,
message,
}
}
}

View File

@ -92,7 +92,7 @@ lazy_static! {
ChatCommand::new(
"time",
"{} {s}",
"/time : Set the time of day",
"/time <XY:XY> 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 <opt: <<cr> <cg> <cb>> <<ox> <oy> <oz>> <<strenght>>>: Spawn entity with light",
"/light <opt: <<cr> <cg> <cb>> <<ox> <oy> <oz>> <<strength>>>: 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 {

View File

@ -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::<comp::Player>().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::<comp::Player>().get(entity) {
Some(player) => format!("[{}] {}", &player.alias, message),
None => format!("[<anon>] {}", message),
None => format!("[<Unknown>] {}", 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

View File

@ -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)

View File

@ -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 {