Added: Downloadable textures in texture property of CViewBitmap

--HG--
branch : compatibility-develop
hg/compatibility-develop
ulukyn 7 years ago
parent a7e2f90e1e
commit fb2ab5c6a7

@ -106,6 +106,10 @@ namespace NLGUI
sint32 MaxHeight;
};
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
enum TImageType {NormalImage=0, OverImage};
// Constructor
CGroupHTML(const TCtorParam &param);
~CGroupHTML();
@ -152,6 +156,10 @@ namespace NLGUI
// End of the paragraph
void endParagraph();
// add image download (used by view_bitmap.cpp to load web images)
void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage);
std::string localImageName(const std::string &url);
// Timeout
void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);}
float getTimeout() const {return (float)_TimeoutValue;}
@ -730,6 +738,8 @@ namespace NLGUI
return _Indent.back();
}
// Current node is a title
bool _Title;
@ -819,10 +829,6 @@ namespace NLGUI
// decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str);
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
enum TImageType {NormalImage=0, OverImage};
struct CDataImageDownload
{
public:
@ -864,8 +870,6 @@ namespace NLGUI
void initImageDownload();
void checkImageDownload();
void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage);
std::string localImageName(const std::string &url);
std::string getAbsoluteUrl(const std::string &url);
bool isTrustedDomain(const std::string &domain);

@ -21,6 +21,7 @@
#include "nel/gui/widget_manager.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/group_container_base.h"
#include "nel/gui/group_html.h"
using namespace std;
using namespace NLMISC;
@ -452,6 +453,18 @@ namespace NLGUI
// ----------------------------------------------------------------------------
void CViewBitmap::setTexture(const std::string & TxName)
{
if (TxName.find("://") != string::npos || TxName.find("//") == 0)
{
CGroupHTML *groupHtml = dynamic_cast<CGroupHTML*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:webig:content:html"));
if (groupHtml) {
string localname = groupHtml->localImageName(TxName);
if (!CFile::fileExists(localname))
localname = "web_del.tga";
_TextureId.setTexture (localname.c_str(), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false);
groupHtml->addImageDownload(TxName, dynamic_cast<CViewBase*>(this));
}
}
else
_TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false);
}

Loading…
Cancel
Save