mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +00:00
feat: add gold glow when action bar spell comes off cooldown
When a spell's cooldown expires, its action bar slot briefly animates with a pulsing gold border (4 pulses over 1.5 seconds, fading out) to draw attention that the ability is ready again. Uses per-slot state tracking with static maps inside the render lambda.
This commit is contained in:
parent
c35bf8d953
commit
8efdaed7e4
1 changed files with 34 additions and 0 deletions
|
|
@ -5127,6 +5127,40 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ready glow: animate a gold border for ~1.5s when a cooldown just expires
|
||||
{
|
||||
static std::unordered_map<int, float> slotGlowTimers; // absSlot -> remaining glow seconds
|
||||
static std::unordered_map<int, bool> slotWasOnCooldown; // absSlot -> last frame state
|
||||
|
||||
float dt = ImGui::GetIO().DeltaTime;
|
||||
bool wasOnCd = slotWasOnCooldown.count(absSlot) ? slotWasOnCooldown[absSlot] : false;
|
||||
|
||||
// Trigger glow when transitioning from on-cooldown to ready (and slot isn't empty)
|
||||
if (wasOnCd && !onCooldown && !slot.isEmpty()) {
|
||||
slotGlowTimers[absSlot] = 1.5f;
|
||||
}
|
||||
slotWasOnCooldown[absSlot] = onCooldown;
|
||||
|
||||
auto git = slotGlowTimers.find(absSlot);
|
||||
if (git != slotGlowTimers.end() && git->second > 0.0f) {
|
||||
git->second -= dt;
|
||||
float t = git->second / 1.5f; // 1.0 → 0.0 over lifetime
|
||||
// Pulse: bright when fresh, fading out
|
||||
float pulse = std::sin(t * IM_PI * 4.0f) * 0.5f + 0.5f; // 4 pulses
|
||||
uint8_t alpha = static_cast<uint8_t>(200 * t * (0.5f + 0.5f * pulse));
|
||||
if (alpha > 0) {
|
||||
ImVec2 bMin = ImGui::GetItemRectMin();
|
||||
ImVec2 bMax = ImGui::GetItemRectMax();
|
||||
auto* gdl = ImGui::GetWindowDrawList();
|
||||
// Gold glow border (2px inset, 3px thick)
|
||||
gdl->AddRect(ImVec2(bMin.x - 2, bMin.y - 2),
|
||||
ImVec2(bMax.x + 2, bMax.y + 2),
|
||||
IM_COL32(255, 215, 0, alpha), 3.0f, 0, 3.0f);
|
||||
}
|
||||
if (git->second <= 0.0f) slotGlowTimers.erase(git);
|
||||
}
|
||||
}
|
||||
|
||||
// Key label below
|
||||
ImGui::TextDisabled("%s", keyLabel);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue