mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
Log a warning in case of missing bookart instead of showing a pink rectangle (Fixes #3826)
This commit is contained in:
parent
335ecd1162
commit
1e585ac71a
4 changed files with 20 additions and 9 deletions
|
@ -360,7 +360,7 @@ namespace MWBase
|
||||||
|
|
||||||
// In WindowManager for now since there isn't a VFS singleton
|
// In WindowManager for now since there isn't a VFS singleton
|
||||||
virtual std::string correctIconPath(const std::string& path) = 0;
|
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 correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr) = 0;
|
||||||
virtual std::string correctTexturePath(const std::string& path) = 0;
|
virtual std::string correctTexturePath(const std::string& path) = 0;
|
||||||
virtual bool textureExists(const std::string& path) = 0;
|
virtual bool textureExists(const std::string& path) = 0;
|
||||||
|
|
||||||
|
|
|
@ -275,8 +275,6 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
case BookTextParser::Event_ImgTag:
|
case BookTextParser::Event_ImgTag:
|
||||||
{
|
{
|
||||||
pag.setIgnoreLeadingEmptyLines(false);
|
|
||||||
|
|
||||||
const BookTextParser::Attributes & attr = parser.getAttributes();
|
const BookTextParser::Attributes & attr = parser.getAttributes();
|
||||||
|
|
||||||
if (attr.find("src") == attr.end() || attr.find("width") == attr.end() || attr.find("height") == attr.end())
|
if (attr.find("src") == attr.end() || attr.find("width") == attr.end() || attr.find("height") == attr.end())
|
||||||
|
@ -286,8 +284,19 @@ namespace MWGui
|
||||||
int width = MyGUI::utility::parseInt(attr.at("width"));
|
int width = MyGUI::utility::parseInt(attr.at("width"));
|
||||||
int height = MyGUI::utility::parseInt(attr.at("height"));
|
int height = MyGUI::utility::parseInt(attr.at("height"));
|
||||||
|
|
||||||
|
bool exists;
|
||||||
|
std::string correctedSrc = MWBase::Environment::get().getWindowManager()->correctBookartPath(src, width, height, &exists);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
std::cerr << "Warning: Could not find \"" << src << "\" referenced by an <img> tag." << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
pag.setIgnoreLeadingEmptyLines(false);
|
||||||
|
|
||||||
ImageElement elem(paper, pag, mBlockStyle,
|
ImageElement elem(paper, pag, mBlockStyle,
|
||||||
src, width, height);
|
correctedSrc, width, height);
|
||||||
elem.paginate();
|
elem.paginate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -471,8 +480,7 @@ namespace MWGui
|
||||||
MyGUI::IntCoord(left, pag.getCurrentTop(), width, mImageHeight), MyGUI::Align::Left | MyGUI::Align::Top,
|
MyGUI::IntCoord(left, pag.getCurrentTop(), width, mImageHeight), MyGUI::Align::Left | MyGUI::Align::Top,
|
||||||
parent->getName() + MyGUI::utility::toString(parent->getChildCount()));
|
parent->getName() + MyGUI::utility::toString(parent->getChildCount()));
|
||||||
|
|
||||||
std::string image = MWBase::Environment::get().getWindowManager()->correctBookartPath(src, width, mImageHeight);
|
mImageBox->setImageTexture(src);
|
||||||
mImageBox->setImageTexture(image);
|
|
||||||
mImageBox->setProperty("NeedMouse", "false");
|
mImageBox->setProperty("NeedMouse", "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2090,9 +2090,12 @@ namespace MWGui
|
||||||
return Misc::ResourceHelpers::correctIconPath(path, mResourceSystem->getVFS());
|
return Misc::ResourceHelpers::correctIconPath(path, mResourceSystem->getVFS());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string WindowManager::correctBookartPath(const std::string& path, int width, int height)
|
std::string WindowManager::correctBookartPath(const std::string& path, int width, int height, bool* exists)
|
||||||
{
|
{
|
||||||
return Misc::ResourceHelpers::correctBookartPath(path, width, height, mResourceSystem->getVFS());
|
std::string corrected = Misc::ResourceHelpers::correctBookartPath(path, width, height, mResourceSystem->getVFS());
|
||||||
|
if (exists)
|
||||||
|
*exists = mResourceSystem->getVFS()->exists(corrected);
|
||||||
|
return corrected;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string WindowManager::correctTexturePath(const std::string& path)
|
std::string WindowManager::correctTexturePath(const std::string& path)
|
||||||
|
|
|
@ -388,7 +388,7 @@ namespace MWGui
|
||||||
|
|
||||||
// In WindowManager for now since there isn't a VFS singleton
|
// In WindowManager for now since there isn't a VFS singleton
|
||||||
virtual std::string correctIconPath(const std::string& path);
|
virtual std::string correctIconPath(const std::string& path);
|
||||||
virtual std::string correctBookartPath(const std::string& path, int width, int height);
|
virtual std::string correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr);
|
||||||
virtual std::string correctTexturePath(const std::string& path);
|
virtual std::string correctTexturePath(const std::string& path);
|
||||||
virtual bool textureExists(const std::string& path);
|
virtual bool textureExists(const std::string& path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue