/*
* Copyright 2004 Perforce Software. All rights reserved.
*
* Developed by Data Shades Ltd.
*/
#include "P4GTMax.h"
#include "CallbackManager.h"
#include "P4GTUtils.h"
#include ".\XRef\IXRefObjMgr.h"
CallbackManager::CallbackManager()
{
doingOpen = false;
doneRefs = false;
RegisterNotification( promptCloseDocument, this, NOTIFY_SYSTEM_PRE_NEW );
RegisterNotification( promptCloseDocument, this, NOTIFY_SYSTEM_PRE_RESET );
RegisterNotification( promptCloseDocument, this, NOTIFY_FILE_PRE_OPEN );
RegisterNotification( promptCloseDocument, this, NOTIFY_SYSTEM_SHUTDOWN );
RegisterNotification( promptOpenDocument, this, NOTIFY_FILE_POST_OPEN );
RegisterNotification( prepareOpen, this, NOTIFY_FILE_PRE_OPEN );
RegisterNotification( syncRefs, this, NOTIFY_FILE_PRE_MERGE );
}
CallbackManager::~CallbackManager()
{
UnRegisterNotification( promptCloseDocument, this, NOTIFY_SYSTEM_PRE_NEW );
UnRegisterNotification( promptCloseDocument, this, NOTIFY_SYSTEM_PRE_RESET );
UnRegisterNotification( promptCloseDocument, this, NOTIFY_FILE_PRE_OPEN );
UnRegisterNotification( promptCloseDocument, this, NOTIFY_SYSTEM_SHUTDOWN );
UnRegisterNotification( promptOpenDocument, this, NOTIFY_FILE_POST_OPEN );
UnRegisterNotification( prepareOpen, this, NOTIFY_FILE_PRE_OPEN );
UnRegisterNotification( syncRefs, this, NOTIFY_FILE_PRE_MERGE );
}
void CallbackManager::promptCloseDocument( void *data, NotifyInfo *info )
{
P4GT_FileCloseEvent();
}
void CallbackManager::prepareOpen( void *data, NotifyInfo *info )
{
((CallbackManager *)data)->doingOpen = true;
((CallbackManager *)data)->doneRefs = false;
}
void CallbackManager::syncRefs( void *data, NotifyInfo *info )
{
CallbackManager *manager = (CallbackManager *)data;
// Only do this once during file load
if ( manager->doingOpen && !manager->doneRefs ) {
P4GT_ClearRefs();
// Get Object files
IObjXRefManager* manager = GetObjXRefManager();
for ( int i=0; i<manager->GetNumFiles(); i++ ) {
P4GT_AddRef( manager->GetFile( i ).GetFileName().data() );
}
// Get Scene files
INode* root = GetCOREInterface()->GetRootNode();
for ( int i=0; i<root->GetXRefFileCount(); i++ ) {
TSTR filename = root->GetXRefFile( i ).GetFileName();
P4GT_AddRef( filename.data() );
}
P4GT_SyncReferences();
((CallbackManager *)data)->doneRefs = true;
}
}
void CallbackManager::promptOpenDocument( void *data, NotifyInfo *info )
{
P4GT_FileOpenEvent();
((CallbackManager *)data)->doingOpen = false;
}
# |
Change |
User |
Description |
Committed |
|
#1
|
10140 |
Matt Attaway |
Initial release of the P4GT source code. |
|
|