mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
connect chat box to network
Former-commit-id: 581c724ee31564c7473120d5431ceb2182afb207
This commit is contained in:
parent
9aece17286
commit
03b20fa1bd
@ -138,11 +138,10 @@ impl Client {
|
||||
// Handle new messages from the server
|
||||
frontend_events.append(&mut self.handle_new_messages()?);
|
||||
|
||||
// Step 3
|
||||
// Step 1
|
||||
if let Some(ecs_entity) = self.player {
|
||||
// TODO: remove this
|
||||
const PLAYER_VELOCITY: f32 = 100.0;
|
||||
|
||||
// TODO: Set acceleration instead
|
||||
self.state.write_component(ecs_entity, comp::phys::Vel(Vec3::from(input.move_dir * PLAYER_VELOCITY)));
|
||||
}
|
||||
|
@ -1069,6 +1069,10 @@ impl Hud {
|
||||
events
|
||||
}
|
||||
|
||||
pub fn new_message(&mut self, msg: String) {
|
||||
self.chat.new_message(msg);
|
||||
}
|
||||
|
||||
pub fn toggle_menu(&mut self) {
|
||||
self.menu_open = !self.menu_open;
|
||||
}
|
||||
|
@ -63,7 +63,14 @@ impl SessionState {
|
||||
let dir_vec = self.key_state.dir_vec();
|
||||
let move_dir = unit_vecs.0 * dir_vec[0] + unit_vecs.1 * dir_vec[1];
|
||||
|
||||
self.client.tick(client::Input { move_dir }, dt)?;
|
||||
for event in self.client.tick(client::Input { move_dir }, dt)? {
|
||||
match event {
|
||||
client::Event::Chat(msg) => {
|
||||
self.hud.new_message(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -153,7 +160,10 @@ impl PlayState for SessionState {
|
||||
// Maintain the UI
|
||||
for event in self.hud.maintain(global_state.window.renderer_mut()) {
|
||||
match event {
|
||||
HudEvent::SendMessage(message) => {} // TODO: Send msg here
|
||||
HudEvent::SendMessage(msg) => {
|
||||
// TODO: Handle result
|
||||
self.client.send_chat(msg);
|
||||
},
|
||||
HudEvent::Logout => return PlayStateResult::Pop,
|
||||
HudEvent::Quit => return PlayStateResult::Shutdown,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user