Merge with lua

--HG--
branch : compatibility-develop
hg/compatibility-develop
Inky 6 years ago
commit c469194de3

@ -4133,3 +4133,100 @@ 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 "";
}
// ***************************************************************************
int CLuaIHMRyzom::displayChatMessage(CLuaState &ls)
{
//H_AUTO(Lua_CLuaIHM_displayChatMessage)
const char *funcName = "displayChatMessage";
CLuaIHM::checkArgMin(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
CInterfaceProperty prop;
CChatStdInput &ci = PeopleInterraction.ChatInput;
std::string msg = ls.toString(1);
const std::string dbPath = "UI:SAVE:CHAT:COLORS";
if (ls.type(2) == LUA_TSTRING)
{
std::string input = toLower(ls.toString(2));
std::unordered_map<std::string, std::string> sParam;
// input should match chat_group_filter sParam
sParam.insert(make_pair(string("around"), string(dbPath+":SAY")));
sParam.insert(make_pair(string("region"), string(dbPath+":REGION")));
sParam.insert(make_pair(string("guild"), string(dbPath+":CLADE")));
sParam.insert(make_pair(string("team"), string(dbPath+":GROUP")));
sParam.insert(make_pair(string("universe"), string(dbPath+":UNIVERSE_NEW")));
for (const auto& db : sParam)
{
if (db.first.c_str() == input)
{
prop.readRGBA(db.second.c_str(), " ");
if (input == "around")
ci.AroundMe.displayMessage(ucstring(msg), prop.getRGBA());
if (input == "region")
ci.Region.displayMessage(ucstring(msg), prop.getRGBA());
if (input == "universe")
ci.Universe.displayMessage(ucstring(msg), prop.getRGBA());
if (input == "guild")
ci.Guild.displayMessage(ucstring(msg), prop.getRGBA());
if (input == "team")
ci.Team.displayMessage(ucstring(msg), prop.getRGBA());
break;
}
}
}
if (ls.type(2) == LUA_TNUMBER)
{
sint64 id = ls.toInteger(2);
prop.readRGBA(toString("%s:DYN:%i", dbPath.c_str(), id).c_str(), " ");
if (id >= 0 && id < CChatGroup::MaxDynChanPerPlayer)
ci.DynamicChat[id].displayMessage(ucstring(msg), prop.getRGBA());
}
return 1;
}

@ -60,6 +60,7 @@ private:
static int getMainPageURL(CLuaState &ls);
static int getCharSlot(CLuaState &ls);
static int displaySystemInfo(CLuaState &ls);
static int displayChatMessage(CLuaState &ls);
static int setWeatherValue(CLuaState &ls); // first value is a boolean to say automatic, second value ranges from of to 1 and gives the weather
static int getWeatherValue(CLuaState &ls); // get current real weather value (blend between server driven value & predicted value). Manual weather value is ignored
static int disableContextHelpForControl(CLuaState &ls); // params: CCtrlBase*. return: none
@ -129,6 +130,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