From c73da1629bc8fa3b83d61c0b332d8b7046fd1556 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Thu, 12 Mar 2026 08:35:47 -0700 Subject: [PATCH] refactor: use classColorVec4 helper in player frame Replace the duplicated 10-case switch in renderPlayerFrame with a call to the shared classColorVec4() helper, keeping the single source of truth for Blizzard class colors. --- src/ui/game_screen.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 618042bf..d11939a4 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -2441,22 +2441,10 @@ void GameScreen::renderPlayerFrame(game::GameHandler& gameHandler) { playerHp = playerMaxHp; } - // Derive class color (WoW standard class colors) - ImVec4 classColor(0.3f, 1.0f, 0.3f, 1.0f); // default green - if (activeChar) { - switch (activeChar->characterClass) { - case game::Class::WARRIOR: classColor = ImVec4(0.78f, 0.61f, 0.43f, 1.0f); break; - case game::Class::PALADIN: classColor = ImVec4(0.96f, 0.55f, 0.73f, 1.0f); break; - case game::Class::HUNTER: classColor = ImVec4(0.67f, 0.83f, 0.45f, 1.0f); break; - case game::Class::ROGUE: classColor = ImVec4(1.00f, 0.96f, 0.41f, 1.0f); break; - case game::Class::PRIEST: classColor = ImVec4(1.00f, 1.00f, 1.00f, 1.0f); break; - case game::Class::DEATH_KNIGHT: classColor = ImVec4(0.77f, 0.12f, 0.23f, 1.0f); break; - case game::Class::SHAMAN: classColor = ImVec4(0.00f, 0.44f, 0.87f, 1.0f); break; - case game::Class::MAGE: classColor = ImVec4(0.41f, 0.80f, 0.94f, 1.0f); break; - case game::Class::WARLOCK: classColor = ImVec4(0.58f, 0.51f, 0.79f, 1.0f); break; - case game::Class::DRUID: classColor = ImVec4(1.00f, 0.49f, 0.04f, 1.0f); break; - } - } + // Derive class color via shared helper + ImVec4 classColor = activeChar + ? classColorVec4(static_cast(activeChar->characterClass)) + : ImVec4(0.3f, 1.0f, 0.3f, 1.0f); // Name in class color — clickable for self-target, right-click for menu ImGui::PushStyleColor(ImGuiCol_Text, classColor);