|
|
@ -100,7 +100,7 @@ void CGroupHTML::addImageDownload(const string &url, CViewBase *img)
|
|
|
|
if (NLMISC::CFile::fileExists(dest))
|
|
|
|
if (NLMISC::CFile::fileExists(dest))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::setRWAccess(dest);
|
|
|
|
CFile::setRWAccess(dest);
|
|
|
|
NLMISC::CFile::deleteFile(dest.c_str());
|
|
|
|
NLMISC::CFile::deleteFile(dest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FILE *fp = fopen (dest.c_str(), "wb");
|
|
|
|
FILE *fp = fopen (dest.c_str(), "wb");
|
|
|
|
if (fp == NULL)
|
|
|
|
if (fp == NULL)
|
|
|
@ -111,7 +111,7 @@ void CGroupHTML::addImageDownload(const string &url, CViewBase *img)
|
|
|
|
curl_easy_setopt(curl, CURLOPT_FILE, fp);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_FILE, fp);
|
|
|
|
|
|
|
|
|
|
|
|
curl_multi_add_handle(MultiCurl, curl);
|
|
|
|
curl_multi_add_handle(MultiCurl, curl);
|
|
|
|
Curls.push_back(CDataDownload(curl, url, fp, ImgType, img));
|
|
|
|
Curls.push_back(CDataDownload(curl, url, fp, ImgType, img, ""));
|
|
|
|
#ifdef LOG_DL
|
|
|
|
#ifdef LOG_DL
|
|
|
|
nlwarning("adding handle %x, %d curls", curl, Curls.size());
|
|
|
|
nlwarning("adding handle %x, %d curls", curl, Curls.size());
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -145,8 +145,8 @@ string CGroupHTML::localBnpName(const string &url)
|
|
|
|
return dest;
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add a bnp download request in the multi_curl
|
|
|
|
// Add a bnp download request in the multi_curl, return true if already downloaded
|
|
|
|
void CGroupHTML::addBnpDownload(const string &url, const string &action)
|
|
|
|
bool CGroupHTML::addBnpDownload(const string &url, const string &action, const string &script)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Search if we are not already downloading this url.
|
|
|
|
// Search if we are not already downloading this url.
|
|
|
|
for(uint i = 0; i < Curls.size(); i++)
|
|
|
|
for(uint i = 0; i < Curls.size(); i++)
|
|
|
@ -156,13 +156,13 @@ void CGroupHTML::addBnpDownload(const string &url, const string &action)
|
|
|
|
#ifdef LOG_DL
|
|
|
|
#ifdef LOG_DL
|
|
|
|
nlwarning("already downloading '%s'", url.c_str());
|
|
|
|
nlwarning("already downloading '%s'", url.c_str());
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CURL *curl = curl_easy_init();
|
|
|
|
CURL *curl = curl_easy_init();
|
|
|
|
if (!MultiCurl || !curl)
|
|
|
|
if (!MultiCurl || !curl)
|
|
|
|
return;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
@ -177,7 +177,11 @@ void CGroupHTML::addBnpDownload(const string &url, const string &action)
|
|
|
|
if (action == "override" || action == "delete")
|
|
|
|
if (action == "override" || action == "delete")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::setRWAccess(dest);
|
|
|
|
CFile::setRWAccess(dest);
|
|
|
|
NLMISC::CFile::deleteFile(dest.c_str());
|
|
|
|
NLMISC::CFile::deleteFile(dest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (action != "delete")
|
|
|
|
if (action != "delete")
|
|
|
@ -186,17 +190,18 @@ void CGroupHTML::addBnpDownload(const string &url, const string &action)
|
|
|
|
if (fp == NULL)
|
|
|
|
if (fp == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nlwarning("Can't open file '%s' for writing: code=%d '%s'", dest.c_str (), errno, strerror(errno));
|
|
|
|
nlwarning("Can't open file '%s' for writing: code=%d '%s'", dest.c_str (), errno, strerror(errno));
|
|
|
|
return;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curl_easy_setopt(curl, CURLOPT_FILE, fp);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_FILE, fp);
|
|
|
|
|
|
|
|
|
|
|
|
curl_multi_add_handle(MultiCurl, curl);
|
|
|
|
curl_multi_add_handle(MultiCurl, curl);
|
|
|
|
Curls.push_back(CDataDownload(curl, url, fp, BnpType, NULL));
|
|
|
|
Curls.push_back(CDataDownload(curl, url, fp, BnpType, NULL, script));
|
|
|
|
#ifdef LOG_DL
|
|
|
|
#ifdef LOG_DL
|
|
|
|
nlwarning("adding handle %x, %d curls", curl, Curls.size());
|
|
|
|
nlwarning("adding handle %x, %d curls", curl, Curls.size());
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
RunningCurls++;
|
|
|
|
RunningCurls++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::initBnpDownload()
|
|
|
|
void CGroupHTML::initBnpDownload()
|
|
|
@ -316,8 +321,6 @@ void CGroupHTML::checkDownloads()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (lookupLocalFile (finalUrl, file.c_str(), false))
|
|
|
|
if (lookupLocalFile (finalUrl, file.c_str(), false))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nlinfo("BNPCHECK : downloaded");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool memoryCompressed = CPath::isMemoryCompressed();
|
|
|
|
bool memoryCompressed = CPath::isMemoryCompressed();
|
|
|
|
if (memoryCompressed)
|
|
|
|
if (memoryCompressed)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -329,7 +332,8 @@ void CGroupHTML::checkDownloads()
|
|
|
|
CPath::memoryCompress();
|
|
|
|
CPath::memoryCompress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
pIM->executeLuaScript("game:onBnpDownloadFinish()", true);
|
|
|
|
pIM->executeLuaScript(_ObjectScript, true);
|
|
|
|
|
|
|
|
_ObjectScript = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1367,6 +1371,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
|
|
|
|
_ObjectMD5Sum = value[HTML_OBJECT_ID];
|
|
|
|
_ObjectMD5Sum = value[HTML_OBJECT_ID];
|
|
|
|
if (present[HTML_OBJECT_STANDBY] && value[HTML_OBJECT_STANDBY])
|
|
|
|
if (present[HTML_OBJECT_STANDBY] && value[HTML_OBJECT_STANDBY])
|
|
|
|
_ObjectAction = value[HTML_OBJECT_STANDBY];
|
|
|
|
_ObjectAction = value[HTML_OBJECT_STANDBY];
|
|
|
|
|
|
|
|
_Object = true;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1494,10 +1499,15 @@ void CGroupHTML::endElement (uint element_number)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!_ObjectData.empty())
|
|
|
|
if (!_ObjectData.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
addBnpDownload(_ObjectData, _ObjectAction);
|
|
|
|
if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
|
|
|
pIM->executeLuaScript(_ObjectScript, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_Object = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2101,6 +2111,10 @@ void CGroupHTML::addString(const ucstring &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_TextAreaContent += tmpStr;
|
|
|
|
_TextAreaContent += tmpStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (_Object)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_ObjectScript += tmpStr.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (_SelectOption)
|
|
|
|
else if (_SelectOption)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!(_Forms.empty()))
|
|
|
|
if (!(_Forms.empty()))
|
|
|
@ -2447,9 +2461,18 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/
|
|
|
|
if (tooltip)
|
|
|
|
if (tooltip)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (CI18N::hasTranslation(tooltip))
|
|
|
|
if (CI18N::hasTranslation(tooltip))
|
|
|
|
|
|
|
|
{
|
|
|
|
ctrlButton->setDefaultContextHelp(CI18N::get(tooltip));
|
|
|
|
ctrlButton->setDefaultContextHelp(CI18N::get(tooltip));
|
|
|
|
|
|
|
|
//ctrlButton->setOnContextHelp(CI18N::get(tooltip).toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
ctrlButton->setDefaultContextHelp(ucstring(tooltip));
|
|
|
|
ctrlButton->setDefaultContextHelp(ucstring(tooltip));
|
|
|
|
|
|
|
|
//ctrlButton->setOnContextHelp(string(tooltip));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctrlButton->setInstantContextHelp(true);
|
|
|
|
|
|
|
|
ctrlButton->setToolTipParent(TTMouse);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getParagraph()->addChild (ctrlButton);
|
|
|
|
getParagraph()->addChild (ctrlButton);
|
|
|
@ -2486,6 +2509,7 @@ void CGroupHTML::clearContext()
|
|
|
|
_CellParams.clear();
|
|
|
|
_CellParams.clear();
|
|
|
|
_Title = false;
|
|
|
|
_Title = false;
|
|
|
|
_TextArea = false;
|
|
|
|
_TextArea = false;
|
|
|
|
|
|
|
|
_Object = false;
|
|
|
|
_Localize = false;
|
|
|
|
_Localize = false;
|
|
|
|
|
|
|
|
|
|
|
|
// TR
|
|
|
|
// TR
|
|
|
|