diff --git a/code/nel/include/nel/gui/interface_link.h b/code/nel/include/nel/gui/interface_link.h index ffa6ac0c7..42fb2bbcf 100644 --- a/code/nel/include/nel/gui/interface_link.h +++ b/code/nel/include/nel/gui/interface_link.h @@ -66,6 +66,11 @@ namespace NLGUI */ bool affect(const CInterfaceExprValue &value); }; + struct CCDBTargetInfo + { + NLMISC::CRefPtr Leaf; + std::string LeafName; + }; /// Updates triggered interface links when triggered by the observed branch @@ -85,7 +90,7 @@ namespace NLGUI * If there are no target element, the link is permanent (removed at exit) * NB : The target is not updated during this call. */ - bool init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent); + bool init(const std::vector &targets, const std::vector &cdbTargets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent); // force all the links that have been created to update their targets. This can be called when the interface has been loaded, and when the databse entries have been retrieved. static void updateAllLinks(); // force all trigered links to be updated @@ -119,6 +124,7 @@ namespace NLGUI * \return true if all targets are valid */ static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect); + static bool splitLinkTargetsExt(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect, std::vector &cdbTargetsVect); //////////////////////////////////////////////////////////////////////////////////////////////////////// private: friend struct CRemoveTargetPred; @@ -135,12 +141,14 @@ namespace NLGUI typedef std::vector TNodeVect; private: std::vector _Targets; + std::vector _CDBTargets; TNodeVect _ObservedNodes; std::string _Expr; CInterfaceExprNode *_ParseTree; std::string _ActionHandler; std::string _AHParams; std::string _AHCond; + CInterfaceExprNode *_AHCondParsed; CInterfaceGroup *_AHParent; static TLinkList _LinkList; TLinkList::iterator _ListEntry; diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 7fedc6240..00723faea 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -444,7 +444,7 @@ namespace NLGUI } float getAlphaRolloverSpeed(); - void resetAlphaRolloverSpeed(); + void resetAlphaRolloverSpeedProps(); void setContainerAlpha( uint8 alpha ); uint8 getContainerAlpha() const { return _ContainerAlpha; } @@ -454,6 +454,7 @@ namespace NLGUI uint8 getGlobalRolloverFactorContainer() const { return _GlobalRolloverFactorContainer; } void updateGlobalAlphas(); + void resetGlobalAlphasProps(); const SInterfaceTimes& getInterfaceTimes() const{ return interfaceTimes; } void updateInterfaceTimes( const SInterfaceTimes × ){ interfaceTimes = times; } @@ -527,6 +528,11 @@ namespace NLGUI NLMISC::CCDBNodeLeaf *_BProp; NLMISC::CCDBNodeLeaf *_AProp; NLMISC::CCDBNodeLeaf *_AlphaRolloverSpeedDB; + + NLMISC::CCDBNodeLeaf *_GlobalContentAlphaDB; + NLMISC::CCDBNodeLeaf *_GlobalContainerAlphaDB; + NLMISC::CCDBNodeLeaf *_GlobalContentRolloverFactorDB; + NLMISC::CCDBNodeLeaf *_GlobalContainerRolloverFactorDB; uint8 _ContainerAlpha; uint8 _GlobalContentAlpha; diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index f981814ba..4e8919e5c 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -2325,7 +2325,8 @@ namespace NLGUI _LUAOnDbChange[dbList]= newLink; // Init and attach to list of untargeted links std::vector noTargets; - newLink->init(noTargets, NLMISC::toString("depends(%s)", dbList.c_str()), "lua", script, "", this); + std::vector noCdbTargets; + newLink->init(noTargets, noCdbTargets, NLMISC::toString("depends(%s)", dbList.c_str()), "lua", script, "", this); } // ------------------------------------------------------------------------------------------------ diff --git a/code/nel/src/gui/interface_link.cpp b/code/nel/src/gui/interface_link.cpp index d672e9402..282199ee7 100644 --- a/code/nel/src/gui/interface_link.cpp +++ b/code/nel/src/gui/interface_link.cpp @@ -165,6 +165,7 @@ namespace NLGUI _NextTriggeredLink[0] = _NextTriggeredLink[1] = NULL; _Triggered[0] = _Triggered[1] = false; _ParseTree = NULL; + _AHCondParsed = NULL; } //=========================================================== @@ -187,10 +188,13 @@ namespace NLGUI _LinkList.erase(_ListEntry); delete _ParseTree; + _ParseTree = NULL; + delete _AHCondParsed; + _AHCondParsed = NULL; } //=========================================================== - bool CInterfaceLink::init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parentGroup) + bool CInterfaceLink::init(const std::vector &targets, const std::vector &cdbTargets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parentGroup) { CInterfaceExprValue result; // Build the parse tree @@ -236,6 +240,7 @@ namespace NLGUI // There are no target for this link, so, put in a dedicated list to ensure that the link will be destroyed at exit _LinksWithNoTarget.push_back(TLinkSmartPtr(this)); } + _CDBTargets = cdbTargets; // create observers createObservers(_ObservedNodes); @@ -243,7 +248,12 @@ namespace NLGUI // _ActionHandler = actionHandler; _AHParams = ahParams; + nlassert(!_AHCondParsed); _AHCond = ahCond; + if (!ahCond.empty()) + { + _AHCondParsed = CInterfaceExpr::buildExprTree(ahCond); + } _AHParent = parentGroup; return true; } @@ -356,19 +366,47 @@ namespace NLGUI } } } + if (_CDBTargets.size()) + { + CInterfaceExprValue resultCopy = result; + if (resultCopy.toInteger()) + { + sint64 resultValue = resultCopy.getInteger(); + for (uint k = 0; k < _CDBTargets.size(); ++k) + { + NLMISC::CCDBNodeLeaf *node = _CDBTargets[k].Leaf; + if (!node) + { + node = _CDBTargets[k].Leaf = NLGUI::CDBManager::getInstance()->getDbProp(_CDBTargets[k].LeafName, false); + } + if (node) + { + // assuming setvalue64 always works + node->setValue64(resultValue); + } + else + { + nlwarning("CInterfaceLink::update: Node does not exist: '%s'", _CDBTargets[k].LeafName.c_str()); + } + } + } + else + { + nlwarning("CInterfaceLink::update: Result conversion to db target failed"); + } + } // if there's an action handler, execute it if (!_ActionHandler.empty()) { // If there is a condition, test it. - bool launch= true; - if(!_AHCond.empty()) + bool launch = _AHCond.empty(); + if (_AHCondParsed) // todo: maybe makes more sense to make condition also cover target { - launch= false; - CInterfaceExprValue result; - if(CInterfaceExpr::eval(_AHCond, result)) - launch= result.getBool(); + CInterfaceExprValue result; + _AHCondParsed->eval(result); + launch = result.getBool(); } - if(launch) + if (launch) { CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams); // do not add any code after this line because this can be deleted !!!! @@ -517,6 +555,11 @@ namespace NLGUI continue; } std::string::size_type lastPos = targetNames[k].find_last_not_of(" "); + if (startPos >= lastPos) + { + nlwarning(" empty target encountered"); + continue; + } if (!splitLinkTarget(targetNames[k].substr(startPos, lastPos - startPos+1), parentGroup, ti.PropertyName, ti.Elem)) { @@ -531,6 +574,70 @@ namespace NLGUI } + // *************************************************************************** + bool CInterfaceLink::splitLinkTargetsExt(const std::string &targets, CInterfaceGroup *parentGroup,std::vector &targetsVect, std::vector &cdbTargetsVect) + { + std::vector targetNames; + NLMISC::splitString(targets, ",", targetNames); + targetsVect.clear(); + targetsVect.reserve(targetNames.size()); + cdbTargetsVect.clear(); // no reserve because less used + bool everythingOk = true; + for (uint k = 0; k < targetNames.size(); ++k) + { + std::string::size_type startPos = targetNames[k].find_first_not_of(" "); + if(startPos == std::string::npos) + { + // todo hulud interface syntax error + nlwarning(" empty target encountered"); + continue; + } + std::string::size_type lastPos = targetNames[k].find_last_not_of(" "); + if (startPos >= (lastPos+1)) + { + nlwarning(" empty target encountered"); + continue; + } + + if (targetNames[k][startPos] == '@') + { + CInterfaceLink::CCDBTargetInfo ti; + ti.LeafName = targetNames[k].substr((startPos+1), (lastPos+1) - (startPos+1)); + // Do not allow Write on SERVER: or LOCAL: + static const std::string dbServer= "SERVER:"; + static const std::string dbLocal= "LOCAL:"; + static const std::string dbLocalR2= "LOCAL:R2"; + if( (0==ti.LeafName.compare(0, dbServer.size(), dbServer)) || + (0==ti.LeafName.compare(0, dbLocal.size(), dbLocal)) + ) + { + if (0!=ti.LeafName.compare(0, dbLocalR2.size(), dbLocalR2)) + { + //nlwarning("You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); + nlstop; + return false; + } + } + ti.Leaf = NLGUI::CDBManager::getInstance()->getDbProp(ti.LeafName, false); + cdbTargetsVect.push_back(ti); + } + else + { + CInterfaceLink::CTargetInfo ti; + if (!splitLinkTarget(targetNames[k].substr(startPos, lastPos - startPos+1), parentGroup, ti.PropertyName, ti.Elem)) + { + // todo hulud interface syntax error + nlwarning(" Can't get link target"); + everythingOk = false; + continue; + } + targetsVect.push_back(ti); + } + } + return everythingOk; + } + + //=========================================================== void CInterfaceLink::checkNbRefs() { diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 76f5df1ed..da8bd1e52 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -997,6 +997,7 @@ namespace NLGUI std::vector targets; + std::vector cdbTargets; ptr = (char*) xmlGetProp (cur, (xmlChar*)"target"); std::string target; @@ -1004,7 +1005,7 @@ namespace NLGUI { target = std::string( (const char*)ptr ); if( !editorMode ) - CInterfaceLink::splitLinkTargets(std::string((const char*)ptr), parentGroup, targets); + CInterfaceLink::splitLinkTargetsExt(std::string((const char*)ptr), parentGroup, targets, cdbTargets); } // optional action handler @@ -1022,7 +1023,7 @@ namespace NLGUI if( !editorMode ) { CInterfaceLink *il = new CInterfaceLink; - il->init(targets, expr, action, params, cond, parentGroup); // init will add 'il' in the list of link present in 'elm' + il->init(targets, cdbTargets, expr, action, params, cond, parentGroup); // init will add 'il' in the list of link present in 'elm' } else { diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 22839a8cf..16b946159 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -1035,8 +1035,8 @@ namespace NLGUI setCapturePointerRight(NULL); resetColorProps(); - - _AlphaRolloverSpeedDB = NULL; + resetAlphaRolloverSpeedProps(); + resetGlobalAlphasProps(); activeAnims.clear(); } @@ -1967,10 +1967,18 @@ namespace NLGUI } // Update global color from database - setGlobalColor( NLMISC::CRGBA ( (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R")->getValue32(), - (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G")->getValue32(), - (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B")->getValue32(), - (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A")->getValue32() ) ); + if (!_RProp) + { + _RProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R"); + _GProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G"); + _BProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B"); + _AProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A"); + } + setGlobalColor(NLMISC::CRGBA( + (uint8)_RProp->getValue32(), + (uint8)_GProp->getValue32(), + (uint8)_BProp->getValue32(), + (uint8)_AProp->getValue32())); NLMISC::CRGBA c = getGlobalColorForContent(); NLMISC::CRGBA gc = getGlobalColor(); @@ -2965,7 +2973,7 @@ namespace NLGUI return fTmp*fTmp*fTmp; } - void CWidgetManager::resetAlphaRolloverSpeed() + void CWidgetManager::resetAlphaRolloverSpeedProps() { _AlphaRolloverSpeedDB = NULL; } @@ -2981,10 +2989,29 @@ namespace NLGUI void CWidgetManager::updateGlobalAlphas() { - _GlobalContentAlpha = (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ALPHA")->getValue32(); - _GlobalContainerAlpha = (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ALPHA")->getValue32(); - _GlobalRolloverFactorContent = (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ROLLOVER_FACTOR")->getValue32(); - _GlobalRolloverFactorContainer = (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ROLLOVER_FACTOR")->getValue32(); + if (!_GlobalContentAlphaDB) + { + _GlobalContentAlphaDB = CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ALPHA"); + nlassert(_GlobalContentAlphaDB); + _GlobalContainerAlphaDB = CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ALPHA"); + nlassert(_GlobalContainerAlphaDB); + _GlobalContentRolloverFactorDB = CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ROLLOVER_FACTOR"); + nlassert(_GlobalContentRolloverFactorDB); + _GlobalContainerRolloverFactorDB = CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ROLLOVER_FACTOR"); + nlassert(_GlobalContainerRolloverFactorDB); + } + _GlobalContentAlpha = (uint8)_GlobalContentAlphaDB->getValue32(); + _GlobalContainerAlpha = (uint8)_GlobalContainerAlphaDB->getValue32(); + _GlobalRolloverFactorContent = (uint8)_GlobalContentRolloverFactorDB->getValue32(); + _GlobalRolloverFactorContainer = (uint8)_GlobalContainerRolloverFactorDB->getValue32(); + } + + void CWidgetManager::resetGlobalAlphasProps() + { + _GlobalContentAlphaDB = NULL; + _GlobalContainerAlphaDB = NULL; + _GlobalContentRolloverFactorDB = NULL; + _GlobalContainerRolloverFactorDB = NULL; } void CWidgetManager::registerNewScreenSizeHandler( INewScreenSizeHandler *handler ) @@ -3171,6 +3198,8 @@ namespace NLGUI _LastYContextHelp= -10000; resetColorProps(); + resetAlphaRolloverSpeedProps(); + resetGlobalAlphasProps(); _GlobalColor = NLMISC::CRGBA(255,255,255,255); _GlobalColorForContent = _GlobalColor; diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/config.xml index 630ecd4c6..4114143e5 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/config.xml @@ -2882,15 +2882,12 @@ This MUST follow the Enum MISSION_DESC::TIconId type="bool" value="true" /> - - - + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/map.xml b/code/ryzom/client/data/gamedev/interfaces_v3/map.xml index f84e9841d..bbc3682d5 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/map.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/map.xml @@ -425,9 +425,7 @@ - + + - + diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index 08189fdd4..f733f6c67 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -318,7 +318,11 @@ void CCDBSynchronised::writeInitInProgressIntoUIDB() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (pIM) - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CDB_INIT_IN_PROGRESS")->setValueBool(_InitInProgress); + { + NLMISC::CCDBNodeLeaf *node = m_CDBInitInProgressDB ? (&*m_CDBInitInProgressDB) + : (m_CDBInitInProgressDB = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CDB_INIT_IN_PROGRESS")); + node->setValueBool(_InitInProgress); + } else nlwarning("InterfaceManager not created"); } diff --git a/code/ryzom/client/src/cdb_synchronised.h b/code/ryzom/client/src/cdb_synchronised.h index 7f8f1fb5e..e5c2f4876 100644 --- a/code/ryzom/client/src/cdb_synchronised.h +++ b/code/ryzom/client/src/cdb_synchronised.h @@ -151,6 +151,8 @@ private: bool allInitPacketReceived() const { return _InitDeltaReceived == 2; } // Classic database + inventory void writeInitInProgressIntoUIDB(); + + NLMISC::CRefPtr m_CDBInitInProgressDB; }; diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index a51877be1..902e63875 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -58,6 +58,7 @@ uint32 MissionRingId = 0; UInstance selectedInstance; const UInstance noSelectedInstance; string selectedInstanceURL; +static NLMISC::CRefPtr s_UserCharFade; /////////////// @@ -273,7 +274,8 @@ void checkUnderCursor() entity= EntitiesMngr.getEntityUnderPos(cursX, cursY, ClientCfg.SelectionDist, isPlayerUnderCursor); // If the mouse is over the player make the player transparent - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false); + CCDBNodeLeaf *pNL = s_UserCharFade ? &*s_UserCharFade + : (s_UserCharFade = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false)); if ((pNL != NULL) && (pNL->getValue32() == 1) && UserEntity->selectable()) { // If the nearest entity is the player, hide! diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index eec5a6b5a..7bc478ce7 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -435,28 +435,47 @@ void CEntityManager::initialize(uint nbMaxEntity) for (i=0; igetDB()->addObserver(&MissionTargetObserver, textId ); + _MissionTargetTitleDB[i][j] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_MissionTargetTitleDB[i][j]); } // Add an Observer to the Team database for (i=0; igetDB()->addObserver(&TeamUIDObserver, textId ); + _GroupMemberUidDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_GroupMemberUidDB[i]); - textId = ICDBNode::CTextId( toString(TEAM_DB_PATH ":%d:NAME", i) ); + text = toString(TEAM_DB_PATH ":%d:NAME", i); + textId = ICDBNode::CTextId(text); NLGUI::CDBManager::getInstance()->getDB()->addObserver(&TeamPresentObserver, textId ); + _GroupMemberNameDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_GroupMemberNameDB[i]); } // Add an Observer to the Animal database for (i=0; igetDB()->addObserver(&AnimalUIDObserver, textId ); + std::string text = toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i); + textId = ICDBNode::CTextId(text); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalUIDObserver, textId); + _BeastUidDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_BeastUidDB[i]); - textId = ICDBNode::CTextId( toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i) ); - NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalStatusObserver, textId ); + text = toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i); + textId = ICDBNode::CTextId(text); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalStatusObserver, textId); + _BeastStatusDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_BeastStatusDB[i]); + + text = toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i); + _BeastTypeDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_BeastTypeDB[i]); } }// initialize // diff --git a/code/ryzom/client/src/entities.h b/code/ryzom/client/src/entities.h index 27551141a..81399f451 100644 --- a/code/ryzom/client/src/entities.h +++ b/code/ryzom/client/src/entities.h @@ -29,6 +29,10 @@ #include "ground_fx_manager.h" #include "projectile_manager.h" #include "user_entity.h" +// Some constants +#include "game_share/mission_desc.h" +#include "interface_v3/people_interraction.h" +#include "game_share/inventories.h" // Misc. #include "nel/misc/types_nl.h" #include "nel/misc/stream.h" @@ -149,6 +153,14 @@ private: NL3D::UInstance _LastInstanceUnderPos; + // DB node pointers used to update some entity flags + NLMISC::CRefPtr _MissionTargetTitleDB[MAX_NUM_MISSIONS][MAX_NUM_MISSION_TARGETS]; + NLMISC::CRefPtr _GroupMemberUidDB[MaxNumPeopleInTeam]; + NLMISC::CRefPtr _GroupMemberNameDB[MaxNumPeopleInTeam]; + NLMISC::CRefPtr _BeastUidDB[MAX_INVENTORY_ANIMAL]; + NLMISC::CRefPtr _BeastStatusDB[MAX_INVENTORY_ANIMAL]; + NLMISC::CRefPtr _BeastTypeDB[MAX_INVENTORY_ANIMAL]; + ////////////// //// DEBUG /// uint _NbUser; @@ -344,6 +356,13 @@ public: */ void refreshInsceneInterfaceOfFriendNPC(uint slot); + inline NLMISC::CCDBNodeLeaf *getMissionTargetTitleDB(int mission, int target) { return _MissionTargetTitleDB[mission][target]; } + inline NLMISC::CCDBNodeLeaf *getGroupMemberUidDB(int member) { return _GroupMemberUidDB[member]; } + inline NLMISC::CCDBNodeLeaf *getGroupMemberNameDB(int member) { return _GroupMemberNameDB[member]; } + inline NLMISC::CCDBNodeLeaf *getBeastUidDB(int beast) { return _BeastUidDB[beast]; } + inline NLMISC::CCDBNodeLeaf *getBeastStatusDB(int beast) { return _BeastStatusDB[beast]; } + inline NLMISC::CCDBNodeLeaf *getBeastTypeDB(int beast) { return _BeastTypeDB[beast]; } + private: // NB: don't return unselectable entities diff --git a/code/ryzom/client/src/entity_cl.cpp b/code/ryzom/client/src/entity_cl.cpp index 9aef8b1c8..2cc491d91 100644 --- a/code/ryzom/client/src/entity_cl.cpp +++ b/code/ryzom/client/src/entity_cl.cpp @@ -120,6 +120,7 @@ NLMISC::CRGBA CEntityCL::_PvpAllyColor; NLMISC::CRGBA CEntityCL::_GMTitleColor[CHARACTER_TITLE::EndGmTitle - CHARACTER_TITLE::BeginGmTitle + 1]; uint8 CEntityCL::_InvalidGMTitleCode = 0xFF; NLMISC::CRefPtr CEntityCL::_OpacityMinNodeLeaf; +NLMISC::CRefPtr CEntityCL::_ShowReticleLeaf; // Context help @@ -2646,7 +2647,7 @@ void CEntityCL::updateMissionTarget() for (j=0; jgetDbProp("SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE", false); + CCDBNodeLeaf *prop = EntitiesMngr.getMissionTargetTitleDB(i, j); // NLGUI::CDBManager::getInstance()->getDbProp("SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE", false); if (prop) { _MissionTarget = _NameId == (uint32)prop->getValue32(); @@ -2846,8 +2847,8 @@ void CEntityCL::updateIsInTeam () for (uint i=0; igetDbProp(toString(TEAM_DB_PATH ":%d:UID", i), false); - CCDBNodeLeaf *presentProp = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:NAME", i), false); + CCDBNodeLeaf *uidProp = EntitiesMngr.getGroupMemberUidDB(i); + CCDBNodeLeaf *presentProp = EntitiesMngr.getGroupMemberNameDB(i); // If same Entity uid than the one in the Database, ok the entity is in the Player TEAM!! if (uidProp && uidProp->getValue32() == (sint32)dataSetId() && presentProp && presentProp->getValueBool() ) @@ -2876,9 +2877,9 @@ void CEntityCL::updateIsUserAnimal () for (uint i=0; igetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); - CCDBNodeLeaf *statusProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false); - CCDBNodeLeaf *typeProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i), false); + CCDBNodeLeaf *uidProp = EntitiesMngr.getBeastUidDB(i); + CCDBNodeLeaf *statusProp = EntitiesMngr.getBeastStatusDB(i); + CCDBNodeLeaf *typeProp = EntitiesMngr.getBeastTypeDB(i); // I must have the same Id, and the animal entry must be ok. if(uidProp && statusProp && typeProp && uidProp->getValue32() == (sint32)dataSetId() && ANIMAL_STATUS::isSpawned((ANIMAL_STATUS::EAnimalStatus)(statusProp->getValue32()) )) @@ -3041,7 +3042,9 @@ void CEntityCL::updateVisiblePostPos(const NLMISC::TTime &/* currentTimeInMs */, bool bShowReticle = true; - CCDBNodeLeaf* node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_RETICLE"); + CCDBNodeLeaf *node = (CCDBNodeLeaf *)_ShowReticleLeaf ? &*_ShowReticleLeaf + : (_ShowReticleLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_RETICLE", false)); + if (node) { bShowReticle = node->getValueBool(); diff --git a/code/ryzom/client/src/entity_cl.h b/code/ryzom/client/src/entity_cl.h index 696efc61d..f7a26e03f 100644 --- a/code/ryzom/client/src/entity_cl.h +++ b/code/ryzom/client/src/entity_cl.h @@ -1111,7 +1111,8 @@ protected: // for localSelectBox() computing sint64 _LastLocalSelectBoxComputeTime; - static NLMISC::CRefPtr _OpacityMinNodeLeaf; + static NLMISC::CRefPtr _OpacityMinNodeLeaf; + static NLMISC::CRefPtr _ShowReticleLeaf; protected: /** diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index 6a21858f5..54c8b6fac 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -425,14 +425,15 @@ class CActionHandlerAddLink : public IActionHandler } std::vector targetsVect; - bool result = CInterfaceLink::splitLinkTargets(targets, parentGroup, targetsVect); + std::vector cdbTargetsVect; + bool result = CInterfaceLink::splitLinkTargetsExt(targets, parentGroup, targetsVect, cdbTargetsVect); if (!result) { nlwarning(" Couldn't parse all links"); } // add the link CInterfaceLink *il = new CInterfaceLink; - il->init(targetsVect, expr, ah, ahparam, ahcond, parentGroup); + il->init(targetsVect, cdbTargetsVect, expr, ah, ahparam, ahcond, parentGroup); CInterfaceManager *im = CInterfaceManager::getInstance(); CWidgetManager::getInstance()->getParser()->addLink(il, id); il->update(); diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index e313c7ae4..449265f8a 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -41,16 +41,77 @@ uint CGroupInSceneUserInfo::_BatLength = 0; CCDBNodeLeaf *CGroupInSceneUserInfo::_Value = NULL; CCDBNodeLeaf *CGroupInSceneUserInfo::_ValueBegin = NULL; CCDBNodeLeaf *CGroupInSceneUserInfo::_ValueEnd = NULL; +NLMISC::CRefPtr CGroupInSceneUserInfo::_GuildIconLeaf[256]; // *************************************************************************** NLMISC_REGISTER_OBJECT(CViewBase, CGroupInSceneUserInfo, std::string, "in_scene_user_info"); REGISTER_UI_CLASS(CGroupInSceneUserInfo) +namespace { + +// Has more entries than actually in config, as not all types have all entries. +class CConfigSaveInsceneDB +{ +public: + void setPrefix(const std::string &prefix) { _DBPrefix = prefix; } + inline NLMISC::CCDBNodeLeaf *getGuildSymbol() { return _GuildSymbol ? (&*_GuildSymbol) : (_GuildSymbol = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "GUILD_SYMBOL")); } + inline NLMISC::CCDBNodeLeaf *getName() { return _Name ? (&*_Name) : (_Name = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "NAME")); } + inline NLMISC::CCDBNodeLeaf *getTitle() { return _Title ? (&*_Title) : (_Title = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "TITLE")); } + inline NLMISC::CCDBNodeLeaf *getRPTags() { return _RPTags ? (&*_RPTags) : (_RPTags = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "RPTAGS")); } + inline NLMISC::CCDBNodeLeaf *getGuildName() { return _GuildName ? (&*_GuildName) : (_GuildName = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "GUILD_NAME")); } + inline NLMISC::CCDBNodeLeaf *getHP() { return _HP ? (&*_HP) : (_HP = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "HP")); } + inline NLMISC::CCDBNodeLeaf *getSta() { return _Sta ? (&*_Sta) : (_Sta = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "STA")); } + inline NLMISC::CCDBNodeLeaf *getSap() { return _Sap ? (&*_Sap) : (_Sap = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "SAP")); } + inline NLMISC::CCDBNodeLeaf *getFocus() { return _Focus ? (&*_Focus) : (_Focus = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "FOCUS")); } + inline NLMISC::CCDBNodeLeaf *getAction() { return _Action ? (&*_Action) : (_Action = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "ACTION")); } + inline NLMISC::CCDBNodeLeaf *getMessages() { return _Messages ? (&*_Messages) : (_Messages = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "MESSAGES")); } + inline NLMISC::CCDBNodeLeaf *getPvPLogo() { return _PvPLogo ? (&*_PvPLogo) : (_PvPLogo = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "PVP_LOGO")); } + inline NLMISC::CCDBNodeLeaf *getNPCName() { return _NPCName ? (&*_NPCName) : (_NPCName = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "NPCNAME")); } + inline NLMISC::CCDBNodeLeaf *getNPCTitle() { return _NPCTitle ? (&*_NPCTitle) : (_NPCTitle = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "NPCTITLE")); } + inline NLMISC::CCDBNodeLeaf *getMissionIcon() { return _MissionIcon ? (&*_MissionIcon) : (_MissionIcon = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "MISSION_ICON")); } + inline NLMISC::CCDBNodeLeaf *getMiniMissionIcon() { return _MiniMissionIcon ? (&*_MiniMissionIcon) : (_MiniMissionIcon = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "MINI_MISSION_ICON")); } +private: + std::string _DBPrefix; + NLMISC::CRefPtr _GuildSymbol; + NLMISC::CRefPtr _Name; + NLMISC::CRefPtr _Title; + NLMISC::CRefPtr _RPTags; + NLMISC::CRefPtr _GuildName; + NLMISC::CRefPtr _HP; + NLMISC::CRefPtr _Sta; + NLMISC::CRefPtr _Sap; + NLMISC::CRefPtr _Focus; + NLMISC::CRefPtr _Action; + NLMISC::CRefPtr _Messages; + NLMISC::CRefPtr _PvPLogo; + NLMISC::CRefPtr _NPCName; + NLMISC::CRefPtr _NPCTitle; + NLMISC::CRefPtr _MissionIcon; + NLMISC::CRefPtr _MiniMissionIcon; +}; + +CConfigSaveInsceneDB _ConfigSaveInsceneDB[4]; // USER/FRIEND/ENEMY/SOURCE +bool _ConfigSaveInsceneDBInit = false; + +#define SAVE_USER 0 +#define SAVE_FRIEND 1 +#define SAVE_ENEMY 2 +#define SAVE_SOURCE 3 + +} CGroupInSceneUserInfo::CGroupInSceneUserInfo(const TCtorParam ¶m) : CGroupInScene(param) { + if (!_ConfigSaveInsceneDBInit) + { + _ConfigSaveInsceneDB[0].setPrefix("UI:SAVE:INSCENE:USER:"); + _ConfigSaveInsceneDB[1].setPrefix("UI:SAVE:INSCENE:FRIEND:"); + _ConfigSaveInsceneDB[2].setPrefix("UI:SAVE:INSCENE:ENEMY:"); + _ConfigSaveInsceneDB[3].setPrefix("UI:SAVE:INSCENE:SOURCE:"); + _ConfigSaveInsceneDBInit = true; + } _Name = NULL; _Title = NULL; _GuildName = NULL; @@ -130,7 +191,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) bool needPvPLogo= false; bool permanentContent = false; bool rpTags = false; - bool displayMissionIcons = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool(); + bool displayMissionIcons = _ConfigSaveInsceneDB[SAVE_FRIEND].getMissionIcon()->getValueBool(); // Names const char *templateName; @@ -156,7 +217,6 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Active fields and bars if ( isForageSource ) { - string dbEntry = "UI:SAVE:INSCENE:SOURCE:"; CForageSourceCL *forageSource = static_cast(entity); name = !entityName.empty() /*&& NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool()*/; @@ -175,32 +235,32 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) } else if(npcFriendAndNeutral) { - string dbEntry; + int dbEntry; getBarSettings( pIM, user, entity->isPlayer(), _friend, dbEntry, bars ); // For RoleMasters, merchants etc... must display name and function, and nothing else for(uint i=0;igetDbProp(dbEntry+"NPCNAME")->getValueBool(); + name= !entityName.empty() && _ConfigSaveInsceneDB[dbEntry].getNPCName()->getValueBool(); symbol= false; - title= !entityTitle.empty() && CDBManager::getInstance()->getDbProp(dbEntry+"NPCTITLE")->getValueBool(); + title= !entityTitle.empty() && _ConfigSaveInsceneDB[dbEntry].getNPCTitle()->getValueBool(); guildName= false; templateName = "in_scene_user_info"; - rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"RPTAGS")->getValueBool(); + rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && _ConfigSaveInsceneDB[dbEntry].getRPTags()->getValueBool(); } else { // Base entry in database - string dbEntry; + int dbEntry; getBarSettings( pIM, user, entity->isPlayer(), _friend, dbEntry, bars ); - name = !entityName.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool(); - title = !entityTitle.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"TITLE")->getValueBool(); - rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"RPTAGS")->getValueBool(); + name = !entityName.empty() && _ConfigSaveInsceneDB[dbEntry].getName()->getValueBool(); + title = !entityTitle.empty() && _ConfigSaveInsceneDB[dbEntry].getTitle()->getValueBool(); + rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && _ConfigSaveInsceneDB[dbEntry].getRPTags()->getValueBool(); // if name is empty but not title, title is displayed as name - if (!title && entityName.empty() && !entityTitle.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool()) + if (!title && entityName.empty() && !entityTitle.empty() && _ConfigSaveInsceneDB[dbEntry].getName()->getValueBool()) title = true; templateName = "in_scene_user_info"; // special guild - if(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"GUILD_SYMBOL")->getValueBool()) + if(_ConfigSaveInsceneDB[dbEntry].getGuildSymbol()->getValueBool()) { // if symbol not still available, wait for one when VP received symbol = (entity->getGuildSymbol() != 0); @@ -211,7 +271,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) symbol= false; needGuildSymbolId = false; } - if(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"GUILD_NAME")->getValueBool()) + if(_ConfigSaveInsceneDB[dbEntry].getGuildName()->getValueBool()) { // if guild name not still available, wait for one when VP received guildName = (entity->getGuildNameID() != 0); @@ -222,7 +282,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) guildName= false; needGuildNameId= false; } - needPvPLogo = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"PVP_LOGO")->getValueBool(); + needPvPLogo = _ConfigSaveInsceneDB[dbEntry].getPvPLogo()->getValueBool(); eventFaction = (entity->getEventFactionID() != 0); } @@ -799,9 +859,9 @@ REGISTER_ACTION_HANDLER( CHandlerResetCharacterInScene, "reset_character_in_scen // *************************************************************************** -void CGroupInSceneUserInfo::getBarSettings( CInterfaceManager* pIM, bool isUser, bool isPlayer, bool isFriend, std::string& dbEntry, bool *bars ) +void CGroupInSceneUserInfo::getBarSettings( CInterfaceManager* pIM, bool isUser, bool isPlayer, bool isFriend, int &dbEntry, bool *bars ) { - dbEntry = isUser?"UI:SAVE:INSCENE:USER:":isFriend?"UI:SAVE:INSCENE:FRIEND:":"UI:SAVE:INSCENE:ENEMY:"; + dbEntry = isUser?SAVE_USER:isFriend?SAVE_FRIEND:SAVE_ENEMY; // if currently is edition mode, then bars are not displayed if (ClientCfg.R2EDEnabled && R2::isEditionCurrent()) { @@ -813,11 +873,11 @@ void CGroupInSceneUserInfo::getBarSettings( CInterfaceManager* pIM, bool isUser, } else { - bars[HP] = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"HP")->getValueBool(); - bars[SAP] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"SAP")->getValueBool(); - bars[STA] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"STA")->getValueBool(); - bars[Focus] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"FOCUS")->getValueBool(); - bars[Action] = (isUser) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"ACTION")->getValueBool(); + bars[HP] = _ConfigSaveInsceneDB[dbEntry].getHP()->getValueBool(); + bars[SAP] = (isUser || isFriend) && (isUser || isPlayer) && _ConfigSaveInsceneDB[dbEntry].getSap()->getValueBool(); + bars[STA] = (isUser || isFriend) && (isUser || isPlayer) && _ConfigSaveInsceneDB[dbEntry].getSta()->getValueBool(); + bars[Focus] = (isUser || isFriend) && (isUser || isPlayer) && _ConfigSaveInsceneDB[dbEntry].getFocus()->getValueBool(); + bars[Action] = (isUser) && _ConfigSaveInsceneDB[dbEntry].getAction()->getValueBool(); } } @@ -831,7 +891,7 @@ void CGroupInSceneUserInfo::setLeftGroupActive( bool active ) if ( _Entity->isUser() || _Entity->isForageSource() ) return; - string dbEntry; + int dbEntry; bool barSettings [NumBars]; getBarSettings( CInterfaceManager::getInstance(), _Entity->isUser(), _Entity->isPlayer(), _Entity->isViewedAsFriend(), dbEntry, barSettings ); @@ -943,8 +1003,13 @@ void CGroupInSceneUserInfo::updateDynamicData () if (_Entity->getGuildSymbol() != 0) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string dbLeaf = "UI:ENTITY:GUILD:"+toString (_Entity->slot())+":ICON"; - NLGUI::CDBManager::getInstance()->getDbProp(dbLeaf)->setValue64(_Entity->getGuildSymbol()); + if (!_GuildIconLeaf[_Entity->slot()]) + { + string dbLeaf = "UI:ENTITY:GUILD:"+toString (_Entity->slot())+":ICON"; + _GuildIconLeaf[_Entity->slot()] = NLGUI::CDBManager::getInstance()->getDbProp(dbLeaf); + } + nlassert(&*_GuildIconLeaf[_Entity->slot()]); + (&*_GuildIconLeaf[_Entity->slot()])->setValue64(_Entity->getGuildSymbol()); } // Set the event faction diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h index 4a9dd6ddd..3869a74b1 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h @@ -72,7 +72,7 @@ protected: }; /// Fill NumBars elements into bars and set dbEntry - static void getBarSettings( CInterfaceManager* pIM, bool isUser, bool isPlayer, bool isFriend, std::string& dbEntry, bool *bars ); + static void getBarSettings( CInterfaceManager* pIM, bool isUser, bool isPlayer, bool isFriend, int &dbEntry, bool *bars ); // The entity (character or forage source) CEntityCL *_Entity; @@ -97,6 +97,9 @@ protected: static NLMISC::CCDBNodeLeaf *_ValueBegin; static NLMISC::CCDBNodeLeaf *_ValueEnd; + // Guild icon leafs + static NLMISC::CRefPtr _GuildIconLeaf[256]; + // Special guild bool _NeedGuildNameId; bool _NeedGuildSymbolId; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index d352aff91..a9b389018 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -511,6 +511,8 @@ CInterfaceManager::CInterfaceManager() _LogState = false; _KeysLoaded = false; CWidgetManager::getInstance()->resetColorProps(); + CWidgetManager::getInstance()->resetAlphaRolloverSpeedProps(); + CWidgetManager::getInstance()->resetGlobalAlphasProps(); _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; @@ -1420,8 +1422,9 @@ void CInterfaceManager::uninitInGame1 () _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; - CWidgetManager::getInstance()->resetAlphaRolloverSpeed(); CWidgetManager::getInstance()->resetColorProps(); + CWidgetManager::getInstance()->resetAlphaRolloverSpeedProps(); + CWidgetManager::getInstance()->resetGlobalAlphasProps(); #ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS CInterfaceManager::getInstance()->DebugTrackGroupsDump(); @@ -1978,7 +1981,11 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) // Update Player characteristics (for Item carac requirement Redifying) nlctassert(CHARACTERISTICS::NUM_CHARACTERISTICS==8); for (uint i=0; igetDbValue32(toString("SERVER:CHARACTER_INFO:CHARACTERISTICS%d:VALUE", i)); + { + NLMISC::CCDBNodeLeaf *node = _CurrentPlayerCharacLeaf[i] ? &*_CurrentPlayerCharacLeaf[i] + : (_CurrentPlayerCharacLeaf[i] = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:CHARACTERISTICS%d:VALUE", i), false)); + _CurrentPlayerCharac[i] = node ? node->getValue32() : 0; + } CWidgetManager::getInstance()->drawViews( camera ); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 567c07a7b..36bd909e3 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -633,7 +633,8 @@ private: std::vector _EmoteCmds; // Item Carac requirement - sint32 _CurrentPlayerCharac[CHARACTERISTICS::NUM_CHARACTERISTICS]; + sint32 _CurrentPlayerCharac[CHARACTERISTICS::NUM_CHARACTERISTICS]; + NLMISC::CRefPtr _CurrentPlayerCharacLeaf[CHARACTERISTICS::NUM_CHARACTERISTICS]; // observers for copying database branch changes CServerToLocalAutoCopy ServerToLocalAutoCopyInventory; diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index b0a050f29..95b091c22 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -558,7 +558,8 @@ void CPeopleInterraction::createTeamList() { CInterfaceLink *il = new CInterfaceLink; vector targets; - il->init(targets, sExpr, sAction, sParams, sCond, TeamChat->getContainer()); + vector cdbTargets; + il->init(targets, cdbTargets, sExpr, sAction, sParams, sCond, TeamChat->getContainer()); } } diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp index 8abb66c8c..9598bedec 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -941,6 +941,8 @@ void CSPhraseManager::reset() CSkillManager *pSM= CSkillManager::getInstance(); pBM->removeBrickLearnedCallback(&_ProgressionUpdate); pSM->removeSkillChangeCallback(&_ProgressionUpdate); + + _TotalMalusEquipLeaf = NULL; } // *************************************************************************** @@ -1122,7 +1124,9 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // **** Compute Phrase Elements from phrase // get the current action malus (0-100) uint32 totalActionMalus= 0; - CCDBNodeLeaf *actMalus= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false); + CCDBNodeLeaf *actMalus = (CCDBNodeLeaf *)_TotalMalusEquipLeaf ? &*_TotalMalusEquipLeaf + : (_TotalMalusEquipLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false)); + // root brick must not be Power or aura, because Action malus don't apply to them // (ie leave 0 ActionMalus for Aura or Powers if(actMalus && !rootBrick->isSpecialPower()) @@ -1652,7 +1656,8 @@ float CSPhraseManager::getPhraseSumBrickProp(const CSPhraseCom &phrase, uint else if(propId==CSBrickManager::getInstance()->StaPropId && brick->Properties[j].PropId==CSBrickManager::getInstance()->StaWeightFactorId) { CInterfaceManager *im = CInterfaceManager::getInstance(); - uint32 weight = (uint32) NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEFAULT_WEIGHT_HANDS")->getValue32() / 10; // weight must be in dg here + if (!_ServerUserDefaultWeightHandsLeaf) _ServerUserDefaultWeightHandsLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEFAULT_WEIGHT_HANDS"); + uint32 weight = (uint32)(&*_ServerUserDefaultWeightHandsLeaf)->getValue32() / 10; // weight must be in dg here CDBCtrlSheet *ctrlSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestionsets:hands:handr")); if (ctrlSheet) { @@ -4501,7 +4506,8 @@ uint32 CSPhraseManager::getTotalActionMalus(const CSPhraseCom &phrase) const CInterfaceManager *pIM = CInterfaceManager::getInstance(); CSBrickManager *pBM= CSBrickManager::getInstance(); uint32 totalActionMalus= 0; - CCDBNodeLeaf *actMalus= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false); + CCDBNodeLeaf *actMalus = (CCDBNodeLeaf *)_TotalMalusEquipLeaf ? &*_TotalMalusEquipLeaf + : (_TotalMalusEquipLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false)); // root brick must not be Power or aura, because Action malus don't apply to them // (ie leave 0 ActionMalus for Aura or Powers if (!phrase.Bricks.empty()) diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.h b/code/ryzom/client/src/interface_v3/sphrase_manager.h index b28ff39ed..c14b584ab 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.h +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.h @@ -651,6 +651,10 @@ private: void computePhraseProgression(); void insertProgressionSkillRecurs(SKILLS::ESkills skill, uint32 value, sint *skillReqLevel, std::vector &skillsToInsert); + mutable NLMISC::CRefPtr _TotalMalusEquipLeaf; + + NLMISC::CRefPtr _ServerUserDefaultWeightHandsLeaf; + // @} /// return the skill of the root diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 2c362aceb..74ac297df 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -382,6 +382,9 @@ CGameContextMenu GameContextMenu; NLMISC::CValueSmoother smoothFPS; NLMISC::CValueSmoother moreSmoothFPS(64); +static CRefPtr s_FpsLeaf; +static CRefPtr s_UiDirectionLeaf; + // Profile /* @@ -2296,7 +2299,8 @@ bool mainLoop() deltaTime = smoothFPS.getSmoothValue (); if (deltaTime > 0.0) { - CCDBNodeLeaf*pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:FPS"); + CCDBNodeLeaf *pNL = (CCDBNodeLeaf *)s_FpsLeaf ? &*s_FpsLeaf + : (s_FpsLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:FPS")); pNL->setValue64((sint64)(1.f/deltaTime)); } } @@ -2801,8 +2805,10 @@ bool mainLoop() H_AUTO_USE ( RZ_Client_Main_Loop_Net ) // Put here things you have to send to the server only once per tick like user position. // UPDATE COMPASS + NLMISC::CCDBNodeLeaf *node = s_UiDirectionLeaf ? (&*s_UiDirectionLeaf) + : (s_UiDirectionLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DIRECTION")); CInterfaceProperty prop; - prop.readDouble("UI:VARIABLES:DIRECTION"," "); + prop.setNodePtr(node); if(CompassMode == 1) { double camDir = atan2(View.view().y, View.view().x); diff --git a/code/ryzom/client/src/motion/user_controls.cpp b/code/ryzom/client/src/motion/user_controls.cpp index b780927e2..794685981 100644 --- a/code/ryzom/client/src/motion/user_controls.cpp +++ b/code/ryzom/client/src/motion/user_controls.cpp @@ -294,7 +294,9 @@ void CUserControls::update() // update camera collision once per frame View.updateCameraCollision(); - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MK_MOVE")->setValue32(autowalkState()); + NLMISC::CCDBNodeLeaf *node = _UiVarMkMoveDB ? &*_UiVarMkMoveDB + : (_UiVarMkMoveDB = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MK_MOVE")); + node->setValue32(autowalkState()); }// update // diff --git a/code/ryzom/client/src/motion/user_controls.h b/code/ryzom/client/src/motion/user_controls.h index be1cbaf99..eb4de2020 100644 --- a/code/ryzom/client/src/motion/user_controls.h +++ b/code/ryzom/client/src/motion/user_controls.h @@ -31,6 +31,9 @@ // Std. #include +namespace NLMISC { + class CCDBNodeLeaf; +} /////////// // CLASS // @@ -305,6 +308,8 @@ private: /// when true the next forward action will cancel any moveto bool _NextForwardCancelMoveTo; + + NLMISC::CRefPtr _UiVarMkMoveDB; }; /// User Controls (mouse, keyboard, interfaces, ...) diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index f9a5628ca..6e45c4fb4 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -3861,22 +3861,28 @@ bool CNetManager::update() CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false); + CCDBNodeLeaf *node = m_PingLeaf ? &*m_PingLeaf + : (m_PingLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false)); if (node) node->setValue32(getPing()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false); + node = m_UploadLeaf ? &*m_UploadLeaf + : (m_UploadLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false)); if (node) node->setValue32((sint32)(getMeanUpload()*1024.f/8.f)); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false); + node = m_DownloadLeaf ? &*m_DownloadLeaf + : (m_DownloadLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false)); if (node) node->setValue32((sint32)(getMeanDownload()*1024.f/8.f)); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false); + node = m_PacketLostLeaf ? &* m_PacketLostLeaf + : (m_PacketLostLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false)); if (node) node->setValue32((sint32)getMeanPacketLoss()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false); + node = m_ServerStateLeaf ? &*m_ServerStateLeaf + : (m_ServerStateLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false)); if (node) node->setValue32((sint32)getConnectionState()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false); + node = m_ConnectionQualityLeaf ? &*m_ConnectionQualityLeaf + : (m_ConnectionQualityLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false)); if (node) node->setValue32((sint32)getConnectionQuality()); } diff --git a/code/ryzom/client/src/net_manager.h b/code/ryzom/client/src/net_manager.h index 9fef4bc1d..06d6a7621 100644 --- a/code/ryzom/client/src/net_manager.h +++ b/code/ryzom/client/src/net_manager.h @@ -43,6 +43,7 @@ void initializeNetwork(); namespace NLMISC { class CBitMemStream; + class CCDBNodeLeaf; }; @@ -126,6 +127,13 @@ public: protected: bool _IsReplayStarting; #endif + + NLMISC::CRefPtr m_PingLeaf; + NLMISC::CRefPtr m_UploadLeaf; + NLMISC::CRefPtr m_DownloadLeaf; + NLMISC::CRefPtr m_PacketLostLeaf; + NLMISC::CRefPtr m_ServerStateLeaf; + NLMISC::CRefPtr m_ConnectionQualityLeaf; }; diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index ddc97fb95..f11476930 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -55,6 +55,7 @@ const uint32 DEFAULT_ENTITY_MIN_OPACITY = 128; bool CTool::_MouseCaptured = false; +NLMISC::CRefPtr CTool::_UserCharFade; static const CVector cardinals[] = { @@ -551,7 +552,8 @@ void CTool::handleMouseOverPlayer(bool over) { //H_AUTO(R2_CTool_handleMouseOverPlayer) // If the mouse is over the player make the player transparent - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false); + CCDBNodeLeaf *pNL = _UserCharFade ? &*_UserCharFade + : (_UserCharFade = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false)); if ((pNL != NULL) && (pNL->getValue32() == 1) && UserEntity->selectable()) { // If the nearest entity is the player, hide! diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h index f7262efc4..d36c514c1 100644 --- a/code/ryzom/client/src/r2/tool.h +++ b/code/ryzom/client/src/r2/tool.h @@ -284,6 +284,7 @@ private: sint64 _AutoPanDelay; sint64 _NumPans; static bool _MouseCaptured; + static NLMISC::CRefPtr _UserCharFade; private: /** compute the nearest valid surface at a given position from the island heightmap * (heightmap must not be empty or an assertion is raised) diff --git a/code/ryzom/client/src/weather.cpp b/code/ryzom/client/src/weather.cpp index 1f5f0f822..17288fbe9 100644 --- a/code/ryzom/client/src/weather.cpp +++ b/code/ryzom/client/src/weather.cpp @@ -194,10 +194,13 @@ bool ServerDrivenWeather = false; const float WEATHER_BLEND_SPEED = 1.f / 8.f; // number of seconds to blend betwen weather states +static NLMISC::CRefPtr s_ServerWeatherValueDB; + // *************************************************************************** static uint16 getServerWeather() { - CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:WEATHER:VALUE"); + CCDBNodeLeaf *node = s_ServerWeatherValueDB ? &*s_ServerWeatherValueDB + : (s_ServerWeatherValueDB = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:WEATHER:VALUE")); if (!node) return 0; return (uint16) node->getValue16(); }