Skip to content

Commit

Permalink
Music and Sound Effect loading and playing
Browse files Browse the repository at this point in the history
almost working music loading

music list sent to godot

wav loading not working

mp3 metadata

load wav initial

load and play title theme first

fix errors not related to nodetools

working wav define loading and music playlists

fixup error handling and playlist

load song chances

code style progress

switch mp3 metadata addon to MusicMetadata

add id3v1 mp3 metadata handling to MusicMetadata

remove commented code from id3v1

sounds gd styling

fix dataloader conflicts

clean up commented code

move MusicChance to dataloader

remove reference to old addon

move sfx defines loader

add self to credits

feedback on soundSingleton

include subfolders in sound singleton sfx map

replace space tabs

replace std_view_to_godot_string with std_to_godot_string

revise singleton files

revise gd side sound

final revisions
  • Loading branch information
Nemrav committed Aug 5, 2024
1 parent fde15e5 commit 9506f41
Show file tree
Hide file tree
Showing 28 changed files with 1,686 additions and 20 deletions.
9 changes: 9 additions & 0 deletions extension/src/openvic-extension/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "openvic-extension/singletons/LoadLocalisation.hpp"
#include "openvic-extension/singletons/MenuSingleton.hpp"
#include "openvic-extension/singletons/ModelSingleton.hpp"
#include "openvic-extension/singletons/SoundSingleton.hpp"

using namespace godot;
using namespace OpenVic;
Expand All @@ -27,6 +28,7 @@ static GameSingleton* _game_singleton = nullptr;
static MenuSingleton* _menu_singleton = nullptr;
static ModelSingleton* _model_singleton = nullptr;
static AssetManager* _asset_manager_singleton = nullptr;
static SoundSingleton* _sound_singleton = nullptr;

void initialize_openvic_types(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
Expand All @@ -41,6 +43,10 @@ void initialize_openvic_types(ModuleInitializationLevel p_level) {
_load_localisation = memnew(LoadLocalisation);
Engine::get_singleton()->register_singleton("LoadLocalisation", LoadLocalisation::get_singleton());

ClassDB::register_class<SoundSingleton>();
_sound_singleton = memnew(SoundSingleton);
Engine::get_singleton()->register_singleton("SoundSingleton", SoundSingleton::get_singleton());

ClassDB::register_class<GameSingleton>();
_game_singleton = memnew(GameSingleton);
Engine::get_singleton()->register_singleton("GameSingleton", GameSingleton::get_singleton());
Expand Down Expand Up @@ -97,6 +103,9 @@ void uninitialize_openvic_types(ModuleInitializationLevel p_level) {

Engine::get_singleton()->unregister_singleton("AssetManager");
memdelete(_asset_manager_singleton);

Engine::get_singleton()->unregister_singleton("SoundSingleton");
memdelete(_sound_singleton);
}

extern "C" {
Expand Down
15 changes: 11 additions & 4 deletions extension/src/openvic-extension/singletons/GameSingleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ StringName const& GameSingleton::_signal_clock_state_changed() {
void GameSingleton::_bind_methods() {
OV_BIND_SMETHOD(setup_logger);

OV_BIND_METHOD(GameSingleton::load_defines_compatibility_mode, { "file_paths" });
OV_BIND_METHOD(GameSingleton::load_defines_compatibility_mode);
OV_BIND_METHOD(GameSingleton::set_compatibility_mode_roots, { "file_paths" });

OV_BIND_SMETHOD(search_for_game_path, { "hint_path" }, DEFVAL(String {}));
OV_BIND_METHOD(GameSingleton::lookup_file_path, { "path" });

Expand Down Expand Up @@ -582,16 +584,21 @@ Error GameSingleton::_load_flag_sheet() {
return ret;
}

Error GameSingleton::load_defines_compatibility_mode(PackedStringArray const& file_paths) {
Error GameSingleton::set_compatibility_mode_roots(PackedStringArray const& file_paths) {
Dataloader::path_vector_t roots;
for (String const& path : file_paths) {
roots.push_back(Utilities::godot_to_std_string(path));
}

Error err = OK;
ERR_FAIL_COND_V_MSG(!game_manager.set_roots(roots), FAILED, "Failed to set dataloader roots!");
return OK;
}

Error GameSingleton::load_defines_compatibility_mode() {
Error err = OK;
auto add_message = std::bind_front(&LoadLocalisation::add_message, LoadLocalisation::get_singleton());
if (!game_manager.load_definitions(roots, add_message)) {

if (!game_manager.load_definitions(add_message)) {
UtilityFunctions::push_error("Failed to load defines!");
err = FAILED;
}
Expand Down
3 changes: 2 additions & 1 deletion extension/src/openvic-extension/singletons/GameSingleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ namespace OpenVic {

/* Load the game's defines in compatiblity mode from the filepath
* pointing to the defines folder. */
godot::Error load_defines_compatibility_mode(godot::PackedStringArray const& file_paths);
godot::Error set_compatibility_mode_roots(godot::PackedStringArray const& file_paths);
godot::Error load_defines_compatibility_mode();

static godot::String search_for_game_path(godot::String const& hint_path = {});
godot::String lookup_file_path(godot::String const& path) const;
Expand Down
Loading

0 comments on commit 9506f41

Please sign in to comment.