mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Fix action bar and buff bar spell tooltips showing 'Spell #xxx'
The action bar's inline Spell.dbc loader had a broken field index lookup: operator[] on the layout map would silently insert 0 if 'Name' wasn't a key, causing all names to be read from field 0 (the spell ID). Also the once-only 'attempted' flag meant if assetMgr wasn't ready, it never retried. Replace the duplicated broken DBC loading in the action bar and buff bar with SpellbookScreen::lookupSpellName(), which reuses the spellbook's already-correct loading (expansion layout + WotLK fallback). Remove the now-unused actionSpellNames/actionSpellDbAttempted/actionSpellDbLoaded fields.
This commit is contained in:
parent
bd70ca17ca
commit
df0bfaea4f
4 changed files with 16 additions and 41 deletions
|
|
@ -203,10 +203,6 @@ private:
|
|||
TalentScreen talentScreen;
|
||||
rendering::WorldMap worldMap;
|
||||
|
||||
bool actionSpellDbAttempted = false;
|
||||
bool actionSpellDbLoaded = false;
|
||||
std::unordered_map<uint32_t, std::string> actionSpellNames;
|
||||
|
||||
// Spell icon cache: spellId -> GL texture ID
|
||||
std::unordered_map<uint32_t, GLuint> spellIconCache_;
|
||||
// SpellIconID -> icon path (from SpellIcon.dbc)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ public:
|
|||
void toggle() { open = !open; }
|
||||
void setOpen(bool o) { open = o; }
|
||||
|
||||
// Spell name lookup — triggers DBC load if needed, used by action bar tooltips
|
||||
std::string lookupSpellName(uint32_t spellId, pipeline::AssetManager* assetManager);
|
||||
|
||||
// Drag-and-drop state for action bar assignment
|
||||
bool isDraggingSpell() const { return draggingSpell_; }
|
||||
uint32_t getDragSpellId() const { return dragSpellId_; }
|
||||
|
|
|
|||
|
|
@ -3084,36 +3084,8 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
|
|||
bool onCooldown = !slot.isReady();
|
||||
|
||||
auto getSpellName = [&](uint32_t spellId) -> std::string {
|
||||
if (!actionSpellDbAttempted) {
|
||||
actionSpellDbAttempted = true;
|
||||
if (assetMgr && assetMgr->isInitialized()) {
|
||||
auto dbc = assetMgr->loadDBC("Spell.dbc");
|
||||
if (dbc && dbc->isLoaded()) {
|
||||
const auto* actionSpellL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("Spell") : nullptr;
|
||||
uint32_t fieldCount = dbc->getFieldCount();
|
||||
uint32_t nameField = actionSpellL ? (*actionSpellL)["Name"] : 136;
|
||||
if (fieldCount < 137) {
|
||||
if (fieldCount > 10) {
|
||||
nameField = fieldCount > 140 ? 136 : 1;
|
||||
} else {
|
||||
nameField = 1;
|
||||
}
|
||||
}
|
||||
uint32_t count = dbc->getRecordCount();
|
||||
actionSpellNames.reserve(count);
|
||||
for (uint32_t r = 0; r < count; ++r) {
|
||||
uint32_t id = dbc->getUInt32(r, actionSpellL ? (*actionSpellL)["ID"] : 0);
|
||||
std::string name = dbc->getString(r, nameField);
|
||||
if (!name.empty() && id > 0) {
|
||||
actionSpellNames[id] = name;
|
||||
}
|
||||
}
|
||||
actionSpellDbLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
auto it = actionSpellNames.find(spellId);
|
||||
if (it != actionSpellNames.end()) return it->second;
|
||||
std::string name = spellbookScreen.lookupSpellName(spellId, assetMgr);
|
||||
if (!name.empty()) return name;
|
||||
return "Spell #" + std::to_string(spellId);
|
||||
};
|
||||
|
||||
|
|
@ -4108,13 +4080,8 @@ void GameScreen::renderBuffBar(game::GameHandler& gameHandler) {
|
|||
|
||||
// Tooltip with spell name and duration
|
||||
if (ImGui::IsItemHovered()) {
|
||||
std::string name;
|
||||
auto it = actionSpellNames.find(aura.spellId);
|
||||
if (it != actionSpellNames.end()) {
|
||||
name = it->second;
|
||||
} else {
|
||||
name = "Spell #" + std::to_string(aura.spellId);
|
||||
}
|
||||
std::string name = spellbookScreen.lookupSpellName(aura.spellId, assetMgr);
|
||||
if (name.empty()) name = "Spell #" + std::to_string(aura.spellId);
|
||||
if (aura.durationMs > 0) {
|
||||
int seconds = aura.durationMs / 1000;
|
||||
if (seconds < 60) {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,15 @@ void SpellbookScreen::loadSpellDBC(pipeline::AssetManager* assetManager) {
|
|||
dbcLoaded = !spellData.empty();
|
||||
}
|
||||
|
||||
std::string SpellbookScreen::lookupSpellName(uint32_t spellId, pipeline::AssetManager* assetManager) {
|
||||
if (!dbcLoadAttempted) {
|
||||
loadSpellDBC(assetManager);
|
||||
}
|
||||
auto it = spellData.find(spellId);
|
||||
if (it != spellData.end()) return it->second.name;
|
||||
return {};
|
||||
}
|
||||
|
||||
void SpellbookScreen::loadSpellIconDBC(pipeline::AssetManager* assetManager) {
|
||||
if (iconDbLoaded) return;
|
||||
iconDbLoaded = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue