1- use godot:: classes:: enet_connection:: CompressionMode ;
2- use godot:: classes:: object:: ConnectFlags ;
3- use godot:: classes:: {
4- Button , ENetMultiplayerPeer , Label , LineEdit , LinkButton , Os , Panel , ProjectSettings , IPanel
5- } ;
6- use godot:: global:: Error ;
1+ use godot:: classes:: enet_connection:: CompressionMode ;
2+ use godot:: classes:: object:: ConnectFlags ;
3+ use godot:: classes:: {
4+ Button , ENetMultiplayerPeer , IPanel , Label , LineEdit , LinkButton , Os , Panel , ProjectSettings ,
5+ } ;
6+ use godot:: global:: Error ;
77use godot:: prelude:: * ;
88
99use crate :: pong:: Pong ;
@@ -33,7 +33,6 @@ pub struct Lobby {
3333
3434#[ godot_api]
3535impl IPanel for Lobby {
36-
3736 fn ready ( & mut self ) {
3837 /*
3938 # Connect all the callbacks related to networking.
@@ -51,16 +50,15 @@ impl IPanel for Lobby {
5150 . builder ( )
5251 . connect_other_gd ( & gd_ref, |mut this : Gd < Self > , _id : i64 | {
5352 godot_print ! ( "Someone connected, start the game!" ) ;
54- let pong: Gd < Pong > = load :: < PackedScene > ( "res://pong.tscn" )
55- . instantiate_as :: < Pong > ( ) ;
53+ let pong: Gd < Pong > =
54+ load :: < PackedScene > ( "res://pong.tscn" ) . instantiate_as :: < Pong > ( ) ;
5655 // Connect deferred so we can safely erase it from the callback.
5756 pong. signals ( )
5857 . game_finished ( )
5958 . builder ( )
6059 . flags ( ConnectFlags :: DEFERRED )
6160 . connect_other_gd ( & this, |mut this : Gd < Self > | {
62- this. bind_mut ( )
63- . end_game ( "Client disconnected." . to_string ( ) ) ;
61+ this. bind_mut ( ) . end_game ( "Client disconnected." . to_string ( ) ) ;
6462 } ) ;
6563
6664 this. bind_mut ( )
@@ -148,7 +146,7 @@ impl Lobby {
148146 self . base ( ) . get_node_as :: < Node > ( "/root/Pong" ) . free ( ) ;
149147 self . base_mut ( ) . show ( ) ;
150148 }
151-
149+
152150 let mut multiplayer = self . base ( ) . get_multiplayer ( ) . unwrap ( ) ;
153151 multiplayer. set_multiplayer_peer ( Gd :: null_arg ( ) ) ; // Remove peer.
154152 self . host_button . set_disabled ( false ) ;
@@ -176,13 +174,13 @@ impl Lobby {
176174 self . host_button . set_disabled ( true ) ;
177175 self . join_button . set_disabled ( true ) ;
178176 self . set_status ( "Waiting for player..." , true ) ;
179- let application_name = ProjectSettings :: singleton ( )
180- . get_setting ( "application/config/name" )
181- . to_string ( ) ;
182- self . base_mut ( )
183- . get_window ( )
184- . unwrap ( )
185- . set_title ( & format ! ( "{application_name}: Server" ) ) ;
177+ let application_name = ProjectSettings :: singleton ( )
178+ . get_setting ( "application/config/name" )
179+ . to_string ( ) ;
180+ self . base_mut ( )
181+ . get_window ( )
182+ . unwrap ( )
183+ . set_title ( & format ! ( "{application_name}: Server" ) ) ;
186184 // Only show hosting instructions when relevant.
187185 self . port_forward_label . set_visible ( true ) ;
188186 self . find_public_ip_button . set_visible ( true ) ;
@@ -205,13 +203,13 @@ impl Lobby {
205203 multiplayer. set_multiplayer_peer ( & peer) ;
206204
207205 self . set_status ( "Connecting..." , true ) ;
208- let application_name = ProjectSettings :: singleton ( )
209- . get_setting ( "application/config/name" )
210- . to_string ( ) ;
211- self . base_mut ( )
212- . get_window ( )
213- . unwrap ( )
214- . set_title ( & format ! ( "{application_name}: Client" ) ) ;
206+ let application_name = ProjectSettings :: singleton ( )
207+ . get_setting ( "application/config/name" )
208+ . to_string ( ) ;
209+ self . base_mut ( )
210+ . get_window ( )
211+ . unwrap ( )
212+ . set_title ( & format ! ( "{application_name}: Client" ) ) ;
215213 }
216214
217215 fn _on_find_public_ip_pressed ( & mut self ) {
0 commit comments