1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 09:45:36 +00:00

Merge branch 'classyimage' into 'master'

Handle non-string RefIds when displaying a class image

See merge request OpenMW/openmw!3111
This commit is contained in:
psi29a 2023-06-07 06:51:24 +00:00
commit 75c371de66

View file

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