reset settings button + saving window mode + saving settings in main menu

This commit is contained in:
Altaezio
2026-07-21 16:09:41 +02:00
parent bc77604fc9
commit 825a41f236
8 changed files with 136 additions and 25 deletions
+54 -12
View File
@@ -6,6 +6,18 @@ const MUSIC_BUS_ID = 1
const SFX_BUS_ID = 2 const SFX_BUS_ID = 2
const AMBIANCE_BUS_ID = 3 const AMBIANCE_BUS_ID = 3
const DEFAULT_MASTER_VOLUME := 1.0
const DEFAULT_MUSIC_VOLUME := 0.7
const DEFAULT_AMBIANCE_VOLUME := 0.7
const DEFAULT_SFX_VOLUME := 0.5
const DEFAULT_WINDOW_MODE := DisplayServer.WINDOW_MODE_FULLSCREEN
const DEFAULT_UI_SIZE := 1.0
const DEFAULT_FOV := 75.0
const DEFAULT_DIFFICULTY := 1
const DEFAULT_AUTO_PICKUP := true
const DEFAULT_MOUSE_SENSIVITY := 0.2
const DEFAULT_ZOOM := 1.0
signal language_changed(settings : SettingsData) signal language_changed(settings : SettingsData)
signal sound_changed(settings : SettingsData) signal sound_changed(settings : SettingsData)
signal video_changed(settings : SettingsData) signal video_changed(settings : SettingsData)
@@ -13,6 +25,26 @@ signal game_changed(settings : SettingsData)
signal fov_changed(value : float) signal fov_changed(value : float)
signal twitch_changed(settings : SettingsData) signal twitch_changed(settings : SettingsData)
func reset_settings() -> void:
language = OS.get_locale_language()
master_volume = DEFAULT_MASTER_VOLUME
music_volume = DEFAULT_MUSIC_VOLUME
ambiance_volume = DEFAULT_AMBIANCE_VOLUME
sfx_volume = DEFAULT_SFX_VOLUME
window_mode = DEFAULT_WINDOW_MODE
ui_size = DEFAULT_UI_SIZE
fov = DEFAULT_FOV
story_mode_difficulty = DEFAULT_DIFFICULTY
auto_pickup = DEFAULT_AUTO_PICKUP
mouse_sensivity = DEFAULT_MOUSE_SENSIVITY
zoom = DEFAULT_ZOOM
closed_help_containers = []
activate_twitch_integration = false
func reset_controls() -> void:
action_remapped = []
input_remapped = []
#region ------------------ Language ------------------ #region ------------------ Language ------------------
const AVAILABLE_LANGUAGES = [ const AVAILABLE_LANGUAGES = [
@@ -31,34 +63,44 @@ const AVAILABLE_LANGUAGES_LABEL = [
#region ------------------ Sound ------------------ #region ------------------ Sound ------------------
@export var master_volume : float = 1.0 : @export var master_volume := DEFAULT_MASTER_VOLUME :
set(v): set(v):
master_volume = v master_volume = v
sound_changed.emit(self) sound_changed.emit(self)
@export var music_volume : float = 0.7 : @export var music_volume := DEFAULT_MUSIC_VOLUME :
set(v): set(v):
music_volume = v music_volume = v
sound_changed.emit(self) sound_changed.emit(self)
@export var ambiance_volume : float = 0.7 : @export var ambiance_volume := DEFAULT_AMBIANCE_VOLUME :
set(v): set(v):
ambiance_volume = v ambiance_volume = v
sound_changed.emit(self) sound_changed.emit(self)
@export var sfx_volume : float = 0.5 : @export var sfx_volume := DEFAULT_SFX_VOLUME :
set(v): set(v):
sfx_volume = v sfx_volume = v
sound_changed.emit(self) sound_changed.emit(self)
#region ------------------ Video ------------------ #region ------------------ Video ------------------
@export var full_screen : bool = true : @export var window_mode := DEFAULT_WINDOW_MODE :
set(v): set(v):
full_screen = v window_mode = v
video_changed.emit(self) video_changed.emit(self)
@export var ui_size : float = 1. : @export var window_size := Vector2i(800, 450):
set(v):
window_size = v
video_changed.emit(self)
@export var window_pos := Vector2i(50, 50):
set(v):
window_pos = v
video_changed.emit(self)
@export var ui_size := DEFAULT_UI_SIZE :
set(v): set(v):
ui_size = v ui_size = v
video_changed.emit(self) video_changed.emit(self)
@@ -70,7 +112,7 @@ const AVAILABLE_LANGUAGES_LABEL = [
@export var action_remapped : Array[String] = [] @export var action_remapped : Array[String] = []
@export var input_remapped : Array[InputEvent] = [] @export var input_remapped : Array[InputEvent] = []
@export var fov := 75. : @export var fov := DEFAULT_FOV :
set(v): set(v):
fov = v fov = v
fov_changed.emit(fov) fov_changed.emit(fov)
@@ -84,17 +126,17 @@ const AVAILABLE_DIFFICULTY = [
"CHALLENGE_MODE" "CHALLENGE_MODE"
] ]
@export var story_mode_difficulty := 1 # Voir AVAILABLE_DIFFICULTY @export var story_mode_difficulty := DEFAULT_DIFFICULTY # Voir AVAILABLE_DIFFICULTY
@export var auto_pickup := true @export var auto_pickup := DEFAULT_AUTO_PICKUP
@export var mouse_sensivity := 0.2 @export var mouse_sensivity := DEFAULT_MOUSE_SENSIVITY
const MAX_ZOOM = 2. const MAX_ZOOM = 2.
const MIN_ZOOM = 0.5 const MIN_ZOOM = 0.5
# Not in settings pannel # Not in settings pannel
@export var zoom : float = 1. : @export var zoom := DEFAULT_ZOOM :
set(v): set(v):
zoom = min(MAX_ZOOM,max(MIN_ZOOM,v)) zoom = min(MAX_ZOOM,max(MIN_ZOOM,v))
game_changed.emit(self) game_changed.emit(self)
+6 -2
View File
@@ -85,6 +85,10 @@ func _init():
func _ready(): func _ready():
Dialogic.timeline_started.connect(_on_timeline_started) Dialogic.timeline_started.connect(_on_timeline_started)
Dialogic.timeline_ended.connect(_on_timeline_ended) Dialogic.timeline_ended.connect(_on_timeline_ended)
if settings_data.window_mode == DisplayServer.WINDOW_MODE_WINDOWED:
var window:= get_tree().root.get_window()
window.size = settings_data.window_size
window.position = settings_data.window_pos
func _on_settings_video_changed(s : SettingsData): func _on_settings_video_changed(s : SettingsData):
update_video_settings(s) update_video_settings(s)
@@ -113,7 +117,7 @@ func update_language_settings(s : SettingsData = settings_data):
TranslationServer.set_locale(s.language) TranslationServer.set_locale(s.language)
func update_video_settings(s : SettingsData = settings_data): func update_video_settings(s : SettingsData = settings_data):
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN if s.full_screen else DisplayServer.WINDOW_MODE_WINDOWED) DisplayServer.window_set_mode(s.window_mode)
if not is_node_ready(): if not is_node_ready():
await ready await ready
get_tree().root.content_scale_factor = s.ui_size get_tree().root.content_scale_factor = s.ui_size
@@ -125,4 +129,4 @@ func update_inputs(s : SettingsData = settings_data):
InputMap.action_add_event(s.action_remapped[i], s.input_remapped[i]) InputMap.action_add_event(s.action_remapped[i], s.input_remapped[i])
func has_unlocked_infinite_mode(): func has_unlocked_infinite_mode():
return true return true
+14 -3
View File
@@ -11,12 +11,14 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
theme_override_constants/margin_left = 100
theme_override_constants/margin_top = 100 theme_override_constants/margin_top = 100
theme_override_constants/margin_right = 100
theme_override_constants/margin_bottom = 100 theme_override_constants/margin_bottom = 100
script = ExtResource("1_g86te") script = ExtResource("1_g86te")
[node name="ColorRect" type="ColorRect" parent="." unique_id=385220162]
layout_mode = 2
color = Color(0, 0, 0, 0)
[node name="ControlsWindow" parent="." unique_id=257725506 instance=ExtResource("1_mnd1d")] [node name="ControlsWindow" parent="." unique_id=257725506 instance=ExtResource("1_mnd1d")]
unique_name_in_owner = true unique_name_in_owner = true
custom_minimum_size = Vector2(900, 0) custom_minimum_size = Vector2(900, 0)
@@ -33,8 +35,17 @@ size_flags_horizontal = 3
theme_override_constants/margin_left = 5 theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 0 theme_override_constants/margin_top = 0
[node name="ControlsContainer" type="VBoxContainer" parent="ControlsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer" unique_id=167218094] [node name="VBoxContainer" type="VBoxContainer" parent="ControlsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer" unique_id=1490504458]
layout_mode = 2
[node name="ControlsContainer" type="VBoxContainer" parent="ControlsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/VBoxContainer" unique_id=167218094]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
[node name="Reset" type="Button" parent="ControlsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/VBoxContainer" unique_id=369586391]
layout_mode = 2
text = "RESET_CONTROLS"
[connection signal="pressed" from="ControlsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/VBoxContainer/Reset" to="." method="_on_reset_pressed"]
[editable path="ControlsWindow"] [editable path="ControlsWindow"]
+8 -1
View File
@@ -11,7 +11,9 @@ func _ready():
%ControlsWindow.closed.connect( %ControlsWindow.closed.connect(
func (): func ():
GameInfo.save_settings() GameInfo.save_settings()
hide()
) )
hide()
func open_controls(): func open_controls():
create_input_list() create_input_list()
@@ -20,6 +22,7 @@ func open_controls():
func close_controls(): func close_controls():
%ControlsWindow.close_window() %ControlsWindow.close_window()
hide()
func create_input_list(): func create_input_list():
InputMap.load_from_project_settings() InputMap.load_from_project_settings()
@@ -34,4 +37,8 @@ func create_input_list():
func instantiate_input_group() -> InputGroup: func instantiate_input_group() -> InputGroup:
return INPUT_GROUP_SCENE.instantiate() as InputGroup return INPUT_GROUP_SCENE.instantiate() as InputGroup
func _on_reset_pressed() -> void:
GameInfo.settings_data.reset_controls()
create_input_list()
+36 -5
View File
@@ -2,7 +2,7 @@
extends Control extends Control
class_name GuiSettings class_name GuiSettings
@onready var settings : SettingsData = GameInfo.settings_data @onready var settings: SettingsData = GameInfo.settings_data
@export_tool_button("Open", "Callable") var open_action = open_settings @export_tool_button("Open", "Callable") var open_action = open_settings
@export_tool_button("Close", "Callable") var close_action = close_settings @export_tool_button("Close", "Callable") var close_action = close_settings
@@ -20,11 +20,30 @@ func _ready():
%SettingsWindow.closed.connect( %SettingsWindow.closed.connect(
func(): func():
GameInfo.save_settings() GameInfo.save_settings()
hide()
) )
TwitchConnection.pseudo_gathered_updated.connect( TwitchConnection.pseudo_gathered_updated.connect(
func (_p):update_twitch_pseudo() func(_p): update_twitch_pseudo()
) )
hide()
func _process(_delta: float) -> void:
if settings:
var window_mode := DisplayServer.window_get_mode()
if window_mode != settings.window_mode:
settings.window_mode = window_mode
GameInfo.save_settings()
if window_mode == DisplayServer.WINDOW_MODE_WINDOWED:
var window := get_tree().root.get_window()
var changed := false
if settings.window_size != window.size:
settings.window_size = window.size
changed = true
if settings.window_pos != window.position:
settings.window_pos = window.position
changed = true
if changed:
GameInfo.save_settings()
func open_settings(): func open_settings():
setup_languages() setup_languages()
@@ -40,6 +59,7 @@ func open_settings():
func close_settings(): func close_settings():
GameInfo.save_settings() GameInfo.save_settings()
%SettingsWindow.close_window() %SettingsWindow.close_window()
hide()
func setup_languages(): func setup_languages():
var optionButton := (%LanguageOptionButton as OptionButton) var optionButton := (%LanguageOptionButton as OptionButton)
@@ -55,7 +75,7 @@ func setup_sound():
%SFXSlider.value = settings.sfx_volume %SFXSlider.value = settings.sfx_volume
func setup_video(): func setup_video():
%FullScreenCheckBox.button_pressed = settings.full_screen %FullScreenCheckBox.button_pressed = settings.window_mode == DisplayServer.WINDOW_MODE_FULLSCREEN
%UiSizeSlider.value = settings.ui_size %UiSizeSlider.value = settings.ui_size
func setup_controls(): func setup_controls():
@@ -82,7 +102,7 @@ func _on_language_option_button_item_selected(index: int):
func _on_full_screen_check_box_toggled(toggled_on: bool): func _on_full_screen_check_box_toggled(toggled_on: bool):
settings.full_screen = toggled_on settings.window_mode = DisplayServer.WINDOW_MODE_FULLSCREEN if toggled_on else DisplayServer.WINDOW_MODE_WINDOWED
func _on_master_slider_drag_ended(_value_changed: bool) -> void: func _on_master_slider_drag_ended(_value_changed: bool) -> void:
%MasterTestPlayer.play() %MasterTestPlayer.play()
@@ -122,3 +142,14 @@ func _on_twitch_channel_line_edit_editing_toggled(toggled_on: bool):
func _on_story_mode_difficulty_option_button_item_selected(index: int): func _on_story_mode_difficulty_option_button_item_selected(index: int):
settings.story_mode_difficulty = index settings.story_mode_difficulty = index
func _on_reset_pressed() -> void:
settings.reset_settings()
setup_languages()
setup_sound()
setup_video()
setup_controls()
setup_difficulty()
setup_twitch()
update_twitch_pseudo()
GameInfo.save_settings()
+14 -2
View File
@@ -25,15 +25,18 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
theme_override_constants/margin_left = 100
theme_override_constants/margin_top = 100 theme_override_constants/margin_top = 100
theme_override_constants/margin_right = 100
theme_override_constants/margin_bottom = 100 theme_override_constants/margin_bottom = 100
script = ExtResource("1_7t8mv") script = ExtResource("1_7t8mv")
[node name="ColorRect" type="ColorRect" parent="." unique_id=221228455]
layout_mode = 2
color = Color(0, 0, 0, 0)
[node name="SettingsWindow" parent="." unique_id=798514856 instance=ExtResource("1_gkn1k")] [node name="SettingsWindow" parent="." unique_id=798514856 instance=ExtResource("1_gkn1k")]
unique_name_in_owner = true unique_name_in_owner = true
process_mode = 3 process_mode = 3
visible = false
custom_minimum_size = Vector2(800, 0) custom_minimum_size = Vector2(800, 0)
layout_mode = 2 layout_mode = 2
size_flags_vertical = 1 size_flags_vertical = 1
@@ -295,6 +298,14 @@ text = "PSEUDO_GATHERED "
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="ResetTitle" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent" unique_id=281140274 instance=ExtResource("3_rbiwc")]
layout_mode = 2
title = ""
[node name="Reset" type="Button" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent" unique_id=1566401845]
layout_mode = 2
text = "RESET_SETTINGS"
[node name="MasterTestPlayer" type="AudioStreamPlayer" parent="." unique_id=1170520824] [node name="MasterTestPlayer" type="AudioStreamPlayer" parent="." unique_id=1170520824]
unique_name_in_owner = true unique_name_in_owner = true
stream = ExtResource("6_8f00b") stream = ExtResource("6_8f00b")
@@ -327,5 +338,6 @@ bus = &"Sfx"
[connection signal="toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GameSettings/AutoPickupCheckBox" to="." method="_on_auto_pickup_check_box_toggled"] [connection signal="toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GameSettings/AutoPickupCheckBox" to="." method="_on_auto_pickup_check_box_toggled"]
[connection signal="toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer/TwitchActivationCheckBox" to="." method="_on_twitch_activation_check_box_toggled"] [connection signal="toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer/TwitchActivationCheckBox" to="." method="_on_twitch_activation_check_box_toggled"]
[connection signal="editing_toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer/TwitchChannelLineEdit" to="." method="_on_twitch_channel_line_edit_editing_toggled"] [connection signal="editing_toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer/TwitchChannelLineEdit" to="." method="_on_twitch_channel_line_edit_editing_toggled"]
[connection signal="pressed" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/Reset" to="." method="_on_reset_pressed"]
[editable path="SettingsWindow"] [editable path="SettingsWindow"]
+2
View File
@@ -560,11 +560,13 @@ autoplay = &"arrive"
[node name="Settings" parent="." unique_id=1832300574 instance=ExtResource("18_lwj2x")] [node name="Settings" parent="." unique_id=1832300574 instance=ExtResource("18_lwj2x")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false
z_index = 100 z_index = 100
mouse_filter = 2 mouse_filter = 2
[node name="Controls" parent="." unique_id=36425199 instance=ExtResource("19_rf16a")] [node name="Controls" parent="." unique_id=36425199 instance=ExtResource("19_rf16a")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false
z_index = 100 z_index = 100
mouse_filter = 2 mouse_filter = 2
+2
View File
@@ -236,6 +236,8 @@ ACTIVATE_TWITCH_INTERACTION,Activate Twitch Integration,Activer l'intégration T
TWITCH_CHANNEL,Twitch channel name,Nom de la chaine Twitch TWITCH_CHANNEL,Twitch channel name,Nom de la chaine Twitch
PSEUDO_GATHERED_%d,"Connected, %d pseudos gathered","Connecté, %d pseudos récupérés" PSEUDO_GATHERED_%d,"Connected, %d pseudos gathered","Connecté, %d pseudos récupérés"
TWITCH_NOT_CONNECTED,"Twitch not connected","Non connecté à Twitch" TWITCH_NOT_CONNECTED,"Twitch not connected","Non connecté à Twitch"
RESET_SETTINGS,"Reset settings","Réinitialiser les paramètres"
RESET_CONTROLS,"Reset controls","Réinitialiser les contrôles"
CONTROLS,Controls,Contrôles CONTROLS,Controls,Contrôles
MOVE_RIGHT,Move right,Déplacement à droite MOVE_RIGHT,Move right,Déplacement à droite
MOVE_LEFT,Move left,Déplacement à gauche MOVE_LEFT,Move left,Déplacement à gauche
1 keys en fr
236 TWITCH_CHANNEL Twitch channel name Nom de la chaine Twitch
237 PSEUDO_GATHERED_%d Connected, %d pseudos gathered Connecté, %d pseudos récupérés
238 TWITCH_NOT_CONNECTED Twitch not connected Non connecté à Twitch
239 RESET_SETTINGS Reset settings Réinitialiser les paramètres
240 RESET_CONTROLS Reset controls Réinitialiser les contrôles
241 CONTROLS Controls Contrôles
242 MOVE_RIGHT Move right Déplacement à droite
243 MOVE_LEFT Move left Déplacement à gauche