diff --git a/game/editor/src/action_logic.rs b/game/editor/src/action_logic.rs index 6a48c0c..eace5a5 100644 --- a/game/editor/src/action_logic.rs +++ b/game/editor/src/action_logic.rs @@ -563,7 +563,7 @@ pub fn merge_actions(actions: &mut Vec) -> anyhow::Result<()> { break; } } else { - break; + unreachable!(); } } diff --git a/game/editor/src/client.rs b/game/editor/src/client.rs index 58f7a05..752094c 100644 --- a/game/editor/src/client.rs +++ b/game/editor/src/client.rs @@ -35,7 +35,7 @@ pub struct EditorClient { notifications: EditorNotifications, local_client: bool, - clients: Vec, + pub(crate) clients: Vec, mapper_name: String, } diff --git a/game/editor/src/editor.rs b/game/editor/src/editor.rs index e0bb59f..c39d253 100644 --- a/game/editor/src/editor.rs +++ b/game/editor/src/editor.rs @@ -2343,7 +2343,7 @@ impl Editor { password, mapper_name, } => self.new_map( - "loading", + &ip_port.clone(), MapLoadOptions::WithoutServer { server_addr: ip_port, cert_hash: (0..cert_hash.len()) diff --git a/game/editor/src/server.rs b/game/editor/src/server.rs index 74d7a4a..3f7f38b 100644 --- a/game/editor/src/server.rs +++ b/game/editor/src/server.rs @@ -88,6 +88,13 @@ impl EditorServer { } } + fn broadcast_client_infos(&self) { + self.network + .send(EditorEvent::Server(EditorEventServerToClient::Infos( + self.clients.values().map(|c| c.props.clone()).collect(), + ))); + } + pub fn update( &mut self, tp: &Arc, @@ -195,13 +202,13 @@ impl EditorServer { )), ); } + + self.broadcast_client_infos(); } } else if client.is_authed { match ev { EditorEventClientToServer::Action(act) => { - if self.cur_action_group < self.action_groups.len() { - self.action_groups.truncate(self.cur_action_group + 1); - } + self.action_groups.truncate(self.cur_action_group + 1); if self .action_groups @@ -370,20 +377,12 @@ impl EditorServer { NetworkEvent::Connected { .. } => { self.clients.insert(id, Client::default()); - self.network.send(EditorEvent::Server( - EditorEventServerToClient::Infos( - self.clients.values().map(|c| c.props.clone()).collect(), - ), - )); + self.broadcast_client_infos(); } NetworkEvent::Disconnected { .. } => { self.clients.remove(&id); - self.network.send(EditorEvent::Server( - EditorEventServerToClient::Infos( - self.clients.values().map(|c| c.props.clone()).collect(), - ), - )); + self.broadcast_client_infos(); } _ => { // ignore diff --git a/game/editor/src/ui/top_tabs/main_frame.rs b/game/editor/src/ui/top_tabs/main_frame.rs index 11d7984..c7668f2 100644 --- a/game/editor/src/ui/top_tabs/main_frame.rs +++ b/game/editor/src/ui/top_tabs/main_frame.rs @@ -14,17 +14,30 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe) { ui.horizontal(|ui| { ui.style_mut().spacing.item_spacing.x = 0.0; let mut remove_tab = None; - for tab in pipe.user_data.editor_tabs.tabs.keys() { - if ui - .add( - Button::new(tab).selected(pipe.user_data.editor_tabs.active_tab == tab), - ) - .clicked() - { - *pipe.user_data.editor_tabs.active_tab = tab.clone(); + for (tab_name, tab) in pipe.user_data.editor_tabs.tabs.iter() { + let tab_display_name = if tab.client.clients.len() > 1 { + format!("\u{f0c0} {tab_name}") + } else { + tab_name.clone() + }; + let mut btn = ui.add( + Button::new(tab_display_name) + .selected(pipe.user_data.editor_tabs.active_tab == tab_name), + ); + if tab.client.clients.len() > 1 { + btn = btn.on_hover_ui(|ui| { + ui.vertical(|ui| { + for client in tab.client.clients.iter() { + ui.label(&client.mapper_name); + } + }); + }) + } + if btn.clicked() { + *pipe.user_data.editor_tabs.active_tab = tab_name.clone(); } if ui.add(Button::new("\u{f00d}")).clicked() { - remove_tab = Some(tab.clone()); + remove_tab = Some(tab_name.clone()); } ui.add_space(10.0); }