Added: Trigger to know when an image is downloaded (using lua callback)

md5() lua function

--HG--
branch : compatibility-develop
hg/compatibility-develop
ulukyn 7 years ago
parent 5c9418cff7
commit b377eefdf3

@ -482,6 +482,7 @@ namespace NLGUI
if (Curls.size() < options.curlMaxConnections) {
if (!startCurlDownload(Curls.back()))
{
CLuaManager::getInstance().executeLuaScript("downloadedImage('"+this->_Id+"', '"+url+"', '"+dest+"')", true);
Curls.pop_back();
return;
}
@ -778,6 +779,8 @@ namespace NLGUI
obj.LastModified = it->data->getLastModified();
CHttpCache::getInstance()->store(it->dest, obj);
CLuaManager::getInstance().executeLuaScript("downloadedImage('"+this->_Id+"', '"+it->url+"', '"+it->dest+"')", true);
}
}
}
@ -812,6 +815,7 @@ namespace NLGUI
{
setImage(it->imgs[i].Image, it->dest, it->imgs[i].Type);
setImageSize(it->imgs[i].Image, it->imgs[i].Style);
CLuaManager::getInstance().executeLuaScript("downloadedImage('"+this->_Id+"', '"+it->url+"', '"+it->dest+"')", true);
}
}
}
@ -4456,6 +4460,7 @@ namespace NLGUI
{
newImage->setRenderLayer(getRenderLayer()+1);
image = finalUrl;
CLuaManager::getInstance().executeLuaScript("downloadedImage('"+this->_Id+"', '"+image+"', '"+finalUrl+"')", true);
}
else
{

@ -8,6 +8,25 @@ if (webig.sheetLists==nil) then
webig.sheetLists = {}
end
if (webig.downloadedImageCallbacks==nil) then
webig.downloadedImageCallbacks = {}
end
function webig:addDownloadedImageCallbacks(ui, nbr_images, callback)
webig.downloadedImageCallbacks[ui] = {nbr_images, callback}
end
function downloadedImage(ui, src, dest)
if webig.downloadedImageCallbacks[ui] ~= nil then
local cb = webig.downloadedImageCallbacks[ui]
cb[1] = cb[1] - 1
if cb[1] <= 0 then
local c = cb[2]
_G[c]()
webig.downloadedImageCallbacks[ui] = nil
end
end
end
function webig:addSheet(dst, sheet, quality, quantity, worned, user_color, rm_class_type, rm_faber_stat_type)
if quality == nil then quality=0 end

@ -499,6 +499,7 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls)
[
LUABIND_FUNC(getDbProp),
LUABIND_FUNC(getDbProp64),
LUABIND_FUNC(md5),
LUABIND_FUNC(setDbProp),
LUABIND_FUNC(addDbProp),
LUABIND_FUNC(delDbProp),
@ -2593,6 +2594,11 @@ sint64 CLuaIHMRyzom::getDbProp64(const std::string &dbProp)
}
}
string CLuaIHMRyzom::md5(const std::string &text)
{
return getMD5((uint8*)text.c_str(), text.size()).toString();
}
void CLuaIHMRyzom::setDbProp(const std::string &dbProp, sint32 value)
{

@ -121,6 +121,7 @@ private:
static sint32 getDbProp(const std::string &dbProp); // return 0 if not found.
static sint64 getDbProp64(const std::string &dbProp); // return 0 if not found.
static std::string md5(const std::string &text);
static void setDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is not created if not present.
static void addDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is created if not present.
static void delDbProp(const std::string &dbProp);

Loading…
Cancel
Save