Merge branch 'classyimage' into 'master'

Handle non-string RefIds when displaying a class image

See merge request OpenMW/openmw!3111
revert-6246b479
psi29a 2 years ago
commit 75c371de66

@ -888,15 +888,22 @@ namespace MWGui
}
void setClassImage(MyGUI::ImageBox* imageBox, const ESM::RefId& classId)
{
std::string_view fallback = "textures\\levelup\\warrior.dds";
std::string classImage;
if (const auto* id = classId.getIf<ESM::StringRefId>())
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
std::string classImage
= Misc::ResourceHelpers::correctTexturePath("textures\\levelup\\" + classId.getRefIdString() + ".dds", vfs);
classImage
= Misc::ResourceHelpers::correctTexturePath("textures\\levelup\\" + id->getValue() + ".dds", vfs);
if (!vfs->exists(classImage))
{
Log(Debug::Warning) << "No class image for " << classId << ", falling back to default";
classImage = "textures\\levelup\\warrior.dds";
classImage = fallback;
}
}
else
classImage = fallback;
imageBox->setImageTexture(classImage);
}

Loading…
Cancel
Save