mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-14 16:04:50 +00:00
✨ Working profile names in-game, basic settings save/load system, flag drops on player death
This commit is contained in:
parent
94b7ee0a53
commit
3640aeb4cf
12 changed files with 122 additions and 67 deletions
|
|
@ -1,15 +1,15 @@
|
|||
# This file is part of open-fpsz.
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
extends Node2D
|
||||
|
|
@ -28,7 +28,7 @@ func _process(_delta):
|
|||
else:
|
||||
_v_box_container.show()
|
||||
|
||||
_player_name_label.text = player.name
|
||||
_player_name_label.text = player.nickname
|
||||
position = camera.unproject_position(attach_point.global_position)
|
||||
var viewport_size : Vector2 = get_viewport_rect().size
|
||||
position.x = clampf(position.x, 0, viewport_size.x - _v_box_container.size.x)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bjctlqvs33nqy"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bjctlqvs33nqy"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c1tjamjm8qjog" path="res://interfaces/menus/boot/background.webp" id="1_ph586"]
|
||||
|
||||
|
|
@ -10,6 +10,13 @@ signal start_demo
|
|||
|
||||
func _on_demo_pressed():
|
||||
start_demo.emit()
|
||||
|
||||
func _on_multiplayer_pressed():
|
||||
$Main.hide()
|
||||
$Multiplayer.show()
|
||||
|
||||
func _on_quit_pressed():
|
||||
get_tree().quit()
|
||||
"
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_krqeq"]
|
||||
|
|
@ -20,9 +27,11 @@ script/source = "class_name MultiplayerPanel extends PanelContainer
|
|||
|
||||
const DEFAULT_HOST : String = \"localhost\"
|
||||
const DEFAULT_PORT : int = 9000
|
||||
const CONFIG_FILE_PATH : String = \"user://settings.cfg\"
|
||||
|
||||
var _join_address = RegEx.new()
|
||||
var _registered_ports = RegEx.new()
|
||||
var _join_address : RegEx = RegEx.new()
|
||||
var _registered_ports : RegEx = RegEx.new()
|
||||
var _config_file : ConfigFile = ConfigFile.new()
|
||||
|
||||
signal start_server(port)
|
||||
signal join_server(host, port)
|
||||
|
|
@ -34,8 +43,21 @@ func _ready():
|
|||
# see https://datatracker.ietf.org/doc/html/rfc1700
|
||||
_registered_ports.compile(r'^(?:102[4-9]|10[3-9]\\d|1[1-9]\\d{2}|[2-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$')
|
||||
_join_address.compile(r'^(?<host>[a-zA-Z0-9.-]+)(:(?<port>:102[4-9]|10[3-9]\\d|1[1-9]\\d{2}|[2-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5]))?$')
|
||||
_load_config()
|
||||
hide() # start hidden
|
||||
|
||||
func _load_config():
|
||||
var error : Error = _config_file.load(CONFIG_FILE_PATH)
|
||||
if error != OK:
|
||||
return
|
||||
|
||||
var profile_name : String = _config_file.get_value(\"profile\", \"name\", \"Newblood\")
|
||||
%ProfileName.text = profile_name
|
||||
|
||||
func _on_save_pressed():
|
||||
_config_file.set_value(\"profile\", \"name\", %ProfileName.text)
|
||||
_config_file.save(CONFIG_FILE_PATH)
|
||||
|
||||
func _on_menu_pressed():
|
||||
hide()
|
||||
owner.get_node(\"Main\").show()
|
||||
|
|
@ -53,8 +75,8 @@ func _on_host_pressed():
|
|||
else: # port is not valid
|
||||
push_warning(\"A valid port number in the range 1024-65535 is required.\")
|
||||
return
|
||||
|
||||
start_server.emit(port)
|
||||
|
||||
start_server.emit(port, %ProfileName.text)
|
||||
|
||||
func _on_join_pressed():
|
||||
var addr = [DEFAULT_HOST, DEFAULT_PORT]
|
||||
|
|
@ -66,7 +88,7 @@ func _on_join_pressed():
|
|||
if rport: addr[1] = int(rport)
|
||||
|
||||
$Modal.show()
|
||||
join_server.emit(addr[0], addr[1])
|
||||
join_server.emit(addr[0], addr[1], %ProfileName.text)
|
||||
|
||||
func _on_connected_to_server():
|
||||
$Modal.hide()
|
||||
|
|
@ -79,17 +101,6 @@ func _on_connection_failed():
|
|||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_snh7i"]
|
||||
bg_color = Color(0, 0.5, 0.5, 0.25)
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_yqbr7"]
|
||||
script/source = "extends PanelContainer
|
||||
|
||||
func _on_multiplayer_pressed():
|
||||
hide()
|
||||
owner.get_node(\"Multiplayer\").show()
|
||||
|
||||
func _on_quit_pressed():
|
||||
get_tree().quit()
|
||||
"
|
||||
|
||||
[node name="BootMenu" type="CanvasLayer"]
|
||||
script = SubResource("GDScript_jd8xf")
|
||||
|
||||
|
|
@ -156,6 +167,10 @@ layout_mode = 2
|
|||
disabled = true
|
||||
text = "Delete"
|
||||
|
||||
[node name="Save" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Save"
|
||||
|
||||
[node name="Spacer" type="MarginContainer" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -313,7 +328,6 @@ offset_right = 313.0
|
|||
grow_vertical = 2
|
||||
size_flags_horizontal = 0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_snh7i")
|
||||
script = SubResource("GDScript_yqbr7")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Main"]
|
||||
layout_mode = 2
|
||||
|
|
@ -342,6 +356,7 @@ text = "Quit"
|
|||
|
||||
[connection signal="join_server" from="Multiplayer" to="." method="_on_multiplayer_join_server"]
|
||||
[connection signal="start_server" from="Multiplayer" to="." method="_on_multiplayer_start_server"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox/Save" to="Multiplayer" method="_on_save_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox/Menu" to="Multiplayer" method="_on_menu_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox/Quit" to="Multiplayer" method="_on_quit_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox/Join" to="Multiplayer" method="_on_join_pressed"]
|
||||
|
|
@ -352,5 +367,5 @@ text = "Quit"
|
|||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox/Quit" to="Multiplayer" method="_on_quit_pressed"]
|
||||
[connection signal="text_changed" from="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/RightBox/ServerPort" to="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/RightBox/ServerPort" method="_on_text_changed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Demo" to="." method="_on_demo_pressed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Multiplayer" to="Main" method="_on_multiplayer_pressed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Quit" to="Main" method="_on_quit_pressed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Multiplayer" to="." method="_on_multiplayer_pressed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue