diff options
author | Nemrav <> | 2024-08-01 23:17:24 +0200 |
---|---|---|
committer | Nemrav <> | 2024-08-03 21:32:56 +0200 |
commit | 0b4732befaaf4a742acb319256c535eb449668a7 (patch) | |
tree | cb7af6c0536e399b8122db6f16985a1f58377c9e /src/openvic-simulation/misc/SoundEffect.cpp | |
parent | 861acff78bd238232ed9e369ea046c2ed4a31198 (diff) |
Music and Sound Effect define loadingsim_music
sound and music pr feedback
more sound and music style fixes
check lookup path
Diffstat (limited to 'src/openvic-simulation/misc/SoundEffect.cpp')
-rw-r--r-- | src/openvic-simulation/misc/SoundEffect.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/openvic-simulation/misc/SoundEffect.cpp b/src/openvic-simulation/misc/SoundEffect.cpp new file mode 100644 index 0000000..df3196b --- /dev/null +++ b/src/openvic-simulation/misc/SoundEffect.cpp @@ -0,0 +1,38 @@ +#include "SoundEffect.hpp" + +using namespace OpenVic; +using namespace OpenVic::NodeTools; + +SoundEffect::SoundEffect ( + std::string_view new_identifier, std::string_view new_file, fixed_point_t new_volume +) : HasIdentifier { new_identifier }, file { new_file }, volume { new_volume } {} + +bool SoundEffectManager::_load_sound_define(std::string_view sfx_identifier, ast::NodeCPtr root) { + std::string_view file {}; + fixed_point_t volume = 1; + bool ret = expect_dictionary_keys( + "file", ONE_EXACTLY, expect_string(assign_variable_callback(file)), + "volume", ZERO_OR_ONE, + expect_fixed_point(assign_variable_callback(volume)) + )(root); + + if (sfx_identifier.empty()) { + Logger::error("Invalid sound identifier - empty!"); + return false; + } + if(file.empty()) { + Logger::error("Invalid sound file name - empty!"); + return false; + } + + ret &= sound_effects.add_item({sfx_identifier,file,volume}); + return ret; +} + +bool SoundEffectManager::load_sound_defines_file(ast::NodeCPtr root) { + return expect_dictionary_reserve_length(sound_effects, + [this](std::string_view key, ast::NodeCPtr value) -> bool { + return _load_sound_define(key,value); + } + )(root); +}
\ No newline at end of file |