Fall back to 'warrior' for not found class images (Fixes #3228)

openmw-39
scrawl 9 years ago
parent 8052225460
commit 92c2a10de4

@ -353,6 +353,7 @@ namespace MWBase
virtual std::string correctIconPath(const std::string& path) = 0;
virtual std::string correctBookartPath(const std::string& path, int width, int height) = 0;
virtual std::string correctTexturePath(const std::string& path) = 0;
virtual bool textureExists(const std::string& path) = 0;
virtual void removeCell(MWWorld::CellStore* cell) = 0;
virtual void writeFog(MWWorld::CellStore* cell) = 0;

@ -55,7 +55,9 @@ namespace MWGui
void GenerateClassResultDialog::setClassId(const std::string &classId)
{
mCurrentClassId = classId;
mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds");
setClassImage(mClassImage, mCurrentClassId);
mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(mCurrentClassId)->mName);
center();
@ -257,7 +259,7 @@ namespace MWGui
ToolTips::createSkillToolTip(mMajorSkill[i], klass->mData.mSkills[i][1]);
}
mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds");
setClassImage(mClassImage, mCurrentClassId);
}
/* InfoBoxDialog */
@ -903,4 +905,15 @@ namespace MWGui
eventDone(this);
}
void setClassImage(MyGUI::ImageBox* imageBox, const std::string &classId)
{
std::string classImage = std::string("textures\\levelup\\") + classId + ".dds";
if (!MWBase::Environment::get().getWindowManager()->textureExists(classImage))
{
std::cout << "No class image for " << classId << ", falling back to default" << std::endl;
classImage = "textures\\levelup\\warrior.dds";
}
imageBox->setImageTexture(classImage);
}
}

@ -8,6 +8,8 @@
namespace MWGui
{
void setClassImage(MyGUI::ImageBox* imageBox, const std::string& classId);
class InfoBoxDialog : public WindowModal
{
public:

@ -19,6 +19,8 @@
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "class.hpp"
namespace MWGui
{
const unsigned int LevelupDialog::sMaxCoins = 3;
@ -154,7 +156,7 @@ namespace MWGui
cls = &*it;
}
mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds");
setClassImage(mClassImage, cls->mId);
int level = creatureStats.getLevel ()+1;
mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + MyGUI::utility::toString(level));

@ -2002,6 +2002,12 @@ namespace MWGui
return Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS());
}
bool WindowManager::textureExists(const std::string &path)
{
std::string corrected = Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS());
return mResourceSystem->getVFS()->exists(corrected);
}
void WindowManager::createCursors()
{
MyGUI::ResourceManager::EnumeratorPtr enumerator = MyGUI::ResourceManager::getInstance().getEnumerator();

@ -374,6 +374,7 @@ namespace MWGui
virtual std::string correctIconPath(const std::string& path);
virtual std::string correctBookartPath(const std::string& path, int width, int height);
virtual std::string correctTexturePath(const std::string& path);
virtual bool textureExists(const std::string& path);
void removeCell(MWWorld::CellStore* cell);
void writeFog(MWWorld::CellStore* cell);

Loading…
Cancel
Save