Merge branch 'main' of ssh://git.gieszer.link:2222/unfa/liblast

remotes/1705725415861086127/tmp_refs/heads/main
unfa 2021-09-25 00:18:17 +02:00
commit c8bc8952fa
18 changed files with 232 additions and 15 deletions

View File

@ -0,0 +1,4 @@
extends "res://Assets/UI/Menu.gd"
func connect_to_server():
Main.connect_to_server($MenuLineEdit.data)

View File

@ -0,0 +1,33 @@
[gd_scene load_steps=5 format=3 uid="uid://dl04vkws76mj5"]
[ext_resource type="PackedScene" uid="uid://81ymy0o073e5" path="res://Assets/UI/Menu.tscn" id="1_cf8yy"]
[ext_resource type="PackedScene" uid="uid://xptjyy2hwb77" path="res://Assets/UI/MenuLineEdit.tscn" id="2_isg6p"]
[ext_resource type="PackedScene" uid="uid://d135tevauvmoq" path="res://Assets/UI/MenuButton.tscn" id="2_n4o24"]
[ext_resource type="Script" path="res://Assets/UI/ConnectMenu.gd" id="2_wk4wj"]
[node name="ConnectMenu" instance=ExtResource( "1_cf8yy" )]
script = ExtResource( "2_wk4wj" )
[node name="MenuLineEdit" parent="." index="0" instance=ExtResource( "2_isg6p" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_right = 155.0
offset_bottom = 33.0
label = "ip"
index = "ip"
[node name="Connect" parent="." index="1" instance=ExtResource( "2_n4o24" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_top = 37.0
offset_right = 155.0
offset_bottom = 66.0
text = "connect"
label = "connect"
[node name="Back" parent="." index="2"]
offset_top = 70.0
offset_right = 155.0
offset_bottom = 99.0
[connection signal="pressed" from="Connect" to="." method="connect_to_server"]

View File

@ -1,10 +1,10 @@
[gd_scene load_steps=6 format=3 uid="uid://b856vwmg8a6o4"]
[ext_resource type="PackedScene" uid="uid://d135tevauvmoq" path="res://Assets/UI/MenuButton.tscn" id="1"]
[ext_resource type="PackedScene" uid="uid://d2d0sbb84rehm" path="res://Assets/UI/Menu.tscn" id="2"]
[ext_resource type="PackedScene" uid="uid://81ymy0o073e5" path="res://Assets/UI/Menu.tscn" id="2"]
[ext_resource type="Texture2D" uid="uid://njj8psk8fh7" path="res://Assets/UI/Logo.png" id="2_oueme"]
[ext_resource type="Script" path="res://Assets/UI/GUI.gd" id="3"]
[ext_resource type="AudioStream" uid="uid://dfxftf2huumhn" path="res://Assets/SFX/UI_Cancel.wav" id="4_lnh50"]
[ext_resource type="AudioStream" uid="uid://dpjwcruomxgkk" path="res://Assets/SFX/UI_Cancel.wav" id="4_lnh50"]
[node name="GUI" type="CenterContainer"]
anchor_right = 1.0
@ -30,32 +30,43 @@ __meta__ = {
[node name="Menu" parent="." instance=ExtResource( "2" )]
offset_left = 412.0
offset_top = 252.0
offset_top = 236.0
offset_right = 612.0
offset_bottom = 347.0
offset_bottom = 364.0
rect_min_size = Vector2(200, 0)
[node name="Options" parent="Menu" instance=ExtResource( "1" )]
[node name="Play" parent="Menu" instance=ExtResource( "1" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_top = 33.0
offset_right = 200.0
offset_bottom = 62.0
text = "play
"
label = "play"
[node name="Options" parent="Menu" instance=ExtResource( "1" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_top = 66.0
offset_right = 200.0
offset_bottom = 95.0
text = "options"
label = "options"
[node name="Quit" parent="Menu" instance=ExtResource( "1" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_top = 66.0
offset_top = 99.0
offset_right = 200.0
offset_bottom = 95.0
offset_bottom = 128.0
text = "quit"
label = "quit"
[node name="ClickSound" parent="Menu/Quit" index="0"]
stream = ExtResource( "4_lnh50" )
[connection signal="pressed" from="Menu/Play" to="Menu" method="open_menu" binds= ["res://Assets/UI/PlayMenu.tscn"]]
[connection signal="pressed" from="Menu/Options" to="Menu" method="open_menu" binds= ["res://Assets/UI/OptionsMenu.tscn"]]
[connection signal="pressed" from="Menu/Quit" to="." method="quit_game"]

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://cd6qhohan2oa1"]
[ext_resource type="PackedScene" uid="uid://d2d0sbb84rehm" path="res://Assets/UI/Menu.tscn" id="1"]
[ext_resource type="PackedScene" uid="uid://81ymy0o073e5" path="res://Assets/UI/Menu.tscn" id="1"]
[ext_resource type="Script" path="res://Assets/UI/GraphicsMenu.gd" id="2"]
[ext_resource type="PackedScene" uid="uid://bl1fc5cl4fcav" path="res://Assets/UI/MenuCheckButton.tscn" id="3"]

View File

@ -3,6 +3,7 @@ extends VBoxContainer
var previous_menu : Node = null
var settings = {}
@onready var GUI = get_parent()
@onready var Main = get_parent().get_parent()
# Called when the node enters the scene tree for the first time.
func _ready():

View File

@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://d2d0sbb84rehm"]
[gd_scene load_steps=4 format=3 uid="uid://81ymy0o073e5"]
[ext_resource type="Script" path="res://Assets/UI/Menu.gd" id="1"]
[ext_resource type="AudioStream" uid="uid://tmb3cqyy8s33" path="res://Assets/SFX/UI_Click.wav" id="2_nkrit"]
[ext_resource type="AudioStream" uid="uid://dvfvty8gqab0a" path="res://Assets/SFX/UI_Hover.wav" id="3_qqhse"]
[ext_resource type="AudioStream" uid="uid://da7hq3d1msmud" path="res://Assets/SFX/UI_Click.wav" id="2_nkrit"]
[ext_resource type="AudioStream" uid="uid://dc4rractm5dhf" path="res://Assets/SFX/UI_Hover.wav" id="3_qqhse"]
[node name="Menu" type="VBoxContainer"]
offset_left = 475.0

View File

@ -0,0 +1,7 @@
extends "res://Assets/UI/MenuData.gd"
func set_data(_data):
super.set_data(_data)
self.color = _data
print(_data)

View File

@ -0,0 +1,17 @@
[gd_scene load_steps=2 format=3 uid="uid://xuvp717ccvi5"]
[ext_resource type="Script" path="res://Assets/UI/MenuColor.gd" id="1_unj4b"]
[node name="MenuColor" type="ColorPickerButton"]
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 4.0
offset_top = 4.0
offset_right = 4.0
offset_bottom = 4.0
script = ExtResource( "1_unj4b" )
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="color_changed" from="." to="." method="set_data"]

View File

@ -10,6 +10,9 @@ func _ready():
set_data(GUI.settings[index])
func set_data(_data):
if GUI == null:
GUI = get_parent().get_parent()
data = _data
var data = null:

View File

@ -1,3 +1,4 @@
@tool
extends Control
@export var label = "":
@ -8,8 +9,8 @@ extends Control
return label
func on_label_changed():
pass
self.text=label
# Called when the node enters the scene tree for the first time.
func _ready():
pass
on_label_changed()

View File

@ -0,0 +1,9 @@
extends "res://Assets/UI/MenuData.gd"
func set_data(_data):
super.set_data(_data)
if not $LineEdit.has_focus():
$LineEdit.text = _data
func on_label_changed():
$Label.text = label

View File

@ -0,0 +1,30 @@
[gd_scene load_steps=2 format=3 uid="uid://xptjyy2hwb77"]
[ext_resource type="Script" path="res://Assets/UI/MenuLineEdit.gd" id="1_lc6vq"]
[node name="MenuLineEdit" type="HBoxContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( "1_lc6vq" )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="."]
offset_top = 288.0
offset_right = 1.0
offset_bottom = 311.0
structured_text_bidi_override_options = []
script = null
[node name="LineEdit" type="LineEdit" parent="."]
offset_left = 5.0
offset_right = 155.0
offset_bottom = 600.0
rect_min_size = Vector2(150, 0)
structured_text_bidi_override_options = []
caret_blink = true
caret_blink_speed = 0.5
script = null
[connection signal="text_changed" from="LineEdit" to="." method="set_data"]

View File

@ -0,0 +1,4 @@
extends "res://Assets/UI/Menu.gd"
func host_button_pressed():
Main.host_server()

View File

@ -0,0 +1,42 @@
[gd_scene load_steps=4 format=3 uid="uid://cc62u7shucxqi"]
[ext_resource type="PackedScene" uid="uid://81ymy0o073e5" path="res://Assets/UI/Menu.tscn" id="1_21oe2"]
[ext_resource type="PackedScene" uid="uid://d135tevauvmoq" path="res://Assets/UI/MenuButton.tscn" id="2_oo0fl"]
[ext_resource type="Script" path="res://Assets/UI/PlayMenu.gd" id="2_pgqlf"]
[node name="PlayMenu" instance=ExtResource( "1_21oe2" )]
script = ExtResource( "2_pgqlf" )
[node name="HostButton" parent="." index="0" instance=ExtResource( "2_oo0fl" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_right = 73.0
offset_bottom = 29.0
text = "host"
label = "host"
[node name="ConnectButton" parent="." index="1" instance=ExtResource( "2_oo0fl" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_top = 33.0
offset_right = 73.0
offset_bottom = 62.0
text = "connect"
label = "connect"
[node name="ProfileButton" parent="." index="2" instance=ExtResource( "2_oo0fl" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_top = 66.0
offset_right = 73.0
offset_bottom = 95.0
text = "profile"
label = "profile"
[node name="Back" parent="." index="3"]
offset_top = 99.0
offset_bottom = 128.0
[connection signal="pressed" from="HostButton" to="." method="host_button_pressed"]
[connection signal="pressed" from="ConnectButton" to="." method="open_menu" binds= ["res://Assets/UI/ConnectMenu.tscn"]]
[connection signal="pressed" from="ProfileButton" to="." method="open_menu" binds= ["res://Assets/UI/ProfileMenu.tscn"]]

View File

@ -0,0 +1,5 @@
extends "res://Assets/UI/Menu.gd"
func change_player_color(data):
if Main:
Main.change_player_color(data)

View File

@ -0,0 +1,34 @@
[gd_scene load_steps=5 format=3 uid="uid://cmbflogxdn20n"]
[ext_resource type="PackedScene" uid="uid://81ymy0o073e5" path="res://Assets/UI/Menu.tscn" id="1_faaua"]
[ext_resource type="Script" path="res://Assets/UI/ProfileMenu.gd" id="2_5v3ua"]
[ext_resource type="PackedScene" uid="uid://xptjyy2hwb77" path="res://Assets/UI/MenuLineEdit.tscn" id="2_ghv7j"]
[ext_resource type="PackedScene" uid="uid://xuvp717ccvi5" path="res://Assets/UI/MenuColor.tscn" id="4_1dm5b"]
[node name="ProfileMenu" instance=ExtResource( "1_faaua" )]
script = ExtResource( "2_5v3ua" )
[node name="UsernameLineEdit" parent="." index="0" instance=ExtResource( "2_ghv7j" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_right = 155.0
offset_bottom = 33.0
label = "username"
index = "username"
[node name="PlayerColor" parent="." index="1" instance=ExtResource( "4_1dm5b" )]
anchor_right = 0.0
anchor_bottom = 0.0
offset_left = 0.0
offset_top = 37.0
offset_right = 155.0
offset_bottom = 66.0
label = "player color"
index = "player color"
[node name="Back" parent="." index="2"]
offset_top = 70.0
offset_right = 155.0
offset_bottom = 99.0
[connection signal="data_changed" from="PlayerColor" to="." method="change_player_color"]

View File

@ -305,11 +305,13 @@ func create_player(pid: int, is_local:= false, respawn:= false) -> void:
if not respawn: # first spawn
new_info = PlayerInfo.new() # generate name, color etc
new_info.name = $GUI.settings["username"]
new_info.color = $GUI.settings["player color"]
else: # respawn
new_info = player_list.players[pid] # reuse previous name, color etc
new_info.health = 100 # give the respawned player full health
focus = GameFocus.GAME # make sure the player has no menu displayed when they respawn
player_list.set(pid, new_info)
# superfluous and harmful code that messes up player data:
@ -337,6 +339,16 @@ func start_dedicated_server(): # start server without creating a local player
get_tree().multiplayer_peer = peer
#create_player(1, true)
func host_server():
_on_Host_pressed()
func connect_to_server(ip):
$NetworkTesting/Host.disabled = true
$NetworkTesting/Connect.disabled = true
peer.create_client(ip, NET_PORT)
get_tree().multiplayer.multiplayer_peer = peer
func _on_Host_pressed(): # start server and create a local player
role = MultiplayerRole.SERVER
$NetworkTesting/Host.disabled = true
@ -354,7 +366,7 @@ func _on_Connect_pressed():
peer.create_client(NET_SERVER, NET_PORT)
get_tree().multiplayer.multiplayer_peer = peer
func _player_connected(pid) -> void:
print("player connected, id: ", pid)
create_player(pid, false)
@ -413,6 +425,9 @@ func _on_TextEdit_text_submitted(new_text):
push_local_player_info()
#chat_announcement("Player " + old_name + " is now known as " + new_name)
func change_player_color(color):
_on_ColorPickerButton_color_changed(color)
func _on_ColorPickerButton_color_changed(color):
player_list.players[get_tree().multiplayer.get_unique_id()].color = color
push_local_player_info()

View File

@ -53,6 +53,7 @@ __meta__ = {
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1)
[node name="NetworkTesting" type="VBoxContainer" parent="."]
visible = false
anchor_left = 1.0
anchor_right = 1.0
offset_left = -188.0