rename ip to address and remove ip validation
This commit is contained in:
parent
a762c2d8ad
commit
340a176e55
@ -54,7 +54,7 @@ text = "Name:"
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
focus_neighbor_right = NodePath("../HostButton")
|
focus_neighbor_right = NodePath("../HostButton")
|
||||||
focus_neighbor_bottom = NodePath("../IpEdit")
|
focus_neighbor_bottom = NodePath("../AddressEdit")
|
||||||
theme_override_font_sizes/font_size = 26
|
theme_override_font_sizes/font_size = 26
|
||||||
text = "ass"
|
text = "ass"
|
||||||
|
|
||||||
@ -65,12 +65,12 @@ focus_neighbor_bottom = NodePath("../JoinButton")
|
|||||||
theme_override_font_sizes/font_size = 26
|
theme_override_font_sizes/font_size = 26
|
||||||
text = "Host"
|
text = "Host"
|
||||||
|
|
||||||
[node name="IpLabel" type="Label" parent="Menu/PlayMenu/MarginContainer/GridContainer"]
|
[node name="AddressLabel" type="Label" parent="Menu/PlayMenu/MarginContainer/GridContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 26
|
theme_override_font_sizes/font_size = 26
|
||||||
text = "IP:"
|
text = "Address:"
|
||||||
|
|
||||||
[node name="IpEdit" type="LineEdit" parent="Menu/PlayMenu/MarginContainer/GridContainer"]
|
[node name="AddressEdit" type="LineEdit" parent="Menu/PlayMenu/MarginContainer/GridContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
focus_neighbor_top = NodePath("../NameEdit")
|
focus_neighbor_top = NodePath("../NameEdit")
|
||||||
@ -80,7 +80,7 @@ text = "127.0.0.1"
|
|||||||
|
|
||||||
[node name="JoinButton" type="Button" parent="Menu/PlayMenu/MarginContainer/GridContainer"]
|
[node name="JoinButton" type="Button" parent="Menu/PlayMenu/MarginContainer/GridContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
focus_neighbor_left = NodePath("../IpEdit")
|
focus_neighbor_left = NodePath("../AddressEdit")
|
||||||
focus_neighbor_top = NodePath("../HostButton")
|
focus_neighbor_top = NodePath("../HostButton")
|
||||||
theme_override_font_sizes/font_size = 26
|
theme_override_font_sizes/font_size = 26
|
||||||
text = "Join"
|
text = "Join"
|
||||||
|
|||||||
@ -57,10 +57,10 @@ func host_game(dedicated: bool = false) -> void:
|
|||||||
_add_player(multiplayer.get_unique_id())
|
_add_player(multiplayer.get_unique_id())
|
||||||
|
|
||||||
|
|
||||||
func join_game(ip: String) -> void:
|
func join_game(address: String) -> void:
|
||||||
print("Joining " + ip + "...")
|
print("Joining " + address + "...")
|
||||||
_peer = ENetMultiplayerPeer.new()
|
_peer = ENetMultiplayerPeer.new()
|
||||||
var error := _peer.create_client(ip, DEFAULT_PORT)
|
var error := _peer.create_client(address, DEFAULT_PORT)
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
match error:
|
match error:
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
extends Panel
|
extends Panel
|
||||||
|
|
||||||
@onready var _name_edit: LineEdit = $MarginContainer/GridContainer/NameEdit
|
@onready var _name_edit: LineEdit = $MarginContainer/GridContainer/NameEdit
|
||||||
@onready var _ip_edit: LineEdit = $MarginContainer/GridContainer/IpEdit
|
@onready var _address_edit: LineEdit = $MarginContainer/GridContainer/AddressEdit
|
||||||
@onready var _host_button: Button = $MarginContainer/GridContainer/HostButton
|
@onready var _host_button: Button = $MarginContainer/GridContainer/HostButton
|
||||||
@onready var _join_button: Button = $MarginContainer/GridContainer/JoinButton
|
@onready var _join_button: Button = $MarginContainer/GridContainer/JoinButton
|
||||||
@onready var _error_label: Label = $ErrorLabel
|
@onready var _error_label: Label = $ErrorLabel
|
||||||
@ -29,16 +29,11 @@ func _on_host_button_pressed() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_join_button_pressed() -> void:
|
func _on_join_button_pressed() -> void:
|
||||||
var ip: String = _ip_edit.text
|
|
||||||
if not ip.is_valid_ip_address():
|
|
||||||
_display_error("Invalid IP address")
|
|
||||||
return
|
|
||||||
|
|
||||||
_join_button.disabled = true
|
_join_button.disabled = true
|
||||||
_host_button.disabled = true
|
_host_button.disabled = true
|
||||||
|
|
||||||
Networker.set_local_player_info(_name_edit.text)
|
Networker.set_local_player_info(_name_edit.text)
|
||||||
Networker.join_game(_ip_edit.text)
|
Networker.join_game(_address_edit.text)
|
||||||
|
|
||||||
|
|
||||||
func _on_networker_network_error(message: String) -> void:
|
func _on_networker_network_error(message: String) -> void:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user