diff --git a/Game.gd b/Game.gd index 0e53629..73f6e57 100644 --- a/Game.gd +++ b/Game.gd @@ -2,8 +2,8 @@ extends Spatial export var is_server = true -export var SERVER_PORT = 9999 -export(String, "172.28.162.191", "172.28.166.24", "127.0.0.1") var SERVER_IP = "172.28.162.191" +export var SERVER_PORT = 9999 setget , get_port +export(String, "172.28.162.191", "172.28.166.24", "127.0.0.1") var SERVER_IP = "172.28.162.191" setget , get_ip export var MAX_PLAYERS = 10 export (String, "MENU", "PLAYING") var GAME_MODE = "MENU" @@ -11,10 +11,8 @@ var player_scene = preload("res://Player.tscn") # Called when the node enters the scene tree for the first time. func _ready(): - pass - #initialize() - - #debug_connection_status() + $MenuContainer/MainMenu/Destination/IPAdress.set_text(SERVER_IP) + $MenuContainer/MainMenu/Destination/Port.set_text(str(SERVER_PORT)) func _input(event): if event.is_action_pressed("ToggleMenu"): @@ -33,10 +31,37 @@ func close_menu(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) $MenuContainer.hide() +func open_quick_join_menu(): + $MenuContainer/MainMenu.hide() + $MenuContainer/QuickJoinMenu.show() + + +func close_quick_join_menu(): + $MenuContainer/MainMenu.show() + $MenuContainer/QuickJoinMenu.hide() + +func join_home(): + SERVER_IP = "127.0.0.1" + initialize_client() + +func join_unfa(): + SERVER_IP = "172.28.162.191" + initialize_client() + +func join_jan(): + SERVER_IP = "172.28.166.24" + initialize_client() + func debug_connection_status(): if (get_tree().network_peer.get_connection_status() == NetworkedMultiplayerPeer.CONNECTION_CONNECTING): print("We are trying to connect") +func get_ip(): + return SERVER_IP + +func get_port(): + return SERVER_PORT + func initialize_server(): var peer = NetworkedMultiplayerENet.new() peer.create_server(SERVER_PORT, MAX_PLAYERS) diff --git a/Game.tscn b/Game.tscn index 2e1299d..d8db51c 100644 --- a/Game.tscn +++ b/Game.tscn @@ -5,6 +5,7 @@ [node name="Game" type="Spatial"] script = ExtResource( 2 ) +SERVER_IP = "127.0.0.1" [node name="Level" parent="." instance=ExtResource( 3 )] @@ -17,61 +18,96 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="MenuList" type="VBoxContainer" parent="MenuContainer"] +[node name="MainMenu" type="VBoxContainer" parent="MenuContainer"] margin_left = 362.0 margin_top = 252.0 margin_right = 662.0 margin_bottom = 348.0 rect_min_size = Vector2( 300, 0 ) -[node name="AdressBook" type="MenuButton" parent="MenuContainer/MenuList"] +[node name="QuickJoin" type="Button" parent="MenuContainer/MainMenu"] margin_right = 300.0 margin_bottom = 20.0 -text = "Select destination" -items = [ "Unfa", null, 0, false, false, 0, 0, null, "", false, "Jan", null, 0, false, false, 1, 0, null, "", false ] +text = "Quick Join" -[node name="Destination" type="HBoxContainer" parent="MenuContainer/MenuList"] +[node name="Destination" type="HBoxContainer" parent="MenuContainer/MainMenu"] margin_top = 24.0 margin_right = 300.0 margin_bottom = 48.0 -[node name="IPAdress" type="LineEdit" parent="MenuContainer/MenuList/Destination"] +[node name="IPAdress" type="LineEdit" parent="MenuContainer/MainMenu/Destination"] margin_right = 208.0 margin_bottom = 24.0 size_flags_horizontal = 3 size_flags_stretch_ratio = 2.38 placeholder_text = "IP address" -[node name="Port" type="LineEdit" parent="MenuContainer/MenuList/Destination"] +[node name="Port" type="LineEdit" parent="MenuContainer/MainMenu/Destination"] margin_left = 212.0 margin_right = 300.0 margin_bottom = 24.0 size_flags_horizontal = 3 placeholder_text = "port" -[node name="NetworkType" type="HBoxContainer" parent="MenuContainer/MenuList"] +[node name="NetworkType" type="HBoxContainer" parent="MenuContainer/MainMenu"] margin_top = 52.0 margin_right = 300.0 margin_bottom = 72.0 -[node name="Host" type="Button" parent="MenuContainer/MenuList/NetworkType"] +[node name="Host" type="Button" parent="MenuContainer/MainMenu/NetworkType"] margin_right = 148.0 margin_bottom = 20.0 size_flags_horizontal = 3 text = "Host" -[node name="Join" type="Button" parent="MenuContainer/MenuList/NetworkType"] +[node name="Join" type="Button" parent="MenuContainer/MainMenu/NetworkType"] margin_left = 152.0 margin_right = 300.0 margin_bottom = 20.0 size_flags_horizontal = 3 text = "Join" -[node name="Quit" type="Button" parent="MenuContainer/MenuList"] +[node name="Quit" type="Button" parent="MenuContainer/MainMenu"] margin_top = 76.0 margin_right = 300.0 margin_bottom = 96.0 text = "Quit" -[connection signal="pressed" from="MenuContainer/MenuList/NetworkType/Host" to="." method="initialize_server"] -[connection signal="pressed" from="MenuContainer/MenuList/NetworkType/Join" to="." method="initialize_client"] -[connection signal="pressed" from="MenuContainer/MenuList/Quit" to="." method="quit"] + +[node name="QuickJoinMenu" type="VBoxContainer" parent="MenuContainer"] +visible = false +margin_left = 362.0 +margin_top = 254.0 +margin_right = 662.0 +margin_bottom = 346.0 +rect_min_size = Vector2( 300, 0 ) + +[node name="Back" type="Button" parent="MenuContainer/QuickJoinMenu"] +margin_right = 300.0 +margin_bottom = 20.0 +text = "Back" + +[node name="Home" type="Button" parent="MenuContainer/QuickJoinMenu"] +margin_top = 24.0 +margin_right = 300.0 +margin_bottom = 44.0 +text = "Home" + +[node name="Unfa" type="Button" parent="MenuContainer/QuickJoinMenu"] +margin_top = 48.0 +margin_right = 300.0 +margin_bottom = 68.0 +text = "Unfa" + +[node name="Jan" type="Button" parent="MenuContainer/QuickJoinMenu"] +margin_top = 72.0 +margin_right = 300.0 +margin_bottom = 92.0 +text = "Jan" +[connection signal="pressed" from="MenuContainer/MainMenu/QuickJoin" to="." method="open_quick_join_menu"] +[connection signal="pressed" from="MenuContainer/MainMenu/NetworkType/Host" to="." method="initialize_server"] +[connection signal="pressed" from="MenuContainer/MainMenu/NetworkType/Join" to="." method="initialize_client"] +[connection signal="pressed" from="MenuContainer/MainMenu/Quit" to="." method="quit"] +[connection signal="pressed" from="MenuContainer/QuickJoinMenu/Back" to="." method="close_quick_join_menu"] +[connection signal="pressed" from="MenuContainer/QuickJoinMenu/Home" to="." method="join_home"] +[connection signal="pressed" from="MenuContainer/QuickJoinMenu/Unfa" to="." method="join_unfa"] +[connection signal="pressed" from="MenuContainer/QuickJoinMenu/Jan" to="." method="join_jan"]