feat: show pet happiness bar in pet frame for hunter pets

This commit is contained in:
Kelsi 2026-03-12 09:43:23 -07:00
parent 84b31d3bbd
commit 88c3cfe7ab
2 changed files with 20 additions and 0 deletions

View file

@ -214,6 +214,9 @@ public:
void setMaxPower(uint32_t p) { maxPowers[powerType < 7 ? powerType : 0] = p; }
void setMaxPowerByType(uint8_t type, uint32_t p) { if (type < 7) maxPowers[type] = p; }
uint32_t getPowerByType(uint8_t type) const { return type < 7 ? powers[type] : 0; }
uint32_t getMaxPowerByType(uint8_t type) const { return type < 7 ? maxPowers[type] : 0; }
uint8_t getPowerType() const { return powerType; }
void setPowerType(uint8_t t) { powerType = t; }

View file

@ -2844,6 +2844,23 @@ void GameScreen::renderPetFrame(game::GameHandler& gameHandler) {
ImGui::PopStyleColor();
}
// Happiness bar — hunter pets store happiness as power type 4
{
uint32_t happiness = petUnit->getPowerByType(4);
uint32_t maxHappiness = petUnit->getMaxPowerByType(4);
if (maxHappiness > 0 && happiness > 0) {
float hapPct = static_cast<float>(happiness) / static_cast<float>(maxHappiness);
// Tier: < 33% = Unhappy (red), < 67% = Content (yellow), >= 67% = Happy (green)
ImVec4 hapColor = hapPct >= 0.667f ? ImVec4(0.2f, 0.85f, 0.2f, 1.0f)
: hapPct >= 0.333f ? ImVec4(0.9f, 0.75f, 0.1f, 1.0f)
: ImVec4(0.85f, 0.2f, 0.2f, 1.0f);
const char* hapLabel = hapPct >= 0.667f ? "Happy" : hapPct >= 0.333f ? "Content" : "Unhappy";
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, hapColor);
ImGui::ProgressBar(hapPct, ImVec2(-1, 8), hapLabel);
ImGui::PopStyleColor();
}
}
// Pet cast bar
if (auto* pcs = gameHandler.getUnitCastState(petGuid)) {
float castPct = (pcs->timeTotal > 0.0f)