mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 02:11:58 +02:00
Add choice between five background music tracks (0.5.1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,10 @@ const SFX_DIR := "res://assets/audio/sfx"
|
||||
const MUSIC_DIR := "res://assets/audio/music"
|
||||
|
||||
const SFX_IDS: Array[String] = ["click", "success", "try_again", "star", "fanfare"]
|
||||
const MUSIC_IDS: Array[String] = ["forest", "marsh"]
|
||||
const MUSIC_IDS: Array[String] = ["forest", "marsh", "meadow", "river", "night"]
|
||||
|
||||
## Choix « automatique » : la musique de la region (voir music_for_level).
|
||||
const MUSIC_AUTO := "auto"
|
||||
|
||||
|
||||
static func sfx_path(sfx_id: String) -> String:
|
||||
@@ -25,3 +28,17 @@ static func music_path(music_id: String) -> String:
|
||||
## Musique d'une region selon le niveau scolaire de la regle.
|
||||
static func music_for_level(level: String) -> String:
|
||||
return "marsh" if level == "CE2" else "forest"
|
||||
|
||||
|
||||
## Choix possibles dans les reglages : automatique puis chaque morceau.
|
||||
static func music_choices() -> Array[String]:
|
||||
var choices: Array[String] = [MUSIC_AUTO]
|
||||
choices.append_array(MUSIC_IDS)
|
||||
return choices
|
||||
|
||||
|
||||
## Morceau a jouer pour le choix de l'utilisateur et le niveau scolaire.
|
||||
static func resolve_music(choice: String, level: String) -> String:
|
||||
if MUSIC_IDS.has(choice):
|
||||
return choice
|
||||
return music_for_level(level)
|
||||
|
||||
@@ -22,6 +22,7 @@ static func defaults() -> Dictionary:
|
||||
"volume": 0.8,
|
||||
"music_volume": 0.5,
|
||||
"effects_volume": 0.8,
|
||||
"music_track": SoundCatalog.MUSIC_AUTO,
|
||||
"text_scale_index": 0,
|
||||
"animations_enabled": true,
|
||||
}
|
||||
@@ -41,6 +42,9 @@ static func sanitize(raw: Variant) -> Dictionary:
|
||||
var other: Variant = source.get(key)
|
||||
if typeof(other) == TYPE_FLOAT or typeof(other) == TYPE_INT:
|
||||
result[key] = clampf(float(other), 0.0, 1.0)
|
||||
var track: Variant = source.get("music_track")
|
||||
if typeof(track) == TYPE_STRING and SoundCatalog.music_choices().has(track):
|
||||
result["music_track"] = track
|
||||
var index: Variant = source.get("text_scale_index")
|
||||
if typeof(index) == TYPE_FLOAT or typeof(index) == TYPE_INT:
|
||||
result["text_scale_index"] = clampi(int(index), 0, TEXT_SCALES.size() - 1)
|
||||
|
||||
Reference in New Issue
Block a user