mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'small-chat-fixes' into 'master'
Small chat fixes See merge request veloren/veloren!379
This commit is contained in:
commit
fbb00601fb
BIN
assets/voxygen/voxel/object/carpet.vox
(Stored with Git LFS)
BIN
assets/voxygen/voxel/object/carpet.vox
(Stored with Git LFS)
Binary file not shown.
@ -58,4 +58,9 @@ pub enum ChatType {
|
|||||||
GameUpdate,
|
GameUpdate,
|
||||||
Private,
|
Private,
|
||||||
Tell,
|
Tell,
|
||||||
|
Say,
|
||||||
|
Group,
|
||||||
|
Faction,
|
||||||
|
Meta,
|
||||||
|
Kill,
|
||||||
}
|
}
|
||||||
|
@ -65,4 +65,10 @@ impl ClientMsg {
|
|||||||
message,
|
message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn kill(message: String) -> ClientMsg {
|
||||||
|
ClientMsg::ChatMsg {
|
||||||
|
chat_type: ChatType::Private,
|
||||||
|
message,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,4 +93,10 @@ impl ServerMsg {
|
|||||||
message,
|
message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn kill(message: String) -> ServerMsg {
|
||||||
|
ServerMsg::ChatMsg {
|
||||||
|
chat_type: ChatType::Kill,
|
||||||
|
message,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ lazy_static! {
|
|||||||
ChatCommand::new(
|
ChatCommand::new(
|
||||||
"time",
|
"time",
|
||||||
"{} {s}",
|
"{} {s}",
|
||||||
"/time : Set the time of day",
|
"/time <XY:XY> or [Time of day] : Set the time of day",
|
||||||
handle_time,
|
handle_time,
|
||||||
),
|
),
|
||||||
ChatCommand::new(
|
ChatCommand::new(
|
||||||
@ -104,7 +104,7 @@ lazy_static! {
|
|||||||
ChatCommand::new(
|
ChatCommand::new(
|
||||||
"players",
|
"players",
|
||||||
"{}",
|
"{}",
|
||||||
"/players : Show the online players list",
|
"/players : Lists players currently online",
|
||||||
handle_players,
|
handle_players,
|
||||||
),
|
),
|
||||||
ChatCommand::new(
|
ChatCommand::new(
|
||||||
@ -142,7 +142,7 @@ lazy_static! {
|
|||||||
ChatCommand::new(
|
ChatCommand::new(
|
||||||
"light",
|
"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,
|
handle_light,
|
||||||
),
|
),
|
||||||
ChatCommand::new(
|
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_square_2") => comp::object::Body::CarpetHumanSquare2,
|
||||||
Ok("carpet_human_squircle") => comp::object::Body::CarpetHumanSquircle,
|
Ok("carpet_human_squircle") => comp::object::Body::CarpetHumanSquircle,
|
||||||
_ => {
|
_ => {
|
||||||
return server
|
return server.clients.notify(
|
||||||
.clients
|
entity,
|
||||||
.notify(entity, ServerMsg::chat(String::from("Object not found!")));
|
ServerMsg::private(String::from("Object not found!")),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
server
|
server
|
||||||
@ -585,11 +586,11 @@ fn handle_object(server: &mut Server, entity: EcsEntity, args: String, _action:
|
|||||||
.build();
|
.build();
|
||||||
server
|
server
|
||||||
.clients
|
.clients
|
||||||
.notify(entity, ServerMsg::chat(format!("Spawned object.")));
|
.notify(entity, ServerMsg::private(format!("Spawned object.")));
|
||||||
} else {
|
} else {
|
||||||
server
|
server
|
||||||
.clients
|
.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();
|
.build();
|
||||||
server
|
server
|
||||||
.clients
|
.clients
|
||||||
.notify(entity, ServerMsg::chat(format!("Spawned object.")));
|
.notify(entity, ServerMsg::private(format!("Spawned object.")));
|
||||||
} else {
|
} else {
|
||||||
server
|
server
|
||||||
.clients
|
.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);
|
light.strength = s.max(0.1).min(20.0);
|
||||||
server.clients.notify(
|
server.clients.notify(
|
||||||
entity,
|
entity,
|
||||||
ServerMsg::chat(String::from("You played with the lantern intensity.")),
|
ServerMsg::private(String::from("You played with flame strength.")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -666,7 +667,7 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action:
|
|||||||
.remove(entity);
|
.remove(entity);
|
||||||
server.clients.notify(
|
server.clients.notify(
|
||||||
entity,
|
entity,
|
||||||
ServerMsg::chat(String::from("You snuff out your lantern.")),
|
ServerMsg::private(String::from("You put out the lantern.")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -685,7 +686,7 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action:
|
|||||||
|
|
||||||
server.clients.notify(
|
server.clients.notify(
|
||||||
entity,
|
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) => {
|
Some(name) => {
|
||||||
server.clients.notify(
|
server.clients.notify(
|
||||||
player,
|
player,
|
||||||
ServerMsg::tell(format!("{} tells you:{}", name, msg)),
|
ServerMsg::tell(format!("[{}] tells you:{}", name, msg)),
|
||||||
);
|
);
|
||||||
server.clients.notify(
|
server.clients.notify(
|
||||||
entity,
|
entity,
|
||||||
ServerMsg::tell(format!("You tell {}:{}", alias, msg)),
|
ServerMsg::tell(format!("You tell [{}]:{}", alias, msg)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
server.clients.notify(
|
server.clients.notify(
|
||||||
entity,
|
entity,
|
||||||
ServerMsg::private(String::from("You do not exist!")),
|
ServerMsg::private(String::from("Failed to send message.")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
server.clients.notify(
|
server.clients.notify(
|
||||||
entity,
|
entity,
|
||||||
ServerMsg::private(format!(
|
ServerMsg::private(format!("[{}] wants to talk to you.", alias)),
|
||||||
"You really should say something to {}!",
|
|
||||||
alias
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -512,7 +512,10 @@ impl Server {
|
|||||||
{
|
{
|
||||||
new_chat_msgs.push((
|
new_chat_msgs.push((
|
||||||
None,
|
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) {
|
if let Some(player) = state.ecs().read_storage::<comp::Player>().get(entity) {
|
||||||
new_chat_msgs.push((
|
new_chat_msgs.push((
|
||||||
None,
|
None,
|
||||||
ServerMsg::broadcast(format!("{} disconnected", &player.alias)),
|
ServerMsg::broadcast(format!("{} went offline.", &player.alias)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
disconnected_clients.push(entity);
|
disconnected_clients.push(entity);
|
||||||
@ -637,7 +640,7 @@ impl Server {
|
|||||||
let message =
|
let message =
|
||||||
match self.state.ecs().read_storage::<comp::Player>().get(entity) {
|
match self.state.ecs().read_storage::<comp::Player>().get(entity) {
|
||||||
Some(player) => format!("[{}] {}", &player.alias, message),
|
Some(player) => format!("[{}] {}", &player.alias, message),
|
||||||
None => format!("[<anon>] {}", message),
|
None => format!("[<Unknown>] {}", message),
|
||||||
};
|
};
|
||||||
self.clients
|
self.clients
|
||||||
.notify_registered(ServerMsg::ChatMsg { chat_type, message });
|
.notify_registered(ServerMsg::ChatMsg { chat_type, message });
|
||||||
@ -737,7 +740,7 @@ impl Server {
|
|||||||
}
|
}
|
||||||
.unwrap_or(format!("{} died", &player.alias));
|
.unwrap_or(format!("{} died", &player.alias));
|
||||||
|
|
||||||
clients.notify_registered(ServerMsg::chat(msg));
|
clients.notify_registered(ServerMsg::kill(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give EXP to the client
|
// Give EXP to the client
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use super::{
|
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 client::Event as ClientEvent;
|
||||||
use common::ChatType;
|
use common::ChatType;
|
||||||
@ -191,11 +192,16 @@ impl<'a> Widget for Chat<'a> {
|
|||||||
match msg {
|
match msg {
|
||||||
ClientEvent::Chat { chat_type, message } => {
|
ClientEvent::Chat { chat_type, message } => {
|
||||||
let color = match chat_type {
|
let color = match chat_type {
|
||||||
|
ChatType::Meta => META_COLOR,
|
||||||
ChatType::Tell => TELL_COLOR,
|
ChatType::Tell => TELL_COLOR,
|
||||||
ChatType::Chat => TEXT_COLOR,
|
ChatType::Chat => TEXT_COLOR,
|
||||||
ChatType::Private => PRIVATE_COLOR,
|
ChatType::Private => PRIVATE_COLOR,
|
||||||
ChatType::Broadcast => BROADCAST_COLOR,
|
ChatType::Broadcast => BROADCAST_COLOR,
|
||||||
ChatType::GameUpdate => GAME_UPDATE_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)
|
let text = Text::new(&message)
|
||||||
.font_size(15)
|
.font_size(15)
|
||||||
|
@ -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 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 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 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 META_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 TELL_COLOR: Color = Color::Rgba(0.98, 0.71, 1.0, 1.0);
|
||||||
const BROADCAST_COLOR: Color = Color::Rgba(0.0, 1.0, 0.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 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! {
|
widget_ids! {
|
||||||
struct Ids {
|
struct Ids {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user