Bugfixes + Menu.
This commit is contained in:
parent
1ee6f6cc6d
commit
26ee79c57d
6 changed files with 94 additions and 21 deletions
64
scenes/ui/create_room.tscn
Normal file
64
scenes/ui/create_room.tscn
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://b2te55um4ya0l"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/ui/create_room.gd" id="1_2jvdo"]
|
||||||
|
|
||||||
|
[node name="CreateRoom" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_2jvdo")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -87.5
|
||||||
|
offset_top = -71.0
|
||||||
|
offset_right = 87.5
|
||||||
|
offset_bottom = 71.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="UsernameHBox" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 8
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/UsernameHBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
text = "Username:"
|
||||||
|
|
||||||
|
[node name="LineEdit" type="LineEdit" parent="VBoxContainer/UsernameHBox"]
|
||||||
|
custom_minimum_size = Vector2(300, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="RoomnameHBox" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 8
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/RoomnameHBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
text = "Roomname:"
|
||||||
|
|
||||||
|
[node name="LineEdit" type="LineEdit" parent="VBoxContainer/RoomnameHBox"]
|
||||||
|
custom_minimum_size = Vector2(300, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="SendButton" type="Button" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
text = "Join Game"
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 10.0
|
|
@ -11,13 +11,12 @@ var skip: bool = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if Networking.isManager:
|
if Networking.isManager:
|
||||||
if timer.timeout.connect(_timer_done) != OK:
|
if timer.timeout.connect(_timer_done):
|
||||||
Log.error("FAILED to connect the timeout signal to _timer_done!", "Internal Error: Failed to connect signal.")
|
pass
|
||||||
first_frame.call_deferred()
|
first_frame.call_deferred()
|
||||||
|
|
||||||
func _timer_done() -> void:
|
func _timer_done() -> void:
|
||||||
if angry_meter > 0:
|
if angry_meter > 0:
|
||||||
Log.debug("angrier %d" % angry_meter)
|
|
||||||
angry_meter -= 1
|
angry_meter -= 1
|
||||||
else:
|
else:
|
||||||
timer.stop()
|
timer.stop()
|
||||||
|
|
10
scripts/ui/create_room.gd
Normal file
10
scripts/ui/create_room.gd
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
if ($VBoxContainer/SendButton as Button).pressed.connect(_on_send_button_pressed):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _on_send_button_pressed() -> void:
|
||||||
|
Game.username = ($VBoxContainer/UsernameHBox/LineEdit as LineEdit).text
|
||||||
|
Game.roomname = ($VBoxContainer/RoomnameHBox/LineEdit as LineEdit).text
|
||||||
|
Networking.join_room()
|
|
@ -6,11 +6,11 @@ extends Control
|
||||||
var label: PackedScene = preload("res://scenes/ui/elements/name_label.tscn")
|
var label: PackedScene = preload("res://scenes/ui/elements/name_label.tscn")
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if Networking.playerlist_changed.connect(_on_playerlist_changed) != OK:
|
if Networking.playerlist_changed.connect(_on_playerlist_changed):
|
||||||
Log.error("FAILED to connect the playerlist_changed signal to _on_playerlist_changed!", "Internal Error: Failed to connect signal.")
|
pass
|
||||||
var start_button: Button = $StartButton
|
var start_button: Button = $StartButton
|
||||||
if start_button.pressed.connect(_on_start_button_pressed) != OK:
|
if start_button.pressed.connect(_on_start_button_pressed):
|
||||||
Log.error("FAILED to connect the pressed signal to _on_start_button_pressed!", "Internal Error: Failed to connect signal.")
|
pass
|
||||||
_on_playerlist_changed()
|
_on_playerlist_changed()
|
||||||
|
|
||||||
func _on_playerlist_changed() -> void:
|
func _on_playerlist_changed() -> void:
|
||||||
|
|
|
@ -54,8 +54,9 @@ func _ready() -> void:
|
||||||
|
|
||||||
match launchmode:
|
match launchmode:
|
||||||
0:
|
0:
|
||||||
# Will eventually redirect to the main menu
|
# Menu
|
||||||
pass
|
if get_tree().change_scene_to_file("res://scenes/ui/create_room.tscn") != OK:
|
||||||
|
Log.error("Couldn't change to the create room scene! Closing application.", "Couldn't change to the create room scene!")
|
||||||
1:
|
1:
|
||||||
# Client with direct join
|
# Client with direct join
|
||||||
Networking.join_room()
|
Networking.join_room()
|
||||||
|
|
|
@ -9,16 +9,16 @@ signal playerlist_changed()
|
||||||
|
|
||||||
# Connect the signals.
|
# Connect the signals.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if multiplayer.connected_to_server.connect(_on_connected_ok) != OK:
|
if multiplayer.connected_to_server.connect(_on_connected_ok):
|
||||||
Log.error("FAILED to connect the connected_to_server signal to _on_connected_ok!", "Internal Error: Failed to connect signal.")
|
pass
|
||||||
if multiplayer.connection_failed.connect(close_network) != OK:
|
if multiplayer.connection_failed.connect(close_network):
|
||||||
Log.error("FAILED to connect the connection_failed signal to _on_connected_fail!", "Internal Error: Failed to connect signal.")
|
pass
|
||||||
if multiplayer.server_disconnected.connect(close_network) != OK:
|
if multiplayer.server_disconnected.connect(close_network):
|
||||||
Log.error("FAILED to connect the server_disconnected signal to _on_server_disconnected!", "Internal Error: Failed to connect signal.")
|
pass
|
||||||
if multiplayer.peer_disconnected.connect(_on_peer_disconnected) != OK:
|
if multiplayer.peer_disconnected.connect(_on_peer_disconnected):
|
||||||
Log.error("FAILED to connect the peer_disconnected signal to _on_peer_disconnected!", "Internal Error: Failed to connect signal.")
|
pass
|
||||||
if playerlist_changed.connect(_on_playerlist_changed) != OK:
|
if playerlist_changed.connect(_on_playerlist_changed):
|
||||||
Log.error("FAILED to connect the playerlist_changed signal to _on_playerlist_changed!", "Internal Error: Failed to connect signal.")
|
pass
|
||||||
|
|
||||||
func _on_playerlist_changed() -> void:
|
func _on_playerlist_changed() -> void:
|
||||||
pass
|
pass
|
||||||
|
@ -139,8 +139,7 @@ func host_disconnected_message() -> void:
|
||||||
Log.info("Host disconnected from the session.")
|
Log.info("Host disconnected from the session.")
|
||||||
managerID = 1
|
managerID = 1
|
||||||
close_network()
|
close_network()
|
||||||
if get_tree().change_scene_to_file("res://start.tscn"):
|
Game._ready()
|
||||||
Log.warning("Failed to change back to the main scene!")
|
|
||||||
|
|
||||||
# This is the message sent out if a peer in the room has left.
|
# This is the message sent out if a peer in the room has left.
|
||||||
@rpc("authority", "call_remote", "reliable")
|
@rpc("authority", "call_remote", "reliable")
|
||||||
|
|
Loading…
Reference in a new issue