Simplified Network manager WIP
This commit is contained in:
+10
-10
@@ -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
|
||||
|
||||
+41
-36
@@ -1,97 +1,102 @@
|
||||
[gd_scene format=3]
|
||||
[gd_scene format=3 uid="uid://jispfagyh1di"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://crs47shds8bm4" path="res://ui/main_menu_panel.gd" id="1_panel"]
|
||||
|
||||
[node name="MainMenuPanel" type="Control"]
|
||||
[node name="MainMenuPanel" type="Control" unique_id=1716965055]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_panel")
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
[node name="Background" type="ColorRect" parent="." unique_id=417297929]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.09, 0.1, 0.13, 1)
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
[node name="Margin" type="MarginContainer" parent="." unique_id=122841427]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 24
|
||||
theme_override_constants/margin_top = 16
|
||||
theme_override_constants/margin_right = 24
|
||||
theme_override_constants/margin_bottom = 16
|
||||
|
||||
[node name="Title" type="Label" parent="Margin"]
|
||||
[node name="Title" type="Label" parent="Margin" unique_id=1426156127]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "VRyHungry"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Status" type="Label" parent="Margin"]
|
||||
[node name="Status" type="Label" parent="Margin" unique_id=672946938]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
theme_override_colors/font_color = Color(0.8, 0.8, 0.5, 1)
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = ""
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="RootView" type="VBoxContainer" parent="Margin"]
|
||||
[node name="RootView" type="VBoxContainer" parent="Margin" unique_id=1020931014]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 14
|
||||
|
||||
[node name="Spacer" type="Control" parent="Margin/RootView"]
|
||||
[node name="Spacer" type="Control" parent="Margin/RootView" unique_id=1907673970]
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="JohnButton" type="Button" parent="Margin/RootView"]
|
||||
[node name="JohnButton" type="Button" parent="Margin/RootView" unique_id=593797044]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 64)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "Play John's Scene"
|
||||
|
||||
[node name="HostButton" type="Button" parent="Margin/RootView"]
|
||||
[node name="HostButton" type="Button" parent="Margin/RootView" unique_id=2142523398]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 64)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "Host Multiplayer"
|
||||
|
||||
[node name="JoinMenuButton" type="Button" parent="Margin/RootView"]
|
||||
[node name="JoinMenuButton" type="Button" parent="Margin/RootView" unique_id=1379606559]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 64)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "Join Multiplayer"
|
||||
|
||||
[node name="JoinView" type="VBoxContainer" parent="Margin"]
|
||||
[node name="JoinView" type="VBoxContainer" parent="Margin" unique_id=1763078998]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="Title" type="Label" parent="Margin/JoinView"]
|
||||
[node name="Title" type="Label" parent="Margin/JoinView" unique_id=309630334]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 22
|
||||
text = "Join Multiplayer"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="IPLabel" type="Label" parent="Margin/JoinView"]
|
||||
[node name="IPLabel" type="Label" parent="Margin/JoinView" unique_id=108493382]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 34
|
||||
text = "127.0.0.1"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Keypad" type="GridContainer" parent="Margin/JoinView"]
|
||||
[node name="Keypad" type="GridContainer" parent="Margin/JoinView" unique_id=1454498030]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
@@ -99,106 +104,106 @@ theme_override_constants/h_separation = 8
|
||||
theme_override_constants/v_separation = 8
|
||||
columns = 3
|
||||
|
||||
[node name="B1" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B1" type="Button" parent="Margin/JoinView/Keypad" unique_id=535729591]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "1"
|
||||
|
||||
[node name="B2" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B2" type="Button" parent="Margin/JoinView/Keypad" unique_id=439142035]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "2"
|
||||
|
||||
[node name="B3" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B3" type="Button" parent="Margin/JoinView/Keypad" unique_id=20138366]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "3"
|
||||
|
||||
[node name="B4" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B4" type="Button" parent="Margin/JoinView/Keypad" unique_id=1142576108]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "4"
|
||||
|
||||
[node name="B5" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B5" type="Button" parent="Margin/JoinView/Keypad" unique_id=422202098]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "5"
|
||||
|
||||
[node name="B6" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B6" type="Button" parent="Margin/JoinView/Keypad" unique_id=652822802]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "6"
|
||||
|
||||
[node name="B7" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B7" type="Button" parent="Margin/JoinView/Keypad" unique_id=1644038518]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "7"
|
||||
|
||||
[node name="B8" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B8" type="Button" parent="Margin/JoinView/Keypad" unique_id=2009764487]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "8"
|
||||
|
||||
[node name="B9" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B9" type="Button" parent="Margin/JoinView/Keypad" unique_id=809575757]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "9"
|
||||
|
||||
[node name="BDot" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="BDot" type="Button" parent="Margin/JoinView/Keypad" unique_id=2136562018]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "."
|
||||
|
||||
[node name="B0" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="B0" type="Button" parent="Margin/JoinView/Keypad" unique_id=2008425599]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "0"
|
||||
|
||||
[node name="BDel" type="Button" parent="Margin/JoinView/Keypad"]
|
||||
[node name="BDel" type="Button" parent="Margin/JoinView/Keypad" unique_id=413462771]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_font_sizes/font_size = 22
|
||||
text = "DEL"
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="Margin/JoinView"]
|
||||
[node name="Buttons" type="HBoxContainer" parent="Margin/JoinView" unique_id=2121996996]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="JoinButton" type="Button" parent="Margin/JoinView/Buttons"]
|
||||
[node name="JoinButton" type="Button" parent="Margin/JoinView/Buttons" unique_id=1797756998]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 56)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 56)
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "JOIN"
|
||||
|
||||
[node name="BackButton" type="Button" parent="Margin/JoinView/Buttons"]
|
||||
[node name="BackButton" type="Button" parent="Margin/JoinView/Buttons" unique_id=704422546]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 56)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 56)
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "BACK"
|
||||
|
||||
Reference in New Issue
Block a user