mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-19 19:44:46 +00:00
✨ Implement a UI Modal when waiting to join a server
This commit is contained in:
parent
3a60f48af5
commit
7a7fe469b2
|
|
@ -25,7 +25,7 @@ func _ready():
|
|||
func _on_menu_pressed():
|
||||
hide()
|
||||
owner.get_node(\"Main\").show()
|
||||
|
||||
|
||||
func _on_quit_pressed():
|
||||
get_tree().quit()
|
||||
|
||||
|
|
@ -37,12 +37,15 @@ func _on_join_pressed():
|
|||
addr[0] = result.get_string(\"host\")
|
||||
var rport = result.get_string(\"port\")
|
||||
if rport: addr[1] = int(rport)
|
||||
|
||||
|
||||
# create client
|
||||
var peer = ENetMultiplayerPeer.new()
|
||||
peer.create_client(addr[0], addr[1])
|
||||
|
||||
join_server.emit(peer)
|
||||
|
||||
multiplayer.connected_to_server.connect(_on_client_connected.bind(peer))
|
||||
multiplayer.connection_failed.connect(_on_client_connection_failed)
|
||||
$Modal.show()
|
||||
multiplayer.multiplayer_peer = peer
|
||||
|
||||
func _on_host_pressed():
|
||||
var port = DEFAULT_PORT
|
||||
|
|
@ -59,8 +62,14 @@ func _on_host_pressed():
|
|||
## create server
|
||||
var peer = ENetMultiplayerPeer.new()
|
||||
peer.create_server(port, MAX_CLIENTS)
|
||||
|
||||
|
||||
start_server.emit(peer)
|
||||
|
||||
func _on_client_connected(peer):
|
||||
join_server.emit(peer)
|
||||
|
||||
func _on_client_connection_failed():
|
||||
$Modal.hide()
|
||||
"
|
||||
|
||||
[node name="Multiplayer" type="PanelContainer"]
|
||||
|
|
@ -246,6 +255,25 @@ unique_name_in_owner = true
|
|||
layout_mode = 2
|
||||
placeholder_text = "9000"
|
||||
|
||||
[node name="Modal" type="Panel" parent="."]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Modal"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -59.5
|
||||
offset_top = -11.5
|
||||
offset_right = 59.5
|
||||
offset_bottom = 11.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "CONNECTING..."
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox/Menu" to="." method="_on_menu_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox/Quit" to="." method="_on_quit_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox/Join" to="." method="_on_join_pressed"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue