diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 2d4c0e2ca..77d740b6f 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -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; diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 51d5e45fb..ab7290e87 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -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().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); + } + } diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index e36a9a98b..8206d6b03 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -8,6 +8,8 @@ namespace MWGui { + void setClassImage(MyGUI::ImageBox* imageBox, const std::string& classId); + class InfoBoxDialog : public WindowModal { public: diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 4e8d0a02c..fb9952ba7 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -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)); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 1b2c45520..54fd31acd 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -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(); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 3cdba8a87..17a2e3855 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -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);