mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-26 02:40:54 +00:00
Avoid redundant calls to getDbProp("UI:SAVE:INSCENE:...")
This commit is contained in:
parent
592e0d5e3e
commit
bef5ba382c
2 changed files with 82 additions and 23 deletions
|
@ -47,11 +47,71 @@ NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> 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<NLMISC::CCDBNodeLeaf> _GuildSymbol;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _Name;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _Title;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _RPTags;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _GuildName;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _HP;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _Sta;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _Sap;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _Focus;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _Action;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _Messages;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _PvPLogo;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _NPCName;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _NPCTitle;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _MissionIcon;
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _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;
|
||||
|
@ -131,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;
|
||||
|
@ -157,7 +217,6 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity)
|
|||
// Active fields and bars
|
||||
if ( isForageSource )
|
||||
{
|
||||
string dbEntry = "UI:SAVE:INSCENE:SOURCE:";
|
||||
CForageSourceCL *forageSource = static_cast<CForageSourceCL*>(entity);
|
||||
|
||||
name = !entityName.empty() /*&& NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool()*/;
|
||||
|
@ -176,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;i<NumBars;i++)
|
||||
bars[i]= false;
|
||||
name= !entityName.empty() && CDBManager::getInstance()->getDbProp(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);
|
||||
|
@ -212,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);
|
||||
|
@ -223,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);
|
||||
}
|
||||
|
@ -800,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())
|
||||
{
|
||||
|
@ -814,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -832,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 );
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue