refactor: deduplicate class name functions in talent_screen and game_screen

Replace local getClassName()/classNameStr() with shared
game::getClassName() from character.hpp, removing 2 duplicate
name-lookup implementations (static arrays + wrapper functions).
This commit is contained in:
Kelsi 2026-03-27 14:30:45 -07:00
parent f5a3ebc774
commit cd29c6d50b
2 changed files with 3 additions and 17 deletions

View file

@ -125,13 +125,9 @@ namespace {
return static_cast<uint8_t>((bytes0 >> 8) & 0xFF);
}
// Return the English class name for a class ID (1-11), or "Unknown".
// Alias for shared class name helper
const char* classNameStr(uint8_t classId) {
static const char* kNames[] = {
"Unknown","Warrior","Paladin","Hunter","Rogue","Priest",
"Death Knight","Shaman","Mage","Warlock","","Druid"
};
return (classId < 12) ? kNames[classId] : "Unknown";
return wowee::game::getClassName(static_cast<wowee::game::Class>(classId));
}
bool isPortBotTarget(const std::string& target) {

View file

@ -13,16 +13,6 @@
namespace wowee { namespace ui {
// WoW class names indexed by class ID (1-11)
static const char* classNames[] = {
"Unknown", "Warrior", "Paladin", "Hunter", "Rogue", "Priest",
"Death Knight", "Shaman", "Mage", "Warlock", "Unknown", "Druid"
};
static const char* getClassName(uint8_t classId) {
return (classId >= 1 && classId <= 11) ? classNames[classId] : "Unknown";
}
void TalentScreen::render(game::GameHandler& gameHandler) {
// Talents toggle via keybinding (edge-triggered)
// Customizable key (default: N) from KeybindingManager
@ -51,7 +41,7 @@ void TalentScreen::render(game::GameHandler& gameHandler) {
uint8_t playerClass = gameHandler.getPlayerClass();
std::string title = "Talents";
if (playerClass > 0) {
title = std::string(getClassName(playerClass)) + " Talents";
title = std::string(game::getClassName(static_cast<game::Class>(playerClass))) + " Talents";
}
bool windowOpen = open;