From c7079bfc08dd8a5f73fafd794ed380b1cdc6d4b7 Mon Sep 17 00:00:00 2001 From: Eneko Nieto Date: Tue, 12 Nov 2024 19:36:05 +0100 Subject: [PATCH] feat(credits): enable music volume, closes #89 --- .../esc/commands/music_enable.gd | 40 +++++++++++++++++++ .../items/inventory/turno_cocina_cuerno.esc | 1 + project.godot | 8 +++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 addons/escoria-ui-return-monkey-island/esc/commands/music_enable.gd diff --git a/addons/escoria-ui-return-monkey-island/esc/commands/music_enable.gd b/addons/escoria-ui-return-monkey-island/esc/commands/music_enable.gd new file mode 100644 index 00000000..dd9dc957 --- /dev/null +++ b/addons/escoria-ui-return-monkey-island/esc/commands/music_enable.gd @@ -0,0 +1,40 @@ +# `music_enable` +# +# Enable music volume +# +# @ESC +extends ESCBaseCommand +class_name MusicEnableCommand + + +var item_count_manager = ESCItemCountManager.new() + +# Return the descriptor of the arguments of this command +func configure() -> ESCCommandArgumentDescriptor: + return ESCCommandArgumentDescriptor.new() + + +# Validate wether the given arguments match the command descriptor +func validate(arguments: Array): + return .validate(arguments) + + +# Run the command +func run(command_params: Array) -> int: + AudioServer.set_bus_volume_db( + AudioServer.get_bus_index(escoria.BUS_MUSIC), + linear2db( + ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.MUSIC_VOLUME + ) + ) + ) + escoria.game_scene.musicEnabled = true + + return ESCExecution.RC_OK + + +# Function called when the command is interrupted. +func interrupt(): + # Do nothing + pass diff --git a/gymkhana/items/inventory/turno_cocina_cuerno.esc b/gymkhana/items/inventory/turno_cocina_cuerno.esc index a7a4e8f4..0b966cdf 100644 --- a/gymkhana/items/inventory/turno_cocina_cuerno.esc +++ b/gymkhana/items/inventory/turno_cocina_cuerno.esc @@ -17,6 +17,7 @@ say player "Parece un cuerno de algĂșn animal. Lo usan para llamar a comer." stop_snd > [turno_cocina_eneko_cata_ok] set_gui_visible false + music_enable change_scene res://gymkhana/rooms/turno_cocina/creditos/creditos.tscn stop play_video res://gymkhana/videos/turno_cocina/cuerno_antes_de_tiempo.ogv diff --git a/project.godot b/project.godot index 2e87960a..6d5c97f0 100644 --- a/project.godot +++ b/project.godot @@ -550,6 +550,11 @@ _global_script_classes=[ { "path": "res://addons/escoria-ui-return-monkey-island/item_outline.gd" }, { "base": "ESCBaseCommand", +"class": "MusicEnableCommand", +"language": "GDScript", +"path": "res://addons/escoria-ui-return-monkey-island/esc/commands/music_enable.gd" +}, { +"base": "ESCBaseCommand", "class": "PlayLibSound", "language": "GDScript", "path": "res://addons/escoria-ui-return-monkey-island/esc/commands/play_lib_snd.gd" @@ -892,7 +897,8 @@ _global_script_class_icons={ "InventoryAddCommand": "", "InventoryRemoveCommand": "", "ItemCountAddCommand": "", -"ItemOutline": "res://addons/escoria-core/design/esc_item.svg", +"ItemOutline": "", +"MusicEnableCommand": "", "PlayLibSound": "", "PlaySndCommand": "", "PlayVideoCommand": "",