Added: get and set rgba database entry

--HG--
branch : patches-from-atys
hg/hotfix/patches-from-atys
Inky 6 years ago
parent 9780decca0
commit 2f2329c67f

@ -4132,3 +4132,47 @@ std::string CLuaIHMRyzom::createGotoFileButtonTag(const char *fileName, uint lin
return "";
}
// ***************************************************************************
void CLuaIHMRyzom::setDbRGBA(const std::string &dbProp, const NLMISC::CRGBA &color)
{
//H_AUTO(Lua_CLuaIHM_setDbRGBA)
static const std::string dbServer = "SERVER:";
static const std::string dbLocal = "LOCAL:";
static const std::string dbLocalR2 = "LOCAL:R2";
// do not allow write on SERVER: or LOCAL:
if ((dbProp.compare(0, dbServer.size(), dbServer) == 0) || (dbProp.compare(0, dbLocal.size(), dbLocal) == 0))
{
if (dbProp.compare(0, dbLocalR2.size(), dbLocalR2) != 0)
{
nlstop;
throw ELuaIHMException("setDbRGBA(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
}
}
// write to the db
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbProp, true);
if (node)
node->setValue64(color.R+(color.G<<8)+(color.B<<16)+(color.A<<24));
return;
}
// ***************************************************************************
std::string CLuaIHMRyzom::getDbRGBA(const std::string &dbProp)
{
//H_AUTO(Lua_CLuaIHM_getDbRGBA)
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbProp, false);
if (node)
{
CRGBA color = CRGBA::White;
sint64 rgba = (sint64)node->getValue64();
color.R = (sint8)(rgba & 0xff);
color.G = (sint8)((rgba >> 8) & 0xff);
color.B = (sint8)((rgba >> 16) & 0xff);
color.A = (sint8)((rgba >> 24) & 0xff);
return toString("%i %i %i %i", color.R, color.G, color.B, color.A);
}
return "";
}

@ -129,6 +129,8 @@ private:
static void setDbProp64(const std::string &dbProp, sint64 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);
static void setDbRGBA(const std::string &dbProp, const NLMISC::CRGBA &color); // the db prop is created if not present
static std::string getDbRGBA(const std::string &dbProp); // empty string if not found
public:
// Print a message in the log.

Loading…
Cancel
Save