diff --git a/scenes/menu.gd b/scenes/menu.gd index 396f568..26debe8 100644 --- a/scenes/menu.gd +++ b/scenes/menu.gd @@ -25,19 +25,22 @@ func _on_singleplayer_button_up(): func _on_JoinGameBtn_button_up(): ip = $JoinPanel/join_ip port = $JoinPanel/join_port - print("Attempting to join game at IP ",ip," via port ",port) + print("Netplay - Attempting to join game at IP ",ip," via port ",port) join_game() func _on_HostGameBtn_button_up(): - #var host_port = $HostPanel/host_port.text - print("Attempting to host game on port ",host_port,"...") + var host_port = $HostPanel/host_port.value + print("Netplay - Attempting to host game on port ",host_port,"...") host_game(host_port) - + func host_game(port): + var maxplayers = $HostPanel/playercount.value var host = NetworkedMultiplayerENet.new() - host.create_server(port) + print("Netplay - Returned: ",host) + host.create_server(port, maxplayers) # ports, maxplayers get_tree().set_network_peer(host) - print("Hosting on port ",port) + print("Netplay - Hosting on port ",port,". Max players: ",maxplayers) + print("Netplay - Are you the server ... ",get_tree().is_network_server()) $HostPanel/HostGameBtn.disabled = 1 $HostPanel/HostGameBtn.hint_tooltip = "Cannot start another server, Server already started." $JoinPanel/JoinGameBtn.disabled = 1 diff --git a/scenes/menu.tscn b/scenes/menu.tscn index 91c647b..652301c 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -11,12 +11,12 @@ [ext_resource path="res://Sprites/polo_sprites/poloright_0.png" type="Texture" id=9] [ext_resource path="res://misc/fonts/upheavtt.tres" type="DynamicFontData" id=10] -[sub_resource type="DynamicFont" id=2] +[sub_resource type="DynamicFont" id=1] outline_size = 1 outline_color = Color( 1, 0.0117647, 0.0117647, 1 ) font_data = ExtResource( 10 ) -[sub_resource type="Theme" id=1] +[sub_resource type="Theme" id=2] default_font = ExtResource( 3 ) [node name="Menu" type="Control"] @@ -41,22 +41,26 @@ __meta__ = { [node name="stars" type="Sprite" parent="."] show_behind_parent = true -position = Vector2( 344, 368 ) +position = Vector2( 1101, 368 ) scale = Vector2( 1.5, 1.5 ) texture = ExtResource( 8 ) region_enabled = true -region_rect = Rect2( 0, 0, 500, 500 ) +region_rect = Rect2( 0, 0, 1500, 500 ) __meta__ = { +"_edit_lock_": true, "_editor_description_": "50" } [node name="mountains" type="Sprite" parent="."] show_behind_parent = true -position = Vector2( 344, 520 ) +position = Vector2( 1101, 520 ) scale = Vector2( 1.5, 1.5 ) texture = ExtResource( 6 ) region_enabled = true -region_rect = Rect2( 0, 0, 500, 500 ) +region_rect = Rect2( 0, 0, 1500, 500 ) +__meta__ = { +"_edit_lock_": true +} [node name="music" type="AudioStreamPlayer" parent="."] stream = ExtResource( 5 ) @@ -108,7 +112,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 margin_top = -43.0 margin_bottom = -10.0 -custom_fonts/font = SubResource( 2 ) +custom_fonts/font = SubResource( 1 ) text = "There isnt much gameplay to this. Its primary objective is learning netplay via godot" align = 1 @@ -227,33 +231,13 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="host_port" type="LineEdit" parent="HostPanel"] -margin_left = 88.0 -margin_top = 48.0 -margin_right = 182.0 -margin_bottom = 72.0 -custom_fonts/font = ExtResource( 3 ) -text = "2670" -max_length = 5 -editable = false -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="ToolButton" type="ToolButton" parent="HostPanel/host_port"] -margin_left = 96.0 -margin_right = 143.0 -margin_bottom = 25.0 -custom_fonts/font = ExtResource( 2 ) -disabled = true -text = "Reset" - [node name="playercount" type="SpinBox" parent="HostPanel"] margin_left = 88.0 margin_top = 80.0 margin_right = 198.0 margin_bottom = 104.0 -theme = SubResource( 1 ) +rect_pivot_offset = Vector2( 48, 12 ) +theme = SubResource( 2 ) min_value = 2.0 max_value = 4.0 value = 2.0 @@ -263,6 +247,21 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="host_port" type="SpinBox" parent="HostPanel"] +margin_left = 88.0 +margin_top = 48.0 +margin_right = 198.0 +margin_bottom = 72.0 +rect_pivot_offset = Vector2( 48, 12 ) +theme = SubResource( 2 ) +min_value = 2000.0 +max_value = 90000.0 +value = 2000.0 +rounded = true +__meta__ = { +"_edit_use_anchors_": false +} + [node name="CheckBox" type="CheckBox" parent="HostPanel"] margin_left = 88.0 margin_top = 104.0 @@ -359,15 +358,17 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="join_port" type="LineEdit" parent="JoinPanel"] +[node name="join_port" type="SpinBox" parent="JoinPanel"] margin_left = 80.0 margin_top = 80.0 -margin_right = 208.0 +margin_right = 190.0 margin_bottom = 104.0 -custom_fonts/font = ExtResource( 3 ) -text = "2500" -max_length = 5 -editable = false +rect_pivot_offset = Vector2( 48, 12 ) +theme = SubResource( 2 ) +min_value = 2000.0 +max_value = 90000.0 +value = 2000.0 +rounded = true __meta__ = { "_edit_use_anchors_": false }