mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-12 15:04:46 +00:00
✨ Implement a Settings menu
This commit is contained in:
parent
c3582b04e6
commit
2c2c3ec719
8 changed files with 283 additions and 92 deletions
|
|
@ -40,7 +40,7 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
@export var nickname : String
|
||||
|
||||
@onready var input : PlayerInput = $PlayerInput
|
||||
@onready var camera = $SpringArm3D/Camera3D
|
||||
@onready var camera : Camera3D = $SpringArm3D/Camera3D
|
||||
@onready var hud = $HUD
|
||||
@onready var iff = $ThirdPerson/IFF
|
||||
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
|
||||
|
|
@ -51,6 +51,7 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
@onready var spring_arm_height = $SpringArm3D.position.y
|
||||
@onready var _original_weapon_transform : Transform3D = weapon.transform
|
||||
@onready var flag_carry_attachment = $SpringArm3D/FlagCarryAttachment
|
||||
@onready var _game_settings : GameSettings = get_node("/root/GlobalSettings")
|
||||
|
||||
signal died(player)
|
||||
signal energy_changed(energy)
|
||||
|
|
@ -64,6 +65,7 @@ func _ready():
|
|||
if _is_first_person():
|
||||
health_component.health_changed.connect(hud._on_health_changed)
|
||||
camera.current = true
|
||||
camera.fov = _game_settings.fov
|
||||
remove_child($ThirdPerson)
|
||||
else:
|
||||
health_component.health_changed.connect(iff._on_health_changed)
|
||||
|
|
@ -71,6 +73,8 @@ func _ready():
|
|||
weapon.hide()
|
||||
health_component.health_changed.emit(health_component.health)
|
||||
health_component.health_zeroed.connect(die)
|
||||
input.MOUSE_SENSITIVITY = _game_settings.mouse_sensitivity
|
||||
input.inverted_y_axis = _game_settings.inverted_y_axis
|
||||
input.fired_primary.connect(_fire_primary)
|
||||
input.jumped.connect(_jump)
|
||||
input.throwed_flag.connect(_throw_flag)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class_name PlayerInput extends MultiplayerSynchronizer
|
|||
@export var direction = Vector2.ZERO
|
||||
@export var camera_rotation : Vector2
|
||||
@export var MOUSE_SENSITIVITY : float = .6
|
||||
@export var inverted_y_axis : bool = false
|
||||
|
||||
signal jumped
|
||||
signal fired_primary
|
||||
|
|
@ -38,12 +39,14 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
# retrieve mouse position relative to last frame
|
||||
_update_camera(event.relative)
|
||||
|
||||
func _update_camera(relative_motion : Vector2, sensitivity : float = MOUSE_SENSITIVITY) -> void:
|
||||
func _update_camera(relative_motion : Vector2) -> void:
|
||||
# clamp vertical rotation (head motion)
|
||||
camera_rotation.y -= relative_motion.y * sensitivity / 100
|
||||
if inverted_y_axis:
|
||||
relative_motion.y *= -1.0
|
||||
camera_rotation.y -= relative_motion.y * MOUSE_SENSITIVITY / 100
|
||||
camera_rotation.y = clamp(camera_rotation.y, deg_to_rad(-90.0),deg_to_rad(90.0))
|
||||
# wrap horizontal rotation (to prevent accumulation)
|
||||
camera_rotation.x -= relative_motion.x * sensitivity / 100
|
||||
camera_rotation.x -= relative_motion.x * MOUSE_SENSITIVITY / 100
|
||||
camera_rotation.x = wrapf(camera_rotation.x, deg_to_rad(0.0),deg_to_rad(360.0))
|
||||
|
||||
func _process(delta):
|
||||
|
|
@ -68,4 +71,3 @@ func _fire_primary():
|
|||
@rpc("call_local")
|
||||
func _throw_flag():
|
||||
throwed_flag.emit()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_resource type="Environment" load_steps=4 format=3 uid="uid://d2ahijqqspw5f"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://odwhjbebqfcn" path="res://environments/skyboxes/kloppenheim_06_puresky_2k.exr" id="1_k44rf"]
|
||||
[ext_resource type="Texture2D" uid="uid://btdbu0qbe1646" path="res://environments/skyboxes/kloppenheim_06_puresky_2k.exr" id="1_k44rf"]
|
||||
|
||||
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_7tawh"]
|
||||
panorama = ExtResource("1_k44rf")
|
||||
|
|
|
|||
36
game_settings.gd
Normal file
36
game_settings.gd
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
class_name GameSettings extends Node
|
||||
|
||||
var _config_file : ConfigFile = ConfigFile.new()
|
||||
|
||||
var fov : int
|
||||
var mouse_sensitivity : float
|
||||
var inverted_y_axis : bool
|
||||
var fullscreen : bool
|
||||
|
||||
const SETTINGS_FILE_PATH : String = "user://settings.cfg"
|
||||
|
||||
func _ready():
|
||||
var error : Error = _config_file.load(SETTINGS_FILE_PATH)
|
||||
if error != OK:
|
||||
print("Settings not found, using defaults")
|
||||
return
|
||||
|
||||
fov = _config_file.get_value("gameplay", "fov", 90)
|
||||
mouse_sensitivity = _config_file.get_value("gameplay", "mouse_sensitivity", 0.6)
|
||||
inverted_y_axis = _config_file.get_value("gameplay", "inverted_y_axis", false)
|
||||
fullscreen = _config_file.get_value("graphics", "fullscreen", false)
|
||||
_update_screen()
|
||||
|
||||
func save_to_file():
|
||||
_config_file.set_value("gameplay", "fov", fov)
|
||||
_config_file.set_value("gameplay", "mouse_sensitivity", mouse_sensitivity)
|
||||
_config_file.set_value("gameplay", "inverted_y_axis", inverted_y_axis)
|
||||
_config_file.set_value("graphics", "fullscreen", fullscreen)
|
||||
_update_screen()
|
||||
_config_file.save(SETTINGS_FILE_PATH)
|
||||
|
||||
func _update_screen():
|
||||
if fullscreen:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
else:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bjctlqvs33nqy"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bjctlqvs33nqy"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c1tjamjm8qjog" path="res://interfaces/menus/boot/background.webp" id="1_ph586"]
|
||||
[ext_resource type="PackedScene" uid="uid://dirxn4o0g48ng" path="res://interfaces/menus/boot/settings.tscn" id="2_0ncey"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_jd8xf"]
|
||||
resource_name = "MainMenu"
|
||||
|
|
@ -8,26 +9,41 @@ script/source = "class_name BootMenu extends CanvasLayer
|
|||
|
||||
signal start_demo
|
||||
|
||||
func _ready():
|
||||
$Settings.menu_pressed.connect(_on_menu_pressed)
|
||||
|
||||
func _on_demo_pressed():
|
||||
start_demo.emit()
|
||||
|
||||
func _on_multiplayer_pressed():
|
||||
$Main.hide()
|
||||
$Multiplayer.show()
|
||||
_show_menu($Multiplayer)
|
||||
|
||||
func _on_settings_pressed():
|
||||
_show_menu($Settings)
|
||||
|
||||
func _on_quit_pressed():
|
||||
get_tree().quit()
|
||||
|
||||
func _on_menu_pressed():
|
||||
_show_menu($Main)
|
||||
|
||||
func _show_menu(menu : PanelContainer) -> void:
|
||||
$Main.hide()
|
||||
$Multiplayer.hide()
|
||||
$Settings.hide()
|
||||
|
||||
menu.show()
|
||||
"
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_krqeq"]
|
||||
bg_color = Color(0.5, 0.5, 0.5, 0.25)
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_tc1bm"]
|
||||
script/source = "class_name MultiplayerPanel extends PanelContainer
|
||||
script/source = "class_name Multiplayer extends PanelContainer
|
||||
|
||||
const DEFAULT_HOST : String = \"localhost\"
|
||||
const DEFAULT_PORT : int = 9000
|
||||
const CONFIG_FILE_PATH : String = \"user://settings.cfg\"
|
||||
const CONFIG_FILE_PATH : String = \"user://profile.cfg\"
|
||||
|
||||
var _join_address : RegEx = RegEx.new()
|
||||
var _registered_ports : RegEx = RegEx.new()
|
||||
|
|
@ -131,15 +147,19 @@ theme_override_constants/margin_top = 20
|
|||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="Multiplayer/MarginContainer"]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Multiplayer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="Multiplayer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/side_margin = 0
|
||||
|
||||
[node name="Profile" type="TabBar" parent="Multiplayer/MarginContainer/TabContainer"]
|
||||
[node name="Profile" type="TabBar" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/h_separation = 0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Multiplayer/MarginContainer/TabContainer/Profile"]
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile"]
|
||||
layout_mode = 0
|
||||
offset_right = 1116.0
|
||||
offset_bottom = 577.0
|
||||
|
|
@ -148,62 +168,49 @@ theme_override_constants/margin_top = 20
|
|||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile/MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
|
||||
[node name="LeftBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer"]
|
||||
[node name="LeftBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.25
|
||||
|
||||
[node name="Create" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
[node name="Create" type="Button" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Create"
|
||||
|
||||
[node name="Delete" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
[node name="Delete" type="Button" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Delete"
|
||||
|
||||
[node name="Save" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
[node name="Save" type="Button" parent="Multiplayer/MarginContainer/VBoxContainer/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
|
||||
|
||||
[node name="Menu" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Menu
|
||||
"
|
||||
|
||||
[node name="Quit" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
|
||||
[node name="RightBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer"]
|
||||
[node name="RightBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/RightBox"]
|
||||
[node name="Label" type="Label" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile/MarginContainer/HBoxContainer/RightBox"]
|
||||
layout_mode = 2
|
||||
text = "Current Profile:"
|
||||
|
||||
[node name="ProfileName" type="LineEdit" parent="Multiplayer/MarginContainer/TabContainer/Profile/MarginContainer/HBoxContainer/RightBox"]
|
||||
[node name="ProfileName" type="LineEdit" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile/MarginContainer/HBoxContainer/RightBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Newblood"
|
||||
|
||||
[node name="Join" type="TabBar" parent="Multiplayer/MarginContainer/TabContainer"]
|
||||
[node name="Join" type="TabBar" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
select_with_rmb = true
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Multiplayer/MarginContainer/TabContainer/Join"]
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Join"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -215,47 +222,34 @@ theme_override_constants/margin_top = 20
|
|||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Join/MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="LeftBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer"]
|
||||
[node name="LeftBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Join/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.25
|
||||
|
||||
[node name="Join" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox"]
|
||||
[node name="Join" type="Button" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Join"
|
||||
|
||||
[node name="Spacer" type="MarginContainer" parent="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Menu" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Menu
|
||||
"
|
||||
|
||||
[node name="Quit" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
|
||||
[node name="RightBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer"]
|
||||
[node name="RightBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Join/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="JoinAddress" type="LineEdit" parent="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/RightBox"]
|
||||
[node name="JoinAddress" type="LineEdit" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Join/MarginContainer/HBoxContainer/RightBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
placeholder_text = "localhost"
|
||||
|
||||
[node name="Host" type="TabBar" parent="Multiplayer/MarginContainer/TabContainer"]
|
||||
[node name="Host" type="TabBar" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
select_with_rmb = true
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Multiplayer/MarginContainer/TabContainer/Host"]
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -267,41 +261,37 @@ theme_override_constants/margin_top = 20
|
|||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host/MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="LeftBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer"]
|
||||
[node name="LeftBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.25
|
||||
|
||||
[node name="Host" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox"]
|
||||
[node name="Host" type="Button" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Host"
|
||||
|
||||
[node name="Spacer" type="MarginContainer" parent="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Menu" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Menu
|
||||
"
|
||||
|
||||
[node name="Quit" type="Button" parent="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
|
||||
[node name="RightBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer"]
|
||||
[node name="RightBox" type="VBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ServerPort" type="LineEdit" parent="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/RightBox"]
|
||||
[node name="ServerPort" type="LineEdit" parent="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host/MarginContainer/HBoxContainer/RightBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
placeholder_text = "9000"
|
||||
|
||||
[node name="VBoxContainer" type="HBoxContainer" parent="Multiplayer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
|
||||
[node name="Menu" type="Button" parent="Multiplayer/MarginContainer/VBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Back to Main Menu
|
||||
"
|
||||
|
||||
[node name="Modal" type="Panel" parent="Multiplayer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
|
@ -321,6 +311,9 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
text = "CONNECTING..."
|
||||
|
||||
[node name="Settings" parent="." instance=ExtResource("2_0ncey")]
|
||||
visible = false
|
||||
|
||||
[node name="Main" type="PanelContainer" parent="."]
|
||||
anchors_preset = 9
|
||||
anchor_bottom = 1.0
|
||||
|
|
@ -349,6 +342,11 @@ layout_mode = 2
|
|||
theme_override_font_sizes/font_size = 32
|
||||
text = "Multiplayer"
|
||||
|
||||
[node name="Settings" type="Button" parent="Main/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Settings"
|
||||
|
||||
[node name="Quit" type="Button" parent="Main/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
|
|
@ -356,16 +354,12 @@ 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"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox/Menu" to="Multiplayer" method="_on_menu_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox/Quit" to="Multiplayer" method="_on_quit_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox/Host" to="Multiplayer" method="_on_host_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox/Menu" to="Multiplayer" method="_on_menu_pressed"]
|
||||
[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="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Profile/MarginContainer/HBoxContainer/LeftBox/Save" to="Multiplayer" method="_on_save_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Join/MarginContainer/HBoxContainer/LeftBox/Join" to="Multiplayer" method="_on_join_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host/MarginContainer/HBoxContainer/LeftBox/Host" to="Multiplayer" method="_on_host_pressed"]
|
||||
[connection signal="text_changed" from="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host/MarginContainer/HBoxContainer/RightBox/ServerPort" to="Multiplayer/MarginContainer/VBoxContainer/TabContainer/Host/MarginContainer/HBoxContainer/RightBox/ServerPort" method="_on_text_changed"]
|
||||
[connection signal="pressed" from="Multiplayer/MarginContainer/VBoxContainer/VBoxContainer/Menu" to="Multiplayer" method="_on_menu_pressed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Demo" to="." method="_on_demo_pressed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Multiplayer" to="." method="_on_multiplayer_pressed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Settings" to="." method="_on_settings_pressed"]
|
||||
[connection signal="pressed" from="Main/MarginContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"]
|
||||
|
|
|
|||
158
interfaces/menus/boot/settings.tscn
Normal file
158
interfaces/menus/boot/settings.tscn
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dirxn4o0g48ng"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_krqeq"]
|
||||
bg_color = Color(0.5, 0.5, 0.5, 0.25)
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_gbnwv"]
|
||||
resource_name = "Settings"
|
||||
script/source = "class_name Settings extends PanelContainer
|
||||
|
||||
const WINDOW_MODE_OPTIONS = [DisplayServer.WINDOW_MODE_WINDOWED, DisplayServer.WINDOW_MODE_FULLSCREEN]
|
||||
|
||||
@onready var _game_settings : GameSettings = get_node(\"/root/GlobalSettings\")
|
||||
|
||||
signal menu_pressed
|
||||
|
||||
func _ready():
|
||||
%FOVSpinBox.value = _game_settings.fov
|
||||
%SensitivitySpinBox.value = _game_settings.mouse_sensitivity
|
||||
var window_mode : int = 1 if _game_settings.fullscreen else 0
|
||||
%InvertedYCheckbox.button_pressed = _game_settings.inverted_y_axis
|
||||
%WindowModeOptionButton.select(window_mode)
|
||||
|
||||
func _on_save_pressed():
|
||||
_game_settings.fov = %FOVSpinBox.value
|
||||
_game_settings.mouse_sensitivity = %SensitivitySpinBox.value
|
||||
_game_settings.inverted_y_axis = %InvertedYCheckbox.button_pressed
|
||||
_game_settings.fullscreen = %WindowModeOptionButton.selected == 1
|
||||
_game_settings.save_to_file()
|
||||
|
||||
|
||||
func _on_menu_pressed():
|
||||
menu_pressed.emit()
|
||||
"
|
||||
|
||||
[node name="Settings" type="PanelContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_krqeq")
|
||||
script = SubResource("GDScript_gbnwv")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/side_margin = 0
|
||||
|
||||
[node name="Gameplay" type="TabBar" parent="MarginContainer/VBoxContainer/TabContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/h_separation = 0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/TabContainer/Gameplay"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/TabContainer/Gameplay/MarginContainer"]
|
||||
layout_mode = 2
|
||||
columns = 2
|
||||
|
||||
[node name="FOVLabel" type="Label" parent="MarginContainer/VBoxContainer/TabContainer/Gameplay/MarginContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Field of view"
|
||||
|
||||
[node name="FOVSpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/TabContainer/Gameplay/MarginContainer/GridContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
min_value = 60.0
|
||||
max_value = 120.0
|
||||
value = 60.0
|
||||
|
||||
[node name="SensitivityLabel" type="Label" parent="MarginContainer/VBoxContainer/TabContainer/Gameplay/MarginContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Mouse sensitivity"
|
||||
|
||||
[node name="SensitivitySpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/TabContainer/Gameplay/MarginContainer/GridContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
max_value = 1.0
|
||||
step = 0.01
|
||||
value = 1.0
|
||||
|
||||
[node name="InvertedYLabel" type="Label" parent="MarginContainer/VBoxContainer/TabContainer/Gameplay/MarginContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Inverted Y"
|
||||
|
||||
[node name="InvertedYCheckbox" type="CheckBox" parent="MarginContainer/VBoxContainer/TabContainer/Gameplay/MarginContainer/GridContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Graphics" type="TabBar" parent="MarginContainer/VBoxContainer/TabContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
select_with_rmb = true
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/TabContainer/Graphics"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="MarginContainer/VBoxContainer/TabContainer/Graphics/MarginContainer"]
|
||||
layout_mode = 2
|
||||
columns = 2
|
||||
|
||||
[node name="WindowModeLabel" type="Label" parent="MarginContainer/VBoxContainer/TabContainer/Graphics/MarginContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
text = "Window mode"
|
||||
|
||||
[node name="WindowModeOptionButton" type="OptionButton" parent="MarginContainer/VBoxContainer/TabContainer/Graphics/MarginContainer/GridContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
item_count = 2
|
||||
selected = 0
|
||||
popup/item_0/text = "Windowed"
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "Fullscreen"
|
||||
popup/item_1/id = 1
|
||||
|
||||
[node name="VBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
|
||||
[node name="Menu" type="Button" parent="MarginContainer/VBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Back to Main Menu
|
||||
"
|
||||
|
||||
[node name="Save" type="Button" parent="MarginContainer/VBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Apply Settings"
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/VBoxContainer/Menu" to="." method="_on_menu_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/VBoxContainer/Save" to="." method="_on_save_pressed"]
|
||||
|
|
@ -51,13 +51,6 @@ func _set_game_mode(new_mode : Node):
|
|||
add_child(mode)
|
||||
|
||||
func _unhandled_input(event):
|
||||
# switch window mode
|
||||
if event.is_action_pressed(\"window_mode\"):
|
||||
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
else:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
|
||||
# switch mouse mode
|
||||
if OS.is_debug_build() and Input.is_action_just_pressed(\"toggle_mouse_capture\"):
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ run/main_scene="res://main.tscn"
|
|||
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
GlobalSettings="*res://game_settings.gd"
|
||||
|
||||
[editor]
|
||||
|
||||
movie_writer/disable_vsync=true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue