mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-25 21:03:51 +00:00
refactor: decouple Application singleton by extracting core subsystems and updating interfaces
- Add `audio::AudioCoordinator` interface and implementation - Modify `Application` to reduce singleton usage and move controller responsibilities: - application.hpp - application.cpp - Update UI and audio headers/sources: - game_screen.hpp - game_screen.cpp - ui_manager.hpp - audio_coordinator.hpp - audio_coordinator.cpp - Project config touched: - CMakeLists.txt
This commit is contained in:
parent
9b38e64f84
commit
d43397163e
8 changed files with 179 additions and 3 deletions
87
src/audio/audio_coordinator.cpp
Normal file
87
src/audio/audio_coordinator.cpp
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#include "audio/audio_coordinator.hpp"
|
||||
#include "audio/audio_engine.hpp"
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/footstep_manager.hpp"
|
||||
#include "audio/activity_sound_manager.hpp"
|
||||
#include "audio/mount_sound_manager.hpp"
|
||||
#include "audio/npc_voice_manager.hpp"
|
||||
#include "audio/ambient_sound_manager.hpp"
|
||||
#include "audio/ui_sound_manager.hpp"
|
||||
#include "audio/combat_sound_manager.hpp"
|
||||
#include "audio/spell_sound_manager.hpp"
|
||||
#include "audio/movement_sound_manager.hpp"
|
||||
#include "pipeline/asset_manager.hpp"
|
||||
#include "core/logger.hpp"
|
||||
|
||||
namespace wowee {
|
||||
namespace audio {
|
||||
|
||||
AudioCoordinator::AudioCoordinator() = default;
|
||||
|
||||
AudioCoordinator::~AudioCoordinator() {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
bool AudioCoordinator::initialize() {
|
||||
// Initialize AudioEngine (singleton)
|
||||
if (!AudioEngine::instance().initialize()) {
|
||||
LOG_WARNING("Failed to initialize AudioEngine - audio will be disabled");
|
||||
audioAvailable_ = false;
|
||||
return false;
|
||||
}
|
||||
audioAvailable_ = true;
|
||||
|
||||
// Create all audio managers (initialized later with asset manager)
|
||||
musicManager_ = std::make_unique<MusicManager>();
|
||||
footstepManager_ = std::make_unique<FootstepManager>();
|
||||
activitySoundManager_ = std::make_unique<ActivitySoundManager>();
|
||||
mountSoundManager_ = std::make_unique<MountSoundManager>();
|
||||
npcVoiceManager_ = std::make_unique<NpcVoiceManager>();
|
||||
ambientSoundManager_ = std::make_unique<AmbientSoundManager>();
|
||||
uiSoundManager_ = std::make_unique<UiSoundManager>();
|
||||
combatSoundManager_ = std::make_unique<CombatSoundManager>();
|
||||
spellSoundManager_ = std::make_unique<SpellSoundManager>();
|
||||
movementSoundManager_ = std::make_unique<MovementSoundManager>();
|
||||
|
||||
LOG_INFO("AudioCoordinator initialized with ", 10, " audio managers");
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioCoordinator::initializeWithAssets(pipeline::AssetManager* assetManager) {
|
||||
if (!audioAvailable_ || !assetManager) return;
|
||||
|
||||
// MusicManager needs asset manager for zone music lookups
|
||||
if (musicManager_) {
|
||||
musicManager_->initialize(assetManager);
|
||||
}
|
||||
|
||||
// Other managers may need asset manager for sound bank loading
|
||||
// (Add similar calls as needed for other managers)
|
||||
|
||||
LOG_INFO("AudioCoordinator initialized with asset manager");
|
||||
}
|
||||
|
||||
void AudioCoordinator::shutdown() {
|
||||
// Reset all managers first (they may reference AudioEngine)
|
||||
movementSoundManager_.reset();
|
||||
spellSoundManager_.reset();
|
||||
combatSoundManager_.reset();
|
||||
uiSoundManager_.reset();
|
||||
ambientSoundManager_.reset();
|
||||
npcVoiceManager_.reset();
|
||||
mountSoundManager_.reset();
|
||||
activitySoundManager_.reset();
|
||||
footstepManager_.reset();
|
||||
musicManager_.reset();
|
||||
|
||||
// Shutdown audio engine last
|
||||
if (audioAvailable_) {
|
||||
AudioEngine::instance().shutdown();
|
||||
audioAvailable_ = false;
|
||||
}
|
||||
|
||||
LOG_INFO("AudioCoordinator shutdown complete");
|
||||
}
|
||||
|
||||
} // namespace audio
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue