Kelsidavis-WoWee/include/ui/ui_colors.hpp
Kelsi 7015e09f90 refactor: add kTooltipGold color constant, replace 14 inline literals
Add colors::kTooltipGold to ui_colors.hpp and replace 14 inline
ImVec4(1.0f, 0.82f, 0.0f, 1.0f) literals in inventory_screen.cpp
for item set names, unique markers, and quest item indicators.
2026-03-25 19:18:54 -07:00

109 lines
4 KiB
C++

#pragma once
#include <imgui.h>
#include "game/inventory.hpp"
namespace wowee::ui {
// ---- Common UI colors ----
namespace colors {
constexpr ImVec4 kRed = {1.0f, 0.3f, 0.3f, 1.0f};
constexpr ImVec4 kGreen = {0.4f, 1.0f, 0.4f, 1.0f};
constexpr ImVec4 kBrightGreen = {0.3f, 1.0f, 0.3f, 1.0f};
constexpr ImVec4 kYellow = {1.0f, 1.0f, 0.3f, 1.0f};
constexpr ImVec4 kGray = {0.6f, 0.6f, 0.6f, 1.0f};
constexpr ImVec4 kDarkGray = {0.5f, 0.5f, 0.5f, 1.0f};
constexpr ImVec4 kLightGray = {0.7f, 0.7f, 0.7f, 1.0f};
constexpr ImVec4 kWhite = {1.0f, 1.0f, 1.0f, 1.0f};
constexpr ImVec4 kTooltipGold = {1.0f, 0.82f, 0.0f, 1.0f};
// Coin colors
constexpr ImVec4 kGold = {1.00f, 0.82f, 0.00f, 1.0f};
constexpr ImVec4 kSilver = {0.80f, 0.80f, 0.80f, 1.0f};
constexpr ImVec4 kCopper = {0.72f, 0.45f, 0.20f, 1.0f};
} // namespace colors
// ---- Item quality colors ----
inline ImVec4 getQualityColor(game::ItemQuality quality) {
switch (quality) {
case game::ItemQuality::POOR: return {0.62f, 0.62f, 0.62f, 1.0f};
case game::ItemQuality::COMMON: return {1.0f, 1.0f, 1.0f, 1.0f};
case game::ItemQuality::UNCOMMON: return {0.12f, 1.0f, 0.0f, 1.0f};
case game::ItemQuality::RARE: return {0.0f, 0.44f, 0.87f, 1.0f};
case game::ItemQuality::EPIC: return {0.64f, 0.21f, 0.93f, 1.0f};
case game::ItemQuality::LEGENDARY: return {1.0f, 0.50f, 0.0f, 1.0f};
case game::ItemQuality::ARTIFACT: return {0.90f, 0.80f, 0.50f, 1.0f};
case game::ItemQuality::HEIRLOOM: return {0.90f, 0.80f, 0.50f, 1.0f};
default: return {1.0f, 1.0f, 1.0f, 1.0f};
}
}
// ---- Coin display (gold/silver/copper) ----
inline void renderCoinsText(uint32_t g, uint32_t s, uint32_t c) {
bool any = false;
if (g > 0) {
ImGui::TextColored(colors::kGold, "%ug", g);
any = true;
}
if (s > 0 || g > 0) {
if (any) ImGui::SameLine(0, 3);
ImGui::TextColored(colors::kSilver, "%us", s);
any = true;
}
if (any) ImGui::SameLine(0, 3);
ImGui::TextColored(colors::kCopper, "%uc", c);
}
// Convenience overload: decompose copper amount and render as gold/silver/copper
inline void renderCoinsFromCopper(uint64_t copper) {
renderCoinsText(static_cast<uint32_t>(copper / 10000),
static_cast<uint32_t>((copper / 100) % 100),
static_cast<uint32_t>(copper % 100));
}
// ---- Inventory slot name from WoW inventory type ----
inline const char* getInventorySlotName(uint32_t inventoryType) {
switch (inventoryType) {
case 1: return "Head";
case 2: return "Neck";
case 3: return "Shoulder";
case 4: return "Shirt";
case 5: return "Chest";
case 6: return "Waist";
case 7: return "Legs";
case 8: return "Feet";
case 9: return "Wrist";
case 10: return "Hands";
case 11: return "Finger";
case 12: return "Trinket";
case 13: return "One-Hand";
case 14: return "Shield";
case 15: return "Ranged";
case 16: return "Back";
case 17: return "Two-Hand";
case 18: return "Bag";
case 19: return "Tabard";
case 20: return "Robe";
case 21: return "Main Hand";
case 22: return "Off Hand";
case 23: return "Held In Off-hand";
case 25: return "Thrown";
case 26: return "Ranged";
case 28: return "Relic";
default: return "";
}
}
// ---- Binding type display ----
inline void renderBindingType(uint32_t bindType) {
const auto& kBindColor = colors::kTooltipGold;
switch (bindType) {
case 1: ImGui::TextColored(kBindColor, "Binds when picked up"); break;
case 2: ImGui::TextColored(kBindColor, "Binds when equipped"); break;
case 3: ImGui::TextColored(kBindColor, "Binds when used"); break;
case 4: ImGui::TextColored(kBindColor, "Quest Item"); break;
default: break;
}
}
} // namespace wowee::ui