0.1.0
Added a basic test map, options menu, bug fixes, and much more.
This commit is contained in:
parent
d72b5ac57b
commit
2dce012535
34 changed files with 1268 additions and 84 deletions
|
@ -1,5 +0,0 @@
|
|||
class_name HostGame
|
||||
extends JoinGame
|
||||
|
||||
func _on_start_game_button_pressed() -> void:
|
||||
Multiplayer.switch_scene.rpc("res://maps/test_map.tscn")
|
|
@ -1,5 +1,10 @@
|
|||
class_name JoinGame
|
||||
extends Control
|
||||
|
||||
func _ready() -> void:
|
||||
Multiplayer.playerlist_label = $PlayerList
|
||||
@onready var options_list: VBoxContainer = $OptionsList
|
||||
@onready var username_input: LineEdit = $OptionsList/UsernameOption/OptionInput
|
||||
@onready var ip_address_input: LineEdit = $OptionsList/IpAddressOption/OptionInput
|
||||
|
||||
func _on_join_button_pressed() -> void:
|
||||
options_list.visible = false
|
||||
Multiplayer.join_server(username_input.text, ip_address_input.text)
|
||||
|
|
|
@ -12,8 +12,56 @@ grow_vertical = 2
|
|||
script = ExtResource("1_ju2tq")
|
||||
|
||||
[node name="PlayerList" type="Label" parent="."]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 9
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 1.0
|
||||
grow_vertical = 2
|
||||
text = "Connecting to the server..."
|
||||
|
||||
[node name="OptionsList" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="UsernameOption" type="HBoxContainer" parent="OptionsList"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
|
||||
[node name="OptionName" type="Label" parent="OptionsList/UsernameOption"]
|
||||
layout_mode = 2
|
||||
text = "Username:"
|
||||
|
||||
[node name="OptionInput" type="LineEdit" parent="OptionsList/UsernameOption"]
|
||||
custom_minimum_size = Vector2(175, 0)
|
||||
layout_mode = 2
|
||||
max_length = 20
|
||||
|
||||
[node name="IpAddressOption" type="HBoxContainer" parent="OptionsList"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
|
||||
[node name="OptionName" type="Label" parent="OptionsList/IpAddressOption"]
|
||||
layout_mode = 2
|
||||
text = "IP Address:"
|
||||
|
||||
[node name="OptionInput" type="LineEdit" parent="OptionsList/IpAddressOption"]
|
||||
custom_minimum_size = Vector2(175, 0)
|
||||
layout_mode = 2
|
||||
max_length = 20
|
||||
|
||||
[node name="JoinButton" type="Button" parent="OptionsList"]
|
||||
layout_mode = 2
|
||||
text = "Join Server"
|
||||
|
||||
[connection signal="pressed" from="OptionsList/JoinButton" to="." method="_on_join_button_pressed"]
|
||||
|
|
15
ui/lobby.gd
Normal file
15
ui/lobby.gd
Normal file
|
@ -0,0 +1,15 @@
|
|||
class_name HostGame
|
||||
extends JoinGame
|
||||
|
||||
@onready var start_button: Button = $StartGameButton
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Multiplayer.playerlist_label = $PlayerList
|
||||
if multiplayer.is_server():
|
||||
start_button.disabled = false
|
||||
start_button.visible = true
|
||||
Multiplayer.request_playerlist.rpc_id(1)
|
||||
|
||||
func _on_start_game_button_pressed() -> void:
|
||||
Multiplayer.switch_scene.rpc("res://maps/test_map.tscn")
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://corjvfihg047u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cuumy3t2hkgcu" path="res://ui/host_game.gd" id="1_fg6en"]
|
||||
[ext_resource type="Script" uid="uid://cuumy3t2hkgcu" path="res://ui/lobby.gd" id="1_nmq56"]
|
||||
|
||||
[node name="HostGame" type="Control"]
|
||||
layout_mode = 3
|
||||
|
@ -9,9 +9,10 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_fg6en")
|
||||
script = ExtResource("1_nmq56")
|
||||
|
||||
[node name="StartGameButton" type="Button" parent="."]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
|
@ -24,6 +25,7 @@ offset_right = 48.0
|
|||
offset_bottom = 15.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
disabled = true
|
||||
text = "Start Game"
|
||||
|
||||
[node name="PlayerList" type="Label" parent="."]
|
||||
|
@ -32,6 +34,5 @@ anchors_preset = 9
|
|||
anchor_bottom = 1.0
|
||||
offset_right = 1.0
|
||||
grow_vertical = 2
|
||||
text = "1"
|
||||
|
||||
[connection signal="pressed" from="StartGameButton" to="." method="_on_start_game_button_pressed"]
|
|
@ -3,10 +3,12 @@ extends Control
|
|||
|
||||
func _on_host_game_button_pressed() -> void:
|
||||
Multiplayer.host_server()
|
||||
if get_tree().change_scene_to_file("res://ui/host_game.tscn") != OK:
|
||||
print("Failed to change to scene.")
|
||||
|
||||
func _on_join_game_button_pressed() -> void:
|
||||
Multiplayer.join_server()
|
||||
if get_tree().change_scene_to_file("res://ui/join_game.tscn") != OK:
|
||||
print("Failed to change to scene.")
|
||||
|
||||
|
||||
func _on_options_button_pressed() -> void:
|
||||
if get_tree().change_scene_to_file("res://ui/options_menu.tscn") != OK:
|
||||
print("Failed to change to scene.")
|
||||
|
|
|
@ -38,5 +38,23 @@ text = "Host Game"
|
|||
layout_mode = 2
|
||||
text = "Join Game"
|
||||
|
||||
[node name="OptionsButton" type="Button" parent="MainContainer"]
|
||||
layout_mode = 2
|
||||
text = "Options"
|
||||
|
||||
[node name="Version" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -40.0
|
||||
offset_top = -23.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
text = "0.1.0"
|
||||
|
||||
[connection signal="pressed" from="MainContainer/HostGameButton" to="." method="_on_host_game_button_pressed"]
|
||||
[connection signal="pressed" from="MainContainer/JoinGameButton" to="." method="_on_join_game_button_pressed"]
|
||||
[connection signal="pressed" from="MainContainer/OptionsButton" to="." method="_on_options_button_pressed"]
|
||||
|
|
27
ui/options_menu.gd
Normal file
27
ui/options_menu.gd
Normal file
|
@ -0,0 +1,27 @@
|
|||
class_name OptionsMenu
|
||||
extends Control
|
||||
|
||||
@onready var username_input: LineEdit = $OptionsList/UsernameOption/OptionInput
|
||||
@onready var ip_address_input: LineEdit = $OptionsList/IpAddressOption/OptionInput
|
||||
@onready var data_collection_input: CheckBox = $OptionsList/DataCollectionOption/OptionInput
|
||||
|
||||
func _ready() -> void:
|
||||
username_input.text = Options.username
|
||||
ip_address_input.text = Options.ip_address
|
||||
data_collection_input.button_pressed = Options.data_collection
|
||||
|
||||
func _username_changed(text: String) -> void:
|
||||
Options.username = text
|
||||
Options.save_options()
|
||||
|
||||
func _ip_address_changed(text: String) -> void:
|
||||
Options.ip_address = text
|
||||
Options.save_options()
|
||||
|
||||
func _data_collection_changed(new_option: bool) -> void:
|
||||
Options.data_collection = new_option
|
||||
Options.save_options()
|
||||
|
||||
func _main_menu() -> void:
|
||||
if get_tree().change_scene_to_file("res://ui/main_menu.tscn") != OK:
|
||||
print("Failed to change to scene.")
|
1
ui/options_menu.gd.uid
Normal file
1
ui/options_menu.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://fpohmcdqnk35
|
78
ui/options_menu.tscn
Normal file
78
ui/options_menu.tscn
Normal file
|
@ -0,0 +1,78 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bxeejl1m7w5mn"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://fpohmcdqnk35" path="res://ui/options_menu.gd" id="1_ibk6l"]
|
||||
|
||||
[node name="OptionsMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_ibk6l")
|
||||
|
||||
[node name="OptionsList" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 13
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -78.5
|
||||
offset_right = 78.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="UsernameOption" type="HBoxContainer" parent="OptionsList"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
|
||||
[node name="OptionName" type="Label" parent="OptionsList/UsernameOption"]
|
||||
layout_mode = 2
|
||||
text = "Username:"
|
||||
|
||||
[node name="OptionInput" type="LineEdit" parent="OptionsList/UsernameOption"]
|
||||
custom_minimum_size = Vector2(175, 0)
|
||||
layout_mode = 2
|
||||
max_length = 20
|
||||
|
||||
[node name="IpAddressOption" type="HBoxContainer" parent="OptionsList"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
|
||||
[node name="OptionName" type="Label" parent="OptionsList/IpAddressOption"]
|
||||
layout_mode = 2
|
||||
text = "IP Address:"
|
||||
|
||||
[node name="OptionInput" type="LineEdit" parent="OptionsList/IpAddressOption"]
|
||||
custom_minimum_size = Vector2(175, 0)
|
||||
layout_mode = 2
|
||||
max_length = 20
|
||||
|
||||
[node name="DataCollectionOption" type="HBoxContainer" parent="OptionsList"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
|
||||
[node name="OptionName" type="Label" parent="OptionsList/DataCollectionOption"]
|
||||
layout_mode = 2
|
||||
text = "Server data collection allowed:"
|
||||
|
||||
[node name="OptionInput" type="CheckBox" parent="OptionsList/DataCollectionOption"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -157.0
|
||||
offset_top = -31.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
text = "Back to Main Menu"
|
||||
|
||||
[connection signal="text_changed" from="OptionsList/UsernameOption/OptionInput" to="." method="_username_changed"]
|
||||
[connection signal="text_changed" from="OptionsList/IpAddressOption/OptionInput" to="." method="_ip_address_changed"]
|
||||
[connection signal="toggled" from="OptionsList/DataCollectionOption/OptionInput" to="." method="_data_collection_changed"]
|
||||
[connection signal="pressed" from="Button" to="." method="_main_menu"]
|
Loading…
Add table
Add a link
Reference in a new issue