From 88c3cfe7ab985b1d6037108afc565074c53bfa88 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Thu, 12 Mar 2026 09:43:23 -0700 Subject: [PATCH] feat: show pet happiness bar in pet frame for hunter pets --- include/game/entity.hpp | 3 +++ src/ui/game_screen.cpp | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/game/entity.hpp b/include/game/entity.hpp index 9f4dfde7..57147902 100644 --- a/include/game/entity.hpp +++ b/include/game/entity.hpp @@ -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; } diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 3967d9f4..bd539149 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -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(happiness) / static_cast(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)