mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-24 00:00:13 +00:00
feat: flash action bar button red when spell cast fails
Add SpellCastFailedCallback to GameHandler, fired from SMSG_CAST_RESULT when result != 0. GameScreen registers the callback and records each failed spellId in actionFlashEndTimes_ (keyed by spell ID, value = expiry time). During action bar rendering, if a slot's spell has an active flash entry, an AddRectFilled overlay is drawn over the button with alpha proportional to remaining time (1.0→0.0 over 0.5 s), giving the same error-red flash visual feedback as the original WoW client.
This commit is contained in:
parent
c1765b6b39
commit
277a26b351
4 changed files with 41 additions and 0 deletions
|
|
@ -414,6 +414,16 @@ void GameScreen::render(game::GameHandler& gameHandler) {
|
|||
uiErrorCallbackSet_ = true;
|
||||
}
|
||||
|
||||
// Flash the action bar button whose spell just failed (0.5 s red overlay).
|
||||
if (!castFailedCallbackSet_) {
|
||||
gameHandler.setSpellCastFailedCallback([this](uint32_t spellId) {
|
||||
if (spellId == 0) return;
|
||||
float now = static_cast<float>(ImGui::GetTime());
|
||||
actionFlashEndTimes_[spellId] = now + kActionFlashDuration;
|
||||
});
|
||||
castFailedCallbackSet_ = true;
|
||||
}
|
||||
|
||||
// Set up reputation change toast callback (once)
|
||||
if (!repChangeCallbackSet_) {
|
||||
gameHandler.setRepChangeCallback([this](const std::string& name, int32_t delta, int32_t standing) {
|
||||
|
|
@ -8435,6 +8445,25 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
|
|||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
// Error-flash overlay: red fade on spell cast failure (~0.5 s).
|
||||
if (slot.type == game::ActionBarSlot::SPELL && slot.id != 0) {
|
||||
auto flashIt = actionFlashEndTimes_.find(slot.id);
|
||||
if (flashIt != actionFlashEndTimes_.end()) {
|
||||
float now = static_cast<float>(ImGui::GetTime());
|
||||
float remaining = flashIt->second - now;
|
||||
if (remaining > 0.0f) {
|
||||
float alpha = remaining / kActionFlashDuration; // 1→0
|
||||
ImVec2 rMin = ImGui::GetItemRectMin();
|
||||
ImVec2 rMax = ImGui::GetItemRectMax();
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(
|
||||
rMin, rMax,
|
||||
ImGui::ColorConvertFloat4ToU32(ImVec4(1.0f, 0.1f, 0.1f, 0.55f * alpha)));
|
||||
} else {
|
||||
actionFlashEndTimes_.erase(flashIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hoveredOnRelease = ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) &&
|
||||
ImGui::IsMouseReleased(ImGuiMouseButton_Left);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue