Skip to content

Commit 9dd4c59

Browse files
committed
Add more informative loading screen
1 parent 5da8ebc commit 9dd4c59

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

mirror-godot-app/scripts/autoload/zone/client.gd

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ func _client_on_game_ui_space_loaded() -> void:
115115

116116
## connect_to_server
117117
func connect_to_server(server_addr: Variant, port: Variant) -> bool:
118+
GameUI.loading_ui.populate_status("Opening connection to server")
119+
print("Opening connection to server at ", Time.get_datetime_string_from_system())
118120
if server_addr.is_empty():
119121
return false
120122
client_peer = ENetMultiplayerPeer.new()
@@ -162,7 +164,8 @@ func _client_on_connected_to_server() -> void:
162164
print("----------------------------------------")
163165
print("ClientPeer: Connected to a server... waiting for server to grant access")
164166
print("----------------------------------------")
165-
167+
GameUI.loading_ui.populate_status("Client socked open")
168+
print("Client connection opened at " + Time.get_datetime_string_from_system())
166169
Analytics.track_event_client(AnalyticsEvent.TYPE.SPACE_JOIN_ATTEMPT_SUCCESS, {"spaceId": _queued_space_id})
167170
Zone.change_to_space_scene()
168171
# TODO: Instead of true, determine if the player has creator permissions for the space.
@@ -175,18 +178,22 @@ func _client_on_connected_to_server() -> void:
175178
var jwt = Firebase.Auth.get_jwt()
176179
var user_id = JWT.get_user_id_from_jwt(jwt, "test123")
177180
var client_version: String = str(Util.get_version_string())
181+
GameUI.loading_ui.populate_status("Requesting client spawn...")
182+
print("Sending client init to server at " + Time.get_datetime_string_from_system())
178183
Zone.send_data_to_server([Packet.TYPE.CLIENT_INIT, jwt, client_version])
179184
PlayerData.acknowledge_local_user_id(user_id)
180185

181186
# note: GDScript cannot understand Zone definition unless passed via a variable in the stack.
182187
var zone_autoload = Zone
188+
# TODO: gordon look here this is a bit fishy. Why start syncing things before all objects exist?
183189
TMSceneSync.start_sync(zone_autoload)
184190

185191
# wait for the space to be in a loaded enough condition to join.
186192
# play servers load all objects before finishing
187193
# wait for the first spawn to complete too
188194
while not is_space_loaded():
189195
await get_tree().create_timer(0.5).timeout
196+
190197
join_server_complete.emit()
191198

192199

@@ -438,6 +445,8 @@ func start_join_localhost() -> void:
438445

439446

440447
func start_join_zone_by_space_id(space_id: String) -> void:
448+
print("Join requested at ", Time.get_datetime_string_from_system())
449+
GameUI.loading_ui.populate_status("Joining space")
441450
_is_joining_play_space = false
442451
join_server_start.emit()
443452
if space_id == _LOCALHOST:
@@ -449,6 +458,7 @@ func start_join_zone_by_space_id(space_id: String) -> void:
449458

450459

451460
func start_join_play_space_by_space_id(space_id: String) -> void:
461+
GameUI.loading_ui.populate_status("Joining space")
452462
join_server_start.emit()
453463
_disconnect_from_server_peer()
454464
_is_joining_play_space = true # after disconnect so flag is not cleared

mirror-godot-app/scripts/autoload/zone/server.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ func _all_files_downloaded() -> bool:
534534

535535

536536
func _init_player(peer_id, jwt, client_version) -> void:
537+
print("Received client init on server at " + Time.get_datetime_string_from_system())
537538
# TODO: This only decodes the JWT, but it needs to validated via Firebase SDK (probs via the NestJS server for ease)
538539
# TODO: Kick the player if JWT validating fails
539540
var user_id = JWT.get_user_id_from_jwt(jwt, "test123")

mirror-godot-app/ui/game/loading_ui.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func _on_join_server_start() -> void:
4141
show()
4242

4343
func _on_join_server_complete() -> void:
44+
GameUI.loading_ui.populate_status("")
45+
print("Loading UI has been closed at: ", Time.get_datetime_string_from_system())
4446
hide()
4547
_progress_animation.stop()
4648

0 commit comments

Comments
 (0)