mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-23 07:16:15 +00:00
Fix html img not showing on some cases, clean up addImage method
This commit is contained in:
parent
e9256d3b0b
commit
ea2e8d1b92
1 changed files with 39 additions and 93 deletions
|
@ -3153,111 +3153,57 @@ namespace NLGUI
|
||||||
void CGroupHTML::addImage(const char *img, bool globalColor, bool reloadImg)
|
void CGroupHTML::addImage(const char *img, bool globalColor, bool reloadImg)
|
||||||
{
|
{
|
||||||
// In a paragraph ?
|
// In a paragraph ?
|
||||||
if (_Paragraph)
|
if (!_Paragraph)
|
||||||
{
|
{
|
||||||
string finalUrl;
|
newParagraph (0);
|
||||||
|
paragraphChange ();
|
||||||
|
}
|
||||||
|
|
||||||
|
string finalUrl;
|
||||||
|
|
||||||
|
// No more text in this text view
|
||||||
|
_CurrentViewLink = NULL;
|
||||||
|
|
||||||
|
// Not added ?
|
||||||
|
CViewBitmap *newImage = new CViewBitmap (TCtorParam());
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1/ try to load the image with the old system (local files in bnp)
|
||||||
|
//
|
||||||
|
string image = CFile::getPath(img) + CFile::getFilenameWithoutExtension(img) + ".tga";
|
||||||
|
if (lookupLocalFile (finalUrl, image.c_str(), false))
|
||||||
|
{
|
||||||
|
newImage->setRenderLayer(getRenderLayer()+1);
|
||||||
|
image = finalUrl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// 1/ try to load the image with the old system (local files in bnp)
|
// 2/ if it doesn't work, try to load the image in cache
|
||||||
//
|
//
|
||||||
string image = CFile::getPath(img) + CFile::getFilenameWithoutExtension(img) + ".tga";
|
image = localImageName(img);
|
||||||
if (lookupLocalFile (finalUrl, image.c_str(), false))
|
if (!reloadImg && lookupLocalFile (finalUrl, image.c_str(), false))
|
||||||
{
|
{
|
||||||
// No more text in this text view
|
// don't display image that are not power of 2
|
||||||
_CurrentViewLink = NULL;
|
uint32 w, h;
|
||||||
|
CBitmap::loadSize (image, w, h);
|
||||||
// Not added ?
|
if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures()))
|
||||||
CViewBitmap *newImage = new CViewBitmap (TCtorParam());
|
image.clear();
|
||||||
/* todo link in image
|
|
||||||
if (getA())
|
|
||||||
{
|
|
||||||
newImage->Link = getLink();
|
|
||||||
newImage->setHTMLView (this);
|
|
||||||
}*/
|
|
||||||
newImage->setRenderLayer(getRenderLayer()+1);
|
|
||||||
newImage->setTexture (finalUrl);
|
|
||||||
newImage->setModulateGlobalColor(globalColor);
|
|
||||||
|
|
||||||
/* todo link in image
|
|
||||||
if (getA())
|
|
||||||
getParagraph()->addChildLink(newImage);
|
|
||||||
else*/
|
|
||||||
getParagraph()->addChild(newImage);
|
|
||||||
paragraphChange ();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// 2/ if it doesn't work, try to load the image in cache
|
// 3/ if it doesn't work, display a placeholder and ask to dl the image into the cache
|
||||||
//
|
//
|
||||||
image = localImageName(img);
|
image = "web_del.tga";
|
||||||
if (!reloadImg && lookupLocalFile (finalUrl, image.c_str(), false))
|
addImageDownload(img, newImage);
|
||||||
{
|
|
||||||
// No more text in this text view
|
|
||||||
_CurrentViewLink = NULL;
|
|
||||||
|
|
||||||
// Not added ?
|
|
||||||
CViewBitmap *newImage = new CViewBitmap (TCtorParam());
|
|
||||||
/* todo link in image
|
|
||||||
if (getA())
|
|
||||||
{
|
|
||||||
newImage->Link = getLink();
|
|
||||||
newImage->setHTMLView (this);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// don't display image that are not power of 2
|
|
||||||
uint32 w, h;
|
|
||||||
CBitmap::loadSize (image, w, h);
|
|
||||||
if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures()))
|
|
||||||
image.clear();
|
|
||||||
|
|
||||||
newImage->setTexture (image);
|
|
||||||
// newImage->setTexture (finalUrl);
|
|
||||||
newImage->setModulateGlobalColor(globalColor);
|
|
||||||
|
|
||||||
/* todo link in image
|
|
||||||
if (getA())
|
|
||||||
getParagraph()->addChildLink(newImage);
|
|
||||||
else*/
|
|
||||||
getParagraph()->addChild(newImage);
|
|
||||||
paragraphChange ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
//
|
|
||||||
// 3/ if it doesn't work, display a placeholder and ask to dl the image into the cache
|
|
||||||
//
|
|
||||||
image = "web_del.tga";
|
|
||||||
if (lookupLocalFile (finalUrl, image.c_str(), false))
|
|
||||||
{
|
|
||||||
// No more text in this text view
|
|
||||||
_CurrentViewLink = NULL;
|
|
||||||
|
|
||||||
// Not added ?
|
|
||||||
CViewBitmap *newImage = new CViewBitmap (TCtorParam());
|
|
||||||
/* todo link in image
|
|
||||||
if (getA())
|
|
||||||
{
|
|
||||||
newImage->Link = getLink();
|
|
||||||
newImage->setHTMLView (this);
|
|
||||||
}*/
|
|
||||||
newImage->setTexture (image);
|
|
||||||
// newImage->setTexture (finalUrl);
|
|
||||||
newImage->setModulateGlobalColor(globalColor);
|
|
||||||
|
|
||||||
addImageDownload(img, newImage);
|
|
||||||
|
|
||||||
/* todo link in image
|
|
||||||
if (getA())
|
|
||||||
getParagraph()->addChildLink(newImage);
|
|
||||||
else*/
|
|
||||||
getParagraph()->addChild(newImage);
|
|
||||||
paragraphChange ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
newImage->setTexture (image);
|
||||||
|
newImage->setModulateGlobalColor(globalColor);
|
||||||
|
|
||||||
|
getParagraph()->addChild(newImage);
|
||||||
|
paragraphChange ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
Loading…
Reference in a new issue