Simplified Network manager WIP

This commit is contained in:
JonShard
2026-07-29 13:41:16 +02:00
parent 0f1f0c6a93
commit 6933e17f3a
15 changed files with 299 additions and 195 deletions
+10 -10
View File
@@ -5,8 +5,8 @@ extends Control
## multiplayer game, or join one by IP, driving scene switches + NetworkManager
## directly.
const JON_SCENE := "res://Scenes/JonScene.tscn"
const MULTIPLAYER_SCENE := "res://Scenes/multiPlayer.tscn"
const JON_SCENE := "res://Scenes/jon_scene.tscn"
const MULTIPLAYER_SCENE := "res://Scenes/multiplayer.tscn"
const SETTINGS_PATH := "user://vryhungry_settings.cfg"
var _ip := "127.0.0.1"
@@ -24,6 +24,7 @@ var _ip := "127.0.0.1"
func _ready() -> void:
print("Menu Panel _ready")
if _bypass_menu_for_cmdline():
return
for child in _keypad.get_children():
@@ -37,12 +38,6 @@ func _ready() -> void:
_load_ip()
_show_root_view()
_refresh_ip()
# Show why we're back here, if the last session ended unexpectedly
# (dropped connection, failed join). Pulled rather than pushed, since
# NetworkManager may have set this before this panel even existed.
var status := NetworkManager.take_status()
if not status.is_empty():
set_status(status)
## --server / --join <ip> on the command line skip straight to the multiplayer
@@ -65,11 +60,13 @@ func _bypass_menu_for_cmdline() -> bool:
func _show_root_view() -> void:
print("Menu Panel show root view")
_root_view.visible = true
_join_view.visible = false
func _show_join_view() -> void:
print("Menu Panel show join view")
_root_view.visible = false
_join_view.visible = true
set_status("Enter host IP, then Join")
@@ -90,16 +87,19 @@ func _refresh_ip() -> void:
func _on_john_pressed() -> void:
print("Menu Panel press jon_scene")
NetworkManager.leave()
get_tree().change_scene_to_file.call_deferred(JON_SCENE)
func _on_host_pressed() -> void:
NetworkManager.request_host()
get_tree().change_scene_to_file.call_deferred("res://Scenes/JonScene.tscn")
print("Menu Panel press host")
NetworkManager.host()
get_tree().change_scene_to_file.call_deferred(MULTIPLAYER_SCENE)
func _on_join_pressed() -> void:
print("Menu Panel press host")
if _ip.is_empty():
set_status("Enter an IP first")
return