From 762daebc755bc72312a918f5862f0a7fddea40cb Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 27 Mar 2026 14:00:15 -0700 Subject: [PATCH] refactor: replace 23 more inline color literals across 3 UI files game_screen: kWhite(3), kSilver(4) inventory_screen: kWarmGold(8), kFriendlyGreen(2), kSocketGreen(4), kActiveGreen(2) talent_screen: kHealthGreen(1), kWhite(3), kRed(1) --- src/ui/game_screen.cpp | 14 +++++++------- src/ui/inventory_screen.cpp | 32 ++++++++++++++++---------------- src/ui/talent_screen.cpp | 8 ++++---- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index fdfcbd3e..4c5d2e3a 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -1303,7 +1303,7 @@ void GameScreen::renderChatWindow(game::GameHandler& gameHandler) { // Helper: parse WoW color code |cAARRGGBB → ImVec4 auto parseWowColor = [](const std::string& text, size_t pos) -> ImVec4 { // |cAARRGGBB (10 chars total: |c + 8 hex) - if (pos + 10 > text.size()) return ImVec4(1, 1, 1, 1); + if (pos + 10 > text.size()) return colors::kWhite; auto hexByte = [&](size_t offset) -> float { const char* s = text.c_str() + pos + offset; char buf[3] = {s[0], s[1], '\0'}; @@ -4878,7 +4878,7 @@ void GameScreen::renderTargetFrame(game::GameHandler& gameHandler) { ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) { std::string totName = getEntityName(totEntity); // Class color for players; gray for NPCs - ImVec4 totNameColor = ImVec4(0.8f, 0.8f, 0.8f, 1.0f); + ImVec4 totNameColor = colors::kSilver; if (totEntity->getType() == game::ObjectType::PLAYER) { uint8_t cid = entityClassId(totEntity.get()); if (cid != 0) totNameColor = classColorVec4(cid); @@ -10111,7 +10111,7 @@ void GameScreen::renderBagBar(game::GameHandler& gameHandler) { ImVec2(slotSize, slotSize), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0.1f, 0.1f, 0.1f, 0.9f), - ImVec4(1, 1, 1, 1))) { + colors::kWhite)) { if (inventoryScreen.isSeparateBags()) inventoryScreen.toggleBackpack(); else @@ -14725,7 +14725,7 @@ void GameScreen::renderGuildRoster(game::GameHandler& gameHandler) { // Guild description / info text if (!roster.guildInfo.empty()) { - ImGui::TextColored(ImVec4(0.8f, 0.8f, 0.8f, 1.0f), "Description:"); + ImGui::TextColored(colors::kSilver, "Description:"); ImGui::TextWrapped("%s", roster.guildInfo.c_str()); } ImGui::Spacing(); @@ -23689,7 +23689,7 @@ void GameScreen::renderDungeonFinderWindow(game::GameHandler& gameHandler) { if (avgSec >= 0) { int aMin = avgSec / 60; int aSec = avgSec % 60; - ImGui::TextColored(ImVec4(0.8f, 0.8f, 0.8f, 1.0f), + ImGui::TextColored(colors::kSilver, "Avg wait: %d:%02d", aMin, aSec); } break; @@ -24393,7 +24393,7 @@ void GameScreen::renderCombatLog(game::GameHandler& gameHandler) { snprintf(desc, sizeof(desc), "%s is immune to %s", tgt, spell); else snprintf(desc, sizeof(desc), "%s is immune", tgt); - color = ImVec4(0.8f, 0.8f, 0.8f, 1.0f); + color = colors::kSilver; break; case T::ABSORB: if (spell && e.amount > 0) @@ -25327,7 +25327,7 @@ void GameScreen::renderInspectWindow(game::GameHandler& gameHandler) { if (iconTex) { ImGui::Image((ImTextureID)(uintptr_t)iconTex, ImVec2(kIconSz, kIconSz), ImVec2(0,0), ImVec2(1,1), - ImVec4(1,1,1,1), qColor); + colors::kWhite, qColor); } else { ImGui::GetWindowDrawList()->AddRectFilled( ImGui::GetCursorScreenPos(), diff --git a/src/ui/inventory_screen.cpp b/src/ui/inventory_screen.cpp index 1b1d009b..c837976f 100644 --- a/src/ui/inventory_screen.cpp +++ b/src/ui/inventory_screen.cpp @@ -928,7 +928,7 @@ void InventoryScreen::renderAggregateBags(game::Inventory& inventory, uint64_t m uint64_t gold = moneyCopper / 10000; uint64_t silver = (moneyCopper / 100) % 100; uint64_t copper = moneyCopper % 100; - ImGui::TextColored(ImVec4(1.0f, 0.84f, 0.0f, 1.0f), "%llug %llus %lluc", + ImGui::TextColored(ui::colors::kWarmGold, "%llug %llus %lluc", static_cast(gold), static_cast(silver), static_cast(copper)); @@ -1146,7 +1146,7 @@ void InventoryScreen::renderBagWindow(const char* title, bool& isOpen, uint64_t gold = moneyCopper / 10000; uint64_t silver = (moneyCopper / 100) % 100; uint64_t copper = moneyCopper % 100; - ImGui::TextColored(ImVec4(1.0f, 0.84f, 0.0f, 1.0f), "%llug %llus %lluc", + ImGui::TextColored(ui::colors::kWarmGold, "%llug %llus %lluc", static_cast(gold), static_cast(silver), static_cast(copper)); @@ -1351,7 +1351,7 @@ void InventoryScreen::renderCharacterScreen(game::GameHandler& gameHandler) { ImGui::SameLine(180.0f); ImGui::SetNextItemWidth(-1.0f); // Bar color: gold when maxed, green otherwise - ImVec4 barColor = isMaxed ? ui::colors::kTooltipGold : ImVec4(0.2f, 0.7f, 0.2f, 1.0f); + ImVec4 barColor = isMaxed ? ui::colors::kTooltipGold : ui::colors::kFriendlyGreen; ImGui::PushStyleColor(ImGuiCol_PlotHistogram, barColor); ImGui::ProgressBar(ratio, ImVec2(0, 14.0f), overlay); ImGui::PopStyleColor(); @@ -1400,7 +1400,7 @@ void InventoryScreen::renderCharacterScreen(game::GameHandler& gameHandler) { } ImGui::PushID(static_cast(id)); - ImGui::TextColored(ImVec4(1.0f, 0.84f, 0.0f, 1.0f), "[Achievement]"); + ImGui::TextColored(ui::colors::kWarmGold, "[Achievement]"); ImGui::SameLine(); ImGui::Text("%s", displayName); ImGui::PopID(); @@ -1527,10 +1527,10 @@ void InventoryScreen::renderReputationPanel(game::GameHandler& gameHandler) { { "Hostile", -6000, -3001, ImVec4(0.8f, 0.2f, 0.1f, 1.0f) }, { "Unfriendly", -3000, -1, ImVec4(0.9f, 0.5f, 0.1f, 1.0f) }, { "Neutral", 0, 2999, ImVec4(0.8f, 0.8f, 0.2f, 1.0f) }, - { "Friendly", 3000, 8999, ImVec4(0.2f, 0.7f, 0.2f, 1.0f) }, + { "Friendly", 3000, 8999, ui::colors::kFriendlyGreen }, { "Honored", 9000, 20999, ImVec4(0.2f, 0.8f, 0.5f, 1.0f) }, { "Revered", 21000, 41999, ImVec4(0.3f, 0.6f, 1.0f, 1.0f) }, - { "Exalted", 42000, 42000, ImVec4(1.0f, 0.84f, 0.0f, 1.0f) }, + { "Exalted", 42000, 42000, ui::colors::kWarmGold }, }; constexpr int kNumTiers = static_cast(sizeof(tiers) / sizeof(tiers[0])); @@ -1626,7 +1626,7 @@ void InventoryScreen::renderReputationPanel(game::GameHandler& gameHandler) { } void InventoryScreen::renderEquipmentPanel(game::Inventory& inventory) { - ImGui::TextColored(ImVec4(1.0f, 0.84f, 0.0f, 1.0f), "Equipment"); + ImGui::TextColored(ui::colors::kWarmGold, "Equipment"); ImGui::Separator(); static const game::EquipSlot leftSlots[] = { @@ -1985,7 +1985,7 @@ void InventoryScreen::renderStatsPanel(game::Inventory& inventory, uint32_t play if (hasAny) { ImGui::Spacing(); ImGui::Separator(); - ImGui::TextColored(ImVec4(1.0f, 0.84f, 0.0f, 1.0f), "Combat"); + ImGui::TextColored(ui::colors::kWarmGold, "Combat"); ImVec4 cyan(0.5f, 0.9f, 1.0f, 1.0f); if (meleeAP >= 0) ImGui::TextColored(cyan, "Attack Power: %d", meleeAP); if (rangedAP >= 0 && rangedAP != meleeAP) @@ -2105,7 +2105,7 @@ void InventoryScreen::renderStatsPanel(game::Inventory& inventory, uint32_t play if (showRun || showFlight || showSwim) { ImGui::Spacing(); ImGui::Separator(); - ImGui::TextColored(ImVec4(1.0f, 0.84f, 0.0f, 1.0f), "Movement"); + ImGui::TextColored(ui::colors::kWarmGold, "Movement"); ImVec4 speedColor(0.6f, 1.0f, 0.8f, 1.0f); if (showRun) { float pct = (runSpeed / kBaseRun) * 100.0f; @@ -2125,7 +2125,7 @@ void InventoryScreen::renderStatsPanel(game::Inventory& inventory, uint32_t play } void InventoryScreen::renderBackpackPanel(game::Inventory& inventory, bool collapseEmptySections) { - ImGui::TextColored(ImVec4(1.0f, 0.84f, 0.0f, 1.0f), "Backpack"); + ImGui::TextColored(ui::colors::kWarmGold, "Backpack"); ImGui::Separator(); constexpr float slotSize = 40.0f; @@ -2927,9 +2927,9 @@ void InventoryScreen::renderItemTooltip(const game::ItemDef& item, const game::I if (hasSocket && qi2->socketBonus != 0) { auto enchIt = s_enchLookupB.find(qi2->socketBonus); if (enchIt != s_enchLookupB.end()) - ImGui::TextColored(ImVec4(0.5f, 0.8f, 0.5f, 1.0f), "Socket Bonus: %s", enchIt->second.c_str()); + ImGui::TextColored(ui::colors::kSocketGreen, "Socket Bonus: %s", enchIt->second.c_str()); else - ImGui::TextColored(ImVec4(0.5f, 0.8f, 0.5f, 1.0f), "Socket Bonus: (id %u)", qi2->socketBonus); + ImGui::TextColored(ui::colors::kSocketGreen, "Socket Bonus: (id %u)", qi2->socketBonus); } } // Item set membership @@ -3004,7 +3004,7 @@ void InventoryScreen::renderItemTooltip(const game::ItemDef& item, const game::I if (se.spellIds[i] == 0 || se.thresholds[i] == 0) continue; const std::string& bname = gameHandler_->getSpellName(se.spellIds[i]); bool active = (equipped >= static_cast(se.thresholds[i])); - ImVec4 col = active ? ImVec4(0.5f, 1.0f, 0.5f, 1.0f) + ImVec4 col = active ? ui::colors::kActiveGreen : ImVec4(0.55f, 0.55f, 0.55f, 1.0f); if (!bname.empty()) ImGui::TextColored(col, "(%u) %s", se.thresholds[i], bname.c_str()); @@ -3523,9 +3523,9 @@ void InventoryScreen::renderItemTooltip(const game::ItemQueryResponseData& info, if (hasSocket && info.socketBonus != 0) { auto enchIt = s_enchLookup.find(info.socketBonus); if (enchIt != s_enchLookup.end()) - ImGui::TextColored(ImVec4(0.5f, 0.8f, 0.5f, 1.0f), "Socket Bonus: %s", enchIt->second.c_str()); + ImGui::TextColored(ui::colors::kSocketGreen, "Socket Bonus: %s", enchIt->second.c_str()); else - ImGui::TextColored(ImVec4(0.5f, 0.8f, 0.5f, 1.0f), "Socket Bonus: (id %u)", info.socketBonus); + ImGui::TextColored(ui::colors::kSocketGreen, "Socket Bonus: (id %u)", info.socketBonus); } } @@ -3627,7 +3627,7 @@ void InventoryScreen::renderItemTooltip(const game::ItemQueryResponseData& info, if (se.spellIds[i] == 0 || se.thresholds[i] == 0) continue; const std::string& bname = gameHandler_->getSpellName(se.spellIds[i]); bool active = (equipped >= static_cast(se.thresholds[i])); - ImVec4 col = active ? ImVec4(0.5f, 1.0f, 0.5f, 1.0f) + ImVec4 col = active ? ui::colors::kActiveGreen : ImVec4(0.55f, 0.55f, 0.55f, 1.0f); if (!bname.empty()) ImGui::TextColored(col, "(%u) %s", se.thresholds[i], bname.c_str()); diff --git a/src/ui/talent_screen.cpp b/src/ui/talent_screen.cpp index 99e743f4..e60d4219 100644 --- a/src/ui/talent_screen.cpp +++ b/src/ui/talent_screen.cpp @@ -431,9 +431,9 @@ void TalentScreen::renderTalent(game::GameHandler& gameHandler, ImVec4 borderColor; ImVec4 tint; switch (state) { - case MAXED: borderColor = ImVec4(0.2f, 0.9f, 0.2f, 1.0f); tint = ImVec4(1,1,1,1); break; - case PARTIAL: borderColor = ImVec4(0.2f, 0.8f, 0.2f, 1.0f); tint = ImVec4(1,1,1,1); break; - case AVAILABLE:borderColor = ImVec4(1.0f, 1.0f, 1.0f, 0.8f); tint = ImVec4(1,1,1,1); break; + case MAXED: borderColor = ImVec4(0.2f, 0.9f, 0.2f, 1.0f); tint = ui::colors::kWhite; break; + case PARTIAL: borderColor = ui::colors::kHealthGreen; tint = ui::colors::kWhite; break; + case AVAILABLE:borderColor = ImVec4(1.0f, 1.0f, 1.0f, 0.8f); tint = ui::colors::kWhite; break; case LOCKED: borderColor = ImVec4(0.4f, 0.4f, 0.4f, 0.8f); tint = ImVec4(0.4f,0.4f,0.4f,1); break; } @@ -566,7 +566,7 @@ void TalentScreen::renderTalent(game::GameHandler& gameHandler, uint8_t prereqCurrentRank = gameHandler.getTalentRank(talent.prereqTalent[i]); bool met = prereqCurrentRank > talent.prereqRank[i]; // storage 1-indexed, DBC 0-indexed - ImVec4 pColor = met ? ImVec4(0.3f, 0.9f, 0.3f, 1) : ImVec4(1.0f, 0.3f, 0.3f, 1); + ImVec4 pColor = met ? ImVec4(0.3f, 0.9f, 0.3f, 1.0f) : ui::colors::kRed; const std::string& prereqName = gameHandler.getSpellName(prereq->rankSpells[0]); ImGui::Spacing();