ajout de panneaux de contrôles, de paramètres et refactorisation de la gestion de l'audio

This commit is contained in:
2025-11-22 15:10:41 +01:00
parent dbe8f03531
commit 435415363c
171 changed files with 2165 additions and 922 deletions

View File

@@ -0,0 +1,35 @@
[gd_scene load_steps=3 format=3 uid="uid://b4qe1dwwsk87t"]
[ext_resource type="Script" uid="uid://dmefdkcsmgr4l" path="res://gui/menu/controls/scripts/controls.gd" id="1_g86te"]
[ext_resource type="PackedScene" uid="uid://brxrl7sipyy6k" path="res://gui/menu/window/window.tscn" id="1_mnd1d"]
[node name="Controls" 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_g86te")
[node name="ControlsWindow" parent="." instance=ExtResource("1_mnd1d")]
unique_name_in_owner = true
custom_minimum_size = Vector2(900, 500)
layout_mode = 1
title = "CONTROLS"
[node name="WindowTitle" parent="ControlsWindow/WindowHeader/MarginContainer" index="0"]
text = "CONTROLS"
[node name="MarginContainer" type="MarginContainer" parent="ControlsWindow/WindowContent/MarginContainer/ContentContainer" index="0"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 0
[node name="ControlsContainer" type="VBoxContainer" parent="ControlsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
[editable path="ControlsWindow"]

View File

@@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=3 uid="uid://dapsvw31ux0j2"]
[ext_resource type="PackedScene" uid="uid://d3agt2njfgddb" path="res://gui/menu/window/content_label.tscn" id="1_ganst"]
[ext_resource type="Script" uid="uid://dhs6kispjoecs" path="res://gui/menu/controls/scripts/input_group.gd" id="1_kkwd7"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="3_s602q"]
[node name="InputGroup" type="HBoxContainer"]
size_flags_horizontal = 3
script = ExtResource("1_kkwd7")
[node name="Text" parent="." instance=ExtResource("1_ganst")]
unique_name_in_owner = true
layout_mode = 2
text = "Input"
[node name="Button" type="Button" parent="."]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 10
theme = ExtResource("3_s602q")
text = "Text"
[connection signal="button_down" from="Button" to="." method="_on_button_button_down"]
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]

View File

@@ -0,0 +1,33 @@
@tool
extends Control
const INPUT_GROUP_SCENE = preload("res://gui/menu/controls/input_group.tscn")
@export_tool_button("Update", "Callable") var update_action = create_input_list
func _ready():
create_input_list()
if not Engine.is_editor_hint():
%ControlsWindow.close_window()
show()
func open_controls():
%ControlsWindow.open_window()
func close_controls():
%ControlsWindow.close_window()
func create_input_list():
InputMap.load_from_project_settings()
for child in %ControlsContainer.get_children():
child.queue_free()
for action in InputMap.get_actions():
if action.substr(0, 3) != "ui_":
var input_group = instantiate_input_group()
input_group.action_name = action
%ControlsContainer.add_child(input_group)
func instantiate_input_group() -> InputGroup:
return INPUT_GROUP_SCENE.instantiate() as InputGroup

View File

@@ -0,0 +1 @@
uid://dmefdkcsmgr4l

View File

@@ -0,0 +1,38 @@
@tool
extends HBoxContainer
class_name InputGroup
const MAX_INPUT_NAME = 30
var event : InputEvent = null
var is_remapping := false
@export var action_name : String :
set(v):
action_name = v
var events : Array[InputEvent] = InputMap.action_get_events(action_name)
event = null if events.size() == 0 else events[0]
update()
func update():
%Text.text = action_name.to_upper()
var input_name = "UNASSIGNED" if event == null else event.as_text()
if input_name.length() > MAX_INPUT_NAME:
input_name = input_name.substr(0,MAX_INPUT_NAME) + "..."
%Button.text = input_name
# (%Button as Button).add_theme_color_override("font_color", Color.RED if )
func _input(new_event):
if is_remapping:
if (
new_event is InputEventKey or (new_event is InputEventMouseButton and new_event.is_pressed())
):
is_remapping = false
GameInfo.update_input(action_name, event, new_event)
event = new_event
update()
func _on_button_button_down():
if !is_remapping:
is_remapping = true
%Button.text = "PRESS_KEY"

View File

@@ -0,0 +1 @@
uid://dhs6kispjoecs

View File

@@ -3,7 +3,5 @@ extends Node
@export_file var start_scene_path : String
func _ready():
var preferred_language = OS.get_locale_language()
TranslationServer.set_locale(preferred_language)
get_tree().change_scene_to_file(start_scene_path)

View File

@@ -0,0 +1,53 @@
@tool
extends Control
class_name GuiSettings
@onready var settings : SettingsData = GameInfo.game_data.settings
@export_tool_button("Open", "Callable") var open_action = open_settings
@export_tool_button("Close", "Callable") var close_action = close_settings
func _ready():
setup_languages()
setup_sound()
setup_video()
if not Engine.is_editor_hint():
%SettingsWindow.close_window()
show()
func open_settings():
%SettingsWindow.open_window()
func close_settings():
%SettingsWindow.close_window()
func setup_languages():
var optionButton := (%LanguageOptionButton as OptionButton)
optionButton.clear()
for language in SettingsData.AVAILABLE_LANGUAGES_LABEL:
optionButton.add_item(language)
optionButton.selected = SettingsData.AVAILABLE_LANGUAGES.find(settings.language)
func setup_sound():
%MusicSlider.value = settings.music_volume
%EnvSlider.value = settings.ambiance_volume
%SFXSlider.value = settings.sfx_volume
func setup_video():
%FullScreenCheckBox.button_pressed = settings.full_screen
func _on_language_option_button_item_selected(index: int):
settings.language = SettingsData.AVAILABLE_LANGUAGES[index]
func _on_full_screen_check_box_toggled(toggled_on: bool):
settings.full_screen = toggled_on
func _on_music_slider_value_changed(value: float):
settings.music_volume = min(1.0, value)
func _on_env_slider_value_changed(value: float):
settings.ambiance_volume = min(1.0, value)
func _on_sfx_slider_value_changed(value: float):
settings.sfx_volume = min(1.0, value)

View File

@@ -0,0 +1 @@
uid://bms0xtv8vh2qg

View File

@@ -0,0 +1,137 @@
[gd_scene load_steps=6 format=3 uid="uid://g6lbgg1fhc25"]
[ext_resource type="Script" uid="uid://bms0xtv8vh2qg" path="res://gui/menu/settings/scripts/settings.gd" id="1_7t8mv"]
[ext_resource type="PackedScene" uid="uid://brxrl7sipyy6k" path="res://gui/menu/window/window.tscn" id="1_gkn1k"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="2_7t8mv"]
[ext_resource type="PackedScene" uid="uid://cvjqp3oewr3rv" path="res://gui/menu/window/content_title.tscn" id="3_rbiwc"]
[ext_resource type="PackedScene" uid="uid://d3agt2njfgddb" path="res://gui/menu/window/content_label.tscn" id="4_rbiwc"]
[node name="Settings" type="Control"]
process_mode = 3
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
script = ExtResource("1_7t8mv")
[node name="SettingsWindow" parent="." instance=ExtResource("1_gkn1k")]
unique_name_in_owner = true
process_mode = 3
layout_mode = 1
offset_left = -349.99994
offset_right = 350.00006
mouse_filter = 0
title = "SETTINGS"
[node name="WindowTitle" parent="SettingsWindow/WindowHeader/MarginContainer" index="0"]
text = "SETTINGS"
[node name="MarginContainer" type="MarginContainer" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer" index="0"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 0
[node name="SettingsContent" type="VBoxContainer" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="LanguageTitle" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent" instance=ExtResource("3_rbiwc")]
layout_mode = 2
title = "LANGUAGE"
[node name="LanguageSettings" type="GridContainer" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent"]
layout_mode = 2
columns = 2
[node name="LanguageText" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/LanguageSettings" instance=ExtResource("4_rbiwc")]
layout_mode = 2
[node name="LanguageOptionButton" type="OptionButton" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/LanguageSettings"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
theme = ExtResource("2_7t8mv")
selected = 0
item_count = 2
popup/item_0/text = "English"
popup/item_0/id = 0
popup/item_1/text = "Français"
popup/item_1/id = 1
[node name="SoundTitle" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent" instance=ExtResource("3_rbiwc")]
layout_mode = 2
title = "SOUND"
[node name="SoundSliders" type="GridContainer" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent"]
layout_mode = 2
columns = 2
[node name="MusicText" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders" instance=ExtResource("4_rbiwc")]
layout_mode = 2
text = "MUSIC_VOLUME"
[node name="MusicSlider" type="HSlider" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource("2_7t8mv")
max_value = 1.0
step = 0.01
value = 1.0
[node name="EvironmentText" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders" instance=ExtResource("4_rbiwc")]
layout_mode = 2
text = "ENVIRONMENT_VOLUME"
[node name="EnvSlider" type="HSlider" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 1
max_value = 1.0
step = 0.01
[node name="SFXText" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders" instance=ExtResource("4_rbiwc")]
layout_mode = 2
text = "SFX_VOLUME"
[node name="SFXSlider" type="HSlider" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 1
max_value = 1.0
step = 0.01
[node name="VideoTitle" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent" instance=ExtResource("3_rbiwc")]
layout_mode = 2
title = "VIDEO"
[node name="VideoSettings" type="GridContainer" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent"]
layout_mode = 2
columns = 2
[node name="FullScreenText" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/VideoSettings" instance=ExtResource("4_rbiwc")]
layout_mode = 2
text = "FULLSCREEN"
[node name="FullScreenCheckBox" type="CheckBox" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/VideoSettings"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 10
size_flags_vertical = 4
theme = ExtResource("2_7t8mv")
[connection signal="item_selected" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/LanguageSettings/LanguageOptionButton" to="." method="_on_language_option_button_item_selected"]
[connection signal="value_changed" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders/MusicSlider" to="." method="_on_music_slider_value_changed"]
[connection signal="value_changed" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders/EnvSlider" to="." method="_on_env_slider_value_changed"]
[connection signal="value_changed" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/SoundSliders/SFXSlider" to="." method="_on_sfx_slider_value_changed"]
[connection signal="toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/VideoSettings/FullScreenCheckBox" to="." method="_on_full_screen_check_box_toggled"]
[editable path="SettingsWindow"]

View File

@@ -0,0 +1,14 @@
[gd_scene load_steps=4 format=3 uid="uid://d3agt2njfgddb"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_qjfiv"]
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="2_klh4u"]
[sub_resource type="LabelSettings" id="LabelSettings_yj6f1"]
font = ExtResource("2_klh4u")
font_size = 20
font_color = Color(0.13725491, 0.39215687, 0.6666667, 1)
[node name="LanguageText" type="Label"]
theme = ExtResource("1_qjfiv")
text = "Language"
label_settings = SubResource("LabelSettings_yj6f1")

View File

@@ -0,0 +1,29 @@
[gd_scene load_steps=5 format=3 uid="uid://cvjqp3oewr3rv"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_g1qh5"]
[ext_resource type="Script" uid="uid://cj3o5y7cyipcs" path="res://gui/menu/window/scripts/content_title.gd" id="1_xbmdr"]
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="2_xbmdr"]
[sub_resource type="LabelSettings" id="LabelSettings_58dya"]
font = ExtResource("2_xbmdr")
font_size = 30
font_color = Color(0.0627451, 0.05882353, 0.16862746, 1)
[node name="ContentTitle" type="HBoxContainer"]
script = ExtResource("1_xbmdr")
title = "TITLE"
[node name="Text" type="Label" parent="."]
unique_name_in_owner = true
layout_mode = 2
theme = ExtResource("1_g1qh5")
theme_override_colors/font_color = Color(0.13725491, 0.39215687, 0.6666667, 1)
text = "TITLE"
label_settings = SubResource("LabelSettings_58dya")
[node name="ColorRect" type="ColorRect" parent="."]
custom_minimum_size = Vector2(0, 2)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 8
color = Color(0.0627451, 0.05882353, 0.16862746, 1)

View File

@@ -0,0 +1,11 @@
@tool
extends HBoxContainer
@export var title : String = "" :
set(v):
title = v
if is_node_ready():
%Text.text = v
func _ready():
%Text.text = title

View File

@@ -0,0 +1 @@
uid://cj3o5y7cyipcs

View File

@@ -0,0 +1,30 @@
@tool
extends VBoxContainer
class_name GuiWindow
signal closed
@export var title : String : set = update_title
@export_tool_button("Open", "Callable") var open_action = open_window
@export_tool_button("Close", "Callable") var close_action = close_window
func _ready():
update_title(title)
func update_title(text : String):
title = text
if (is_node_ready()):
%WindowTitle.text = title
func _on_close_button_pressed():
close_window()
func open_window():
show()
%ControlAnimationPlayer.appear()
func close_window():
%ControlAnimationPlayer.disappear(0.3)
await get_tree().create_timer(0.3).timeout
hide()
closed.emit()

View File

@@ -0,0 +1 @@
uid://bvsjrf5n8jp1i

107
gui/menu/window/window.tscn Normal file
View File

@@ -0,0 +1,107 @@
[gd_scene load_steps=10 format=3 uid="uid://brxrl7sipyy6k"]
[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="1_0d57l"]
[ext_resource type="Script" uid="uid://bvsjrf5n8jp1i" path="res://gui/menu/window/scripts/window.gd" id="1_8s3xn"]
[ext_resource type="Texture2D" uid="uid://ottk0ccw1d1r" path="res://common/icons/square-rounded-x.svg" id="2_8s3xn"]
[ext_resource type="Script" uid="uid://0dhj8sdpil7q" path="res://gui/tools/control_animation_player.gd" id="2_n80be"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="4_ghh86"]
[ext_resource type="Texture2D" uid="uid://bxrn0qho5jo7f" path="res://common/icons/square-rounded-x-nofill.svg" id="5_ghh86"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yj6f1"]
bg_color = Color(1, 0.6509804, 0.09019608, 1)
corner_radius_top_left = 20
corner_radius_top_right = 20
corner_radius_bottom_right = 20
corner_radius_bottom_left = 20
expand_margin_bottom = 50.0
[sub_resource type="LabelSettings" id="LabelSettings_apjlw"]
font = ExtResource("1_0d57l")
font_size = 30
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7c7ks"]
bg_color = Color(1, 1, 1, 1)
corner_radius_top_left = 20
corner_radius_top_right = 20
corner_radius_bottom_right = 20
corner_radius_bottom_left = 20
[node name="Window" type="VBoxContainer"]
custom_minimum_size = Vector2(700, 500)
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -250.0
offset_top = -250.0
offset_right = 250.00012
offset_bottom = 250.00122
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/separation = 10
script = ExtResource("1_8s3xn")
title = "Hello"
[node name="ControlAnimationPlayer" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource("2_n80be")
metadata/_custom_type_script = "uid://0dhj8sdpil7q"
[node name="WindowHeader" type="Panel" parent="."]
custom_minimum_size = Vector2(0, 50)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_yj6f1")
[node name="MarginContainer" type="MarginContainer" parent="WindowHeader"]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 58.0
grow_horizontal = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 0
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 0
[node name="WindowTitle" type="Label" parent="WindowHeader/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
text = "Hello"
label_settings = SubResource("LabelSettings_apjlw")
horizontal_alignment = 1
[node name="CloseButton" type="TextureButton" parent="WindowHeader/MarginContainer"]
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 4
theme = ExtResource("4_ghh86")
texture_normal = ExtResource("2_8s3xn")
texture_hover = ExtResource("5_ghh86")
ignore_texture_size = true
stretch_mode = 5
[node name="WindowContent" type="Panel" parent="."]
layout_mode = 2
size_flags_vertical = 3
theme_override_styles/panel = SubResource("StyleBoxFlat_7c7ks")
[node name="MarginContainer" type="MarginContainer" parent="WindowContent"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("4_ghh86")
[node name="ContentContainer" type="ScrollContainer" parent="WindowContent/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
horizontal_scroll_mode = 0
[connection signal="pressed" from="WindowHeader/MarginContainer/CloseButton" to="." method="_on_close_button_pressed"]