mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
refactor: convert 15 more renderer+sound patterns to withSoundManager
Replace 15 additional 3-line renderer acquisition + sound manager null-check blocks with single-line withSoundManager() calls. Total 22 sites now use the helper; 11 remaining have complex multi-line bodies or non-sound renderer usage.
This commit is contained in:
parent
ea15740e17
commit
0f19ed40f8
1 changed files with 15 additions and 59 deletions
|
|
@ -3529,9 +3529,7 @@ void GameHandler::registerOpcodeHandlers() {
|
||||||
if (info && info->type == 17) {
|
if (info && info->type == 17) {
|
||||||
addUIError("A fish is on your line!");
|
addUIError("A fish is on your line!");
|
||||||
addSystemChatMessage("A fish is on your line!");
|
addSystemChatMessage("A fish is on your line!");
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer())
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playQuestUpdate(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playQuestUpdate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4265,10 +4263,7 @@ void GameHandler::registerOpcodeHandlers() {
|
||||||
}
|
}
|
||||||
if (newLevel > oldLevel) {
|
if (newLevel > oldLevel) {
|
||||||
addSystemChatMessage("You have reached level " + std::to_string(newLevel) + "!");
|
addSystemChatMessage("You have reached level " + std::to_string(newLevel) + "!");
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playLevelUp(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playLevelUp();
|
|
||||||
}
|
|
||||||
if (levelUpCallback_) levelUpCallback_(newLevel);
|
if (levelUpCallback_) levelUpCallback_(newLevel);
|
||||||
fireAddonEvent("PLAYER_LEVEL_UP", {std::to_string(newLevel)});
|
fireAddonEvent("PLAYER_LEVEL_UP", {std::to_string(newLevel)});
|
||||||
}
|
}
|
||||||
|
|
@ -4290,10 +4285,7 @@ void GameHandler::registerOpcodeHandlers() {
|
||||||
" result=", static_cast<int>(result));
|
" result=", static_cast<int>(result));
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
pendingSellToBuyback_.erase(itemGuid);
|
pendingSellToBuyback_.erase(itemGuid);
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playDropOnGround(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playDropOnGround();
|
|
||||||
}
|
|
||||||
fireAddonEvent("BAG_UPDATE", {});
|
fireAddonEvent("BAG_UPDATE", {});
|
||||||
fireAddonEvent("PLAYER_MONEY", {});
|
fireAddonEvent("PLAYER_MONEY", {});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -4333,10 +4325,7 @@ void GameHandler::registerOpcodeHandlers() {
|
||||||
const char* msg = (result < 7) ? sellErrors[result] : "Unknown sell error";
|
const char* msg = (result < 7) ? sellErrors[result] : "Unknown sell error";
|
||||||
addUIError(std::string("Sell failed: ") + msg);
|
addUIError(std::string("Sell failed: ") + msg);
|
||||||
addSystemChatMessage(std::string("Sell failed: ") + msg);
|
addSystemChatMessage(std::string("Sell failed: ") + msg);
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playError(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playError();
|
|
||||||
}
|
|
||||||
LOG_WARNING("SMSG_SELL_ITEM error: ", static_cast<int>(result), " (", msg, ")");
|
LOG_WARNING("SMSG_SELL_ITEM error: ", static_cast<int>(result), " (", msg, ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4434,10 +4423,7 @@ void GameHandler::registerOpcodeHandlers() {
|
||||||
std::string msg = errMsg ? errMsg : "Inventory error (" + std::to_string(error) + ").";
|
std::string msg = errMsg ? errMsg : "Inventory error (" + std::to_string(error) + ").";
|
||||||
addUIError(msg);
|
addUIError(msg);
|
||||||
addSystemChatMessage(msg);
|
addSystemChatMessage(msg);
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playError(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -4500,10 +4486,7 @@ void GameHandler::registerOpcodeHandlers() {
|
||||||
}
|
}
|
||||||
addUIError(msg);
|
addUIError(msg);
|
||||||
addSystemChatMessage(msg);
|
addSystemChatMessage(msg);
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playError(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -4528,10 +4511,7 @@ void GameHandler::registerOpcodeHandlers() {
|
||||||
std::string msg = "Purchased: " + buildItemLink(pendingBuyItemId_, buyQuality, itemLabel);
|
std::string msg = "Purchased: " + buildItemLink(pendingBuyItemId_, buyQuality, itemLabel);
|
||||||
if (itemCount > 1) msg += " x" + std::to_string(itemCount);
|
if (itemCount > 1) msg += " x" + std::to_string(itemCount);
|
||||||
addSystemChatMessage(msg);
|
addSystemChatMessage(msg);
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playPickupBag(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playPickupBag();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pendingBuyItemId_ = 0;
|
pendingBuyItemId_ = 0;
|
||||||
pendingBuyItemSlot_ = 0;
|
pendingBuyItemSlot_ = 0;
|
||||||
|
|
@ -4985,10 +4965,7 @@ void GameHandler::registerOpcodeHandlers() {
|
||||||
questCompleteCallback_(questId, it->title);
|
questCompleteCallback_(questId, it->title);
|
||||||
}
|
}
|
||||||
// Play quest-complete sound
|
// Play quest-complete sound
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playQuestComplete(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playQuestComplete();
|
|
||||||
}
|
|
||||||
questLog_.erase(it);
|
questLog_.erase(it);
|
||||||
LOG_INFO(" Removed quest ", questId, " from quest log");
|
LOG_INFO(" Removed quest ", questId, " from quest log");
|
||||||
fireAddonEvent("QUEST_TURNED_IN", {std::to_string(questId)});
|
fireAddonEvent("QUEST_TURNED_IN", {std::to_string(questId)});
|
||||||
|
|
@ -13520,10 +13497,7 @@ void GameHandler::handleDuelRequested(network::Packet& packet) {
|
||||||
pendingDuelRequest_ = true;
|
pendingDuelRequest_ = true;
|
||||||
|
|
||||||
addSystemChatMessage(duelChallengerName_ + " challenges you to a duel!");
|
addSystemChatMessage(duelChallengerName_ + " challenges you to a duel!");
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playTargetSelect(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playTargetSelect();
|
|
||||||
}
|
|
||||||
LOG_INFO("SMSG_DUEL_REQUESTED: challenger=0x", std::hex, duelChallengerGuid_,
|
LOG_INFO("SMSG_DUEL_REQUESTED: challenger=0x", std::hex, duelChallengerGuid_,
|
||||||
" flag=0x", duelFlagGuid_, std::dec, " name=", duelChallengerName_);
|
" flag=0x", duelFlagGuid_, std::dec, " name=", duelChallengerName_);
|
||||||
fireAddonEvent("DUEL_REQUESTED", {duelChallengerName_});
|
fireAddonEvent("DUEL_REQUESTED", {duelChallengerName_});
|
||||||
|
|
@ -14315,10 +14289,7 @@ void GameHandler::handleItemQueryResponse(network::Packet& packet) {
|
||||||
std::string msg = "Received: " + link;
|
std::string msg = "Received: " + link;
|
||||||
if (it->count > 1) msg += " x" + std::to_string(it->count);
|
if (it->count > 1) msg += " x" + std::to_string(it->count);
|
||||||
addSystemChatMessage(msg);
|
addSystemChatMessage(msg);
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playLootItem(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playLootItem();
|
|
||||||
}
|
|
||||||
if (itemLootCallback_) itemLootCallback_(data.entry, it->count, data.quality, itemName);
|
if (itemLootCallback_) itemLootCallback_(data.entry, it->count, data.quality, itemName);
|
||||||
it = pendingItemPushNotifs_.erase(it);
|
it = pendingItemPushNotifs_.erase(it);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -18450,10 +18421,7 @@ void GameHandler::handleCastFailed(network::Packet& packet) {
|
||||||
addLocalChatMessage(msg);
|
addLocalChatMessage(msg);
|
||||||
|
|
||||||
// Play error sound for cast failure feedback
|
// Play error sound for cast failure feedback
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playError(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playError();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire UNIT_SPELLCAST_FAILED + UNIT_SPELLCAST_STOP so Lua addons can react
|
// Fire UNIT_SPELLCAST_FAILED + UNIT_SPELLCAST_STOP so Lua addons can react
|
||||||
fireAddonEvent("UNIT_SPELLCAST_FAILED", {"player", std::to_string(data.spellId)});
|
fireAddonEvent("UNIT_SPELLCAST_FAILED", {"player", std::to_string(data.spellId)});
|
||||||
|
|
@ -19177,10 +19145,7 @@ void GameHandler::handleGroupInvite(network::Packet& packet) {
|
||||||
if (!data.inviterName.empty()) {
|
if (!data.inviterName.empty()) {
|
||||||
addSystemChatMessage(data.inviterName + " has invited you to a group.");
|
addSystemChatMessage(data.inviterName + " has invited you to a group.");
|
||||||
}
|
}
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playTargetSelect(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playTargetSelect();
|
|
||||||
}
|
|
||||||
fireAddonEvent("PARTY_INVITE_REQUEST", {data.inviterName});
|
fireAddonEvent("PARTY_INVITE_REQUEST", {data.inviterName});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20792,10 +20757,7 @@ void GameHandler::acceptQuest() {
|
||||||
pendingQuestAcceptNpcGuids_[questId] = npcGuid;
|
pendingQuestAcceptNpcGuids_[questId] = npcGuid;
|
||||||
|
|
||||||
// Play quest-accept sound
|
// Play quest-accept sound
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playQuestActivate(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playQuestActivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
questDetailsOpen = false;
|
questDetailsOpen = false;
|
||||||
questDetailsOpenTime = std::chrono::steady_clock::time_point{};
|
questDetailsOpenTime = std::chrono::steady_clock::time_point{};
|
||||||
|
|
@ -21589,10 +21551,7 @@ void GameHandler::handleLootRemoved(network::Packet& packet) {
|
||||||
std::string msgStr = "Looted: " + link;
|
std::string msgStr = "Looted: " + link;
|
||||||
if (it->count > 1) msgStr += " x" + std::to_string(it->count);
|
if (it->count > 1) msgStr += " x" + std::to_string(it->count);
|
||||||
addSystemChatMessage(msgStr);
|
addSystemChatMessage(msgStr);
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playLootItem(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playLootItem();
|
|
||||||
}
|
|
||||||
currentLoot.items.erase(it);
|
currentLoot.items.erase(it);
|
||||||
fireAddonEvent("LOOT_SLOT_CLEARED", {std::to_string(slotIndex + 1)});
|
fireAddonEvent("LOOT_SLOT_CLEARED", {std::to_string(slotIndex + 1)});
|
||||||
break;
|
break;
|
||||||
|
|
@ -25623,10 +25582,7 @@ void GameHandler::handleAchievementEarned(network::Packet& packet) {
|
||||||
|
|
||||||
earnedAchievements_.insert(achievementId);
|
earnedAchievements_.insert(achievementId);
|
||||||
achievementDates_[achievementId] = earnDate;
|
achievementDates_[achievementId] = earnDate;
|
||||||
if (auto* renderer = core::Application::getInstance().getRenderer()) {
|
withSoundManager(&rendering::Renderer::getUiSoundManager, [](auto* sfx) { sfx->playAchievementAlert(); });
|
||||||
if (auto* sfx = renderer->getUiSoundManager())
|
|
||||||
sfx->playAchievementAlert();
|
|
||||||
}
|
|
||||||
if (achievementEarnedCallback_) {
|
if (achievementEarnedCallback_) {
|
||||||
achievementEarnedCallback_(achievementId, achName);
|
achievementEarnedCallback_(achievementId, achName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue