mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +00:00
game/ui: generalize cast tracking to per-GUID map; add boss cast bars
Previously the target cast bar tracked a single target using 4 private fields. This replaces that with unitCastStates_ (unordered_map<uint64_t, UnitCastState>), tracking cast state for every non-player unit whose SMSG_SPELL_START we receive. Changes: - GameHandler::UnitCastState struct: casting, spellId, timeRemaining, timeTotal - getUnitCastState(guid) → returns cast state for any tracked unit - isTargetCasting(), getTargetCastSpellId(), getTargetCastProgress(), getTargetCastTimeRemaining() now delegate to getUnitCastState(targetGuid) - handleSpellStart: tracks all non-player casters (not just the target) - handleSpellGo: erases caster from map when spell lands - update loop: ticks down all unit cast states, erasing expired entries - unitCastStates_ cleared on world reset - renderBossFrames: shows red cast progress bar per boss slot with spell name + remaining seconds — critical for instance interrupt play
This commit is contained in:
parent
1c85b7a46d
commit
07d0485a31
3 changed files with 68 additions and 36 deletions
|
|
@ -5010,6 +5010,24 @@ void GameScreen::renderBossFrames(game::GameHandler& gameHandler) {
|
|||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
// Boss cast bar — shown when the boss is casting (critical for interrupt)
|
||||
if (auto* cs = gameHandler.getUnitCastState(bs.guid)) {
|
||||
float castPct = (cs->timeTotal > 0.0f)
|
||||
? (cs->timeTotal - cs->timeRemaining) / cs->timeTotal : 0.0f;
|
||||
uint32_t bspell = cs->spellId;
|
||||
const std::string& bcastName = (bspell != 0)
|
||||
? gameHandler.getSpellName(bspell) : "";
|
||||
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImVec4(0.9f, 0.3f, 0.2f, 1.0f));
|
||||
char bcastLabel[72];
|
||||
if (!bcastName.empty())
|
||||
snprintf(bcastLabel, sizeof(bcastLabel), "%s (%.1fs)",
|
||||
bcastName.c_str(), cs->timeRemaining);
|
||||
else
|
||||
snprintf(bcastLabel, sizeof(bcastLabel), "Casting... (%.1fs)", cs->timeRemaining);
|
||||
ImGui::ProgressBar(castPct, ImVec2(-1, 12), bcastLabel);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue