game/ui: add target cast bar to target frame (SMSG_SPELL_START tracking)

SMSG_SPELL_START fires for all units, not just the player. Previously only
the player's own cast was tracked; now we also track when the current
target is casting, enabling interrupt decisions.

- GameHandler: track targetCasting_/targetCastSpellId_/targetCastTimeTotal_
  /targetCastTimeRemaining_ — updated by SMSG_SPELL_START for the current
  target and ticked down in the update loop each frame
- Target cast cleared when: target changes (setTarget), target's spell
  lands (SMSG_SPELL_GO), or cast timer expires naturally
- game_screen: renderTargetFrame shows a red cast progress bar between
  the power bar and distance line when the target is casting, with
  spell name + remaining seconds
- Public accessors: isTargetCasting(), getTargetCastSpellId(),
  getTargetCastProgress(), getTargetCastTimeRemaining()
This commit is contained in:
Kelsi 2026-03-09 23:06:40 -07:00
parent 6951b7803d
commit 4d39736d29
3 changed files with 61 additions and 0 deletions

View file

@ -2093,6 +2093,22 @@ void GameScreen::renderTargetFrame(game::GameHandler& gameHandler) {
}
}
// Target cast bar — shown when the target is casting
if (gameHandler.isTargetCasting()) {
float castPct = gameHandler.getTargetCastProgress();
float castLeft = gameHandler.getTargetCastTimeRemaining();
uint32_t tspell = gameHandler.getTargetCastSpellId();
const std::string& castName = (tspell != 0) ? gameHandler.getSpellName(tspell) : "";
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImVec4(0.9f, 0.3f, 0.2f, 1.0f));
char castLabel[72];
if (!castName.empty())
snprintf(castLabel, sizeof(castLabel), "%s (%.1fs)", castName.c_str(), castLeft);
else
snprintf(castLabel, sizeof(castLabel), "Casting... (%.1fs)", castLeft);
ImGui::ProgressBar(castPct, ImVec2(-1, 14), castLabel);
ImGui::PopStyleColor();
}
// Distance
const auto& movement = gameHandler.getMovementInfo();
float dx = target->getX() - movement.x;