CDB no longer depends on CInterfaceLink.
This commit is contained in:
parent
f815bb2549
commit
4313f62647
6 changed files with 84 additions and 11 deletions
|
@ -16,8 +16,6 @@
|
|||
|
||||
|
||||
|
||||
#include "stdpch.h"
|
||||
|
||||
//#define TRACE_READ_DELTA
|
||||
//#define TRACE_WRITE_DELTA
|
||||
//#define TRACE_SET_VALUE
|
||||
|
@ -32,7 +30,6 @@
|
|||
#include "cdb_leaf.h"
|
||||
#include "game_share/xml_auto_ptr.h"
|
||||
//#include <iostream.h>
|
||||
#include "interface_v3/interface_manager.h"
|
||||
|
||||
////////////////
|
||||
// Namespaces //
|
||||
|
@ -84,6 +81,8 @@ uint CCDBNodeBranch::_FirstLevelIdBitsByBank [NB_CDB_BANKS];
|
|||
|
||||
extern const char *CDBBankNames[INVALID_CDB_BANK+1];
|
||||
|
||||
std::vector< CCDBNodeBranch::IBranchObserverCallFlushObserver* > CCDBNodeBranch::flushObservers;
|
||||
|
||||
// reset all static data
|
||||
void CCDBNodeBranch::reset()
|
||||
{
|
||||
|
@ -703,15 +702,46 @@ void CCDBNodeBranch::flushObserversCalls()
|
|||
}
|
||||
nlassert(_FirstNotifiedObs[1 - _CurrNotifiedObsList] == NULL);
|
||||
nlassert(_LastNotifiedObs[1 - _CurrNotifiedObsList] == NULL);
|
||||
// update triggered link
|
||||
CInterfaceLink::updateTrigeredLinks();
|
||||
triggerFlushObservers();
|
||||
// examine other list to see if nodes have been registered
|
||||
_CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList];
|
||||
}
|
||||
CInterfaceLink::updateTrigeredLinks(); // should call it at least once
|
||||
triggerFlushObservers();
|
||||
// nlassert(_CrtCheckMemory());
|
||||
}
|
||||
|
||||
void CCDBNodeBranch::triggerFlushObservers()
|
||||
{
|
||||
for( std::vector< IBranchObserverCallFlushObserver* >::iterator itr = flushObservers.begin(); itr != flushObservers.end(); itr++ )
|
||||
{
|
||||
(*itr)->onObserverCallFlush();
|
||||
}
|
||||
}
|
||||
|
||||
void CCDBNodeBranch::addFlushObserver( CCDBNodeBranch::IBranchObserverCallFlushObserver *observer )
|
||||
{
|
||||
std::vector< IBranchObserverCallFlushObserver* >::iterator itr
|
||||
= std::find( flushObservers.begin(), flushObservers.end(), observer );
|
||||
|
||||
// Already exists
|
||||
if( itr != flushObservers.end() )
|
||||
return;
|
||||
|
||||
flushObservers.push_back( observer );
|
||||
}
|
||||
|
||||
void CCDBNodeBranch::removeFlushObserver( CCDBNodeBranch::IBranchObserverCallFlushObserver *observer )
|
||||
{
|
||||
std::vector< IBranchObserverCallFlushObserver* >::iterator itr
|
||||
= std::find( flushObservers.begin(), flushObservers.end(), observer );
|
||||
|
||||
// Isn't in our list
|
||||
if( itr == flushObservers.end() )
|
||||
return;
|
||||
|
||||
flushObservers.erase( itr );
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::CDBBranchObsInfo::link(uint list, NLMISC::TStringId modifiedLeafName)
|
||||
{
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
class CCDBNodeBranch : public ICDBNode
|
||||
{
|
||||
public:
|
||||
/// Triggered when the branch observers are updated
|
||||
class IBranchObserverCallFlushObserver : public NLMISC::CRefCount{
|
||||
public:
|
||||
virtual ~IBranchObserverCallFlushObserver(){}
|
||||
virtual void onObserverCallFlush() = 0;
|
||||
};
|
||||
|
||||
// default constructor
|
||||
CCDBNodeBranch(const std::string &name) : ICDBNode(name)
|
||||
|
@ -212,6 +218,13 @@ public:
|
|||
*/
|
||||
static void flushObserversCalls();
|
||||
|
||||
private:
|
||||
static void triggerFlushObservers();
|
||||
|
||||
public:
|
||||
static void addFlushObserver( IBranchObserverCallFlushObserver *observer );
|
||||
static void removeFlushObserver( IBranchObserverCallFlushObserver *observer );
|
||||
|
||||
// mark this branch and parent branch as 'modified'. This is usually called by sub-leaves
|
||||
void linkInModifiedNodeList(NLMISC::TStringId modifiedLeafName);
|
||||
|
||||
|
@ -324,6 +337,11 @@ protected:
|
|||
/// called by clear
|
||||
void removeAllBranchObserver();
|
||||
void removeBranchInfoIt(TObsList::iterator it);
|
||||
|
||||
|
||||
private:
|
||||
static std::vector< IBranchObserverCallFlushObserver* > flushObservers;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -130,7 +130,20 @@ static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem
|
|||
return true;
|
||||
}
|
||||
|
||||
CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater()
|
||||
{
|
||||
CCDBNodeBranch::addFlushObserver( this );
|
||||
}
|
||||
|
||||
CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater()
|
||||
{
|
||||
CCDBNodeBranch::removeFlushObserver( this );
|
||||
}
|
||||
|
||||
void CInterfaceLink::CInterfaceLinkUpdater::onObserverCallFlush()
|
||||
{
|
||||
CInterfaceLink::updateTrigeredLinks();
|
||||
}
|
||||
|
||||
/////////////
|
||||
// MEMBERS //
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
#ifndef CL_INTERFACE_LINK_H
|
||||
#define CL_INTERFACE_LINK_H
|
||||
|
||||
#include "../cdb.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "../cdb_branch.h"
|
||||
|
||||
class CInterfaceElement;
|
||||
class ICDBNode;
|
||||
class CCDBNodeLeaf;
|
||||
class CReflectedProperty;
|
||||
class CInterfaceExprValue;
|
||||
class CInterfaceGroup;
|
||||
|
@ -66,6 +63,17 @@ public:
|
|||
*/
|
||||
bool affect(const CInterfaceExprValue &value);
|
||||
};
|
||||
|
||||
|
||||
/// Updates triggered interface links when triggered by the observed branch
|
||||
class CInterfaceLinkUpdater : public CCDBNodeBranch::IBranchObserverCallFlushObserver
|
||||
{
|
||||
public:
|
||||
CInterfaceLinkUpdater();
|
||||
~CInterfaceLinkUpdater();
|
||||
void onObserverCallFlush();
|
||||
};
|
||||
|
||||
public:
|
||||
CInterfaceLink();
|
||||
~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement
|
||||
|
|
|
@ -257,6 +257,7 @@ CInterfaceManager::CInterfaceManager()
|
|||
{
|
||||
_Instance = this;
|
||||
_DbRootNode = new CCDBNodeBranch("ROOT");
|
||||
interfaceLinkUpdater = new CInterfaceLink::CInterfaceLinkUpdater();
|
||||
_ScreenW = _ScreenH = 0;
|
||||
_LastInGameScreenW = _LastInGameScreenH = 0;
|
||||
_Pointer = NULL;
|
||||
|
@ -372,6 +373,8 @@ CInterfaceManager::~CInterfaceManager()
|
|||
|
||||
// release the database observers
|
||||
releaseServerToLocalAutoCopyObservers();
|
||||
delete interfaceLinkUpdater;
|
||||
interfaceLinkUpdater = NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -1063,7 +1063,8 @@ private:
|
|||
|
||||
// Update tooltip coordinate if they need to be (getInvalidCoords() returns a value != 0)
|
||||
void updateTooltipCoords(CCtrlBase *newCtrl);
|
||||
|
||||
|
||||
CInterfaceLink::CInterfaceLinkUpdater *interfaceLinkUpdater;
|
||||
};
|
||||
|
||||
#endif // NL_INTERFACE_MANAGER_H
|
||||
|
|
Loading…
Reference in a new issue