Add instructions for port forwarding in the high-level multiplayer demos

The instructions will only show when the player is hosting a server.
This also includes a button to get your public IP address.

This partially addresses #535.
This commit is contained in:
Hugo Locurcio
2020-11-08 15:37:27 +01:00
parent 2503599bed
commit 6fd3e4d525
8 changed files with 89 additions and 9 deletions

View File

@@ -92,5 +92,32 @@ size_flags_horizontal = 2
size_flags_vertical = 0
custom_colors/font_color = Color( 1, 0, 0, 1 )
align = 1
[node name="PortForward" type="Label" parent="LobbyPanel"]
visible = false
margin_left = -128.0
margin_top = 136.0
margin_right = 124.0
margin_bottom = 184.0
custom_constants/line_spacing = 6
text = "If you want non-LAN clients to connect,
make sure the port 8910 in UDP
is forwarded on your router."
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="FindPublicIP" type="LinkButton" parent="LobbyPanel"]
visible = false
margin_left = 155.0
margin_top = 152.0
margin_right = 328.0
margin_bottom = 166.0
text = "Find your public IP address"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="LobbyPanel/HostButton" to="LobbyPanel" method="_on_host_pressed"]
[connection signal="pressed" from="LobbyPanel/JoinButton" to="LobbyPanel" method="_on_join_pressed"]
[connection signal="pressed" from="LobbyPanel/FindPublicIP" to="LobbyPanel" method="_on_find_public_ip_pressed"]

View File

@@ -1,12 +1,17 @@
extends Control
const DEFAULT_PORT = 8910 # An arbitrary number.
# Default game server port. Can be any number between 1024 and 49151.
# Not on the list of registered or common ports as of November 2020:
# https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
const DEFAULT_PORT = 8910
onready var address = $Address
onready var host_button = $HostButton
onready var join_button = $JoinButton
onready var status_ok = $StatusOk
onready var status_fail = $StatusFail
onready var port_forward_label = $PortForward
onready var find_public_ip_button = $FindPublicIP
var peer = null
@@ -95,6 +100,10 @@ func _on_host_pressed():
join_button.set_disabled(true)
_set_status("Waiting for player...", true)
# Only show hosting instructions when relevant.
port_forward_label.visible = true
find_public_ip_button.visible = true
func _on_join_pressed():
var ip = address.get_text()
@@ -108,3 +117,7 @@ func _on_join_pressed():
get_tree().set_network_peer(peer)
_set_status("Connecting...", true)
func _on_find_public_ip_pressed():
OS.shell_open("https://icanhazip.com/")