|
|
@ -58,6 +58,7 @@
|
|
|
|
#include "nel/gui/css_style.h"
|
|
|
|
#include "nel/gui/css_style.h"
|
|
|
|
#include "nel/gui/css_parser.h"
|
|
|
|
#include "nel/gui/css_parser.h"
|
|
|
|
#include "nel/gui/css_border_renderer.h"
|
|
|
|
#include "nel/gui/css_border_renderer.h"
|
|
|
|
|
|
|
|
#include "nel/gui/css_background_renderer.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
|
|
|
@ -346,6 +347,25 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::TextureDownloadCB::finish()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// tmpdest file does not exist if download skipped (ie cache was used)
|
|
|
|
|
|
|
|
if (CFile::fileExists(tmpdest) && CFile::getFileSize(tmpdest) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (CFile::fileExists(dest))
|
|
|
|
|
|
|
|
CFile::deleteFile(dest);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CFile::moveFile(dest, tmpdest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
|
|
|
|
|
|
|
for(uint i = 0; i < TextureIds.size(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rVR.reloadTexture(TextureIds[i].first, dest);
|
|
|
|
|
|
|
|
TextureIds[i].second->invalidateCoords();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::BnpDownloadCB::finish()
|
|
|
|
void CGroupHTML::BnpDownloadCB::finish()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool verified = false;
|
|
|
|
bool verified = false;
|
|
|
@ -734,6 +754,63 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add a image download request in the multi_curl
|
|
|
|
|
|
|
|
// return new textureId and download callback
|
|
|
|
|
|
|
|
ICurlDownloadCB *CGroupHTML::addTextureDownload(const string &url, sint32 &texId, CViewBase *view)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
|
|
|
|
|
|
|
// data:image/png;base64,AA...==
|
|
|
|
|
|
|
|
if (startsWith(url, "data:image/"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
texId = rVR.createTextureFromDataURL(url);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string finalUrl;
|
|
|
|
|
|
|
|
// load the image from local files/bnp
|
|
|
|
|
|
|
|
if (lookupLocalFile(finalUrl, std::string(CFile::getPath(url) + CFile::getFilenameWithoutExtension(url) + ".tga").c_str(), false))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
texId = rVR.createTexture(finalUrl);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
finalUrl = upgradeInsecureUrl(getAbsoluteUrl(url));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// use requested url for local name (cache)
|
|
|
|
|
|
|
|
string dest = localImageName(url);
|
|
|
|
|
|
|
|
LOG_DL("add to download '%s' dest '%s'", finalUrl.c_str(), dest.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CFile::fileExists(dest) && CFile::getFileSize(dest) > 0)
|
|
|
|
|
|
|
|
texId = rVR.createTexture(dest);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
texId = rVR.newTextureId(dest);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Search if we are not already downloading this url.
|
|
|
|
|
|
|
|
for(std::list<CDataDownload*>::iterator it = Curls.begin(); it != Curls.end(); ++it)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if((*it)->url == finalUrl)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOG_DL("already downloading '%s' img %p", finalUrl.c_str(), img);
|
|
|
|
|
|
|
|
TextureDownloadCB *cb = dynamic_cast<TextureDownloadCB*>(*it);
|
|
|
|
|
|
|
|
if (cb)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cb->addTexture(texId, view);
|
|
|
|
|
|
|
|
// return pointer to shared ImageDownloadCB
|
|
|
|
|
|
|
|
return cb;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("Found texture download '%s', but casting to TextureDownloadCB failed", finalUrl.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Curls.push_back(new TextureDownloadCB(finalUrl, dest, texId, this));
|
|
|
|
|
|
|
|
// as we return pointer to callback, skip starting downloads just now
|
|
|
|
|
|
|
|
//pumpCurlQueue();
|
|
|
|
|
|
|
|
return Curls.back();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add a image download request in the multi_curl
|
|
|
|
// Add a image download request in the multi_curl
|
|
|
|
ICurlDownloadCB *CGroupHTML::addImageDownload(const string &url, CViewBase *img, const CStyleParams &style, TImageType type, const std::string &placeholder)
|
|
|
|
ICurlDownloadCB *CGroupHTML::addImageDownload(const string &url, CViewBase *img, const CStyleParams &style, TImageType type, const std::string &placeholder)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -2331,6 +2408,38 @@ namespace NLGUI
|
|
|
|
doBrowseAnchor(_UrlFragment);
|
|
|
|
doBrowseAnchor(_UrlFragment);
|
|
|
|
_UrlFragment.clear();
|
|
|
|
_UrlFragment.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!m_HtmlBackground.isEmpty() || !m_BodyBackground.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// get scroll offset from list
|
|
|
|
|
|
|
|
CGroupList *list = getList();
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CInterfaceElement* vp = list->getParentPos() ? list->getParentPos() : this;
|
|
|
|
|
|
|
|
sint htmlW = std::max(vp->getWReal(), list->getWReal());
|
|
|
|
|
|
|
|
sint htmlH = list->getHReal();
|
|
|
|
|
|
|
|
sint htmlX = list->getXReal() + list->getOfsX();
|
|
|
|
|
|
|
|
sint htmlY = list->getYReal() + list->getOfsY();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!m_HtmlBackground.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_HtmlBackground.setFillViewport(true);
|
|
|
|
|
|
|
|
m_HtmlBackground.setBorderArea(htmlX, htmlY, htmlW, htmlH);
|
|
|
|
|
|
|
|
m_HtmlBackground.setPaddingArea(htmlX, htmlY, htmlW, htmlH);
|
|
|
|
|
|
|
|
m_HtmlBackground.setContentArea(htmlX, htmlY, htmlW, htmlH);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!m_BodyBackground.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: html padding + html border
|
|
|
|
|
|
|
|
m_BodyBackground.setBorderArea(htmlX, htmlY, htmlW, htmlH);
|
|
|
|
|
|
|
|
// TODO: html padding + html border + body border
|
|
|
|
|
|
|
|
m_BodyBackground.setPaddingArea(htmlX, htmlY, htmlW, htmlH);
|
|
|
|
|
|
|
|
// TODO: html padding + html_border + body padding
|
|
|
|
|
|
|
|
m_BodyBackground.setContentArea(htmlX, htmlY, htmlW, htmlH);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
@ -3185,52 +3294,47 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::setupBackground(CSSBackgroundRenderer *bg)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!bg) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bg->setModulateGlobalColor(_Style.Current.GlobalColor);
|
|
|
|
|
|
|
|
bg->setBackground(_Style.Current.Background);
|
|
|
|
|
|
|
|
bg->setFontSize(_Style.Root.FontSize, _Style.Current.FontSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bg->setViewport(getList()->getParentPos() ? getList()->getParentPos() : this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!_Style.Current.Background.image.empty())
|
|
|
|
|
|
|
|
addTextureDownload(_Style.Current.Background.image, bg->TextureId, this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::setBackgroundColor (const CRGBA &bgcolor)
|
|
|
|
void CGroupHTML::setBackgroundColor (const CRGBA &bgcolor)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Should have a child named bg
|
|
|
|
// TODO: DefaultBackgroundBitmapView should be removed from interface xml
|
|
|
|
CViewBase *view = getView (DefaultBackgroundBitmapView);
|
|
|
|
CViewBase *view = getView (DefaultBackgroundBitmapView);
|
|
|
|
if (view)
|
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
view->setActive(false);
|
|
|
|
CViewBitmap *bitmap = dynamic_cast<CViewBitmap*> (view);
|
|
|
|
|
|
|
|
if (bitmap)
|
|
|
|
m_HtmlBackground.setColor(bgcolor);
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: background color should have separate bitmap from background texture
|
|
|
|
|
|
|
|
// Change the background color
|
|
|
|
|
|
|
|
bitmap->setColor (bgcolor);
|
|
|
|
|
|
|
|
bitmap->setModulateGlobalColor(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::setBackground (const string &bgtex, bool scale, bool tile)
|
|
|
|
void CGroupHTML::setBackground (const string &bgtex, bool scale, bool tile)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Should have a child named bg
|
|
|
|
// TODO: DefaultBackgroundBitmapView should be removed from interface xml
|
|
|
|
CViewBase *view = getView (DefaultBackgroundBitmapView);
|
|
|
|
CViewBase *view = getView (DefaultBackgroundBitmapView);
|
|
|
|
if (view)
|
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
view->setActive(false);
|
|
|
|
CViewBitmap *bitmap = dynamic_cast<CViewBitmap*> (view);
|
|
|
|
|
|
|
|
if (bitmap)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bitmap->setParentPosRef(Hotspot_TL);
|
|
|
|
|
|
|
|
bitmap->setPosRef(Hotspot_TL);
|
|
|
|
|
|
|
|
bitmap->setX(0);
|
|
|
|
|
|
|
|
bitmap->setY(0);
|
|
|
|
|
|
|
|
// FIXME: renders behind container background
|
|
|
|
|
|
|
|
bitmap->setRenderLayer(-2);
|
|
|
|
|
|
|
|
bitmap->setScale(scale);
|
|
|
|
|
|
|
|
bitmap->setTile(tile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clear size ref for non-scaled image or it does not show up
|
|
|
|
m_HtmlBackground.setImage(bgtex);
|
|
|
|
if (scale || tile)
|
|
|
|
m_HtmlBackground.setImageRepeat(tile);
|
|
|
|
bitmap->setSizeRef("wh");
|
|
|
|
m_HtmlBackground.setImageCover(scale);
|
|
|
|
else
|
|
|
|
|
|
|
|
bitmap->setSizeRef("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addImageDownload(bgtex, view, CStyleParams(), NormalImage, "");
|
|
|
|
if (!bgtex.empty())
|
|
|
|
}
|
|
|
|
addTextureDownload(bgtex, m_HtmlBackground.TextureId, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -4013,6 +4117,8 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::draw ()
|
|
|
|
void CGroupHTML::draw ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
m_HtmlBackground.draw();
|
|
|
|
|
|
|
|
m_BodyBackground.draw();
|
|
|
|
CGroupScrollText::draw ();
|
|
|
|
CGroupScrollText::draw ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -4081,9 +4187,14 @@ namespace NLGUI
|
|
|
|
// Clear all the context
|
|
|
|
// Clear all the context
|
|
|
|
clearContext();
|
|
|
|
clearContext();
|
|
|
|
|
|
|
|
|
|
|
|
// Reset default background color
|
|
|
|
// Reset default background
|
|
|
|
setBackgroundColor (_BrowserStyle.Current.Background.color);
|
|
|
|
m_HtmlBackground.clear();
|
|
|
|
setBackground ("blank.tga", true, false);
|
|
|
|
m_BodyBackground.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: DefaultBackgroundBitmapView should be removed from interface xml
|
|
|
|
|
|
|
|
CViewBase *view = getView (DefaultBackgroundBitmapView);
|
|
|
|
|
|
|
|
if (view)
|
|
|
|
|
|
|
|
view->setActive(false);
|
|
|
|
|
|
|
|
|
|
|
|
paragraphChange ();
|
|
|
|
paragraphChange ();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -5091,46 +5202,6 @@ namespace NLGUI
|
|
|
|
_CellParams.push_back (cellParams);
|
|
|
|
_CellParams.push_back (cellParams);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CGroupHTML::applyBackground(const CHtmlElement &elm)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool root = elm.Value == "html" || elm.Value == "body";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// non-empty image
|
|
|
|
|
|
|
|
if (_Style.hasStyle("background-image"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool repeat = _Style.checkStyle("background-repeat", "repeat");
|
|
|
|
|
|
|
|
bool scale = _Style.checkStyle("background-size", "100%");
|
|
|
|
|
|
|
|
std::string image = _Style.getStyle("background-image");
|
|
|
|
|
|
|
|
if (!image.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (root)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
setBackground (image, scale, repeat);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: else
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// default background color is transparent, so image does not show
|
|
|
|
|
|
|
|
if (!_Style.hasStyle("background-color") || _Style.checkStyle("background-color", "transparent"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_Style.applyStyle("background-color: #fff;");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_Style.hasStyle("background-color"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CRGBA bgColor = _Style.Current.Background.color;
|
|
|
|
|
|
|
|
scanHTMLColor(elm.getAttribute("bgcolor").c_str(), bgColor);
|
|
|
|
|
|
|
|
if (root)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
setBackgroundColor(bgColor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: else
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupHTML::insertFormImageButton(const std::string &name, const std::string &tooltip, const std::string &src, const std::string &over, const std::string &formId, const std::string &action, uint32 minWidth, const std::string &templateName)
|
|
|
|
void CGroupHTML::insertFormImageButton(const std::string &name, const std::string &tooltip, const std::string &src, const std::string &over, const std::string &formId, const std::string &action, uint32 minWidth, const std::string &templateName)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -5261,11 +5332,12 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// override <body> (or <html>) css style attribute
|
|
|
|
// override <body> (or <html>) css style attribute
|
|
|
|
if (elm.hasNonEmptyAttribute("bgcolor"))
|
|
|
|
if (elm.hasNonEmptyAttribute("bgcolor"))
|
|
|
|
{
|
|
|
|
|
|
|
|
_Style.applyStyle("background-color: " + elm.getAttribute("bgcolor"));
|
|
|
|
_Style.applyStyle("background-color: " + elm.getAttribute("bgcolor"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applyBackground(elm);
|
|
|
|
if (m_HtmlBackground.isEmpty())
|
|
|
|
|
|
|
|
setupBackground(&m_HtmlBackground);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
setupBackground(&m_BodyBackground);
|
|
|
|
|
|
|
|
|
|
|
|
renderPseudoElement(":before", elm);
|
|
|
|
renderPseudoElement(":before", elm);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -5659,11 +5731,11 @@ namespace NLGUI
|
|
|
|
void CGroupHTML::htmlHTML(const CHtmlElement &elm)
|
|
|
|
void CGroupHTML::htmlHTML(const CHtmlElement &elm)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (elm.hasNonEmptyAttribute("style"))
|
|
|
|
if (elm.hasNonEmptyAttribute("style"))
|
|
|
|
{
|
|
|
|
|
|
|
|
_Style.applyStyle(elm.getAttribute("style"));
|
|
|
|
_Style.applyStyle(elm.getAttribute("style"));
|
|
|
|
}
|
|
|
|
|
|
|
|
_Style.Root = _Style.Current;
|
|
|
|
_Style.Root = _Style.Current;
|
|
|
|
applyBackground(elm);
|
|
|
|
|
|
|
|
|
|
|
|
setupBackground(&m_HtmlBackground);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|