Added: Downloadable textures in texture property of CViewBitmap

--HG--
branch : develop
This commit is contained in:
ulukyn 2018-06-12 14:43:20 +02:00
parent 1a128ac269
commit 0863830734
2 changed files with 24 additions and 7 deletions

View file

@ -106,6 +106,10 @@ namespace NLGUI
sint32 MaxHeight; sint32 MaxHeight;
}; };
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
enum TImageType {NormalImage=0, OverImage};
// Constructor // Constructor
CGroupHTML(const TCtorParam &param); CGroupHTML(const TCtorParam &param);
~CGroupHTML(); ~CGroupHTML();
@ -151,6 +155,10 @@ namespace NLGUI
// End of the paragraph // End of the paragraph
void endParagraph(); 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 // Timeout
void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);} void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);}
@ -722,6 +730,8 @@ namespace NLGUI
return 0; return 0;
return _Indent.back(); return _Indent.back();
} }
// Current node is a title // Current node is a title
bool _Title; bool _Title;
@ -811,10 +821,6 @@ namespace NLGUI
private: private:
// decode all HTML entities // decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str); static ucstring decodeHTMLEntities(const ucstring &str);
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
enum TImageType {NormalImage=0, OverImage};
struct CDataImageDownload struct CDataImageDownload
{ {
@ -857,8 +863,6 @@ namespace NLGUI
void initImageDownload(); void initImageDownload();
void checkImageDownload(); 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); std::string getAbsoluteUrl(const std::string &url);
bool isTrustedDomain(const std::string &domain); bool isTrustedDomain(const std::string &domain);

View file

@ -21,6 +21,7 @@
#include "nel/gui/widget_manager.h" #include "nel/gui/widget_manager.h"
#include "nel/gui/interface_group.h" #include "nel/gui/interface_group.h"
#include "nel/gui/group_container_base.h" #include "nel/gui/group_container_base.h"
#include "nel/gui/group_html.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -452,7 +453,19 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CViewBitmap::setTexture(const std::string & TxName) void CViewBitmap::setTexture(const std::string & TxName)
{ {
_TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); 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);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------