chore(renderer): extract AnimationController and remove audio pass-throughs

Extract ~1,500 lines of character animation state from Renderer into a dedicated
AnimationController class, and complete the AudioCoordinator migration by removing
all 10 audio pass-through getters from Renderer.

AnimationController:
- New: include/rendering/animation_controller.hpp (182 lines)
- New: src/rendering/animation_controller.cpp (1,703 lines)
- Moves: locomotion state machine (50+ members), mount animation (40+ members),
  emote system, footstep triggering, surface detection, melee combat animations
- Renderer holds std::unique_ptr<AnimationController> and delegates completely
- AnimationController accesses audio via renderer_->getAudioCoordinator()

Audio caller migration:
- Migrate ~60 external callers from renderer->getXManager() to AudioCoordinator
  directly, grouped by access pattern:
  - UIServices: settings_panel, game_screen, toast_manager, chat_panel,
    combat_ui, window_manager
  - GameServices: game_handler, spell_handler, inventory_handler, quest_handler,
    social_handler, combat_handler
  - Application singleton: application.cpp, auth_screen.cpp, lua_engine.cpp
- Remove 10 pass-through getter definitions from renderer.cpp
- Remove 10 pass-through getter declarations from renderer.hpp
- Remove individual audio manager forward declarations from renderer.hpp
- Redirect 69 internal renderer.cpp audio calls to audioCoordinator_ directly
- game_handler.cpp: withSoundManager template uses services_.audioCoordinator;
  MFP changed from &Renderer::getUiSoundManager to &AudioCoordinator::getUiSoundManager
- GameServices struct: add AudioCoordinator* audioCoordinator member
- settings_panel: applyAudioVolumes(Renderer*) -> applyAudioVolumes(AudioCoordinator*)
This commit is contained in:
Paul 2026-04-02 13:06:31 +03:00
parent 5ef600098a
commit 5af9f7aa4b
22 changed files with 2208 additions and 1958 deletions

View file

@ -6,6 +6,7 @@
#include "core/logger.hpp"
#include "core/application.hpp"
#include "rendering/renderer.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/ui_sound_manager.hpp"
#include "game/expansion_profile.hpp"
#include <imgui.h>
@ -1003,9 +1004,9 @@ static int lua_IsInRaid(lua_State* L) {
// PlaySound(soundId) — play a WoW UI sound by ID or name
static int lua_PlaySound(lua_State* L) {
auto* renderer = core::Application::getInstance().getRenderer();
if (!renderer) return 0;
auto* sfx = renderer->getUiSoundManager();
auto* ac = core::Application::getInstance().getAudioCoordinator();
if (!ac) return 0;
auto* sfx = ac->getUiSoundManager();
if (!sfx) return 0;
// Accept numeric sound ID or string name

View file

@ -152,6 +152,7 @@ bool Application::initialize() {
// Populate game services — all subsystems now available
gameServices_.renderer = renderer.get();
gameServices_.audioCoordinator = audioCoordinator_.get();
gameServices_.assetManager = assetManager.get();
gameServices_.expansionRegistry = expansionRegistry_.get();
@ -1091,7 +1092,7 @@ void Application::logoutToLogin() {
}
renderer->clearMount();
renderer->setCharacterFollow(0);
if (auto* music = renderer->getMusicManager()) {
if (auto* music = audioCoordinator_ ? audioCoordinator_->getMusicManager() : nullptr) {
music->stopMusic(0.0f);
}
}
@ -2828,7 +2829,7 @@ void Application::setupUICallbacks() {
// Resolves soundId → SoundEntries.dbc → MPQ path → MusicManager.
gameHandler->setPlayMusicCallback([this](uint32_t soundId) {
if (!assetManager || !renderer) return;
auto* music = renderer->getMusicManager();
auto* music = audioCoordinator_ ? audioCoordinator_->getMusicManager() : nullptr;
if (!music) return;
auto dbc = assetManager->loadDBC("SoundEntries.dbc");
@ -3418,7 +3419,7 @@ void Application::setupUICallbacks() {
// NPC greeting callback - play voice line
gameHandler->setNpcGreetingCallback([this](uint64_t guid, const glm::vec3& position) {
if (renderer && renderer->getNpcVoiceManager()) {
if (audioCoordinator_ && audioCoordinator_->getNpcVoiceManager()) {
// Convert canonical to render coords for 3D audio
glm::vec3 renderPos = core::coords::canonicalToRender(position);
@ -3431,13 +3432,13 @@ void Application::setupUICallbacks() {
voiceType = entitySpawner_->detectVoiceTypeFromDisplayId(displayId);
}
renderer->getNpcVoiceManager()->playGreeting(guid, voiceType, renderPos);
audioCoordinator_->getNpcVoiceManager()->playGreeting(guid, voiceType, renderPos);
}
});
// NPC farewell callback - play farewell voice line
gameHandler->setNpcFarewellCallback([this](uint64_t guid, const glm::vec3& position) {
if (renderer && renderer->getNpcVoiceManager()) {
if (audioCoordinator_ && audioCoordinator_->getNpcVoiceManager()) {
glm::vec3 renderPos = core::coords::canonicalToRender(position);
audio::VoiceType voiceType = audio::VoiceType::GENERIC;
@ -3448,13 +3449,13 @@ void Application::setupUICallbacks() {
voiceType = entitySpawner_->detectVoiceTypeFromDisplayId(displayId);
}
renderer->getNpcVoiceManager()->playFarewell(guid, voiceType, renderPos);
audioCoordinator_->getNpcVoiceManager()->playFarewell(guid, voiceType, renderPos);
}
});
// NPC vendor callback - play vendor voice line
gameHandler->setNpcVendorCallback([this](uint64_t guid, const glm::vec3& position) {
if (renderer && renderer->getNpcVoiceManager()) {
if (audioCoordinator_ && audioCoordinator_->getNpcVoiceManager()) {
glm::vec3 renderPos = core::coords::canonicalToRender(position);
audio::VoiceType voiceType = audio::VoiceType::GENERIC;
@ -3465,13 +3466,13 @@ void Application::setupUICallbacks() {
voiceType = entitySpawner_->detectVoiceTypeFromDisplayId(displayId);
}
renderer->getNpcVoiceManager()->playVendor(guid, voiceType, renderPos);
audioCoordinator_->getNpcVoiceManager()->playVendor(guid, voiceType, renderPos);
}
});
// NPC aggro callback - play combat start voice line
gameHandler->setNpcAggroCallback([this](uint64_t guid, const glm::vec3& position) {
if (renderer && renderer->getNpcVoiceManager()) {
if (audioCoordinator_ && audioCoordinator_->getNpcVoiceManager()) {
glm::vec3 renderPos = core::coords::canonicalToRender(position);
audio::VoiceType voiceType = audio::VoiceType::GENERIC;
@ -3482,7 +3483,7 @@ void Application::setupUICallbacks() {
voiceType = entitySpawner_->detectVoiceTypeFromDisplayId(displayId);
}
renderer->getNpcVoiceManager()->playAggro(guid, voiceType, renderPos);
audioCoordinator_->getNpcVoiceManager()->playAggro(guid, voiceType, renderPos);
}
});
@ -3718,7 +3719,7 @@ void Application::spawnPlayerCharacter() {
playerCharacterSpawned = true;
// Set voice profile to match character race/gender
if (auto* asm_ = renderer->getActivitySoundManager()) {
if (auto* asm_ = audioCoordinator_ ? audioCoordinator_->getActivitySoundManager() : nullptr) {
const char* raceFolder = "Human";
const char* raceBase = "Human";
switch (playerRace_) {

View file

@ -6,6 +6,7 @@
#include "game/update_field_table.hpp"
#include "game/opcode_table.hpp"
#include "rendering/renderer.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/combat_sound_manager.hpp"
#include "audio/activity_sound_manager.hpp"
#include "core/application.hpp"
@ -451,8 +452,8 @@ void CombatHandler::handleAttackerStateUpdate(network::Packet& packet) {
}
// Play combat sounds via CombatSoundManager + character vocalizations
if (auto* renderer = owner_.services().renderer) {
if (auto* csm = renderer->getCombatSoundManager()) {
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* csm = ac->getCombatSoundManager()) {
auto weaponSize = audio::CombatSoundManager::WeaponSize::MEDIUM;
if (data.isMiss()) {
csm->playWeaponMiss(false);
@ -466,7 +467,7 @@ void CombatHandler::handleAttackerStateUpdate(network::Packet& packet) {
}
}
// Character vocalizations
if (auto* asm_ = renderer->getActivitySoundManager()) {
if (auto* asm_ = ac->getActivitySoundManager()) {
if (isPlayerAttacker && !data.isMiss() && data.victimState != 1 && data.victimState != 2) {
asm_->playAttackGrunt();
}

View file

@ -17,6 +17,7 @@
#include "game/update_field_table.hpp"
#include "game/expansion_profile.hpp"
#include "rendering/renderer.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/activity_sound_manager.hpp"
#include "audio/combat_sound_manager.hpp"
#include "audio/spell_sound_manager.hpp"
@ -599,8 +600,8 @@ static QuestQueryRewards tryParseQuestRewards(const std::vector<uint8_t>& data,
template<typename ManagerGetter, typename Callback>
void GameHandler::withSoundManager(ManagerGetter getter, Callback cb) {
if (auto* renderer = services_.renderer) {
if (auto* mgr = (renderer->*getter)()) cb(mgr);
if (auto* ac = services_.audioCoordinator) {
if (auto* mgr = (ac->*getter)()) cb(mgr);
}
}
@ -1198,9 +1199,9 @@ void GameHandler::updateTimers(float deltaTime) {
}
if (!alreadyAnnounced && pendingLootMoneyAmount_ > 0) {
addSystemChatMessage("Looted: " + formatCopperAmount(pendingLootMoneyAmount_));
auto* renderer = services_.renderer;
if (renderer) {
if (auto* sfx = renderer->getUiSoundManager()) {
auto* ac = services_.audioCoordinator;
if (ac) {
if (auto* sfx = ac->getUiSoundManager()) {
if (pendingLootMoneyAmount_ >= 10000) {
sfx->playLootCoinLarge();
} else {
@ -1974,7 +1975,7 @@ void GameHandler::registerOpcodeHandlers() {
ping.age = 0.0f;
minimapPings_.push_back(ping);
if (senderGuid != playerGuid) {
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playMinimapPing(); });
withSoundManager(&audio::AudioCoordinator::getUiSoundManager, [](auto* sfx) { sfx->playMinimapPing(); });
}
};
dispatchTable_[Opcode::SMSG_ZONE_UNDER_ATTACK] = [this](network::Packet& packet) {
@ -2124,7 +2125,7 @@ void GameHandler::registerOpcodeHandlers() {
if (info && info->type == 17) {
addUIError("A fish is on your line!");
addSystemChatMessage("A fish is on your line!");
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playQuestUpdate(); });
withSoundManager(&audio::AudioCoordinator::getUiSoundManager, [](auto* sfx) { sfx->playQuestUpdate(); });
}
}
}
@ -2350,7 +2351,7 @@ void GameHandler::registerOpcodeHandlers() {
}
if (newLevel > oldLevel) {
addSystemChatMessage("You have reached level " + std::to_string(newLevel) + "!");
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playLevelUp(); });
withSoundManager(&audio::AudioCoordinator::getUiSoundManager, [](auto* sfx) { sfx->playLevelUp(); });
if (levelUpCallback_) levelUpCallback_(newLevel);
fireAddonEvent("PLAYER_LEVEL_UP", {std::to_string(newLevel)});
}

View file

@ -4,6 +4,7 @@
#include "game/entity.hpp"
#include "game/packet_parsers.hpp"
#include "rendering/renderer.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/ui_sound_manager.hpp"
#include "core/application.hpp"
#include "core/logger.hpp"
@ -70,9 +71,9 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
}
if (!alreadyAnnounced) {
owner_.addSystemChatMessage("Looted: " + formatCopperAmount(amount));
auto* renderer = owner_.services().renderer;
if (renderer) {
if (auto* sfx = renderer->getUiSoundManager()) {
auto* ac = owner_.services().audioCoordinator;
if (ac) {
if (auto* sfx = ac->getUiSoundManager()) {
if (amount >= 10000) sfx->playLootCoinLarge();
else sfx->playLootCoinSmall();
}
@ -222,8 +223,8 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
std::string msg = "Received item: " + link;
if (count > 1) msg += " x" + std::to_string(count);
owner_.addSystemChatMessage(msg);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playLootItem();
}
if (owner_.addonEventCallback_) {
@ -253,8 +254,8 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
" result=", static_cast<int>(result));
if (result == 0) {
pendingSellToBuyback_.erase(itemGuid);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playDropOnGround();
}
if (owner_.addonEventCallback_) {
@ -295,8 +296,8 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
const char* msg = (result < 7) ? sellErrors[result] : "Unknown sell error";
owner_.addUIError(std::string("Sell failed: ") + msg);
owner_.addSystemChatMessage(std::string("Sell failed: ") + msg);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playError();
}
LOG_WARNING("SMSG_SELL_ITEM error: ", (int)result, " (", msg, ")");
@ -392,8 +393,8 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
std::string msg = errMsg ? errMsg : "Inventory error (" + std::to_string(error) + ").";
owner_.addUIError(msg);
owner_.addSystemChatMessage(msg);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playError();
}
}
@ -450,8 +451,8 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
}
owner_.addUIError(msg);
owner_.addSystemChatMessage(msg);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playError();
}
}
@ -474,8 +475,8 @@ void InventoryHandler::registerOpcodes(DispatchTable& table) {
std::string msg = "Purchased: " + buildItemLink(pendingBuyItemId_, buyQuality, itemLabel);
if (itemCount > 1) msg += " x" + std::to_string(itemCount);
owner_.addSystemChatMessage(msg);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playPickupBag();
}
}
@ -766,8 +767,8 @@ void InventoryHandler::handleLootRemoved(network::Packet& packet) {
std::string msgStr = "Looted: " + link;
if (it->count > 1) msgStr += " x" + std::to_string(it->count);
owner_.addSystemChatMessage(msgStr);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playLootItem();
}
currentLoot_.items.erase(it);
@ -2382,8 +2383,8 @@ void InventoryHandler::handleItemQueryResponse(network::Packet& packet) {
std::string msg = "Received: " + link;
if (it->count > 1) msg += " x" + std::to_string(it->count);
owner_.addSystemChatMessage(msg);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager()) sfx->playLootItem();
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager()) sfx->playLootItem();
}
if (owner_.itemLootCallback_) owner_.itemLootCallback_(data.entry, it->count, data.quality, itemName);
it = owner_.pendingItemPushNotifs_.erase(it);
@ -3149,8 +3150,8 @@ void InventoryHandler::handleTrainerBuySucceeded(network::Packet& packet) {
owner_.addSystemChatMessage("You have learned " + name + ".");
else
owner_.addSystemChatMessage("Spell learned.");
if (auto* renderer = owner_.services().renderer)
if (auto* sfx = renderer->getUiSoundManager()) sfx->playQuestActivate();
if (auto* ac = owner_.services().audioCoordinator)
if (auto* sfx = ac->getUiSoundManager()) sfx->playQuestActivate();
owner_.fireAddonEvent("TRAINER_UPDATE", {});
owner_.fireAddonEvent("SPELLS_CHANGED", {});
}
@ -3171,8 +3172,8 @@ void InventoryHandler::handleTrainerBuyFailed(network::Packet& packet) {
else if (errorCode != 0) msg += " (error " + std::to_string(errorCode) + ")";
owner_.addUIError(msg);
owner_.addSystemChatMessage(msg);
if (auto* renderer = owner_.services().renderer)
if (auto* sfx = renderer->getUiSoundManager()) sfx->playError();
if (auto* ac = owner_.services().audioCoordinator)
if (auto* sfx = ac->getUiSoundManager()) sfx->playError();
}
// ============================================================

View file

@ -6,6 +6,7 @@
#include "game/packet_parsers.hpp"
#include "network/world_socket.hpp"
#include "rendering/renderer.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/ui_sound_manager.hpp"
#include "core/application.hpp"
#include "core/logger.hpp"
@ -469,8 +470,8 @@ void QuestHandler::registerOpcodes(DispatchTable& table) {
owner_.questCompleteCallback_(questId, it->title);
}
// Play quest-complete sound
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playQuestComplete();
}
questLog_.erase(it);
@ -1095,8 +1096,8 @@ void QuestHandler::acceptQuest() {
pendingQuestAcceptNpcGuids_[questId] = npcGuid;
// Play quest-accept sound
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playQuestActivate();
}

View file

@ -5,6 +5,7 @@
#include "game/packet_parsers.hpp"
#include "game/update_field_table.hpp"
#include "game/opcode_table.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/ui_sound_manager.hpp"
#include "network/world_socket.hpp"
#include "rendering/renderer.hpp"
@ -1053,8 +1054,8 @@ void SocialHandler::handleDuelRequested(network::Packet& packet) {
}
pendingDuelRequest_ = true;
owner_.addSystemChatMessage(duelChallengerName_ + " challenges you to a duel!");
if (auto* renderer = owner_.services().renderer)
if (auto* sfx = renderer->getUiSoundManager()) sfx->playTargetSelect();
if (auto* ac = owner_.services().audioCoordinator)
if (auto* sfx = ac->getUiSoundManager()) sfx->playTargetSelect();
if (owner_.addonEventCallback_) owner_.addonEventCallback_("DUEL_REQUESTED", {duelChallengerName_});
}
@ -1219,8 +1220,8 @@ void SocialHandler::handleGroupInvite(network::Packet& packet) {
pendingInviterName = data.inviterName;
if (!data.inviterName.empty())
owner_.addSystemChatMessage(data.inviterName + " has invited you to a group.");
if (auto* renderer = owner_.services().renderer)
if (auto* sfx = renderer->getUiSoundManager()) sfx->playTargetSelect();
if (auto* ac = owner_.services().audioCoordinator)
if (auto* sfx = ac->getUiSoundManager()) sfx->playTargetSelect();
if (owner_.addonEventCallback_)
owner_.addonEventCallback_("PARTY_INVITE_REQUEST", {data.inviterName});
}

View file

@ -4,6 +4,7 @@
#include "game/packet_parsers.hpp"
#include "game/entity.hpp"
#include "rendering/renderer.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/spell_sound_manager.hpp"
#include "audio/combat_sound_manager.hpp"
#include "core/application.hpp"
@ -795,8 +796,8 @@ void SpellHandler::handleCastFailed(network::Packet& packet) {
queuedSpellTarget_ = 0;
// Stop precast sound
if (auto* renderer = owner_.services().renderer) {
if (auto* ssm = renderer->getSpellSoundManager()) {
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* ssm = ac->getSpellSoundManager()) {
ssm->stopPrecast();
}
}
@ -817,8 +818,8 @@ void SpellHandler::handleCastFailed(network::Packet& packet) {
msg.message = errMsg;
owner_.addLocalChatMessage(msg);
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playError();
}
@ -869,8 +870,8 @@ void SpellHandler::handleSpellStart(network::Packet& packet) {
// Play precast sound — skip profession/tradeskill spells
if (!owner_.isProfessionSpell(data.spellId)) {
if (auto* renderer = owner_.services().renderer) {
if (auto* ssm = renderer->getSpellSoundManager()) {
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* ssm = ac->getSpellSoundManager()) {
owner_.loadSpellNameCache();
auto it = owner_.spellNameCache_.find(data.spellId);
auto school = (it != owner_.spellNameCache_.end() && it->second.schoolMask)
@ -907,8 +908,8 @@ void SpellHandler::handleSpellGo(network::Packet& packet) {
if (data.casterUnit == owner_.playerGuid) {
// Play cast-complete sound
if (!owner_.isProfessionSpell(data.spellId)) {
if (auto* renderer = owner_.services().renderer) {
if (auto* ssm = renderer->getSpellSoundManager()) {
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* ssm = ac->getSpellSoundManager()) {
owner_.loadSpellNameCache();
auto it = owner_.spellNameCache_.find(data.spellId);
auto school = (it != owner_.spellNameCache_.end() && it->second.schoolMask)
@ -931,8 +932,8 @@ void SpellHandler::handleSpellGo(network::Packet& packet) {
}
if (isMeleeAbility) {
if (owner_.meleeSwingCallback_) owner_.meleeSwingCallback_();
if (auto* renderer = owner_.services().renderer) {
if (auto* csm = renderer->getCombatSoundManager()) {
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* csm = ac->getCombatSoundManager()) {
csm->playWeaponSwing(audio::CombatSoundManager::WeaponSize::MEDIUM, false);
csm->playImpact(audio::CombatSoundManager::WeaponSize::MEDIUM,
audio::CombatSoundManager::ImpactType::FLESH, false);
@ -990,8 +991,8 @@ void SpellHandler::handleSpellGo(network::Packet& packet) {
if (tgt == owner_.playerGuid) { targetsPlayer = true; break; }
}
if (targetsPlayer) {
if (auto* renderer = owner_.services().renderer) {
if (auto* ssm = renderer->getSpellSoundManager()) {
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* ssm = ac->getSpellSoundManager()) {
owner_.loadSpellNameCache();
auto it = owner_.spellNameCache_.find(data.spellId);
auto school = (it != owner_.spellNameCache_.end() && it->second.schoolMask)
@ -1036,8 +1037,8 @@ void SpellHandler::handleSpellGo(network::Packet& packet) {
}
if (playerIsHit || playerHitEnemy) {
if (auto* renderer = owner_.services().renderer) {
if (auto* ssm = renderer->getSpellSoundManager()) {
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* ssm = ac->getSpellSoundManager()) {
owner_.loadSpellNameCache();
auto it = owner_.spellNameCache_.find(data.spellId);
auto school = (it != owner_.spellNameCache_.end() && it->second.schoolMask)
@ -1396,8 +1397,8 @@ void SpellHandler::handleAchievementEarned(network::Packet& packet) {
owner_.earnedAchievements_.insert(achievementId);
owner_.achievementDates_[achievementId] = earnDate;
if (auto* renderer = owner_.services().renderer) {
if (auto* sfx = renderer->getUiSoundManager())
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager())
sfx->playAchievementAlert();
}
if (owner_.achievementEarnedCallback_) {
@ -2350,8 +2351,8 @@ void SpellHandler::handleSpellFailure(network::Packet& packet) {
craftQueueRemaining_ = 0;
queuedSpellId_ = 0;
queuedSpellTarget_ = 0;
if (auto* renderer = owner_.services().renderer) {
if (auto* ssm = renderer->getSpellSoundManager()) {
if (auto* ac = owner_.services().audioCoordinator) {
if (auto* ssm = ac->getSpellSoundManager()) {
ssm->stopPrecast();
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,7 @@
#include "rendering/renderer.hpp"
#include "rendering/vk_context.hpp"
#include "pipeline/asset_manager.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/music_manager.hpp"
#include "game/expansion_profile.hpp"
#include <imgui.h>
@ -199,20 +200,20 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
}
auto& app = core::Application::getInstance();
auto* renderer = app.getRenderer();
auto* ac = app.getAudioCoordinator();
if (!musicInitAttempted) {
musicInitAttempted = true;
auto* assets = app.getAssetManager();
if (renderer) {
auto* music = renderer->getMusicManager();
if (ac) {
auto* music = ac->getMusicManager();
if (music && assets && assets->isInitialized() && !music->isInitialized()) {
music->initialize(assets);
}
}
}
// Login screen music
if (renderer) {
auto* music = renderer->getMusicManager();
if (ac) {
auto* music = ac->getMusicManager();
if (music) {
if (!loginMusicVolumeAdjusted_) {
savedMusicVolume_ = music->getVolume();
@ -506,9 +507,9 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
void AuthScreen::stopLoginMusic() {
auto& app = core::Application::getInstance();
auto* renderer = app.getRenderer();
if (!renderer) return;
auto* music = renderer->getMusicManager();
auto* ac = app.getAudioCoordinator();
if (!ac) return;
auto* music = ac->getMusicManager();
if (!music) return;
if (musicPlaying) {
music->stopMusic(500.0f);

View file

@ -11,6 +11,7 @@
#include "rendering/renderer.hpp"
#include "rendering/camera.hpp"
#include "rendering/camera_controller.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/audio_engine.hpp"
#include "audio/ui_sound_manager.hpp"
#include "pipeline/asset_manager.hpp"
@ -1109,8 +1110,8 @@ void ChatPanel::render(game::GameHandler& gameHandler,
std::string bodyLower = mMsg.message;
for (auto& c : bodyLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
if (bodyLower.find(selfNameLower) != std::string::npos) {
if (auto* renderer = services_.renderer) {
if (auto* ui = renderer->getUiSoundManager())
if (auto* ac = services_.audioCoordinator) {
if (auto* ui = ac->getUiSoundManager())
ui->playWhisperReceived();
}
break; // play at most once per scan pass

View file

@ -15,6 +15,7 @@
#include "rendering/camera.hpp"
#include "game/game_handler.hpp"
#include "pipeline/asset_manager.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/audio_engine.hpp"
#include "audio/ui_sound_manager.hpp"
#include <imgui.h>
@ -283,9 +284,11 @@ void CombatUI::renderRaidWarningOverlay(game::GameHandler& gameHandler) {
raidWarnEntries_.erase(raidWarnEntries_.begin());
}
// Whisper audio notification
if (msg.type == game::ChatType::WHISPER && renderer) {
if (auto* ui = renderer->getUiSoundManager())
ui->playWhisperReceived();
if (msg.type == game::ChatType::WHISPER) {
if (auto* ac = services_.audioCoordinator) {
if (auto* ui = ac->getUiSoundManager())
ui->playWhisperReceived();
}
}
}
raidWarnChatSeenCount_ = newCount;

View file

@ -14,6 +14,7 @@
#include "rendering/character_renderer.hpp"
#include "rendering/camera.hpp"
#include "rendering/camera_controller.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/audio_engine.hpp"
#include "audio/music_manager.hpp"
#include "game/zone_manager.hpp"
@ -285,8 +286,8 @@ void GameScreen::render(game::GameHandler& gameHandler) {
uiErrors_.push_back({msg, 0.0f});
if (uiErrors_.size() > 5) uiErrors_.erase(uiErrors_.begin());
// Play error sound for each new error (rate-limited by deque cap of 5)
if (auto* r = services_.renderer) {
if (auto* sfx = r->getUiSoundManager()) sfx->playError();
if (auto* ac = services_.audioCoordinator) {
if (auto* sfx = ac->getUiSoundManager()) sfx->playError();
}
});
uiErrorCallbackSet_ = true;
@ -345,9 +346,9 @@ void GameScreen::render(game::GameHandler& gameHandler) {
// Apply saved volume settings once when audio managers first become available
if (!settingsPanel_.volumeSettingsApplied_) {
auto* renderer = services_.renderer;
if (renderer && renderer->getUiSoundManager()) {
settingsPanel_.applyAudioVolumes(renderer);
auto* ac = services_.audioCoordinator;
if (ac && ac->getUiSoundManager()) {
settingsPanel_.applyAudioVolumes(ac);
settingsPanel_.volumeSettingsApplied_ = true;
}
}
@ -6525,38 +6526,38 @@ void GameScreen::renderMinimapMarkers(game::GameHandler& gameHandler) {
}
auto applyMuteState = [&]() {
auto* activeRenderer = services_.renderer;
auto* ac = services_.audioCoordinator;
float masterScale = settingsPanel_.soundMuted_ ? 0.0f : static_cast<float>(settingsPanel_.pendingMasterVolume) / 100.0f;
audio::AudioEngine::instance().setMasterVolume(masterScale);
if (!activeRenderer) return;
if (auto* music = activeRenderer->getMusicManager()) {
if (!ac) return;
if (auto* music = ac->getMusicManager()) {
music->setVolume(settingsPanel_.pendingMusicVolume);
}
if (auto* ambient = activeRenderer->getAmbientSoundManager()) {
if (auto* ambient = ac->getAmbientSoundManager()) {
ambient->setVolumeScale(settingsPanel_.pendingAmbientVolume / 100.0f);
}
if (auto* ui = activeRenderer->getUiSoundManager()) {
if (auto* ui = ac->getUiSoundManager()) {
ui->setVolumeScale(settingsPanel_.pendingUiVolume / 100.0f);
}
if (auto* combat = activeRenderer->getCombatSoundManager()) {
if (auto* combat = ac->getCombatSoundManager()) {
combat->setVolumeScale(settingsPanel_.pendingCombatVolume / 100.0f);
}
if (auto* spell = activeRenderer->getSpellSoundManager()) {
if (auto* spell = ac->getSpellSoundManager()) {
spell->setVolumeScale(settingsPanel_.pendingSpellVolume / 100.0f);
}
if (auto* movement = activeRenderer->getMovementSoundManager()) {
if (auto* movement = ac->getMovementSoundManager()) {
movement->setVolumeScale(settingsPanel_.pendingMovementVolume / 100.0f);
}
if (auto* footstep = activeRenderer->getFootstepManager()) {
if (auto* footstep = ac->getFootstepManager()) {
footstep->setVolumeScale(settingsPanel_.pendingFootstepVolume / 100.0f);
}
if (auto* npcVoice = activeRenderer->getNpcVoiceManager()) {
if (auto* npcVoice = ac->getNpcVoiceManager()) {
npcVoice->setVolumeScale(settingsPanel_.pendingNpcVoiceVolume / 100.0f);
}
if (auto* mount = activeRenderer->getMountSoundManager()) {
if (auto* mount = ac->getMountSoundManager()) {
mount->setVolumeScale(settingsPanel_.pendingMountVolume / 100.0f);
}
if (auto* activity = activeRenderer->getActivitySoundManager()) {
if (auto* activity = ac->getActivitySoundManager()) {
activity->setVolumeScale(settingsPanel_.pendingActivityVolume / 100.0f);
}
};

View file

@ -17,6 +17,7 @@
#include "rendering/wmo_renderer.hpp"
#include "rendering/character_renderer.hpp"
#include "game/zone_manager.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/audio_engine.hpp"
#include "audio/music_manager.hpp"
#include "audio/ambient_sound_manager.hpp"
@ -439,7 +440,7 @@ ImGui::BeginChild("AudioSettings", ImVec2(0, 360), true);
// Helper lambda to apply audio settings
auto applyAudioSettings = [&]() {
applyAudioVolumes(renderer);
applyAudioVolumes(services_.audioCoordinator);
saveCallback();
};
@ -1227,29 +1228,29 @@ std::string SettingsPanel::getSettingsPath() {
return dir + "/settings.cfg";
}
void SettingsPanel::applyAudioVolumes(rendering::Renderer* renderer) {
if (!renderer) return;
void SettingsPanel::applyAudioVolumes(audio::AudioCoordinator* ac) {
if (!ac) return;
float masterScale = soundMuted_ ? 0.0f : static_cast<float>(pendingMasterVolume) / 100.0f;
audio::AudioEngine::instance().setMasterVolume(masterScale);
if (auto* music = renderer->getMusicManager())
if (auto* music = ac->getMusicManager())
music->setVolume(pendingMusicVolume);
if (auto* ambient = renderer->getAmbientSoundManager())
if (auto* ambient = ac->getAmbientSoundManager())
ambient->setVolumeScale(pendingAmbientVolume / 100.0f);
if (auto* ui = renderer->getUiSoundManager())
if (auto* ui = ac->getUiSoundManager())
ui->setVolumeScale(pendingUiVolume / 100.0f);
if (auto* combat = renderer->getCombatSoundManager())
if (auto* combat = ac->getCombatSoundManager())
combat->setVolumeScale(pendingCombatVolume / 100.0f);
if (auto* spell = renderer->getSpellSoundManager())
if (auto* spell = ac->getSpellSoundManager())
spell->setVolumeScale(pendingSpellVolume / 100.0f);
if (auto* movement = renderer->getMovementSoundManager())
if (auto* movement = ac->getMovementSoundManager())
movement->setVolumeScale(pendingMovementVolume / 100.0f);
if (auto* footstep = renderer->getFootstepManager())
if (auto* footstep = ac->getFootstepManager())
footstep->setVolumeScale(pendingFootstepVolume / 100.0f);
if (auto* npcVoice = renderer->getNpcVoiceManager())
if (auto* npcVoice = ac->getNpcVoiceManager())
npcVoice->setVolumeScale(pendingNpcVoiceVolume / 100.0f);
if (auto* mount = renderer->getMountSoundManager())
if (auto* mount = ac->getMountSoundManager())
mount->setVolumeScale(pendingMountVolume / 100.0f);
if (auto* activity = renderer->getActivitySoundManager())
if (auto* activity = ac->getActivitySoundManager())
activity->setVolumeScale(pendingActivityVolume / 100.0f);
}

View file

@ -2,6 +2,7 @@
#include "game/game_handler.hpp"
#include "core/application.hpp"
#include "rendering/renderer.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/ui_sound_manager.hpp"
#include <imgui.h>
@ -461,11 +462,13 @@ void ToastManager::triggerDing(uint32_t newLevel, uint32_t hpDelta, uint32_t man
dingStats_[3] = intel;
dingStats_[4] = spi;
auto* renderer = services_.renderer;
if (renderer) {
if (auto* sfx = renderer->getUiSoundManager()) {
auto* ac = services_.audioCoordinator;
if (ac) {
if (auto* sfx = ac->getUiSoundManager()) {
sfx->playLevelUp();
}
}
if (auto* renderer = services_.renderer) {
renderer->playEmote("cheer");
}
}
@ -550,9 +553,9 @@ void ToastManager::triggerAchievementToast(uint32_t achievementId, std::string n
achievementToastTimer_ = ACHIEVEMENT_TOAST_DURATION;
// Play a UI sound if available
auto* renderer = services_.renderer;
if (renderer) {
if (auto* sfx = renderer->getUiSoundManager()) {
auto* ac = services_.audioCoordinator;
if (ac) {
if (auto* sfx = ac->getUiSoundManager()) {
sfx->playAchievementAlert();
}
}

View file

@ -16,6 +16,7 @@
#include "game/game_handler.hpp"
#include "pipeline/asset_manager.hpp"
#include "pipeline/dbc_layout.hpp"
#include "audio/audio_coordinator.hpp"
#include "audio/ui_sound_manager.hpp"
#include "audio/music_manager.hpp"
#include <imgui.h>
@ -1701,9 +1702,9 @@ void WindowManager::renderEscapeMenu(SettingsPanel& settingsPanel) {
settingsPanel.showEscapeSettingsNotice = false;
}
if (ImGui::Button("Quit", ImVec2(-1, 0))) {
auto* renderer = services_.renderer;
if (renderer) {
if (auto* music = renderer->getMusicManager()) {
auto* ac = services_.audioCoordinator;
if (ac) {
if (auto* music = ac->getMusicManager()) {
music->stopMusic(0.0f);
}
}