Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,416 @@
/*=========================================================================
*
* CPABaseO.cpp - CPA_BaseObject : implementation
*
*
* Version 1.0
* Creation date 20.06.97
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "itf/CPABaseO.hpp"
#include "acp_base.h"
#include "itf/CPAEditB.hpp"
#include "itf/NameMngr.hpp"
#include "itf/CPAInter.hpp"
//#################################################################################
// INITS
//#################################################################################
/*===========================================================================
Constructor
=========================================================================*/
CPA_BaseObject::CPA_BaseObject (CPA_EditorBase *pEditor, const CString csType, CPA_BaseObject *pOwner, BOOL bAvailable)
{
// init parameters
m_p_oEditor = pEditor;
m_p_oOwner = pOwner;
m_p_oBaseObjectList = pEditor->GetBaseObjectList(csType);
m_p_oInvalidObjectList = pEditor->GetInvalidObjectList(csType);
m_bIsAvailable = bAvailable;
// NAME IS NOT VALID
m_csName.Empty();
m_p_szName = NULL;
m_bIsValid = FALSE;
}
/*===========================================================================
Copy-Constructor
=========================================================================*/
CPA_BaseObject::CPA_BaseObject (CPA_BaseObject &r_oSource)
{
// init parameters
m_p_oEditor = r_oSource.m_p_oEditor;
m_p_oOwner = r_oSource.m_p_oOwner;
m_p_oBaseObjectList = r_oSource.m_p_oBaseObjectList;
m_p_oInvalidObjectList = r_oSource.m_p_oInvalidObjectList;
m_bIsAvailable = r_oSource.m_bIsAvailable;
// NAME IS NOT VALID
m_csName.Empty();
m_p_szName = NULL;
m_bIsValid = FALSE;
}
/*===========================================================================
Destructor
=========================================================================*/
CPA_BaseObject::~CPA_BaseObject (void)
{
// remove object from corresponding BaseObjectList
fn_bUnRegister();
}
/*===========================================================================
Owner
=========================================================================*/
BOOL CPA_BaseObject::fn_bSetOwner (CPA_BaseObject *pNewOwner)
{
// can only be initialised once
if (m_p_oOwner != NULL)
return FALSE;
// update BaseObjectList if the object is into the list
if (! m_csName.IsEmpty())
{
if (m_bIsValid)
m_p_oBaseObjectList->fn_vBeforeChangingObjectOwner(this, pNewOwner);
else
m_p_oInvalidObjectList->fn_vBeforeChangingObjectOwner(this, pNewOwner);
}
// update owner
m_p_oOwner = pNewOwner;
return TRUE;
}
/*===========================================================================
Data
=========================================================================*/
void CPA_BaseObject::fn_vUpdateData (void *pNewData)
{
// update BaseObjectList if the object is into the list
if (! m_csName.IsEmpty())
{
if (m_bIsValid)
m_p_oBaseObjectList->fn_vBeforeChangingObjectData(this, pNewData);
else
m_p_oInvalidObjectList->fn_vBeforeChangingObjectData(this, pNewData);
}
}
/*===========================================================================
MainWorld
=========================================================================*/
CPA_MainWorld * CPA_BaseObject::GetMainWorld (void)
{
return GetEditor()->GetMainWorld();
}
/*===========================================================================
Type
=========================================================================*/
CString CPA_BaseObject::GetType (void)
{
if (m_p_oBaseObjectList == NULL)
return ("");
return m_p_oBaseObjectList->fn_csGetTypeName();
}
char * CPA_BaseObject::fn_p_szGetType (void)
{
return m_p_oBaseObjectList->fn_szGetTypeName();
}
//#################################################################################
// PRIVATE FUNCTIONS
//#################################################################################
/*===========================================================================
* Description: register object in corresponding BaseObjectList
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_BaseObject::fn_bRegister (void)
{
// default => is valid
m_bIsValid = TRUE;
// register in list
return m_p_oBaseObjectList->fn_bAddObject(this);
}
/*===========================================================================
* Description: unregister object from corresponding BaseObjectList
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_BaseObject::fn_bUnRegister (void)
{
// valid => remove from base list
if (m_bIsValid)
return m_p_oBaseObjectList->fn_bRemoveObject(this);
// invalid => remove from invalid list
else
return m_p_oInvalidObjectList->fn_bRemoveObject(this);
}
/*===========================================================================
* Description: rename object and register it if necessary
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_BaseObject::fn_vDoRename (const CString csNewName)
{
BOOL bFirstRegister;
bFirstRegister = m_csName.IsEmpty();
// update BaseObjectList
if (!bFirstRegister)
{
if (m_bIsValid)
m_p_oBaseObjectList->fn_vBeforeChangingObjectName(this, (char*)(LPCTSTR) csNewName);
else
m_p_oInvalidObjectList->fn_vBeforeChangingObjectName(this, (char*)(LPCTSTR) csNewName);
}
// update name
m_csName = csNewName;
m_p_szName = (char*)(LPCTSTR) m_csName;
// if necessary, register object
if (bFirstRegister)
fn_bRegister();
}
//#################################################################################
// VALIDITY
//#################################################################################
/*===========================================================================
* Description: validate object (if initialised) and update corresponding list
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_BaseObject::fn_bValidate (void)
{
BOOL bResult;
// cannot validate an object without name
if (m_csName.IsEmpty())
return FALSE;
// update flag
m_bIsValid = TRUE;
// switch from invalid list to base list
bResult = m_p_oInvalidObjectList->fn_bRemoveObject(this);
bResult = m_p_oBaseObjectList->fn_bAddObject(this);
return bResult;
}
/*===========================================================================
* Description: invalidate object and update corresponding list
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_BaseObject::fn_bUnValidate (void)
{
BOOL bResult;
// update flag
m_bIsValid = FALSE;
// switch from invalid list to base list
bResult = m_p_oBaseObjectList->fn_bRemoveObject(this);
bResult = m_p_oInvalidObjectList->fn_bAddObject(this);
return bResult;
}
//#################################################################################
// DEFAULT NAME
//#################################################################################
/*===========================================================================
* Description: ask the list for a default name, and check unicity criteria
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CString CPA_BaseObject::GetDefaultUniqueName (const CString csDefaultBaseName /*=""*/)
{
CString csNewName;
CPA_Interface *pInterface;
pInterface = GetEditor()->GetInterface();
do {
csNewName = pInterface->GetPrefixedName( GetBaseObjectList() -> GetNewName(csDefaultBaseName) );
} while( fn_eCheckUnicity(csNewName) != E_mc_None );
return csNewName;
}
/*===========================================================================
* Description: rename object with default name, according to unicity criteria
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_BaseObject::SetDefaultUniqueName (const CString csDefaultBaseName /*= ""*/)
{
CString csNewName;
csNewName = GetDefaultUniqueName(csDefaultBaseName);
fn_vDoRename(csNewName);
}
//#################################################################################
// UNICITY
//#################################################################################
/*===========================================================================
* Description: check type
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_BaseObject::fn_bIsOfType (const CString csTypeName)
{
return ((csTypeName.IsEmpty()) || (csTypeName.CompareNoCase(GetType()) == 0));
}
/*===========================================================================
* Description: default unicity criteria => Type + Name
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
tdeMissingCriteria CPA_BaseObject::fn_eCheckDefaultUnicity (const CString csNewName)
{
CPA_List<CPA_BaseObject> oListObjects;
long lNbObjects;
if (csNewName.IsEmpty())
return E_mc_NoName;
// check BaseObjectList => unicity Name + Type
lNbObjects = m_p_oBaseObjectList->fn_lFindObjects(NULL, csNewName, GetType());
if (lNbObjects > 0)
return E_mc_TypeUnicity;
// check InvalidObjectList => unicity Name + Type
lNbObjects = m_p_oInvalidObjectList->fn_lFindObjects(NULL, csNewName, GetType());
if (lNbObjects > 0)
return E_mc_TypeUnicity;
// no objection
return E_mc_None;
}
/*===========================================================================
* Description: current unicity criteria => Type + Name + Owner
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
tdeMissingCriteria CPA_BaseObject::fn_eCheckUnicityWithOwner (const CString csNewName)
{
long lNbObjects;
if (csNewName.IsEmpty())
return E_mc_NoName;
// check ReachableObjectList => unicity Name + Type
lNbObjects = m_p_oBaseObjectList->fn_lFindObjects(NULL, csNewName, GetType(), m_p_oOwner);
if (lNbObjects > 0)
return E_mc_OwnerUnicity;
// check InvalidObjectList => unicity Name + Type
lNbObjects = m_p_oInvalidObjectList->fn_lFindObjects(NULL, csNewName, GetType(), m_p_oOwner);
if (lNbObjects > 0)
return E_mc_OwnerUnicity;
// no objection
return E_mc_None;
}
//#################################################################################
// RENAME
//#################################################################################
/*===========================================================================
* Description: check unicity criteria and rename object
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
tdeMissingCriteria CPA_BaseObject::fn_eRename (const CString csNewName)
{
tdeMissingCriteria eResult;
CPA_Interface *pInterface;
CString csName;
pInterface = m_p_oEditor->GetInterface();
// not loading => check prefix
if ((!pInterface->fn_bIsLoadingWorld())&&(!csNewName.IsEmpty()))
csName = pInterface->GetPrefixedName(csNewName);
else
csName = csNewName;
// check unicity
eResult = fn_eCheckUnicity(csName);
// rename object
if (eResult == E_mc_None)
fn_vDoRename(csName);
// loading => register conflict
else if ((eResult != E_mc_NoName)&&(pInterface->fn_bIsLoadingWorld()))
{
pInterface->fn_vAddRenamedObject();
g_oNameManager.fn_vRegisterConflict(this, csName, eResult);
}
return eResult;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,952 @@
/*=========================================================================
*
* CPAEditB.cpp : CPA_EditorBase : Implementation file.
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#include "Itf/customid.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAMdfO.hpp"
#include "itf/CPAEditB.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAProj.hpp"
/*===========================================================================
Constructor
=========================================================================*/
CPA_EditorBase::CPA_EditorBase (void)
{
m_oListOfBaseObjectList.RemoveAll();
m_oListOfInvalidObjectList.RemoveAll();
// m_oListOfModifiedBaseObjects.RemoveAll();
m_p_oMainWorld = NULL;
m_stContext.pPreviousEditor = NULL;
// editor info
m_stEditorInfo.csName = "";
m_stEditorInfo.csAuthor = "";
m_stEditorInfo.csVersion = "";
m_stEditorInfo.csFrenchHelpFile = "";
m_stEditorInfo.csEnglishHelpFile = "";
}
CPA_EditorBase::~CPA_EditorBase (void)
{
CPA_BaseObjectList *p_oList;
while (!(m_oListOfBaseObjectList.IsEmpty()))
{
p_oList = m_oListOfBaseObjectList.GetHead();
p_oList->DeleteAllObjects();
delete m_oListOfBaseObjectList.RemoveHead();
}
while (!(m_oListOfInvalidObjectList.IsEmpty()))
{
p_oList = m_oListOfInvalidObjectList.GetHead();
p_oList->DeleteAllObjects();
delete m_oListOfInvalidObjectList.RemoveHead();
}
/*
POSITION stPos = m_oListOfModifiedBaseObjects.GetHeadPosition();
while ( stPos )
{
tdstModifiedObjectsInfo *p_stList = m_oListOfModifiedBaseObjects.GetNext( stPos );
POSITION stPosROLN = p_stList -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPosROLN )
{
tdstBaseObjectListNamed *p_stROLN = p_stList -> m_oListOfModifiedObjects . GetNext( stPosROLN );
p_stROLN -> m_oListOfBaseObjects . DeleteAllElements ();
delete p_stROLN;
}
p_stList -> m_oListOfModifiedObjects . RemoveAll();
delete p_stList;
}
*/
}
void CPA_EditorBase::SetEditorInfo(CString csName, CString csAuthor,
CString csVersion, CString csFrenchHelpFile, CString csEnglishHelpFile)
{
m_stEditorInfo . csName = csName;
m_stEditorInfo . csAuthor = csAuthor;
m_stEditorInfo . csVersion = csVersion;
m_stEditorInfo . csFrenchHelpFile = csFrenchHelpFile;
m_stEditorInfo . csEnglishHelpFile = csEnglishHelpFile;
}
void CPA_EditorBase::SetMainWorld (CPA_MainWorld *p_oMainWorld)
{
m_p_oMainWorld = p_oMainWorld;
if (m_p_oMainWorld)
m_p_oMainWorld->fn_vRegisterEditor(this);
}
CPA_Interface * CPA_EditorBase::GetInterface (void)
{
return m_p_oMainWorld->GetInterface();
}
/*===========================================================================
Register objects types for BaseObjectsList
=========================================================================*/
void CPA_EditorBase::fn_vRegisterObjectsType (CString a_csTypeName[], long lTypeCount)
{
long iIndex;
for (iIndex = 0; iIndex < lTypeCount; iIndex++)
{
CPA_BaseObjectList *p_oListOfObjects;
// check if there is allready a list with that typename!!!!
ASSERT(m_p_oMainWorld->fn_p_oGetOriginalObjectList(a_csTypeName[iIndex]) == NULL);
// create base object list
p_oListOfObjects = new CPA_BaseObjectList(a_csTypeName[iIndex]);
m_oListOfBaseObjectList.AddTail(p_oListOfObjects);
// create invalid object list
p_oListOfObjects = new CPA_BaseObjectList(a_csTypeName[iIndex]);
m_oListOfInvalidObjectList.AddTail(p_oListOfObjects);
}
}
/*===========================================================================
Get the BaseObjectList corresponding to csTypeName
=========================================================================*/
CPA_BaseObjectList * CPA_EditorBase::GetBaseObjectList (CString csTypeName)
{
CPA_BaseObjectList *p_oListOfObjects;
POSITION pos;
pos = m_oListOfBaseObjectList.GetHeadPosition();
// search list
while(pos)
{
p_oListOfObjects = m_oListOfBaseObjectList.GetNext(pos);
if (p_oListOfObjects->fn_bIsOfType(csTypeName))
return p_oListOfObjects;
}
return NULL;
}
/*===========================================================================
Get the BaseObjectList corresponding to csTypeName
=========================================================================*/
CPA_BaseObjectList * CPA_EditorBase::GetInvalidObjectList (CString csTypeName)
{
CPA_BaseObjectList *p_oListOfObjects;
POSITION pos;
pos = m_oListOfInvalidObjectList.GetHeadPosition();
// search list
while(pos)
{
p_oListOfObjects = m_oListOfInvalidObjectList.GetNext(pos);
if (p_oListOfObjects->fn_bIsOfType(csTypeName))
return p_oListOfObjects;
}
return NULL;
}
/*===========================================================================
Add object to the corresponding BaseObjectList
=========================================================================*/
BOOL CPA_EditorBase::fn_bAddObject (CPA_BaseObject *p_oObject)
{
CPA_BaseObjectList *p_oListOfObjects;
// find the list
if (p_oObject->fn_bIsValid())
p_oListOfObjects = GetBaseObjectList(p_oObject->GetType());
else
p_oListOfObjects = GetInvalidObjectList(p_oObject->GetType());
// if the list for this type of object does not exist
if (!p_oListOfObjects)
{
ASSERT(0);
return FALSE;
}
// add object
return p_oListOfObjects->fn_bAddObject(p_oObject);
}
/*===========================================================================
Remove object from the corresponding BaseObjectList
=========================================================================*/
BOOL CPA_EditorBase::fn_bRemoveObject (CPA_BaseObject *p_oObject)
{
CPA_BaseObjectList *p_oListOfObjects;
// find corresponding list
if (p_oObject->fn_bIsValid())
p_oListOfObjects = GetBaseObjectList(p_oObject->GetType());
else
p_oListOfObjects = GetInvalidObjectList(p_oObject->GetType());
// type of object does not exists in this DLL
if (p_oListOfObjects == NULL)
{
ASSERT(0);
return FALSE;
}
return p_oListOfObjects->fn_bRemoveObject(p_oObject);
}
/*===========================================================================
check if object exists
=========================================================================*/
BOOL CPA_EditorBase::fn_bExist(CPA_BaseObject *p_oObject, tdeResearchCriteria eCriteria)
{
CPA_BaseObjectList *p_oListOfObjects;
BOOL bResult = FALSE;
// look in base object list
if (eCriteria != E_rc_InvalidObjects)
{
p_oListOfObjects = GetBaseObjectList(p_oObject->GetType());
if (p_oListOfObjects)
bResult = p_oListOfObjects->fn_bExist(p_oObject);
}
// look in invalid object list
if ((!bResult)&&(eCriteria != E_rc_ValidObjects))
{
p_oListOfObjects = GetInvalidObjectList(p_oObject->GetType());
if (p_oListOfObjects)
bResult = p_oListOfObjects->fn_bExist(p_oObject);
}
return bResult;
}
/*===========================================================================
check if object exists
=========================================================================*/
BOOL CPA_EditorBase::fn_bExist(CString csObjectName, CString csObjectType, CPA_BaseObject *p_oOwner, tdeResearchCriteria eCriteria)
{
CPA_BaseObjectList *p_oListOfObjects;
POSITION pos;
BOOL bResult = FALSE;
if ((csObjectName.IsEmpty()) && (csObjectType.IsEmpty()) && (p_oOwner == NO_CRITERIA))
{
ASSERT(0);
}
// if type is valid
if (!csObjectType.IsEmpty())
{
// look in base object list
if (eCriteria != E_rc_InvalidObjects)
{
p_oListOfObjects = GetBaseObjectList(csObjectType);
if (p_oListOfObjects)
bResult = fn_bExist(csObjectName,csObjectType,p_oOwner);
}
// look in invalid object list
if ((!bResult)&&(eCriteria != E_rc_ValidObjects))
{
p_oListOfObjects = GetInvalidObjectList(csObjectType);
if (p_oListOfObjects)
bResult = fn_bExist(csObjectName,csObjectType,p_oOwner);
}
return bResult;
}
else
{
// look in every base object list
if (eCriteria != E_rc_InvalidObjects)
{
pos = m_oListOfBaseObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfBaseObjectList.GetNext(pos);
// find the object in this list
if (p_oListOfObjects->fn_bExist(csObjectName,csObjectType,p_oOwner))
return TRUE;
}
}
// look in every invalid object list
if (eCriteria != E_rc_ValidObjects)
{
pos = m_oListOfInvalidObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfInvalidObjectList.GetNext(pos);
// find the object in this list
if (p_oListOfObjects->fn_bExist(csObjectName,csObjectType,p_oOwner))
return TRUE;
}
}
}
return FALSE;
}
/*===========================================================================
find object from its type and name
=========================================================================*/
CPA_BaseObject * CPA_EditorBase::GetBaseObject (CString csObjectName, CString csObjectType, CPA_BaseObject *p_oOwner, tdeResearchCriteria eCriteria)
{
CPA_BaseObjectList *p_oListOfObjects;
CPA_BaseObject *p_oObject = NULL;
POSITION pos;
if ((csObjectName.IsEmpty()) && (csObjectType.IsEmpty()) && (p_oOwner == NO_CRITERIA))
{
ASSERT(0);
}
// if type is valid
if (!csObjectType.IsEmpty())
{
// look in base object list
if (eCriteria != E_rc_InvalidObjects)
{
p_oListOfObjects = GetBaseObjectList(csObjectType);
if (p_oListOfObjects)
p_oObject = p_oListOfObjects->fn_p_oFindObject(csObjectName,csObjectType,p_oOwner);
}
// look in invalid object list
if ((!p_oObject)&&(eCriteria != E_rc_ValidObjects))
{
p_oListOfObjects = GetInvalidObjectList(csObjectType);
if (p_oListOfObjects)
p_oObject = p_oListOfObjects->fn_p_oFindObject(csObjectName,csObjectType,p_oOwner);
}
return p_oObject;
}
else
{
// look in every base object list
if (eCriteria != E_rc_InvalidObjects)
{
pos = m_oListOfBaseObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfBaseObjectList.GetNext(pos);
// find the object in this list
p_oObject = p_oListOfObjects->fn_p_oFindObject(csObjectName,csObjectType,p_oOwner);
if (p_oObject != NULL)
return p_oObject;
}
}
// look in every invalid object list
if (eCriteria != E_rc_ValidObjects)
{
pos = m_oListOfInvalidObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfInvalidObjectList.GetNext(pos);
// find the object in this list
p_oObject = p_oListOfObjects->fn_p_oFindObject(csObjectName,csObjectType,p_oOwner);
if (p_oObject != NULL)
return p_oObject;
}
}
}
return NULL;
}
/*===========================================================================
find object from its type and engine struct
=========================================================================*/
CPA_BaseObject * CPA_EditorBase::GetBaseObject (void *p_vEngineStruct, CString csObjectType, CPA_BaseObject *p_oOwner, tdeResearchCriteria eCriteria)
{
CPA_BaseObjectList *p_oListOfObjects;
CPA_BaseObject *p_oObject = NULL;
POSITION pos;
if ((p_vEngineStruct == NULL) && (csObjectType.IsEmpty()) && (p_oOwner == NO_CRITERIA))
{
ASSERT(0);
}
// if type is valid
if (!csObjectType.IsEmpty())
{
// look in base object list
if (eCriteria != E_rc_InvalidObjects)
{
p_oListOfObjects = GetBaseObjectList(csObjectType);
if (p_oListOfObjects)
p_oObject = p_oListOfObjects->fn_p_oFindObjectWithdData(p_vEngineStruct,csObjectType,p_oOwner);
}
// look in invalid object list
if ((!p_oObject)&&(eCriteria != E_rc_ValidObjects))
{
p_oListOfObjects = GetInvalidObjectList(csObjectType);
if (p_oListOfObjects)
p_oObject = p_oListOfObjects->fn_p_oFindObjectWithdData(p_vEngineStruct,csObjectType,p_oOwner);
}
return p_oObject;
}
else
{
// look in every base object list
if (eCriteria != E_rc_InvalidObjects)
{
pos = m_oListOfBaseObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfBaseObjectList.GetNext(pos);
// find the object in this list
p_oObject = p_oListOfObjects->fn_p_oFindObjectWithdData(p_vEngineStruct,csObjectType,p_oOwner);
if (p_oObject != NULL)
return p_oObject;
}
}
// look in every invalid object list
if (eCriteria != E_rc_ValidObjects)
{
pos = m_oListOfInvalidObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfInvalidObjectList.GetNext(pos);
// find the object in this list
p_oObject = p_oListOfObjects->fn_p_oFindObjectWithdData(p_vEngineStruct,csObjectType,p_oOwner);
if (p_oObject != NULL)
return p_oObject;
}
}
}
return NULL;
}
/*===========================================================================
find objects with given type and name
=========================================================================*/
long CPA_EditorBase::fn_lFindObjects (CPA_List<CPA_BaseObject> *p_oResultList, CString csObjectName, CString csObjectType, CPA_BaseObject *p_oOwner, tdeResearchCriteria eCriteria)
{
CPA_BaseObjectList *p_oListOfObjects;
POSITION pos;
long lResult = 0;
if ((csObjectName.IsEmpty()) && (csObjectType.IsEmpty()) && (p_oOwner == NO_CRITERIA))
{
ASSERT(0);
}
// if type is valid
if (!csObjectType.IsEmpty())
{
// look in base object list
if (eCriteria != E_rc_InvalidObjects)
{
p_oListOfObjects = GetBaseObjectList(csObjectType);
if (p_oListOfObjects)
lResult += p_oListOfObjects->fn_lFindObjects(p_oResultList,csObjectName,csObjectType,p_oOwner);
}
// look in invalid object list
if (eCriteria != E_rc_ValidObjects)
{
p_oListOfObjects = GetInvalidObjectList(csObjectType);
if (p_oListOfObjects)
lResult += p_oListOfObjects->fn_lFindObjects(p_oResultList,csObjectName,csObjectType,p_oOwner);
}
}
else
{
// look in every base object list
if (eCriteria != E_rc_InvalidObjects)
{
pos = m_oListOfBaseObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfBaseObjectList.GetNext(pos);
// find the object in this list
lResult += p_oListOfObjects->fn_lFindObjects(p_oResultList,csObjectName,csObjectType,p_oOwner);
}
}
// look in every invalid object list
if (eCriteria != E_rc_ValidObjects)
{
pos = m_oListOfInvalidObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfInvalidObjectList.GetNext(pos);
// find the object in this list
lResult += p_oListOfObjects->fn_lFindObjects(p_oResultList,csObjectName,csObjectType,p_oOwner);
}
}
}
return lResult;
}
/*
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// for Modified Reachable Objects
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CPA_EditorBase::fn_vRegisterModificationsType(CString _csObjectTypeName, CString a_csModificationType[], long lTypeCount)
{
ASSERT( GetBaseObjectList( _csObjectTypeName ) );
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
if ( !p_stList )
{
// create new
p_stList = new(tdstModifiedObjectsInfo);
p_stList -> m_oObjectType = _csObjectTypeName;
p_stList-> m_oListOfModifiedObjects . RemoveAll();
// add
m_oListOfModifiedBaseObjects . AddTail( p_stList );
}
// add modifications
for ( long i=0 ; i<lTypeCount ; i++ )
{
ASSERT( !fn_bIsRegisterModificationType( p_stList, a_csModificationType[i] ) );
tdstBaseObjectListNamed *p_stROLN = new(tdstBaseObjectListNamed);
p_stROLN -> m_ocsModificationTypeName = a_csModificationType[i];
p_stROLN -> m_oListOfBaseObjects . DeleteAllElements();
// p_stROLN -> m_oListOfBaseObjects . fn_bSetTypeName( _csObjectTypeName );
p_stList -> m_oListOfModifiedObjects . AddTail( p_stROLN );
}
}
*/
/*===========================================================================
=========================================================================*/
/*
long CPA_EditorBase::fn_lFillWithRegisterModificationsType(CPA_List<CString> *_p_oList, CString _csObjectTypeName)
{
ASSERT( GetBaseObjectList( _csObjectTypeName ) );
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
if( p_stList )
{
POSITION stPos = p_stList->m_oListOfModifiedObjects.GetHeadPosition();
while ( stPos )
{
_p_oList -> AddTail( &(p_stList -> m_oListOfModifiedObjects . GetNext( stPos ) -> m_ocsModificationTypeName) );
}
return ((long)p_stList->m_oListOfModifiedObjects.GetCount());
}
return 0;
}
*/
/*===========================================================================
=========================================================================*/
/*
int CPA_EditorBase::fn_iGetModificationCount(CString _csObjectTypeName)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
return ( p_stList ? p_stList -> m_oListOfModifiedObjects . GetCount() : 0 );
}
*/
/*===========================================================================
=========================================================================*/
/*
CPA_BaseObjectList* CPA_EditorBase::fn_p_oGetModifiedObjectsList(CString _csObjectTypeName, CString _csModificationType)
{
tdstBaseObjectListNamed *p_stROLN = fn_p_stGetROLN (_csObjectTypeName, _csModificationType);
return ( p_stROLN ? &(p_stROLN -> m_oListOfBaseObjects) : NULL );
}
*/
/*===========================================================================
=========================================================================*/
/*
int CPA_EditorBase::fn_iGetModificationIndex(CString _csObjectTypeName, CString _csModificationType)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
if(p_stList)
{
int iResult = 0;
POSITION stPos = p_stList -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPos )
{
if( p_stList -> m_oListOfModifiedObjects . GetNext( stPos ) -> m_ocsModificationTypeName == _csModificationType )
return iResult;
iResult++;
}
}
return -1;
}
*/
/*===========================================================================
=========================================================================*/
/*
CString CPA_EditorBase::fn_csGetModificationByIndex(CString _csObjectTypeName, int _iIndex )
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
if(p_stList)
{
POSITION stPos = p_stList -> m_oListOfModifiedObjects . FindIndex( _iIndex );
return ( stPos ? p_stList -> m_oListOfModifiedObjects . GetAt( stPos ) -> m_ocsModificationTypeName : "");
}
return "";
}
*/
/*===========================================================================
=========================================================================*/
/*
BOOL CPA_EditorBase::fn_bAddModifiedObject(CPA_BaseObject *_p_oObject, CString _csModificationType)
{
tdstBaseObjectListNamed *p_stROLN = fn_p_stGetROLN (_p_oObject -> GetType(), _csModificationType);
if ( p_stROLN )
{
return p_stROLN -> m_oListOfBaseObjects . fn_bAddObject(_p_oObject);
}
return FALSE;
}
*/
/*===========================================================================
=========================================================================*/
/*
BOOL CPA_EditorBase::fn_bRemoveModifiedObject(CPA_BaseObject *_p_oObject, CString _csModificationType)
{
tdstBaseObjectListNamed *p_stROLN = fn_p_stGetROLN (_p_oObject -> GetType(), _csModificationType);
if ( p_stROLN )
{
return p_stROLN -> m_oListOfBaseObjects . fn_bRemoveObject(_p_oObject);
}
return FALSE;
}
*/
/*===========================================================================
=========================================================================*/
/*
BOOL CPA_EditorBase::fn_bIsModified(CPA_BaseObject *_p_oObject, CString _csModificationType )
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _p_oObject -> GetType() );
if(p_stList)
{
if ( _csModificationType != "" )
{
tdstBaseObjectListNamed *p_stROLN = fn_p_stGetROLN (p_stList, _csModificationType );
return ( p_stROLN ? p_stROLN -> m_oListOfBaseObjects . fn_bExist( _p_oObject ) : FALSE );
}
else
{
POSITION stPos = p_stList -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPos )
{
tdstBaseObjectListNamed *p_stROLN = p_stList -> m_oListOfModifiedObjects . GetNext( stPos );
if( (p_stROLN) && p_stROLN -> m_oListOfBaseObjects . fn_bExist( _p_oObject ) )
return TRUE;
}
}
}
return FALSE;
}
*/
/*===========================================================================
for dialog list
=========================================================================*/
void CPA_EditorBase::fn_vInitDefaultParameters (CPA_DialogList *pDialog)
{
pDialog->SetDefaultTestName("No Test");
pDialog->SetDefaultTypeName("");
}
/*===========================================================================
save context when editor changes
=========================================================================*/
void CPA_EditorBase::fn_vSaveContext (void)
{
int i, j;
// save current dll
if (GetMainWorld()->GetCurrentEditor() != this)
{
if (!m_stContext.pPreviousEditor)
{
m_stContext.pPreviousEditor = GetMainWorld()->GetCurrentEditor();
// save and update current editor
if (m_stContext.pPreviousEditor)
{
m_stContext.bCurrentEditor = m_stContext.pPreviousEditor->fn_bIsCurrentEditor();
m_stContext.pPreviousEditor->SetCurrent(FALSE);
}
// save dialogs
memcpy(m_stContext.m_aWinArray, g_oFrameGest.ma_p_oWinArray, sizeof(FRMBase *) * (FRM_C_MaxCol+2) * (FRM_C_MaxRow+2));
}
else
{
m_stContext.pPreviousEditor->SetCurrent(FALSE);
if (GetMainWorld()->GetCurrentEditor())
GetMainWorld()->GetCurrentEditor()->SetCurrent(FALSE);
}
// close all editor frames
for (i=1; i<=FRM_C_MaxCol; i++)
{
for (j=1; j<=FRM_C_MaxRow; j++)
{
if (((i!=2)||(j!=2))&&(g_oFrameGest.ma_p_oWinArray[i][j]))
g_oFrameGest.mfn_vDisactivateWindow(g_oFrameGest.ma_p_oWinArray[i][j]);
}
}
}
}
/*===========================================================================
restore context when editor changes
=========================================================================*/
void CPA_EditorBase::fn_vRestoreContext (void)
{
int i, j;
// restore current dll and editor
if (m_stContext.pPreviousEditor)
{
m_stContext.pPreviousEditor->SetCurrent(m_stContext.bCurrentEditor);
GetMainWorld()->fn_bRestoreEditor(m_stContext.pPreviousEditor);
// close all editor frames
for (i=1; i<=FRM_C_MaxCol; i++)
{
for (j=1; j<=FRM_C_MaxRow; j++)
{
if (((i!=2)||(j!=2))&&(g_oFrameGest.ma_p_oWinArray[i][j]))
g_oFrameGest.mfn_vDisactivateWindow(g_oFrameGest.ma_p_oWinArray[i][j]);
}
}
// restore previous dialogs
for (i=1; i<=FRM_C_MaxCol; i++)
{
for (j=1; j<=FRM_C_MaxRow; j++)
{
if (((i!=2)||(j!=2))&&(m_stContext.m_aWinArray[i][j]))
{
g_oFrameGest.mfn_vActivateWindow(m_stContext.m_aWinArray[i][j]);
m_stContext.m_aWinArray[i][j] = NULL;
}
}
}
}
// reinit context
m_stContext.pPreviousEditor = NULL;
}
/*===========================================================================
=========================================================================*/
CString CPA_EditorBase::GetReferencePath (CString csEntry)
{
CString csFileName, csReferencePath;
char szPath[SCR_CV_ui_Cfg_MaxLenName];
// search ini file for given entry
csFileName = M_GetMainApp()->m_csEditorDataPath + C_szReferenceIniFile;
GetPrivateProfileString ("ReferencePath", (char*)(LPCSTR)csEntry, "", szPath, 256, (char*)(LPCSTR)csFileName);
// build reference path
csReferencePath = szPath;
return csReferencePath;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// private
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*===========================================================================
=========================================================================*/
/*
BOOL CPA_EditorBase::fn_bIsRegisterModificationType(CString _csObjectType, CString _csModificationType)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo(_csObjectType);
return (p_stList ? fn_bIsRegisterModificationType(p_stList, _csModificationType) : FALSE );
}
*/
/*===========================================================================
=========================================================================*/
/*
BOOL CPA_EditorBase::fn_bIsRegisterModificationType(tdstModifiedObjectsInfo *p_stMOI, CString _csModificationType)
{
POSITION stPos = p_stMOI -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPos )
{
if( p_stMOI -> m_oListOfModifiedObjects . GetNext( stPos ) -> m_ocsModificationTypeName == _csModificationType )
return TRUE;
}
return FALSE;
}
*/
/*===========================================================================
=========================================================================*/
/*
tdstModifiedObjectsInfo *CPA_EditorBase::fn_p_stGetMOInfo(CString _csObjectType)
{
POSITION stPos = m_oListOfModifiedBaseObjects . GetHeadPosition();
while ( stPos )
{
tdstModifiedObjectsInfo *p_stList = m_oListOfModifiedBaseObjects . GetNext( stPos );
if( p_stList -> m_oObjectType == _csObjectType )
return p_stList;
}
return NULL;
}
*/
/*===========================================================================
=========================================================================*/
/*tdstBaseObjectListNamed *CPA_EditorBase::fn_p_stGetROLN(CString _csObjectType, CString _csModificationType)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo(_csObjectType);
return (p_stList ? fn_p_stGetROLN(p_stList, _csModificationType) : NULL );
}
*/
/*===========================================================================
=========================================================================*/
/*
tdstBaseObjectListNamed *CPA_EditorBase::fn_p_stGetROLN(tdstModifiedObjectsInfo *_p_stMOI, CString _csModificationType)
{
POSITION stPos = _p_stMOI -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPos )
{
tdstBaseObjectListNamed *p_stList = _p_stMOI -> m_oListOfModifiedObjects . GetNext( stPos );
if( p_stList -> m_ocsModificationTypeName == _csModificationType )
return p_stList;
}
return NULL;
}
*/
/*===========================================================================
=========================================================================*/
void CPA_EditorBase::fn_vRegisterModificationsType(const CString _csObjectTypeName, CString a_csModificationType[], long lTypeCount)
{
// search CPA_ModifNamesList
CPA_ModifNamesList *p_oList = fn_p_oGetModifNamesList( _csObjectTypeName );
if ( p_oList == NULL )
{
// add list
p_oList = new CPA_ModifNamesList();
p_oList -> fn_vSetObjectTypeName( _csObjectTypeName );
m_oListOfModifications . AddTail( p_oList );
}
p_oList -> fn_vRegisterModificationsType( a_csModificationType, lTypeCount );
}
/*===========================================================================
=========================================================================*/
CPA_ModifNamesList *CPA_EditorBase::fn_p_oGetModifNamesList(const CString _csObjectTypeName)
{
POSITION xPos = m_oListOfModifications . GetHeadPosition();
while ( xPos )
{
CPA_ModifNamesList *p_oList = m_oListOfModifications . GetNext( xPos );
if( p_oList -> fn_csGetObjectTypeName() == _csObjectTypeName )
return p_oList;;
}
return NULL;
}
/*===========================================================================
=========================================================================*/
long CPA_EditorBase::fn_lFillWithModifiedObject(CPA_List<CPA_ModifiableObject> *_p_oTargetList, const CString _csObjectTypeName, const CString _csModifTypeName)
{
BOOL bAddOnList = ( _p_oTargetList != NULL );
long lNbObjects = 0;
CPA_BaseObjectList *p_oList = GetBaseObjectList( _csObjectTypeName );
if( p_oList != NULL )
{
Position xPos = p_oList -> GetHeadPosition();
while ( xPos )
{
CPA_BaseObject *p_oObject = p_oList -> GetNext( xPos );
if( p_oObject -> fn_eGetBaseClass() == E_bc_ModifiableObject )
{
// Modifiable object
CPA_ModifiableObject *p_oModObj = (CPA_ModifiableObject *)p_oObject;
if( p_oModObj -> fn_bIsModified( _csModifTypeName ) )
{
lNbObjects++;
if(bAddOnList) _p_oTargetList -> AddTail( p_oModObj );
}
}
}
}
return lNbObjects;
}
/*===========================================================================
* Description: Get child for tree element (default implementation)
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_BaseObject * CPA_EditorBase::GetTreeNodeNextChild (CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pParent, CPA_BaseObject *pCurrentChild)
{
CPA_SuperObject *pSupObj, *pChild;
if ((pParent->GetType() == C_szSuperObjectTypeName)&&
((!pCurrentChild)||(pCurrentChild->GetType() == C_szSuperObjectTypeName)))
{
pSupObj = (CPA_SuperObject *) pParent;
pChild = (CPA_SuperObject *) pCurrentChild;
if (pChild)
return pSupObj->GetSuperObjectNextChild(pChild);
else
return pSupObj->GetSuperObjectFirstChild();
}
return NULL;
}
/*===========================================================================
============================================================================
============================================================================
class CPA_ModifNamesList
============================================================================
============================================================================
===========================================================================*/
CPA_ModifNamesList::CPA_ModifNamesList()
{
RemoveAll();
}
CPA_ModifNamesList::~CPA_ModifNamesList()
{
}
void CPA_ModifNamesList::fn_vRegisterModificationsType(CString a_csTypeName[], long lTypeCount)
{
for (long iIndex = 0; iIndex < lTypeCount; iIndex++)
AddTail( a_csTypeName[iIndex] );
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,220 @@
/*=========================================================================
*
* CPAFileO.cpp - CPA_FileObject : implementation
*
*
* Version 1.0
* Creation date 20.06.97
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAFileO.hpp"
#include "itf/CPAEditB.hpp"
#include "itf/CPAInter.hpp"
//#################################################################################
// INITS
//#################################################################################
/*===========================================================================
Constructor
=========================================================================*/
CPA_FileObject::CPA_FileObject (CPA_EditorBase *pEditor, const CString csFileName)
: CPA_BaseObject (pEditor, C_szFileTypeName)
{
tdeMissingCriteria eResult;
// list
m_oDllKeyList.RemoveAll();
// rename
eResult = fn_eRename(csFileName);
ASSERT(eResult == E_mc_None);
}
/*===========================================================================
Destructor
=========================================================================*/
CPA_FileObject::~CPA_FileObject (void)
{
}
//#################################################################################
// ACCES
//#################################################################################
/*===========================================================================
prefix string that completes the minimal name to the full name
=========================================================================*/
char *CPA_FileObject::GetCompletionPath (CPA_EditorBase *pEditor, const CString csKey)
{
tdstDllKeyList *p_stList;
tdstKeyName *p_stKey;
CString csName;
// init name
csName.Empty();
// find Dll List
p_stList = GetDllKeyList(pEditor);
if (!p_stList)
return "";
// find Key
p_stKey = GetKeyName(p_stList, csKey);
if (!p_stKey)
return "";
return (char *)LPCTSTR(p_stKey->m_csCompletionName);
}
/*===========================================================================
Minimal name
=========================================================================*/
CString CPA_FileObject::GetReferencedName (CPA_EditorBase *pEditor, const CString csKey)
{
tdstDllKeyList *p_stList;
tdstKeyName *p_stKey;
CString csName;
// init name
csName.Empty();
// find Dll List
p_stList = GetDllKeyList(pEditor);
if (!p_stList)
return csName;
// find Key
p_stKey = GetKeyName(p_stList, csKey);
if (!p_stKey)
return csName;
// return corresponding name
return (p_stKey->m_csName);
}
/*===========================================================================
Complete name
=========================================================================*/
CString CPA_FileObject::GetCompleteName (void)
{
CString csName, csPrefix;
// get current prefix
csPrefix = GetName().Left(4);
// if necessary, remove prefix
if (csPrefix == GetEditor()->GetInterface()->GetUserPrefix())
csName = GetName().Mid(4);
else
csName = GetName();
return csName;
}
/*===========================================================================
Register reference
=========================================================================*/
//replace all '/' symbols by '\' symbols in the path string
/*static*/ void CPA_FileObject::sm_vUniformizeSlashes(CString &r_csPath)
{
char *pszSlash = r_csPath.GetBuffer(0);
while ( pszSlash = strchr(pszSlash, '/') )
*pszSlash = '\\';
r_csPath.ReleaseBuffer();
}
BOOL CPA_FileObject::fn_bSetReferencedName(CPA_EditorBase *pEditor, const CString csKey, const CString csName)
{
tdstDllKeyList *p_stList;
tdstKeyName *p_stKey;
CString csReferencedName(csName);
sm_vUniformizeSlashes(csReferencedName); //because arg is const
//if the referenced name is not a substring of the full name, do not add the key...
if ( GetCompleteName().Find(csName) == -1 )
return FALSE;
// check if DllKeyList already exists
p_stList = GetDllKeyList(pEditor);
if (!p_stList)
{
// create new list
p_stList = new (tdstDllKeyList);
// init parameters
p_stList->m_pEditor = pEditor;
p_stList->m_oKeyList.RemoveAll();
// add it to the list
m_oDllKeyList.AddTail(p_stList);
}
// check if Key already exists
p_stKey = GetKeyName(p_stList, csKey);
if (p_stKey)
return (p_stKey->m_csName == csName);
// create new Key
p_stKey = new (tdstKeyName);
// init parameters
p_stKey->m_csKey = csKey;
p_stKey->m_csName = csName;
// completion path
long lCompleteLength = GetCompleteName().GetLength();
long lReferencedLength = p_stKey->m_csName.GetLength();
p_stKey->m_csCompletionName = (lCompleteLength > lReferencedLength)
? GetCompleteName().Left(lCompleteLength - lReferencedLength - 1)
: "";
// add it to the list
p_stList->m_oKeyList.AddTail(p_stKey);
return TRUE;
}
/*===========================================================================
Find DLL Key List
=========================================================================*/
tdstDllKeyList * CPA_FileObject::GetDllKeyList (CPA_EditorBase *pEditor)
{
tdstDllKeyList *p_stList;
POSITION pos;
pos = m_oDllKeyList.GetHeadPosition();
while (pos)
{
p_stList = m_oDllKeyList.GetNext(pos);
if (p_stList->m_pEditor == pEditor)
return p_stList;
}
return NULL;
}
/*===========================================================================
Find Key in DLL List
=========================================================================*/
tdstKeyName * CPA_FileObject::GetKeyName (tdstDllKeyList *p_stList, const CString csKey)
{
tdstKeyName *p_stKey;
POSITION pos;
pos = p_stList->m_oKeyList.GetHeadPosition();
while (pos)
{
p_stKey = p_stList->m_oKeyList.GetNext(pos);
if (p_stKey->m_csKey == csKey)
return p_stKey;
}
return NULL;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,212 @@
/*=========================================================================
*
* CPAHieEd.cpp : CPA_HierarchyEditor : Implementation file.
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#include "itf/customid.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAHieEd.hpp"
#include "itf/CPAInter.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAFileO.hpp"
//#################################################################################
// INITS
//#################################################################################
/*===========================================================================
Creation
=========================================================================*/
void CPA_HierarchyEditor::Create (void)
{
CString types[] = {C_szSuperObjectTypeName, C_szFileTypeName};
// reachable object list
fn_vRegisterObjectsType(types,2);
}
//#################################################################################
// FOCUS
//#################################################################################
/*===========================================================================
Called just before engine loop
=========================================================================*/
void CPA_HierarchyEditor::fn_vBeforeEngine()
{
// update menu
GetMainWorld()->GetFRMBase()->fn_vUpdateCurrentEditor(NULL);
// update state
GetInterface()->SetInitialState(FALSE);
}
/*===========================================================================
Update editor hierarchy after engine loop
=========================================================================*/
void CPA_HierarchyEditor::fn_vBeforeEditor()
{
}
//#################################################################################
// EDITOR
//#################################################################################
/*===========================================================================
Activate default editor
=========================================================================*/
void CPA_HierarchyEditor::fn_vOnActivateEditor (CPA_List<CPA_BaseObject> *pParams, BOOL bBackActivated)
{
CPA_SuperObject *pEdObj;
CPA_BaseObject *pElem;
POSITION pos;
// if there is a list, select corresponding super-objects
if (pParams)
{
// cancel current selection
GetInterface()->fn_vCancelCurrentSelection(FALSE);
// select parameters
for (pElem = pParams->GetHeadElement(pos); pElem;
pElem = pParams->GetNextElement(pos))
{
// check if this is a super-object
if (pElem->GetType() == C_szSuperObjectTypeName)
{
// if possible, select it
pEdObj = (CPA_SuperObject *) pElem;
if (GetInterface()->fn_bCanSelect(pEdObj) == C_Accept)
GetInterface()->fn_vAddSelectedObject(pEdObj, FALSE);
}
}
}
}
/*===========================================================================
Close default editor
=========================================================================*/
void CPA_HierarchyEditor::fn_vOnCloseEditor (void)
{
fn_vCancelAllModes();
}
//#################################################################################
// SUPER-OBJECT
//#################################################################################
/*===========================================================================
GetEditor SO from engine SO
=========================================================================*/
CPA_SuperObject * CPA_HierarchyEditor::GetEditorObject (HIE_tdxHandleToSuperObject hSupObj)
{
CPA_SuperObject *pElem;
POSITION pos;
// test the structure
for (pElem = M_GetWorld()->GetListAllObjects()->GetHeadElement(pos); pElem;
pElem = M_GetWorld()->GetListAllObjects()->GetNextElement(pos))
{
if (pElem->GetStruct() == hSupObj)
return pElem;
}
// object was not found
return NULL;
}
/*===========================================================================
Create new super-object (from engine struct)
=========================================================================*/
CPA_SuperObject * CPA_HierarchyEditor::GetNewSuperObject (HIE_tdxHandleToSuperObject hEngineSO,
tdeSaveStatus eStatus, tdeTypeSO eTypeSO,
CString csName, CString csEngineFileName)
{
CPA_SuperObject *pSupObj;
// create super-object
pSupObj = new CPA_SuperObject(this, hEngineSO, eStatus, eTypeSO);
// name
if (pSupObj->fn_eRename(csName) != E_mc_None)
pSupObj->SetDefaultUniqueName();
return pSupObj;
}
/*===========================================================================
Create new super-object
=========================================================================*/
CPA_SuperObject * CPA_HierarchyEditor::GetNewSuperObject (tdeSaveStatus eStatus, tdeTypeSO eTypeSO,
CString csName, CString csEngineFileName)
{
CPA_SuperObject *pSupObj;
// create super-object
pSupObj = new CPA_SuperObject(this, eStatus, eTypeSO);
// name
if (pSupObj->fn_eRename(csName) != E_mc_None)
pSupObj->SetDefaultUniqueName();
return pSupObj;
}
/*===========================================================================
Copy super-object
=========================================================================*/
CPA_SuperObject * CPA_HierarchyEditor::GetCopyOfSuperObject (CPA_SuperObject *pModel)
{
CPA_SuperObject *pSupObj;
// copy super-object
pSupObj = new CPA_SuperObject(*pModel);
// set new name
pSupObj->SetDefaultUniqueName();
return pSupObj;
}
//#################################################################################
// FILE-OBJECT
//#################################################################################
/*===========================================================================
Get or load file object
=========================================================================*/
CPA_FileObject * CPA_HierarchyEditor::GetFileObject (CString csFileName)
{
CPA_FileObject *pFileObject;
// get corresponding prefixed name
csFileName = GetInterface()->GetPrefixedName(csFileName);
CPA_FileObject::sm_vUniformizeSlashes(csFileName);
// check if file object already exists
pFileObject = (CPA_FileObject *) GetBaseObject(csFileName, C_szFileTypeName, NO_CRITERIA, E_rc_AllObjects);
// if necessary, create it
if (!pFileObject)
pFileObject = new CPA_FileObject(this, csFileName);
return pFileObject;
}
//ANNECY Shaitan EmptySectors 25/02/98
BOOL CPA_HierarchyEditor::fn_bCanBeParent (CPA_SuperObject *pParent, tdstPosition *p_stPosition, tdeTypeSO eTypeSO, tdeSaveStatus eStatus)
{
return FALSE;
}
//ENDANNECY Shaitan EmptySectors
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,129 @@
//=========================================================================
// CPAMCapt.cpp : MouseCapturer implementation. virtual class that all objects capturing
// mouse movement messages must derive from.
//
// Version 1.0
// Creation date 24/01/97
// Revision date
//
// (c) Ubi Studios 1997
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// BENOIT GERMAIN.
//=========================================================================
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "itf\frmbsmn.hpp"
#include "itf\frmgest.hpp"
//================================================================================
//================================================================================
CPA_MouseCapturer::CPA_MouseCapturer()
{
m_p_oPreviousCapturer = m_p_oCurrentCapturer = NULL;
m_bDestruction = FALSE;
}
//================================================================================
//================================================================================
CPA_MouseCapturer::~CPA_MouseCapturer()
{
m_bDestruction = TRUE;
m_p_oSurrenderCapture();
}
//================================================================================
//================================================================================
CWnd *CPA_MouseCapturer::m_p_oGrabCaptureFor(CWnd *pWnd)
{
CWnd *p_oCurrentCapturer;
ASSERT(pWnd);
// check who has the capture
p_oCurrentCapturer = pWnd->GetCapture();
if ( p_oCurrentCapturer != pWnd ) // if it is not the same
{
// in case more than one consecutive grab occur...
if ( !m_p_oPreviousCapturer )
// remember who had the capture before the new capturer
m_p_oPreviousCapturer = p_oCurrentCapturer;
// remember who the new capturer is
m_p_oCurrentCapturer = pWnd;
// if both the current and new capturer are valid
if ( m_p_oCurrentCapturer )
{
// release the capture of the current capturer
if ( p_oCurrentCapturer )
ReleaseCapture();
// and grab it for the new capturer
m_p_oCurrentCapturer->SetCapture();
}
}
else //it is not allowed to grab consecutively for the same CWnd...
{
/*if ( g_oFrameGest.ma_p_oOccupyArray[2][2] )
{
((FRMBaseMenu *) g_oFrameGest.ma_p_oOccupyArray[2][2])->UpdateStatus(
"INTERNAL: It is not allowed to grab consecutively for the same CWnd...",
C_STATUSPANE_INFOS,
C_STATUS_WARNING
);
}*/
}
// return the pointer to the capturer that will be surrendered capture
return m_p_oPreviousCapturer;
}
//================================================================================
//================================================================================
CWnd *CPA_MouseCapturer::m_p_oSurrenderCapture(BOOL bCheckCoherence /*= TRUE*/)
{
CWnd *pToReturn = m_p_oPreviousCapturer;
CWnd *p_oInstantCapturer;
// if there was a capturer before the one we established
if ( m_p_oPreviousCapturer )
{
// check who has the capture right now
p_oInstantCapturer = m_p_oPreviousCapturer->GetCapture();
// if nobody took it from us
if ( p_oInstantCapturer == m_p_oCurrentCapturer )
{
// we can release it
ReleaseCapture();
// and give it back to our predecessor
m_p_oPreviousCapturer->SetCapture();
// and remember it
m_p_oCurrentCapturer = NULL;
m_p_oPreviousCapturer = NULL;
}
}
else if ( m_p_oCurrentCapturer ) // we were first to capture the mouse
{
// release the capture
ReleaseCapture();
// and remember than now nobody has the capture
m_p_oCurrentCapturer = NULL;
}
else // somebody tried to make us surrender whereas we had not grabbed anything
{
// the only autorized circumstance is when the destructor calls us
// while we had not grabbed anything
/*if ( g_oFrameGest.ma_p_oOccupyArray[2][2] && ((!bCheckCoherence) || (m_bDestruction)) )
{
((FRMBaseMenu *) g_oFrameGest.ma_p_oOccupyArray[2][2])->UpdateStatus(
"INTERNAL: It is not allowed to surrender consecutively for the same CWnd...",
C_STATUSPANE_INFOS,
C_STATUS_WARNING
);
}*/
}
return pToReturn;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,159 @@
/*=========================================================================
*
* CPASectO.hpp - CPA_SectionObject : implementation
*
*
* Version 1.0
* Creation date 20.06.97
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAMdfO.hpp"
#include "itf/CPAEditB.hpp"
/*-----------------------------------------------------------------------------
* MACRO
*---------------------------------------------------------------------------*/
#define lMAKE_MODIF( bExists, bInitialState ) ( (long) ((bExists ? 0x0000ffff : 0) + (bInitialState ? 0xffff0000 : 0)) )
#define M_bExists( lModif ) ( (BOOL ) ( lModif & 0x0000ffff ) )
#define M_bOnInitialState( lModif ) ( (BOOL ) ( lModif & 0xffff0000 ) )
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
CPA_ModifiableObject::CPA_ModifiableObject(CPA_EditorBase *pEditor, const CString csType, tdeSaveStatus eStatus,
CPA_BaseObject *pOwner, BOOL bAvailable,
char *p_szDataPath, SCR_tdpfn_Ntfy_Callback pCallBack)
:CPA_SaveObject(pEditor, csType, eStatus, pOwner, bAvailable, p_szDataPath, pCallBack)
{
m_p_oListOfModifNames = pEditor -> fn_p_oGetModifNamesList(csType);
//
m_oListOfModifications . RemoveAll();
if( m_p_oListOfModifNames != NULL )
{
for( int i=0 ; i < m_p_oListOfModifNames -> GetCount() ; i++ )
m_oListOfModifications . AddTail( lMAKE_MODIF( FALSE, TRUE ) );
}
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
CPA_ModifiableObject::CPA_ModifiableObject(CPA_ModifiableObject &r_oSource)
:CPA_SaveObject(r_oSource)
{
m_p_oListOfModifNames = r_oSource . m_p_oListOfModifNames;
m_oListOfModifications . RemoveAll();
if( m_p_oListOfModifNames != NULL )
{
for( int i=0 ; i < m_p_oListOfModifNames -> GetCount() ; i++ )
m_oListOfModifications . AddTail( lMAKE_MODIF( FALSE, TRUE ) );
}
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
CPA_ModifiableObject::~CPA_ModifiableObject()
{
m_oListOfModifications . RemoveAll();
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
void CPA_ModifiableObject::fn_vSetCurrentState(const CString _ocsModificationType, BOOL _bInitialState)
{
POSITION stPos = fn_stGetModificationPos( _ocsModificationType );
if( stPos )
{
long lModif = m_oListOfModifications . GetAt( stPos );
BOOL bHasModif = M_bExists( lModif );
fn_vSetOnState( _ocsModificationType, _bInitialState );
lModif = lMAKE_MODIF( bHasModif, _bInitialState );
m_oListOfModifications . SetAt( stPos, lModif );
}
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
void CPA_ModifiableObject::fn_vSetModification(const CString _ocsModificationType, BOOL _bModified /*=TRUE*/, BOOL _bInitialState /*=TRUE*/)
{
fn_vSetOnState( _ocsModificationType, _bInitialState );
fn_vUpdateModification(_ocsModificationType, _bModified, _bInitialState);
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
void CPA_ModifiableObject::fn_vUpdateModification (const CString _ocsModificationType, BOOL _bModified, BOOL bInitialState)
{
POSITION stPos = fn_stGetModificationPos( _ocsModificationType );
if( stPos )
m_oListOfModifications . SetAt( stPos, lMAKE_MODIF( _bModified, bInitialState ) );
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
BOOL CPA_ModifiableObject::fn_bIsOnInitialState(const CString _ocsModificationType)
{
POSITION stPos = fn_stGetModificationPos( _ocsModificationType );
if( stPos )
return M_bOnInitialState( m_oListOfModifications . GetAt( stPos ) );
return TRUE;
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
BOOL CPA_ModifiableObject::fn_bIsModified(const CString _ocsModificationType)
{
POSITION stPos = fn_stGetModificationPos( _ocsModificationType );
if( stPos )
return M_bExists( m_oListOfModifications . GetAt( stPos ) );
return FALSE;
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
void CPA_ModifiableObject::fn_vValidateState(const CString _ocsModificationType, BOOL bInitialState)
{
fn_vSetModification( _ocsModificationType, FALSE, bInitialState);
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
POSITION CPA_ModifiableObject::fn_stGetModificationPos( const CString _ocsModificationType )
{
if( m_p_oListOfModifNames != NULL )
{
POSITION xPosName = m_p_oListOfModifNames -> GetHeadPosition();
POSITION xPosModif = m_oListOfModifications . GetHeadPosition();
while( xPosName )
{
ASSERT( xPosModif );
CString csName = m_p_oListOfModifNames -> GetNext( xPosName );
if( csName == _ocsModificationType )
return xPosModif;
m_oListOfModifications . GetNext( xPosModif );
}
}
return NULL;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,440 @@
/*=========================================================================
*
* CPASectO.hpp - CPA_SectionObject : implementation
*
*
* Version 1.0
* Creation date 20.06.97
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "itf/CPASaveO.hpp"
#include "acp_base.h"
#include "itf/CoheMngr.hpp"
#include "itf/NameMngr.hpp"
#include "itf/CPAInter.hpp"
//#################################################################################
// INIT
//#################################################################################
/*===========================================================================
Constructor
=========================================================================*/
CPA_SaveObject::CPA_SaveObject (CPA_EditorBase *pEditor, const CString csType,
tdeSaveStatus eStatus, CPA_BaseObject *pOwner, BOOL bAvailable,
char *p_szDataPath, SCR_tdpfn_Ntfy_Callback pCallBack)
: CPA_BaseObject (pEditor, csType, pOwner, bAvailable),
CPA_SectionObject ("", p_szDataPath, pCallBack)
{
// init save status
m_eSaveStatus = eStatus;
}
/*===========================================================================
Copy-Constructor
=========================================================================*/
CPA_SaveObject::CPA_SaveObject (CPA_SaveObject &r_oSource)
: CPA_BaseObject (r_oSource),
CPA_SectionObject (r_oSource)
{
// init save status
m_eSaveStatus = r_oSource.m_eSaveStatus;
}
/*===========================================================================
Destructor
=========================================================================*/
CPA_SaveObject::~CPA_SaveObject (void)
{
}
//#################################################################################
// PRIVATE FUNCTIONS
//#################################################################################
/*===========================================================================
* Description: rename object
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::fn_vDoRename (const CString csNewName)
{
BOOL bFirstRegister;
bFirstRegister = GetName().IsEmpty();
// base rename
CPA_BaseObject::fn_vDoRename(csNewName);
if (!bFirstRegister)
{
// notify save with new name
if (fn_bCanBeNotified())
fn_vNotifyRename();
// update all references
fn_vUpdateAllReferences();
}
}
//#################################################################################
// NAME
//#################################################################################
/*===========================================================================
* Description: get a default name according to validity criteria
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CString CPA_SaveObject::GetDefaultValidName (const CString csDefaultBaseName /*= ""*/)
{
CString csNewName;
CPA_Interface *pInterface;
pInterface = GetEditor()->GetInterface();
do {
csNewName = pInterface->GetPrefixedName( GetBaseObjectList() -> GetNewName( csDefaultBaseName ) );
} while( fn_eCheckValidity(csNewName) != E_mc_None );
return csNewName;
}
/*===========================================================================
* Description: rename object with default name, according to validity criteria
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::SetDefaultValidName (const CString csDefaultBaseName /*= ""*/)
{
CString csNewName;
csNewName = GetDefaultValidName( csDefaultBaseName );
fn_vDoRename(csNewName);
}
/*===========================================================================
* Description: rename object, checking validity criteria
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
tdeMissingCriteria CPA_SaveObject::fn_eRename (const CString csNewName)
{
tdeMissingCriteria eResult;
CPA_Interface *pInterface;
CString csName;
pInterface = GetEditor()->GetInterface();
// not loading => check prefix
if ((!pInterface->fn_bIsLoadingWorld())&&(!csNewName.IsEmpty()))
csName = pInterface->GetPrefixedName(csNewName);
else
csName = csNewName;
// check unicity
eResult = fn_eCheckValidity(csName);
// rename object
if (eResult == E_mc_None)
fn_vDoRename(csName);
// loading => register conflict
else if ((eResult != E_mc_NoName)&&(pInterface->fn_bIsLoadingWorld()))
{
pInterface->fn_vAddRenamedObject();
g_oNameManager.fn_vRegisterConflict(this, csName, eResult);
}
return eResult;
}
//#################################################################################
// VALIDITY
//#################################################################################
/*===========================================================================
* Description: check name for forbidden characters (scritps criteria)
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_SaveObject::fn_bCheckScriptCharacters (const CString csName)
{
int iNbFound = 0;
iNbFound += csName.Find(' ') + 1;
iNbFound += csName.Find('(') + 1;
iNbFound += csName.Find(')') + 1;
iNbFound += csName.Find('[') + 1;
iNbFound += csName.Find(']') + 1;
iNbFound += csName.Find('{') + 1;
iNbFound += csName.Find('}') + 1;
iNbFound += csName.Find('*') + 1;
iNbFound += csName.Find('#') + 1;
iNbFound += csName.Find('$') + 1;
iNbFound += csName.Find(';') + 1;
iNbFound += csName.Find(':') + 1;
iNbFound += csName.Find('^') + 1;
iNbFound += csName.Find('@') + 1;
return (iNbFound == 0);
}
/*===========================================================================
* Description: check if section was notified with Delete
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_SaveObject::fn_bCheckNotification (const CString csNewName)
{
SCR_tdst_Ntfy_Description *pNotification;
// if new name is original one, verification is not necessary
if (fn_csComputeReferencedSectionName(csNewName) == GetInitialSectionName())
return TRUE;
// if this section is registered as deleted, name is not valid
pNotification = SCR_fnp_st_SvL1_GetRegisterNotify((char *)(LPCSTR)fn_csComputeCompleteSectionName(csNewName));
if ((pNotification)&&(pNotification->eAction == SCR_EA_Ntfy_DeleteSection))
return FALSE;
// no objection
return TRUE;
}
/*===========================================================================
* Description: check name for forbidden characters (scritps criteria)
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
tdeMissingCriteria CPA_SaveObject::fn_eCheckValidity (const CString csNewName)
{
tdeMissingCriteria eResult;
// empty name is never valid
if (csNewName.IsEmpty())
return E_mc_NoName;
// check unicity
eResult = fn_eCheckUnicity(csNewName);
if (eResult != E_mc_None)
return eResult;
// check notification
if (fn_bCanBeNotified())
{
if (!fn_bCheckScriptCharacters(csNewName))
return E_mc_ScriptCharacters;
if (!fn_bCheckNotification(csNewName))
return E_mc_Notification;
}
// name is valid
return eResult;
}
//#################################################################################
// REFERENCES
//#################################################################################
/*===========================================================================
* Description: update all objects referencing current one
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::fn_vUpdateAllReferences (void)
{
CPA_List<CPA_BaseObject> stListOfReferences;
CPA_BaseObject *pReference;
POSITION pos;
int iNbReferences;
// RAZ
stListOfReferences.RemoveAll();
// get all references
iNbReferences = g_oCoherenceManager.m_fn_iGetFatherList(this, &stListOfReferences);
// notify all references
for (pReference = stListOfReferences.GetHeadElement(pos); pReference;
pReference = stListOfReferences.GetNextElement(pos))
{
if (pReference->fn_bCanBeSaved())
((CPA_SaveObject *) pReference)->fn_vUpdateReference(this);
}
}
/*===========================================================================
* Description: called when an object referenced by the current one has changed
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::fn_vUpdateReference (CPA_SaveObject *pReferencedObject)
{
// default handling => notify save
fn_vNotifySave();
}
//#################################################################################
// NOTIFICATIONS
//#################################################################################
/*===========================================================================
* Description: check if obejct must be notifies (save status)
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_SaveObject::fn_bCanBeNotified (void)
{
// default handling => test responsibility level and validity
return ((m_eSaveStatus != E_ss_NoSave)&&(m_eSaveStatus != E_ss_NoModif));
}
/*===========================================================================
* Description: called when object must be saved (Add or Rebuild)
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::fn_vNotifySave (void)
{
// default handling => set add or rebuild notify on SectionObject
fn_vWriteSection();
}
/*===========================================================================
* Description: called when object must be removed (Delete)
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::fn_vNotifyUnSave (void)
{
// default handling => set delete notify on SectionObject
fn_vDeleteSection();
}
/*===========================================================================
* Description: called when object must be restored (cancel Delete and restore previous notify)
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::fn_vNotifyRestore (void)
{
// default handling => restore notify on SectionObject
fn_vRestoreSection();
}
/*===========================================================================
* Description: called when object is renamed
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::fn_vNotifyRename (void)
{
// default handling => rename section of SectionObject
fn_vRenameSection(fn_csComputeReferencedSectionName(GetName()));
}
//#################################################################################
// SECTION NAME
//#################################################################################
/*===========================================================================
* Description: called when section name must be changed without notification
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SaveObject::fn_vUpdateSectionName (void)
{
SetReferencedSectionName(fn_csComputeReferencedSectionName(GetName()));
}
/*===========================================================================
* Description: get referenced (minimum) section name corresponding to new name
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CString CPA_SaveObject::fn_csComputeReferencedSectionName (const CString csNewName)
{
CString csSectionName;
char szNewSectionName[SCR_CV_ui_Cfg_MaxLenName];
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
char szActionName[SCR_CV_ui_Cfg_MaxLenName];
char szName[SCR_CV_ui_Cfg_MaxLenName];
// default handling => new section is build from old one
csSectionName = GetReferencedSectionName();
if (!csSectionName.IsEmpty())
{
SCR_fn_v_RdL0_SplitSectionName((char *)(LPCSTR)csSectionName, szFileName, szActionName, szName);
SCR_fn_v_RdL0_ComputeSectionName(szNewSectionName, szFileName, szActionName, (char*)(LPCSTR)csNewName);
csSectionName = szNewSectionName;
}
return csSectionName;
}
/*===========================================================================
* Description: get complete section name corresponding to new name
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CString CPA_SaveObject::fn_csComputeCompleteSectionName (const CString csNewName)
{
CString csCompleteName;
csCompleteName = GetDataPath();
csCompleteName += "\\" + fn_csComputeReferencedSectionName(csNewName);
return csCompleteName;
}
#endif //ACTIVE_EDITOR

View File

@@ -0,0 +1,249 @@
/*=========================================================================
*
* CPASectO.hpp - CPA_SectionObject : implementation
*
*
* Version 1.0
* Creation date 20.06.97
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "itf/CPASectO.hpp"
//#################################################################################
// INIT
//#################################################################################
/*===========================================================================
Constructor
=========================================================================*/
CPA_SectionObject::CPA_SectionObject (const CString csReferencedSectionName, char *p_szDataPath,
SCR_tdpfn_Ntfy_Callback pCallBack,
void *pSectionData, BOOL bExistingSection)
{
// init parameters
m_csReferencedSectionName = csReferencedSectionName;
m_csInitialReferencedSectionName.Empty();
m_p_szDataPath = p_szDataPath;
// parameters for save
m_p_fnCallBackSave = pCallBack;
m_bExistingSection = bExistingSection;
m_pSectionData = pSectionData;
// init notifications
m_eLastNotify = m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
}
/*===========================================================================
Copy-Constructor
=========================================================================*/
CPA_SectionObject::CPA_SectionObject (CPA_SectionObject &r_oSource)
{
// init parameters
m_csReferencedSectionName = r_oSource.GetReferencedSectionName();
m_csInitialReferencedSectionName.Empty();
m_p_szDataPath = r_oSource.m_p_szDataPath;
// parameters for save
m_p_fnCallBackSave = r_oSource.m_p_fnCallBackSave;
m_pSectionData = r_oSource.m_pSectionData;
m_bExistingSection = FALSE;
// init notifications
m_eLastNotify = m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
}
/*===========================================================================
Destructor
=========================================================================*/
CPA_SectionObject::~CPA_SectionObject (void)
{
}
//#################################################################################
// REFERENCES
//#################################################################################
/*===========================================================================
* Description: return referenced (minimum) name of the section
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CString CPA_SectionObject::GetReferencedSectionName (void)
{
return m_csReferencedSectionName;
}
/*===========================================================================
* Description: return complete name of the section
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CString CPA_SectionObject::GetCompleteSectionName (void)
{
CString csCompleteName;
// complete name : data path + short name
csCompleteName = m_p_szDataPath;
csCompleteName += "\\" + m_csReferencedSectionName;
return csCompleteName;
}
//#################################################################################
// NOTIFICATIONS
//#################################################################################
/*===========================================================================
* Description: notify section for Add or Rebuild, according to flag
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SectionObject::fn_vWriteSection(void)
{
fn_vNotifySection( m_bExistingSection ? SCR_EA_Ntfy_RebuildSection : SCR_EA_Ntfy_AddSection );
}
/*===========================================================================
* Description: notify section for Delete, and save current notification
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SectionObject::fn_vDeleteSection (void)
{
if( m_bExistingSection || (m_eCurrentNotify != SCR_EA_Ntfy_Dummy) )
{
// save current notification
m_eLastNotify = m_eCurrentNotify;
// add delete notification
fn_vNotifySection( SCR_EA_Ntfy_DeleteSection ) ;
}
}
/*===========================================================================
* Description: cancel Delete notification and restore previous one
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SectionObject::fn_vRestoreSection (void)
{
// remove current script notification
if ( m_eCurrentNotify == SCR_EA_Ntfy_DeleteSection )
SCR_fn_v_SvL1_DeleteRegisterNotify((char*) (LPCTSTR)GetCompleteSectionName(), SCR_CDR_c_RdL0_Match);
// restore previous notification
if( m_eLastNotify != SCR_EA_Ntfy_Dummy )
{
fn_vNotifySection( m_eLastNotify );
m_eLastNotify = SCR_EA_Ntfy_Dummy;
}
else
m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
}
/*===========================================================================
* Description: rename section => Delete previous and Add new one
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SectionObject::fn_vRenameSection (const CString csNewReferencedSectionName)
{
// delete previous section
fn_vDeleteSection();
// back to initial name ?
if (csNewReferencedSectionName == m_csInitialReferencedSectionName)
{
// initial name => section exists !
m_bExistingSection = TRUE;
// rename section
m_csReferencedSectionName = csNewReferencedSectionName;
// notify for Rebuild
m_eLastNotify = SCR_EA_Ntfy_RebuildSection;
fn_vRestoreSection();
}
// new name
else
{
// first rename of existing section
if (m_bExistingSection)
{
// save initial name
m_csInitialReferencedSectionName = m_csReferencedSectionName;
// update flag
m_bExistingSection = FALSE;
}
// rename and save new section
m_csReferencedSectionName = csNewReferencedSectionName;
fn_vWriteSection();
}
}
/*===========================================================================
* Description: notify section without any test
* Creation date: 20.06.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SectionObject::fn_vNotifySection(SCR_tde_Ntfy_Action eAction)
{
if (m_eCurrentNotify != eAction)
{
// update current notification
m_eCurrentNotify = eAction;
// register notification
SCR_fn_v_SvL1_RegisterNotify((char*) (LPCTSTR) GetCompleteSectionName(),
m_p_fnCallBackSave, m_pSectionData, eAction);
}
}
/*===========================================================================
* Description: reinit parameters when section was written or deleted
* Creation date: 03.07.97
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_SectionObject::fn_vSectionSaved (void)
{
// section exists
SetExistingSection(TRUE);
// no more notifications
m_eLastNotify = m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
}
//===========================================================================
void CPA_SectionObject::fn_vSectionDeleted (void)
{
// section doesn't exist
SetExistingSection(FALSE);
// no more notifications
m_eLastNotify = m_eCurrentNotify = SCR_EA_Ntfy_Dummy;
}
#endif ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,152 @@
/*=========================================================================
*
* CPAdPerm.cpp : Selection - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdPerm.hpp"
#include "itf/CPAInter.hpp"
#include "itf/FrmGest.Hpp"
//#################################################################################
// CPA_DialogPermission dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_DialogPermission::CPA_DialogPermission(CWnd* pParent /*=NULL*/)
: CDialog(CPA_DialogPermission::IDD, &g_oBaseFrame)
{
//{{AFX_DATA_INIT(CPA_DialogPermission)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPermission::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogPermission)
DDX_Control(pDX, CPA_IDC_OBJECTNAME, m_cObjectName);
DDX_Control(pDX, CPA_IDC_DESIGNERNAME, m_cDesignerName);
DDX_Control(pDX, CPA_IDC_MODIFY, m_cModify);
DDX_Control(pDX, CPA_IDC_CANCEL, m_cCancel);
DDX_Control(pDX, CPA_IDC_ALWAYS, m_cAlways);
//}}AFX_DATA_MAP
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogPermission, CDialog)
//{{AFX_MSG_MAP(CPA_DialogPermission)
ON_BN_CLICKED(CPA_IDC_MODIFY, OnModify)
ON_BN_CLICKED(CPA_IDC_CANCEL, OnCancel)
ON_BN_CLICKED(CPA_IDC_ALWAYS, OnAlways)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// CPA_DialogPermission message handlers
//#################################################################################
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogPermission::fn_bDoDialog (CPA_Interface *pInterface, CPA_BaseObject *pObject, long lUserIndex)
{
// init parameters
m_pInterface = pInterface;
m_lUserIndex = lUserIndex;
m_pObject = pObject;
// init state
m_bAlways = FALSE;
m_bCanModify = FALSE;
// this dialog is modal
DoModal();
// return permission
return m_bCanModify;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPermission::fn_vCloseDialog (void)
{
// release capture
SetCapture();
m_p_oSurrenderCapture();
}
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogPermission::OnInitDialog ()
{
// Create the dialog
CDialog::OnInitDialog();
// set focus to the dialog
m_p_oGrabCapture();
// free capture (for controls)
ReleaseCapture();
// init object name
m_cObjectName.SetWindowText(m_pObject->GetName());
// init designer name
m_cDesignerName.SetWindowText(m_pInterface->GetUserName(m_lUserIndex));
// init control state
m_cAlways.SetCheck(m_bAlways);
return TRUE;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPermission::OnModify()
{
// set permission
m_bCanModify = TRUE;
// if necessary, add permission
if (m_bAlways)
m_pInterface->fn_vAddAuthorization(m_pInterface->GetUserPrefix(m_lUserIndex));
// close the dialog
fn_vCloseDialog();
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPermission::OnCancel()
{
// set permission
m_bCanModify = FALSE;
// if necessary, add interdiction
if (m_bAlways)
m_pInterface->fn_vAddProhibition(m_pInterface->GetUserPrefix(m_lUserIndex));
// close the dialog
fn_vCloseDialog();
CDialog::OnCancel();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPermission::OnAlways()
{
// set permission
m_bAlways = m_cAlways.GetCheck();
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,165 @@
/*=========================================================================
*
* EDTdUser.cpp : User - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdStat.hpp"
#include "itf/CPAInter.hpp"
#include "itf/CPASpec.hpp"
#include "itf/FrmGest.hpp"
//#################################################################################
// CPA_DialogStatus dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_DialogStatus::CPA_DialogStatus (CWnd* pParent)
: CDialog (CPA_DialogStatus::IDD, &g_oBaseFrame)
{
//{{AFX_DATA_INIT(CPA_DialogStatus)
//}}AFX_DATA_INIT
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogStatus::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogStatus)
DDX_Control(pDX, CPA_IDC_GRAPHIST, m_cGraphic);
DDX_Control(pDX, CPA_IDC_DESIGNER, m_cDesign);
DDX_Control(pDX, CPA_IDC_MANAGER, m_cManager);
DDX_Control(pDX, CPA_IDC_SAVESTATUS, m_cSaveStatus);
DDX_Control(pDX, IDOK, m_cOK);
//}}AFX_DATA_MAP
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogStatus, CDialog)
//{{AFX_MSG_MAP(CPA_DialogStatus)
ON_BN_CLICKED(CPA_IDC_SAVESTATUS, OnSave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// CPA_DialogStatus Inits
//#################################################################################
/*===========================================================================
* Description: Init dialog
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_DialogStatus::fn_vDoDialog (CPA_SpecificInterface *pEditor, BOOL bCanUpdate)
{
// create the dialog
m_pEditor = pEditor;
m_bCanUpdate = bCanUpdate;
DoModal();
}
//#################################################################################
// CPA_DialogStatus message handlers
//#################################################################################
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogStatus::OnInitDialog (void)
{
tdeUserStatus eInitStatus;
// Create the dialog
CDialog::OnInitDialog();
eInitStatus = m_pEditor->GetUserStatus();
if (eInitStatus == E_us_NoStatus)
eInitStatus = E_us_StatusDesign;
// init mode
m_cGraphic.SetCheck(eInitStatus == E_us_StatusGraphic);
m_cDesign.SetCheck(eInitStatus == E_us_StatusDesign);
m_cManager.SetCheck(eInitStatus == E_us_StatusAll);
// init controls
m_cOK.SetWindowText(m_bCanUpdate ? "OK" : "Cancel");
return TRUE;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogStatus::OnSave (void)
{
// save user mode
if (m_cGraphic.GetCheck())
m_pEditor->fn_vSaveUserStatus(E_us_StatusGraphic);
else if (m_cDesign.GetCheck())
m_pEditor->fn_vSaveUserStatus(E_us_StatusDesign);
else
m_pEditor->fn_vSaveUserStatus(E_us_StatusAll);
// close dialog
if (!m_bCanUpdate)
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogStatus::OnOK (void)
{
if (m_bCanUpdate)
{
// get user mode
if (m_cGraphic.GetCheck())
m_pEditor->SetUserStatus(E_us_StatusGraphic);
else if (m_cDesign.GetCheck())
m_pEditor->SetUserStatus(E_us_StatusDesign);
else
m_pEditor->SetUserStatus(E_us_StatusAll);
}
// close dialog
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogStatus::OnCancel (void)
{
if (m_bCanUpdate)
{
// get user mode
if (m_cGraphic.GetCheck())
m_pEditor->SetUserStatus(E_us_StatusGraphic);
else if (m_cDesign.GetCheck())
m_pEditor->SetUserStatus(E_us_StatusDesign);
else
m_pEditor->SetUserStatus(E_us_StatusAll);
}
// close dialog
CDialog::OnCancel();
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,569 @@
/*=========================================================================
*
* CPAdList.cpp : Lists - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdTree.hpp"
#include "itf/CPAdList.hpp"
#include "ITF/CPABaseO.hpp"
#include "ITF/CPAEditB.hpp"
#include "itf/CPAProj.hpp"
#include "IncTUT.h"
#define C_uiCustomEntriesStart 10
//#################################################################################
// CPA_TreeItem
//#################################################################################
/*----------------------------------------
Constructor
----------------------------------------*/
CPA_TreeItem::CPA_TreeItem (CPA_BaseObject *pObject)
{
// init parameters
m_pObject = pObject;
m_pInfo = NULL;
m_iIcon = 0;
m_iState = 0;
}
/*----------------------------------------
Destructor
----------------------------------------*/
CPA_TreeItem::~CPA_TreeItem (void)
{
}
//#################################################################################
// Hierarchy Tree Control
//#################################################################################
BEGIN_MESSAGE_MAP(CPA_HierarchyTree, CTreeCtrl)
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONDBLCLK()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_KEYDOWN()
ON_WM_KEYUP()
END_MESSAGE_MAP()
/*----------------------------------------
Constructor
----------------------------------------*/
CPA_HierarchyTree::CPA_HierarchyTree (void)
{
m_pParentDialog = NULL;
m_hDraggedItem = NULL;
m_hTarget = NULL;
m_pRoot = NULL;
// init default icons
m_stDefaultImageList.Create(16, 16, FALSE, 0, 1);
m_stDefaultImageList.Add(M_GetMainApp()->LoadIcon(CPA_IDI_EDIT_DEFAULT));
}
CPA_HierarchyTree::~CPA_HierarchyTree (void)
{
}
/*----------------------------------------
Set functions
----------------------------------------*/
void CPA_HierarchyTree::SetTreeRoot (CPA_BaseObject *pRoot)
{
m_pRoot = pRoot;
fn_vFillHierarchyTree(pRoot, TVI_ROOT);
}
/*----------------------------------------
Set icons
----------------------------------------*/
void CPA_HierarchyTree::SetIconList (CImageList *pIconList, BOOL bUpdate)
{
// user icon list
if (pIconList)
{
SetImageList(pIconList, TVSIL_NORMAL);
m_pIconList = pIconList;
}
// else default one
else
{
SetImageList(&m_stDefaultImageList, TVSIL_NORMAL);
m_pIconList = &m_stDefaultImageList;
}
if (bUpdate)
fn_vFillHierarchyTree(m_pRoot, TVI_ROOT);
}
/*----------------------------------------
Set icons
----------------------------------------*/
void CPA_HierarchyTree::SetStateList (CImageList *pStateList, BOOL bUpdate)
{
// user icon list
if (pStateList)
SetImageList(pStateList, TVSIL_STATE);
m_pStateList = pStateList;
if (bUpdate)
fn_vFillHierarchyTree(m_pRoot, TVI_ROOT);
}
/*----------------------------------------
Init Hierarchy
----------------------------------------*/
void CPA_HierarchyTree::fn_vDeleteHierarchyTree (HTREEITEM hTreeParent)
{
CPA_TreeItem *pTreeItem;
HTREEITEM hChild;
if (!m_pRoot)
return;
if (hTreeParent)
{
// delete item data
pTreeItem = (CPA_TreeItem *) GetItemData(hTreeParent);
if (pTreeItem)
delete pTreeItem;
}
// test all childs
hChild = (hTreeParent) ? GetChildItem(hTreeParent) : GetRootItem();
while (hChild)
{
fn_vDeleteHierarchyTree(hChild);
hChild = GetNextSiblingItem(hChild);
}
// end => delete items
if (hTreeParent == NULL)
DeleteAllItems();
}
/*----------------------------------------
Init Hierarchy
----------------------------------------*/
void CPA_HierarchyTree::fn_vFillHierarchyTree (CPA_BaseObject *pEdParent, HTREEITEM hTreeParent)
{
CPA_BaseObject *pEdChild;
CPA_TreeItem *pTreeItem;
HTREEITEM hTreeChild;
void *pInfo;
int iNumIcon, iNumState;
if (!pEdParent)
return;
// first child
pEdChild = GetCorrespondingChild(pEdParent, NULL);
while (pEdChild)
{
// create tree item
pTreeItem = new CPA_TreeItem(pEdChild);
// get icon
iNumIcon = GetCorrespondingIcon(pEdChild);
pTreeItem->SetIcon(iNumIcon);
// set info
pInfo = GetCorrespondingInfo(pEdChild, pEdParent);
pTreeItem->SetInfo(pInfo);
// get state
if (m_pStateList)
{
// get icon
iNumState = GetCorrespondingState(pEdChild);
pTreeItem->SetState(iNumState);
}
// create item
hTreeChild = InsertItem(pEdChild->GetNameToDraw(), iNumIcon, iNumIcon, hTreeParent, TVI_LAST);
// set data
SetItemData(hTreeChild, (DWORD) pTreeItem);
// if necessary, set state icon
if (m_pStateList)
SetItem(hTreeChild, TVIF_STATE, pEdChild->GetNameToDraw(), iNumState, iNumState,
TVIS_STATEIMAGEMASK, INDEXTOSTATEIMAGEMASK(iNumState), (DWORD)pTreeItem);
// next level
fn_vFillHierarchyTree(pEdChild, hTreeChild);
// next child
pEdChild = GetCorrespondingChild(pEdParent, pEdChild);
}
}
/*----------------------------------------
Drag&Drop End
----------------------------------------*/
void CPA_HierarchyTree::OnLButtonUp (UINT nFlags, CPoint point)
{
if ((!m_hDraggedItem)||(!m_hTarget))
{
CTreeCtrl::OnLButtonUp (nFlags, point);
return;
}
// if target is valid, complete drag&drop
m_pParentDialog->fn_vOnDragDropEndHierarchy();
SetItemState(m_hTarget, 0, TVIS_DROPHILITED);
m_hDraggedItem = NULL;
m_hTarget = NULL;
}
/*----------------------------------------
Drag&Drop
----------------------------------------*/
void CPA_HierarchyTree::OnMouseMove (UINT nFlags, CPoint point)
{
HTREEITEM hTarget;
UINT pFlag;
if (!m_hDraggedItem)
{
CTreeCtrl::OnMouseMove (nFlags, point);
return;
}
hTarget = HitTest(point, &pFlag);
if (hTarget != m_hTarget)
{
if (m_hTarget)
SetItemState(m_hTarget, 0, TVIS_DROPHILITED);
if (m_pParentDialog->fn_bAcceptAsDragDropTarget(hTarget))
m_hTarget = hTarget;
else
m_hTarget = NULL;
if (m_hTarget)
SetItemState(m_hTarget, TVIS_DROPHILITED, TVIS_DROPHILITED);
}
}
/*----------------------------------------
DblClk
----------------------------------------*/
void CPA_HierarchyTree::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if (m_pParentDialog)
m_pParentDialog->fn_vOnDblClkHierarchyTree();
else
CTreeCtrl::OnLButtonDblClk(nFlags, point);
}
/*----------------------------------------
Key Down
----------------------------------------*/
void CPA_HierarchyTree::OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (!m_pParentDialog || !m_pParentDialog->fn_bOnKeyDownInControl(nChar, nRepCnt, nFlags))
CTreeCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
/*----------------------------------------
Key Up
----------------------------------------*/
void CPA_HierarchyTree::OnKeyUp (UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (!m_pParentDialog || !m_pParentDialog->fn_bOnKeyUpInControl(nChar, nRepCnt, nFlags))
CTreeCtrl::OnKeyUp(nChar, nRepCnt, nFlags);
}
/*----------------------------------------
Popup Menu
----------------------------------------*/
void CPA_HierarchyTree::OnRButtonDown(UINT nFlags, CPoint point)
{
BOOL bEntry = FALSE;
ClientToScreen( &point );
// create popup menu
CMenu oMenu;
oMenu.CreatePopupMenu();
// Custom Entries
if (m_pParentDialog)
bEntry = m_pOwnerEditor->fn_bAddEntriesToTreePopup(m_pParentDialog, m_pParentDialog->GetCurrentType(), &oMenu, C_uiCustomEntriesStart);
else
bEntry = m_pOwnerEditor->fn_bAddEntriesToTreePopup(this, m_pRoot, &oMenu, C_uiCustomEntriesStart);
// display & track popup menu
if (bEntry)
{
TUT_M_vGetTutDll ();
TUT_M_vRegisterMenu (this -> m_hWnd , oMenu . m_hMenu , point . x , point . y);
oMenu.TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}
// destroy menus
oMenu.DestroyMenu();
}
/*----------------------------------------
Answer to Popup
----------------------------------------*/
BOOL CPA_HierarchyTree::OnCommand( WPARAM wParam, LPARAM lParam )
{
// command from a menu ?
if (HIWORD(wParam) == 0)
{
// custom entries
if (LOWORD(wParam) >= C_uiCustomEntriesStart)
{
if (m_pParentDialog)
m_pOwnerEditor->fn_vOnCommandInTreePopup(m_pParentDialog, m_pParentDialog->GetCurrentType(), LOWORD(wParam) - C_uiCustomEntriesStart);
else
m_pOwnerEditor->fn_vOnCommandInTreePopup(this, m_pRoot, LOWORD(wParam) - C_uiCustomEntriesStart);
}
}
return CTreeCtrl::OnCommand(wParam, lParam);
}
/*----------------------------------------
Get Item
----------------------------------------*/
HTREEITEM CPA_HierarchyTree::GetCorrespondingItem (CPA_BaseObject *pObject, CPA_BaseObject *pParent, HTREEITEM hElem)
{
HTREEITEM hChild, hParent, hResult;
CPA_TreeItem *pData;
// test hElem name
if (hElem)
{
// get item data
pData = (CPA_TreeItem *) GetItemData(hElem);
// check item data
if ((pData)&&(pData->GetObject() == pObject))
{
// no parent specified => OK
if (!pParent)
return hElem;
// must test parent
else
{
// get parent item
hParent = GetParentItem(hElem);
if (hParent)
{
// test parent data
pData = (CPA_TreeItem *) GetItemData(hParent);
if ((pData)&&(pData->GetObject() == pParent))
return hElem;
}
}
}
}
// test all childs
hChild = (hElem) ? GetChildItem(hElem) : GetRootItem();
while (hChild)
{
hResult = GetCorrespondingItem(pObject, pParent, hChild);
if (hResult)
return hResult;
hChild = GetNextSiblingItem(hChild);
}
return NULL;
}
/*----------------------------------------
Get Icon
----------------------------------------*/
int CPA_HierarchyTree::GetCorrespondingIcon (CPA_BaseObject *pObject)
{
// get icon
if (m_pParentDialog)
return m_pOwnerEditor->GetIconForTreeItem (m_pParentDialog, m_pParentDialog->GetCurrentType(), pObject);
else
return m_pOwnerEditor->GetIconForTreeItem (this, m_pRoot, pObject);
}
/*----------------------------------------
Get State
----------------------------------------*/
int CPA_HierarchyTree::GetCorrespondingState (CPA_BaseObject *pObject)
{
// get state
if (m_pParentDialog)
return m_pOwnerEditor->GetStateForTreeItem (m_pParentDialog, m_pParentDialog->GetCurrentType(), pObject);
else
return m_pOwnerEditor->GetStateForTreeItem (this, m_pRoot, pObject);
}
/*----------------------------------------
Get State
----------------------------------------*/
CPA_BaseObject * CPA_HierarchyTree::GetCorrespondingChild (CPA_BaseObject *pParent, CPA_BaseObject *pBrother)
{
if (m_pParentDialog)
return m_pOwnerEditor->GetTreeNodeNextChild (m_pParentDialog, m_pParentDialog->GetCurrentType(), pParent, pBrother);
else
return m_pOwnerEditor->GetTreeNodeNextChild (this, m_pRoot, pParent, pBrother);
}
/*----------------------------------------
Get Info
----------------------------------------*/
void * CPA_HierarchyTree::GetCorrespondingInfo (CPA_BaseObject *pObject, CPA_BaseObject *pParent)
{
if (m_pParentDialog)
return m_pOwnerEditor->GetInfoForTreeItem (m_pParentDialog, m_pParentDialog->GetCurrentType(), pObject, pParent);
else
return m_pOwnerEditor->GetInfoForTreeItem (this, m_pRoot, pObject, pParent);
}
/*----------------------------------------
Get Item Info
----------------------------------------*/
void * CPA_HierarchyTree::GetItemInfo (CPA_BaseObject *pObject, CPA_BaseObject *pParent)
{
CPA_TreeItem *pItemData;
HTREEITEM hItem;
// get item
hItem = GetCorrespondingItem (pObject, pParent, NULL);
if (!hItem)
return NULL;
//get item data
pItemData = (CPA_TreeItem *) GetItemData(hItem);
if (!pItemData)
return NULL;
// get item info
return pItemData->GetInfo();
}
/*----------------------------------------
Set Item Info
----------------------------------------*/
void CPA_HierarchyTree::SetItemInfo (CPA_BaseObject *pObject, CPA_BaseObject *pParent, void *pInfo)
{
CPA_TreeItem *pItemData;
HTREEITEM hItem;
// get item
hItem = GetCorrespondingItem (pObject, pParent, NULL);
if (!hItem)
return;
//get item data
pItemData = (CPA_TreeItem *) GetItemData(hItem);
if (!pItemData)
return;
// set item info
pItemData->SetInfo(pInfo);
}
/*----------------------------------------
Get Item Icon
----------------------------------------*/
int CPA_HierarchyTree::GetItemIcon (CPA_BaseObject *pObject, CPA_BaseObject *pParent)
{
CPA_TreeItem *pItemData;
HTREEITEM hItem;
// get item
hItem = GetCorrespondingItem (pObject, pParent, NULL);
if (!hItem)
return -1;
//get item data
pItemData = (CPA_TreeItem *) GetItemData(hItem);
if (!pItemData)
return -1;
// get item icon
return pItemData->GetIcon();
}
/*----------------------------------------
Set Item Icon
----------------------------------------*/
void CPA_HierarchyTree::SetItemIcon (CPA_BaseObject *pObject, CPA_BaseObject *pParent, int iIcon)
{
CPA_TreeItem *pItemData;
HTREEITEM hItem;
// get item
hItem = GetCorrespondingItem (pObject, pParent, NULL);
if (!hItem)
return;
//get item data
pItemData = (CPA_TreeItem *) GetItemData(hItem);
if (!pItemData)
return;
// set item icon
pItemData->SetIcon(iIcon);
SetItemImage(hItem, iIcon, iIcon);
}
/*----------------------------------------
Get Item State
----------------------------------------*/
int CPA_HierarchyTree::GetItemStateI (CPA_BaseObject *pObject, CPA_BaseObject *pParent)
{
CPA_TreeItem *pItemData;
HTREEITEM hItem;
// no image list => no icon index
if (!m_pStateList)
return -1;
// get item
hItem = GetCorrespondingItem (pObject, pParent, NULL);
if (!hItem)
return -1;
//get item data
pItemData = (CPA_TreeItem *) GetItemData(hItem);
if (!pItemData)
return -1;
// get item state
return pItemData->GetState();
}
/*----------------------------------------
Set Item State
----------------------------------------*/
void CPA_HierarchyTree::SetItemStateI (CPA_BaseObject *pObject, CPA_BaseObject *pParent, int iState)
{
CPA_TreeItem *pItemData;
HTREEITEM hItem;
// no image list => no icon index
if (!m_pStateList)
return;
// get item
hItem = GetCorrespondingItem (pObject, pParent, NULL);
if (!hItem)
return;
//get item data
pItemData = (CPA_TreeItem *) GetItemData(hItem);
if (!pItemData)
return;
// set item state
pItemData->SetState(iState);
SetItem(hItem, TVIF_STATE, pItemData->GetObject()->GetNameToDraw(), iState, iState,
TVIS_STATEIMAGEMASK, INDEXTOSTATEIMAGEMASK(iState), (DWORD)pItemData);
}
#endif //ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,224 @@
/*=========================================================================
*
* NameMngr.cpp : Name Manager : Implementation file.
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#include "itf/customid.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
//#include "itf/EDTBase.hpp"
#include "itf/CPAInter.hpp"
#include "itf/NameMngr.hpp"
#include "DPT.h"
CPA_NameManager g_oNameManager;
//#################################################################################
// NAME CONFLICT
//#################################################################################
/*===========================================================================
Constructor (initial object)
=========================================================================*/
CPA_NameConflict::CPA_NameConflict (CPA_BaseObject *pInitial, CPA_BaseObject *pRenamed,
const CString csInitialName, tdeMissingCriteria eConflict)
{
// init parameters
m_pInitialObject = pInitial;
m_pRenamedObject = pRenamed;
m_csInitialName = csInitialName;
m_eConflict = eConflict;
}
/*===========================================================================
Destructor
=========================================================================*/
CPA_NameConflict::~CPA_NameConflict (void)
{
}
//#################################################################################
// CONSTRUCTOR
//#################################################################################
/*===========================================================================
Constructor - init the list
=========================================================================*/
CPA_NameManager::CPA_NameManager ( )
{
}
/*===========================================================================
Destructor -
=========================================================================*/
CPA_NameManager::~CPA_NameManager (void)
{
}
//#################################################################################
// CONFLICTS
//#################################################################################
/*===========================================================================
Register a name conflict
=========================================================================*/
void CPA_NameManager::fn_vRegisterConflict (CPA_BaseObject *pObject, const CString csInitialName, tdeMissingCriteria eConflict)
{
CPA_BaseObjectList *pListObject;
CPA_BaseObjectList *pListInvalid;
CPA_BaseObject *pFirstObject;
CPA_BaseObject *pOwner;
CString csTypeName;
// no object => no conflict
if (!pObject)
return;
// init parameters
pListObject = pObject->GetBaseObjectList();
pListInvalid = pObject->GetInvalidObjectList();
csTypeName = pObject->GetType();
pOwner = pObject->GetOwner();
// switch conflict type to find object
switch (eConflict)
{
case E_mc_TypeUnicity:
pFirstObject = pListObject->fn_p_oFindObject(csInitialName, csTypeName, NO_CRITERIA);
if (!pFirstObject)
pFirstObject = pListInvalid->fn_p_oFindObject(csInitialName, csTypeName, NO_CRITERIA);
break;
case E_mc_OwnerUnicity:
pFirstObject = pListObject->fn_p_oFindObject(csInitialName, csTypeName, pOwner);
if (!pFirstObject)
pFirstObject = pListInvalid->fn_p_oFindObject(csInitialName, csTypeName, pOwner);
break;
case E_mc_CustomUnicity:
pFirstObject = NULL;
break;
default:
pFirstObject = NULL;
}
m_oListOfNameConflict.AddTail (new CPA_NameConflict(pFirstObject, pObject, csInitialName, eConflict));
}
/*===========================================================================
Register name conflict file
=========================================================================*/
void CPA_NameManager::fn_vWriteNameConflicts (void)
{
CPA_NameConflict *pElem;
CPA_BaseObject *pObject;
POSITION pos;
CString csInitialName;
CString csTime;
CTime oTime = CTime::GetCurrentTime();
FILE *pFile;
char szFileName[MAX_PATH];
char szText[MAX_PATH];
// Compute modification file name (last and new)
strcpy(szFileName, fn_szGetGameDataPath());
strcat(szFileName, "\\NameMngr.txt");
// Append modification list
pFile = fopen(szFileName, "at");
if (!pFile)
return;
// Date
csTime.Format("%d/%d/%d %d:%d:%d", oTime.GetDay(), oTime.GetMonth(), oTime.GetYear(),
oTime.GetHour(), oTime.GetMinute(), oTime.GetSecond());
sprintf(szText, "\nCONFLICTS : %s\n", csTime);
fputs(szText, pFile);
for (pElem = m_oListOfNameConflict.GetHeadElement(pos); pElem;
pElem = m_oListOfNameConflict.GetNextElement(pos))
{
fputs("\n*********** Conflict *************\n\n", pFile);
csInitialName = pElem->m_csInitialName;
// conflict type
switch (pElem->m_eConflict)
{
case E_mc_TypeUnicity:
sprintf(szText, "CONFLICT ON : (Name + Type) unicity criteria \n");
break;
case E_mc_OwnerUnicity:
sprintf(szText, "CONFLICT ON : (Name + Type + Owner) unicity criteria \n");
break;
case E_mc_CustomUnicity:
sprintf(szText, "CONFLICT ON : custom unicity criteria\n");
break;
}
fputs(szText, pFile);
// renamed object
fputs("RENAMED OBJECT :\n", pFile);
pObject = pElem->m_pRenamedObject;
// type
sprintf(szText, "Type : %s \n", pObject->GetType());
fputs(szText, pFile);
if (pObject->GetOwner())
{
sprintf(szText, "Owner : %s \n", pObject->GetOwner()->GetName());
fputs(szText, pFile);
}
// section
if (pObject->fn_bCanBeSaved())
{
sprintf(szText, "Section : %s \n", ((CPA_SaveObject *) pObject)->fn_csComputeCompleteSectionName(csInitialName));
fputs(szText, pFile);
}
else
{
sprintf(szText, "OldName : %s \n", csInitialName);
fputs(szText, pFile);
}
// initial object
if (pElem->m_pInitialObject)
{
fputs("CONFLICT WITH :\n", pFile);
pObject = pElem->m_pInitialObject;
// type
sprintf(szText, "Type : %s \n", pObject->GetType());
fputs(szText, pFile);
// owner
if (pObject->GetOwner())
{
sprintf(szText, "Owner : %s \n", pObject->GetOwner()->GetName());
fputs(szText, pFile);
}
// section
if (pObject->fn_bCanBeSaved())
{
sprintf(szText, "Section : %s \n", ((CPA_SaveObject *) pObject)->GetCompleteSectionName());
fputs(szText, pFile);
}
else
{
sprintf(szText, "Name : %s \n", csInitialName);
fputs(szText, pFile);
}
}
}
fputs("\n##########################################################\n", pFile);
fclose(pFile);
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,644 @@
/*
=======================================================================================
Name :SaveMngr.cpp
Author :Vincent Lhullier Date :11/07/97
Description :manage save of data before modification
Create a copy of GameData tree with all file that would be modified. That will allow
someone to recuperate previous version if save generate some problem in data.
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include <io.h>
#include "SaveMngr.h"
#include "acp_base.h"
#include "itf/CPAProj.hpp"
#include "DPT.h"
#include "SCR.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
STRUCTURE
=======================================================================================
*/
typedef struct SAVE_tdstFile_
{
char *szName;
char cNew;
} SAVE_tdstFile;
/*
=======================================================================================
GLOBALS
=======================================================================================
*/
/*
* indicate next number of version to use to save files
* Warning : to be valid you must call SAVE_fn_vAnalyseCurrentUsedVersion before using
* this number
*/
static long SAVE_g_lNextVersionNumber;
static BOOL SAVE_g_bContinue;
static BOOL SAVE_g_bGenerateIsActive = 2;
static char SAVE_g_szDirName[ _MAX_PATH ];
static SAVE_tdstFile *SAVE_gs_d_stFile;
static long SAVE_gs_lNumberOfFiles;
static char *SAVE_g_szGameData;
static long SAVE_g_lGameDataLength;
/*
=======================================================================================
=======================================================================================
FUNCTIONS
=======================================================================================
=======================================================================================
*/
/*
=======================================================================================
Directory Functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Don't call this function directly, it is used by SAVE_fn_bDeleteTree
Description : delete recursively a directory
Returns (BOOL ) true if success
----------------------------------------------------------------------------------------
*/
BOOL fn_bDeleteTree( void )
{
WIN32_FIND_DATA stFindData;
HANDLE hFind;
char *p_szEndDirName;
p_szEndDirName = SAVE_g_szDirName + strlen( SAVE_g_szDirName );
strcpy( p_szEndDirName, "\\*.*" );
if( (hFind = FindFirstFile(SAVE_g_szDirName, &stFindData )) == INVALID_HANDLE_VALUE)
return TRUE;
*p_szEndDirName = 0;
do
{
*p_szEndDirName = '\\';
strcpy( p_szEndDirName + 1, stFindData.cFileName );
if ( stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
if ( *stFindData.cFileName != '.')
{
if ( !fn_bDeleteTree() )
return FALSE;
}
}
else
{
if (_access( SAVE_g_szDirName, 2) == -1 )
_chmod( SAVE_g_szDirName, _S_IWRITE );
if ( !DeleteFile( SAVE_g_szDirName ) )
return FALSE;
}
*p_szEndDirName = 0;
} while(FindNextFile( hFind, &stFindData ));
FindClose( hFind );
return RemoveDirectory( SAVE_g_szDirName );
}
/*
----------------------------------------------------------------------------------------
Description : delete completely a directory
szDirName -> name of dir to delete
Returns (BOOL ) true if success
----------------------------------------------------------------------------------------
*/
BOOL SAVE_fn_bDeleteTree( char *szDirName )
{
strcpy( SAVE_g_szDirName, szDirName );
return fn_bDeleteTree();
}
/*
----------------------------------------------------------------------------------------
Description : create a directory
szDirName -> name of directory
Returns (BOOL ) true if sucess
----------------------------------------------------------------------------------------
*/
BOOL SAVE_fn_bCreateDirectory( char *szDirName )
{
if ( (!CreateDirectory( szDirName, NULL )) && (GetLastError() != ERROR_ALREADY_EXISTS) )
{
char *p_szCur;
p_szCur = strchr( szDirName, '\\');
while (p_szCur != NULL)
{
*p_szCur = 0;
if ((!CreateDirectory (szDirName, NULL)) && (GetLastError() != ERROR_ALREADY_EXISTS) )
{
char szMessage[ 512 ];
sprintf( szMessage, "Can't create local path %s", szDirName );
SAVE_fn_vErrorMessage( szMessage );
return FALSE;
}
*p_szCur++ = '\\';
p_szCur = strchr( p_szCur, '\\');
};
if ((!CreateDirectory (szDirName, NULL)) && (GetLastError() != ERROR_ALREADY_EXISTS) )
{
char szMessage[ 512 ];
sprintf( szMessage, "Can't create local path %s", szDirName );
SAVE_fn_vErrorMessage( szMessage );
return FALSE;
}
}
return TRUE;
}
/*
=======================================================================================
Error functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : display an error message
_szMessage -> message to display
----------------------------------------------------------------------------------------
*/
void SAVE_fn_vErrorMessage( char *_szMessage )
{
char szError[1024];
char *p_szError = szError;
p_szError += sprintf( p_szError, "Error saving current version before saving new data\n" );
p_szError += sprintf( p_szError, "You will not be able to get local previous version\n" );
p_szError += sprintf( p_szError, "---------------------------------------------------\n" );
p_szError += sprintf( p_szError, "%s\n\n", _szMessage );
p_szError += sprintf( p_szError, " Save anyway ?" );
SAVE_g_bContinue = AfxMessageBox( szError, MB_ICONSTOP | MB_YESNO );
}
/*
=======================================================================================
Version functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description :
_szSavedDirectoryName -> name of directory from which function extract version number
Returns (long ) version number if it's a valid directory, -1 else
----------------------------------------------------------------------------------------
*/
long SAVE_fn_lGetVersionNumberFromDirExt( char *_szSavedDirectoryName )
{
char *p_szExt;
long lVersionNumber = -1;
p_szExt = strchr( _szSavedDirectoryName, '.' );
if (p_szExt != NULL)
{
if ( strlen( ++p_szExt ) == 3)
{
lVersionNumber = 0;
while (*p_szExt != 0)
{
if ( !isdigit (*p_szExt) )
return -1;
lVersionNumber = lVersionNumber * 10 + (*p_szExt++ - '0');
}
}
}
return lVersionNumber;
}
/*
----------------------------------------------------------------------------------------
Description : return name of directory used to store data for a given version
lVersion -> version number
szVersionDirName -> to put dir name (assumed to be long enough )
----------------------------------------------------------------------------------------
*/
void SAVE_fn_vGetVersionDirName( long _lVersion, char *_szVersionDirName )
{
sprintf( _szVersionDirName, "%s.%03d", fn_szGetGameDataPath(), _lVersion );
}
/*
----------------------------------------------------------------------------------------
Description : delete a version directory
_lVersion -> number of version
Returns (BOOL ) true if success
----------------------------------------------------------------------------------------
*/
BOOL SAVE_fn_bDeleteVersion( long _lVersion )
{
char szVersionName[ _MAX_PATH ];
SAVE_fn_vGetVersionDirName( _lVersion, szVersionName );
if (!SAVE_fn_bDeleteTree( szVersionName ))
{
char szMessage[100];
sprintf( szMessage, "Can't delete old %s version directory", szVersionName );
SAVE_fn_vErrorMessage( szMessage );
return FALSE;
}
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : rename a version
_lOldVersion -> old version number
_lNewVersion -> new version number
Returns (BOOL )
----------------------------------------------------------------------------------------
*/
BOOL SAVE_fn_bRenameVersion( long _lOldVersion, long _lNewVersion )
{
char szOldVersion[ _MAX_PATH ];
char szNewVersion[ _MAX_PATH ];
SAVE_fn_vGetVersionDirName( _lOldVersion, szOldVersion );
SAVE_fn_vGetVersionDirName( _lNewVersion, szNewVersion );
if ( !MoveFile( szOldVersion, szNewVersion) )
{
char szMessage[100];
sprintf( szMessage, "Can't rename old %s version to new version %s ", szOldVersion, szNewVersion );
SAVE_fn_vErrorMessage( szMessage );
return FALSE;
}
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : analyse the current version that are on disk
a_cVersion -> array of 1000 char that will be filled
each case is a flag that indicate if a version number is used or not
return (long) number of used version
----------------------------------------------------------------------------------------
*/
long SAVE_fn_lGetUsedVersion( char *a_cVersion )
{
WIN32_FIND_DATA stFindData;
HANDLE hFind;
char szFilter[ _MAX_PATH ];
long lNumberOfVersions = 0;
long lVersion;
/*
* set all version as unused
*/
memset ( a_cVersion , 0, 1000 );
sprintf( szFilter, "%s.*", fn_szGetGameDataPath() );
if( (hFind = FindFirstFile(szFilter, &stFindData )) == INVALID_HANDLE_VALUE)
return 0;
do
{
if ( stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
lVersion = SAVE_fn_lGetVersionNumberFromDirExt( stFindData.cFileName );
if (lVersion != -1)
{
a_cVersion[ lVersion ] = 1;
lNumberOfVersions++ ;
}
}
} while(FindNextFile( hFind, &stFindData ));
FindClose( hFind );
return lNumberOfVersions;
}
/*
----------------------------------------------------------------------------------------
Description : analyse the current version that are on disk
----------------------------------------------------------------------------------------
*/
BOOL SAVE_fn_bAnalyseCurrentUsedVersion( void )
{
char a_cVersion[1000];
long lNumberOfVersions;
long lVersion;
long lVersionIndex;
long lLastUnusedVersion = -1;
/*
* get used versions
*/
lNumberOfVersions = SAVE_fn_lGetUsedVersion( a_cVersion );
if (lNumberOfVersions == 0)
{
SAVE_g_lNextVersionNumber = 0;
return TRUE;
}
/*
* check for hole in version number
*/
lVersion = 0;
for (lVersionIndex = 0; lVersion < lNumberOfVersions; lVersionIndex ++)
{
if (a_cVersion[ lVersionIndex ])
{
lVersion ++;
}
else
{
lLastUnusedVersion = lVersionIndex;
}
}
if (lLastUnusedVersion == -1)
{
SAVE_g_lNextVersionNumber = lNumberOfVersions;
}
else
{
for (lVersionIndex = 0; lVersionIndex < lLastUnusedVersion; lVersionIndex++)
{
if (a_cVersion[ lVersionIndex ])
{
if (!SAVE_fn_bDeleteVersion( lVersionIndex ))
{
return FALSE;
}
}
}
lVersion = 0;
for (lVersionIndex = lLastUnusedVersion + 1; a_cVersion[ lVersionIndex ]; lVersionIndex ++)
{
if (!SAVE_fn_bRenameVersion( lVersionIndex, lVersion ++ ))
{
return FALSE;
}
}
SAVE_g_lNextVersionNumber = lVersion;
}
return TRUE;
}
/*
=======================================================================================
modified File functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Add Gamedata dir behind name if not already here and check if file
exist
szFile -> name to check
Returns (BOOL ) true if file exist
----------------------------------------------------------------------------------------
*/
BOOL SAVE_fn_bGetGameDataFile( char *szFile )
{
if (strnicmp( szFile, SAVE_g_szGameData, SAVE_g_lGameDataLength ) != 0)
{
memmove( szFile + SAVE_g_lGameDataLength + 1, szFile, strlen( szFile ));
memcpy ( szFile, SAVE_g_szGameData, SAVE_g_lGameDataLength );
*(szFile + SAVE_g_lGameDataLength) = '\\';
}
return ( _access( szFile, 0) == 0);
}
/*
----------------------------------------------------------------------------------------
Description : add file in array of file to save. check if file doesn't still exist
szFile -> name to add
----------------------------------------------------------------------------------------
*/
void SAVE_fn_vAddFile( char *_szFile, char _cNew )
{
long lFile;
/*
* check if file doesn't till exist in list
*/
for (lFile = 0; lFile < SAVE_gs_lNumberOfFiles; lFile++)
{
if (stricmp( _szFile, SAVE_gs_d_stFile[ lFile ].szName ) == 0 )
return;
}
/*
* Add file
*/
SAVE_gs_d_stFile[ SAVE_gs_lNumberOfFiles ].szName = (char *) malloc( strlen( _szFile ) + 1 );
strcpy( SAVE_gs_d_stFile[ SAVE_gs_lNumberOfFiles ].szName, _szFile );
SAVE_gs_d_stFile[ SAVE_gs_lNumberOfFiles ].cNew = _cNew;
SAVE_gs_lNumberOfFiles++;
}
/*
----------------------------------------------------------------------------------------
Description : delete file list
----------------------------------------------------------------------------------------
*/
void SAVE_fn_vFreeFileList( void )
{
long lFile;
if ( SAVE_gs_d_stFile != NULL)
{
for (lFile = 0; lFile < SAVE_gs_lNumberOfFiles; lFile++)
free ( SAVE_gs_d_stFile[ lFile ].szName );
free ( SAVE_gs_d_stFile );
SAVE_gs_d_stFile = NULL;
}
}
/*
----------------------------------------------------------------------------------------
Description : read all notification to buil list of files that would be modified
return (long ) : number of file in list
----------------------------------------------------------------------------------------
*/
long SAVE_fn_lGetNotifiedFileList( void )
{
unsigned int uiPos;
SCR_tdst_Ntfy_Description *p_stNtfy;
char szFile[ _MAX_PATH ];
char *p_szEndFile;
long lNbMaxFiles;
/*
* get number max of files and allocate array to store filenames
*/
lNbMaxFiles = SCR_g_st_Ntfy_Array.uiNumValues;
SAVE_gs_lNumberOfFiles = 0;
SAVE_gs_d_stFile = (SAVE_tdstFile *) malloc( (lNbMaxFiles + 1) * sizeof( SAVE_tdstFile ) );
/*
* add eventually modification file
*/
strcpy( szFile, "modiflst.txt" );
SAVE_fn_vAddFile( szFile, SAVE_fn_bGetGameDataFile( szFile ) ? 0 : 1 );
/*
* parse all notifications
*/
for (uiPos = 0; uiPos < (unsigned short) lNbMaxFiles; uiPos ++)
{
SCR_M_DyAr_GetNextElement(SCR_tdst_Ntfy_Description, uiPos, p_stNtfy, SCR_g_st_Ntfy_Array);
if (p_stNtfy == NULL)
break;
strcpy( szFile, p_stNtfy->a_szSectionName );
p_szEndFile = strchr( szFile, '^' );
if (p_szEndFile != NULL)
*p_szEndFile = 0;
SAVE_fn_vAddFile( szFile, SAVE_fn_bGetGameDataFile( szFile ) ? 0 : 1 );
}
return SAVE_gs_lNumberOfFiles;
}
/*
----------------------------------------------------------------------------------------
Description : create new tree with saved file
----------------------------------------------------------------------------------------
*/
BOOL SAVE_fn_bCreateNewVersion( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lFile;
char szNewFile[ _MAX_PATH ];
char *p_szNewFile;
char *p_szEndPath;
FILE *hpFile;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SAVE_fn_vGetVersionDirName( SAVE_g_lNextVersionNumber, szNewFile );
p_szNewFile = szNewFile + strlen( szNewFile );
*p_szNewFile++ = '\\';
/*
* copy file that exist and are going to be modified
*/
for (lFile = 0; lFile < SAVE_gs_lNumberOfFiles; lFile ++)
{
if ( SAVE_gs_d_stFile[lFile].cNew == 0)
{
strcpy( p_szNewFile, SAVE_gs_d_stFile[ lFile ].szName + SAVE_g_lGameDataLength + 1 );
p_szEndPath = strrchr( szNewFile, '\\' );
*p_szEndPath = 0;
if ( !SAVE_fn_bCreateDirectory( szNewFile ) )
return FALSE;
*p_szEndPath = '\\';
if ( !CopyFile( SAVE_gs_d_stFile[ lFile ].szName, szNewFile, FALSE ) )
{
//char szMessage[ 512 ];
//sprintf( szMessage, "Can't copy %s to %s", SAVE_g_d_szFile[ lFile ], szNewFile );
return FALSE;
}
}
}
/*
* create a file with all file that are going to be created
*/
strcpy( p_szNewFile, "delete.lst" );
if ((hpFile = fopen( szNewFile, "wt" )) == NULL)
return FALSE;
for (lFile = 0; lFile < SAVE_gs_lNumberOfFiles; lFile ++)
{
if ( SAVE_gs_d_stFile[lFile].cNew )
fprintf( hpFile, "%s\n", SAVE_gs_d_stFile[ lFile ].szName + SAVE_g_lGameDataLength + 1 );
}
fclose( hpFile );
return TRUE;
}
/*
=======================================================================================
principal function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : make a copy of file that will be deleted.
----------------------------------------------------------------------------------------
*/
BOOL SAVE_fn_bGenerateACopyOfFilesBeforeModification( void )
{
SAVE_g_bContinue = TRUE;
if (SAVE_g_bGenerateIsActive == 2)
{
CString csFileName;
csFileName = M_GetMainApp()->m_csEditorDataPath + C_szInterfaceIniFile;
SAVE_g_bGenerateIsActive = GetPrivateProfileInt ("SecuritySave", "Active", 1, (char*)(LPCSTR) csFileName);
}
if ( !SAVE_g_bGenerateIsActive )
return TRUE;
if (SCR_g_st_Ntfy_Array.uiNumValues == 0)
return TRUE;
/*
* init
*/
SAVE_g_szGameData = fn_szGetGameDataPath();
SAVE_g_lGameDataLength = strlen( SAVE_g_szGameData );
if (SAVE_fn_bAnalyseCurrentUsedVersion())
{
if (SAVE_fn_lGetNotifiedFileList())
{
SAVE_fn_bCreateNewVersion();
SAVE_fn_vFreeFileList();
}
}
return SAVE_g_bContinue;
}
#endif /*ACTIVE_EDITOR*/

View File

@@ -0,0 +1,65 @@
/*
=======================================================================================
Name :SaveMngr.h
Author :Vincent Lhullier Date :11/07/97
Description :manage save of data before modification
Create a copy of GameData tree with all file that would be modified. That will allow
someone to recuperate previous version if save generate some problem in data.
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
#ifdef ACTIVE_EDITOR
#ifndef __SAVEMNGR_H__
#define __SAVEMNGR_H__
/*
=======================================================================================
Directory Functions
=======================================================================================
*/
BOOL SAVE_fn_bDeleteTree( char *szDirName );
BOOL SAVE_fn_bCreateDirectory( char *szDirName );
/*
=======================================================================================
Error functions
=======================================================================================
*/
void SAVE_fn_vErrorMessage( char *_szMessage );
/*
=======================================================================================
Version functions
=======================================================================================
*/
long SAVE_fn_lGetVersionNumberFromDirExt( char *_szSavedDirectoryName );
void SAVE_fn_vGetVersionDirName( long _lVersion, char *_szVersionDirName );
BOOL SAVE_fn_bDeleteVersion( long _lVersion );
BOOL SAVE_fn_bRenameVersion( long _lOldVersion, long _lNewVersion );
long SAVE_fn_lGetUsedVersion( char *a_cVersion );
BOOL SAVE_fn_bAnalyseCurrentUsedVersion( void );
long SAVE_fn_lGetNotifiedFileList( void );
void SAVE_fn_vCreateNewVersion( void );
/*
=======================================================================================
principal function
=======================================================================================
*/
BOOL SAVE_fn_bGenerateACopyOfFilesBeforeModification( void );
#endif /*__SAVEMNGR_H__*/
#endif /*ACTIVE_EDITOR*/

View File

@@ -0,0 +1,122 @@
//===========================================================================
// A3dKeyboardConfDlg.cpp : implementation of Keyboard Configuration Dialog
//
// Version 1.0
// Creation date 21/10/96
// Author: Philippe Touillaud
//
// Revision date
// Author:
// (TEST SHARE)
// (c) Ubi Pictures 1996
//
//===========================================================================
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "geo.h"
#include "gli.h"
#include "col.h"
#define HieFriend
#include "lst.hpp"
#include "spo.h"
#undef HieFriend
#include "itf/A3dKeybo.hpp"
#include "itf/CPAkacnf.hpp"
#include "itf/A3dkeyal.hpp"
#include "itf/CPAProj.Hpp"
#include "itf/CPARes.h"
/////////////////////////////////////////////////////////////////////////////
// A3d_KeyboardConfDlg dialog
// Constructor
A3d_KeyboardAllConfDlg::A3d_KeyboardAllConfDlg(void) : CDialog(A3d_KeyboardAllConfDlg::IDD, M_GetMainWnd())
{
//{{AFX_DATA_INIT(A3d_KeyboardConfDlg)
//}}AFX_DATA_INIT
}
void A3d_KeyboardAllConfDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(A3d_KeyboardConfDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(A3d_KeyboardAllConfDlg, CDialog)
//{{AFX_MSG_MAP(A3d_KeyboardConfDlg)
ON_COMMAND(IDOK, OnEdit)
ON_LBN_DBLCLK(IDC_LIST1, OnEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// Overrides
BOOL A3d_KeyboardAllConfDlg::OnInitDialog()
{
BOOL bTemoin;
POSITION pos;
CPA_KeyActionConfiguration *p_Current;
pos = M_GetMainApp()->m_lstKeyboard.GetHeadPosition();
while(pos)
{
p_Current = M_GetMainApp()->m_lstKeyboard.GetNext(pos);
if(p_Current)
{
if (p_Current->IsInitFileValid())
((CListBox *) GetDlgItem(IDC_LIST1))->AddString(p_Current->mfn_szGetObjectName());
}
}
bTemoin = CDialog::OnInitDialog();
if(bTemoin)
{
UpdateData(FALSE);
}
return bTemoin;
}
BOOL A3d_KeyboardAllConfDlg::UpdateData(BOOL bSaveToClass)
{
BOOL bReturn;
if (bSaveToClass)
{
bReturn = CDialog::UpdateData(TRUE);
}
else
{
bReturn = CDialog::UpdateData(FALSE);
}
return bReturn;
}
void A3d_KeyboardAllConfDlg::OnEdit(void)
{
int iSel = ((CListBox *) GetDlgItem(IDC_LIST1))->GetCurSel();
POSITION pos;
CPA_KeyActionConfiguration *p_Current;
pos = M_GetMainApp()->m_lstKeyboard.GetHeadPosition();
p_Current = M_GetMainApp()->m_lstKeyboard.GetHead();
while(pos && iSel)
{
M_GetMainApp()->m_lstKeyboard.GetNext(pos);
p_Current = M_GetMainApp()->m_lstKeyboard.GetAt(pos);
if (p_Current->IsInitFileValid())
iSel--;
}
p_Current->mfn_vDialog(this, p_Current->mfn_szGetObjectName());
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,524 @@
//===========================================================================
// A3dKeyboardConfDlg.cpp : implementation of Keyboard Configuration Dialog
//
// Version 1.0
// Creation date 21/10/96
// Author: Philippe Touillaud
//
// Revision date
// Author:
//
// (c) Ubi Pictures 1996
//
//===========================================================================
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "itf/A3dKeybo.hpp"
#include "itf/CPAkacnf.hpp"
#include "itf/CPARes.h"
/////////////////////////////////////////////////////////////////////////////
// A3d_KeyboardConfDlg dialog
// Constructor
A3d_KeyboardConfDlg::A3d_KeyboardConfDlg(CWnd *pParent, CString szName)
: CDialog(A3d_KeyboardConfDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(A3d_KeyboardConfDlg)
m_bCheckCtrl = FALSE;
m_bCheckShift = FALSE;
m_bCheckAlt = FALSE; /* CPA2 Corneliu Babiuc (ALT Key) 14-05-98 */
m_uiCEditValue = 0;
//}}AFX_DATA_INIT
m_p_oKeyStringList = NULL;
m_cCombinatedKey = 0;
m_cCurrentKey = 0;
m_szName = szName;
}
void A3d_KeyboardConfDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(A3d_KeyboardConfDlg)
DDX_Control(pDX, IDC_A3D_KDBCONF_UNMODIFTEXT, m_oUnmodifCStatic);
DDX_Control(pDX, IDC_A3D_KDBCONF_KEYPRESS, m_oVKDetector);
DDX_Control(pDX, IDC_A3D_KBDCONF_LIST, m_oKeyConfCListBox);
DDX_Check(pDX, IDC_A3D_KBDCONF_CHECK_CTRL, m_bCheckCtrl);
DDX_Check(pDX, IDC_A3D_KBDCONF_CHECK_SHIFT, m_bCheckShift);
DDX_Check(pDX, IDC_A3D_KBDCONF_CHECK_ALT, m_bCheckAlt); /* CPA2 Corneliu Babiuc (ALT Key) 14-05-98 */
DDX_Text(pDX, IDC_A3D_KBDCONF_EDIT_KEY, m_uiCEditValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(A3d_KeyboardConfDlg, CDialog)
//{{AFX_MSG_MAP(A3d_KeyboardConfDlg)
ON_BN_CLICKED(IDC_A3D_KBDCONF_CHECK_CTRL, mfn_vOnCheckCtrl)
ON_BN_CLICKED(IDC_A3D_KBDCONF_CHECK_SHIFT, mfn_vOnCheckShift)
ON_BN_CLICKED(IDC_A3D_KBDCONF_CHECK_ALT, mfn_vOnCheckAlt) /* CPA2 Corneliu Babiuc (ALT Key) 14-05-98 */
ON_LBN_SELCHANGE(IDC_A3D_KBDCONF_LIST, mfn_vOnSelchangeConfList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// Overrides
BOOL A3d_KeyboardConfDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText(m_szName);
mfn_vBuildStringList();
m_oKeyConfCListBox.SetTabStops(128);
m_oKeyConfCListBox.SetCurSel(0);
mfn_vReadKeyDef();
UpdateData(FALSE);
GetDlgItem(IDC_A3D_KDBCONF_KEYPRESS)->SetFocus();
return FALSE;
}
BOOL A3d_KeyboardConfDlg::UpdateData(BOOL bSaveToClass)
{
BOOL bReturn;
if (bSaveToClass)
{
bReturn = CDialog::UpdateData(TRUE);
}
else
{
bReturn = CDialog::UpdateData(FALSE);
}
return bReturn;
}
//===========================================================================
// Description: inits the string list in the CListBox
// Creation date: 21 oct 96
// Author: Philippe Touillaud
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void A3d_KeyboardConfDlg::mfn_vBuildStringList(void)
{
CString oCurrent;
POSITION stPos;
ASSERT(m_p_oKeyStringList != NULL);
// builds the string in the CListBox
stPos = m_p_oKeyStringList->GetHeadPosition();
while(stPos != NULL)
{
oCurrent = m_p_oKeyStringList->GetAt(stPos);
m_oKeyConfCListBox.AddString((LPCTSTR)oCurrent);
m_p_oKeyStringList->GetNext(stPos);
}
}
//===========================================================================
// Description: reads the selected string in the CListBox, and
// changes the associated controls.
// Creation date: 26 oct 96
// Author: Philippe Touillaud
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void A3d_KeyboardConfDlg::mfn_vReadKeyDef(void)
{
CString oKeyDef;
CString& r_oKeyDef = oKeyDef; // reference, to call GetText
char cFlags;
unsigned short uwAction; // just for the fonction call
m_oKeyConfCListBox.GetText(m_oKeyConfCListBox.GetCurSel(), r_oKeyDef);
m_cCurrentKey = m_p_oKAConfig->mfn_cConvertStringInKeyDef(&oKeyDef, &cFlags, &uwAction);
m_bCheckShift = m_p_oKAConfig->mfn_bIsShiftSet(cFlags);
m_bCheckCtrl = m_p_oKAConfig->mfn_bIsCtrlSet(cFlags);
//CPA2 Corneliu Babiuc (Alt key) 14-05-98
m_bCheckAlt = m_p_oKAConfig->mfn_bIsAltSet(cFlags);
//END CPA2 Corneliu Babiuc (Alt key) 14-05-98
if((m_cCurrentKey == VK_SHIFT) || (m_cCurrentKey == VK_CONTROL)
//CPA2 Corneliu Babiuc (Alt key) 14-05-98
|| (m_cCurrentKey == VK_MENU) )
{
GetDlgItem(IDC_A3D_KBDCONF_CHECK_ALT)->EnableWindow(FALSE);
//END CPA2 Corneliu Babiuc (Alt key) 14-05-98
GetDlgItem(IDC_A3D_KBDCONF_CHECK_CTRL)->EnableWindow(FALSE);
GetDlgItem(IDC_A3D_KBDCONF_CHECK_SHIFT)->EnableWindow(FALSE);
}
else
{
GetDlgItem(IDC_A3D_KBDCONF_CHECK_CTRL)->EnableWindow(TRUE);
GetDlgItem(IDC_A3D_KBDCONF_CHECK_SHIFT)->EnableWindow(TRUE);
//CPA2 Corneliu Babiuc (Alt key) 14-05-98
GetDlgItem(IDC_A3D_KBDCONF_CHECK_ALT)->EnableWindow(TRUE);
//END CPA2 Corneliu Babiuc (Alt key) 14-05-98
}
if (m_p_oKAConfig->mfn_bIsReserved(m_cCurrentKey))
{
m_oUnmodifCStatic.ShowWindow(SW_SHOW);
m_oVKDetector.ShowWindow(SW_HIDE);
}
else
{
m_oUnmodifCStatic.ShowWindow(SW_HIDE);
m_oVKDetector.ShowWindow(SW_SHOW);
}
mfn_vShowKeyTyped(m_cCurrentKey, cFlags);
GetDlgItem(IDC_A3D_KDBCONF_KEYPRESS)->SetFocus();
}
//===========================================================================
// Description: Updates the selected string in the CListBox with the
// new values chosen (tests if the values are correct
// before updating: if the key is already used, no change
// is made , and the user is warned).
// Creation date: 26 oct 96
// Author: Philippe Touillaud
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void A3d_KeyboardConfDlg::mfn_vUpdateKeyDef(char cKey, char cFlags)
{
CString oKeyDef;
CString& r_oKeyDef = oKeyDef; // reference, to call GetText
char cOldKey;
char cOldFlags;
unsigned short uwAction;
int iIndexSelect; // 0 based index of current selection
iIndexSelect = m_oKeyConfCListBox.GetCurSel();
m_oKeyConfCListBox.GetText(iIndexSelect, r_oKeyDef);
cOldKey = m_p_oKAConfig->mfn_cConvertStringInKeyDef(&oKeyDef, &cOldFlags, &uwAction);
// Modification of the key def (if the new choice is valid)
if ( m_p_oKAConfig->mfn_bKeyIsUsedOutside(cKey ,cFlags) )
{ // key is used by windows, or by an accelerator table
AfxMessageBox("Reserved key !");
SetActiveWindow(); // regains the focus on dialog
// restore the original key def
mfn_vReadKeyDef();
// The possible key up message is swallowed by the MessageBox ():
// mfn_vResetsCombinatedKey isn't called as it should be.
m_cCombinatedKey = 0;
return;
}
if ( mfn_bKeyIsUsed(cKey ,cFlags) )
{ // key is used in the application list
if ( (cKey != cOldKey) || (cFlags != cOldFlags) )
{
// the new key chosen is already used : warn the user
int iRes = AfxMessageBox("Already used !", MB_OKCANCEL); //IDM_A3D_USEDKEY);
if(iRes == IDCANCEL)
{
SetActiveWindow(); // regains the focus on dialog
// and restore the original key def
mfn_vReadKeyDef();
m_cCombinatedKey = 0;
return;
}
}
}
// the key is valid: we change the definition
// in the CListBox
oKeyDef = m_p_oKAConfig->mfn_oConvertKeyDefInString(cKey, cFlags, uwAction);
m_oKeyConfCListBox.DeleteString(iIndexSelect);
m_oKeyConfCListBox.InsertString(iIndexSelect, (LPCTSTR)oKeyDef);
m_oKeyConfCListBox.SetCurSel(iIndexSelect);
// in the String List, mirror of the CListBox list
m_p_oKeyStringList->SetAt(m_p_oKeyStringList->FindIndex(iIndexSelect), oKeyDef);
}
//===========================================================================
// Description: Checks if a key is already used in the current list
// (m_p_oKeyStringList).
// Creation date: 30 oct 96
// Author: Philippe Touillaud
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
BOOL A3d_KeyboardConfDlg::mfn_bKeyIsUsed(char cKey ,char cFlags)
{
BOOL bIsUsed = FALSE; // result returned
CString oCurrent;
POSITION stPos;
char cCurrentKey;
char cCurrentFlags;
unsigned short uwAction; // only used for the function call
ASSERT(m_p_oKeyStringList != NULL);
// tests the list
stPos = m_p_oKeyStringList->GetHeadPosition();
while(stPos != NULL)
{
oCurrent = m_p_oKeyStringList->GetAt(stPos);
cCurrentKey = m_p_oKAConfig->mfn_cConvertStringInKeyDef(&oCurrent, &cCurrentFlags, &uwAction);
if ( (cCurrentKey == cKey) && (cCurrentFlags == cFlags) )
{
bIsUsed = TRUE;
}
m_p_oKeyStringList->GetNext(stPos);
}
return bIsUsed;
}
//===========================================================================
// Description: This fonction is called by the child caption
// (A3dVKeyTypedDetect) when a key is pressed in it.
// It processes the change.
// Creation date: 30 oct 96
// Author: Philippe Touillaud
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void A3d_KeyboardConfDlg::mfn_vDetectKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CString oKeyString;
char cFlags;
// parameters of OnKeyDown. nChar is the virtual key code.
UpdateData(TRUE);
m_uiCEditValue = nChar;
//CPA2 Corneliu Babiuc
if (nChar != VK_MENU)
cFlags = cFlags;
//CPA2 Corneliu Babiuc
if ( m_p_oKAConfig->mfn_bIsCombined(nChar) )
{
m_cCombinatedKey = nChar;
cFlags = 0;
mfn_vUpdateKeyDef(nChar, cFlags);
mfn_vShowKeyTyped(nChar, cFlags);
}
else if ( m_p_oKAConfig->mfn_bIsReserved(nChar) )
{
AfxMessageBox("System key !"); //IDM_A3D_SYSTEMKEY);
SetActiveWindow(); // regains the focus on dialog
}
else
{
cFlags = 0;
m_p_oKAConfig->mfn_vSetFlag(m_cCombinatedKey, &cFlags);
mfn_vUpdateKeyDef(nChar, cFlags);
mfn_vShowKeyTyped(nChar, cFlags);
}
mfn_vReadKeyDef();
UpdateData(FALSE);
}
//===========================================================================
// Description: This fonction is called by the child caption
// (A3dVKeyTypedDetect) when a key is released in it.
// The purpose is to manage combination keys
// Creation date: 30 oct 96
// Author: Philippe Touillaud
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void A3d_KeyboardConfDlg::mfn_vResetsCombinatedKey(char cChar)
{
if ( m_p_oKAConfig->mfn_bIsCombined(cChar) )
{
m_cCombinatedKey = 0;
}
}
//===========================================================================
// Description: Shows the key typed (decoded) in the caption
// Creation date: 30 oct 96
// Author: Philippe Touillaud
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void A3d_KeyboardConfDlg::mfn_vShowKeyTyped(char cChar, char cFlags)
{
CString oKey;
if ( m_p_oKAConfig->mfn_bIsShiftSet(cFlags) )
{
oKey = "Shift+";
}
if ( m_p_oKAConfig->mfn_bIsCtrlSet(cFlags) )
{
oKey = "Ctrl+";
}
//CPA2 Corneliu Babiuc (ALT key) 14-05-98
if ( m_p_oKAConfig->mfn_bIsAltSet(cFlags) )
{
oKey = "Alt+";
}
//END CPA2 Corneliu Babiuc (ALT key) 14-05-98
oKey += m_p_oKAConfig->mfn_oKeyToIniString(cChar, 0);
m_oVKDetector.ResetContent();
m_oVKDetector.AddString(( LPCTSTR)oKey );
}
/////////////////////////////////////////////////////////////////////////////
// A3d_KeyboardConfDlg message handlers
void A3d_KeyboardConfDlg::mfn_vOnCheckCtrl()
{
char cFlags = 0;
UpdateData(TRUE);
// Mutual exclusion between Shift and Ctrl
if (m_bCheckCtrl)
{
m_bCheckShift = FALSE;
//CPA2 Corneliu Babiuc (ALT key) 14-05-98
//and now exclude ALT key
m_bCheckAlt = FALSE;
//END CPA2 Corneliu Babiuc (ALT key) 14-05-98
m_p_oKAConfig->mfn_vSetCtrl(&cFlags);
}
if (m_bCheckShift)
{
m_p_oKAConfig->mfn_vSetShift(&cFlags);
}
//CPA2 Corneliu Babiuc (ALT key) 14-05-98
if (m_bCheckAlt)
{
m_p_oKAConfig->mfn_vSetAlt(&cFlags);
}
//END CPA2 Corneliu Babiuc (ALT key) 14-05-98
mfn_vUpdateKeyDef(m_cCurrentKey, cFlags);
UpdateData(FALSE);
mfn_vShowKeyTyped(m_cCurrentKey, cFlags);
GetDlgItem(IDC_A3D_KDBCONF_KEYPRESS)->SetFocus();
}
void A3d_KeyboardConfDlg::mfn_vOnCheckShift()
{
char cFlags = 0;
UpdateData(TRUE);
// Mutual exclusion between Shift and Ctrl
if (m_bCheckShift)
{
m_bCheckCtrl = FALSE;
//CPA2 Corneliu Babiuc (ALT key) 14-05-98
//and now exclude ALT key
m_bCheckAlt = FALSE;
//END CPA2 Corneliu Babiuc (ALT key) 14-05-98
m_p_oKAConfig->mfn_vSetShift(&cFlags);
}
if (m_bCheckCtrl)
{
m_p_oKAConfig->mfn_vSetCtrl(&cFlags);
}
//CPA2 Corneliu Babiuc (ALT key) 14-05-98
if (m_bCheckAlt)
{
m_p_oKAConfig->mfn_vSetAlt(&cFlags);
}
//END CPA2 Corneliu Babiuc (ALT key) 14-05-98
mfn_vUpdateKeyDef(m_cCurrentKey, cFlags);
UpdateData(FALSE);
mfn_vShowKeyTyped(m_cCurrentKey, cFlags);
GetDlgItem(IDC_A3D_KDBCONF_KEYPRESS)->SetFocus();
}
//CPA2 Corneliu Babiuc (ALT key) 14-05-98
void A3d_KeyboardConfDlg::mfn_vOnCheckAlt()
{
char cFlags = 0;
UpdateData(TRUE);
// Mutual exclusion between Alt, Shift and Ctrl
if (m_bCheckAlt)
{
m_bCheckCtrl = FALSE;
//and now exclude ALT key
m_bCheckShift = FALSE;
m_p_oKAConfig->mfn_vSetAlt(&cFlags);
}
if (m_bCheckCtrl)
{
m_p_oKAConfig->mfn_vSetCtrl(&cFlags);
}
if (m_bCheckShift)
{
m_p_oKAConfig->mfn_vSetShift(&cFlags);
}
mfn_vUpdateKeyDef(m_cCurrentKey, cFlags);
UpdateData(FALSE);
mfn_vShowKeyTyped(m_cCurrentKey, cFlags);
GetDlgItem(IDC_A3D_KDBCONF_KEYPRESS)->SetFocus();
}
//END CPA2 Corneliu Babiuc (ALT key) 14-05-98
void A3d_KeyboardConfDlg::mfn_vOnSelchangeConfList()
{
// adapts controls values (check buttons) to de selected key def
UpdateData(TRUE);
mfn_vReadKeyDef();
UpdateData(FALSE);
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,96 @@
//=========================================================================
// A3dVKeyTypedDetect.cpp : Special class for keydown value detection.
// Used for keyboard configuration.
// MUST BE USED WITH A3d_KeyboardConfDlg class
//
// Version 1.0
// Creation date 30/10/96
// Author: Philippe Touillaud
//
// Revision date
// Author:
//
// (c) Ubi Pictures 1996
//
//=========================================================================
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "itf/A3dKeybo.hpp"
#include "itf/A3dVKeyT.hpp"
/////////////////////////////////////////////////////////////////////////////
// A3d_VKeyTypedDetect
A3d_VKeyTypedDetect::A3d_VKeyTypedDetect()
{
}
A3d_VKeyTypedDetect::~A3d_VKeyTypedDetect()
{
}
BEGIN_MESSAGE_MAP(A3d_VKeyTypedDetect, CListBox)
//{{AFX_MSG_MAP(A3d_VKeyTypedDetect)
ON_WM_KEYDOWN()
ON_WM_KEYUP()
// CPA2 Corneliu Babiuc (Alt Key) 14-05-98
ON_WM_SYSKEYDOWN()
ON_WM_SYSKEYUP()
// END CPA2 Corneliu Babiuc (Alt Key) 14-05-98
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// A3d_VKeyTypedDetect message handlers
void A3d_VKeyTypedDetect::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
A3d_KeyboardConfDlg* poParentDlg;
poParentDlg = (A3d_KeyboardConfDlg*)(GetParent());
ASSERT(poParentDlg != NULL);
// Send the detected key to the treatment function.
poParentDlg->mfn_vDetectKeyDown(nChar, nRepCnt, nFlags);
}
void A3d_VKeyTypedDetect::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
A3d_KeyboardConfDlg* poParentDlg;
poParentDlg = (A3d_KeyboardConfDlg*)(GetParent());
ASSERT(poParentDlg != NULL);
// Resets the possible combinated key.
poParentDlg->mfn_vResetsCombinatedKey(nChar);
}
/* CPA2 Corneliu Babiuc (Alt Key) 14-05-98 */
void A3d_VKeyTypedDetect::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
A3d_KeyboardConfDlg* poParentDlg;
poParentDlg = (A3d_KeyboardConfDlg*)(GetParent());
ASSERT(poParentDlg != NULL);
// Send the detected key to the treatment function.
poParentDlg->mfn_vDetectKeyDown(nChar, nRepCnt, nFlags);
}
void A3d_VKeyTypedDetect::OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
A3d_KeyboardConfDlg* poParentDlg;
poParentDlg = (A3d_KeyboardConfDlg*)(GetParent());
ASSERT(poParentDlg != NULL);
// Resets the possible combinated key.
poParentDlg->mfn_vResetsCombinatedKey(nChar);
}
/* END CPA2 Corneliu Babiuc (Alt Key) 14-05-98 */
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,81 @@
/*=========================================================================
* CAMDLLB.cpp : Implementation of camera DLL base.
* This is a part of the CPA project.
*
* Version 1.0
* Creation date 03/25/97
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#include "acp_base.h"
#ifdef ACTIVE_EDITOR
#include "geo.h"
#include "gli.h"
#include "col.h"
#define HieFriend
#include "lst.hpp"
#include "spo.h"
#undef HieFriend
#include "itf/Camdllb.hpp"
#define C_PI 3.14159265
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
////////////////////////////// CPA_CameraCoords /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
CPA_CameraCoords::CPA_CameraCoords(tdeAxisSystem eAxis, float fX, float fY, float fZ)
{
m_fX = fX;
m_fY = fY;
m_fZ = fZ;
m_eAxisSystem = eAxis;
}
void CPA_CameraCoords::SetCoords(MTH3D_tdstVector *p_stVector)
{
m_fX = MTH3D_M_xGetXofVector(p_stVector);
m_fY = MTH3D_M_xGetYofVector(p_stVector);
m_fZ = MTH3D_M_xGetZofVector(p_stVector);
}
void CPA_CameraCoords::SetCoords(POS_tdstCompletePosition *p_stMatrix)
{
MTH3D_tdstVector stTransVector;
POS_fn_vGetTranslationVector(p_stMatrix,&stTransVector);
SetCoords(&stTransVector);
}
void CPA_CameraCoords::GetCoords(MTH3D_tdstVector &r_stVector)
{
MTH3D_M_vSetVectorElements(&r_stVector,m_fX,m_fY,m_fZ);
}
void CPA_CameraCoords::GetCoords(POS_tdstCompletePosition &r_stMatrix)
{
MTH3D_tdstVector stTransVector;
GetCoords(stTransVector);
POS_fn_vSetTranslationVector(&r_stMatrix,&stTransVector);
}
void CPA_CameraCoords::SetXYZ(float fX, float fY, float fZ)
{
m_fX = fX;
m_fY = fY;
m_fZ = fZ;
}
#endif //ACTIVE_EDITOR

View File

@@ -0,0 +1,502 @@
#include "stdafx.h"
#include "acp_base.h"
#include "itf/camslots.hpp"
#include "itf/camdllb.hpp"
#include "IncTUT.h"
#ifdef ACTIVE_EDITOR
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
CPA_CameraSlots::CPA_CameraSlots()
{
m_oCameraSlots.SetSize(10);
m_lPrevCamSlotNum = -1;
//Stefan Dumitrean 24-06-98 ( slots )
m_lCurrentSlot = -1;
m_lSpecialSlotForModeChange = -1;
//End Stefan Dumitrean 24-06-98 ( slots )
for (int i=0;i<10;i++)
{
CString name;
m_oCameraSlots[i].p_oCamera = NULL;
name.Format("Slot %i",i);
m_oCameraSlots[i].csName = name;
m_oCameraSlots[i].bReserved = FALSE;
m_oCameraSlots[i].bActive = TRUE;
}
m_p_oInterface = NULL;
}
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
CPA_CameraSlots::~CPA_CameraSlots()
{
for (long i=0;i<m_oCameraSlots.GetSize();i++)
{
if (m_oCameraSlots[i].p_oCamera != NULL)
delete m_oCameraSlots[i].p_oCamera;
}
}
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
long CPA_CameraSlots::ActivatePrevCamTip()
{
if (m_lPrevCamSlotNum != -1)
return m_lPrevCamSlotNum;
// choose a slot num for the previous camera
for (long i=0;i<m_oCameraSlots.GetSize();i++)
{
// the slot must be free!
if ((m_oCameraSlots[i].p_oCamera == NULL) && (!m_oCameraSlots[i].bReserved) && (m_oCameraSlots[i].bActive))
{
m_lPrevCamSlotNum = i;
m_oCameraSlots[i].bReserved = TRUE;
m_oCameraSlots[i].csName = "Previous Camera";
break;
}
}
return m_lPrevCamSlotNum;
}
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
long CPA_CameraSlots::ReserveASlot(CString csName)
{
long lResult;
// choose a free slot num
for (long i=0;i<m_oCameraSlots.GetSize();i++)
{
// the slot must be free!
if ((m_oCameraSlots[i].p_oCamera == NULL) && (!m_oCameraSlots[i].bReserved) && (m_oCameraSlots[i].bActive))
{
lResult = i;
m_oCameraSlots[i].bReserved = TRUE;
m_oCameraSlots[i].csName = csName;
break;
}
}
return lResult;
}
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//Stefan Dumitrean 24-06-98 ( slots )
long CPA_CameraSlots::SaveCameraInSlot(long lSlotNum,CString csName,CPA_BaseObject *p_oCamera, tdeMakeCopy eCopy)
//End Stefan Dumitrean 24-06-98 ( slots )
{
CPA_BaseObject *p_oSlotCamera;
//Stefan Dumitrean 1-07-98 ( slots )
if( lSlotNum < -1 || lSlotNum > m_oCameraSlots.GetUpperBound() + 1)
return -1;
//End Stefan Dumitrean 1-07-98 ( slots )
if (p_oCamera == NULL)
{
p_oSlotCamera = NULL;
}
else if (eCopy == MakeACopy)
{
// copy camera
p_oSlotCamera = m_p_oInterface->CopySlotCamera(p_oCamera);
}
else
{
p_oSlotCamera = p_oCamera;
}
// if lslotNum == -1, then add a new element at the end of the array
if ((lSlotNum == -1) || (lSlotNum == m_oCameraSlots.GetUpperBound()+1))
{
tdstSlot stNewSlot;
stNewSlot.p_oCamera = p_oSlotCamera;
stNewSlot.csName.Format("Slot %i",m_oCameraSlots.GetUpperBound()+1);
stNewSlot.bReserved = FALSE;
stNewSlot.bActive = TRUE;
m_oCameraSlots.Add(stNewSlot);
lSlotNum = m_oCameraSlots.GetUpperBound();
}
else
{
// delete slot camera
if (m_oCameraSlots[lSlotNum].p_oCamera != NULL)
{
delete m_oCameraSlots[lSlotNum].p_oCamera;
m_oCameraSlots[lSlotNum].p_oCamera = NULL;
}
}
// rename slot
if (csName != "")
m_oCameraSlots[lSlotNum].csName = csName;
// give the slot name to the camera
if (p_oSlotCamera != NULL)
p_oSlotCamera->fn_eRename(m_oCameraSlots[lSlotNum].csName);
m_oCameraSlots[lSlotNum].p_oCamera = p_oSlotCamera;
//Stefan Dumitrean 2-07-98 ( slots )
//save also the extra slot information
m_oCameraSlots[lSlotNum].stExtraInfo.csEditorBaseName = GetCurrentEditorName();
m_oCameraSlots[lSlotNum].stExtraInfo.csSelectedInstanceName = GetCurrentSelectionName();
//End Stefan Dumitrean 2-07-98 ( slots )
//Stefan Dumitrean 24-06-98 ( slots )
return lSlotNum;
//End Stefan Dumitrean 24-06-98 ( slots )
}
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
/*long CPA_CameraSlots::GetNbBusySlots()
{
long lRes = 0;
long i;
for (i=0;i<m_oCameraSlots.GetSize();i++)
{
if (m_oCameraSlots[i].p_oCamera != NULL)
lRes++;
}
return lRes;
}
*/
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
BOOL CPA_CameraSlots::IsEmpty(long lSlotNum)
{
return ((m_oCameraSlots[lSlotNum].p_oCamera == NULL) &&
(m_oCameraSlots[lSlotNum].bActive) &&
(!m_oCameraSlots[lSlotNum].bReserved));
}
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
//Stefan Dumitrean 22-06-98 ( slots )
CPA_BaseObject *CPA_CameraSlots::GetCameraFromPopUpMenu( long &lSlotNum, CWnd *p_oParent, tdeMakeCopy eCopy )
//End Stefan Dumitrean 22-06-98 ( slots)
{
CMenu oMenu;
POINT stPoint;
long lResult;
BOOL bAddSeparator;
oMenu.CreatePopupMenu();
bAddSeparator = FALSE;
// add previuos slot first (if it exists)
if ((m_lPrevCamSlotNum != -1) &&
(m_oCameraSlots[m_lPrevCamSlotNum].p_oCamera != NULL) &&
(m_oCameraSlots[m_lPrevCamSlotNum].bActive))
{
oMenu.AppendMenu(MF_STRING|MF_ENABLED,m_lPrevCamSlotNum+1,m_oCameraSlots[m_lPrevCamSlotNum].csName);
bAddSeparator = TRUE;
}
// add reserved slots first (do not add default slot)
for (long i=0;i<m_oCameraSlots.GetSize();i++)
{
if (i != m_lPrevCamSlotNum && i != m_lSpecialSlotForModeChange && m_oCameraSlots[i].bReserved &&
m_oCameraSlots[i].bActive && m_oCameraSlots[i].p_oCamera != NULL)
{
//Stefan Dumitrean 23-06-98 ( slots )
CString csName = m_oCameraSlots[i].csName;
if ( i == m_lCurrentSlot )
csName += " <20>";
oMenu.AppendMenu(MF_STRING|MF_ENABLED,i+1,/*m_oCameraSlots[i].*/csName);
//End Stefan Dumitrean 23-06-98 ( slots)
bAddSeparator = TRUE;
}
}
// add normal slots
for (i=0;i<m_oCameraSlots.GetSize();i++)
{
if (!m_oCameraSlots[i].bReserved && m_oCameraSlots[i].bActive && m_oCameraSlots[i].p_oCamera != NULL)
{
// there is a normal entry --> add one and only one separator
if (bAddSeparator)
{
oMenu.AppendMenu(MF_SEPARATOR,0,"");
bAddSeparator = FALSE;
}
//Stefan Dumitrean 23-06-98 ( slots )
CString csName = m_oCameraSlots[i].csName;
if( i == m_lCurrentSlot )
csName += " <20>";
oMenu.AppendMenu(MF_STRING|MF_ENABLED,i+1,/*m_oCameraSlots[i].*/csName);
//End Stefan Dumitrean 23-06-98 ( slots )
}
}
GetCursorPos(&stPoint);
TUT_M_vGetTutDll ();
TUT_M_vRegisterMenu (p_oParent -> m_hWnd , oMenu . m_hMenu , stPoint . x , stPoint . y + 15);
lResult = oMenu.TrackPopupMenu(TPM_NONOTIFY|TPM_RETURNCMD|TPM_LEFTBUTTON|TPM_CENTERALIGN,
stPoint.x,stPoint.y+15,p_oParent,NULL);
//Stefan Dumitrean 22-06-98 ( slots )
lSlotNum = lResult - 1;
//End Stefan Dumitrean 22-06-98 ( slots )
if (lResult == 0)
return NULL;
lResult -= 1;
if (eCopy == MakeACopy)
return m_p_oInterface->CopySlotCamera(m_oCameraSlots[lResult].p_oCamera);
else
return m_oCameraSlots[lResult].p_oCamera;
}
//********************************************************************************************************
//********************************************************************************************************
//********************************************************************************************************
long CPA_CameraSlots::GetSlotFromPopUpMenu(CWnd *p_oParent)
{
CMenu oMenu;
POINT stPoint;
long lResult;
oMenu.CreatePopupMenu();
// add entries : checked if occuped, not checked if free
for (long i=0;i<m_oCameraSlots.GetSize();i++)
{
if (m_oCameraSlots[i].bActive && !m_oCameraSlots[i].bReserved)
{
if (m_oCameraSlots[i].p_oCamera != NULL)
oMenu.AppendMenu(MF_STRING|MF_ENABLED|MF_CHECKED,i+1,m_oCameraSlots[i].csName);
else
oMenu.AppendMenu(MF_STRING|MF_ENABLED,i+1,m_oCameraSlots[i].csName);
}
}
// add the 'new slot' entry
oMenu.AppendMenu(MF_STRING|MF_ENABLED,1000,"new entry");
GetCursorPos(&stPoint);
TUT_M_vGetTutDll ();
TUT_M_vRegisterMenu (p_oParent -> m_hWnd , oMenu . m_hMenu , stPoint . x , stPoint . y + 15);
lResult = oMenu.TrackPopupMenu(TPM_NONOTIFY|TPM_RETURNCMD|TPM_LEFTBUTTON|TPM_CENTERALIGN,
stPoint.x,stPoint.y+15,p_oParent,NULL);
if (lResult == 1000)
return -2;
return (lResult - 1);
}
//CPA2 Corneliu Babiuc 05-05-98
//***********************************************************************************************
// Method : CPA_BaseObject * CPA_CameraSlots::GetCameraFromSlot(long lNum, tdeMakeCopy eCopy = MakeACopy)
// Date : 05-05-1998
//***********************************************************************************************
// Description :
// Returns the camera in a given number of slot by do or don't make a copy
// Parameters:
// lNum - Number of slot
// eCopy - do or don't make copy
// Author : Corneliu Babiuc
//***********************************************************************************************
inline CPA_BaseObject * CPA_CameraSlots::GetCameraFromSlot(long lNum, tdeMakeCopy eCopy )
{
ASSERT(lNum<m_oCameraSlots.GetSize());
CPA_BaseObject *p_oSlotCamera;
if (eCopy == MakeACopy)
{
//CPA2 Corneliu Babiuc 15-05-98
if (!m_oCameraSlots[lNum].p_oCamera)
return NULL;
//END CPA2 Corneliu Babiuc 15-05-98
// copy camera
return m_p_oInterface->CopySlotCamera(m_oCameraSlots[lNum].p_oCamera);
}
else
{
return p_oSlotCamera = m_oCameraSlots[lNum].p_oCamera;
}
}
//***********************************************************************************************
// Method : long CPA_CameraSlots::GetSlotNumber(CString csSlotName)
// Date : 05-04-1998
//***********************************************************************************************
// Description :
// Function to get the slot number from name of a slot. Searching through camera slots
// and return the first occurance of a slot with the name csName. If no slot is found return -1
// Parameters:
// csSlotName - name of the slots should be found
// Author : Corneliu Babiuc
//***********************************************************************************************
long CPA_CameraSlots::GetSlotNumber(CString csSlotName)
{
for (long i=0;i<m_oCameraSlots.GetSize();i++)
{
if (m_oCameraSlots[i].csName == csSlotName)
return i;
}
return -1;
}
//END CPA2 Corneliu Babiuc 05-05-98
//Stefan Dumitrean 2-07-98 ( slots )
void CPA_CameraSlots::SetCurrentSlot( CString csSlotName )
{
m_lCurrentSlot = GetSlotNumber( csSlotName );
}
void CPA_CameraSlots::SetCurrentSlot( long lSlotNum )
{
m_lCurrentSlot = -1;
if( lSlotNum >= 0 && lSlotNum < m_oCameraSlots.GetSize() )
m_lCurrentSlot = lSlotNum;
}
long CPA_CameraSlots::GetCurrentSlot( )
{
return m_lCurrentSlot;
}
BOOL CPA_CameraSlots::IsSlotReserved( CString csSlotName )
{
long lSlotNum = GetSlotNumber( csSlotName );
if( lSlotNum >= 0 && lSlotNum < m_oCameraSlots.GetSize() )
return m_oCameraSlots[lSlotNum].bReserved;
return TRUE;
}
BOOL CPA_CameraSlots::IsSlotReserved( long lSlotNum )
{
if( lSlotNum >= 0 && lSlotNum < m_oCameraSlots.GetSize() )
return m_oCameraSlots[lSlotNum].bReserved;
return TRUE;
}
long CPA_CameraSlots::FindFirstEmptySlot( )
{
for (long i=0;i<m_oCameraSlots.GetSize();i++)
{
if( IsEmpty( i ) )
return i;
}
return i;
}
CString CPA_CameraSlots::GetCurrentEditorName()
{
CString csName = "no selection";
if( m_p_oInterface && m_p_oInterface->GetMainWorld() &&
m_p_oInterface->GetMainWorld()->GetCurrentEditor()
)
csName = m_p_oInterface->GetMainWorld()->GetCurrentEditor()->GetEditorInfo()->csName;
return csName;
}
CString CPA_CameraSlots::GetCurrentSelectionName()
{
CString csName = "no selection";
if( m_p_oInterface && m_p_oInterface->GetMainWorld() &&
m_p_oInterface->GetMainWorld()->GetInterface() &&
m_p_oInterface->GetMainWorld()->GetInterface()->GetCurrentWorld() &&
m_p_oInterface->GetMainWorld()->GetInterface()->GetCurrentWorld()->GetSingleSelection()
)
csName = m_p_oInterface->GetMainWorld()->GetInterface()->GetCurrentWorld()->GetSingleSelection()->GetName();
return csName;
}
void CPA_CameraSlots::SetCurrentEditorForSlotNr( long lSlotNum )
{
CPA_EditorBase *p_oEditor;
CString csName;
if( lSlotNum < 0 || lSlotNum > m_oCameraSlots.GetUpperBound() )
return;
csName = m_oCameraSlots[lSlotNum].stExtraInfo.csEditorBaseName;
if( m_p_oInterface && m_p_oInterface->GetMainWorld() )
if( p_oEditor = m_p_oInterface->GetMainWorld()->GetEditorByName( csName ) )
m_p_oInterface->GetMainWorld()->fn_bActivateEditor( p_oEditor, NULL );
}
void CPA_CameraSlots::SetCurrentSelectionForSlotNr( long lSlotNum )
{
CPA_SuperObject *p_oSuperObject;
CString csName;
if( lSlotNum < 0 || lSlotNum > m_oCameraSlots.GetUpperBound() )
return;
csName = m_oCameraSlots[lSlotNum].stExtraInfo.csSelectedInstanceName;
if( m_p_oInterface && m_p_oInterface->GetMainWorld() &&
m_p_oInterface->GetMainWorld()->GetInterface()
)
{
p_oSuperObject = m_p_oInterface->GetMainWorld()->GetInterface()->GetSuperObject( "All Types", csName );
m_p_oInterface->GetMainWorld()->GetInterface()->fn_bSelectObject( p_oSuperObject, FALSE );
}
}
CString CPA_CameraSlots::GetEditorNameForSlotNr( long lSlotNum )
{
if( lSlotNum < 0 || lSlotNum > m_oCameraSlots.GetUpperBound() )
return "";
return m_oCameraSlots[lSlotNum].stExtraInfo.csEditorBaseName;
}
CString CPA_CameraSlots::GetSelectionNameForSlotNr( long lSlotNum )
{
if( lSlotNum < 0 || lSlotNum > m_oCameraSlots.GetUpperBound() )
return "";
return m_oCameraSlots[lSlotNum].stExtraInfo.csSelectedInstanceName;
}
void CPA_CameraSlots::SetEditorNameForSlotNr( long lSlotNum, CString csName )
{
if( lSlotNum < 0 || lSlotNum > m_oCameraSlots.GetUpperBound() )
return;
m_oCameraSlots[lSlotNum].stExtraInfo.csEditorBaseName = csName;
}
void CPA_CameraSlots::SetSelectionNameForSlotNr( long lSlotNum, CString csName )
{
if( lSlotNum < 0 || lSlotNum > m_oCameraSlots.GetUpperBound() )
return;
m_oCameraSlots[lSlotNum].stExtraInfo.csSelectedInstanceName = csName;
}
//End Stefan Dumitrean 2-07-98 ( slots )
#endif //ACTIVE_EDITOR

View File

@@ -0,0 +1,843 @@
/*
*=======================================================================================
* Name :cmdlg.cpp
*
* Author : VL Date :20/01/97
*
* Description : show incoherence that are in member list
*=======================================================================================
* Modification -> Author : VL Date : 26/05/97
* Description : some bug corrected, and all objects are now reachable objects
*=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#include "Itf/CPARes.h"
#include "Itf/CMDlg.h"
#include "Itf/cpamworl.hpp"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef ACTIVE_EDITOR
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "geo.h"
#include "gli.h"
#include "col.h"
#define HieFriend
#include "lst.hpp"
#include "spo.h"
#undef HieFriend
#include "IncTUT.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
*=======================================================================================
* CCoherenceManagerDlg class function
*=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : constructor
----------------------------------------------------------------------------------------
*/
CCoherenceManagerDlg::CCoherenceManagerDlg(CWnd* pParent /*=NULL*/) : CDialog(CCoherenceManagerDlg::IDD, pParent)
{
int iCx, iCy;
RECT stRect;
m_bBitmapInit = FALSE;
m_cMode = C_CM_Mode_cIncoherence;
GetDesktopWindow()->GetWindowRect( &stRect );
iCx = stRect.right - stRect.left + 1;
iCy = stRect.bottom - stRect.top + 1;
m_stWindowPos.top = iCy / 2 - 100;
m_stWindowPos.bottom = m_stWindowPos.top + 200;
m_stWindowPos.left = iCx / 2 - 200;
m_stWindowPos.right = m_stWindowPos.left + 400;
}
/*
----------------------------------------------------------------------------------------
Description : destructor
----------------------------------------------------------------------------------------
*/
CCoherenceManagerDlg::~CCoherenceManagerDlg()
{
if (m_bBitmapInit)
{
for (char cBitmap = 0; cBitmap < 5; cBitmap ++)
m_a_oBitmap[ cBitmap ].DeleteObject();
m_oBitmapList.DeleteImageList();
}
}
/*
----------------------------------------------------------------------------------------
Description : Data exchange
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
/*
----------------------------------------------------------------------------------------
Description : Message Map
----------------------------------------------------------------------------------------
*/
BEGIN_MESSAGE_MAP(CCoherenceManagerDlg, CDialog)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab )
ON_BN_CLICKED(IDC_RADIO_ALPHA, OnRadioAlpha)
ON_BN_CLICKED(IDC_RADIO_INCOHERENCE, OnRadioIncoherence)
ON_BN_CLICKED(IDC_RADIO_DLL, OnRadioDLL)
ON_CBN_SELCHANGE(IDC_COMBO_DLLFATHER, OnComboDLLFatherSelChange)
ON_CBN_SELCHANGE(IDC_COMBO_DLLINCOHERENCE, OnComboDLLIncoherenceSelChange)
ON_CBN_SELCHANGE(IDC_COMBO_DLLCHILD, OnComboDLLChildSelChange)
ON_WM_SIZE()
ON_WM_SIZING()
ON_WM_DESTROY()
END_MESSAGE_MAP()
/*
----------------------------------------------------------------------------------------
Description : Pre translate message
----------------------------------------------------------------------------------------
*/
BOOL CCoherenceManagerDlg::PreTranslateMessage(MSG* pMsg)
{
BOOL bResult;
if (pMsg->hwnd == m_a_stModeData[m_cMode].p_oTree->GetSafeHwnd() )
{
CTreeCtrl *pTC = m_a_stModeData[m_cMode].p_oTree;
TV_ITEM stItem;
if ( pMsg->message == WM_LBUTTONDOWN)
{
bResult = CDialog::PreTranslateMessage( pMsg );
if ( (stItem.hItem = pTC->GetSelectedItem()) != NULL )
{
stItem.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
pTC->GetItem( &stItem );
if ( (stItem.lParam) && (LOWORD(pMsg->lParam) < 16) )
pTC->Expand( stItem.hItem, TVE_TOGGLE );
}
return bResult;
}
else if (pMsg->message == WM_LBUTTONDBLCLK )
{
if ( (stItem.hItem = pTC->GetSelectedItem()) != NULL )
{
stItem.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
pTC->GetItem( &stItem );
if ( (stItem.lParam) && (LOWORD(pMsg->lParam) >= 16) )
{
if (m_cMode == C_CM_Mode_cChild)
m_fn_vCallDLL( ((tdstChild *) stItem.lParam)->m_p_oChild );
else
m_fn_vCallDLL( ((tdstFather *) stItem.lParam)->m_p_oFather );
}
else
pTC->Expand( stItem.hItem, TVE_TOGGLE );
return 1;
}
}
else if (pMsg->message == WM_RBUTTONDOWN)
{
pMsg->message = WM_LBUTTONDOWN;
bResult = CDialog::PreTranslateMessage(pMsg);
if ( (stItem.hItem = pTC->GetSelectedItem()) != NULL )
{
CMenu oPopMenu;
POINT xPos;
stItem.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
pTC->GetItem( &stItem );
if (stItem.lParam != 0)
{
if (m_cMode == C_CM_Mode_cChild)
m_p_oSelectedObject = ((tdstChild *) stItem.lParam)->m_p_oChild;
else
m_p_oSelectedObject = ((tdstFather *) stItem.lParam)->m_p_oFather;
oPopMenu.CreatePopupMenu () ;
// fill
oPopMenu.AppendMenu( MF_STRING | ( (m_p_oSelectedObject == NULL )?MF_GRAYED:0) , 1 , "Call DLL" ) ;
// display
xPos.x = LOWORD(pMsg->lParam);
xPos.y = HIWORD(pMsg->lParam);
pTC->ClientToScreen(&xPos);
TUT_M_vGetTutDll ();
TUT_M_vRegisterMenu (this -> m_hWnd , oPopMenu . m_hMenu , xPos . x , xPos . y);
oPopMenu.TrackPopupMenu ( TPM_LEFTALIGN|TPM_RIGHTBUTTON, xPos.x, xPos.y, this);
oPopMenu.DestroyMenu ();
}
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
/*
----------------------------------------------------------------------------------------
Description : OnCommand
----------------------------------------------------------------------------------------
*/
BOOL CCoherenceManagerDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch(LOWORD(wParam))
{
case 1:
m_fn_vCallDLL( m_p_oSelectedObject );
break;
default :
return CDialog::OnCommand(wParam, lParam);
}
return TRUE;
}
/*
----------------------------------------------------------------------------------------
WM_DESTROY
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::OnDestroy()
{
GetWindowRect( &m_stWindowPos );
CDialog::OnDestroy();
}
/*
----------------------------------------------------------------------------------------
WM_SIZING
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::OnSizing( UINT nSide, LPRECT lpRect )
{
long lWidth = lpRect->right - lpRect->left + 1;
long lHeight= lpRect->bottom - lpRect->top + 1;
if (lWidth < 200)
{
switch (nSide)
{
case WMSZ_BOTTOMLEFT:
case WMSZ_LEFT:
case WMSZ_TOPLEFT:
lpRect->left = lpRect->right - 200;
break;
case WMSZ_BOTTOMRIGHT:
case WMSZ_RIGHT:
case WMSZ_TOPRIGHT:
lpRect->right = lpRect->left + 200;
break;
}
}
if (lHeight < 200)
{
switch (nSide)
{
case WMSZ_BOTTOM:
case WMSZ_BOTTOMLEFT:
case WMSZ_BOTTOMRIGHT:
lpRect->bottom = lpRect->top + 200;
break;
case WMSZ_TOP:
case WMSZ_TOPLEFT:
case WMSZ_TOPRIGHT:
lpRect->top = lpRect->bottom - 200;
}
}
CDialog::OnSizing( nSide, lpRect );
}
/*
----------------------------------------------------------------------------------------
WM_SIZE
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::OnSize(UINT nType, int cx, int cy)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char cMode;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
CDialog::OnSize(nType, cx, cy);
if ( (nType != SIZE_MINIMIZED) && (GetDlgItem( IDC_STATIC_NOTHING ) != NULL) )
{
/*
* resizing Tab control
*/
GetDlgItem( IDC_TAB )->SetWindowPos( NULL, 5, 5, cx - 10, cy - 10, SWP_NOREDRAW | SWP_NOZORDER );
/*
* resizing check boxes
*/
GetDlgItem( IDC_RADIO_ALPHA )->SetWindowPos( NULL, 10, cy - 45, (cx - 30) / 2, 12, SWP_NOREDRAW | SWP_NOZORDER );
GetDlgItem( IDC_RADIO_INCOHERENCE )->SetWindowPos( NULL, 10, cy - 28, (cx - 30) / 2, 12, SWP_NOREDRAW | SWP_NOZORDER );
GetDlgItem( IDC_RADIO_DLL )->SetWindowPos( NULL, (cx - 30) / 2 + 15, cy - 45, (cx - 30) / 2, 12, SWP_NOREDRAW | SWP_NOZORDER );
/*
* resizing combo boxes and tree control
*/
for (cMode = 0; cMode < C_CM_cNumberOfModes; cMode++)
{
m_a_stModeData[ cMode ].p_oTree->SetWindowPos( NULL, 10, 30, cx - 20, cy - 80, SWP_NOREDRAW | SWP_NOZORDER );
m_a_stModeData[ cMode ].p_oCombo->SetWindowPos( NULL, (cx - 30) / 2 + 15, cy - 28, (cx - 30) / 2, 12, SWP_NOREDRAW | SWP_NOZORDER );
}
/*
* moving nothing static
*/
GetDlgItem( IDC_STATIC_NOTHING )->SetWindowPos( NULL, (cx / 2) - 40, (cy / 2) - 10, 80, 20, SWP_NOREDRAW | SWP_NOZORDER );
Invalidate();
}
}
/*
----------------------------------------------------------------------------------------
Description : functions to display list
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::m_fn_vFatherList( CFatherMap *_p_oMap, char cMode, char *szDLLName )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char szFather[200];
CTreeCtrl *pTC = m_a_stModeData[cMode].p_oTree;
CComboBox *pCB = m_a_stModeData[cMode].p_oCombo;
int iFatherImage = ( (cMode == C_CM_Mode_cIncoherence) ? 1 : 0);
int iChildImage = ((cMode == C_CM_Mode_cIncoherence) ? 3 : 2);
POSITION xPos;
POSITION xPosList;
HTREEITEM hFather;
CPA_BaseObject *p_oObject;
tdstFather *p_stFather;
tdstLinkedChild *p_stLinkedChild;
TV_ITEM stItem;
char *szName;
BOOL bReinitDllComboBox = !strcmp( szDLLName, C_szAllDLLName);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
pTC->DeleteAllItems();
if (bReinitDllComboBox)
{
pCB->ResetContent();
pCB->AddString( C_szAllDLLName );
pCB->SetCurSel(0);
}
if (_p_oMap->IsEmpty())
{
pTC->ShowWindow( FALSE );
GetDlgItem( IDC_STATIC_NOTHING )->ShowWindow( TRUE );
return;
}
pTC->ShowWindow(TRUE);
GetDlgItem( IDC_STATIC_NOTHING )->ShowWindow( FALSE );
xPos = _p_oMap->GetStartPosition();
while ( xPos )
{
_p_oMap->GetNextAssoc( xPos, p_oObject, p_stFather );
if ( (p_stFather == NULL) || (p_oObject == NULL) )
continue;
if (bReinitDllComboBox)
{
if (pCB->FindStringExact( -1, p_oObject->GetEditor()->GetCurrentEditorName() ) == CB_ERR)
pCB->AddString( p_oObject->GetEditor()->GetCurrentEditorName() );
}
else
{
if ( strcmp(p_oObject->GetEditor()->GetCurrentEditorName(), szDLLName) )
continue;
}
// insert item in tree
sprintf( szFather, "%s (%s)", p_oObject->GetName(), p_oObject->GetEditor()->GetCurrentEditorName() );
hFather = pTC->InsertItem( szFather );
stItem.hItem = hFather;
stItem.iImage = iFatherImage;
stItem.iSelectedImage = iFatherImage;
stItem.mask = TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE ;
stItem.lParam = (LPARAM) p_stFather;
pTC->SetItem( &stItem );
// insert child
xPosList = p_stFather->m_oChildList.GetHeadPosition();
while (xPosList)
{
p_stLinkedChild = p_stFather->m_oChildList.GetNext( xPosList );
if ( (p_stLinkedChild == NULL) || (p_stLinkedChild->m_p_stChild->m_p_oChild == NULL))
continue;
sprintf
(
szFather,
"[%d] %s (%s)",
p_stLinkedChild->m_ulLinkWeight,
p_stLinkedChild->m_p_stChild->m_p_oChild->GetName(),
p_stLinkedChild->m_p_stChild->m_p_oChild->GetEditor()->GetCurrentEditorName()
);
pTC->InsertItem( szFather, iChildImage, iChildImage, hFather );
}
// insert destroyed child
xPosList = p_stFather->m_oDestroyedChildList.GetHeadPosition();
while (xPosList )
{
szName = p_stFather->m_oDestroyedChildList.GetNext( xPosList );
pTC->InsertItem( szName, 4, 4, hFather );
}
}
// change order to the last used one
switch (m_a_stModeData[ cMode ].cOrder )
{
case C_cAlpha:
m_fn_vSortAlpha( cMode );
break;
case C_cIncoherence:
m_fn_vSortIncoherence( cMode );
break;
case C_cDLL:
m_fn_vSortDLL( cMode );
break;
}
}
/*
----------------------------------------------------------------------------------------
Description : functions to display list
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::m_fn_vChildList( CChildMap *_p_oMap, char cMode, char *szDLLName )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char szString[200];
CTreeCtrl *pTC = m_a_stModeData[cMode].p_oTree;
CComboBox *pCB = m_a_stModeData[cMode].p_oCombo;
int iFatherImage = ( (cMode == C_CM_Mode_cIncoherence) ? 1 : 0);
int iChildImage = ((cMode == C_CM_Mode_cIncoherence) ? 3 : 2);
POSITION xPos;
POSITION xPosList;
HTREEITEM hChild;
CPA_BaseObject *p_oObject;
tdstFather *p_stFather;
tdstChild *p_stChild;
TV_ITEM stItem;
BOOL bReinitDllComboBox = !strcmp( szDLLName, C_szAllDLLName);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
pTC->DeleteAllItems();
if (bReinitDllComboBox)
{
pCB->ResetContent();
pCB->AddString( C_szAllDLLName );
pCB->SetCurSel(0);
}
if (_p_oMap->IsEmpty())
{
pTC->ShowWindow( FALSE );
GetDlgItem( IDC_STATIC_NOTHING )->ShowWindow( TRUE );
return;
}
pTC->ShowWindow(TRUE);
GetDlgItem( IDC_STATIC_NOTHING )->ShowWindow( FALSE );
xPos = _p_oMap->GetStartPosition();
while ( xPos )
{
_p_oMap->GetNextAssoc( xPos, p_oObject, p_stChild );
if ( (p_stChild == NULL) || (p_oObject == NULL) )
continue;
if (bReinitDllComboBox)
{
if (pCB->FindStringExact( -1, p_oObject->GetEditor()->GetCurrentEditorName() ) == CB_ERR)
pCB->AddString( p_oObject->GetEditor()->GetCurrentEditorName() );
}
else
{
if ( strcmp(p_oObject->GetEditor()->GetCurrentEditorName(), szDLLName) )
continue;
}
// insert item in tree
sprintf( szString, "%s (%s)", p_oObject->GetName(), p_oObject->GetEditor()->GetCurrentEditorName() );
hChild = pTC->InsertItem( szString );
stItem.hItem = hChild;
stItem.iImage = iFatherImage;
stItem.iSelectedImage = iFatherImage;
stItem.mask = TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE ;
stItem.lParam = (LPARAM) p_stChild;
pTC->SetItem( &stItem );
// insert child
xPosList = p_stChild->m_oFatherList.GetHeadPosition();
while (xPosList)
{
p_stFather = p_stChild->m_oFatherList.GetNext( xPosList );
if ( (p_stFather == NULL) || (p_stFather->m_p_oFather == NULL))
continue;
sprintf
(
szString,
"%s (%s)",
p_stFather->m_p_oFather->GetName(),
p_stFather->m_p_oFather->GetEditor()->GetCurrentEditorName()
);
pTC->InsertItem( szString, 0, 0, hChild );
}
}
// change order to the last used one
switch (m_a_stModeData[ cMode ].cOrder )
{
case C_cAlpha:
m_fn_vSortAlpha( cMode );
break;
case C_cIncoherence:
m_fn_vSortIncoherence( cMode );
break;
case C_cDLL:
m_fn_vSortDLL( cMode );
break;
}
}
/*
*=======================================================================================
* CCoherenceManagerDlg message handlers
*=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : call DLL
----------------------------------------------------------------------------------------
*/
//void CCoherenceManagerDlg::m_fn_vCallDLL(tdstFather *p_stFather)
void CCoherenceManagerDlg::m_fn_vCallDLL(CPA_BaseObject *_p_oObject)
{
m_oReachObjList.RemoveAll();
//m_oReachObjList.AddTail( (CPA_BaseObject *) p_stFather->m_p_oFather);
m_oReachObjList.AddTail( _p_oObject );
//p_stFather->m_p_oFather->GetMainWorld()->fn_bActivateEditor( p_stFather->m_p_oFather->GetEditor(), &m_oReachObjList );
_p_oObject->GetMainWorld()->fn_bActivateEditor( _p_oObject->GetEditor(), &m_oReachObjList );
}
/*
----------------------------------------------------------------------------------------
Description : handle BN_CLICKED message on IDC_RADIO_ALPHA
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::m_fn_vSortAlpha( char cMode )
{
m_a_stModeData[ cMode ].p_oTree->SortChildren( NULL );
m_a_stModeData[ cMode ].cOrder = C_cAlpha;
}
void CCoherenceManagerDlg::OnRadioAlpha(void)
{
m_fn_vSortAlpha( m_cMode );
}
/*
----------------------------------------------------------------------------------------
Description : handle BN_CLICKED message on IDC_RADIO_INCOHERENCE
----------------------------------------------------------------------------------------
*/
int CALLBACK fn_iIncoherenceCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
tdstFather *p_stFather1 = (tdstFather *) lParam1;
tdstFather *p_stFather2 = (tdstFather *) lParam2;
return (p_stFather2->m_oChildList.GetCount() - p_stFather1->m_oChildList.GetCount());
}
int CALLBACK fn_iNumberOfFathersCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
tdstChild *p_stChild1 = (tdstChild *) lParam1;
tdstChild *p_stChild2 = (tdstChild *) lParam2;
return (p_stChild2->m_oFatherList.GetCount() - p_stChild1->m_oFatherList.GetCount());
}
void CCoherenceManagerDlg::m_fn_vSortIncoherence( char cMode )
{
TV_SORTCB stSort;
stSort.hParent = NULL;
switch (m_cMode)
{
case C_CM_Mode_cIncoherence:
case C_CM_Mode_cFather:
stSort.lpfnCompare = fn_iIncoherenceCompare;
break;
case C_CM_Mode_cChild:
stSort.lpfnCompare = fn_iNumberOfFathersCompare;
break;
}
m_a_stModeData[cMode].p_oTree->SortChildrenCB( &stSort );
m_a_stModeData[cMode].cOrder = C_cIncoherence;
}
void CCoherenceManagerDlg::OnRadioIncoherence( void )
{
m_fn_vSortIncoherence( m_cMode );
}
/*
----------------------------------------------------------------------------------------
Description : handle BN_CLICKED message on IDC_RADIO_DLL
----------------------------------------------------------------------------------------
*/
int CALLBACK fn_iFatherDLLCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
tdstFather *p_stFather1 = (tdstFather *) lParam1;
tdstFather *p_stFather2 = (tdstFather *) lParam2;
return strcmp(p_stFather1->m_p_oFather->GetEditor()->GetCurrentEditorName(), p_stFather2->m_p_oFather->GetEditor()->GetCurrentEditorName());
}
int CALLBACK fn_iChildDLLCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
tdstChild *p_stChild1 = (tdstChild *) lParam1;
tdstChild *p_stChild2 = (tdstChild *) lParam2;
return strcmp(p_stChild1->m_p_oChild->GetEditor()->GetCurrentEditorName(), p_stChild2->m_p_oChild->GetEditor()->GetCurrentEditorName());
}
void CCoherenceManagerDlg::m_fn_vSortDLL( char cMode )
{
TV_SORTCB stSort;
stSort.hParent = NULL;
switch (m_cMode)
{
case C_CM_Mode_cIncoherence:
case C_CM_Mode_cFather:
stSort.lpfnCompare = fn_iFatherDLLCompare;
break;
case C_CM_Mode_cChild:
stSort.lpfnCompare = fn_iChildDLLCompare;
break;
}
m_a_stModeData[cMode].p_oTree->SortChildrenCB( &stSort );
m_a_stModeData[cMode].cOrder = C_cDLL;
}
void CCoherenceManagerDlg::OnRadioDLL(void)
{
m_fn_vSortDLL( m_cMode );
}
/*
----------------------------------------------------------------------------------------
Description : CBN_SELCHANGE message for IDC_COMBO_DLLFATHER
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::OnComboDLLFatherSelChange(void)
{
char szDllName[100];
GetDlgItem(IDC_COMBO_DLLFATHER)->GetWindowText(szDllName, 100);
m_fn_vFatherList( m_p_oFatherMap, 1 , szDllName );
}
/*
----------------------------------------------------------------------------------------
Description : CBN_SELCHANGE message for IDC_COMBO_DLLINCOHERENCE
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::OnComboDLLIncoherenceSelChange(void)
{
char szDllName[100];
GetDlgItem(IDC_COMBO_DLLINCOHERENCE)->GetWindowText(szDllName, 100);
m_fn_vFatherList( m_p_oIncoherenceMap, 0 , szDllName );
}
/*
----------------------------------------------------------------------------------------
Description : CBN_SELCHANGE message for IDC_COMBO_DLLCHILD
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::OnComboDLLChildSelChange(void)
{
char szDllName[100];
GetDlgItem(IDC_COMBO_DLLCHILD)->GetWindowText(szDllName, 100);
m_fn_vChildList( m_p_oChildMap, 2 , szDllName );
}
/*
----------------------------------------------------------------------------------------
Description : TCN_SELCHANGE message
----------------------------------------------------------------------------------------
*/
void CCoherenceManagerDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{
int iTab = ((CTabCtrl *) GetDlgItem( IDC_TAB ))->GetCurSel() ;
BOOL bSomething;
bSomething = m_a_stModeData[iTab].p_oTree->GetCount() > 0;
// show new mode
m_a_stModeData[ iTab ].p_oTree->ShowWindow( bSomething );
m_a_stModeData[ iTab ].p_oCombo->ShowWindow( bSomething );
GetDlgItem( IDC_STATIC_NOTHING )->ShowWindow( !bSomething );
GetDlgItem( IDC_RADIO_ALPHA )->ShowWindow( bSomething );
GetDlgItem( IDC_RADIO_INCOHERENCE )->ShowWindow( bSomething );
GetDlgItem( IDC_RADIO_DLL )->ShowWindow( bSomething );
if (bSomething )
{
((CButton *) GetDlgItem( IDC_RADIO_ALPHA ))->SetCheck( m_a_stModeData[iTab].cOrder == C_cAlpha ? 1 : 0 );
((CButton *) GetDlgItem( IDC_RADIO_INCOHERENCE ))->SetCheck( m_a_stModeData[iTab].cOrder == C_cIncoherence ? 1 : 0 );
((CButton *) GetDlgItem( IDC_RADIO_DLL ))->SetCheck( m_a_stModeData[iTab].cOrder == C_cDLL ? 1 : 0 );
GetDlgItem( IDC_RADIO_INCOHERENCE )->SetWindowText( m_a_stModeData[iTab].szOrderName );
}
// hide old mode
if (m_cMode != iTab )
{
m_a_stModeData[ m_cMode ].p_oTree->ShowWindow( FALSE );
m_a_stModeData[ m_cMode ].p_oCombo->ShowWindow( FALSE );
// set new mode
m_cMode = iTab;
}
*pResult = 0;
}
/*
----------------------------------------------------------------------------------------
Description : handle WM_INITDIALOG message
----------------------------------------------------------------------------------------
*/
BOOL CCoherenceManagerDlg::OnInitDialog()
{
char szTitle[20];
TC_ITEM stItem;
CTabCtrl *p_oTab = (CTabCtrl *) GetDlgItem( IDC_TAB );
char cMode;
CDialog::OnInitDialog();
if ( !m_bBitmapInit )
{
char cBitmap;
m_a_oBitmap[0].LoadBitmap( IDB_BITMAP_FATHER );
m_a_oBitmap[1].LoadBitmap( IDB_BITMAP_INCOHERENCE );
m_a_oBitmap[2].LoadBitmap( IDB_BITMAP_CHILD );
m_a_oBitmap[3].LoadBitmap( IDB_BITMAP_DELETEDCHILD );
m_a_oBitmap[4].LoadBitmap( IDB_BITMAP_DESTROYEDCHILD );
m_oBitmapList.Create(16,16,TRUE, 5,5);
for (cBitmap = 0; cBitmap < 5; cBitmap ++)
m_oBitmapList.Add( &m_a_oBitmap[ cBitmap ], RGB(255,255,255) );
m_bBitmapInit = TRUE;
}
/*
* Init Mode data
*/
m_a_stModeData[C_CM_Mode_cIncoherence].p_oTree = (CTreeCtrl *) GetDlgItem( IDC_TREE_INCOHERENCE );
m_a_stModeData[C_CM_Mode_cIncoherence].p_oCombo = (CComboBox *) GetDlgItem( IDC_COMBO_DLLINCOHERENCE );
m_a_stModeData[C_CM_Mode_cIncoherence].cOrder = C_cAlpha;
strcpy( m_a_stModeData[C_CM_Mode_cIncoherence].szOrderName, "Number of incoherences" );
m_a_stModeData[C_CM_Mode_cFather].p_oTree = (CTreeCtrl *) GetDlgItem( IDC_TREE_FATHER );
m_a_stModeData[C_CM_Mode_cFather].p_oCombo = (CComboBox *) GetDlgItem( IDC_COMBO_DLLFATHER );
m_a_stModeData[C_CM_Mode_cFather].cOrder = C_cAlpha;
strcpy( m_a_stModeData[C_CM_Mode_cFather].szOrderName, "Number of children" );
m_a_stModeData[C_CM_Mode_cChild].p_oTree = (CTreeCtrl *) GetDlgItem( IDC_TREE_CHILD );
m_a_stModeData[C_CM_Mode_cChild].p_oCombo = (CComboBox *) GetDlgItem( IDC_COMBO_DLLCHILD );
m_a_stModeData[C_CM_Mode_cChild].cOrder = C_cAlpha;
strcpy( m_a_stModeData[C_CM_Mode_cChild].szOrderName, "Number of fathers" );
p_oTab->DeleteAllItems();
p_oTab->SetImageList( &m_oBitmapList );
stItem.mask = TCIF_TEXT | TCIF_IMAGE;
stItem.pszText = szTitle;
stItem.iImage = 1;
strcpy( szTitle, "Invalid links" );
p_oTab->InsertItem( 0 , &stItem );
stItem.iImage = 0;
strcpy( szTitle, "Father links" );
p_oTab->InsertItem( 1 , &stItem );
stItem.iImage = 2;
strcpy( szTitle, "Child links" );
p_oTab->InsertItem( 2 , &stItem );
for (cMode = 0; cMode < C_CM_cNumberOfModes; cMode ++)
m_a_stModeData[ cMode ].p_oTree->SetImageList( &m_oBitmapList, TVSIL_NORMAL );
m_fn_vFatherList( m_p_oIncoherenceMap, 0, C_szAllDLLName );
m_fn_vFatherList( m_p_oFatherMap, 1, C_szAllDLLName );
m_fn_vChildList( m_p_oChildMap, 2, C_szAllDLLName );
for (cMode = 0; cMode < C_CM_cNumberOfModes; cMode ++)
{
m_a_stModeData[ cMode ].p_oTree->ShowWindow( FALSE );
m_a_stModeData[ cMode ].p_oCombo->ShowWindow( FALSE );
}
LRESULT lResult;
p_oTab->SetCurSel( m_cMode );
OnSelchangeTab( NULL, &lResult );
MoveWindow( &m_stWindowPos );
return TRUE;
}
#endif //ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
// CPAAbout.cpp : implementation file
//
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "ACP_Base.h"
#include "itf/CPAAbout.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAEditB.hpp"
#include "itf/CPAProj.hpp"
#include "itf/CPAConst.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define M_List() ((CListCtrl*)GetDlgItem(IDC_LIST_EDITOR))
/////////////////////////////////////////////////////////////////////////////
// CPA_DlgAbout dialog
CPA_DlgAbout::CPA_DlgAbout(CWnd* pParent /*=NULL*/)
: CDialog(CPA_DlgAbout::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_DlgAbout)
//}}AFX_DATA_INIT
}
void CPA_DlgAbout::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DlgAbout)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPA_DlgAbout, CDialog)
//{{AFX_MSG_MAP(CPA_DlgAbout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_DlgAbout message handlers
BOOL CPA_DlgAbout::OnInitDialog()
{
CDialog::OnInitDialog();
// update application name
GetDlgItem( IDC_ST_APPNAME ) -> SetWindowText( M_GetMainApp() -> m_csApplicationName );
// update application version
GetDlgItem( IDC_ST_APPVERSION ) -> SetWindowText( M_GetMainApp() -> m_csApplicationVersion );
// update interface name
GetDlgItem(IDC_ST_APPNAME2)->SetWindowText("Editors Interface");
// update application version
GetDlgItem(IDC_ST_APPVERSION2)->SetWindowText(C_szCPAVersion);
// update editor list
fn_vFillEditorList();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPA_DlgAbout::fn_vFillEditorList()
{
CListCtrl *pLC = M_List();
int iTaille = pLC -> GetStringWidth( "m" );
// add column
pLC -> InsertColumn(0,"Editor",LVCFMT_LEFT,iTaille*20);
pLC -> InsertColumn(1,"Version",LVCFMT_LEFT,iTaille*20);
pLC -> InsertColumn(2,"Author",LVCFMT_LEFT,iTaille*20);
pLC -> DeleteAllItems();
// add info
CPA_List<CPA_EditorBase> *p_oList = m_p_oMainWorld -> GetListOfEditorBase();
POSITION stPos = p_oList -> GetHeadPosition();
WORD wR = 0;
while ( stPos )
{
tdstEDTInfo *p_stInfo = p_oList -> GetNext( stPos ) -> GetEditorInfo();
pLC -> InsertItem (wR, p_stInfo -> csName, 0);
pLC -> SetItemText(wR, 1, p_stInfo -> csVersion);
pLC -> SetItemText(wR, 2, p_stInfo -> csAuthor);
}
}
#endif

View File

@@ -0,0 +1,701 @@
/*=========================================================================
*
* CPABase.cpp : CPA_EditorBase : Implementation file.
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#include "Itf/customid.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPABase.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAProj.hpp"
/*===========================================================================
Constructor
=========================================================================*/
CPA_EditorBase::CPA_EditorBase (void)
{
m_oListOfReachableObjectList.RemoveAll();
m_oListOfModifiedReachableObjects.RemoveAll();
m_p_oMainWorld = NULL;
m_stContext.pPreviousEditor = NULL;
// editor info
m_stEditorInfo.csName = "";
m_stEditorInfo.csAuthor = "";
m_stEditorInfo.csVersion = "";
m_stEditorInfo.csHelpFile = "";
}
CPA_EditorBase::~CPA_EditorBase (void)
{
CPA_ReachableObjectList *p_oList;
while (!(m_oListOfReachableObjectList.IsEmpty()))
{
p_oList = m_oListOfReachableObjectList.GetHead();
p_oList->DeleteAllObjects();
delete m_oListOfReachableObjectList.RemoveHead();
}
POSITION stPos = m_oListOfModifiedReachableObjects.GetHeadPosition();
while ( stPos )
{
tdstModifiedObjectsInfo *p_stList = m_oListOfModifiedReachableObjects.GetNext( stPos );
POSITION stPosROLN = p_stList -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPosROLN )
{
tdstReachableObjectListNamed *p_stROLN = p_stList -> m_oListOfModifiedObjects . GetNext( stPosROLN );
p_stROLN -> m_oListOfReachableObjects . RemoveAll();
delete p_stROLN;
}
p_stList -> m_oListOfModifiedObjects . RemoveAll();
delete p_stList;
}
}
void CPA_EditorBase::SetEditorInfo(CString csName, CString csAuthor,
CString csVersion, CString csHelpFile)
{
m_stEditorInfo . csName = csName;
m_stEditorInfo . csAuthor = csAuthor;
m_stEditorInfo . csVersion = csVersion;
m_stEditorInfo . csHelpFile = csHelpFile;
}
void CPA_EditorBase::SetMainWorld (CPA_MainWorld *p_oMainWorld)
{
m_p_oMainWorld = p_oMainWorld;
if (m_p_oMainWorld)
m_p_oMainWorld->fn_vRegisterEditor(this);
}
CPA_Interface * CPA_EditorBase::GetInterface (void)
{
return m_p_oMainWorld->GetInterface();
}
/*===========================================================================
Register objects types for ReachableObjectsList
=========================================================================*/
void CPA_EditorBase::fn_vRegisterObjectsType (CString a_csTypeName[], long lTypeCount)
{
long iIndex;
for (iIndex = 0; iIndex < lTypeCount; iIndex++)
{
CPA_ReachableObjectList *p_oListOfObjects;
// check if there is allready a list with that typename!!!!
ASSERT(m_p_oMainWorld->fn_p_oGetOriginalObjectList(a_csTypeName[iIndex]) == NULL);
p_oListOfObjects = new CPA_ReachableObjectList(a_csTypeName[iIndex]);
m_oListOfReachableObjectList.AddTail(p_oListOfObjects);
}
}
/*===========================================================================
=========================================================================*/
long CPA_EditorBase::fn_lFillWithRegisterObjectsType(CPA_List<CString> *_p_oList)
{
POSITION stPos = m_oListOfReachableObjectList.GetHeadPosition();
while ( stPos )
{
_p_oList -> AddTail( m_oListOfReachableObjectList.GetNext( stPos ) -> fn_p_csGetTypeName() );
}
return ((long)m_oListOfReachableObjectList.GetCount());
}
/*===========================================================================
Get the ReachableObjectList corresponding to csTypeName
=========================================================================*/
CPA_ReachableObjectList * CPA_EditorBase::GetObjectList (CString csTypeName)
{
CPA_ReachableObjectList *p_oListOfObjects;
POSITION pos;
pos = m_oListOfReachableObjectList.GetHeadPosition();
// search list
while(pos)
{
p_oListOfObjects = m_oListOfReachableObjectList.GetNext(pos);
if (p_oListOfObjects->fn_bIsType(csTypeName))
return p_oListOfObjects;
}
return NULL;
}
/*===========================================================================
Add object to the corresponding ReachableObjectList
=========================================================================*/
BOOL CPA_EditorBase::fn_bAddObject (CPA_ReachableObject *p_oObject)
{
CPA_ReachableObjectList *p_oListOfObjects;
// find the list
p_oListOfObjects = GetObjectList(p_oObject->CPA_ReachableObject::fn_csGetTypeName());
// if the list for this type of object does not exist
if (!p_oListOfObjects)
{
ASSERT(0);
return FALSE;
}
// add object
return p_oListOfObjects->fn_bAddObject(p_oObject);
}
/*===========================================================================
Remove object from the corresponding ReachableObjectList
=========================================================================*/
BOOL CPA_EditorBase::fn_bRemoveObject (CPA_ReachableObject *p_oObject)
{
CPA_ReachableObjectList *p_oListOfObjects;
// find corresponding list
p_oListOfObjects = GetObjectList(p_oObject->CPA_ReachableObject::fn_csGetTypeName());
// type of object does not exists in this DLL
if (p_oListOfObjects == NULL)
{
ASSERT(0);
return FALSE;
}
return p_oListOfObjects->fn_bRemoveObject(p_oObject);
}
/*===========================================================================
check if object exists
=========================================================================*/
BOOL CPA_EditorBase::fn_bExist(CPA_ReachableObject *p_oObject)
{
CPA_ReachableObjectList *p_oListOfObjects;
BOOL bResult = FALSE;
p_oListOfObjects = GetObjectList(p_oObject->CPA_ReachableObject::fn_csGetTypeName());
if(p_oListOfObjects)
bResult = p_oListOfObjects->fn_bExist(p_oObject);
return bResult;
}
/*===========================================================================
check if object exists
=========================================================================*/
BOOL CPA_EditorBase::fn_bExist(CString csObjectName, CString csObjectType, CPA_ReachableObject *p_oOwner)
{
CPA_ReachableObjectList *p_oListOfObjects;
POSITION pos;
if ((csObjectName.IsEmpty()) && (csObjectType.IsEmpty()) && (p_oOwner == NO_CRITERIA))
{
ASSERT(0);
}
// if type is valid
if (!csObjectType.IsEmpty())
{
// we just look in the list corresponding to this type
p_oListOfObjects = GetObjectList(csObjectType);
if (!p_oListOfObjects)
return FALSE;
return p_oListOfObjects->fn_bExist(csObjectName,csObjectType,p_oOwner);
}
else
{
// we must look in every list
pos = m_oListOfReachableObjectList.GetHeadPosition();
while(pos) // look in every list
{
// get the current list
p_oListOfObjects = m_oListOfReachableObjectList.GetNext(pos);
// find the object in this list
if (p_oListOfObjects->fn_bExist(csObjectName,csObjectType,p_oOwner))
return TRUE;
}
}
return FALSE;
}
/*===========================================================================
find object from its type and name
=========================================================================*/
CPA_ReachableObject * CPA_EditorBase::GetReachableObject (CString csObjectName, CString csObjectType, CPA_ReachableObject *p_oOwner)
{
CPA_ReachableObjectList *p_oListOfObjects;
CPA_ReachableObject *p_oObject;
POSITION pos;
if ((csObjectName.IsEmpty()) && (csObjectType.IsEmpty()) && (p_oOwner == NO_CRITERIA))
{
ASSERT(0);
}
// if type is valid
if (!csObjectType.IsEmpty())
{
// we just look in the list corresponding to this type
p_oListOfObjects = GetObjectList(csObjectType);
if (!p_oListOfObjects)
return NULL;
return p_oListOfObjects->fn_p_oFindObject(csObjectName,csObjectType,p_oOwner);
}
else
{
// we must look in every list
pos = m_oListOfReachableObjectList.GetHeadPosition();
while (pos)
{
// get the current list
p_oListOfObjects = m_oListOfReachableObjectList.GetNext(pos);
// find the object in this list
p_oObject = p_oListOfObjects->fn_p_oFindObject(csObjectName,csObjectType,p_oOwner);
if (p_oObject != NULL)
return p_oObject;
}
}
return NULL;
}
/*===========================================================================
find object from its type and engine struct
=========================================================================*/
CPA_ReachableObject * CPA_EditorBase::GetReachableObject (void *p_vEngineStruct, CString csObjectType, CPA_ReachableObject *p_oOwner)
{
CPA_ReachableObjectList *p_oListOfObjects;
CPA_ReachableObject *p_oObject;
POSITION pos;
if ((p_vEngineStruct == NULL) && (csObjectType.IsEmpty()) && (p_oOwner == NO_CRITERIA))
{
ASSERT(0);
}
// if type is valid
if (!csObjectType.IsEmpty())
{
// we just look in the list corresponding to this type
p_oListOfObjects = GetObjectList(csObjectType);
if (!p_oListOfObjects)
return NULL;
return p_oListOfObjects->fn_p_oFindObjectWithEngine(p_vEngineStruct,csObjectType,p_oOwner);
}
else
{
// we must look in every list
pos = m_oListOfReachableObjectList.GetHeadPosition();
while (pos)
{
CPA_ReachableObjectList *p_oListOfObjects;
// get the current list
p_oListOfObjects = m_oListOfReachableObjectList.GetNext(pos);
// find the object in this list
p_oObject = p_oListOfObjects->fn_p_oFindObjectWithEngine(p_vEngineStruct,csObjectType,p_oOwner);
if (p_oObject != NULL)
return p_oObject;
}
}
return NULL;
}
/*===========================================================================
find objects with given type and name
=========================================================================*/
long CPA_EditorBase::fn_lFindObjects (CPA_ReachableObjectList *p_oResultList, CString csObjectName, CString csObjectType, CPA_ReachableObject *p_oOwner)
{
CPA_ReachableObjectList *p_oListOfObjects;
POSITION pos;
long lResult = 0;
if ((csObjectName.IsEmpty()) && (csObjectType.IsEmpty()) && (p_oOwner == NO_CRITERIA))
{
ASSERT(0);
}
// if type is valid
if (!csObjectType.IsEmpty())
{
// we just look in the list corresponding to this type
p_oListOfObjects = GetObjectList(csObjectType);
if(!p_oListOfObjects)
return 0;
lResult = p_oListOfObjects->fn_lFindObjects(p_oResultList,csObjectName,csObjectType,p_oOwner);
}
else
{
// we must look in every list
pos = m_oListOfReachableObjectList.GetHeadPosition();
while(pos) // look in every list, whatever the result is
{
// get the current list
p_oListOfObjects = m_oListOfReachableObjectList.GetNext(pos);
// find the object in this list
lResult += p_oListOfObjects->fn_lFindObjects(p_oResultList,csObjectName,csObjectType,p_oOwner);
}
}
return lResult;
}
/*===========================================================================
update lists when objects are created or deleted
=========================================================================*/
void CPA_EditorBase::fn_vUpdateObjectList (CPA_ReachableObject *p_oObject, tdeUpdate eType)
{
CPA_ReachableObject *pEdObj;
// delete => unregister object
if (eType == C_EDTDelete)
p_oObject->fn_bUnRegister();
// insert => register object
else
{
// is pEdObj already registered ?
pEdObj = GetReachableObject(p_oObject->GetName(), p_oObject->fn_csGetTypeName(), p_oObject->GetOwner());
// register object (if necessary, change its name)
if (pEdObj != p_oObject)
p_oObject->GetMainWorld()->fn_p_cReInsertAnObject(p_oObject, (eType == C_EDTInsert));
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// for Modified Reachable Objects
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CPA_EditorBase::fn_vRegisterModificationsType(CString _csObjectTypeName, CString a_csModificationType[], long lTypeCount)
{
ASSERT( GetObjectList( _csObjectTypeName ) );
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
if ( !p_stList )
{
// create new
p_stList = new(tdstModifiedObjectsInfo);
p_stList -> m_oObjectType = _csObjectTypeName;
p_stList-> m_oListOfModifiedObjects . RemoveAll();
// add
m_oListOfModifiedReachableObjects . AddTail( p_stList );
}
// add modifications
for ( long i=0 ; i<lTypeCount ; i++ )
{
ASSERT( !fn_bIsRegisterModificationType( p_stList, a_csModificationType[i] ) );
tdstReachableObjectListNamed *p_stROLN = new(tdstReachableObjectListNamed);
p_stROLN -> m_ocsModificationTypeName = a_csModificationType[i];
p_stROLN -> m_oListOfReachableObjects . RemoveAll();
p_stROLN -> m_oListOfReachableObjects . fn_bSetTypeName( _csObjectTypeName );
p_stList -> m_oListOfModifiedObjects . AddTail( p_stROLN );
}
}
/*===========================================================================
=========================================================================*/
long CPA_EditorBase::fn_lFillWithRegisterModificationsType(CPA_List<CString> *_p_oList, CString _csObjectTypeName)
{
ASSERT( GetObjectList( _csObjectTypeName ) );
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
if( p_stList )
{
POSITION stPos = p_stList->m_oListOfModifiedObjects.GetHeadPosition();
while ( stPos )
{
_p_oList -> AddTail( &(p_stList -> m_oListOfModifiedObjects . GetNext( stPos ) -> m_ocsModificationTypeName) );
}
return ((long)p_stList->m_oListOfModifiedObjects.GetCount());
}
return 0;
}
/*===========================================================================
=========================================================================*/
int CPA_EditorBase::fn_iGetModificationCount(CString _csObjectTypeName)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
return ( p_stList ? p_stList -> m_oListOfModifiedObjects . GetCount() : 0 );
}
/*===========================================================================
=========================================================================*/
CPA_ReachableObjectList* CPA_EditorBase::fn_p_oGetModifiedObjectsList(CString _csObjectTypeName, CString _csModificationType)
{
tdstReachableObjectListNamed *p_stROLN = fn_p_stGetROLN (_csObjectTypeName, _csModificationType);
return ( p_stROLN ? &(p_stROLN -> m_oListOfReachableObjects) : NULL );
}
/*===========================================================================
=========================================================================*/
int CPA_EditorBase::fn_iGetModificationIndex(CString _csObjectTypeName, CString _csModificationType)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
if(p_stList)
{
int iResult = 0;
POSITION stPos = p_stList -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPos )
{
if( p_stList -> m_oListOfModifiedObjects . GetNext( stPos ) -> m_ocsModificationTypeName == _csModificationType )
return iResult;
iResult++;
}
}
return -1;
}
/*===========================================================================
=========================================================================*/
CString CPA_EditorBase::fn_csGetModificationByIndex(CString _csObjectTypeName, int _iIndex )
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _csObjectTypeName );
if(p_stList)
{
POSITION stPos = p_stList -> m_oListOfModifiedObjects . FindIndex( _iIndex );
return ( stPos ? p_stList -> m_oListOfModifiedObjects . GetAt( stPos ) -> m_ocsModificationTypeName : "");
}
return "";
}
/*===========================================================================
=========================================================================*/
BOOL CPA_EditorBase::fn_bAddModifiedObject(CPA_ReachableObject *_p_oObject, CString _csModificationType)
{
tdstReachableObjectListNamed *p_stROLN = fn_p_stGetROLN (_p_oObject -> fn_csGetTypeName(), _csModificationType);
if ( p_stROLN )
{
return p_stROLN -> m_oListOfReachableObjects . fn_bAddObject(_p_oObject);
}
return FALSE;
}
/*===========================================================================
=========================================================================*/
BOOL CPA_EditorBase::fn_bRemoveModifiedObject(CPA_ReachableObject *_p_oObject, CString _csModificationType)
{
tdstReachableObjectListNamed *p_stROLN = fn_p_stGetROLN (_p_oObject -> fn_csGetTypeName(), _csModificationType);
if ( p_stROLN )
{
return p_stROLN -> m_oListOfReachableObjects . fn_bRemoveObject(_p_oObject);
}
return FALSE;
}
/*===========================================================================
=========================================================================*/
BOOL CPA_EditorBase::fn_bIsModified(CPA_ReachableObject *_p_oObject, CString _csModificationType /* = "" */)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo( _p_oObject -> fn_csGetTypeName() );
if(p_stList)
{
if ( _csModificationType != "" )
{
tdstReachableObjectListNamed *p_stROLN = fn_p_stGetROLN (p_stList, _csModificationType );
return ( p_stROLN ? p_stROLN -> m_oListOfReachableObjects . fn_bExist( _p_oObject ) : FALSE );
}
else
{
POSITION stPos = p_stList -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPos )
{
tdstReachableObjectListNamed *p_stROLN = p_stList -> m_oListOfModifiedObjects . GetNext( stPos );
if( (p_stROLN) && p_stROLN -> m_oListOfReachableObjects . fn_bExist( _p_oObject ) )
return TRUE;
}
}
}
return FALSE;
}
/*===========================================================================
for dialog list
=========================================================================*/
void CPA_EditorBase::fn_vInitDefaultParameters (CPA_DialogList *pDialog)
{
pDialog->SetDefaultTestName("No Test");
pDialog->SetDefaultTypeName("");
}
/*===========================================================================
save context when editor changes
=========================================================================*/
void CPA_EditorBase::fn_vSaveContext (void)
{
int i, j;
// save current dll
if (GetMainWorld()->GetCurrentEditor() != this)
{
if (!m_stContext.pPreviousEditor)
{
m_stContext.pPreviousEditor = GetMainWorld()->GetCurrentEditor();
// save and update current editor
if (m_stContext.pPreviousEditor)
{
m_stContext.bCurrentEditor = m_stContext.pPreviousEditor->fn_bIsCurrentEditor();
m_stContext.pPreviousEditor->SetCurrent(FALSE);
}
// save dialogs
memcpy(m_stContext.m_aWinArray, g_oFrameGest.ma_p_oWinArray, sizeof(FRMBase *) * (FRM_C_MaxCol+2) * (FRM_C_MaxRow+2));
}
// close all editor frames
for (i=1; i<=FRM_C_MaxCol; i++)
{
for (j=1; j<=FRM_C_MaxRow; j++)
{
if (((i!=2)||(j!=2))&&(g_oFrameGest.ma_p_oWinArray[i][j]))
g_oFrameGest.mfn_vDisactivateWindow(g_oFrameGest.ma_p_oWinArray[i][j]);
}
}
}
}
/*===========================================================================
restore context when editor changes
=========================================================================*/
void CPA_EditorBase::fn_vRestoreContext (void)
{
int i, j;
// restore current dll and editor
if (m_stContext.pPreviousEditor)
{
m_stContext.pPreviousEditor->SetCurrent(m_stContext.bCurrentEditor);
GetMainWorld()->fn_bSetCurrentEditor(m_stContext.pPreviousEditor);
// close all editor frames
for (i=1; i<=FRM_C_MaxCol; i++)
{
for (j=1; j<=FRM_C_MaxRow; j++)
{
if (((i!=2)||(j!=2))&&(g_oFrameGest.ma_p_oWinArray[i][j]))
g_oFrameGest.mfn_vDisactivateWindow(g_oFrameGest.ma_p_oWinArray[i][j]);
}
}
// restore previous dialogs
for (i=1; i<=FRM_C_MaxCol; i++)
{
for (j=1; j<=FRM_C_MaxRow; j++)
{
if (((i!=2)||(j!=2))&&(m_stContext.m_aWinArray[i][j]))
{
g_oFrameGest.mfn_vActivateWindow(m_stContext.m_aWinArray[i][j]);
m_stContext.m_aWinArray[i][j] = NULL;
}
}
}
}
// reinit context
m_stContext.pPreviousEditor = NULL;
}
/*===========================================================================
=========================================================================*/
CString CPA_EditorBase::GetReferencePath (CString csEntry)
{
CString csFileName, csReferencePath;
char szPath[SCR_CV_ui_Cfg_MaxLenName];
// search ini file for given entry
csFileName = M_GetMainApp()->m_csEditorDataPath + C_szReferenceIniFile;
GetPrivateProfileString ("ReferencePath", (char*)(LPCSTR)csEntry, "", szPath, 256, (char*)(LPCSTR)csFileName);
// build reference path
csReferencePath = szPath;
return csReferencePath;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// private
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*===========================================================================
=========================================================================*/
BOOL CPA_EditorBase::fn_bIsRegisterModificationType(CString _csObjectType, CString _csModificationType)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo(_csObjectType);
return (p_stList ? fn_bIsRegisterModificationType(p_stList, _csModificationType) : FALSE );
}
/*===========================================================================
=========================================================================*/
BOOL CPA_EditorBase::fn_bIsRegisterModificationType(tdstModifiedObjectsInfo *p_stMOI, CString _csModificationType)
{
POSITION stPos = p_stMOI -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPos )
{
if( p_stMOI -> m_oListOfModifiedObjects . GetNext( stPos ) -> m_ocsModificationTypeName == _csModificationType )
return TRUE;
}
return FALSE;
}
/*===========================================================================
=========================================================================*/
tdstModifiedObjectsInfo *CPA_EditorBase::fn_p_stGetMOInfo(CString _csObjectType)
{
POSITION stPos = m_oListOfModifiedReachableObjects . GetHeadPosition();
while ( stPos )
{
tdstModifiedObjectsInfo *p_stList = m_oListOfModifiedReachableObjects . GetNext( stPos );
if( p_stList -> m_oObjectType == _csObjectType )
return p_stList;
}
return NULL;
}
/*===========================================================================
=========================================================================*/
tdstReachableObjectListNamed *CPA_EditorBase::fn_p_stGetROLN(CString _csObjectType, CString _csModificationType)
{
tdstModifiedObjectsInfo *p_stList = fn_p_stGetMOInfo(_csObjectType);
return (p_stList ? fn_p_stGetROLN(p_stList, _csModificationType) : NULL );
}
/*===========================================================================
=========================================================================*/
tdstReachableObjectListNamed *CPA_EditorBase::fn_p_stGetROLN(tdstModifiedObjectsInfo *_p_stMOI, CString _csModificationType)
{
POSITION stPos = _p_stMOI -> m_oListOfModifiedObjects . GetHeadPosition();
while ( stPos )
{
tdstReachableObjectListNamed *p_stList = _p_stMOI -> m_oListOfModifiedObjects . GetNext( stPos );
if( p_stList -> m_ocsModificationTypeName == _csModificationType )
return p_stList;
}
return NULL;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,552 @@
//=========================================================================
// CPACont.cpp : implementation of the CPA_Contact class
// This is a part of the CPA project.
//
// Version 1.0
// Creation date 13/06/96
// Revision date
//
// (c) Ubi Studios 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPACont.Hpp"
#include "itf/CPARes.h"
#include "itf/DEVMulti.hpp"
#include "itf/ToolDLLb.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAInter.hpp"
/////////////////////////////////////////////////////////////////////////////
// Local Macros
#define M_GetListOfToolDLLFromMsg() M_GetMainWorld()->GetToolDLLReceivingWindowMsg()
#define M_ForEachToolDLL(p_oTool) \
CPA_ToolDLLBase *p_oTool; \
POSITION stPos; \
for( p_oTool = M_GetListOfToolDLLFromMsg()->GetHeadElement(stPos) ; \
p_oTool ; \
p_oTool = M_GetListOfToolDLLFromMsg()->GetNextElement(stPos) )
/////////////////////////////////////////////////////////////////////////////
// CPA_Contact
IMPLEMENT_DYNCREATE(CPA_Contact, CObject)
/////////////////////////////////////////////////////////////////////////////
// CPA_Contact construction/destruction
CPA_Contact::CPA_Contact(DEV_MultiDevice *p_oDevice)
{
m_p_oDevice = p_oDevice;
}
CPA_Contact::~CPA_Contact()
{
}
CPA_Interface * CPA_Contact::GetInterface (void)
{
return m_p_oDevice->GetInterface();
}
//###########################################################################
// processing of messages coming from viewport
// Default implementation : send the message to the EvtEditor if it exists.
//###########################################################################
BOOL CPA_Contact::_OnCommand(UINT IDCmdMsg)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnCommand(IDCmdMsg) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnCommand(IDCmdMsg);
}
// send message to EvtEditor
return M_GetEditor()->_OnCommand(IDCmdMsg);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnUpdateCommandUI(CCmdUI *pCmdUI)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnUpdateCommandUI(pCmdUI->m_nID, pCmdUI) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnUpdateCommandUI(pCmdUI->m_nID, pCmdUI);
}
// send message to EvtEditor
return M_GetEditor()->_OnUpdateCommandUI(pCmdUI->m_nID, pCmdUI);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnKeyDown(nChar, nRepCnt, nFlags) == TRUE)
return TRUE;
}
// send message to DLL of selected object
if ((M_GetCountSelected() == 1) && (M_GetSingleSelection()->GetObjectDLL() != NULL))
{
if (M_GetSingleSelection()->GetObjectDLL()->_OnKeyDown(nChar, nRepCnt, nFlags) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnKeyDown(nChar, nRepCnt, nFlags);
}
// send it to EvtEditor
return M_GetEditor()->_OnKeyDown(nChar, nRepCnt, nFlags);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnKeyUp(nChar, nRepCnt, nFlags) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnKeyUp(nChar, nRepCnt, nFlags);
}
// send it to EvtEditor
return M_GetEditor()->_OnKeyUp(nChar, nRepCnt, nFlags);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnMouseMove(UINT nFlags, tdstMousePos *p_stPos, MTH3D_tdstVector *p_stObject)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnMouseMove(nFlags, p_stPos, p_stObject) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnMouseMove(nFlags, p_stPos, p_stObject);
}
// send it to EvtEditor
return M_GetEditor()->_OnMouseMove(nFlags, p_stPos, p_stObject);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnLButtonDblClk(UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stObject)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnLButtonDblClk(nFlags, p_stPos, xIndex, p_stObject) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnLButtonDblClk(nFlags, p_stPos, xIndex, p_stObject);
}
// send it to EvtEditor
return M_GetEditor()->_OnLButtonDblClk(nFlags, p_stPos, xIndex, p_stObject);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnLButtonDown(UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stObject)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnLButtonDown(nFlags, p_stPos, xIndex, p_stObject) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnLButtonDown(nFlags, p_stPos, xIndex, p_stObject);
}
// send it to EvtEditor
return M_GetEditor()->_OnLButtonDown(nFlags, p_stPos, xIndex, p_stObject);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnLButtonUp(UINT nFlags, tdstMousePos *p_stPos)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnLButtonUp(nFlags, p_stPos) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnLButtonUp(nFlags, p_stPos);
}
// send it to EvtEditor
return M_GetEditor()->_OnLButtonUp(nFlags, p_stPos);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnRButtonDblClk(UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stObject)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnRButtonDblClk(nFlags, p_stPos, xIndex, p_stObject) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnRButtonDblClk(nFlags, p_stPos, xIndex, p_stObject);
}
// send it to EvtEditor
return M_GetEditor()->_OnRButtonDblClk(nFlags, p_stPos, xIndex, p_stObject);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnRButtonUp(UINT nFlags, tdstMousePos *p_stPos)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnRButtonUp(nFlags, p_stPos) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnRButtonUp(nFlags, p_stPos);
}
// send it to EvtEditor
return M_GetEditor()->_OnRButtonUp(nFlags, p_stPos);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnRButtonDown(UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stObject)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnRButtonDown(nFlags, p_stPos, xIndex, p_stObject) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnRButtonDown(nFlags, p_stPos, xIndex, p_stObject);
}
// send it to EvtEditor
return M_GetEditor()->_OnRButtonDown(nFlags, p_stPos, xIndex, p_stObject);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnDragDropEnd(WPARAM wParam, LPARAM lParam)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnDragDropEnd(wParam, lParam) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnDragDropEnd(wParam, lParam);
}
// send it to EvtEditor
return M_GetEditor()->_OnDragDropEnd(wParam, lParam);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnDragDropLooseFocus(WPARAM wParam, LPARAM lParam)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnDragDropLooseFocus(wParam, lParam) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnDragDropLooseFocus(wParam, lParam);
}
// send it to EvtEditor
return M_GetEditor()->_OnDragDropLooseFocus(wParam, lParam);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnDragDropGainFocus(WPARAM wParam, LPARAM lParam)
{
ASSERT (m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnDragDropGainFocus(wParam, lParam) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnDragDropGainFocus(wParam, lParam);
}
return M_GetEditor()->_OnDragDropGainFocus(wParam, lParam);
}
return FALSE;
}
//---------------------------------------------------------------------------
BOOL CPA_Contact::_OnDragDropMove(WPARAM wParam, LPARAM lParam)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->_OnDragDropMove(wParam, lParam) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->_OnDragDropMove(wParam, lParam);
}
// send it to EvtEditor
return M_GetEditor()->_OnDragDropMove(wParam, lParam);
}
return FALSE;
}
//---------------------------------------------------------------------------
void CPA_Contact::fn_vBeforeDrawingWorld(GLD_tdstViewportAttributes *p1, GLI_tdxHandleToLight p2, DEV_ViewPort* p3)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
M_GetCurrentEditor()->fn_vBeforeDrawingWorld(p1,p2,p3);
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->fn_vBeforeDrawingWorld(p1,p2,p3);
}
// send it to EvtEditor
M_GetEditor()->fn_vBeforeDrawingWorld(p1,p2,p3);
}
}
//---------------------------------------------------------------------------
void CPA_Contact::fn_vAddObjectsToDraw(GLD_tdstViewportAttributes *p1, GLI_tdxHandleToLight p2, DEV_ViewPort* p3)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
M_GetCurrentEditor()->fn_vAddObjectsToDraw(p1,p2,p3);
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->fn_vAddObjectsToDraw(p1,p2,p3);
}
// send it to EvtEditor
M_GetEditor()->fn_vAddObjectsToDraw(p1,p2,p3);
}
}
//---------------------------------------------------------------------------
void CPA_Contact::fn_vAddObjectsToDraw2(GLD_tdstViewportAttributes *p1, GLI_tdxHandleToLight p2)
{
ASSERT(m_p_oDevice != NULL);
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
M_GetCurrentEditor()->fn_vAddObjectsToDraw2(p1,p2);
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->fn_vAddObjectsToDraw2(p1,p2);
}
// send it to EvtEditor
M_GetEditor()->fn_vAddObjectsToDraw2(p1,p2);
}
}
//###########################################################################
// processing of messages coming from ACP
// Default implementation : nothing.
//###########################################################################
//---------------------------------------------------------------------------
BOOL CPA_Contact::fn_bPreTranslateMessage(MSG *p_stMsg)
{
if (GetInterface())
{
// send message to current editor
if (!M_IsCurrentEditor())
{
if (M_GetCurrentEditor()->fn_bPreTranslateMessage(p_stMsg) == TRUE)
return TRUE;
}
// send message to Tool DLLs
M_ForEachToolDLL(p_oToolDLL)
{
if (!p_oToolDLL->fn_bIsCurrentEditor())
p_oToolDLL->fn_bPreTranslateMessage(p_stMsg);
}
}
return FALSE;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,446 @@
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include <sys/timeb.h>
#include "itf/CPAProj.hpp"
#include "itf/DEVMul3D.hpp"
#include "itf/CPADD.hpp"
#include "itf/CPARes.h"
// For rectangles
static int gs_iNumOfRects = 0;
typedef struct DD_tdstRect_
{
RECT stRect;
HWND hWnd;
} DD_tdstRect;
#define DD_C_MaxRects 50
static DD_tdstRect gs_a_stRects[DD_C_MaxRects];
// for timer
UINT gs_uiTimer;
UINT gs_uiElapseScroll = 500;
int gs_iRect = -1;
//==================================================================
// REFERENCES
//==================================================================
// Search a reference to a window in array of all references
BOOL DD_bSearchReference(HWND hWnd, char *p_szName, UINT uiDataType, BOOL *p_bCopy)
{
int iIndex;
for(iIndex = 0; iIndex < M_GetMainApp()->m_iNumRef; iIndex++)
{
if
(
(M_GetMainApp()->m_a_WndRef[iIndex].hWnd == hWnd)
&& (!strcmpi(p_szName, M_GetMainApp()->m_a_WndRef[iIndex].p_szEditorName))
&& (M_GetMainApp()->m_a_WndRef[iIndex].uiDataType == uiDataType)
)
{
*p_bCopy = M_GetMainApp()->m_a_WndRef[iIndex].bCopyOnly;
return TRUE;
}
}
return FALSE;
}
// Add a reference to a window that can receive a dragdrop object
tdeDDError DD_eAddReference(HWND hWnd, char *p_szName, UINT uiDataType, BOOL bCopy)
{
BOOL bTemp;
// Too much references already define
if(M_GetMainApp()->m_iNumRef == C_ucMaxCWndRef)
return E_DDERR_TooMuchRef;
// Reference always exists
if(DD_bSearchReference(hWnd, p_szName, uiDataType, &bTemp))
return E_DDERR_None;
// Add reference
M_GetMainApp()->m_a_WndRef[M_GetMainApp()->m_iNumRef].hWnd = hWnd;
M_GetMainApp()->m_a_WndRef[M_GetMainApp()->m_iNumRef].p_szEditorName = p_szName;
M_GetMainApp()->m_a_WndRef[M_GetMainApp()->m_iNumRef].uiDataType = uiDataType;
M_GetMainApp()->m_a_WndRef[M_GetMainApp()->m_iNumRef++].bCopyOnly = bCopy;
return E_DDERR_None;
}
// Delete a reference to a window (all types)
tdeDDError DD_eDelReference(HWND hWnd)
{
int iIndex;
BOOL bOk = FALSE;
for(iIndex = 0; iIndex < M_GetMainApp()->m_iNumRef; iIndex++)
{
if(M_GetMainApp()->m_a_WndRef[iIndex].hWnd == hWnd)
{
memmove(&M_GetMainApp()->m_a_WndRef[iIndex], &M_GetMainApp()->m_a_WndRef[iIndex+1], M_GetMainApp()->m_iNumRef - iIndex);
M_GetMainApp()->m_iNumRef--;
bOk = TRUE;
}
}
if(bOk)
return E_DDERR_None;
else
return E_DDERR_UnknownRef;
}
// Delete a reference to a window with a special type
tdeDDError DD_eDelReferenceType(HWND hWnd, char *p_szName, UINT uiDataType)
{
int iIndex;
for(iIndex = 0; iIndex < M_GetMainApp()->m_iNumRef; iIndex++)
{
if
(
(M_GetMainApp()->m_a_WndRef[iIndex].hWnd == hWnd)
&& (!strcmpi(p_szName, M_GetMainApp()->m_a_WndRef[iIndex].p_szEditorName))
&& (M_GetMainApp()->m_a_WndRef[iIndex].uiDataType == uiDataType)
)
{
memmove(&M_GetMainApp()->m_a_WndRef[iIndex], &M_GetMainApp()->m_a_WndRef[iIndex+1], M_GetMainApp()->m_iNumRef - iIndex);
M_GetMainApp()->m_iNumRef--;
return E_DDERR_None;
}
}
return E_DDERR_UnknownRef;
}
// Delete all references
void DD_vDelAllReferences(void)
{
M_GetMainApp()->m_iNumRef = 0;
}
//==================================================================
// Drag & Drop
//==================================================================
// Determins what type of mouse pointer must be drawn regardless to window
// under mouse.
// Set M_GetMainApp()->m_bCanDrop global variable.
void DD_vCanDrop(HWND hWnd, char *p_szEditorName, UINT uiDataType)
{
HCURSOR hcursor;
BOOL bCopy;
// Is Window reference ?
if(hWnd && (DD_bSearchReference(hWnd, p_szEditorName, uiDataType, &bCopy)))
{
M_GetMainApp()->m_bCanDrop = TRUE;
// Copy if CONTROL key is pressed or if window only accept copy objects
if(M_GetMainApp()->m_bControl || bCopy)
{
hcursor = AfxGetApp()->LoadCursor(CPA_IDC_DRAGCOPY);
M_GetMainApp()->m_bCopy = TRUE;
}
else
{
hcursor = AfxGetApp()->LoadCursor(CPA_IDC_DRAGMOVE);
M_GetMainApp()->m_bCopy = FALSE;
}
}
else
{
M_GetMainApp()->m_bCanDrop = FALSE;
M_GetMainApp()->m_bCopy = FALSE;
hcursor = AfxGetApp()->LoadCursor(CPA_IDC_DRAGNONE);
}
::SetCursor(hcursor);
}
// Test if p_Wnd is loosing or gaining the focus of drag & drop
// That function is call only if cursor pos has changed
void DD_vDeterminsFocus(HWND hWnd, DD_Object *p_stDDObject)
{
if (hWnd != M_GetMainApp()->m_LastFocusWnd)
{
// Send a loosing focus message to last window
if(M_GetMainApp()->m_LastFocusWnd)
::SendMessage(M_GetMainApp()->m_LastFocusWnd, WM_DRAGDROP_LOOSEFOCUS, 0, (LPARAM) p_stDDObject);
// If there's a new window that accept drop, we send a message to it
if(hWnd && M_GetMainApp()->m_bCanDrop)
::SendMessage(hWnd, WM_DRAGDROP_GAINFOCUS, 0, (LPARAM) p_stDDObject);
}
else if (hWnd)
{
// Mouse move in the same window than last one
::SendMessage(hWnd, WM_DRAGDROP_MOVE, 0, (LPARAM) p_stDDObject);
}
// Last focus window is now new one
M_GetMainApp()->m_LastFocusWnd = hWnd;
}
// Get mouse position with a LPARAM parameter
// Set m_stMousePos with current value of mouse position
void DD_vGetMousePos(LPARAM lParam, DD_Object *p_stDDObject)
{
GetCursorPos(&M_GetMainApp()->m_stMousePos);
/* M_GetMainApp()->m_stMousePos.x = LOWORD(lParam);
M_GetMainApp()->m_stMousePos.y = HIWORD(lParam);
p_stDDObject->fn_p_stGetOwner()->ClientToScreen(&M_GetMainApp()->m_stMousePos);*/
p_stDDObject->m_stMousePos.x = M_GetMainApp()->m_stMousePos.x;
p_stDDObject->m_stMousePos.y = M_GetMainApp()->m_stMousePos.y;
}
// Finish a drag & drop operation
// Send a message to current window if it accepts drag & drop
// Restore mouse cursor
void DD_vFinish(DD_Object *p_stDDObject)
{
// Send a end of drag & drop message to current window if it's possible, else
// send a loose focus
if(M_GetMainApp()->m_bCanDrop)
::SendMessage(M_GetMainApp()->m_LastFocusWnd, WM_DRAGDROP_END, (WPARAM) M_GetMainApp()->m_bCopy, (LPARAM) p_stDDObject);
else
::SendMessage(M_GetMainApp()->m_LastFocusWnd, WM_DRAGDROP_LOOSEFOCUS, 0, (LPARAM) p_stDDObject);
// Restore initial mouse cursor
::SetCursor(M_GetMainApp()->m_hFirstCursor);
}
// Register a special rectangle
void DD_vRegisterRect(RECT *p_stRect, HWND hWnd)
{
if(gs_iNumOfRects == DD_C_MaxRects)
return;
memcpy(&gs_a_stRects[gs_iNumOfRects].stRect, p_stRect, sizeof(RECT));
gs_a_stRects[gs_iNumOfRects++].hWnd = hWnd;
}
// change timer elapse time
void DD_vSetScrollTime( UINT uiTime )
{
gs_uiElapseScroll = uiTime;
}
// Determins if mouse is in a rect
int fn_iIsInRect(void)
{
int i;
for(i = 0; i < gs_iNumOfRects; i++)
{
if(gs_a_stRects[i].hWnd == M_GetMainApp()->m_LastFocusWnd)
{
POINT pt;
RECT *r = &gs_a_stRects[i].stRect;
GetCursorPos(&pt);
if((pt.x >= r->left ) && (pt.x <= r->right) && (pt.y >= r->top) && (pt.y <= r->bottom))
return i;
}
}
return gs_iNumOfRects;
}
// Treat registered rectangles
void fn_vTreatRects(DD_Object *p_stDDObject)
{
int iRes;
iRes = fn_iIsInRect();
if(iRes < gs_iNumOfRects)
{
if (gs_iRect == -1)
{
gs_uiTimer = SetTimer(NULL, 1, gs_uiElapseScroll, NULL );
gs_iRect = iRes;
}
}
else
{
if (gs_iRect != -1)
{
KillTimer( NULL, gs_uiTimer );
gs_iRect = -1;
}
}
}
// Begin a drag & drop operation
// p_Rect : Rect to begin drag & drop
// p_stObject : Object to transmit
HWND DD_hBeginDragDrop(RECT *p_Rect, DD_Object *p_stDDObject)
{
BOOL bOutOfRect = FALSE;
BOOL bEndOfLoop = FALSE;
BOOL bCanDispatch;
MSG stMsg;
// Inits
//------
M_GetMainApp()->m_bCanDrop = FALSE;
M_GetMainApp()->m_bCopy = FALSE;
M_GetMainApp()->m_bControl = FALSE;
M_GetMainApp()->m_hFirstCursor = ::GetCursor();
// Wait mouse to go out of first rect area
//----------------------------------------
while (bEndOfLoop == FALSE)
{
::GetMessage(&stMsg, NULL, 0, 0);
switch(stMsg.message)
{
case WM_MOUSEMOVE:
DD_vGetMousePos(stMsg.lParam, p_stDDObject);
if (!::PtInRect(p_Rect, M_GetMainApp()->m_stMousePos))
{
bOutOfRect = TRUE;
bEndOfLoop = TRUE;
break;
}
break;
case WM_LBUTTONUP:
bEndOfLoop = TRUE;
break;
}
::TranslateMessage(&stMsg);
::DispatchMessage(&stMsg);
}
// A drag & drop is beginnig if bOutOfRect is set to TRUE
//-------------------------------------------------------
if (bOutOfRect)
{
// Source window capture mouse
//----------------------------
ASSERT(p_stDDObject->fn_p_stGetOwner() != NULL);
p_stDDObject->m_p_oGrabCaptureFor(p_stDDObject->fn_p_stGetOwner());
bEndOfLoop = FALSE;
// The last wnd under mouse is window that owns object
M_GetMainApp()->m_LastFocusWnd = p_stDDObject->fn_p_stGetOwner()->GetSafeHwnd();
while(bEndOfLoop == FALSE)
{
HWND hWndUnder; // Current window under mouse
::GetMessage(&stMsg, NULL, 0, 0);
bCanDispatch = TRUE; // Can dispatch messages ?
switch(stMsg.message)
{
case WM_TIMER:
if (stMsg.wParam == gs_uiTimer)
{
// we are in a scroll rect, send DRAGDROP_SCROLL message
::SendMessage(M_GetMainApp()->m_LastFocusWnd, WM_DRAGDROP_SCROLL, 0, (LPARAM) &gs_a_stRects[gs_iRect].stRect);
// Don't dispatch the message
bCanDispatch = FALSE;
}
break;
case WM_MOUSEMOVE:
// Coords of mouse
DD_vGetMousePos(stMsg.lParam, p_stDDObject);
// Get window under mouse
hWndUnder = WindowFromPoint(M_GetMainApp()->m_stMousePos);
// specific for 2nd screen
if (M_GetMainApp()->GetInterface()->fn_bGetAutomaticSwap())
{
// get active device & viewport
DEV_MultiDevice3D * pMulti = (DEV_MultiDevice3D *) M_GetMainDevice2();
DEV_ViewPort3D * pViewport = (DEV_ViewPort3D *) M_GetActiveViewport(pMulti);
// call this function to detect swap
pViewport->DetectMouseSwap();
// update active window
if (!M_GetMainApp()->m_bCursorInFirstScreen)
hWndUnder = pViewport->GetSafeHwnd();
else if (hWndUnder == pViewport->GetSafeHwnd())
hWndUnder = NULL;
}
// Window under mouse accept drag & drop ?
DD_vCanDrop(hWndUnder, p_stDDObject->fn_p_szGetEditorName(), p_stDDObject->fn_uiGetDataType());
// Treat focus messages
DD_vDeterminsFocus(hWndUnder, p_stDDObject);
// Don't dispatch message
bCanDispatch = FALSE;
break;
case WM_RBUTTONDOWN:
M_GetMainApp()->m_bCanDrop = FALSE;
DD_vFinish(p_stDDObject);
bEndOfLoop = TRUE;
// Don't dispatch message
bCanDispatch = FALSE;
break;
case WM_LBUTTONUP:
DD_vFinish(p_stDDObject);
bEndOfLoop = TRUE;
// Don't dispatch message
bCanDispatch = FALSE;
break;
// For copying object instead of moving it
case WM_KEYDOWN:
if(stMsg.wParam == VK_CONTROL)
{
M_GetMainApp()->m_bControl = TRUE;
// To redraw mouse cursor
DD_vCanDrop(M_GetMainApp()->m_LastFocusWnd, p_stDDObject->fn_p_szGetEditorName(), p_stDDObject->fn_uiGetDataType());
// Don't dispatch message
bCanDispatch = FALSE;
}
break;
case WM_KEYUP:
if(stMsg.wParam == VK_CONTROL)
{
M_GetMainApp()->m_bControl = FALSE;
DD_vCanDrop(M_GetMainApp()->m_LastFocusWnd, p_stDDObject->fn_p_szGetEditorName(), p_stDDObject->fn_uiGetDataType());
// Don't dispatch message
bCanDispatch = FALSE;
}
break;
}
// Can we dispatch message ?
if(bCanDispatch)
{
::TranslateMessage(&stMsg);
::DispatchMessage(&stMsg);
}
// Treat registered rectangles
if(bEndOfLoop == FALSE)
fn_vTreatRects(p_stDDObject);
}
// We restore mouse capture
//-------------------------
p_stDDObject->m_p_oSurrenderCapture();
}
// No rects
gs_iNumOfRects = 0;
// set elapse time to default value
gs_uiElapseScroll = 500;
// kill timer if still in a rectangle
if (gs_iRect != -1)
{
KillTimer( NULL, gs_uiTimer );
gs_iRect = -1;
}
// Return handle of window that accepted Drag & Drop
if(M_GetMainApp()->m_bCanDrop)
return M_GetMainApp()->m_LastFocusWnd;
else
return NULL;
}
#endif // ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,69 @@
//=========================================================================
// CPADgCam.cpp : implementation file for dialog box of camera properties
// This is a part of the CPA project.
//
// Version 1.0
// Creation date 16/07/96
// Revision date
//
// (c) Ubi Studios 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================
// CPADgCam.cpp : implementation file
//
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPADgCam.hpp"
#include "itf/CPAProj.hpp"
#include "itf/FrmGest.hpp"
/////////////////////////////////////////////////////////////////////////////
// CPA_DialogCamera dialog
CPA_DialogCamera::CPA_DialogCamera(CWnd* pParent /*=NULL*/)
: CDialog(CPA_DialogCamera::IDD, &g_oBaseFrame)
{
//{{AFX_DATA_INIT(CPA_DialogCamera)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
int CPA_DialogCamera::DoModal(void)
{
int iRes;
M_GetMainWnd()->EnableWindow(FALSE);
GetParent()->EnableWindow(FALSE);
EnableWindow(TRUE);
iRes = RunModalLoop();
GetParent()->EnableWindow(TRUE);
M_GetMainWnd()->EnableWindow(TRUE);
return iRes;
}
void CPA_DialogCamera::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogCamera)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Radio(pDX, CPA_IDC_RADIO1, m_iTranslate);
DDX_Radio(pDX, CPA_IDC_RADIO_1, m_iRotate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPA_DialogCamera, CDialog)
//{{AFX_MSG_MAP(CPA_DialogCamera)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_DialogCamera message handlers
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,683 @@
/*=========================================================================
*
* CPAdIns.cpp : Insertion - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdIns.hpp"
#include "itf/CPADD.hpp"
#include "itf/DEVVp3D.hpp"
#include "itf/DEVMul3D.hpp"
#include "itf/CPAProj.hpp"
#include "itf/CPAInter.hpp"
#include "itf/CPAMWorl.hpp"
#include "x:\cpa\main\inc\_EditID.h"
#include "TUT.h"
#include <direct.h>
//#################################################################################
// CPA_DialogInsert dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_DialogInsert::CPA_DialogInsert(CWnd* pParent)
: CFormView(CPA_DialogInsert::IDD)
{
//{{AFX_DATA_INIT(CPA_DialogInsert)
//}}AFX_DATA_INIT
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogInsert)
DDX_Control(pDX, CPA_IDC_NEWMODEL, m_cNewModel);
DDX_Control(pDX, CPA_IDC_DELMODEL, m_cDelModel);
DDX_Control(pDX, CPA_IDC_CHANGEICON, m_cModelIcon);
DDX_Control(pDX, CPA_IDC_SAVELIST, m_cSaveList);
DDX_Control(pDX, CPA_IDC_LOADLIST, m_cLoadList);
DDX_Control(pDX, CPA_IDC_COMBOTYPE, m_cComboType);
//}}AFX_DATA_MAP
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogInsert, CFormView)
//{{AFX_MSG_MAP(CPA_DialogInsert)
ON_CBN_SELCHANGE(CPA_IDC_COMBOTYPE, OnSelchangeCombotype)
ON_BN_CLICKED(CPA_IDC_NEWMODEL, OnNewModel)
ON_BN_CLICKED(CPA_IDC_DELMODEL, OnDelModel)
ON_BN_CLICKED(CPA_IDC_CHANGEICON, OnModelIcon)
ON_BN_CLICKED(CPA_IDC_SAVELIST, OnSaveList)
ON_BN_CLICKED(CPA_IDC_LOADLIST, OnLoadList)
ON_WM_SIZE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// CPA_DialogInsert dialog
//#################################################################################
/*===========================================================================
* Description: Init the dialog
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_DialogInsert::fn_vInitDialog (CPA_Interface *pInterface, FRMBase *pFrame)
{
// create the dialog
m_bInitialised = FALSE;
m_p_oInterface = pInterface;
CFormView::Create(NULL, "", WS_VISIBLE|WS_CHILD/*AFX_WS_DEFAULT_VIEW*/, CRect(0,0,0,0), pFrame, AFX_IDW_PANE_FIRST, NULL);
// update data
CFormView::UpdateData(FALSE);
// init the combo box
GetInterface()->SetCurrentModel(NULL);
m_csTypeInsert = "All Types";
// init the list box
m_iNumDesc = -1;
m_pListModels = NULL;
m_lNbValidNew = 0;
m_lNbValidLoad = 0;
m_ePopupMode = E_pm_NoMode;
m_bInitialised = TRUE;
// register controls
TUT_M_vGetTutDll();
TUT_M_vRegisterControlID( CPA_IDC_NEWMODEL, "ITF_MODEL_BTNEW", TUT_e_Button );
TUT_M_vRegisterControlID( CPA_IDC_DELMODEL, "ITF_MODEL_BTDEL", TUT_e_Button );
TUT_M_vRegisterControlID( CPA_IDC_CHANGEICON, "ITF_MODEL_BTICON", TUT_e_Button );
TUT_M_vRegisterControlID( CPA_IDC_SAVELIST, "ITF_MODEL_BTSAVE", TUT_e_Button );
TUT_M_vRegisterControlID( CPA_IDC_LOADLIST, "ITF_MODEL_BTLOAD", TUT_e_Button );
TUT_M_vRegisterControlID( CPA_IDC_COMBOTYPE, "ITF_MODEL_CBTYPE", TUT_e_ComboBox );
}
/*===========================================================================
* Description: init the combo box
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_DialogInsert::fn_vInitComboType (CString csListName)
{
CPA_ObjectDLLBase *p_oDLL;
EDT_ModelsByType *pListType;
POSITION pos;
int iInd;
// RAZ
m_cComboType.ResetContent();
m_lNbValidNew = 0;
m_lNbValidLoad = 0;
m_cComboType.AddString("All Types");
// fill the list of the combo with the available types
for (pListType = GetInterface()->GetListOfModelsByType()->GetHeadElement(pos); pListType;
pListType = GetInterface()->GetListOfModelsByType()->GetNextElement(pos))
m_cComboType.AddString(pListType->GetTypeName());
// set the current selection (Select Mode)
if (csListName.IsEmpty())
{
m_csTypeInsert = "All Types";
m_cComboType.SetCurSel(0);
}
else
{
m_csTypeInsert = csListName;
iInd = m_cComboType.FindStringExact(-1, csListName);
m_cComboType.SetCurSel(iInd);
}
// update flags
iInd = 0;
do
{
p_oDLL = M_GetMainWorld()->GetListOfObjectDLLBase()->FindElementFromIndex(iInd);
if ((p_oDLL)&&(p_oDLL->fn_bCanLoadNewModel("All Types")))
m_lNbValidNew++;
if ((p_oDLL)&&(p_oDLL->fn_bCanLoadListModels()))
m_lNbValidLoad++;
iInd++;
}
while (p_oDLL);
// update the list
fn_vUpdateListModel();
}
/*===========================================================================
* Description: init the combo box
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_DialogInsert::fn_vSetCurrentListModel (CString csListName)
{
int iInd;
// set the current selection (Select Mode)
iInd = m_cComboType.FindStringExact(-1, csListName);
if (iInd != -1)
{
m_csTypeInsert = csListName;
m_cComboType.SetCurSel(iInd);
}
else
{
m_csTypeInsert = "All Types";
m_cComboType.SetCurSel(0);
}
// update the list
fn_vUpdateListModel();
}
/*===========================================================================
* Description: init the list box
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_DialogInsert::fn_vReinitListModel (void)
{
RECT AbsolutePosition, WindowPosition;
int px, py, cx, cy;
// Calculate the position of the dialog
GetDlgItem(CPA_IDC_NEWDIALOG)->GetWindowRect(&AbsolutePosition);
GetWindowRect(&WindowPosition);
px = AbsolutePosition.left - WindowPosition.left;
py = AbsolutePosition.top - WindowPosition.top;
cx = WindowPosition.right - WindowPosition.left - 2*px;
cy = WindowPosition.bottom - WindowPosition.top - py - 10;
// move the new dialog
if (m_pListModels)
{
m_pListModels->MoveWindow(px, py , cx, cy);
m_pListModels->ShowWindow(SW_SHOW);
m_pListModels->EnableWindow(TRUE);
m_pListModels->Invalidate();
}
}
/*===========================================================================
* Description: update the list of models
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_DialogInsert::fn_vUpdateListModel (void)
{
EDT_ModelsByType *pListType;
// get list by type
pListType = GetInterface()->GetModelsWithTypeName(m_csTypeInsert);
if (!pListType)
pListType = GetInterface()->GetListAllModels();
// get model view
if (m_pListModels)
{
m_pListModels->ShowWindow(SW_HIDE);
m_pListModels->EnableWindow(FALSE);
}
m_pListModels = pListType->m_pModelView;
fn_vReinitListModel();
GetInterface()->SetCurrentModel(NULL);
// reinit controls
if (pListType != GetInterface()->GetListAllModels())
{
// init button "Del"
m_cDelModel.EnableWindow(pListType->CanDeleteModel());
// init button "New"
m_cNewModel.EnableWindow(pListType->CanLoadNewModel());
// init button "Icon"
m_cModelIcon.EnableWindow(pListType->CanChangeModelIcon());
// init button "Save"
m_cSaveList.EnableWindow(pListType->CanSaveList());
}
else
{
m_cDelModel.EnableWindow(FALSE);
m_cModelIcon.EnableWindow(FALSE);
m_cNewModel.EnableWindow((m_lNbValidNew > 0));
m_cSaveList.EnableWindow(FALSE);
}
// init button "Load"
m_cLoadList.EnableWindow((m_lNbValidLoad > 0));
// Update the current object to insert
if (m_pListModels->m_fn_lGetCount())
m_iNumDesc = 0;
else
m_iNumDesc = -1;
}
/*===========================================================================
* Description: load new model
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_DialogInsert::fn_vLoadNewModel (CPA_ObjectDLLBase *p_oDLL)
{
EDT_Model *pNewModel;
BOOL bRes;
if (!p_oDLL)
return;
// call the corresponding load function
pNewModel = p_oDLL->GetNewModel(m_csTypeInsert);
// test the type
if (pNewModel)
{
bRes = GetInterface()->fn_bAddANewModel(pNewModel, m_csTypeInsert, p_oDLL);
// test unicity
if (!bRes)
{
M_GetMainWnd()->MessageBox("This descriptor is already loaded",
"Sorry...", MB_ICONSTOP|MB_OK);
delete pNewModel;
return;
}
// update the list box
m_pListModels->Invalidate();
// update selection
GetInterface()->SetCurrentModel(pNewModel);
GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
}
}
/*===========================================================================
* Description: load model list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_DialogInsert::fn_vLoadListModels (CPA_ObjectDLLBase *p_oDLL)
{
CString csNewList;
if (p_oDLL)
csNewList = p_oDLL->fn_csLoadListModels();
// if there's a new list, update dialog
if (!csNewList.IsEmpty())
fn_vInitComboType(csNewList);
}
/*===========================================================================
* Description: load model list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_ObjectDLLBase * CPA_DialogInsert::GetSingleDllForNew (void)
{
CPA_ObjectDLLBase *p_oDLL;
long lIndex = 0;
do
{
p_oDLL = M_GetMainWorld()->GetListOfObjectDLLBase()->FindElementFromIndex(lIndex);
if ((p_oDLL)&&(p_oDLL->fn_bCanLoadNewModel(m_csTypeInsert)))
return p_oDLL;
lIndex++;
}
while (p_oDLL);
return NULL;
}
/*===========================================================================
* Description: load model list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_ObjectDLLBase * CPA_DialogInsert::GetSingleDllForLoad (void)
{
CPA_ObjectDLLBase *p_oDLL;
long lIndex = 0;
do
{
p_oDLL = M_GetMainWorld()->GetListOfObjectDLLBase()->FindElementFromIndex(lIndex);
if ((p_oDLL)&&(p_oDLL->fn_bCanLoadListModels()))
return p_oDLL;
lIndex++;
}
while (p_oDLL);
return NULL;
}
//#################################################################################
// CPA_DialogInsert message handlers
//#################################################################################
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::OnDestroy()
{
// register controls
TUT_M_vGetTutDll();
TUT_M_vUnregisterControlID( CPA_IDC_NEWMODEL );
TUT_M_vUnregisterControlID( CPA_IDC_DELMODEL );
TUT_M_vUnregisterControlID( CPA_IDC_SAVELIST );
TUT_M_vUnregisterControlID( CPA_IDC_LOADLIST );
TUT_M_vUnregisterControlID( CPA_IDC_COMBOTYPE );
//
CFormView::OnDestroy();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::OnSelchangeCombotype()
{
// find the type of object to insert
m_cComboType.GetLBText(m_cComboType.GetCurSel(), m_csTypeInsert);
// update the list of descriptors
fn_vUpdateListModel();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::OnNewModel()
{
CPA_ObjectDLLBase *p_oDLLInterface = NULL;
EDT_ModelsByType *pListType;
CPA_MainWorld *pMainWorld;
CMenu oMenu;
RECT WindowPosition;
long lIndex = 0;
int px, py;
// find the DLL interface corresponding to the choice in Combo Box
pListType = GetInterface()->GetModelsWithTypeName(m_csTypeInsert);
if (pListType)
p_oDLLInterface = pListType->GetDLL();
if ((m_csTypeInsert == "All Types")&&(m_lNbValidNew == 1))
p_oDLLInterface = GetSingleDllForNew();
if (p_oDLLInterface)
{
fn_vLoadNewModel(p_oDLLInterface);
return;
}
if (m_lNbValidNew == 0)
return;
// init mode
m_ePopupMode = E_pm_NewModel;
// create popup menu
oMenu.CreatePopupMenu();
// entries for DLLs
pMainWorld = M_GetMainWorld();
do
{
p_oDLLInterface = pMainWorld->GetListOfObjectDLLBase()->FindElementFromIndex(lIndex);
if ((p_oDLLInterface)&&(p_oDLLInterface->fn_bCanLoadNewModel(m_csTypeInsert)))
oMenu.AppendMenu(MF_STRING, lIndex, p_oDLLInterface->GetName());
lIndex++;
}
while (p_oDLLInterface);
if (!oMenu.GetMenuItemCount())
oMenu.AppendMenu(MF_STRING, lIndex, "No New Available");
// get position
m_cNewModel.GetWindowRect(&WindowPosition);
px = WindowPosition.right;
py = WindowPosition.top;
// register the popup menu for the tutorial module
TUT_M_vGetTutDll ();
TUT_M_vRegisterMenu (this -> m_hWnd , oMenu . m_hMenu , px , py);
// display & track popup menu
oMenu.TrackPopupMenu(TPM_RIGHTALIGN | TPM_LEFTBUTTON, px, py, this);
// destroy menus
oMenu.DestroyMenu();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::OnDelModel (void)
{
EDT_Model *pModel;
BOOL bRes;
// all types => cannot remove
if (m_csTypeInsert == "All Types")
return;
// get current model
pModel = GetInterface()->GetCurrentModel();
// remove it from the list
if (pModel)
bRes = GetInterface()->fn_bRemoveAModel(pModel->m_csName, m_csTypeInsert);
// update list
if (bRes)
{
GetInterface()->SetCurrentModel(NULL);
fn_vUpdateListModel();
GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
}
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::OnModelIcon (void)
{
EDT_Model *pModel;
CString csBitmapName;
BOOL bRes = FALSE;
// all types => cannot remove
if (m_csTypeInsert == "All Types")
return;
// get current model
pModel = GetInterface()->GetCurrentModel();
// remove it from the list
if (pModel && pModel->m_pObjectDLL)
{
// get name for new icon
csBitmapName = pModel->m_pObjectDLL->fn_csChangeModelIcon(m_csTypeInsert, pModel->m_csName);
// load new icon
bRes = pModel->fn_bChangeBitmap(GetInterface(), csBitmapName);
}
// update list
if (bRes)
{
EDT_ModelsByType *pListType;
// update model in local list
pListType = GetInterface()->GetModelsWithTypeName(m_csTypeInsert);
pListType->fn_vRemoveAModel(pModel);
pListType->fn_vAddANewModel(pModel);
// update model in global list
GetInterface()->GetListAllModels()->fn_vRemoveAModel(pModel);
GetInterface()->GetListAllModels()->fn_vAddANewModel(pModel);
// update drawing
fn_vUpdateListModel();
GetInterface()->fn_vUpdateAll(E_mc_UpdateDialog);
}
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::OnSaveList()
{
CPA_ObjectDLLBase *p_oDLLInterface;
EDT_ModelsByType *pListType;
// find the DLL interface corresponding to the choice in Combo Box
pListType = GetInterface()->GetModelsWithTypeName(m_csTypeInsert);
if (pListType)
p_oDLLInterface = pListType->GetDLL();
else
return;
// call the corresponding save function
p_oDLLInterface->fn_vSaveListModels(pListType->GetTypeName(), &pListType->m_stListModels);
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::OnLoadList()
{
CPA_ObjectDLLBase *p_oDLL;
CPA_MainWorld *pMainWorld;
CMenu oMenu;
RECT WindowPosition;
long lIndex = 0;
int px, py;
if (m_lNbValidLoad == 0)
return;
if (m_lNbValidLoad == 1)
{
p_oDLL = GetSingleDllForLoad();
fn_vLoadListModels(p_oDLL);
return;
}
// init mode
m_ePopupMode = E_pm_LoadList;
// create popup menu
oMenu.CreatePopupMenu();
// entries for DLLs
pMainWorld = M_GetMainWorld();
do
{
p_oDLL = pMainWorld->GetListOfObjectDLLBase()->FindElementFromIndex(lIndex);
if ((p_oDLL)&&(p_oDLL->fn_bCanLoadListModels()))
oMenu.AppendMenu(MF_STRING, lIndex, p_oDLL->GetName());
lIndex++;
}
while (p_oDLL);
if (!oMenu.GetMenuItemCount())
oMenu.AppendMenu(MF_STRING, lIndex, "No Load Available");
// get position
m_cLoadList.GetWindowRect(&WindowPosition);
px = WindowPosition.right;
py = WindowPosition.top;
// register the popup menu for the tutorial module
TUT_M_vGetTutDll ();
TUT_M_vRegisterMenu (this -> m_hWnd , oMenu . m_hMenu , px , py);
// display & track popup menu
oMenu.TrackPopupMenu(TPM_RIGHTALIGN | TPM_LEFTBUTTON, px, py, this);
// destroy menus
oMenu.DestroyMenu();
}
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogInsert::OnCommand (WPARAM wParam, LPARAM lParam)
{
CPA_ObjectDLLBase *p_oDLL;
CPA_MainWorld *pMainWorld;
long lIndex = 0;
// entries for DLLs
pMainWorld = M_GetMainWorld();
// command from a menu
if (HIWORD(wParam) == 0)
{
// get ID of menu item
lIndex = LOWORD(wParam);
// get corresponding DLL
p_oDLL = pMainWorld->GetListOfObjectDLLBase()->FindElementFromIndex(lIndex);
// do corresponding action
if (m_ePopupMode == E_pm_NewModel)
fn_vLoadNewModel(p_oDLL);
else if (m_ePopupMode == E_pm_LoadList)
fn_vLoadListModels(p_oDLL);
// update popup mode
m_ePopupMode = E_pm_NoMode;
}
return CFormView::OnCommand(wParam, lParam);
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogInsert::OnSize(UINT nType, int cx, int cy)
{
RECT AbsolutePosition, WindowPosition;
int px, py, cwx, cwy, crx, cx1, cry;
if (m_bInitialised)
{
GetWindowRect(&WindowPosition);
GetDlgItem(CPA_IDC_POSINSERT)->GetWindowRect(&AbsolutePosition);
// calculate relative position
cwx = WindowPosition.right - WindowPosition.left;
cwy = WindowPosition.bottom - WindowPosition.top;
crx = AbsolutePosition.right - AbsolutePosition.left;
cry = AbsolutePosition.bottom - AbsolutePosition.top;
py = AbsolutePosition.top - WindowPosition.top;
crx = (crx < cwx) ? crx : cwx - 10;
cx1 = (crx < 40) ? 40 : crx - 20;
px = (cwx - crx) / 2;
// move button "Del" and "New"
m_cNewModel.MoveWindow(px, py, cx1/11, cry-2);
m_cDelModel.MoveWindow(px + crx/11 , py, cx1/11, cry-2);
m_cModelIcon.MoveWindow(px + 2*crx/11 , py, cx1/11, cry-2);
// move Static and Combo
GetDlgItem(CPA_IDC_TEXT)->MoveWindow(px + 7*crx/22, py+4, cx1/11, cry);
m_cComboType.MoveWindow(px + 9*crx/22, py, 4*cx1/11, cry);
// move buttons "Save" and "Load"
m_cSaveList.MoveWindow(px + 9*crx/11, py, cx1/11, cry);
m_cLoadList.MoveWindow(px + 10*crx/11, py, cx1/11, cry);
// Move the list
fn_vReinitListModel();
}
return;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,107 @@
/*=========================================================================
*
* CPAdlang.cpp : CPA_DialogLanguage - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Xavier Billault
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdLang.hpp"
#include "itf/CPAInter.hpp"
//#################################################################################
// CPA_DialogLanguage dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_DialogLanguage::CPA_DialogLanguage(CPA_Interface *pclInterface,CStringList *pcslList,CWnd* pParent /*=NULL*/)
: CDialog(CPA_DialogLanguage::IDD, pParent)
{
m_pclInterface=pclInterface;
m_pcslLanguageList=pcslList;
//{{AFX_DATA_INIT(CPA_DialogLanguage)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogLanguage::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogLanguage)
//}}AFX_DATA_MAP
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogLanguage, CDialog)
//{{AFX_MSG_MAP(CPA_DialogLanguage)
ON_BN_CLICKED(ID_LANG_SAVE, OnSave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// CPA_DialogLanguage message handlers
//#################################################################################
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogLanguage::OnInitDialog ()
{
// Create the dialog
CDialog::OnInitDialog();
// init combo
CComboBox *pclCombo=(CComboBox *)GetDlgItem(IDC_LANG_COMBO);
pclCombo->ResetContent();
POSITION pos=m_pcslLanguageList->GetHeadPosition();
while(pos!=NULL)
{
pclCombo->AddString(m_pcslLanguageList->GetNext(pos));
}
pclCombo->SetCurSel(0);
return TRUE;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogLanguage::OnOK()
{
// set the current selection
CComboBox *pclCombo=(CComboBox *)GetDlgItem(IDC_LANG_COMBO);
pclCombo->GetLBText(pclCombo->GetCurSel(),m_csLanguage);
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogLanguage::OnSave ()
{
CComboBox *pclCombo=(CComboBox *)GetDlgItem(IDC_LANG_COMBO);
pclCombo->GetLBText(pclCombo->GetCurSel(),m_csLanguage);
m_pclInterface->fn_vSaveLanguage(m_csLanguage);
}
#endif // ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
//=========================================================================
// OBJDLLb.hpp : base of objects DLL
// This is a part of the CPA project.
//
// Version 1.0
// Creation date 10/06/96
// Revision date
//
// (c) Ubi Studio 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================
#include "stdafx.h"
#include <afxtempl.h>
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPADLLB.hpp"
#include "itf/FRMBase.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAInter.hpp"
//#include "CPAPubOb.hpp"
//=========================================================================
//=========================================================================
////
CPA_DLLBase::CPA_DLLBase()
{
SetCurrent(FALSE);
m_p_stDLLIdentity = NULL;
}
//=========================================================================
//=========================================================================
////
CPA_DLLBase::~CPA_DLLBase()
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// private
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif //ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
//=========================================================================
// CPADoc.cpp : implementation of the CPA_ProjectDoc class
// This is a part of the CPA project.
//
// Version 1.0
// Creation date 06/06/96
// Revision date
//
// (c) Ubi Studios 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================
#include "stdafx.h"
#include "Itf/CPADoc.hpp"
/////////////////////////////////////////////////////////////////////////////
// CPA_ProjectDoc
IMPLEMENT_DYNCREATE(CPA_ProjectDoc, CDocument)
BEGIN_MESSAGE_MAP(CPA_ProjectDoc, CDocument)
//{{AFX_MSG_MAP(CPA_ProjectDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_ProjectDoc construction/destruction
CPA_ProjectDoc::CPA_ProjectDoc()
{
}
CPA_ProjectDoc::~CPA_ProjectDoc()
{
}
BOOL CPA_ProjectDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CPA_ProjectDoc commands

View File

@@ -0,0 +1,199 @@
/*=========================================================================
*
* CPAdOpt.cpp : Option Dialog - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdOpt.hpp"
#include "itf/cpainter.hpp"
#include "itf/cohemngr.hpp"
#include "itf/cpaproj.hpp"
#include "itf/a3dkeyal.hpp"
//#################################################################################
// CPA_DialogOption dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_DialogOption::CPA_DialogOption(CWnd* pParent /*=NULL*/)
: CDialog(CPA_DialogOption::IDD, pParent)
{
//{{AFX_DATA_INIT(EDT_DialogFlag)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogOption::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogOption)
// general options
DDX_Control(pDX, CPA_IDC_AUTOCOHEMNGR, m_cCoheMngr);
DDX_Control(pDX, CPA_IDC_REINITMAP, m_cReinitMap);
DDX_Control(pDX, CPA_IDC_SCALEOBJECTS, m_cScaleEditor);
DDX_Control(pDX, CPA_IDC_PYRAMIDDEPTH, m_cPyramidDepth);
DDX_Control(pDX, CPA_IDC_TARGETDEPTH, m_cTargetDepth);
DDX_Control(pDX, CPA_IDC_AUTHORISATIONS, m_cAuthorisation);
DDX_Control(pDX, CPA_IDC_KEYBOARD, m_cKeyboard);
// move options
DDX_Control(pDX, CPA_IDC_ROTSTEP, m_cRotStep);
DDX_Control(pDX, CPA_IDC_TRANSTEP, m_cTranStep);
DDX_Control(pDX, CPA_IDC_GOTHROUGH, m_cGothrough);
DDX_Control(pDX, CPA_IDC_BLOCK, m_cBlock);
DDX_Control(pDX, CPA_IDC_SPEEDUP, m_cAccelerate);
//CPA2 Gabi Dumitrascu 98/07/09
//screen options
DDX_Control(pDX, IDC_CHECK_AUTOMATIC_SWAP, m_cAutomaticSwap);
DDX_Control(pDX, IDC_RADIO_SWAP_LEFT, m_cSwapLeft);
DDX_Control(pDX, IDC_RADIO_SWAP_RIGHT, m_cSwapRight);
DDX_Control(pDX, IDC_RADIO_SWAP_BOTH, m_cSwapBoth);
//End CPA2 Gabi Dumitrascu 98/07/09
//}}AFX_DATA_MAP
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogOption, CDialog)
//{{AFX_MSG_MAP(CPA_DialogOption)
ON_BN_CLICKED(CPA_IDC_AUTHORISATIONS, OnAuthorisation)
ON_BN_CLICKED(CPA_IDC_KEYBOARD, OnKeyboard)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// EDT_DialogFlag message handlers
//#################################################################################
/*----------------------------------------
----------------------------------------*/
void CPA_DialogOption::fn_vDoDialog (CPA_Interface *pInterface)
{
// init parameters
m_pInterface = pInterface;
// this dialog is modal
DoModal();
}
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogOption::OnInitDialog ()
{
float fDepth;
char szDepth[15];
// Create the dialog
CDialog::OnInitDialog();
// init general options
m_cCoheMngr.SetCheck(g_oCoherenceManager.m_fn_bIsCoherenceManagerDialogAutomatic());
m_cReinitMap.SetCheck(M_GetMainApp()->m_bAutoReinitTheMap);
m_cScaleEditor.SetCheck(m_pInterface->fn_bIsScaleActive());
// init pyramidal depth
fDepth = GetInterface()->GetPyramidalDepth();
sprintf(szDepth, "%8.4f", fDepth);
m_cPyramidDepth.SetWindowText(szDepth);
// init target depth
fDepth = GetInterface()->GetCameraTargetDepth();
sprintf(szDepth, "%8.4f", fDepth);
m_cTargetDepth.SetWindowText(szDepth);
// init move options
// ...
//CPA2 Gabi Dumitrascu 98/07/09
//init screen options
m_cAutomaticSwap.SetCheck (m_pInterface->fn_bGetAutomaticSwap ());
int nSwapID;
switch (m_pInterface->fn_eGetForceSwap())
{
case eSwapBoth : nSwapID = IDC_RADIO_SWAP_BOTH; break;
case eSwapLeft : nSwapID = IDC_RADIO_SWAP_LEFT; break;
case eSwapRight : nSwapID = IDC_RADIO_SWAP_RIGHT; break;
}
CheckRadioButton (IDC_RADIO_SWAP_LEFT, IDC_RADIO_SWAP_BOTH, nSwapID);
//End CPA2 Gabi Dumitrascu 98/07/09
return TRUE;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogOption::OnOK()
{
float fDepth;
char szDepth[15];
// register general options
g_oCoherenceManager.m_fn_vSetAutomaticCoherenceManagerDialog(m_cCoheMngr.GetCheck());
M_GetMainApp()->m_bAutoReinitTheMap = m_cReinitMap.GetCheck();
GetInterface()->fn_bSetScaleActive(m_cScaleEditor.GetCheck());
// register pyramidal depth
m_cPyramidDepth.GetWindowText(szDepth, 15);
fDepth = (float) atof (szDepth);
GetInterface()->SetPyramidalDepth(fDepth);
// register target depth
m_cTargetDepth.GetWindowText(szDepth, 15);
fDepth = (float) atof (szDepth);
GetInterface()->SetCameraTargetDepth(fDepth);
//CPA2 Gabi Dumitrascu 98/07/09
m_pInterface->fn_bSetAutomaticSwap (m_cAutomaticSwap.GetCheck ());
int nSwapID = GetCheckedRadioButton (IDC_RADIO_SWAP_LEFT, IDC_RADIO_SWAP_BOTH);
tdeForceSwap eForceSwap = eSwapRight;
switch (nSwapID)
{
case IDC_RADIO_SWAP_BOTH : eForceSwap = eSwapBoth; break;
case IDC_RADIO_SWAP_LEFT : eForceSwap = eSwapLeft; break;
case IDC_RADIO_SWAP_RIGHT : eForceSwap = eSwapRight; break;
}
m_pInterface->fn_eSetForceSwap (eForceSwap);
//End CPA2 Gabi Dumitrascu 98/07/09
// register options
GetInterface()->fn_vSaveOptions();
// close dialog
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogOption::OnCancel()
{
// close dialog
CDialog::OnCancel();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogOption::OnAuthorisation()
{
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogOption::OnKeyboard()
{
A3d_KeyboardAllConfDlg oDialog;
oDialog.DoModal();
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,148 @@
/*=========================================================================
*
* CPAdPref.cpp : Selection - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdPref.hpp"
#include "itf/CPAInter.hpp"
//#################################################################################
// CPA_DialogPrefix dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_DialogPrefix::CPA_DialogPrefix(CWnd* pParent /*=NULL*/)
: CDialog(CPA_DialogPrefix::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_DialogPrefix)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPrefix::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogPrefix)
DDX_Control(pDX, CPA_IDC_COMBOUSERS, m_cComboUsers);
DDX_Control(pDX, CPA_IDC_SAVEPREFIX, m_cSave);
//}}AFX_DATA_MAP
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogPrefix, CDialog)
//{{AFX_MSG_MAP(CPA_DialogPrefix)
ON_LBN_SELCHANGE(CPA_IDC_COMBOUSERS, OnSelChangeComboUsers)
ON_LBN_DBLCLK(CPA_IDC_COMBOUSERS, OnDblClkComboUsers)
ON_BN_CLICKED(CPA_IDC_SAVEPREFIX, OnSave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// CPA_DialogPrefix message handlers
//#################################################################################
/*----------------------------------------
----------------------------------------*/
long CPA_DialogPrefix::fn_lDoDialog (CPA_Interface *pEditor, CString a_csUserNames[], long lNbUsers)
{
long lIndex;
// init parameters
m_pEditor = pEditor;
m_lNbUsers = lNbUsers;
for (lIndex = 0; lIndex <lNbUsers; lIndex++)
m_a_csUserNames[lIndex] = a_csUserNames[lIndex];
// this dialog is modal
DoModal();
return m_lUserSelected;
}
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogPrefix::OnInitDialog ()
{
long lIndex;
// Create the dialog
CDialog::OnInitDialog();
// init combo
m_cComboUsers.ResetContent();
for (lIndex = 0; lIndex <m_lNbUsers; lIndex++)
m_cComboUsers.AddString(m_a_csUserNames[lIndex]);
// set current selection
m_lUserSelected = -1;
return TRUE;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPrefix::OnSelChangeComboUsers()
{
// set the current selection
m_lUserSelected = m_cComboUsers.GetCurSel();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPrefix::OnDblClkComboUsers()
{
// set the current selection
m_lUserSelected = m_cComboUsers.GetCurSel();
// if selection, close dialog
if (m_lUserSelected != -1)
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPrefix::OnOK()
{
// set the current selection
if (m_lUserSelected != -1)
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPrefix::OnCancel()
{
// set the current selection
if (m_lUserSelected != -1)
CDialog::OnCancel();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogPrefix::OnSave ()
{
if (m_lUserSelected != -1)
m_pEditor->fn_vSaveUserPrefix( m_pEditor->GetUserPrefix(m_lUserSelected) );
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,263 @@
/*=========================================================================
*
* CPAdSel.cpp : Selection - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdSel.hpp"
#include "itf/DEVMul3d.Hpp"
#include "itf/CPAInter.hpp"
//#################################################################################
// CPA_DialogSelect dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_DialogSelect::CPA_DialogSelect(CWnd* pParent /*=NULL*/)
: CDialog(CPA_DialogSelect::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_DialogSelect)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogSelect)
DDX_Control(pDX, CPA_IDC_LISTSELECT2, m_cListSelect2);
DDX_Control(pDX, CPA_IDC_LISTSELECT, m_cListSelect);
DDX_Control(pDX, CPA_IDC_HIERARCHY2, m_cHierarchy2);
DDX_Control(pDX, CPA_IDC_HIERARCHY1, m_cHierarchy);
//}}AFX_DATA_MAP
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogSelect, CDialog)
//{{AFX_MSG_MAP(CPA_DialogSelect)
ON_LBN_SELCHANGE(CPA_IDC_LISTSELECT, OnSelchangeListSelect)
ON_LBN_DBLCLK(CPA_IDC_LISTSELECT, OnDblClkListSelect)
ON_LBN_SELCHANGE(CPA_IDC_HIERARCHY1, OnSelchangeHierarchy)
ON_LBN_DBLCLK(CPA_IDC_HIERARCHY1, OnDblClkHierarchy)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// CPA_DialogSelect message handlers
//#################################################################################
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::fn_vDoDialog (CPA_Interface *pInterface, tdeSelectMode eMode, CString csTypeName, CString a_csValidTypes[], long lNbTypes)
{
long lIndex;
// init parameters
m_pInterface = pInterface;
m_eMode = eMode;
m_lNbTypes = lNbTypes;
// type name
m_csTypeName = csTypeName;
// valid types
if (a_csValidTypes)
{
for (lIndex = 0; lIndex <lNbTypes; lIndex++)
m_a_csValidTypes[lIndex] = a_csValidTypes[lIndex];
}
// this dialog is modal
DoModal();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::fn_vInitDialog ()
{
m_stListSelect.RemoveAll();
m_stHierarchy.RemoveAll();
m_pSelection = NULL;
m_pObjectToSelect = NULL;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::fn_vCloseDialog (void)
{
// close the dialog
m_bDoDialog = FALSE;
// release capture
SetCapture();
m_p_oSurrenderCapture();
}
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogSelect::OnInitDialog ()
{
CPA_SuperObject *pElem;
POSITION pos;
char szName[256];
char szType[256];
// Create the dialog
CDialog::OnInitDialog();
// set focus to the dialog
m_p_oGrabCapture();
// free capture (for controls)
ReleaseCapture();
// init list destroy
for (pElem = m_stListSelect.GetHeadElement(pos); pElem;
pElem = m_stListSelect.GetNextElement(pos))
{
sprintf(szName, "%s", pElem->GetNameToDraw());
sprintf(szType, " %.1s-%s", pElem->GetRealTypeName(), pElem->GetModelName());
m_cListSelect.AddString(szName);
m_cListSelect2.AddString(szType);
}
// set current selection
m_cListSelect.SetCurSel(0);
m_pSelection = m_stListSelect.FindElementFromIndex(0);
// init hierarchy
fn_vInitHierarchy();
return TRUE;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::fn_vInitHierarchy (void)
{
CPA_SuperObject *pElem;
POSITION pos;
char szName[256];
char szType[256];
long lIndex;
// RAZ
m_stHierarchy.RemoveAll();
m_cHierarchy.ResetContent();
m_cHierarchy2.ResetContent();
// fill hierarchy list
if (m_lNbTypes)
{
for (lIndex = 0; lIndex <m_lNbTypes; lIndex++)
GetInterface()->fn_lFindSelectionInHierarchy(m_eMode, m_pSelection, m_a_csValidTypes[lIndex]);
}
else
GetInterface()->fn_lFindSelectionInHierarchy(m_eMode, m_pSelection, m_csTypeName);
// init control
for (pElem = m_stHierarchy.GetHeadElement(pos); pElem;
pElem = m_stHierarchy.GetNextElement(pos))
{
sprintf(szName, "%s", pElem->GetNameToDraw());
sprintf(szType, " %.1s-%s", pElem->GetRealTypeName(), pElem->GetModelName());
m_cHierarchy.AddString(szName);
m_cHierarchy2.AddString(szType);
}
// set default selection
m_cHierarchy.SetCurSel(0);
m_pObjectToSelect = m_stHierarchy.FindElementFromIndex(0);
// update drawing
GetInterface()->fn_vUpdateSelection(m_pObjectToSelect, m_eMode);
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::OnSelchangeListSelect()
{
// set the current selection
m_pSelection = m_stListSelect.FindElementFromIndex(m_cListSelect.GetCurSel());
// update hierarchy list
fn_vInitHierarchy();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::OnDblClkListSelect()
{
// set the current selection
m_pSelection = m_stListSelect.FindElementFromIndex(m_cListSelect.GetCurSel());
// update hierarchy list
fn_vInitHierarchy();
if (m_pSelection)
{
// get object to select
m_pObjectToSelect = m_pSelection;
// close the dialog
fn_vCloseDialog();
CDialog::OnOK();
}
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::OnSelchangeHierarchy()
{
// get object to select
m_pObjectToSelect = m_stHierarchy.FindElementFromIndex(m_cHierarchy.GetCurSel());
// update drawing
GetInterface()->fn_vUpdateSelection(m_pObjectToSelect, m_eMode);
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::OnDblClkHierarchy()
{
// get object to select
m_pObjectToSelect = m_stHierarchy.FindElementFromIndex(m_cHierarchy.GetCurSel());
// update drawing
GetInterface()->fn_vUpdateSelection(m_pObjectToSelect, m_eMode);
// close the dialog
if (m_pObjectToSelect)
{
fn_vCloseDialog();
CDialog::OnOK();
}
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::OnOK()
{
// set the current selection
m_pObjectToSelect = m_stHierarchy.FindElementFromIndex(m_cHierarchy.GetCurSel());
// close the dialog
fn_vCloseDialog();
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogSelect::OnCancel()
{
// cancel the selection
m_pObjectToSelect = NULL;
// close the dialog
fn_vCloseDialog();
CDialog::OnCancel();
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,595 @@
/*=========================================================================
*
* CPAdTip.cpp : TipOfDay Dialog - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAdTip.hpp"
#include "itf/FrmGest.hpp"
#include "acp_base.h"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAProj.hpp"
#include "x:\cpa\main\inc\_EditID.h"
#include "TUT.h"
typedef struct tdstBitmapTip_
{
HBITMAP hBitmap;
long lSizeX;
long lSizeY;
long lPos;
}
tdstBitmapTip;
//#################################################################################
// CPA_ColorEdit control
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_ColorEdit::CPA_ColorEdit (void)
{
m_crTextColor = RGB(0, 0, 150);
m_crBackColor = RGB(0, 200, 200);
m_brBrush.CreateSolidBrush(m_crBackColor);
}
/*----------------------------------------
----------------------------------------*/
void CPA_ColorEdit::fn_vSetColors (COLORREF crText, COLORREF crBack)
{
m_crTextColor = crText;
m_crBackColor = crBack;
m_brBrush.Detach();
m_brBrush.CreateSolidBrush(m_crBackColor);
}
/*----------------------------------------
----------------------------------------*/
HBRUSH CPA_ColorEdit::CtlColor (CDC* pDC, UINT nCtlColor)
{
pDC->SetTextColor(m_crTextColor);
pDC->SetBkColor(m_crBackColor);
return m_brBrush;
}
/*----------------------------------------
----------------------------------------*/
void CPA_ColorEdit::OnLButtonDown (UINT nFlags, CPoint point)
{
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_ColorEdit, CEdit)
//{{AFX_MSG_MAP(CPA_ColorEdit)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// CPA_DialogTip dialog
//#################################################################################
/*----------------------------------------
----------------------------------------*/
CPA_DialogTip::CPA_DialogTip(CWnd* pParent /*=NULL*/)
: CDialog(CPA_DialogTip::IDD, (pParent ? pParent : &g_oBaseFrame))
{
//{{AFX_DATA_INIT(CPA_DialogTip)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// init parameters
m_hTitle = NULL;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogTip::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_DialogTip)
DDX_Control(pDX, CPA_IDC_TIPTEXT, m_cTipText);
DDX_Control(pDX, CPA_IDC_NEXTTIP, m_cNextTip);
DDX_Control(pDX, CPA_IDC_FIRSTONLY, m_cFirstOnly);
//}}AFX_DATA_MAP
}
/*----------------------------------------
----------------------------------------*/
BEGIN_MESSAGE_MAP(CPA_DialogTip, CDialog)
//{{AFX_MSG_MAP(CPA_DialogTip)
ON_BN_CLICKED(CPA_IDC_NEXTTIP, OnNextTip)
ON_BN_CLICKED(CPA_IDC_CLOSETIP, OnCloseTip)
ON_WM_CTLCOLOR()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//#################################################################################
// EDT_DialogFlag message handlers
//#################################################################################
/*----------------------------------------
----------------------------------------*/
void CPA_DialogTip::fn_vDoDialog (CString csEditor, CString csTag, CString csFile, long lCurrentTip)
{
// init tips parameters
m_csFileName = csFile;
m_csEditor = csEditor;
m_csTag = csTag;
m_lCurrentTip = lCurrentTip;
// this dialog is modal
DoModal();
}
/*----------------------------------------
----------------------------------------*/
BOOL CPA_DialogTip::OnInitDialog ()
{
COLORREF crTextColor, crBackColor;
HBITMAP hEditor;
CRect rcTitle(100, 5, 290, 90);
CRect rcEditor(150, 100, 190, 40);
char szEditor[256], szCurrent[256], szBackGround[256];
char szMode[10], szText[10], szBack[10];
long lR,lG,lB;
// Create the dialog
CDialog::OnInitDialog();
// create Title bitmap
if (!m_hTitle)
m_hTitle = m_hLoadImage("EDT_Data\\Bitmaps\\TipOfDay.bmp",290,90);
// set title
if (m_hTitle)
{
m_cTitle.Create("TIP OF THE DAY", WS_CHILD|WS_BORDER|SS_BITMAP|SS_CENTERIMAGE, rcTitle, this);
m_cTitle.ModifyStyleEx(NULL, WS_EX_CLIENTEDGE);
m_cTitle.SetWindowPos(NULL, 0, 0, 290, 90, SWP_NOMOVE);
m_cTitle.ShowWindow(TRUE);
m_cTitle.SetBitmap(m_hTitle);
}
else
{
m_cTitle.Create("TIP OF THE DAY", WS_CHILD|WS_BORDER, rcTitle, this);
m_cTitle.ModifyStyleEx(NULL, WS_EX_CLIENTEDGE);
m_cTitle.SetWindowPos(NULL, 0, 0, 290, 90, SWP_NOMOVE);
m_cTitle.ShowWindow(TRUE);
m_cTitle.SetWindowText("TIP OF THE DAY");
}
// create Editor bitmap
sprintf(szEditor, "EDT_Data\\Bitmaps\\%s\\%s.bmp", m_csTag, m_csTag);
hEditor = m_hLoadImage(szEditor, 190, 40);
// set title
if (hEditor)
{
m_cEditor.Create(m_csEditor, WS_CHILD|WS_BORDER|SS_BITMAP|SS_CENTERIMAGE, rcEditor, this);
m_cTitle.ModifyStyleEx(NULL, WS_EX_CLIENTEDGE);
m_cEditor.SetWindowPos(NULL, 0, 0, 190, 40, SWP_NOMOVE);
m_cEditor.ShowWindow(TRUE);
m_cEditor.SetBitmap(hEditor);
}
else
{
m_cEditor.Create(m_csEditor, WS_CHILD|WS_BORDER, rcEditor, this);
m_cTitle.ModifyStyleEx(NULL, WS_EX_CLIENTEDGE);
m_cEditor.SetWindowPos(NULL, 0, 0, 190, 40, SWP_NOMOVE);
m_cEditor.ShowWindow(TRUE);
m_cEditor.SetWindowText(m_csEditor);
}
// get editor colors
sprintf(szText, "%s_Text", m_csTag);
sprintf(szBack, "%s_Back", m_csTag);
GetPrivateProfileString ("Colors", szText, "", szCurrent, 256, (char*)(LPCSTR)m_csFileName);
GetPrivateProfileString ("Colors", szBack, "", szBackGround, 256, (char*)(LPCSTR)m_csFileName);
if ((strlen(szCurrent) > 0) && (strlen(szBackGround) > 0))
{
// get text color
sscanf(szCurrent, "R%ld,G%ld,B%ld", &lR, &lG, &lB);
crTextColor = RGB(lR, lG, lB);
// get back color
sscanf(szBackGround, "R%ld,G%ld,B%ld", &lR, &lG, &lB);
crBackColor = RGB(lR, lG, lB);
// init tip colors
m_cTipText.fn_vSetColors(crTextColor, crBackColor);
}
else
{
// get default text color
crTextColor = RGB(0, 0, 0);
// get default back color
crBackColor = RGB(250, 250, 250);
// init tip colors
m_cTipText.fn_vSetColors(crTextColor, crBackColor);
}
// get mode
sprintf(szMode, "%s_Mode", m_csTag);
GetPrivateProfileString ("TipOfDay", szMode, "Always", szCurrent, 256, (char*)(LPCSTR)m_csFileName);
// set checkbox
m_cFirstOnly.SetCheck(!strcmp(szCurrent, "FirstOnly"));
// set tip text
fn_vGetNextTip();
// register controls
TUT_M_vGetTutDll();
TUT_M_vRegisterControlID( CPA_IDC_TIPTEXT, "ITF_TIPS_TEXT", TUT_e_TextEdit );
TUT_M_vRegisterControlID( CPA_IDC_NEXTTIP, "ITF_TIPS_NEXT", TUT_e_Button );
TUT_M_vRegisterControlID( CPA_IDC_FIRSTONLY, "ITF_TIPS_FIRSTONLY", TUT_e_Button );
TUT_M_vRegisterControlID( CPA_IDC_CLOSETIP, "ITF_TIPS_CLOSETIP", TUT_e_Button );
return TRUE;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogTip::OnNextTip ()
{
fn_vGetNextTip();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogTip::fn_vGetNextTip (void)
{
char szCurrentTip[10];
char szCurrentText[255];
char szCurrentBitmap[255];
char szRealText[255];
char szText[10];
char szBitmap[10];
char szTip[10];
long lLine = 1;
CList<tdstBitmapTip *, tdstBitmapTip *> stBitmapList;
// reinit text and bitmap list
m_csText = "";
while (m_stListOfBitmaps.GetCount())
{
CStatic *p_cBitmap = m_stListOfBitmaps.RemoveHead();
p_cBitmap->DestroyWindow();
delete (p_cBitmap);
}
sprintf(szCurrentTip, "%s%ld", m_csTag, m_lCurrentTip);
// get corresponding text
while (lLine > 0)
{
// Get text
sprintf(szText, "L%ld", lLine);
GetPrivateProfileString (szCurrentTip, szText, "", szCurrentText, 256, (char*)(LPCSTR)m_csFileName);
// check if there is a text
if (strlen(szCurrentText) > 0)
{
char *p_szSymbol;
// new line
if (!strcmp(szCurrentText, "."))
strcpy(szRealText, " ");
else
{
strcpy(szRealText, szCurrentText);
// tabulations
while ((p_szSymbol = strstr(szRealText, "/t")) != NULL)
{
strcpy(szCurrentText, p_szSymbol+2);
strcpy(p_szSymbol, "\t");
strcat(szRealText, szCurrentText);
}
// espaces de d<>but de ligne
while ((p_szSymbol = strstr(szRealText, "/e")) != NULL)
{
strcpy(szCurrentText, p_szSymbol+2);
strcpy(p_szSymbol, " ");
strcat(szRealText, szCurrentText);
}
}
// update text
m_csText += szRealText;
m_csText += "\r\n";
lLine++;
}
else
lLine = -1;
// Get bitmap
sprintf(szBitmap, "B%ld", lLine-1);
GetPrivateProfileString (szCurrentTip, szBitmap, "", szCurrentBitmap, 256, (char*)(LPCSTR)m_csFileName);
// check if there is a text
if (strlen(szCurrentBitmap) > 0)
{
HBITMAP hBitmap;
char szBitmapName[255];
char *p_szSize;
long lSizeX = 0;
long lSizeY = 0;
// get bitmap size
p_szSize = strstr(szCurrentBitmap, ",Y");
if (p_szSize)
{
lSizeY = atol(p_szSize+2);
strcpy(p_szSize, "\0");
}
p_szSize = strstr(szCurrentBitmap, ",X");
if (p_szSize)
{
lSizeX = atol(p_szSize+2);
strcpy(p_szSize, "\0");
}
// get bitmap name
sprintf(szBitmapName, "EDT_Data\\Bitmaps\\%s\\%s", m_csTag, szCurrentBitmap);
// load the bitmap
hBitmap = m_hLoadImage(szBitmapName, lSizeX, lSizeY);
if (hBitmap)
{
tdstBitmapTip *p_stBitmap = new tdstBitmapTip;
long lAdd;
// create bitmap tip
p_stBitmap->hBitmap = hBitmap;
p_stBitmap->lSizeX = lSizeX;
p_stBitmap->lSizeY = lSizeY;
p_stBitmap->lPos = m_csText.GetLength();
// add dit to the list
stBitmapList.AddTail(p_stBitmap);
// add lines to the text
for (lAdd = 0; lAdd < (lSizeY / 18) + 1; lAdd++)
m_csText += "\r\n";
}
}
}
// display text of the tip
m_cTipText.SetWindowText(m_csText);
// display bitmaps
while (stBitmapList.GetCount())
{
// get bitmap parameters
tdstBitmapTip *p_stBitmap = stBitmapList.RemoveHead();
CStatic *p_cBitmap = new CStatic;
CPoint oPoint = m_cTipText.PosFromChar(p_stBitmap->lPos);
CRect rcBitmap(0, oPoint.y+1, p_stBitmap->lSizeX, oPoint.y+1+p_stBitmap->lSizeY);
// create static control
p_cBitmap->Create(szCurrentTip, WS_CHILD|SS_BITMAP|SS_CENTERIMAGE, rcBitmap, &m_cTipText);
p_cBitmap->SetWindowPos(NULL, 0, 0, p_stBitmap->lSizeX, p_stBitmap->lSizeY, SWP_NOMOVE);
p_cBitmap->ShowWindow(TRUE);
p_cBitmap->SetBitmap(p_stBitmap->hBitmap);
// add it to the list
m_stListOfBitmaps.AddTail(p_cBitmap);
// free bitmap
// delete (p_stBitmap);
}
// get next current tip or return to first one
sprintf(szCurrentTip, "%s%ld", m_csTag, m_lCurrentTip+1);
GetPrivateProfileString (szCurrentTip, "L1", "", szCurrentText, 256, (char*)(LPCSTR)m_csFileName);
// check if there is a text
m_lCurrentTip = (strlen(szCurrentText) > 0) ? m_lCurrentTip + 1 : 1;
sprintf(szCurrentTip, "%ld", m_lCurrentTip);
// register this new curent tip
sprintf(szTip, "%s_nTip", m_csTag);
WritePrivateProfileString ("TipOfDay", szTip, szCurrentTip, (char*)(LPCSTR)m_csFileName);
}
/*----------------------------------------
----------------------------------------*/
HBRUSH CPA_DialogTip::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hBrush;
switch (nCtlColor)
{
case CTLCOLOR_EDIT:
pDC->SetBkColor(RGB(0,200,200));
pDC->SetTextColor(RGB(0,0,100));
hBrush = HBRUSH(pDC->GetCurrentBrush());
break;
default:
hBrush = CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
break;
}
return hBrush;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogTip::OnCloseTip ()
{
char szMode[10];
// write state for this editor
sprintf(szMode, "%s_Mode", m_csTag);
WritePrivateProfileString ("TipOfDay", szMode, m_cFirstOnly.GetCheck() ? "FirstOnly" : "Always", (char*)(LPCSTR)m_csFileName);
// quit
CDialog::OnOK();
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogTip::OnCancel ()
{
char szMode[10];
// write state for this editor
sprintf(szMode, "%s_Mode", m_csTag);
WritePrivateProfileString ("TipOfDay", szMode, m_cFirstOnly.GetCheck() ? "FirstOnly" : "Always", (char*)(LPCSTR)m_csFileName);
// quit
CDialog::OnCancel();
}
/*----------------------------------------
----------------------------------------*/
HBITMAP CPA_DialogTip::m_hLoadImage(CString _csName, int _cx, int _cy)
{
HBITMAP hBitmap = NULL;
CString csExtension = strrchr(LPCTSTR(_csName), '.');
short wImageType;
if ( !csExtension.CompareNoCase(".bmp") ) // load a bmp file
wImageType = 'BM';
else if ( !csExtension.CompareNoCase(".tga") ) // load a tga file
wImageType = 'TG';
else
wImageType = 0;
if ( wImageType )
{
FILE *p_stTextureFile;
p_stTextureFile = fopen(LPCTSTR(_csName),"rb");
if ( p_stTextureFile )
{
BITMAPINFO stBitmapInfo;
unsigned char aDEF_ucReadBuffer[512L*4L];
short wTgaWidth, wTgaHeight;
unsigned char ucBBP;
if ( wImageType == 'BM' ) // load a bmp file
{
BITMAPFILEHEADER bf;
BITMAPINFOHEADER bi;
fread(&bf, 1, sizeof(bf), p_stTextureFile);
fread(&bi, 1, sizeof(bi), p_stTextureFile);
stBitmapInfo.bmiHeader = bi;
wTgaWidth = (short) bi.biWidth;
wTgaHeight = (short) bi.biHeight;
ucBBP = (unsigned char) bi.biBitCount;
}
else if ( wImageType == 'TG' ) // load a bmp file
{
//read TGA header
fread(aDEF_ucReadBuffer,18,1,p_stTextureFile);
//get image width and height
wTgaWidth = (aDEF_ucReadBuffer[13]<<8) + aDEF_ucReadBuffer[12];
wTgaHeight = (aDEF_ucReadBuffer[15]<<8) + aDEF_ucReadBuffer[14];
ucBBP = aDEF_ucReadBuffer[16];
}
else
{
fclose(p_stTextureFile);
return NULL;
}
//here, we have read the header of the image file, either BMP or TGA
//here, the file has a size that we accept
if ( wImageType == 'BM' ) // load a bmp file with the Windows API
{
fclose(p_stTextureFile);
hBitmap = (HBITMAP) LoadImage(NULL, _csName, IMAGE_BITMAP, _cx, _cy, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
}
else if ( wImageType = 'TG' ) // load a tga file
{
BITMAPINFO stBitmapInfo;
unsigned char *pRawBits;
//we load only true color images
if ( ucBBP != 24 && ucBBP != 32 )
{
fclose(p_stTextureFile);
return NULL;
}
//get the number of bytes per pixel (3 or 4)
ucBBP >>= 3;
ASSERT(wTgaWidth * ucBBP <= sizeof(aDEF_ucReadBuffer));
//fill the other useful fields of the header
stBitmapInfo.bmiHeader.biWidth = _cx;
stBitmapInfo.bmiHeader.biHeight = _cy;
stBitmapInfo.bmiHeader.biPlanes = 1;
stBitmapInfo.bmiHeader.biBitCount = 24; //we dont care about alpha channel here, so we wont save it
stBitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
stBitmapInfo.bmiHeader.biCompression = BI_RGB;
stBitmapInfo.bmiHeader.biSizeImage = 0 /*stBitmapInfo.bmiHeader.biWidth * stBitmapInfo.bmiHeader.biHeight * ucBBP*/;
stBitmapInfo.bmiHeader.biXPelsPerMeter = 0;
stBitmapInfo.bmiHeader.biYPelsPerMeter = 0;
stBitmapInfo.bmiHeader.biClrUsed = 0;
stBitmapInfo.bmiHeader.biClrImportant = 0;
//create the bitmap image of the size we want (_cx, _cy)
hBitmap = CreateDIBSection(NULL, &stBitmapInfo, DIB_RGB_COLORS, (void **) &pRawBits, NULL, 0);
//copy/stretch the tga raw data in the image's bits area
if ( hBitmap && pRawBits )
{
long lDestLine, lSrcLine, lOldSrcLine = -1;
for ( lDestLine = 0; lDestLine < _cy; lDestLine ++ )
{
lSrcLine = (lDestLine * wTgaHeight) / _cy;
//read as many lines in the as required to reach the proper source data
while ( lSrcLine != lOldSrcLine )
{
lOldSrcLine ++;
//read a line in the file
fread((void*)aDEF_ucReadBuffer, ucBBP, wTgaWidth, p_stTextureFile);
}
unsigned char *pSrcLine = aDEF_ucReadBuffer;
unsigned char *pDestLine = pRawBits + lDestLine * _cx * 3;
long lDestPixel, lSrcPixel;
for ( lDestPixel = 0; lDestPixel < _cx; lDestPixel ++ )
{
lSrcPixel = (lDestPixel * wTgaWidth) / _cx;
unsigned char *pSrcPixel = pSrcLine + lSrcPixel * ucBBP;
unsigned char *pDestPixel = pDestLine + lDestPixel * 3;
*(pDestPixel ++) = *(pSrcPixel ++);
*(pDestPixel ++) = *(pSrcPixel ++);
*(pDestPixel ++) = *(pSrcPixel ++);
} //column scan loop
} //image scan loop
} //bitmap creation test
else
hBitmap = NULL;
fclose(p_stTextureFile);
} //image type test
} //file open test
}//image type test
return hBitmap;
}
/*----------------------------------------
----------------------------------------*/
void CPA_DialogTip::OnDestroy()
{
// register controls
TUT_M_vGetTutDll();
TUT_M_vUnregisterControlID( CPA_IDC_TIPTEXT );
TUT_M_vUnregisterControlID( CPA_IDC_NEXTTIP );
TUT_M_vUnregisterControlID( CPA_IDC_FIRSTONLY );
TUT_M_vUnregisterControlID( CPA_IDC_CLOSETIP );
CDialog::OnDestroy();
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,842 @@
//=========================================================================
// CPAFrame.cpp : implementation of the CPA_MainFrame class
// This is a part of the CPA project.
//
// Version 1.0
// Creation date 06/06/96
// Revision date
//
// (c) Ubi Studios 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================
#include "stdafx.h"
#include "acp_base.h"
#include <pbt.h>
#include "direct.h"
#include "Itf/CPARes.h"
#include "errint.h"
#include "mmgint.h"
#include "Itf/DEVViewp.hpp"
#include "Itf/DEVMul3D.hpp"
#include "Itf/CPAFrame.hpp"
#include "Itf/CPAProj.hpp"
#include "Itf/CPAConst.hpp"
#include "Itf/A3dkeyal.hpp"
#include "Itf/cpamworl.hpp"
#include "Itf/camdllb.hpp"
#include "Itf/CPAInter.hpp"
#include "incgam.h"
/////////////////////////////////////////////////////////////////////////////
// CPA_MainFrame
#define M_BaseClass FRMBaseMenu
// #define M_GetDevice() ((DEV_MultiDevice*)GetActiveView())
// #define M_GetEditManager() (M_GetDevice()->GetEditManager())
IMPLEMENT_DYNCREATE(CPA_MainFrame, M_BaseClass)
BEGIN_MESSAGE_MAP(CPA_MainFrame, M_BaseClass)
//{{AFX_MSG_MAP(CPA_MainFrame)
ON_MESSAGE(WM_POWERBROADCAST, m_lOnPowerManagement)
ON_WM_CREATE()
ON_WM_CLOSE()
// ON_WM_ACTIVATEAPP()
ON_WM_MOUSEACTIVATE()
ON_WM_SYSCOMMAND()
ON_WM_SIZE()
ON_WM_GETMINMAXINFO()
ON_WM_NCLBUTTONDOWN()
ON_WM_WINDOWPOSCHANGED()
ON_COMMAND(CPA_ID_APP_EXIT, OnAppExit)
ON_COMMAND(CPA_IDCB_SWAPTOEDITORS, OnSwapToEditors)
ON_COMMAND(CPA_IDCB_FULLSCREEN, OnFullScreen)
ON_WM_NCHITTEST()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_MainFrame construction/destruction
CPA_MainFrame::CPA_MainFrame()
{
mbWantSplit = TRUE;
mbWantNew = TRUE;
mbWantTile = TRUE;
mbWantClose = TRUE;
}
CPA_MainFrame::~CPA_MainFrame()
{
}
//###########################################################################
// POWER MANAGEMENT AND SCREEN SAVER
//###########################################################################
// handled WM_POWERBROADCAST
LRESULT CPA_MainFrame::m_lOnPowerManagement(UINT wParam, LONG lParam)
{
switch ( lParam )
{
case PBT_APMQUERYSUSPEND: //when system asks apps if they accept to enter low-power mode
case PBT_APMQUERYSTANDBY:
return TRUE; //return BROADCAST_QUERY_DENY for refusal to enter low-power mode
case PBT_APMSTANDBY: //received when all apps granted low-power mode, right before low-power mode is activated
case PBT_APMSUSPEND: //these 2 may me received before the two others if some app forces the mode
if ( !M_GetMainApp()->m_bEngineIsStopped )
{
M_GetMainApp()->fn_vStopEngine();
// if we are in fullscreen, then swap to windowed
// and tell we were in full screen
if (M_GetMainDevice()->GetDevice(0)->IsFullScreen())
{
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
}
return TRUE; //accept entry into low-power mode
case PBT_APMRESUMESUSPEND: //when resuming from low-power mode to normal operation
case PBT_APMRESUMESTANDBY: //when resuming from low-power mode to normal operation
case PBT_APMRESUMECRITICAL: //received when power is enough to proceed with normal operations
OnActivateApp(TRUE, NULL);
return FALSE;
case PBT_APMQUERYSUSPENDFAILED: //when an app denied request, others receive this message
case PBT_APMQUERYSTANDBYFAILED: //when an app denied request, others receive this message
case PBT_APMPOWERSTATUSCHANGE: //when power supply change is detected (batt<->mains/low, etc...)
case PBT_APMOEMEVENT: //when bios sends an OEM APM change
case PBT_APMBATTERYLOW: //when battery is running low
return FALSE; //return value is irrelevant
// PBTF_APMRESUMEFROMFAILURE ?
}
return BROADCAST_QUERY_DENY; //any other case is not known, so prevent power management just in case
}
int g_iMainWindowWidth = 652; //700
int g_iMainWindowHeight = 526;//550
BOOL CPA_MainFrame::PreCreateWindow(CREATESTRUCT &cs)
{
CSize ss(GetSystemMetrics(SM_CXMAXIMIZED), GetSystemMetrics(SM_CYMAXIMIZED));
cs.style = WS_CAPTION|WS_CLIPCHILDREN|WS_THICKFRAME|WS_OVERLAPPED;
cs.hwndParent = g_oBaseFrame.m_hWnd;
cs.x = (ss.cx - g_iMainWindowWidth) / 2;
cs.y = (ss.cy - g_iMainWindowHeight) / 2;
cs.cx = g_iMainWindowWidth;
cs.cy = g_iMainWindowHeight;
return CFrameWnd::PreCreateWindow(cs);
}
void CPA_MainFrame::OnSysCommand(UINT nID, LPARAM lParam) //handles WM_SYSCOMMAND message
{
UINT uiTrueNID = nID & 0xFFFFFFF0;
if(M_bEditorsActive())
{
if(uiTrueNID == SC_MAXIMIZE)
return;
}
if(uiTrueNID == SC_CLOSE)
TerminateProcess(GetCurrentProcess(),0);
switch ( uiTrueNID )
{
case SC_MONITORPOWER:
case SC_SCREENSAVE: // screensaver
// if we are in fullscreen, then swap to windowed
// and tell we were in full screen
//(do not do this for MONITORPOWER message, because the resolution change causes the
//power management counter to reset -> the monitor does not switch off...
if ( /*uiTrueNID == SC_SCREENSAVE &&*/ M_GetMainDevice()->GetDevice(0)->IsFullScreen() )
{
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
M_GetMainApp()->fn_vAppliAskToStopEngine();
break;
/*
case SC_KEYMENU:
case SC_MAXIMIZE:
return bRes = FALSE; //message processed -> if we do nothing, no one will */
}
CFrameWnd::OnSysCommand(nID, lParam);
}
void CPA_MainFrame::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
if(nHitTest == HTCAPTION)
{
if(M_bEditorsActive())
{
SetFocus();
return;
}
}
CFrameWnd::OnNcLButtonDown(nHitTest, point);
}
void CPA_MainFrame::OnWindowPosChanged(WINDOWPOS *lpwndpos)
{
/* if(!M_bEditorsActive())
m_oMainPos.SetRect
(
lpwndpos->x,
lpwndpos->y,
lpwndpos->x + lpwndpos->cx - 1,
lpwndpos->y + lpwndpos->cy - 1
);
*/ FRMBaseMenu::OnWindowPosChanged(lpwndpos);
}
void CPA_MainFrame::OnSize(UINT nType, int cx, int cy)
{
if(!M_bEditorsActive())
{
CFrameWnd::OnSize(nType, cx, cy);
return;
}
FRMBaseMenu::OnSize(nType, cx, cy);
}
void CPA_MainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
CSize ss(GetSystemMetrics(SM_CXMAXIMIZED), GetSystemMetrics(SM_CYMAXIMIZED));
if(M_bEditorsActive())
{
FRMBaseMenu::OnGetMinMaxInfo(lpMMI);
return;
}
lpMMI->ptMaxSize.x = g_iMainWindowWidth;
lpMMI->ptMaxSize.y = g_iMainWindowHeight;
lpMMI->ptMaxPosition.x = (ss.cx - g_iMainWindowWidth) / 2;
lpMMI->ptMaxPosition.y = (ss.cy - g_iMainWindowHeight) / 2;
lpMMI->ptMinTrackSize.x = lpMMI->ptMaxSize.x;
lpMMI->ptMinTrackSize.y = lpMMI->ptMaxSize.y;
lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x;
lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;
}
//===========================================================================
// Description: That function is called by MFC to update main frame title.
// We put project title and actual version of project.
// Creation date: 06 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// BOOL Not used
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_MainFrame::OnUpdateFrameTitle(BOOL)
{
// M_GetMainApp()->fn_vUpdateFrameTitle();
// ::SetWindowText(m_hWnd, (LPCTSTR) m_szProjectName);
}
//===========================================================================
// Description: Call when application is activate or desactivate.
// Creation date: 24 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// bActive Application is activated or not ?
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
int CPA_MainFrame::OnMouseActivate( CWnd* pDesktopWnd, UINT nHitTest, UINT message )
{
if(!M_bEditorsActive())
return MA_NOACTIVATEANDEAT;
else
return CFrameWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
void CPA_MainFrame::OnActivateApp(BOOL bActive, DWORD)
{
static BOOL s_bPreventNestedCalls = FALSE;
if ( s_bPreventNestedCalls )
return;
s_bPreventNestedCalls = TRUE;
if(bActive)
{
// Change priority level of main process
// Warning ! HIGH_PRIORITY_CLASS = same level as windows task manager. So if
// appli crash, it may causes somes problems.
// SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
// if we are not in editor mode, check if we were in fullscreen before leaving
// and resume then engine
if(!M_bEditorsActive())
{
if (M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus)
{
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = FALSE;
if (M_GetMainDevice()->GetDevice(0)->IsFullScreen() == FALSE)
{
// if(M_GetMainWnd()->IsIconic())
// M_GetMainWnd()->SendMessage(WM_SYSCOMMAND, SC_RESTORE);
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
}
}
M_GetMainApp()->m_bAppliAskedToStopEngine = FALSE;
M_GetMainApp()->fn_vRestartEngine();
}
// Call a virtual method for a real project
M_GetMainApp()->fn_vWhenAppGainFocus();
}
else
{
if(!M_bEditorsActive())
{
if (M_GetMainApp()->m_bProjectIsClosing == 0)
{
if (M_GetMainApp()->m_bLeavingApplication == FALSE)
{
// Suspend engine thread
M_GetMainApp()->fn_vAppliAskToStopEngine();
//if we were in full screen, it might be because the screen saver was activated...
// if (M_GetMainDevice()->GetDevice(0)->IsFullScreen())
// {
// M_GetMainDevice()->GetDevice(0)->SwapFullScreen(FALSE);
// M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
// SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
// }
// Restore a normal priority for actual process
// SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
// Call a virtual method for a real project
M_GetMainApp()->fn_vWhenAppLooseFocus();
}
}
}
}
/*#ifdef ACTIVE_EDITOR
if(M_bEditorsActive() && bActive)
{
for(int x = 1; x <= FRM_C_MaxCol; x++)
for(int y = 1; y <= FRM_C_MaxRow; y++)
if(g_oFrameGest.ma_p_oWinArray[x][y]) g_oFrameGest.ma_p_oWinArray[x][y]->BringWindowToTop();
}
#endif*/
s_bPreventNestedCalls = FALSE;
}
//===========================================================================
// Description: Call to close main frame.
// In editor mode, we ask all editors to close. Editors can
// say NO to not close application !
// Else we force second thread to close.
// Creation date: 20 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_MainFrame::OnClose(void)
{
// if the engine has finished its closing process, the perform the onclose
if (M_GetMainApp()->m_bEngineIsOver == FALSE)
{
if(fn_bCanClose() == FALSE)
return;
// We are in full screen ?
if(M_GetMainDevice()->GetDevice(0)->IsFullScreen())
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
// We indicate that project is closing
M_GetMainApp()->m_bProjectIsClosing = 1;
M_GetMainApp()->m_bLeavingApplication = 1;
// Force engine thread to close.
// we ask engine thread to begin the closing process
M_GetMainApp()->fn_vAppliAskToEndGame();
}
else
{
// We close window
TerminateProcess(GetCurrentProcess(),0);
CFrameWnd::OnClose();
}
}
//===========================================================================
// Description: Call to create main frame.
// In editor mode, we create toolbar and menus.
// Creation date: 06 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
int CPA_MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (M_BaseClass::OnCreate(lpCreateStruct) == -1)
return -1;
SetMenu(NULL); // No menu at this point of program
return 0;
}
//###########################################################################
// RESPONSE TO EDIT INTERFACE MESSAGES
//###########################################################################
UINT CPA_MainFrame::OnNcHitTest(CPoint point)
{
if(M_bEditorsActive())
return FRMBaseMenu::OnNcHitTest(point);
return CFrameWnd::OnNcHitTest(point);
}
//###########################################################################
// RESPONSE TO EDIT INTERFACE MESSAGES
//###########################################################################
void CPA_MainFrame::ActivateEditors(void)
{
M_GetMainApp()->fn_vAfterEngineStops();
// Tells the main contact that engine has just been stopped
g_oFrameGest.mfn_vSetRefresh(FALSE);
M_GetMainApp()->m_bEditorsAreActive = TRUE;
M_GetMainApp()->m_bFullScreenInEditor = M_GetMainDevice()->GetDevice(0)->IsFullScreen();
M_GetListOfAllDLL()->CallBeforeEditor();
g_oFrameGest.mfn_vSetRefresh(TRUE);
M_GetMainDevice()->DrawObject();
// M_GetMainDevice()->SetFocusDevice(0);
M_GetMainWnd()->fn_vShowGeneralInterface(TRUE);
g_oBaseFrame.SetFocus();
// M_FocusToDevice(M_GetMainDevice());
GetInterface()->fn_vDisplayTipOfDay("Interface","ITF",FALSE);
}
void CPA_MainFrame::DisactivateEditors(void)
{
// Ask the main contact if it accepts to run engine
// Exit if it says NO !
if (M_GetListOfAllDLL()->CallAcceptToRunEngine() == FALSE)
{
M_GetMainApp()->m_bAppliAskedToActivateEditors = TRUE;
fn_vShowGeneralInterface(TRUE); // For button that is now pressed
return;
}
// compute all bounding volumes
// OnComputeAllBound();
// erase info in status bar
M_GetMainWnd()->UpdateStatus(NULL, C_STATUSPANE_INFOS, C_STATUS_NORMAL);
// tells main contact that engine is about to start
// 5000 = Special value to force hide in FrmGest.
g_oFrameGest.m_iCanRefresh = -5000;
M_GetListOfAllDLL()->CallBeforeEngine();
M_bEditorsActive() = FALSE;
// M_GetMainWnd()->MoveWindow(((FRMBase *)M_GetMainWnd())->m_oMainPos);
M_GetMainWnd()->m_cLock = 0;
g_oFrameGest.m_iCanRefresh = 0;
// Go Engine
M_GetMainApp()->fn_vBeforeEngineStarts();
if (M_GetMainApp()->m_bAutoReinitTheMap)
{
fn_vReinitTheMap();
}
// OnComputeAllBound();
if(M_GetMainDevice()->GetDevice(0)->IsFullScreen())
M_GetMainWnd()->ShowWindow(FALSE);
else
{
fn_vShowGeneralInterface(FALSE);
CSize ss(GetSystemMetrics(SM_CXMAXIMIZED), GetSystemMetrics(SM_CYMAXIMIZED));
CRect cs;
//g_iMainWindowWidth = (g_iMainWindowHeight-46)*1.33 + 12;//chbani
cs.left = (ss.cx - g_iMainWindowWidth) / 2;
cs.top = (ss.cy - g_iMainWindowHeight) / 2;
cs.right = cs.left + g_iMainWindowWidth;
cs.bottom = cs.top + g_iMainWindowHeight;
M_GetMainWnd()->MoveWindow(cs);
}
M_GetMainApp()->fn_vRestartEngine();
// fn_vShowGeneralInterface(TRUE);
// M_FocusToDevice(M_GetMainDevice());
g_oBaseFrame.SetFocus();
}
//===========================================================================
//===========================================================================
// Description: Call to swap between motor and editors
// Creation date: 11 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_MainFrame::OnSwapToEditors(void)
{
if (M_GetMainApp()->m_bAppliAskedToActivateEditors == TRUE)
{
// if editors are not active, don't stop them
if (M_bEditorsActive())
{
M_GetMainApp()->fn_vAppliAskToStopEditors();
}
}
else
{
if (!M_bEditorsActive())
{
M_GetMainApp()->fn_vAppliAskToStartEditors();
}
}
}
//===========================================================================
// Description: To pass to full screen when engine runs
// Creation date: 27 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_MainFrame::OnFullScreen(void)
{
//
// DO NOT PUT SPECIAL CODE FOR FULL SCREEN HERE, BUT PUT IT IN SWAPFULLSCREEN
//
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
if (M_bEditorsActive())
M_FocusToDevice(M_GetMainDevice());
}
//===========================================================================
// Description: To exit application
// Creation date: 20 Sep 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date: 3 Dec 97
// Author: CPA2-GDumitrascu
//===========================================================================
void CPA_MainFrame::OnAppExit(void)
{
SendMessage(WM_CLOSE);
}
void CPA_MainFrame::fn_vInitGeneralDialogBarWithContext(void)
{
CComboBox *pCombo;
CButton *pBut;
// ENABLE OR DISABLE ITEMS
// Determins if an item of the control must be enabled or disabled. If editors are
// not active, a lot of things are disabled.
// COMBOBOX : Not active if engine runs
// PAUSEENGINE: Not active if engine doesn't run
// ONE/SOMESTEP: Not active if not in pause or engine doesn't run
// FULLSCREEN: Not active if engine doesn't run or engine in pause
if (M_bEditorsActive() == FALSE)
{
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_SWAPTOEDITORS);
pBut->SetCheck(0);
// pBut->ShowWindow(m_bEnableEditors ? SW_SHOW : SW_HIDE);
pBut->ShowWindow(SW_SHOW);
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_PAUSEENGINE);
pBut->ShowWindow(m_bEnableEditors ? SW_SHOW : SW_HIDE);
if (M_GetMainApp()->m_bAppliAskedToStopEngine)
{
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_ONESTEPENGINE);
pBut->ShowWindow(SW_SHOW);
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_FULLSCREEN);
pBut->ShowWindow(SW_HIDE);
}
else
{
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_ONESTEPENGINE);
pBut->ShowWindow(SW_HIDE);
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_FULLSCREEN);
pBut->ShowWindow(m_bEnableEditors ? SW_SHOW : SW_HIDE);
}
// Undo/Redo
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_UNDO);
pBut->SetCheck(0);
pBut->ShowWindow(SW_HIDE);
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_REDO);
pBut->SetCheck(0);
pBut->ShowWindow(SW_HIDE);
// Save
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_SAVEALL);
pBut->ShowWindow(SW_HIDE);
// Options
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_OPTIONS);
pBut->ShowWindow(SW_HIDE);
// select mode
pCombo = (CComboBox *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_SELECTMODE);
pCombo->ShowWindow(SW_HIDE);
// display mode
m_oGeneralDialogBar.m_oDisplayToolbar.ShowWindow(SW_HIDE);
// current sector
pCombo = (CComboBox *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_CURRENTSECTOR);
pCombo->ShowWindow(SW_HIDE);
// auto target
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_AUTOTARGET);
pBut->ShowWindow(SW_HIDE);
pBut->EnableWindow(FALSE);
// CPA_Ed_1 FS begin
// move camera
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_MOVECAMERA);
pBut->ShowWindow(SW_HIDE);
pBut->EnableWindow(FALSE);
// CPA_Ed_1 FS end
// Full button
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_FULL);
pBut->ShowWindow(SW_HIDE);
pBut->EnableWindow(FALSE);
// Delta button
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_DELTA);
pBut->ShowWindow(SW_HIDE);
pBut->EnableWindow(FALSE);
//ROMTEAM 3DEdition (Adrian Silvescu 24/02/98)
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_LOCK);
pBut->ShowWindow(SW_HIDE);
pBut->EnableWindow(FALSE);
//ENDROMTEAM 3DEdition (Adrian Silvescu)
m_oGeneralDialogBar.m_oDeviceToolbar.ShowWindow(SW_HIDE);
}
// Editors active
else
{
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_SWAPTOEDITORS);
pBut->SetCheck(1);
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_PAUSEENGINE);
pBut->ShowWindow(SW_HIDE);
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_ONESTEPENGINE);
pBut->ShowWindow(SW_HIDE);
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_FULLSCREEN);
pBut->ShowWindow(SW_HIDE);
// Undo/Redo
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_UNDO);
pBut->SetCheck(0);
pBut->ShowWindow(SW_SHOW);
pBut->EnableWindow(M_GetEditManager()->CanUndo() ? TRUE : FALSE);
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_REDO);
pBut->SetCheck(0);
pBut->ShowWindow(SW_SHOW);
pBut->EnableWindow(M_GetEditManager()->CanRedo() ? TRUE : FALSE);
// Save
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_SAVEALL);
pBut->ShowWindow(SW_SHOW);
// Options
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_OPTIONS);
pBut->ShowWindow(SW_SHOW);
// select mode
pCombo = (CComboBox *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_SELECTMODE);
pCombo->ShowWindow(SW_SHOW);
// display mode
m_oGeneralDialogBar.m_oDisplayToolbar.ShowWindow(SW_SHOW);
// current sector
pCombo = (CComboBox *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_CURRENTSECTOR);
pCombo->ShowWindow(SW_SHOW);
// auto target
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_AUTOTARGET);
pBut->ShowWindow(SW_SHOW);
pBut->EnableWindow(TRUE);
pBut->SetCheck(GetInterface()->fn_bAutoTarget());
// CPA_Ed_1 FS begin
// move camera
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_MOVECAMERA);
pBut->ShowWindow(SW_SHOW);
pBut->EnableWindow(TRUE);
pBut->SetCheck(GetInterface()->fn_bMoveCamera());
// CPA_Ed_1 FS end
// Full button
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_FULL);
pBut->ShowWindow(SW_SHOW);
pBut->EnableWindow(TRUE);
pBut->SetCheck(GetInterface()->fn_bFullSelect());
// Delta button
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_DELTA);
pBut->ShowWindow(SW_SHOW);
pBut->EnableWindow(TRUE);
pBut->SetCheck(GetInterface()->fn_bDeltaSelect());
//ROMTEAM 3DEdition (Adrian Silvescu 24/02/98)
pBut = (CButton *) m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_LOCK);
pBut->ShowWindow(SW_SHOW);
pBut->EnableWindow(TRUE);
pBut->SetCheck(GetInterface()->GetLockSelection());
//ENDROMTEAM 3DEdition (Adrian Silvescu)
m_oGeneralDialogBar.m_oDeviceToolbar.ShowWindow(SW_SHOW);
}
// Device toolbar
mfn_vUpdateDeviceToolBar();
}
#ifdef TEST_CPA_VERSION_3D
//===========================================================================
// Description: To load a world id DATA directory.
// Creation date: 20 Sep 96
// Author: CB
//---------------------------------------------------------------------------
// szName Name of the world to load
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void fn_vInitCompleteWorld3D(LPCTSTR szName)
{
// Load an object in main view
HIE_tdxHandleToSuperObject hRoot/*, hSRoot*/;
// CPA_SuperObject *pRoot, *pSRoot;
DEV_MultiDevice3D *pDev;
long NbTriangles = 0;
#define C_MaxTriangles 100000
char temp[MAX_PATH];
SCR_tdst_Cxt_Values *p_stValues ;
char szSectionName[256];
GLI_xResetMatrixStack();
Mmg_M_SetModeAlloc4Ch(Int, E_ucDynamic, C_ucMmgDefaultChannel);
//chdir(M_GetMainApp()->m_csEngineDataPath);
GMT_fn_vInitLoadGameMaterial();
strcpy(temp, (char *) (LPCTSTR) (M_GetMainApp()->m_csEngineDataPath));
strcat(temp, "world\\levels\\");
SCR_fn_v_RdL0_RegisterPath(temp);
::GetCurrentDirectory(255, temp);
pDev = (DEV_MultiDevice3D *) M_GetMainApp()->fn_p_oGetMainWorld()->GetEditor()->GetDevice();
// Init des scripts et lecture du fichier
SCR_M_RdL0_SetContextLong(2, 0, (long) M_GetMainApp()->fn_p_oGetMainWorld());
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, "cave\\cave.spo", "SuperObject", "Root");
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(szSectionName, SCR_CDF_uw_Anl_Normal);
if (p_stValues)
hRoot = (HIE_tdxHandleToSuperObject) p_stValues->a_ulValues[0];
pDev->SetEngineWorld(hRoot);
chdir(temp);
//g_b_lLinesOn = 0;
//g_b_lSurfacesOn = 1;
//g_b_lBackFaceOn = 0;
}
//===========================================================================
// Description: To close current world.
// Creation date: 20 Sep 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void fn_vCloseCompleteWorld3D(void)
{
}
#endif // TEST_CPA_VERSION_3D

View File

@@ -0,0 +1,517 @@
//=========================================================================
// CPAFrame.cpp : implementation of the CPA_MainFrame class
// This is a part of the CPA project.
//
// Version 1.0
// Creation date 06/06/96
// Revision date
//
// (c) Ubi Studios 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================
#include "stdafx.h"
#include "acp_base.h"
#include <pbt.h>
#include "direct.h"
#include "Itf/CPARes.h"
#include "errint.h"
#include "mmgint.h"
#include "Itf/DEVViewp.hpp"
#include "Itf/DEVMul3D.hpp"
#include "Itf/CPAFrame.hpp"
#include "Itf/CPAProj.hpp"
#include "Itf/CPAConst.hpp"
#include "Itf/A3dkeyal.hpp"
#include "Itf/cpamworl.hpp"
#include "Itf/camdllb.hpp"
#include "Itf/CPAInter.hpp"
#include "incgam.h"
/////////////////////////////////////////////////////////////////////////////
// CPA_MainFrame
#define M_BaseClass CFrameWnd
IMPLEMENT_DYNCREATE(CPA_MainFrame, M_BaseClass)
BEGIN_MESSAGE_MAP(CPA_MainFrame, M_BaseClass)
//{{AFX_MSG_MAP(CPA_MainFrame)
ON_MESSAGE(WM_POWERBROADCAST, m_lOnPowerManagement)
ON_MESSAGE(WM_DISPLAYCHANGE, OnDisplayChange)
ON_WM_CREATE()
ON_WM_CLOSE()
ON_WM_ACTIVATEAPP()
ON_WM_ACTIVATE()
ON_WM_SYSCOMMAND()
ON_WM_SIZE()
ON_WM_GETMINMAXINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_MainFrame construction/destruction
CPA_MainFrame::CPA_MainFrame()
{
}
CPA_MainFrame::~CPA_MainFrame()
{
}
LRESULT CPA_MainFrame::OnDisplayChange(UINT wParam, LONG lParam)
{
HDC hdc;
int iAppBPP;
hdc = ::GetDC(NULL);
iAppBPP = ::GetDeviceCaps(hdc, PLANES);
iAppBPP *= wParam;
::ReleaseDC(NULL, hdc);
M_GetMainApp()->m_bBadResolution = FALSE;
if(iAppBPP != 16)
M_GetMainApp()->m_bBadResolution = TRUE;
if(M_GetMainApp()->m_bBadResolution)
{
if(!M_GetMainDevice()->GetDevice(0)->IsFullScreen())
{
if(!IsIconic())
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
// else
// M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
}
}
return 0;
}
//###########################################################################
// POWER MANAGEMENT AND SCREEN SAVER
//###########################################################################
// handled WM_POWERBROADCAST
LRESULT CPA_MainFrame::m_lOnPowerManagement(UINT wParam, LONG lParam)
{
switch ( lParam )
{
case PBT_APMQUERYSUSPEND: //when system asks apps if they accept to enter low-power mode
case PBT_APMQUERYSTANDBY:
return TRUE; //return BROADCAST_QUERY_DENY for refusal to enter low-power mode
case PBT_APMSTANDBY: //received when all apps granted low-power mode, right before low-power mode is activated
case PBT_APMSUSPEND: //these 2 may me received before the two others if some app forces the mode
if ( !M_GetMainApp()->m_bEngineIsStopped )
{
M_GetMainApp()->fn_vStopEngine();
// if we are in fullscreen, then swap to windowed
// and tell we were in full screen
M_GetMainApp()->BeforeWindows();
if (M_GetMainDevice()->GetDevice(0)->IsFullScreen())
{
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
{
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
}
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
M_GetMainApp()->AfterWindows();
}
return TRUE; //accept entry into low-power mode
case PBT_APMRESUMESUSPEND: //when resuming from low-power mode to normal operation
case PBT_APMRESUMESTANDBY: //when resuming from low-power mode to normal operation
case PBT_APMRESUMECRITICAL: //received when power is enough to proceed with normal operations
OnActivateApp(TRUE, NULL);
return FALSE;
case PBT_APMQUERYSUSPENDFAILED: //when an app denied request, others receive this message
case PBT_APMQUERYSTANDBYFAILED: //when an app denied request, others receive this message
case PBT_APMPOWERSTATUSCHANGE: //when power supply change is detected (batt<->mains/low, etc...)
case PBT_APMOEMEVENT: //when bios sends an OEM APM change
case PBT_APMBATTERYLOW: //when battery is running low
return FALSE; //return value is irrelevant
// PBTF_APMRESUMEFROMFAILURE ?
}
return BROADCAST_QUERY_DENY; //any other case is not known, so prevent power management just in case
}
void CPA_MainFrame::OnSysCommand(UINT nID, LPARAM lParam) //handles WM_SYSCOMMAND message
{
UINT uiTrueNID = nID & 0xFFFFFFF0;
M_GetMainApp()->BeforeWindows();
switch ( uiTrueNID )
{
case SC_MONITORPOWER:
case SC_SCREENSAVE: // screensaver
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
{
if (M_GetMainDevice()->GetDevice(0)->IsFullScreen() )
{
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
M_GetMainApp()->fn_vAppliAskToStopEngine();
}
else
{
CFrameWnd::OnSysCommand(nID, lParam);
}
break;
case SC_MINIMIZE:
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
CFrameWnd::OnSysCommand(nID, lParam);
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
}
break;
case SC_MAXIMIZE:
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
M_GetMainWnd()->SendMessage(WM_SYSCOMMAND, SC_RESTORE);
}
break;
case SC_RESTORE:
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
CFrameWnd::OnSysCommand(nID, lParam);
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
}
break;
default:
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
CFrameWnd::OnSysCommand(nID, lParam);
}
}
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
{
CFrameWnd::OnSysCommand(nID, lParam);
}
M_GetMainApp()->AfterWindows();
}
void CPA_MainFrame::OnSize(UINT nType, int cx, int cy)
{
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
M_GetMainApp()->BeforeWindows();
CFrameWnd::OnSize(nType, cx, cy);
M_GetMainApp()->AfterWindows();
}
else
{
if((M_GetMainApp()->m_p_oEngineThread) && (M_GetMainApp()->m_bEngineIsStopped == FALSE))
WaitForSingleObject(M_GetMainApp()->m_hDrawSem, INFINITE);
CFrameWnd::OnSize(nType, cx, cy);
if((M_GetMainApp()->m_p_oEngineThread) && (M_GetMainApp()->m_bEngineIsStopped == FALSE))
ReleaseSemaphore(M_GetMainApp()->m_hDrawSem, 1, NULL);
}
}
void CPA_MainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
CSize sizeScreen(GetSystemMetrics(SM_CXMAXIMIZED), GetSystemMetrics(SM_CYMAXIMIZED));
lpMMI->ptMinTrackSize.x = 50;
lpMMI->ptMinTrackSize.y = 50;
lpMMI->ptMaxTrackSize.x = sizeScreen.cx;
lpMMI->ptMaxTrackSize.y = sizeScreen.cy;
}
//===========================================================================
// Description: That function is called by MFC to update main frame title.
// We put project title and actual version of project.
// Creation date: 06 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// BOOL Not used
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_MainFrame::OnUpdateFrameTitle(BOOL)
{
M_GetMainApp()->fn_vUpdateFrameTitle();
::SetWindowText(m_hWnd, (LPCTSTR) m_szProjectName);
}
void CPA_MainFrame::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized )
{
long l;
static BOOL s_bPreventNestedCalls = FALSE;
static BOOL s_bActive = FALSE;
Erm_fn_v_PrintErrMsgWithPersonalMsg("ITF - CpaFrame_eng", "on_Activate", "***********************");
if (nState == WA_ACTIVE || nState == WA_CLICKACTIVE)
{
l = 5;
l++;
}
CFrameWnd::OnActivate(nState,pWndOther,bMinimized);
}
//===========================================================================
// Description: Call when application is activate or desactivate.
// Creation date: 24 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// bActive Application is activated or not ?
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_MainFrame::OnActivateApp(BOOL bActive, DWORD)
{
static BOOL s_bPreventNestedCalls = FALSE;
static BOOL s_bActive = FALSE;
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
Erm_fn_v_PrintErrMsgWithPersonalMsg("ITF - CpaFrame_eng", "on_ActivateApp", "***********************");
if ( s_bPreventNestedCalls )
return;
s_bPreventNestedCalls = TRUE;
if(bActive)
{
Erm_fn_v_PrintErrMsgWithPersonalMsg("ITF - CpaFrame_eng", "on_ActivateApp", "*********TRUE**************");
if (s_bActive)
{
s_bPreventNestedCalls = FALSE;
return;
}
s_bActive = TRUE;
M_GetMainApp()->BeforeWindows();
// Change priority level of main process
// Warning ! HIGH_PRIORITY_CLASS = same level as windows task manager. So if
// appli crash, it may causes somes problems.
// SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
// if we are not in editor mode, check if we were in fullscreen before leaving
// and resume then engine
if (M_GetMainApp()->m_p_oEngineThread)
{
// if((M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus) || (M_GetMainApp()->m_bBadResolution))
// {
// M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = FALSE;
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
{
if ((M_GetMainDevice()->GetDevice(0)->IsFullScreen() == FALSE))
{
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
}
}
if ((M_GetMainWnd()->IsIconic()))
{
M_GetMainWnd()->SendMessage(WM_SYSCOMMAND, SC_RESTORE);
}
}
M_GetMainApp()->m_bAppliAskedToStopEngine = FALSE;
M_GetMainApp()->fn_vRestartEngine();
// Call a virtual method for a real project
M_GetMainApp()->fn_vWhenAppGainFocus();
M_GetMainApp()->AfterWindows();
M_GetMainApp()->AfterWindows();
}
else
{
Erm_fn_v_PrintErrMsgWithPersonalMsg("ITF - CpaFrame_eng", "on_ActivateApp", "*********FALSE**************");
if (!s_bActive)
{
s_bPreventNestedCalls = FALSE;
return;
}
s_bActive = FALSE;
M_GetMainApp()->BeforeWindows();
if (M_GetMainApp()->m_bProjectIsClosing == 0)
{
if (M_GetMainApp()->m_bLeavingApplication == FALSE)
{
// Suspend engine thread
M_GetMainApp()->fn_vAppliAskToStopEngine();
M_GetMainApp()->BeforeWindows();
if (!(M_GetMainWnd()->IsIconic()))
{
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
// Restore a normal priority for actual process
// SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
// Call a virtual method for a real project
M_GetMainApp()->fn_vWhenAppLooseFocus();
}
}
M_GetMainApp()->AfterWindows();
}
s_bPreventNestedCalls = FALSE;
}
else
{
if ( s_bPreventNestedCalls )
return;
s_bPreventNestedCalls = TRUE;
if(bActive)
{
// Change priority level of main process
// Warning ! HIGH_PRIORITY_CLASS = same level as windows task manager. So if
// appli crash, it may causes somes problems.
// SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
// if we are not in editor mode, check if we were in fullscreen before leaving
// and resume then engine
if (M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus)
{
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = FALSE;
if (M_GetMainDevice()->GetDevice(0)->IsFullScreen() == FALSE)
{
if(M_GetMainWnd()->IsIconic())
M_GetMainWnd()->SendMessage(WM_SYSCOMMAND, SC_RESTORE);
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
}
}
M_GetMainApp()->m_bAppliAskedToStopEngine = FALSE;
M_GetMainApp()->fn_vRestartEngine();
// Call a virtual method for a real project
M_GetMainApp()->fn_vWhenAppGainFocus();
}
else
{
if (M_GetMainApp()->m_bProjectIsClosing == 0)
{
if (M_GetMainApp()->m_bLeavingApplication == FALSE)
{
// Suspend engine thread
M_GetMainApp()->fn_vAppliAskToStopEngine();
//if we were in full screen, it might be because the screen saver was activated...
if (M_GetMainDevice()->GetDevice(0)->IsFullScreen())
{
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
// Restore a normal priority for actual process
// SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
// Call a virtual method for a real project
M_GetMainApp()->fn_vWhenAppLooseFocus();
}
}
}
s_bPreventNestedCalls = FALSE;
}
}
//===========================================================================
// Description: Call to close main frame.
// In editor mode, we ask all editors to close. Editors can
// say NO to not close application !
// Else we force second thread to close.
// Creation date: 20 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_MainFrame::OnClose(void)
{
// if the engine has finished its closing process, the perform the onclose
if (M_GetMainApp()->m_bEngineIsOver == FALSE)
{
// We are in full screen ?
if(M_GetMainDevice()->GetDevice(0)->IsFullScreen())
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
// We indicate that project is closing
M_GetMainApp()->m_bProjectIsClosing = 1;
M_GetMainApp()->m_bLeavingApplication = 1;
// Force engine thread to close.
// we ask engine thread to begin the closing process
M_GetMainApp()->fn_vAppliAskToEndGame();
}
else
{
// We close window
CFrameWnd::OnClose();
}
}
//===========================================================================
// Description: Call to create main frame.
// In editor mode, we create toolbar and menus.
// Creation date: 06 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
int CPA_MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (M_BaseClass::OnCreate(lpCreateStruct) == -1)
return -1;
SetMenu(NULL); // No menu at this point of program
return 0;
}
//###########################################################################
// RESPONSE TO EDIT INTERFACE MESSAGES
//###########################################################################

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,398 @@
/*=========================================================================
*
* EDTlType.cpp : Editor Lists - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPALists.hpp"
#include "itf/CPAInter.hpp"
#include "itf/cpaproj.hpp"
//#################################################################################
// CLASS EDT_ListByType
//#################################################################################
/*===========================================================================
* Description: constructor
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
EDT_ListByType::EDT_ListByType (CPA_ObjectDLLBase *p_oDLL, CString csTypeName)
{
// DLL
m_pObjectDLL = p_oDLL;
// TypeName
m_csTypeName = csTypeName;
}
//===========================================================================
//===========================================================================
EDT_ListByType::EDT_ListByType (void)
{
// DLL
m_pObjectDLL = NULL;
}
//===========================================================================
//===========================================================================
EDT_ListByType::~EDT_ListByType (void)
{
CPA_BaseObject *pElem;
// lists
m_stListObjects.RemoveAll();
if (M_GetMainApp()->m_bLeavingApplication == FALSE)
{
while (m_stSortedList.GetCount())
{
pElem = m_stSortedList.GetHead();
m_stSortedList.fn_bRemoveObject(pElem);
delete pElem;
}
}
}
/*===========================================================================
* Description: set name
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ListByType::SetTypeName (CString csTypeName)
{
// TypeName
m_csTypeName = csTypeName;
}
/*===========================================================================
* Description: Reinit the list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ListByType::fn_vReinit (void)
{
// lists
m_stListObjects.RemoveAll();
}
/*===========================================================================
* Description: Test unicity of the name
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_SuperObject * EDT_ListByType::GetObjectWithName (CString csName)
{
CPA_SuperObject *pElem;
POSITION pos;
// search the list
for (pElem = m_stListObjects.GetHeadElement(pos); pElem;
pElem = m_stListObjects.GetNextElement(pos))
{
// search for the name
if (pElem->GetName().CompareNoCase(csName) == 0)
return pElem;
}
// name was not found
return NULL;
}
//#################################################################################
// CLASS EDT_ListByDLL
//#################################################################################
/*===========================================================================
* Description: constructor
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
EDT_ListByDLL::EDT_ListByDLL (CPA_ObjectDLLBase *p_oDLL)
{
// parameters
m_pDLLObject = p_oDLL;
// reinit list
m_stListConcerned.RemoveAll();
m_stListSelected.RemoveAll();
m_stListProtectConcerned.RemoveAll();
m_stListProtectSelected.RemoveAll();
}
EDT_ListByDLL::~EDT_ListByDLL (void)
{
// remove selection
m_stListConcerned.RemoveAll();
m_stListSelected.RemoveAll();
// remove protect
m_stListProtectConcerned.RemoveAll();
m_stListProtectSelected.RemoveAll();
// delete list by type
while (m_stListOfListByType.GetCount())
delete (m_stListOfListByType.RemoveTail());
}
/*===========================================================================
* Description: Reinit the list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ListByDLL::fn_vReinit (void)
{
EDT_ListByType *pListType;
POSITION pos;
// reinit list all types
m_stListAllTypes.fn_vReinit();
// reinit list by type
for (pListType = m_stListOfListByType.GetHeadElement(pos); pListType;
pListType = m_stListOfListByType.GetNextElement(pos))
pListType->fn_vReinit();
// reinit selection
m_stListConcerned.RemoveAll();
m_stListSelected.RemoveAll();
// reinit protect
m_stListProtectSelected.RemoveAll();
m_stListProtectConcerned.RemoveAll();
}
/*===========================================================================
* Description: Reinit sorted list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ListByDLL::fn_vUpdateSortedList (void)
{
/* EDT_ListByType *pListType;
POSITION pos;
// update list all types
m_stListAllTypes.m_stSortedList.fn_vReinitSortedList((CPA_List<CPA_BaseObject> *) &m_stListAllTypes.m_stListObjects);
// update list by type
for (pListType = m_stListOfListByType.GetHeadElement(pos); pListType;
pListType = m_stListOfListByType.GetNextElement(pos))
pListType->m_stSortedList.fn_vReinitSortedList((CPA_List<CPA_BaseObject> *) &pListType->m_stListObjects);
*/
}
/*===========================================================================
* Description: Update the list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ListByDLL::fn_vUpdateListObject (CPA_SuperObject *pEdObj, tdeListUpdateMode eType)
{
EDT_ListByType *pListType;
POSITION pos;
pListType = GetListByType(pEdObj->GetRealTypeName());
// insert ?
if ((eType == E_lum_Insert) || (eType == E_lum_ReInsert))
{
// update the lists by type
m_stListAllTypes.m_stListObjects.AddTail(pEdObj);
m_stListAllTypes.m_stSortedList.fn_bAddObject(pEdObj);
// update corresponding list
if (pListType)
{
pListType->m_stListObjects.AddTail(pEdObj);
pListType->m_stSortedList.fn_bAddObject(pEdObj);
}
}
// delete ?
else if (eType == E_lum_Delete)
{
// update the lists by type
pos = m_stListAllTypes.m_stListObjects.Find(pEdObj, NULL);
if (pos)
m_stListAllTypes.m_stListObjects.RemoveAt(pos);
m_stListAllTypes.m_stSortedList.fn_bRemoveObject(pEdObj);
// update corresponding list
if (pListType)
{
pos = pListType->m_stListObjects.Find(pEdObj, NULL);
if (pos)
pListType->m_stListObjects.RemoveAt(pos);
pListType->m_stSortedList.fn_bRemoveObject(pEdObj);
}
}
}
/*===========================================================================
* Description: Update the list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ListByDLL::fn_vUpdateListSelect (CPA_SuperObject *pEdObj, tdeListUpdateMode eType, BOOL bIsSelected)
{
POSITION pos;
// update list concerned
pos = m_stListConcerned.Find(pEdObj, NULL);
// insert ?
if ((eType == E_lum_Insert)&&(!pos))
m_stListConcerned.AddTail(pEdObj);
// delete ?
if ((eType == E_lum_Delete)&&(pos))
m_stListConcerned.RemoveAt(pos);
// update list selected
if (bIsSelected)
{
pos = m_stListSelected.Find(pEdObj, NULL);
// insert ?
if ((eType == E_lum_Insert)&&(!pos))
m_stListSelected.AddTail(pEdObj);
// delete ?
if ((eType == E_lum_Delete)&&(pos))
m_stListSelected.RemoveAt(pos);
}
}
/*===========================================================================
* Description: Update the list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ListByDLL::fn_vUpdateListProtect (CPA_SuperObject *pEdObj, tdeListUpdateMode eType, BOOL bIsSelected)
{
POSITION pos;
// update list concerned
pos = m_stListProtectConcerned.Find(pEdObj, NULL);
// insert ?
if ((eType == E_lum_Insert)&&(!pos))
m_stListProtectConcerned.AddTail(pEdObj);
// delete ?
if ((eType == E_lum_Delete)&&(pos))
m_stListProtectConcerned.RemoveAt(pos);
// update list selected
if (bIsSelected)
{
pos = m_stListProtectSelected.Find(pEdObj, NULL);
// insert ?
if ((eType == E_lum_Insert)&&(!pos))
m_stListProtectSelected.AddTail(pEdObj);
// delete ?
if ((eType == E_lum_Delete)&&(pos))
m_stListProtectSelected.RemoveAt(pos);
}
}
/*===========================================================================
* Description: Test unicity of the name
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_SuperObject * EDT_ListByDLL::GetObject (char *szTypeName, char *szName)
{
EDT_ListByType *pListType;
if (szTypeName)
pListType = GetListByType (szTypeName);
else
pListType = &m_stListAllTypes;
if (pListType)
return pListType->GetObjectWithName(szName);
// name was not found
return NULL;
}
/*===========================================================================
* Description: Test unicity of the name
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
EDT_ListByType * EDT_ListByDLL::GetListByType (CString csTypeName)
{
EDT_ListByType *pListType;
POSITION pos;
// all types
if (csTypeName == "All Types")
return &m_stListAllTypes;
// list by type
for (pListType = m_stListOfListByType.GetHeadElement(pos); pListType;
pListType = m_stListOfListByType.GetNextElement(pos))
{
if (csTypeName == pListType->GetTypeName())
return pListType;
}
// not found
return NULL;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,178 @@
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "itf/CpaMdf.hpp"
#include "itf/FRMBsMn.hpp"
#include "itf/FRMGest.hpp"
unsigned long CPA_Modif::LastSerial=0;
CPA_Modif::CPA_Modif(unsigned short pType, CString pName, BOOL pBlock /* = FALSE */)
{
Type = pType;
Name = pName;
m_HasBeenDone = FALSE;
if ( !pBlock ) LastSerial ++;
Serial = LastSerial;
}
//-------------------------------------------------------------------
CPA_EditManager::CPA_EditManager(int iMaxUndo)
{
NextPosition=NULL;
PrevPosition=NULL;
NextModif=NULL;
PrevModif=NULL;
CurrentIndex=0;
m_iMaxUndo=iMaxUndo;
m_bIsReDoing = FALSE;
m_bIsUnDoing = FALSE;
}
CPA_EditManager::~CPA_EditManager(void)
{
while(0<ListOfModifs.GetCount())
delete ListOfModifs.RemoveTail();//I own the modif's, so I delete them
}
BOOL CPA_EditManager::AskFor(CPA_Modif * pModif, BOOL _bDeleteUponFailure /*= TRUE*/)
{
// cannot insert a new modification while we are undoing or redoing another one
if (m_bIsReDoing || m_bIsUnDoing)
return FALSE;
if(!pModif->Do())
{
if ( _bDeleteUponFailure )
delete pModif;
return FALSE;//if the modif don't succeed do not erase the list (redo are still available)
}
pModif->Done();
while(CurrentIndex<ListOfModifs.GetCount())//no more Redo's
delete ListOfModifs.RemoveTail();//I own the modif's, so I delete them
if(m_iMaxUndo)
{
while(ListOfModifs.GetCount()>=m_iMaxUndo)
{
unsigned long CurrentSerial;
POSITION pOldPosition;
CPA_Modif *pOldModif;
for
(
pOldModif=ListOfModifs.GetHeadElement(pOldPosition),CurrentSerial=pOldModif->GetSerial();
pOldModif!=NULL && pOldModif->GetSerial()==CurrentSerial;
pOldModif=ListOfModifs.GetNextElement(pOldPosition),
CurrentIndex--
)
{
delete pOldModif;
ListOfModifs.RemoveAt(pOldPosition);
}
}
}
PrevPosition=ListOfModifs.AddTail(PrevModif=pModif);
NextPosition=NULL; //no more Redo's
NextModif=NULL; //no more Redo's
CurrentIndex++;
// Update dialog bar (for buttons)
((FRMBaseMenu *) g_oFrameGest.ma_p_oWinArray[2][2])->fn_vInitGeneralDialogBarWithContext();
return TRUE;
}
void CPA_EditManager::Reset(void)
{
while(ListOfModifs.GetCount())//no more Modif's
delete ListOfModifs.RemoveTail();
NextPosition=NULL;
PrevPosition=NULL;
NextModif=NULL;
PrevModif=NULL;
CurrentIndex=0;
}
BOOL CPA_EditManager::Redo(void)
{
BOOL OK,ret;
unsigned long CurrentSerial;
if (!CanRedo())
return FALSE;
m_bIsReDoing = TRUE;
OK=TRUE;
CurrentSerial=NextModif->GetSerial();
for
(
;
NextModif!=NULL && NextModif->GetSerial()==CurrentSerial;
NextModif=ListOfModifs.GetNextElement(NextPosition),
PrevModif=ListOfModifs.GetNextElement(PrevPosition),
CurrentIndex++
)
{
ret = NextModif->Do();
if (ret)
NextModif->Done();
OK = OK&&ret;
}
m_bIsReDoing = FALSE;
return OK;
}
BOOL CPA_EditManager::Undo(void)
{
BOOL OK,ret;
unsigned long CurrentSerial;
if (!CanUndo())
return FALSE;
m_bIsUnDoing = TRUE;
OK=TRUE;
CurrentSerial=PrevModif->GetSerial();
for
(
;
PrevModif!=NULL && PrevModif->GetSerial()==CurrentSerial;
NextModif=ListOfModifs.GetPrevElement(NextPosition),
PrevModif=ListOfModifs.GetPrevElement(PrevPosition),
CurrentIndex--
)
{
ret = PrevModif->Undo();
if (ret)
PrevModif->Undone();
OK = OK&&ret;
}
m_bIsUnDoing = FALSE;
return OK;
}
CString CPA_EditManager::GetRedoName(void)
{
if(!CanRedo()) return "No Redo Available";
return "Redo "+NextModif->GetName();
}
CString CPA_EditManager::GetUndoName(void)
{
if(!CanUndo()) return "No Undo Available";
return "Undo "+PrevModif->GetName();
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,287 @@
/*=========================================================================
*
* EDTlType.cpp : Editor Lists - Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAModel.hpp"
#include "itf/CPAProj.hpp"
#include "itf/CPAdIns.hpp"
#include "itf/CPAInter.hpp"
#include <direct.h>
//#################################################################################
// CLASS EDT_Model
//#################################################################################
/*===========================================================================
* Description: constructor
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
EDT_Model::EDT_Model (CPA_ObjectDLLBase *p_oDLL, CString csTypeName, CString csName, CString csBitmapName, CPA_Interface *pInterface)
{
CString csBitmapLoad;
// set DLL
m_pObjectDLL = p_oDLL;
// set type
m_csTypeName = csTypeName;
// set descriptor
m_csName = csName;
// set bitmap name
m_csBitmapName = csBitmapName;
// get complete file name
csBitmapLoad = M_GetMainApp()->m_csEditorDataPath + "\\" + m_csBitmapName;
// create bitmap and store it into the list
m_iBitmapPos = pInterface->GetBitmapList()->m_fn_iAdd(csBitmapLoad);
if (m_iBitmapPos == -1)
{
csBitmapLoad = M_GetMainApp()->m_csEditorDataPath + "\\Hierarchy\\Default.bmp";
m_iBitmapPos = pInterface->GetBitmapList()->m_fn_iAdd(csBitmapLoad);
}
}
EDT_Model::~EDT_Model (void)
{
}
/*----------------------------------------
Bitmap
----------------------------------------*/
BOOL EDT_Model::fn_bChangeBitmap (CPA_Interface *pInterface, CString csNewBitmapName)
{
CString csBitmapLoad;
int iBitmapPos;
// get complete file name
csBitmapLoad = M_GetMainApp()->m_csEditorDataPath + "\\" + csNewBitmapName;
// create bitmap and store it into the list
iBitmapPos = pInterface->GetBitmapList()->m_fn_iAdd(csBitmapLoad);
if (iBitmapPos != -1)
{
m_csBitmapName = csNewBitmapName;
m_iBitmapPos = iBitmapPos;
return TRUE;
}
else
return FALSE;
}
//#################################################################################
// EDT_ModelView
//#################################################################################
/*----------------------------------------
CONSTRUCTEUR
----------------------------------------*/
EDT_ModelView::EDT_ModelView ()
: C3ListView()
{
// update parameters
m_fn_vSetBox(C_cDisplayBitmapAndText, 80, 52);
m_fn_vSetBox(C_cDisplayBitmap, 34, 34);
m_fn_vSetBox(C_cDisplayText, 80, 18);
// set DD parameters
m_fn_vSetDDTypeAndEditor( C_ucModel, "Evt_Editor");
}
EDT_ModelView::~EDT_ModelView()
{
}
/*-----------------------------------------------------------------------------
* Description : called when selected item change to the given case
*---------------------------------------------------------------------------*/
void EDT_ModelView::OnSelectItem (short wCase)
{
CPA_Interface *pInterface;
EDT_Model *pNewModel;
C3ListView::OnSelectItem(wCase);
pInterface = ((CPA_DialogInsert *) GetParent())->GetInterface();
// Get model corresponding to the choice
tdstTSLItem *p_stCurItem = m_fn_p_stGetItem(wCase, m_cCurrentOrder);
if (p_stCurItem)
pNewModel = (EDT_Model *) p_stCurItem->m_lContent;
else
pNewModel = NULL;
pInterface->SetCurrentModel(pNewModel);
}
//#################################################################################
// CLASS EDT_ModelsByType
//#################################################################################
/*===========================================================================
* Description: constructor
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
EDT_ModelsByType::EDT_ModelsByType (CString csTypeName, CPA_ObjectDLLBase *p_oDLL, CWnd *pParentDialog, CBitmapList *pBitmapList)
{
// parameters
m_pDLLObject = p_oDLL;
m_csTypeName = csTypeName;
// init list models
fn_vInitModelView(pParentDialog, pBitmapList);
}
EDT_ModelsByType::~EDT_ModelsByType (void)
{
m_stListModels.RemoveAll();
}
/*===========================================================================
* Description: reinit
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ModelsByType::fn_vReinit (void)
{
EDT_Model *pModel;
long lIndex;
// remove all models
while (m_stListModels.GetCount() > 0)
{
pModel = m_stListModels.RemoveTail();
// update model view
lIndex = m_pModelView->m_fn_lFindName(-1, pModel->m_csName);
m_pModelView->m_fn_bDeleteItem(lIndex);
}
}
/*===========================================================================
* Description: create model view
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ModelsByType::fn_vInitModelView (CWnd *pParentDialog, CBitmapList *pBitmapList)
{
// create model view
m_pModelView = new EDT_ModelView;
m_pModelView->Create(NULL, "", WS_BORDER|WS_VISIBLE|WS_CHILD/*AFX_WS_DEFAULT_VIEW*/, CRect(0,0,0,0), pParentDialog, AFX_IDW_PANE_FIRST, NULL);
// set display type in list of models
m_pModelView->m_fn_vSetBitmapList(pBitmapList);
m_pModelView->m_fn_vChangeDisplayType(C_cDisplayBitmapAndText);
// init items
fn_vFillModelView();
}
/*===========================================================================
* Description: fill model view
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ModelsByType::fn_vFillModelView (void)
{
EDT_Model *pElem;
POSITION pos;
for (pElem = m_stListModels.GetHeadElement(pos); pElem;
pElem = m_stListModels.GetNextElement(pos))
m_pModelView->m_fn_iAddItem(pElem->m_csName, pElem->m_iBitmapPos, (long) pElem);
}
/*===========================================================================
* Description: Get the model with the given name
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
EDT_Model * EDT_ModelsByType::GetModelWithName (CString csName)
{
EDT_Model *pModel;
POSITION pos;
for (pModel = m_stListModels.GetHeadElement(pos); pModel;
pModel = m_stListModels.GetNextElement(pos))
{
if (pModel->m_csName == csName)
return pModel;
}
// model was not found
return NULL;
}
/*===========================================================================
* Description: Add model to the list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ModelsByType::fn_vAddANewModel (EDT_Model *pNewModel)
{
// add model to the list
m_stListModels.AddTail(pNewModel);
// update model view
m_pModelView->m_fn_iAddItem(pNewModel->m_csName, pNewModel->m_iBitmapPos, (long) pNewModel);
}
/*===========================================================================
* Description: remove model from the list
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void EDT_ModelsByType::fn_vRemoveAModel (EDT_Model *pOldModel)
{
POSITION pos;
long lIndex;
// Remove it from the list
pos = m_stListModels.Find(pOldModel);
if (pos)
m_stListModels.RemoveAt(pos);
// update model view
lIndex = m_pModelView->m_fn_lFindName(-1, pOldModel->m_csName);
m_pModelView->m_fn_bDeleteItem(lIndex);
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,838 @@
// class CPA_MAINWORLD
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include <direct.h>
#include "itf/CPASObj.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAWorld.hpp"
//#include "itf/EDTBase.hpp"
#include "itf/DevMul3d.hpp"
#include "itf/DevMulti.hpp"
#include "itf/CPAProj.hpp"
#include "itf/CPAInter.hpp"
#include "itf/StdDLLID.h"
/*===========================================================================
* Description: constructor
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_MainWorld::CPA_MainWorld(long lKey,DEV_MultiDevice *p_oDevice, CPA_Interface *p_oInterface)
{
CPA_ObjectDLLBase *p_oDLL, *p_oPreviousDLL;
CPA_ToolDLLBase *p_oToolDLL;
CPA_HierarchyEditor *p_oEditor;
CString csMessage;
long i;
CPA_DLLBase **ap_oDLL;
long lNbOfDLL;
m_p_oGlobalWorld = NULL;
m_lKey = lKey;
// editor
p_oEditor = (CPA_HierarchyEditor *) M_GetListOfAllDLL()->GetANewDLL(HIERARCHY_DLL, C_szDLLHierarchyName, m_lKey);
p_oInterface->SetHierarchyEditor(p_oEditor);
// set parent editor
m_p_oInterface = p_oInterface;
// tell parent editor we are its main world
m_p_oInterface->SetMainWorld(this);
m_p_oCurrentEditor = m_p_oInterface->GetEditor();
// link given multidevice to the editor
p_oDevice->SetInterface(m_p_oInterface);
// tell parent editor to display the given multidevice (so our world)
m_p_oInterface->SetMultiDevice(p_oDevice);
// set CurrentFRMBase
m_p_oCurrentFrameBaseMenu = NULL;
// lights
m_lNbLocalLights = 0;
m_lNbDynamicLights = 0;
//-----------------------------------------------------------------------------------
// get all object dlls
// create instances for all Object DLLS
ap_oDLL = new CPA_DLLBase* [M_GetListOfAllDLL()->GetDLLCount()];
lNbOfDLL = M_GetListOfAllDLL()->GetAllNewDLL(ALL_OBJECTS_DLL,ap_oDLL,m_lKey);
// init list of DLLs
m_oListOfObjectDLL.RemoveAll();
// Add all instances to the world
for (i=0; i<lNbOfDLL; i++)
{
// get current instance
p_oDLL = (CPA_ObjectDLLBase *) ap_oDLL[i];
ASSERT(p_oDLL != NULL);
// set DLL parameters
p_oDLL->SetMainWorld(this);
// register the DLL
if (!p_oDLL->GetName().IsEmpty())
{
// check unicity of the DLL with the given engine type
p_oPreviousDLL = GetObjectDLLWithName(p_oDLL->GetName());
if (p_oPreviousDLL)
{
csMessage = "Two Object DLLs have the same name " + p_oDLL->GetName() + ".";
M_GetMainWnd()->MessageBox(csMessage, "Unable to load the DLLs", MB_ICONSTOP|MB_OK);
ASSERT(0);
}
// if DLL is OK, add it to Editor List
m_oListOfObjectDLL.AddTail(p_oDLL);
}
}
//-----------------------------------------------------------------------------------
// get all tool dlls
// create instances for all tool DLLS
lNbOfDLL = M_GetListOfAllDLL()->GetAllNewDLL(ALL_TOOLS_DLL,ap_oDLL,m_lKey);
// init list of DLLs
m_oListOfToolDLL.RemoveAll();
//MT
m_oListOfToolDLLReceivingWindowMsg.RemoveAll();
m_oListOfToolDLLReceivingEvtEditorMsg.RemoveAll();
//MT
// Add all instances to the world
for (i=0; i<lNbOfDLL; i++)
{
// get current instance
p_oToolDLL = (CPA_ToolDLLBase *) ap_oDLL[i];
ASSERT(p_oToolDLL != NULL);
// Set DLL parmeters
p_oToolDLL->SetMainWorld(this);
// register the DLL
m_oListOfToolDLL.AddTail(p_oToolDLL);
}
delete [] ap_oDLL;
// now that we have the object dll list, we can buil the world
m_p_oGlobalWorld = new CPA_World(this);
// tell given multidevice to display our world
((DEV_MultiDevice3D*)(p_oDevice))->SetWorld(m_p_oGlobalWorld);
// reserve a slot in the MainWorld's World CameraSlots for the prevcam tip
CPA_CameraSlots *p_oCamSlots;
p_oCamSlots = m_p_oGlobalWorld->GetCameraSlots();
p_oCamSlots->ActivatePrevCamTip();
// and init the given evt editor
m_p_oInterface->Create();
}
/*===========================================================================
* Description: destructor
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_MainWorld::~CPA_MainWorld()
{
delete m_p_oGlobalWorld;
m_p_oGlobalWorld = NULL;
delete m_p_oInterface;
m_p_oInterface = NULL;
}
/*===========================================================================
* Description: load a new editor world
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_MainWorld::LoadANewWorld(char *szPath, char *szFileName)
{
/* *** SHAITAN => chargements modifi<66>s + changement script => TODO ***
char szOldPath[C_MaxLenPath];
CPA_SuperObject *p_oSuperObject;
SCRIPT_tdstError *err;
// Deplacement dans le repertoire de datas
getcwd(szOldPath,C_MaxLenPath);
chdir(szPath);
// Init des scripts et lecture du fichier
SCRIPT_vRegisterPath(szPath);
SCRIPT_vSetResultSubSection((long)this);
p_oSuperObject = (CPA_SuperObject*)SCRIPT_ulAnalyseSection(szFileName,"Edit-SuperObject_Root");
err = SCRIPT_p_stGetLastError();
if (err)
{
ASSERT(0);
}
// Replacement dans le repertoire precedent
chdir(szOldPath);
m_p_oGlobalWorld->fn_vSetRoot(p_oSuperObject);
*/
}
/*===========================================================================
* Description: update main frame
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_MainWorld::fn_vSetCurrentFRMBaseMenu(FRMBaseMenu *_p_oCurrentFrameBaseMenu)
{
m_p_oCurrentFrameBaseMenu = _p_oCurrentFrameBaseMenu;
m_p_oCurrentFrameBaseMenu->fn_vUpdateCurrentEditor(NULL);
}
//=================================================================================
//=================================================================================
//================= OLE TOOLS =====================================================
//=================================================================================
//=================================================================================
//=================================================================================
/*===========================================================================
* Description: get BaseObjectList of valid objects with corresponding type
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_BaseObjectList *CPA_MainWorld::fn_p_oGetOriginalObjectList(CString csType)
{
POSITION stPos;
CPA_DLLBase *p_oDLL;
CPA_BaseObjectList *p_oList;
p_oList = NULL;
// check with superobject list
if ((p_oList = GetInterface()->GetEditor()->GetBaseObjectList(csType)) != NULL)
return p_oList;
// look in Object DLLs
stPos = m_oListOfObjectDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
if ((p_oList = p_oDLL->GetBaseObjectList(csType)) != NULL)
return p_oList;
}
// look in Tool DLLs
stPos = m_oListOfToolDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
if ((p_oList = p_oDLL->GetBaseObjectList(csType)) != NULL)
return p_oList;
}
return NULL;
}
/*===========================================================================
* Description: get BaseObjectList of invalid objects with corresponding type
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_BaseObjectList *CPA_MainWorld::fn_p_oGetInvalidObjectList(CString csType)
{
POSITION stPos;
CPA_DLLBase *p_oDLL;
CPA_BaseObjectList *p_oList;
p_oList = NULL;
// check with superobject list
if ((p_oList = GetInterface()->GetEditor()->GetInvalidObjectList(csType)) != NULL)
return p_oList;
// look in Object DLLs
stPos = m_oListOfObjectDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
if ((p_oList = p_oDLL->GetInvalidObjectList(csType)) != NULL)
return p_oList;
}
// look in Tool DLLs
stPos = m_oListOfToolDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
if ((p_oList = p_oDLL->GetInvalidObjectList(csType)) != NULL)
return p_oList;
}
return NULL;
}
/*===========================================================================
* Description: fill list with objects corresponding to criteria
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
long CPA_MainWorld::fn_lFindObjects (CPA_List<CPA_BaseObject> *p_oList, CString csObjectName, CString csObjectType, CPA_BaseObject *p_oOwner, tdeResearchCriteria eCriteria)
{
POSITION stPos;
long lResult;
CPA_DLLBase *p_oDLL;
lResult = 0;
// look in EvtEditor
lResult += GetInterface()->GetEditor()->fn_lFindObjects(p_oList, csObjectName, csObjectType, p_oOwner, eCriteria);
// look in Object DLLs
stPos = m_oListOfObjectDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
lResult += p_oDLL->fn_lFindObjects(p_oList, csObjectName, csObjectType, p_oOwner, eCriteria);
}
// look in Tool DLLs
stPos = m_oListOfToolDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
lResult += p_oDLL->fn_lFindObjects(p_oList, csObjectName, csObjectType, p_oOwner, eCriteria);
}
return lResult;
}
/*===========================================================================
* Description: fill list with objects corresponding to criteria
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_BaseObject *CPA_MainWorld::fn_p_oFindObjectWithEngine(void *p_vEngineStruct, CString csObjectType, CPA_BaseObject *p_oOwner, tdeResearchCriteria eCriteria)
{
POSITION stPos;
CPA_DLLBase *p_oDLL;
CPA_BaseObject *p_oResultObject;
p_oResultObject = NULL;
// look in EvtEditor
p_oResultObject = GetInterface()->GetEditor()->GetBaseObject(p_vEngineStruct, csObjectType, p_oOwner, eCriteria);
if (p_oResultObject)
return p_oResultObject;
// look in Object DLLs
stPos = m_oListOfObjectDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
p_oResultObject = p_oDLL->GetBaseObject(p_vEngineStruct, csObjectType, p_oOwner, eCriteria);
if (p_oResultObject != NULL)
return p_oResultObject;
}
// look in Tool DLLs
stPos = m_oListOfToolDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
p_oResultObject = p_oDLL->GetBaseObject(p_vEngineStruct, csObjectType, p_oOwner, eCriteria);
if (p_oResultObject != NULL)
return p_oResultObject;
}
return p_oResultObject;
}
/*===========================================================================
* Description: find first object corresponding to criteria
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_BaseObject *CPA_MainWorld::fn_p_oFindObject(CString csObjectName, CString csObjectType, CPA_BaseObject *p_oOwner, tdeResearchCriteria eCriteria)
{
POSITION stPos;
CPA_DLLBase *p_oDLL;
CPA_BaseObject *p_oResultObject;
p_oResultObject = NULL;
// look in EvtEditor
p_oResultObject = GetInterface()->GetEditor()->GetBaseObject(csObjectName, csObjectType, p_oOwner, eCriteria);
if (p_oResultObject)
return p_oResultObject;
// look in Object DLLs
stPos = m_oListOfObjectDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
p_oResultObject = p_oDLL->GetBaseObject(csObjectName, csObjectType, p_oOwner, eCriteria);
if (p_oResultObject != NULL)
return p_oResultObject;
}
// look in Tool DLLs
stPos = m_oListOfToolDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
p_oResultObject = p_oDLL->GetBaseObject(csObjectName, csObjectType, p_oOwner, eCriteria);
if (p_oResultObject != NULL)
return p_oResultObject;
}
return p_oResultObject;
}
/*===========================================================================
* Description: check if there is an object corresponding to criteria
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_MainWorld::fn_bExist(CString csName, CString csTypeName, CPA_BaseObject *p_oOwner, tdeResearchCriteria eCriteria)
{
POSITION stPos;
CPA_DLLBase *p_oDLL;
BOOL bOK;
bOK = FALSE;
// if type == superobject, just look in the SO list
bOK = GetInterface()->GetEditor()->fn_bExist(csName, csTypeName, p_oOwner, eCriteria);
// look in Object DLLs
stPos = m_oListOfObjectDLL.GetHeadPosition();
while (stPos && !bOK)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
bOK = p_oDLL->fn_bExist(csName, csTypeName, p_oOwner, eCriteria);
}
// look in Tool DLLs
stPos = m_oListOfToolDLL.GetHeadPosition();
while (stPos && !bOK)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
bOK = p_oDLL->fn_bExist(csName, csTypeName, p_oOwner, eCriteria);
}
return bOK;
}
/*===========================================================================
* Description: check if this object is registered (valid, invalid or all)
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_MainWorld::fn_bExist(CPA_BaseObject *p_oObject, tdeResearchCriteria eCriteria)
{
POSITION stPos;
CPA_DLLBase *p_oDLL;
BOOL bOK;
bOK = FALSE;
// if type == superobject, just look in the SO list
bOK = GetInterface()->GetEditor()->fn_bExist(p_oObject, eCriteria);
// look in Object DLLs
stPos = m_oListOfObjectDLL.GetHeadPosition();
while (stPos && !bOK)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
bOK = p_oDLL->fn_bExist(p_oObject, eCriteria);
}
// look in Tool DLLs
stPos = m_oListOfToolDLL.GetHeadPosition();
while (stPos && !bOK)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
bOK = p_oDLL->fn_bExist(p_oObject, eCriteria);
}
return bOK;
}
/*===========================================================================
* Description: add an editor to the list
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_MainWorld::fn_vRegisterEditor (CPA_EditorBase *p_oEditor)
{
if(!m_oListOfEditorBase.Find(p_oEditor))
m_oListOfEditorBase.AddTail(p_oEditor);
}
/*===========================================================================
* Description: find an editor with its name
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_EditorBase *CPA_MainWorld::GetEditorByName(CString csName)
{
POSITION stPos = m_oListOfEditorBase.GetHeadPosition();
while( stPos )
{
CPA_EditorBase *p_oEditor = m_oListOfEditorBase.GetNext(stPos);
if(p_oEditor -> GetCurrentEditorName() == csName )
return p_oEditor;
}
return NULL;
}
/*===========================================================================
* Description: find the DLL that handles this editor type
* Creation date:
* Author:
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_DLLBase *CPA_MainWorld::GetDLLWithTypeName(CString csType)
{
POSITION stPos;
CPA_DLLBase *p_oDLL;
CPA_BaseObjectList *p_oList;
p_oList = NULL;
// look in Object DLLs
stPos = m_oListOfObjectDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
if ((p_oList = p_oDLL->GetBaseObjectList(csType)) != NULL)
return p_oDLL;
}
// look in Tool DLLs
stPos = m_oListOfToolDLL.GetHeadPosition();
while (stPos)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
if ((p_oList = p_oDLL->GetBaseObjectList(csType)) != NULL)
return p_oDLL;
}
return NULL;
}
/*===========================================================================
* Description: get the object DLL with the given name
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_ObjectDLLBase * CPA_MainWorld::GetObjectDLLWithName (CString csName)
{
POSITION stPos;
CPA_ObjectDLLBase *p_oDLL;
stPos = m_oListOfObjectDLL.GetHeadPosition();
while(stPos != NULL)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
if (csName == p_oDLL->GetName())
return p_oDLL;
}
return NULL;
}
/*===========================================================================
* Description: get the object DLL that can handle the given engine type
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_ObjectDLLBase * CPA_MainWorld::GetObjectDLLWithType (long lEngineType)
{
POSITION stPos;
CPA_ObjectDLLBase *p_oDLL;
stPos = m_oListOfObjectDLL.GetHeadPosition();
while(stPos != NULL)
{
p_oDLL = m_oListOfObjectDLL.GetNext(stPos);
if (p_oDLL->fn_bCanHandleThisType(lEngineType))
return p_oDLL;
}
return NULL;
}
/*===========================================================================
* Description: get the tool DLL with the given name
* Creation date:
* Author: MT
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
CPA_ToolDLLBase * CPA_MainWorld::GetToolDLLWithName(char *_szName)
{
POSITION stPos;
CPA_ToolDLLBase *p_oDLL;
stPos = m_oListOfToolDLL.GetHeadPosition();
while(stPos != NULL)
{
p_oDLL = m_oListOfToolDLL.GetNext(stPos);
if (!strcmp(p_oDLL->GetName(), _szName))
return p_oDLL;
}
return NULL;
}
/*===========================================================================
* Description: add/remove the tool DLL from the list
* Creation date:
* Author: MT
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_MainWorld::fn_vSetReceivingWindowMsgState(CPA_ToolDLLBase * _p_oToolDLL,BOOL _bWantToReceive /*=TRUE*/)
{
POSITION stPos = m_oListOfToolDLLReceivingWindowMsg.Find(_p_oToolDLL);
if(_bWantToReceive)
{
//add Tool on list
if(!stPos)
m_oListOfToolDLLReceivingWindowMsg.AddTail(_p_oToolDLL);
}
else
{
//remove tool from list
if(stPos)
m_oListOfToolDLLReceivingWindowMsg.RemoveAt(stPos);
}
}
/*===========================================================================
* Description: add/remove the tool DLL form the list
* Creation date:
* Author: MT
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_MainWorld::fn_vSetReceivingEvtEditorMsgState(CPA_ToolDLLBase *_p_oToolDLL,BOOL _bWantToReceive /*=TRUE*/)
{
POSITION stPos = m_oListOfToolDLLReceivingEvtEditorMsg.Find(_p_oToolDLL);
if(_bWantToReceive)
{
//add Tool on list
if(!stPos)
m_oListOfToolDLLReceivingEvtEditorMsg.AddTail(_p_oToolDLL);
}
else
{
//remove tool from list
if(stPos)
m_oListOfToolDLLReceivingEvtEditorMsg.RemoveAt(stPos);
}
}
//********************************************************************************
//********************************************************************************
/*===========================================================================
* Description: Activate a new Editor
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_MainWorld::fn_bActivateEditor (CPA_EditorBase *pNewEditor, CPA_List<CPA_BaseObject> *pParams)
{
CPA_EditorBase *p_oOldEditor = m_p_oCurrentEditor;
CPA_EditorBase *p_oCurEditor = m_p_oCurrentEditor;
tdePermission ePermission = C_CloseBefore;
// ask permission to new DLL
if (!pNewEditor->fn_bCanActivateEditor(pParams))
return FALSE;
// disable refresh to avoid flicking
g_oFrameGest.mfn_vSetRefresh(FALSE);
// if necessary, restore context
while (ePermission == C_CloseBefore)
{
ePermission = m_p_oCurrentEditor->fn_eAcceptNewEditor(pNewEditor);
if (ePermission == C_CloseBefore)
{
if (m_p_oCurrentEditor->fn_bIsCurrentEditor())
{
m_p_oCurrentEditor->fn_vOnCloseEditor();
m_p_oCurrentEditor->SetCurrent(FALSE);
m_p_oCurrentEditor->fn_vRestoreContext();
}
else
ePermission = C_Allow;
}
}
// update old editor
p_oCurEditor = m_p_oCurrentEditor;
// if current editor refuse or is the new one, re-activate it
if ((ePermission != C_Allow)||(pNewEditor == p_oCurEditor))
{
fn_bRestoreEditor(p_oOldEditor);
fn_bSetCurrentEditor(p_oCurEditor);
g_oFrameGest.mfn_vSetRefresh(TRUE);
m_p_oCurrentFrameBaseMenu->fn_vUpdateCurrentEditor(m_p_oCurrentEditor);
return FALSE;
}
// save current context
pNewEditor->fn_vSaveContext();
// set new editor
fn_bRestoreEditor(p_oOldEditor);
fn_bSetCurrentEditor(pNewEditor);
GetInterface()->fn_vCancelAllModes();
// activate the new editor
pNewEditor->fn_vOnActivateEditor(pParams);
// resfresh all dialogs
g_oFrameGest.mfn_vSetRefresh(TRUE);
//VL170997
// When previous refresh was done some window are hidden after being shown.
// here we force frame gest to show again windows
g_oFrameGest.mfn_vRefreshWindows( TRUE );
//EVL170997
((DEV_ViewPort3D *) GetInterface()->GetMultiDevice()->GetFocusDevice()->GetViewPort())->SetFocus();
return TRUE;
}
/*===========================================================================
* Description: Close Editor
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_MainWorld::fn_bCloseEditor (CPA_EditorBase *pOldEditor)
{
CPA_EditorBase *p_oOldEditor = m_p_oCurrentEditor;
CPA_EditorBase *p_oCurEditor = m_p_oCurrentEditor;
// non-current editor is already closed
if (!pOldEditor->fn_bIsCurrentEditor())
return TRUE;
// ask permission
if (!pOldEditor->fn_bCanCloseEditor())
return FALSE;
g_oFrameGest.mfn_vSetRefresh(FALSE);
// restore all parameters and close
pOldEditor->fn_vOnCloseEditor();
pOldEditor->SetCurrent(FALSE);
pOldEditor->fn_vRestoreContext();
// update old editor
p_oCurEditor = m_p_oCurrentEditor;
fn_bRestoreEditor(p_oOldEditor);
fn_bSetCurrentEditor(p_oCurEditor);
// restore focus
g_oFrameGest.mfn_vSetRefresh(TRUE);
((DEV_ViewPort3D *) GetInterface()->GetMultiDevice()->GetFocusDevice()->GetViewPort())->SetFocus();
return TRUE;
}
/*===========================================================================
* Description: update the current DLL
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_MainWorld::fn_bSetCurrentEditor (CPA_EditorBase *p_oEditor)
{
CPA_ToolDLLBase *pDLLTool;
POSITION pos;
// if there's no change
if (p_oEditor == m_p_oCurrentEditor)
return FALSE;
// send message to Tool DLLs
for (pDLLTool = GetToolDLLReceivingEvtEditorMsg()->GetHeadElement(pos); pDLLTool;
pDLLTool = GetToolDLLReceivingEvtEditorMsg()->GetNextElement(pos))
pDLLTool->fn_vOnChangeCurrentEditor(m_p_oCurrentEditor, p_oEditor);
// tell the new DLL it just lost focus
m_p_oCurrentEditor->fn_vHasLostFocus();
m_p_oCurrentEditor->SetCurrent(FALSE);
// set current editor
m_p_oCurrentEditor = p_oEditor;
// tell the new DLL it just gained focus
m_p_oCurrentEditor->fn_bHasGainedFocus();
m_p_oCurrentEditor->SetCurrent(TRUE);
// update menu
m_p_oCurrentFrameBaseMenu->fn_vUpdateCurrentEditor(m_p_oCurrentEditor);
return TRUE;
}
/*===========================================================================
* Description: update the current DLL
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
BOOL CPA_MainWorld::fn_bRestoreEditor (CPA_EditorBase *p_oEditor)
{
// if there's no change
if (p_oEditor == m_p_oCurrentEditor)
return FALSE;
// set current editor
m_p_oCurrentEditor = p_oEditor;
return TRUE;
}
#endif //ACTIVE_EDITOR

View File

@@ -0,0 +1,151 @@
/*=========================================================================
*
* EDTpopm.cpp : popup menu
*
*
* Version 1.1
* Creation date
* Revision date 06/03/97 MT
*
* FBF
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "ACP_Base.h"
#include "geo.h"
#include "gli.h"
#include "col.h"
#define HieFriend
#include "spo.h"
#include "lst.hpp"
#include "IncTUT.h"
#include "itf/CPApopm.hpp"
#include "itf/CPADLLb.hpp"
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-------------------------ENTRY MENU CODE-------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Description : constructor
// ----------------------------------------------------------------------------
EDT_PopUpMenuEntry::EDT_PopUpMenuEntry(CPA_EditorBase *p_oOwner, char *p_cText, UINT uiMsgID, UINT uiIntID, BOOL _bCheck /*=FALSE*/, BOOL _bEnable /*=TRUE*/)
:EDT_SubMenuEntry (p_oOwner, p_cText, uiMsgID, uiIntID, _bCheck , _bEnable)
{
}
// ----------------------------------------------------------------------------
// Description : call handle function
// ----------------------------------------------------------------------------
UINT EDT_PopUpMenuEntry::SendCommand(EDT_SubMenu *_p_oSubMenu)
{
if (m_pOwner)
m_pOwner->_OnPopUpMenuCommand(m_IDCmdMsg);
return NULL;
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-------------------------POPUP MENU CODE-------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Description : constructor
// ----------------------------------------------------------------------------
EDT_PopUpMenu::EDT_PopUpMenu(UINT _uiIDStart /*=C_EDTPopUpMenuIDStart*/)
:EDT_SubMenu(C_PopupMenu,_uiIDStart)
{
}
// ----------------------------------------------------------------------------
// Description : construct the PopupMenu
// ----------------------------------------------------------------------------
void EDT_PopUpMenu::Build(CMenu *_p_oMenu)
{
if( !m_bHasFather )
{
m_oMenu . CreatePopupMenu();
EDT_SubMenu::Build(&m_oMenu);
}
else
{
ASSERT( _p_oMenu );
EDT_SubMenu::Build(_p_oMenu);
}
}
// ----------------------------------------------------------------------------
// Description : display the PopupMenu
// ----------------------------------------------------------------------------
void EDT_PopUpMenu::Draw(DEV_ViewPort *_p_oViewPort,tdstMousePos *p_stCoords)
{
BOOL bWasInSecondScreen = FALSE;
// register the popup menu for the tutorial module
TUT_M_vGetTutDll ();
TUT_M_vRegisterMenu (_p_oViewPort -> m_hWnd , m_oMenu . m_hMenu , p_stCoords->stPos.x , p_stCoords->stPos.y);
// Shaitan - For second screen mode
if (M_bFullScreenEditor() && _p_oViewPort->GetDevice()->IsFullScreen() && !((DEV_ViewPort3D *)_p_oViewPort)->IsCursorInFirstScreen ())
{
bWasInSecondScreen = TRUE;
//disable the confine of the cursor
SetCursorPos (p_stCoords->stPos.x, p_stCoords->stPos.y);
ShowCursor (TRUE);
ReleaseCapture ();
ClipCursor (NULL);
((DEV_ViewPort3D *)_p_oViewPort)->SetCursorInFirstScreen ();
}
m_oMenu . TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, p_stCoords->stPos.x, p_stCoords->stPos.y, _p_oViewPort);
m_oMenu . DestroyMenu();
if (bWasInSecondScreen)
{
ShowCursor (FALSE);
_p_oViewPort->SetCapture ();
SetCursorPos (p_stCoords->stPos.x, p_stCoords->stPos.y);
((DEV_ViewPort3D *)_p_oViewPort)->SetCursorInSecondScreen ();
}
}
// ----------------------------------------------------------------------------
// Description : get a new SubMenu (must uses it as sub menu of 'this')
// ----------------------------------------------------------------------------
EDT_SubMenu *EDT_PopUpMenu::fn_p_oGetNewSubMenu(char *_szName, tde_SubMenu _eMenuType /*=C_SubSubMenu*/)
{
ASSERT( _szName );
EDT_PopUpMenu *p_oResult = new EDT_PopUpMenu( _eMenuType == C_SubSubMenu ? GetSubMenuType() : _eMenuType );
p_oResult -> fn_vSetName( _szName );
p_oResult -> fn_vSetFather( this );
return p_oResult;
}
// ----------------------------------------------------------------------------
// Description : add an entry from DLL
// ----------------------------------------------------------------------------
void EDT_PopUpMenu::AddAnEntry(CPA_EditorBase *p_oOwner, char *p_cText, UINT uiEntryID, BOOL _bCheck /*=FALSE*/, BOOL _bEnable /*=TRUE*/)
{
AddTail(new EDT_PopUpMenuEntry(p_oOwner, p_cText, uiEntryID, mfn_vGetNextInternalID(), _bCheck, _bEnable));
}
#endif

View File

@@ -0,0 +1,814 @@
/*=========================================================================
* CPAPopTB : Implementation of PopUpToolBar.
* This is a part of the PCA project.
*
* Version 1.0
* Creation date 26/06/96
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "geo.h"
#include "gli.h"
#include "itf/CPAPopTB.hpp"
#include "itf/DEVMulti.hpp"
#include "itf/DEVViewp.hpp"
#include "itf/CPAProj.hpp"
BOOL g_bMouseLocked = FALSE;
/////////////////////////////////////////////////////////////////////////////
// CPA_PopUpToolBar
CPA_PopUpToolBar::CPA_PopUpToolBar()
{
m_bMousePickedButton = FALSE;
m_lNbButtonsTotal = 0;
m_lNbFamilies = 0;
m_bCurrentButtonAlone = FALSE;
m_bDefined = FALSE;
m_bJustPressed = FALSE;
m_bAllreadyCreated = FALSE;
}
CPA_PopUpToolBar::~CPA_PopUpToolBar()
{
}
// copy constructor : the toolbar is built and defines, but not created
CPA_PopUpToolBar::CPA_PopUpToolBar(CPA_PopUpToolBar &r_src)
{
long k;
m_bMousePickedButton = FALSE;
m_bCurrentButtonAlone = FALSE;
m_bJustPressed = FALSE;
m_lNbButtonsTotal = r_src.m_lNbButtonsTotal;
m_lIdResource = r_src.m_lIdResource;
m_lIdEndFamily = r_src.m_lIdEndFamily;
m_lButtonSizeX = r_src.m_lButtonSizeX;
m_lButtonSizeY = r_src.m_lButtonSizeY;
m_lIdCurrentButton = r_src.m_lIdCurrentButton;
m_lNbFamilies = r_src.m_lNbFamilies;
for (k=0; k<m_lNbFamilies; k++)
{
m_a_lFamiliesIndex[k] = r_src.m_a_lFamiliesIndex[k];
m_a_lInitialStates[k] = r_src.m_a_lInitialStates[k];
}
for (k = 0; k < m_lNbButtonsTotal; k++)
{
m_a_stButtons[k] = r_src.m_a_stButtons[k];
m_a_bInitialPermissions[k] = r_src.m_a_bInitialPermissions[k];
// set initial permissions
m_a_stButtons[k].bPermit = m_a_bInitialPermissions[k];
}
for (k=0; k<m_lNbFamilies; k++)
{
// copy toolbar state
// m_a_lButtonsInTBIndex[k] = r_src.m_a_lButtonsInTBIndex[k];
// set toolbar state to initial values
m_a_lButtonsInTBIndex[k] = GetIndex(m_a_lInitialStates[k]);
}
m_bDefined = TRUE;
m_bAllreadyCreated = r_src.m_bAllreadyCreated;
}
BEGIN_MESSAGE_MAP(CPA_PopUpToolBar, CToolBarCtrl)
//{{AFX_MSG_MAP(CPA_PopUpToolBar)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// gets the Id of the initial state of each family
long CPA_PopUpToolBar::GetInitialStates(long a_lStates[])
{
long i;
for (i = 0; i < m_lNbFamilies; i++)
a_lStates[i] = m_a_lInitialStates[i];
return m_lNbFamilies;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// gets the initial permission of all butttons
long CPA_PopUpToolBar::GetInitialPermissions(BOOL a_bPermissions[])
{
long i;
for (i = 0; i < m_lNbButtonsTotal; i++)
a_bPermissions[i] = m_a_bInitialPermissions[i];
return m_lNbButtonsTotal;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// gets the Id of all the buttons visible in the toolbar
long CPA_PopUpToolBar::GetStates(long a_lStates[])
{
long i;
for (i = 0; i < m_lNbFamilies; i++)
a_lStates[i] = m_a_stButtons[m_a_lButtonsInTBIndex[i]].lId;
return m_lNbFamilies;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
long CPA_PopUpToolBar::GetIndex(long lIdButton)
{
for (int i=0;i<m_lNbButtonsTotal;i++)
{
if (lIdButton == m_a_stButtons[i].lId)
return i;
}
return -1;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the visibility of the given button
void CPA_PopUpToolBar::SetVisibility(long lId, BOOL bVisible)
{
long lIndex;
lIndex = GetIndex(lId);
ASSERT(lIndex != -1);
m_a_stButtons[lIndex].bVisible = bVisible;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the visibility of the given buttons
void CPA_PopUpToolBar::SetVisibility(long a_lIdButtons[], BOOL a_bVisible[],long lNbButtons)
{
long i;
for (i=0;i<lNbButtons;i++)
{
SetPermission(a_lIdButtons[i],a_bVisible[i]);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// put the given button in the toolbar, at the appropriate
// position (acording to its family)
void CPA_PopUpToolBar::SetButton(long lId)
{
TBBUTTON TBBut;
long lFamily,lIndex;
if (lId == m_lIdEndFamily)
return;
lIndex = GetIndex(lId);
ASSERT(lIndex != -1);
if (IsStandAlone(lId) == FALSE)
ASSERT(m_a_stButtons[lIndex].bPermit == TRUE);
if (m_a_stButtons[lIndex].bIsAMode == FALSE)
return;
lFamily = GetFamily(lId);
ASSERT(lFamily != -1);
GetButton(lFamily, &TBBut);
// Which bitmap ?
TBBut.iBitmap = m_a_stButtons[lIndex].lIndexBitmap;
TBBut.idCommand = lId;
InsertButton(lFamily, &TBBut);
DeleteButton(lFamily+1);
m_a_lButtonsInTBIndex[lFamily] = lIndex;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// put the given buttons in the toolbar, at the appropriate
// position (acording to its family)
void CPA_PopUpToolBar::SetButtons(long pId[])
{
UINT i;
for (i = 0; i < (unsigned int) m_lNbFamilies; i++)
SetButton(pId[i]);
RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// ask if the given button exists in this toolbar
BOOL CPA_PopUpToolBar::IsPresent(long lIdButton)
{
for (int i=0;i<m_lNbButtonsTotal;i++)
{
if (lIdButton == m_a_stButtons[i].lId)
return TRUE;
}
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// ask if the given button is on the screen
BOOL CPA_PopUpToolBar::IsOnScreen(long lIdButton)
{
for (int i=0;i<m_lNbFamilies;i++)
{
if (lIdButton == m_a_stButtons[m_a_lButtonsInTBIndex[i]].lId)
return TRUE;
}
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// ask is the given button is permitted
BOOL CPA_PopUpToolBar::IsPermitted(long lId)
{
long lIndex;
lIndex = GetIndex(lId);
ASSERT(lIndex != -1);
return (m_a_stButtons[lIndex].bPermit);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// ask is the given button is alone in its family
BOOL CPA_PopUpToolBar::IsStandAlone(long lId)
{
long lFamily;
lFamily = GetFamily(lId);
return (GetNbButtonsTotalInFamily(lFamily) == 1);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// ask if the given button is a mode button
BOOL CPA_PopUpToolBar::IsAMode(long lId)
{
long lIndex;
lIndex = GetIndex(lId);
ASSERT(lIndex != -1);
return (m_a_stButtons[lIndex].bIsAMode);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the permission of a button
void CPA_PopUpToolBar::SetPermission(long lId, BOOL bPermit)
{
long lIndex;
if (lId == m_lIdEndFamily)
return;
lIndex = GetIndex(lId);
ASSERT(lIndex != -1);
m_a_stButtons[lIndex].bPermit = bPermit;
if (IsStandAlone(lId))
{
// stand-alone button, we must disable it in the toolbar
EnableButton(lId,bPermit);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the permission of several buttons
void CPA_PopUpToolBar::SetPermissions(long a_lIdButtons[], BOOL a_bPermit[], long lNbButtons)
{
long i;
for (i=0;i<lNbButtons;i++)
{
SetPermission(a_lIdButtons[i],a_bPermit[i]);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the initial permissions of several buttons
void CPA_PopUpToolBar::SetInitialPermissions(long a_lIdButtons[], BOOL a_bPermit[], long lNbButtons)
{
long i,lIndex;
for (i=0;i<lNbButtons;i++)
{
lIndex = GetIndex(a_lIdButtons[i]);
ASSERT(lIndex != -1);
m_a_bInitialPermissions[lIndex] = a_bPermit[i];
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the initial state of several buttons
void CPA_PopUpToolBar::SetInitialStates(long a_lIdButtons[],long lNbButtons)
{
long i,lFamily;
for (i=0;i<lNbButtons;i++)
{
lFamily = GetFamily(a_lIdButtons[i]);
ASSERT(lFamily != -1);
m_a_lInitialStates[lFamily] = a_lIdButtons[i];
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the initial permissions of one button
void CPA_PopUpToolBar::SetInitialPermission(long lIdButton,BOOL bPermit)
{
long lIndex;
lIndex = GetIndex(lIdButton);
ASSERT(lIndex != -1);
m_a_bInitialPermissions[lIndex] = bPermit;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the initial state of one button
void CPA_PopUpToolBar::SetInitialState(long lIdButton)
{
long lFamily;
lFamily = GetFamily(lIdButton);
ASSERT(lFamily != -1);
m_a_lInitialStates[lFamily] = lIdButton;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// sets the permission of all buttons
void CPA_PopUpToolBar::SetPermissions(BOOL a_bPermit[])
{
long i;
for (i=0;i<m_lNbButtonsTotal;i++)
{
SetPermission(m_a_stButtons[i].lId,a_bPermit[i]);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// tooltips
BOOL CPA_PopUpToolBar::GetToolTipText(LPTOOLTIPTEXT p_ToolTipText, UINT Id)
{
long lButtonIndex;
lButtonIndex = GetIndex(Id);
if (lButtonIndex == -1) return FALSE;
strcpy(p_ToolTipText->szText,m_a_stButtons[lButtonIndex].szTipText);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// tells the toolbarcontrol how many buttons there are, and draw the visible ones.
long CPA_PopUpToolBar::CreateToolBarCtrl(CWnd *p_WndParent, CPoint org)
{
TBBUTTON a_stTBBut[C_MAX_POPUPTOOLBAR_FAMILY];
long iBitmap;
long i;
Create(CCS_NODIVIDER | CBRS_TOOLTIPS| TBSTYLE_TOOLTIPS |
WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | CBRS_SIZE_DYNAMIC,
CRect(org.x,org.y,20,50),
p_WndParent,
m_lIdResource);
SetButtonSize(CSize(m_lButtonSizeX,m_lButtonSizeY));
SetBitmapSize(CSize(m_lButtonSizeX,m_lButtonSizeY));
iBitmap = AddBitmap(m_lNbButtonsTotal, m_lIdResource);
// sets buttons bitmaps
for (i = 0; i < m_lNbButtonsTotal; i++)
m_a_stButtons[i].lIndexBitmap = i + iBitmap;
if (!m_bAllreadyCreated)
{
// sets buttons initial state
for ( i = 0; i < m_lNbFamilies; i++)
m_a_lButtonsInTBIndex[i] = GetIndex(m_a_lInitialStates[i]);
// sets buttons initial permissions
for (i = 0; i < m_lNbButtonsTotal; i++)
m_a_stButtons[i].bPermit = m_a_bInitialPermissions[i];
}
m_bAllreadyCreated = TRUE;
// add buttons
for ( i = 0; i < m_lNbFamilies; i++)
{
if (IsStandAlone(m_a_stButtons[m_a_lButtonsInTBIndex[i]].lId))
ASSERT(m_a_stButtons[m_a_lButtonsInTBIndex[i]].bPermit);
ASSERT(IsAMode(m_a_stButtons[m_a_lButtonsInTBIndex[i]].lId));
a_stTBBut[i].fsState = (m_a_stButtons[m_a_lButtonsInTBIndex[i]].bPermit)? TBSTATE_ENABLED : TBSTATE_INDETERMINATE ; // button state
a_stTBBut[i].fsStyle = TBSTYLE_BUTTON; // button style--see below
a_stTBBut[i].dwData = NULL; // application-defined value
a_stTBBut[i].iString = NULL; // zero-based index of button label string
a_stTBBut[i].iBitmap = m_a_stButtons[m_a_lButtonsInTBIndex[i]].lIndexBitmap;
a_stTBBut[i].idCommand = m_a_lInitialStates[i];
}
AddButtons( m_lNbFamilies, a_stTBBut );
RECT stButtonRect;
GetItemRect(0,&stButtonRect);
MoveWindow
(
org.x, org.y,
(stButtonRect.right - stButtonRect.left + 1) * m_lNbFamilies,
(stButtonRect.bottom - stButtonRect.top + 2)
);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// returns the family number of the given button;
// return -1 if button couldn't be found
// the family number is also the zero-based position of the button in the toolbar
long CPA_PopUpToolBar::GetFamily(long lIdButton)
{
long i,lfamily;
ASSERT (lIdButton != m_lIdEndFamily);
lfamily = 0;
for (i=0; i<m_lNbButtonsTotal;i++)
{
if (m_a_stButtons[i].lId == lIdButton)
return lfamily;
if (m_a_stButtons[i].lId == m_lIdEndFamily)
lfamily++;
}
return -1;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// return the total number of buttons in the given family
// (not included the EndFamily)
long CPA_PopUpToolBar::GetNbButtonsTotalInFamily(long lFamily)
{
long lNbButtons,lFamilyIndex;
ASSERT( (lFamily >=0) && (lFamily < m_lNbFamilies));
lNbButtons = 0;
lFamilyIndex = m_a_lFamiliesIndex[lFamily];
while(m_a_stButtons[lFamilyIndex++].lId != m_lIdEndFamily)
lNbButtons++;
ASSERT(lNbButtons != 0);
return lNbButtons;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// choose, in the given family, an available button that is different
// from the given one.
long CPA_PopUpToolBar::GetOtherAvailableButtonInFamily(long lIdButton,
BOOL a_bPermissions[],
long lFamily)
{
UINT i;
int k;
// get teh family of the button
if (lFamily == -1)
{
lFamily = GetFamily(lIdButton);
}
ASSERT(lFamily != -1);
// let's see if the initial button of the family suits
if (a_bPermissions == NULL)
{
if ((m_a_lInitialStates[lFamily] != lIdButton) &&
(m_a_stButtons[GetIndex(m_a_lInitialStates[lFamily])].bPermit) &&
(m_a_stButtons[GetIndex(m_a_lInitialStates[lFamily])].bIsAMode))
return m_a_lInitialStates[lFamily];
}
else
{
if ((m_a_lInitialStates[lFamily] != lIdButton) &&
(a_bPermissions[GetIndex(m_a_lInitialStates[lFamily])]) &&
(m_a_stButtons[GetIndex(m_a_lInitialStates[lFamily])].bIsAMode))
return m_a_lInitialStates[lFamily];
}
// get the index of the family
k = m_a_lFamiliesIndex[lFamily];
// k is the index of the first button of the family
for ( i = k; i < (unsigned int) m_lNbButtonsTotal; i++) // scan all buttons of the family
{
if (m_a_stButtons[i].lId == m_lIdEndFamily) return -1; // couldn't find a button
if (a_bPermissions == NULL)
{
if ((m_a_stButtons[i].lId != lIdButton) &&
(m_a_stButtons[i].bPermit) &&
(m_a_stButtons[i].bIsAMode))
return m_a_stButtons[i].lId;
}
else
{
if ((m_a_stButtons[i].lId != lIdButton) &&
(a_bPermissions[i]) &&
(m_a_stButtons[i].bIsAMode))
return m_a_stButtons[i].lId;
}
}
return -1;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// fill in the toolbar buttons with all datas
int CPA_PopUpToolBar::Define(tdstButtonDef a_stButtonDef[],
long lNbButtons,
long lIdResource,
long lIdEndFamily,
long lSizeX,
long lSizeY)
{
long k;
ASSERT((lNbButtons > 0) && (lNbButtons <= C_MAX_POPUPTOOLBAR_BUTTONS));
m_lNbButtonsTotal = lNbButtons;
m_lIdResource = lIdResource;
m_lIdEndFamily = lIdEndFamily;
m_lButtonSizeX = lSizeX;
m_lButtonSizeY = lSizeY;
// fills in the button array, and
// Count the number of Families
// a family of buttons is registered if the last button has
// the m_lIdEndFamily ID !!!!
m_lNbFamilies = 0;
m_a_lFamiliesIndex[0] = 0; // the first family begins at button 0;
for (k = 0; k < m_lNbButtonsTotal; k++)
{
m_a_stButtons[k].lId = a_stButtonDef[k].lId;
m_a_stButtons[k].bPermit = (a_stButtonDef[k].lId != m_lIdEndFamily);
m_a_bInitialPermissions[k] = (a_stButtonDef[k].lId != m_lIdEndFamily);
m_a_stButtons[k].bVisible = TRUE;
m_a_stButtons[k].bIsAMode = a_stButtonDef[k].bIsAMode;
strcpy(m_a_stButtons[k].szTipText,a_stButtonDef[k].szTip);
if (m_a_stButtons[k].lId == m_lIdEndFamily)
{
ASSERT(m_lNbFamilies < C_MAX_POPUPTOOLBAR_FAMILY-1);
// separator => one more family
m_lNbFamilies++;
m_a_lFamiliesIndex[m_lNbFamilies] = k+1;
}
}
// init : now, sets which buttons are to be displayed : the first one of
// each family
for (k=0; k<m_lNbFamilies; k++)
{
m_a_lInitialStates[k] = m_a_stButtons[m_a_lFamiliesIndex[k]].lId;
}
m_bDefined = TRUE;
return 0;
}
void CPA_PopUpToolBar::InitAllStatesArray(long aa_lSaveStates[][C_MAX_POPUPTOOLBAR_FAMILY])
{
long i,k;
// fills in the save-states array
for (i=0;i<MAX_DEVICE;i++)
{
for (k=0;k<m_lNbFamilies;k++)
{
aa_lSaveStates[i][k] = m_a_lInitialStates[k];
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
void CPA_PopUpToolBar::OnButton(UINT lId, UINT lFlags, long lIndexInTB)
{
CRect stViewportRect, stButtonRect;
long lx, ly, lIndBeginFamily;
tdstButton a_stButtonsFamily[C_MAX_BUTTON_PER_FAMILY];
long lNbButtonsFamily;
long lDx;
// Where is the new toolbar ?
GetWindowRect(&stViewportRect);
GetItemRect(0,&stButtonRect);
lDx = (stViewportRect.right-stViewportRect.left)-m_lNbFamilies*stButtonRect.right;
stViewportRect.top += stButtonRect.bottom;
stViewportRect.left += stButtonRect.right*lIndexInTB-(lDx / 2);
lx = stViewportRect.left;
ly = stViewportRect.top;
// Make the toolbar array of Id.
lIndBeginFamily = m_a_lFamiliesIndex[lIndexInTB];
lNbButtonsFamily = 0;
while (m_a_stButtons[lIndBeginFamily].lId != m_lIdEndFamily)
{
if (m_a_stButtons[lIndBeginFamily].bVisible == TRUE)
{
a_stButtonsFamily[lNbButtonsFamily++] = m_a_stButtons[lIndBeginFamily];
}
lIndBeginFamily++;
}
// Create the ToolBar.
ASSERT (lNbButtonsFamily > 1) ;
m_oWndButton.CreateWndButton(this,
lx,
ly,
a_stButtonsFamily,
lNbButtonsFamily,
lIndexInTB,
m_lNbButtonsTotal,
m_lIdResource);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CPA_PopUpToolBar message handlers
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
void CPA_PopUpToolBar::OnLButtonDown(UINT nFlags, CPoint oPoint)
{
int i;
BOOL b;
CToolBarCtrl::OnLButtonDown(nFlags, oPoint);
m_lIdCurrentButton = -1;
for (i = 0; i < m_lNbFamilies; i++)
{
b = IsButtonPressed(m_a_stButtons[m_a_lButtonsInTBIndex[i]].lId);
if ((b != 0) && (b != -1))
{
m_lIdCurrentButton = m_a_stButtons[m_a_lButtonsInTBIndex[i]].lId;
break;
}
}
// here, i = the index of the pressed button in the toolbar
if(m_lIdCurrentButton != -1)
{
PressButton(m_lIdCurrentButton, TRUE);
m_bMousePickedButton = TRUE;
if (GetNbButtonsTotalInFamily(i) == 1)
{
// we have only one button in this family...
m_bCurrentButtonAlone = TRUE;
}
else
{
m_bCurrentButtonAlone = FALSE;
OnButton(m_lIdCurrentButton, nFlags, i);
}
}
m_bJustPressed = TRUE;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
void CPA_PopUpToolBar::OnLButtonUp(UINT nFlags, CPoint oPoint)
{
BOOL bButtonPressed;
if (m_bMousePickedButton)
bButtonPressed = IsButtonPressed(m_lIdCurrentButton);
if (m_bMousePickedButton)
{
if (m_bCurrentButtonAlone == TRUE) // case with no sub-toolbar
{
if (bButtonPressed)
{
m_bCurrentButtonAlone = FALSE;
m_bMousePickedButton = FALSE;
CToolBarCtrl::OnLButtonUp(nFlags, oPoint);
return;
}
}
else // case with sub-toolbar
{
long lIdChosenButton;
m_bCurrentButtonAlone = FALSE;
m_bMousePickedButton = FALSE;
CToolBarCtrl::OnLButtonUp(nFlags, oPoint);
PressButton(m_lIdCurrentButton,FALSE);
lIdChosenButton = m_oWndButton.GetChosenButtonId();
if (lIdChosenButton != 0)
{
SetButton(lIdChosenButton);
GetParent()->SendMessage(WM_COMMAND, lIdChosenButton);
}
}
}
else
{
CToolBarCtrl::OnLButtonUp(nFlags, oPoint);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
void CPA_PopUpToolBar::OnMouseMove(UINT nFlags, CPoint oPoint)
{
CToolBarCtrl::OnMouseMove(nFlags,oPoint); // for tooltips!!!
}
#endif // ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,695 @@
//=========================================================================
// CPAProject.cpp : Defines the class behaviors for the application.
// This is a part of the CPA project.
//
// Version 1.0
// Creation date 06/06/96
// Revision date
//
// (c) Ubi Studios 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================
#include "stdafx.h"
#include "acp_base.h"
#define __DeclareGlobalVariableErrInt_h__
#include "ErrInt.h"
#undef __DeclareGlobalVariableErrInt_h__
#define __DeclareGlobalVariableMmgInt_h__
#include "MmgInt.h"
#undef __DeclareGlobalVariableMmgInt_h__
#include "direct.h"
#undef EXTERN
#include "geo.h"
#include "gli.h"
#include "col.h"
#define HieFriend
#include "spo.h"
#include "lst.h"
#undef HieFriend
#include "Itf/CPARes.h"
#include "Itf/CPAProj.hpp"
#include "Itf/CPADoc.hpp"
#include "Itf/DEVMul3D.hpp"
#include "Itf/FRMGest.Hpp"
#include "Itf/CPACont.hpp"
#include "Itf/CPAConst.hpp"
#include "Itf/CPAkacnf.hpp"
#include "Itf/cpamworl.hpp"
#include "Itf/cpakacnf.hpp"
#include "Itf/CPAAbout.hpp"
#include "Itf/CPAInter.hpp"
/////////////////////////////////////////////////////////////////////////////
// CPA_ProjectApp
BEGIN_MESSAGE_MAP(CPA_ProjectApp, CWinApp)
//{{AFX_MSG_MAP(CPA_ProjectApp)
ON_THREAD_MESSAGE(WM_USER,OnUserMsg)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
END_MESSAGE_MAP()
//###########################################################################
// Constructor and destructor of application
//###########################################################################
//===========================================================================
// Description: CONSTRUCTOR
// => Change windows parameters
// Creation date: 27 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
CPA_ProjectApp::CPA_ProjectApp()
{
//---------------------------------------------------------------------------
// memory and error messages initialisations
// For memory usage and errors
Erm_M_InitErrMsg(Erm);
Erm_M_InitErrMsg(Mmg);
Erm_M_InitErrMsg(Int);
Mmg_fn_vFirstInitMmgModule(10);
Mmg_M_InitMmg(Int);
m_bWasInFullScreenBeforeLooseFocus = FALSE;
m_bLeavingApplication = FALSE;
m_bBadResolution = FALSE;
m_bFlagTaken = FALSE;
//---------------------------------------------------------------------------
m_bProjectIsClosing = 0;
m_bEngineIsStopped = FALSE;
m_bEditorsAreActive = FALSE;
m_bAppliAskedToStopEngine = FALSE;
m_bAppliPulsedOneStep = FALSE;
m_bAppliAskedToActivateEditors = FALSE;
m_bEngineAskedToForceEditors = FALSE;
m_bAppliAskedToEndGame = FALSE;
m_bEngineIsOver = FALSE;
m_bFinishEngine = FALSE;
}
//===========================================================================
// Description: DESTRUCTOR
// => Kill all editors
// => Restore windows parameters
// Creation date: 27 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
CPA_ProjectApp::~CPA_ProjectApp()
{
}
//###########################################################################
// CPA_ProjectApp initializations and close
//###########################################################################
//===========================================================================
// Description: Set and reset windows parameters.
// Creation date: 27 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_ProjectApp::fn_vSetWindowsParameters(void)
{
// => No screen saver
/* SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &m_bOldScreenSaveActive, 0);
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);*/
}
void CPA_ProjectApp::fn_vResetWindowsParameters(void)
{
// => Screen saver
//SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, m_bOldScreenSaveActive, NULL, 0);
}
//===========================================================================
// Description: Test windows config. to be sure that it's correct for
// game.
// Fatal error if not correct.
// Creation date: 27 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_ProjectApp::fn_vTestWindowsConfig(void)
{
HDC hdc;
int iAppBPP;
hdc = ::GetDC(NULL);
iAppBPP = ::GetDeviceCaps(hdc, PLANES);
iAppBPP *= ::GetDeviceCaps(hdc, BITSPIXEL);
::ReleaseDC(NULL, hdc);
if(iAppBPP != 16)
m_bBadResolution = TRUE;
}
//===========================================================================
// Description: Init camera to see the world correctly
// Creation date: 05 sept 96
// Author: FBF
//---------------------------------------------------------------------------
// Return niet
//---------------------------------------------------------------------------
// Revision date: ?
// Author:
//===========================================================================
//===========================================================================
// Description: First init of application.
// Creation date: 21 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return BOOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
extern "C"
{
long (*GLI_DRV_lSendDataToDll)(char *, void *);
}
BOOL CPA_ProjectApp::InitApplication(void)
{
// Change protection of EXE if there's auto generate code, and virtual lock
// code.
// fn_vChangeExeProtection((unsigned long) m_hInstance);
// Test windows environment
fn_vTestWindowsConfig();
// Change windows parameters
fn_vSetWindowsParameters();
// Create all semaphores
m_hDrawSem = CreateSemaphore(NULL, 1, 1, (LPCTSTR) "DRAWSEM");
GLI_DRV_lSendDataToDll("DrawSem", m_hDrawSem );
// To avoid list of dump memory at the end of execution
AfxEnableMemoryTracking(FALSE);
//FBFFBF temporaire V3.1, <20> virer ds la prochaine version
HIE_fn_vInitGlobalMatrixFrameCounter(3);
return CWinApp::InitApplication();
}
//===========================================================================
// Description: Last exit of application.
// Creation date: 27 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return BOOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_ProjectApp::ExitApplication(void)
{
ClipCursor(NULL);
// show cursor
while (ShowCursor(TRUE) < 0);
m_bLeavingApplication = TRUE;
// Free all semaphores
CloseHandle(m_hDrawSem);
// Restore windows parameters
fn_vResetWindowsParameters();
}
//===========================================================================
// Description: Call for each new instance of application.
// Creation date: 10 Jun 96
// Author: CB
//---------------------------------------------------------------------------
// Return void
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
BOOL CPA_ProjectApp::InitInstance()
{
// Register document templates
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
CPA_IDR_MAINFRAME,
RUNTIME_CLASS(CPA_ProjectDoc),
RUNTIME_CLASS(CPA_MainFrame),
RUNTIME_CLASS(DEV_MultiDevice3D));
AddDocTemplate(pDocTemplate);
//
// Add all DLLs to list.
//
// New file
OnFileNew();
if (m_pMainWnd == NULL)
return FALSE;
m_nCmdShow = SW_SHOWNORMAL;
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
M_GetMainDevice()->GetDevice(0)->AfterCreate();
}
// Clear main device
GLD_bClearDevice(M_GetMainDevice()->GetDevice(0)->m_hDisplayDevice);
GLD_bFlipDevice(M_GetMainDevice()->GetDevice(0)->m_hDisplayDevice);
// Special frame
//
// Create a new process for engine
//
fn_vCreateEngineThread();
M_GetMainWnd()->SetFocus();
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
m_p_oEngineThread->ResumeThread();
}
#ifdef NDEBUG
while (ShowCursor(FALSE) >= 0);
#endif
return TRUE;
}
//###########################################################################
//###########################################################################
BOOL CPA_ProjectApp::PreTranslateMessageEditor(MSG *p_stMsg)
{
return FALSE;
}
//###########################################################################
//###########################################################################
void CPA_ProjectApp::BeforeWindows()
{
if (m_p_oEngineThread == NULL)
return;
if (WaitForSingleObject(m_hDrawSem,10000) == WAIT_TIMEOUT)
ASSERT(0);
ASSERT(m_p_oEngineThread->SuspendThread() >= 0);
ReleaseSemaphore(m_hDrawSem,1,NULL);
}
//###########################################################################
//###########################################################################
void CPA_ProjectApp::AfterWindows()
{
if (m_p_oEngineThread == NULL)
return;
if (WaitForSingleObject(m_hDrawSem,10000) == WAIT_TIMEOUT)
ASSERT(0);
ReleaseSemaphore(m_hDrawSem,1,NULL);
m_p_oEngineThread->ResumeThread();
}
//###########################################################################
//###########################################################################
extern BOOL GLD_fn_bCanBeWindowed( void );
void fnv_SwapFullScreen(void)
{
/*
* Device is in full screen
*/
if (M_GetMainDevice()->GetDevice(0)->IsFullScreen())
{
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
/*
* can't be windowed
*/
if (M_GetMainApp()->m_bBadResolution || !GLD_fn_bCanBeWindowed() )
{
M_GetMainApp()->fn_vAppliAskToStopEngine();
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
M_GetMainWnd()->SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
}
/*
* device is windowed or minimized
*/
else
{
/*
* can't be windowed
*/
if(M_GetMainWnd()->IsIconic())
M_GetMainWnd()->SendMessage(WM_SYSCOMMAND, SC_RESTORE);
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = FALSE;
}
/*
if((M_GetMainApp()->m_bBadResolution) && (M_GetMainDevice()->GetDevice(0)->IsFullScreen()))
{
M_GetMainApp()->fn_vAppliAskToStopEngine();
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = TRUE;
M_GetMainWnd()->SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
else
{
if(M_GetMainDevice()->GetDevice(0)->IsFullScreen())
{
if(M_GetMainWnd()->IsIconic())
M_GetMainWnd()->SendMessage(WM_SYSCOMMAND, SC_RESTORE);
M_GetMainApp()->m_bWasInFullScreenBeforeLooseFocus = FALSE;
}
M_GetMainDevice()->GetDevice(0)->SwapFullScreen();
}
*/
}
//###########################################################################
//###########################################################################
BOOL CPA_ProjectApp::PreTranslateMessageEngine(MSG *p_stMsg)
{
BOOL bRes = FALSE;
static BOOL bMenu = FALSE;
BeforeWindows();
switch(p_stMsg->message)
{
/*
* Want to restore window. If window was in full screen before been minimized,
* for to swap to full screen.
*/
case WM_SYSCOMMAND:
switch(p_stMsg->wParam)
{
case SC_RESTORE:
case SC_MAXIMIZE:
if(m_bWasInFullScreenBeforeLooseFocus)
fnv_SwapFullScreen();
break;
}
break;
case WM_SYSKEYUP:
switch(p_stMsg->wParam)
{
case VK_RETURN:
fnv_SwapFullScreen();
bRes = TRUE;
break;
case VK_TAB:
M_GetMainApp()->fn_vAppliAskToStopEngine();
if (M_GetMainDevice()->GetDevice(0)->IsFullScreen())
fnv_SwapFullScreen();
bRes = TRUE;
break;
case VK_F10:
bRes = TRUE;
break;
}
break;
// Keyboard messages
case WM_KEYDOWN:
case WM_KEYUP:
case WM_CHAR:
case WM_DEADCHAR:
if (p_stMsg->wParam == VK_NUMLOCK ||
p_stMsg->wParam == VK_SCROLL ||
p_stMsg->wParam == VK_CAPITAL ||
p_stMsg->wParam == VK_SHIFT ||
p_stMsg->wParam == VK_LSHIFT ||
p_stMsg->wParam == VK_RSHIFT)
bRes = FALSE;
else
bRes = TRUE;
break;
// No mouse messages
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
bRes = TRUE;
break;
default:
bRes = FALSE;
break;
}
AfterWindows();
return bRes;
}
//###########################################################################
//###########################################################################
BOOL CPA_ProjectApp::PreTranslateMessage( MSG* pMsg )
{
BOOL bRes;
//call base member
bRes = CWinApp::PreTranslateMessage(pMsg);
if (!bRes)
{
bRes = CPA_ProjectApp::PreTranslateMessageEngine(pMsg);
}
return bRes;
}
//###########################################################################
//###########################################################################
int CPA_ProjectApp::Run(void)
{
MSG stMsg;
BOOL bRes;
// loop while message is not WM_QUIT
while (::GetMessage(&stMsg, NULL, 0, 0))
{
if (stMsg.message == WM_CANCELMODE)
{
fnv_SwapFullScreen();
}
bRes = PreTranslateMessage(&stMsg);
if(!bRes)
{
::TranslateMessage(&stMsg);
::DispatchMessage(&stMsg);
}
}
// Application exit code
ExitApplication();
return stMsg.wParam;
}
//===========================================================================
// Description: Called by the appli when the appli wants to stop the engine
// result :
// The Engine has not been stopped, but it has been notified to do so. We will receive a
// user message when the engine wants to be stopped
// Creation date: 19 jun 97
// Author: FBF
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_ProjectApp::fn_vAppliAskToStopEngine(void)
{
m_bAppliAskedToStopEngine = TRUE;
}
//===========================================================================
// Description: Called by the appli when the appli wants to start the engine
// result :
// The Engine will restart
// Creation date: 19 jun 97
// Author: FBF
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_ProjectApp::fn_vAppliAskToStartEngine(void)
{
m_bAppliAskedToStopEngine = FALSE;
if (m_bEngineIsStopped)
fn_vRestartEngine();
}
//===========================================================================
// Description: Called by the appli when the appli wants to start the engine
// for one step
// Creation date: aujourd'hui
// Author: VL mais j'avoue avoir copi<70> la fonction de FBF de CpaProj.cpp
// par contre j'aime pas du tout le style des commentaires mais
// c'est plutot personnel
//===========================================================================
void CPA_ProjectApp::fn_vAppliAskOneStep(void)
{
// pulse if engine has been stopped by the appli and if the engine is stopped and if one step has not allready been asked
if ((m_bAppliAskedToStopEngine == TRUE) && (m_bEngineIsStopped == TRUE) && (m_bAppliPulsedOneStep == FALSE))
{
m_bAppliPulsedOneStep = TRUE;
fn_vRestartEngine();
}
}
//===========================================================================
// Description: Called by the appli when the appli wants to end the game
// result :
// The Engine has been notified to begin the closing process
// we will receive a user message when the engine begin this process,
// and when the engine has finished this process
// Creation date: 19 jun 97
// Author: FBF
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_ProjectApp::fn_vAppliAskToEndGame(void)
{
// tell that we want to close
m_bAppliAskedToEndGame = TRUE;
// if editors are active, then we must restart the engine so that it can close
// to allow the engine to restart
M_GetMainApp()->m_bEditorsAreActive = FALSE;
// to prevent the engine from going back to editors
M_GetMainApp()->m_bAppliAskedToActivateEditors = FALSE;
M_GetMainApp()->fn_vRestartEngine();
}
//===========================================================================
// Description: a user message has been received
// return value:
// Creation date: 19 jun 97
// Author: FBF
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
afx_msg void CPA_ProjectApp::OnUserMsg(UINT wParam,LONG lParam)
{
// structure for Message box request
tdstMsgBox * p_stMsgBox;
switch(wParam)
{
case C_uiWinCm_RequestMessageBox:
p_stMsgBox = (tdstMsgBox*) lParam;
SendMessage(m_pMainWnd->m_hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
p_stMsgBox->iResult = MessageBox(NULL,p_stMsgBox->szText,p_stMsgBox->szTitle,p_stMsgBox->uiStyle);
SendMessage(m_pMainWnd->m_hWnd, WM_SYSCOMMAND, SC_RESTORE, 0);
// SetEvent(p_stMsgBox->hEvent);
break;
case USERM_STOP_ENGINE:
// if the flag is not right, do nothing
if (m_bAppliAskedToStopEngine == FALSE)
break;
fn_vStopEngine();
break;
case USERM_ENGINE_IS_CLOSING:
m_bLeavingApplication = TRUE;
break;
case USERM_ENGINE_IS_DONE:
m_bLeavingApplication = TRUE;
m_bEngineIsOver = TRUE;
m_bFinishEngine = TRUE;
M_GetMainWnd()->PostMessage(WM_CLOSE,0,0);
break;
case USERM_SWAP_FULLSCREEN:
fnv_SwapFullScreen();
break;
}
}
//===========================================================================
// Description: Stops the engine
// return value:
// Creation date: 19 jun 97
// Author: FBF
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_ProjectApp::fn_vStopEngine()
{
// if the engine is allready stopped, do nothing
if (m_bEngineIsStopped)
return;
// stop the engine
VERIFY(m_p_oEngineThread->SuspendThread() >= 0);
m_bEngineIsStopped = TRUE;
}
//===========================================================================
// Description: resume the engine
// return value:
// Creation date: 19 jun 97
// Author: FBF
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void CPA_ProjectApp::fn_vRestartEngine()
{
// if engine runs, do nothing
if (!m_bEngineIsStopped)
return;
ASSERT(m_bEditorsAreActive == FALSE);
if (m_p_oEngineThread)
{
m_bEngineIsStopped = FALSE;
m_p_oEngineThread->ResumeThread();
}
}

View File

@@ -0,0 +1,222 @@
//////////////////////////////////////////////////////////////////////
//
// SectorList.c: interface for the CPA_SectorList class.
//
//////////////////////////////////////////////////////////////////////
// Author: Silviu Simen 01 september 1998
//////////////////////////////////////////////////////////////////////
#include "itf/cpaslist.hpp"
/////////////////////////////////////////////////////////////////////////////
CPA_ListBySector::CPA_ListBySector (void)
{
}
/////////////////////////////////////////////////////////////////////////////
CPA_ListBySector::~CPA_ListBySector (void)
{
}
/////////////////////////////////////////////////////////////////////////////
void CPA_ListBySector::fn_vCleanAllListsOfSectors (void)
{
CPA_ListOfObjectsInSectorsByType *pListType;
CPA_ListOfObjectsInSectors *pList;
POSITION pos;
// update list by sector
pos = m_lstList.GetHeadPosition();
while (pos)
{
pList = m_lstList.GetNext(pos);
pList->m_lstObjectList.DeleteAllElements();
}
// update list by sector and type
pos = m_lstTypeList.GetHeadPosition();
while (pos)
{
pListType = m_lstTypeList.GetNext(pos);
pListType->m_lstObjectList.DeleteAllElements();
}
}
/////////////////////////////////////////////////////////////////////////////
void CPA_ListBySector::AddElement (CPA_SuperObject * pObject, SECTOR_TYPE pSector)
{
CPA_BaseObjectList *pListType;
CPA_BaseObjectList *pList;
// update list by sector
pList = GetListOfSector(pSector);
if (pList)
pList->fn_bAddObject(pObject);
// update list by sector and type
pListType = GetListOfSectorByType(pSector, HIE_fn_ulGetSuperObjectType(pObject->GetStruct()));
if (pListType)
pListType->fn_bAddObject(pObject);
}
/////////////////////////////////////////////////////////////////////////////
BOOL CPA_ListBySector::RemoveElement (CPA_SuperObject * pObject)
{
CPA_ListOfObjectsInSectorsByType *pListType;
CPA_ListOfObjectsInSectors *pList;
POSITION pos;
BOOL bFound;
BOOL bRes = FALSE;
// update list by sector
bFound = FALSE;
pos = m_lstList.GetHeadPosition();
while (pos && !bRes)
{
pList = m_lstList.GetNext(pos);
if (pList->m_lstObjectList.fn_bExist(pObject))
{
bRes = pList->m_lstObjectList.fn_bRemoveObject(pObject);
bFound = TRUE;
}
}
// update list by sector and type
bFound = FALSE;
pos = m_lstTypeList.GetHeadPosition();
while (pos && !bRes)
{
pListType = m_lstTypeList.GetNext(pos);
if (pListType->m_lstObjectList.fn_bExist(pObject))
{
bRes = pListType->m_lstObjectList.fn_bRemoveObject(pObject);
bFound = TRUE;
}
}
return bRes;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CPA_ListBySector::UpdateElement (CPA_SuperObject * pObject, SECTOR_TYPE pNewSector)
{
CPA_ListOfObjectsInSectorsByType *pListType;
CPA_ListOfObjectsInSectors *pList;
CPA_BaseObjectList *pNewListType;
CPA_BaseObjectList *pNewList;
POSITION pos;
BOOL bFound = FALSE;
BOOL bRes = FALSE;
// get list by sector
pNewList = GetListOfSector(pNewSector);
if (!pNewList)
return FALSE;
if (!pNewList->fn_bExist(pObject))
{
// update list by sector
bFound = FALSE;
pos = m_lstList.GetHeadPosition();
while (pos && !bRes)
{
pList = m_lstList.GetNext(pos);
if (pList->m_lstObjectList.fn_bExist(pObject))
{
pList->m_lstObjectList.fn_bRemoveObject(pObject);
bFound = TRUE;
}
}
bRes = pNewList->fn_bAddObject(pObject);
}
// get list by sector
pNewListType = GetListOfSectorByType(pNewSector, HIE_fn_ulGetSuperObjectType(pObject->GetStruct()));
if (!pNewListType)
return FALSE;
if (!pNewListType->fn_bExist(pObject))
{
// update list by sector
bFound = FALSE;
pos = m_lstTypeList.GetHeadPosition();
while (pos && !bRes)
{
pListType = m_lstTypeList.GetNext(pos);
if (pListType->m_lstObjectList.fn_bExist(pObject))
{
bRes = pListType->m_lstObjectList.fn_bRemoveObject(pObject);
bFound = TRUE;
}
}
bRes = pNewListType->fn_bAddObject(pObject);
}
return bRes;
}
/////////////////////////////////////////////////////////////////////////////
CPA_BaseObjectList * CPA_ListBySector::GetListOfSector (SECTOR_TYPE pSector)
{
CPA_ListOfObjectsInSectors *pList;
POSITION pos;
// search list by sector
pos = m_lstList.GetHeadPosition();
while (pos)
{
pList = m_lstList.GetNext(pos);
if (pList->m_pSector == pSector)
return &pList->m_lstObjectList;
}
// sector was not found => create it
pList = new CPA_ListOfObjectsInSectors;
pList->m_pSector = pSector;
m_lstList.AddTail(pList);
return &pList->m_lstObjectList;
}
/////////////////////////////////////////////////////////////////////////////
CPA_BaseObjectList * CPA_ListBySector::GetListOfSectorByType (SECTOR_TYPE pSector,unsigned long ulType)
{
CPA_ListOfObjectsInSectorsByType *pList;
POSITION pos;
// search list by sector
pos = m_lstTypeList.GetHeadPosition();
while (pos)
{
pList = m_lstTypeList.GetNext(pos);
if ((pList->m_pSector == pSector) && (pList->m_ulType == ulType))
return &pList->m_lstObjectList;
}
// sector was not found => create it
pList = new CPA_ListOfObjectsInSectorsByType;
pList->m_pSector = pSector;
pList->m_ulType = ulType;
m_lstTypeList.AddTail(pList);
return &pList->m_lstObjectList;
}
/////////////////////////////////////////////////////////////////////////////
CPA_BaseObjectList * CPA_ListBySector::GetListOfSectorByName (CString csName)
{
CPA_ListOfObjectsInSectors *pList;
POSITION pos;
// search list by sector
pos = m_lstList.GetHeadPosition();
while (pos)
{
pList = m_lstList.GetNext(pos);
if (pList->m_pSector->GetName() == csName)
return &pList->m_lstObjectList;
}
// sector was not found
return NULL;
}

View File

@@ -0,0 +1,340 @@
/*=========================================================================
*
* CPASObj.cpp - CPA_SuperObject : implementation
*
*
* Version 1.0
* Creation date 20.06.97
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPASObj.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAInter.hpp"
#include "itf/CPAHieEd.hpp"
#include "itf/CoheMngr.hpp"
#include "x:\cpa\Main\inc\_editid.h"
#include "DPT.h"
//#################################################################################
// CPA_SuperObject
//#################################################################################
/*===========================================================================
Static Init
=========================================================================*/
void CPA_SuperObject::fn_vInitLoadEditor()
{
CPA_EdMot<HIE_tdxHandleToSuperObject>::Init(HIE_fn_hCreateSuperObject,HIE_fn_vCopySuperObject,HIE_fn_vDestroySuperObject);
}
/*===========================================================================
Constructor
=========================================================================*/
CPA_SuperObject::CPA_SuperObject (CPA_EditorBase *pEditor, HIE_tdxHandleToSuperObject hEngineSO,
tdeSaveStatus eStatus, tdeTypeSO eTypeSO)
: m_p_oObject(NULL),
CPA_EdMot<HIE_tdxHandleToSuperObject>(hEngineSO),
CPA_SuperObjectBase(hEngineSO),
CPA_ModifiableObject(pEditor, C_szSuperObjectTypeName, eStatus)
{
// parameters
m_p_oObjectDLLInterface = NULL;
m_pSuperObjectOwner = NULL;
m_bEditProtected = FALSE;
m_bAxisDrawn = FALSE;
m_bCenterVisible = FALSE;
m_csModelName = "";
SetTypeSO(eTypeSO);
}
/*===========================================================================
New Constructor
=========================================================================*/
CPA_SuperObject::CPA_SuperObject (CPA_EditorBase *pEditor, tdeSaveStatus eStatus, tdeTypeSO eTypeSO)
: m_p_oObject(NULL),
CPA_EdMot<HIE_tdxHandleToSuperObject>(),
CPA_SuperObjectBase(),
CPA_ModifiableObject(pEditor, C_szSuperObjectTypeName, eStatus)
{
GEO_tdxHandleToMatrix hLocalMatrix;
// local matrix
hLocalMatrix = GEO_fn_hCreateMatrix();
POS_fn_vSetIdentityMatrix(hLocalMatrix);
HIE_fn_vSetSuperObjectMatrix(GetStruct(), hLocalMatrix);
// parameters
m_p_oObjectDLLInterface = NULL;
m_pSuperObjectOwner = NULL;
m_bEditProtected = FALSE;
m_bAxisDrawn = FALSE;
m_bCenterVisible = FALSE;
m_csModelName = "";
SetTypeSO(eTypeSO);
}
/*===========================================================================
Copy-Constructor
=========================================================================*/
CPA_SuperObject::CPA_SuperObject (CPA_SuperObject &r_oSource)
:m_p_oObject(NULL),
CPA_EdMot<HIE_tdxHandleToSuperObject>(r_oSource),
CPA_ModifiableObject(r_oSource),
CPA_SuperObjectBase()
{
// local matrix
POS_tdxHandleToPosition hLocalMatrix = (POS_tdxHandleToPosition) malloc (sizeof (POS_tdstCompletePosition));
POS_fn_vSetIdentityMatrix(hLocalMatrix);
GEO_M_vCopyMatrix(hLocalMatrix, HIE_fn_hGetSuperObjectMatrix(r_oSource.GetStruct()));
HIE_fn_vSetSuperObjectMatrix(GetStruct(), hLocalMatrix);
// global matrix
GEO_M_vCopyMatrix(HIE_fn_hGetSuperObjectGlobalMatrix(GetStruct()), HIE_fn_hGetSuperObjectGlobalMatrix(r_oSource.GetStruct()));
// copy common parameters
m_p_oObjectDLLInterface = r_oSource.m_p_oObjectDLLInterface;
m_pSuperObjectOwner = r_oSource.m_pSuperObjectOwner;
m_bEditProtected = r_oSource.m_bEditProtected;
m_bAxisDrawn = r_oSource.m_bAxisDrawn;
m_bCenterVisible = r_oSource.m_bCenterVisible;
m_csModelName = r_oSource.m_csModelName;
SetTypeSO(r_oSource.GetTypeSO());
// init object
SetObject(r_oSource.m_p_oObject);
}
/*===========================================================================
Destructor
=========================================================================*/
CPA_SuperObject::~CPA_SuperObject(void)
{
CPA_SuperObjectBase *p_oSuperObject;
POSITION P;
for(p_oSuperObject = GetHeadElement(P); p_oSuperObject;
p_oSuperObject = GetNextElement(P))
{
delete ((CPA_SuperObject *) p_oSuperObject);
p_oSuperObject = NULL;
}
}
/*===========================================================================
Object & DLL
=========================================================================*/
long CPA_SuperObject::GetObjectType()
{
return ( (m_p_oObject) ? m_p_oObject->GetDataType() : GetDataType() );
}
//===========================================================================
void CPA_SuperObject::SetObject (CPA_BaseObject * p_oNewObject)
{
if (m_p_oObject != NULL)
{
// warn coherence manager
g_oCoherenceManager.m_fn_vRemoveALink(this, m_p_oObject);
// cancel old link
m_p_oObject = NULL;
m_p_oObjectDLLInterface = NULL;
HIE_fn_vSetSuperObjectObjectAndType(GetStruct(), NULL, HIE_C_ulSuperObject);
}
if (p_oNewObject != NULL)
{
// warn coherence manager
g_oCoherenceManager.m_fn_vAddALink(this, p_oNewObject);
// set new link
m_p_oObject = p_oNewObject;
m_p_oObjectDLLInterface = (CPA_ObjectDLLBase *) (p_oNewObject->GetEditor());
HIE_fn_vSetSuperObjectObjectAndType(GetStruct(), p_oNewObject->GetData(), p_oNewObject->GetDataType());
}
else
{
m_p_oObject = NULL;
m_p_oObjectDLLInterface = NULL;
HIE_fn_vSetSuperObjectObjectAndType(GetStruct(), NULL, HIE_C_ulSuperObject);
}
}
/*===========================================================================
Hierarchy Links
=========================================================================*/
CPA_SuperObject * CPA_SuperObject::GetSuperObjectFirstChild (void)
{
return ((CPA_SuperObject *) GetHeadElement());
}
//===========================================================================
CPA_SuperObject * CPA_SuperObject::GetSuperObjectLastChild (void)
{
return ((CPA_SuperObject *) GetTailElement());
}
//===========================================================================
CPA_SuperObject * CPA_SuperObject::GetSuperObjectNextChild (CPA_SuperObject *pChild)
{
return ((CPA_SuperObject *) GetNextElement(pChild));
}
//===========================================================================
CPA_SuperObject * CPA_SuperObject::GetSuperObjectPrevChild (CPA_SuperObject *pChild)
{
return ((CPA_SuperObject *) GetPrevElement(pChild));
}
//===========================================================================
CPA_SuperObject * CPA_SuperObject::GetSuperObjectFather (void)
{
return ((CPA_SuperObject *) GetParent());
}
//===========================================================================
void CPA_SuperObject::AddANewChild (CPA_SuperObject *pChild, BOOL bUpdateEngine, CPA_SuperObject *pNextBrother)
{
POSITION pos = NULL;
// find position
if (pNextBrother)
pos = Find(pNextBrother);
// insert at the right position
if (pos)
InsertBefore(pos, pChild, bUpdateEngine);
else
AddTail(pChild, bUpdateEngine);
// warn coherence manager
g_oCoherenceManager.m_fn_vAddALink(this, pChild);
}
//===========================================================================
void CPA_SuperObject::RemoveAChild (CPA_SuperObject *pChild, BOOL bUpdateEngine)
{
POSITION pos = NULL;
// isolate child
pos = Find(pChild);
if (pos)
RemoveAt(pos, bUpdateEngine);
// warn coherence manager
g_oCoherenceManager.m_fn_vRemoveALink(this, pChild);
}
//===========================================================================
void CPA_SuperObject::RemoveAllChilds (BOOL bUpdateEngine)
{
CPA_SuperObject *pChild;
// remove childs
while (GetCount())
{
// remove child
pChild = (CPA_SuperObject *) RemoveHead(bUpdateEngine);
// warn coherence manager
g_oCoherenceManager.m_fn_vRemoveALink(this, pChild);
}
}
//===========================================================================
void CPA_SuperObject::IsolateChild (BOOL bUpdateEngine)
{
CPA_SuperObject *pFather;
// save father
pFather = GetSuperObjectFather();
// Isolate Child
Isolate(bUpdateEngine);
// warn coherence manager
if (pFather)
g_oCoherenceManager.m_fn_vRemoveALink(pFather, this);
}
//===========================================================================
void CPA_SuperObject::fn_vUpdateValidity (BOOL bValid)
{
CPA_SuperObject *pChild;
// update super-object
if (bValid)
fn_bValidate();
else
fn_bUnValidate();
// update all childs
for (pChild = GetSuperObjectFirstChild(); pChild;
pChild = GetSuperObjectNextChild(pChild))
pChild->fn_vUpdateValidity(bValid);
}
/*===========================================================================
Parameters
*=========================================================================*/
BOOL CPA_SuperObject::SetTypeSO (tdeTypeSO eType)
{
//Evt_Editor *pEditor = (Evt_Editor *) GetEditor();
// check editor specification
//if (pEditor->GetSpecificEditor()->fn_bCanChangeTypeSO(this, eType))
m_eTypeSO = eType;
// check if type is coherent
return (m_eTypeSO == eType);
}
/*===========================================================================
Name & Name to draw
*=========================================================================*/
CString CPA_SuperObject::GetRealTypeName (void)
{
return ( (m_p_oObject) ? m_p_oObject->GetType() : GetType() );
}
//===========================================================================
BOOL CPA_SuperObject::fn_bIsUnderObject (CPA_SuperObject *pEdObj)
{
CPA_SuperObject *pParent;
if (pEdObj == this)
return TRUE;
pParent = GetSuperObjectFather();
if (!pParent)
return FALSE;
else
return (pParent->fn_bIsUnderObject(pEdObj));
}
//===========================================================================
void CPA_SuperObject::SetSuperObjectStruct (HIE_tdxHandleToSuperObject hSupObj)
{
// update base object
fn_vUpdateData(hSupObj);
// set engine struct
CPA_SuperObjectBase::SetSuperObjectStruct(hSupObj);
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,560 @@
// (c) Ubi Studios 1996
// See Vincent Greco for any comment or question
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "geo.h"
#include "gli.h"
#include "col.h"
#define HieFriend
#include "spo.h"
#include "lst.hpp"
#include "incgam.h"
#undef HieFriend
#include "x:\cpa\tempgrp\gliGLOU\MULTIDRV\inc\visus_st.h"
#include "itf/CPASObjB.hpp"
//temporary 3DOS header file include
//#include "x:appli\3dos\inc\3dos\physicol.h"
#include "pcs.h"
#include "po.h"
#include "ipo.h"
#include "isi.h"
DeclareTemplateStatic(HIE_tdxHandleToSuperObject);
ACP_tdxHandleOfMaterial g_hMaterial;
BOOL g_bMaterialInitialised = FALSE;
extern ACP_tdxBool g_bShowCollisionMap;
GLI_tdstColor TabColor[]=
{
{(float) 0.00, (float) 0.00, (float) 0.00, (float) 0.0},//E_lc_NoColor
{(float) 0.8f, (float) 0.0f, (float) 0.0f, (float) 1.f},//E_lc_Red
{(float) 0.00, (float) 0.99, (float) 0.00, (float) 0.0},//E_lc_Green
{(float) 0.00, (float) 0.00, (float) 0.99, (float) 0.0},//E_lc_Blue
{(float) 0.45, (float) 0.45, (float) 0.00, (float) 0.0},//E_lc_Yellow
{(float) 0.45, (float) 0.00, (float) 0.99, (float) 0.0},//E_lc_Violet
{(float) 0.00, (float) 0.45, (float) 0.99, (float) 0.0},//E_lc_LightBlue
};
#define C_lLocalColorMask ( GLI_C_lAllIsEnable \
- GLI_C_lIsNotForceDefaultMaterial \
- GLI_C_lIsNotGrided \
- GLI_C_lIsUseStaticLights \
- GLI_C_lIsUseRLI)
//########################################################################################
//########################################################################################
//########################################################################################
CPA_SuperObjectBase::CPA_SuperObjectBase (void)
: CPA_EdNode<CPA_SuperObjectBase,HIE_tdxHandleToSuperObject,HIE_tdxHandleToSuperObject>()
{
m_eDrawingFlag = E_df_Normal;
m_eColor = E_lc_NoColor;
m_bMustDraw = TRUE;
m_bDrawBV = FALSE;
}
//########################################################################################
//########################################################################################
//########################################################################################
CPA_SuperObjectBase::CPA_SuperObjectBase(HIE_tdxHandleToSuperObject hEngineSO)
{
SetStruct(hEngineSO);
m_eDrawingFlag = E_df_Normal;
m_eColor = E_lc_NoColor;
m_bMustDraw = TRUE;
m_bDrawBV = FALSE;
}
//ANNECY TQ 26/02/98{
//########################################################################################
//########################################################################################
//########################################################################################
//--------------------------------------------------------------------------------------
// Name : CreateParallelBoxGeometricObject
// Author : Thierry QUERE
// Date : 27/02/98
// Description : Creates an engine-geometric object to store the parallel box (bounding volume)
// and to send it to the viewport
//--------------------------------------------------------------------------------------
void CPA_SuperObjectBase::CreateParallelBoxGeometricObject()
{
ACP_tdxHandleOfElement hAlignedBoxes;
GEO_vCreateGeometricObject(&s_hBoxGeomObj, 2 /* 2 points */, 1 /* 1 element */);
GEO_vCreateElementAlignedBoxes(s_hBoxGeomObj, &hAlignedBoxes, 1);
}
void CPA_SuperObjectBase::DestroyParallelBoxGeometricObject()
{
GEO_vDeleteGeometricObject(&s_hBoxGeomObj);
}
//--------------------------------------------------------------------------------------
// Name : CreateBoundingSphereGeometricObject
// Author : Thierry QUERE
// Date : 03/06/98
// Description : Creates an engine-geometric object to store the BoundingSphere (bounding volume)
// and to send it to the viewport
//--------------------------------------------------------------------------------------
void CPA_SuperObjectBase::CreateBoundingSphereGeometricObject()
{
ACP_tdxHandleOfElement hSphere;
GEO_vCreateGeometricObject(&s_hSphereGeomObj, 1 /* 1 point */, 1 /* 1 element */);
GEO_vCreateElementSpheres(s_hSphereGeomObj, &hSphere, 1);
}
void CPA_SuperObjectBase::DestroyBoundingSphereGeometricObject()
{
GEO_vDeleteGeometricObject(&s_hSphereGeomObj);
}
//ENDANNECY TQ}
//########################################################################################
//########################################################################################
//########################################################################################
void CPA_SuperObjectBase::Display(GLD_tdxHandleToViewportAttributes hVpt,long lDrawMask,
tdstSaveLight a_tdxhArrayOfLights[], long lNbLights,
HIE_tdxHandleToSuperObject pWorld, BOOL bUseLocalFlag)
{
HIE_tdxHandleToSuperObject pStruct;
ACP_tdxHandleToRadiosity hRad;
GEO_tdxHandleToBoundingSphere hBoundingSphere = NULL;
GEO_tdxHandleToParallelBox hParallelBox = NULL;
ACP_tdxHandleOfObject hBoundingVolume = NULL;
HIE_tdxHandleToVoid hObject;
CPA_SuperObjectBase * pChild;
MTH3D_tdstVector stCenter;
tdeLocalColor eCol;
POSITION pos;
long lLocalMask;
unsigned long ulType;
long lMask;
long lIndex;
MTH3D_tdstVector stMaxBoxPoint;
MTH3D_tdstVector stMinBoxPoint;
POS_tdstCompletePosition * p_stGlobalMatrix;
POS_tdstCompletePosition stIdentityMatrix;
float fGlobalAlphaTemp ;
float fTransp, fTransparency = -1.0;
ACP_tdxBool bDummy;
// draw only valid objects
if (!m_bMustDraw)
return;
if (!g_bMaterialInitialised)
{
GLI_xCreateMaterial(&g_hMaterial);
GLI_xSetMaterialType(g_hMaterial, C_lGouraudElement);
g_bMaterialInitialised = TRUE;
}
// init parameters
pStruct = (HIE_tdxHandleToSuperObject) GetSuperObjectStruct();
eCol = GetLocalColor();
// init matrix
HIE_fn_vPushMatrix (pStruct);
HIE_fn_vPushOnCameraMatrixStack (pStruct);
// selection drawing : no light !
if (eCol != E_lc_NoColor)
{
for (lIndex = 0; lIndex < lNbLights; lIndex++)
GLI_xSetLightState(a_tdxhArrayOfLights[lIndex].hLight, 0);
}
// local mask
lLocalMask = (eCol == E_lc_NoColor) ? lDrawMask : lDrawMask & C_lLocalColorMask ;
//ANNECY VL PRT 08/04/98{
// avoid sinus effect while in editor mode
lLocalMask |= GLI_C_lHasNotSinusEffect;
//ENDANNECY VL}
// default material
GLI_xSetMaterialAmbientCoef (g_hMaterial, TabColor+eCol);
GLI_vSetDefaultMaterial(hVpt, g_hMaterial);
// local drawing flag
if (bUseLocalFlag)
{
switch (m_eDrawingFlag)
{
case E_df_BoundingV:
lLocalMask &= ~GLI_C_lIsNotDrawingSuperObjectBoundingVolume;
break;
case E_df_Grided:
lLocalMask &= ~GLI_C_lIsNotGrided;
break;
case E_df_Wired:
lLocalMask &= ~GLI_C_lIsNotWired;
break;
}
}
if (m_bDrawBV)
lLocalMask &= ~GLI_C_lIsNotDrawingSuperObjectBoundingVolume;
fTransp = HIE_fn_fGetSuperObjectTransparenceLevel(pStruct);
if (( eCol != E_lc_NoColor) ||
((fTransp < 30.0) && (fTransp > 0.0)) ||
( bUseLocalFlag && (m_eDrawingFlag == E_df_Grided)) ||
!(HIE_fn_lGetSuperObjectDrawMask(pWorld) & GLI_C_lIsNotGrided))
{
fTransparency = fTransp;
// minimal transparency
if (fTransparency < 30.0 && fTransparency > 0.0)
HIE_fn_vSetSuperObjectTransparenceLevel(pStruct, 30.0);
if (eCol == E_lc_NoColor)
{
if (fTransparency > 200.0)
HIE_fn_vSetSuperObjectTransparenceLevel(pStruct, (float) (fTransparency - 100.0));
else if (fTransparency > 100.0)
HIE_fn_vSetSuperObjectTransparenceLevel(pStruct, 100.0);
}
else
HIE_fn_vSetSuperObjectTransparenceLevel(pStruct, 128.0);
}
// parameters
ulType = HIE_fn_ulGetSuperObjectType(pStruct);
lMask = HIE_fn_lGetSuperObjectDrawMask(pStruct);
// avoid sinus effect while in editor mode
lMask |= GLI_C_lHasNotSinusEffect;
hObject = HIE_fn_hGetSuperObjectObject(pStruct);
// bounding volume
hParallelBox = (GEO_tdxHandleToParallelBox)HIE_fn_hGetSuperObjectBoundingVolume(pStruct);
if (hParallelBox && HIE_fn_SO_bHasABoxBoundingVolume (pStruct))
{
p_stGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(pStruct);
MTH3D_M_vAddVector(&stMaxBoxPoint, &p_stGlobalMatrix->stTranslationVector, GEO_fn_pGetMaxPointOfParallelBox(hParallelBox));
MTH3D_M_vAddVector(&stMinBoxPoint, &p_stGlobalMatrix->stTranslationVector, GEO_fn_pGetMinPointOfParallelBox(hParallelBox));
GEO_vSetPointOfObject (s_hBoxGeomObj,
&stMaxBoxPoint,
1);
GEO_vSetPointOfObject (s_hBoxGeomObj,
&stMinBoxPoint,
0);
GEO_vSetMinMaxPointOfIndexedAlignedBox( s_hBoxGeomObj,
0, /* First element */
0, /* First Aligned box of the element */
0, /* First point = Max */
1);/* Second point = Min */
hBoundingVolume = s_hBoxGeomObj;
}
else
{
hBoundingSphere = (GEO_tdxHandleToBoundingSphere)HIE_fn_hGetSuperObjectBoundingVolume(pStruct);
if ((hBoundingSphere) && (!HIE_fn_SO_bHasABoxBoundingVolume(pStruct)))
{
MTH3D_M_vCopyVector(&stCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
GEO_vSetPointOfObject( s_hSphereGeomObj,
GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere),
0);
GEO_vSetCenterPointOfIndexedSphere ( s_hSphereGeomObj,
0, /* First Element */
0, /* First Sphere of the element */
0); /* First Point */
GEO_vSetRadiusOfIndexedSphere ( s_hSphereGeomObj,
0, /* First Element */
0, /* First Sphere of the element */
GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere)
);
hBoundingVolume = s_hSphereGeomObj;
}
}
// draw geometric object
if (ulType & (HIE_C_ulEDT_Geometric | HIE_C_ulSpecialEffect))
{
POS_tdstCompletePosition *p_stCurrentMatrix;
if((MTH_M_bEqual(GEO_xGetElementType((ACP_tdxHandleOfObject)hObject, 0), GEO_C_xElementAlignedBoxes)) && (fn_bHasALinkedZDM() == TRUE))
{
/* The points have not the translation of the object ... */
MTH3D_M_vAddVector(&((ACP_tdxHandleOfObject)hObject)->d_stListOfPoints[0], &pStruct->hGlobalMatrix->stTranslationVector, &((ACP_tdxHandleOfObject)hObject)->d_stListOfPoints[0]);
MTH3D_M_vAddVector(&((ACP_tdxHandleOfObject)hObject)->d_stListOfPoints[1], &pStruct->hGlobalMatrix->stTranslationVector, &((ACP_tdxHandleOfObject)hObject)->d_stListOfPoints[1]);
POS_fn_vSetIdentityMatrix(&stIdentityMatrix);
HIE_fn_bLoadMatrix (&stIdentityMatrix);
// update camera matrix
p_stCurrentMatrix = HIE_fn_pGetCurrentInCamCoordsMatrix();
HIE_fn_vSetCurrentInCamCoordsMatrix(&((( GLI_tdstSpecificAttributesFor3D *)hVpt->p_vSpecificToXD)->p_stCam)->stMatrix);
}
fGlobalAlphaTemp = GLI_vGetGlobalAlpha();
GLI_vSetGlobalAlpha( HIE_fn_fGetSuperObjectTransparenceLevel(pStruct) );
GLI_xSendObjectToViewportWithLights(hVpt, (ACP_tdxHandleOfObject)hObject, lMask&lLocalMask);
if (eCol != E_lc_NoColor)
GLI_xSendObjectToViewportWithLights(hVpt, (ACP_tdxHandleOfObject)hObject, (lMask&lLocalMask) - GLI_C_lIsNotWired);
GLI_vSetGlobalAlpha (fGlobalAlphaTemp) ;
// Please, do not alter the following line without contacting Thierry QUERE // Annecy
if((MTH_M_bEqual(GEO_xGetElementType((ACP_tdxHandleOfObject)hObject, 0), GEO_C_xElementAlignedBoxes)) && (fn_bHasALinkedZDM() == TRUE))
{
HIE_fn_vPopMatrix ();
// update camera matrix
HIE_fn_vSetCurrentInCamCoordsMatrix(p_stCurrentMatrix);
//HIE_fn_vPopOnCameraMatrixStack ();
MTH3D_M_vSubVector(&((ACP_tdxHandleOfObject)hObject)->d_stListOfPoints[0], &((ACP_tdxHandleOfObject)hObject)->d_stListOfPoints[0], &pStruct->hGlobalMatrix->stTranslationVector);
MTH3D_M_vSubVector(&((ACP_tdxHandleOfObject)hObject)->d_stListOfPoints[1], &((ACP_tdxHandleOfObject)hObject)->d_stListOfPoints[1], &pStruct->hGlobalMatrix->stTranslationVector);
}
}
// draw physical object
if ((ulType == HIE_C_ulPO) || (ulType == HIE_C_ulPO_Mirror))
{
PO_tdxHandleToPhysicalObject hPO = (PO_tdxHandleToPhysicalObject) hObject;
// get bounding volume and center
if (!HIE_fn_SO_bHasABoxBoundingVolume (pStruct))
hBoundingSphere = PO_fn_hGetBoundingVolume(hPO);
if ((hBoundingSphere) && (!HIE_fn_SO_bHasABoxBoundingVolume(pStruct)))
{
MTH3D_M_vCopyVector(&stCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
GEO_vSetPointOfObject( s_hSphereGeomObj,
GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere),
0);
GEO_vSetCenterPointOfIndexedSphere ( s_hSphereGeomObj,
0, /* First Element */
0, /* First Sphere of the element */
0); /* First Point */
GEO_vSetRadiusOfIndexedSphere ( s_hSphereGeomObj,
0, /* First Element */
0, /* First Sphere of the element */
GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere)
);
hBoundingVolume = s_hSphereGeomObj;
}
else if ((!hBoundingSphere) && (!HIE_fn_SO_bHasABoxBoundingVolume(pStruct)))
MTH3D_M_vNullVector(&stCenter);
fGlobalAlphaTemp = GLI_vGetGlobalAlpha();
GLI_vSetGlobalAlpha( HIE_fn_fGetSuperObjectTransparenceLevel(pStruct) );
//--- Display collision map ---
if(g_bShowCollisionMap)
{
if(PO_fn_hGetCollideSet(hPO))
{
if(PCS_fn_hGetZdrGeoObjOfPhysicalCollSet(PO_fn_hGetCollideSet(hPO)))
GLI_xSendObjectToViewportWithLights(hVpt, PCS_fn_hGetZdrGeoObjOfPhysicalCollSet(PO_fn_hGetCollideSet(hPO)), lMask&lLocalMask);
}
}
else
//--- Display graphical map ---
{
GLI_lSendVisualSetToViewport2(hVpt, PO_fn_hGetVisualSet(hPO), &stCenter, lMask&lLocalMask);
if (eCol != E_lc_NoColor)
GLI_lSendVisualSetToViewport2(hVpt, PO_fn_hGetVisualSet(hPO), &stCenter, (lMask&lLocalMask) - GLI_C_lIsNotWired);
GLI_vSetGlobalAlpha (fGlobalAlphaTemp) ;
}
}
// draw instanciated physical object
if (ulType & (HIE_C_ulIPO | HIE_C_ulIPO_Mirror))
{
IPO_tdxHandleToInstanciatedPhysicalObject hIPO = (IPO_tdxHandleToInstanciatedPhysicalObject) hObject;
PO_tdxHandleToPhysicalObject hPO = IPO_fn_hGetPhysicalObject(hIPO);
// get bounding volume and center
if (!HIE_fn_SO_bHasABoxBoundingVolume (pStruct))
hBoundingSphere = PO_fn_hGetBoundingVolume(hPO);
//ANNECY TQ 27/02/98{
if ((hBoundingSphere) && (!HIE_fn_SO_bHasABoxBoundingVolume(pStruct)))
{
MTH3D_M_vCopyVector(&stCenter, GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere));
GEO_vSetPointOfObject( s_hSphereGeomObj,
GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere),
0);
GEO_vSetCenterPointOfIndexedSphere ( s_hSphereGeomObj,
0, /* First Element */
0, /* First Sphere of the element */
0); /* First Point */
GEO_vSetRadiusOfIndexedSphere ( s_hSphereGeomObj,
0, /* First Element */
0, /* First Sphere of the element */
GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere)
);
hBoundingVolume = s_hSphereGeomObj;
}
else if (HIE_fn_SO_bHasABoxBoundingVolume(pStruct))
{
MTH3D_tdstVector * p_stMinPoint = GEO_fn_pGetMinPointOfParallelBox ((GEO_tdstParallelBox *) HIE_fn_hGetSuperObjectBoundingVolume (pStruct));
MTH3D_tdstVector * p_stMaxPoint = GEO_fn_pGetMaxPointOfParallelBox ((GEO_tdstParallelBox *) HIE_fn_hGetSuperObjectBoundingVolume (pStruct));
MTH3D_M_vMiddleVector (&stCenter , p_stMinPoint , p_stMaxPoint);
}
//ENDANNECY TQ}
fGlobalAlphaTemp = GLI_vGetGlobalAlpha();
GLI_vSetGlobalAlpha( HIE_fn_fGetSuperObjectTransparenceLevel(pStruct) );
// get RLI parameters
hRad = IPO_fn_hGetRadiosity(hIPO);
//--- Display Collision Map ---
if(g_bShowCollisionMap)
{
if(PO_fn_hGetCollideSet(hPO))
{
if(PCS_fn_hGetZdrGeoObjOfPhysicalCollSet(PO_fn_hGetCollideSet(hPO)))
GLI_xSendObjectToViewportWithLights(hVpt, PCS_fn_hGetZdrGeoObjOfPhysicalCollSet(PO_fn_hGetCollideSet(hPO)), lMask&lLocalMask);
}
}
else
//--- Display Graphical Map ---
{
GLI_lSendVisualSetToViewportWithRLI2(hVpt, PO_fn_hGetVisualSet(hPO), &stCenter, lMask&lLocalMask, hRad/*dColor*/);
if (eCol != E_lc_NoColor)
GLI_lSendVisualSetToViewportWithRLI2(hVpt, PO_fn_hGetVisualSet(hPO), &stCenter, (lMask&lLocalMask) - GLI_C_lIsNotWired, hRad /*dColor*/);
}
}
GLI_vSetGlobalAlpha (fGlobalAlphaTemp) ;
/* The matrix that is on the top of the pile is currently the global matrix of the object */
/* This matrix is used by the viewport to know in what axis system the coordinates he receives
are */
/* When the bounding volume is a sphere, the matrix on the top MUST be the gobal matrix because
the center and the radius are computed in the local axis system of the object, */
/* but, unfortunatly, for the parallel boxes where everything is computed in the global
axis system, the matrix on the top must be the identity matrix */
// draw bounding volume
if (hBoundingVolume &&
(HIE_fn_SO_bHasABoxBoundingVolume(pStruct)) &&
!(lLocalMask & GLI_C_lIsNotDrawingSuperObjectBoundingVolume))
{
POS_tdstCompletePosition *p_stCurrentMatrix;
POS_fn_vSetIdentityMatrix(&stIdentityMatrix);
HIE_fn_bLoadMatrix (&stIdentityMatrix);
// update camera matrix
p_stCurrentMatrix = HIE_fn_pGetCurrentInCamCoordsMatrix();
HIE_fn_vSetCurrentInCamCoordsMatrix(&((( GLI_tdstSpecificAttributesFor3D *)hVpt->p_vSpecificToXD)->p_stCam)->stMatrix);
GLI_xSendObjectToViewportWithLights(hVpt, hBoundingVolume, lMask & lDrawMask &~GLI_C_lIsNotWired &~GLI_C_lIsNotDrawCollideInformation);
HIE_fn_vPopMatrix ();
// update camera matrix
HIE_fn_vSetCurrentInCamCoordsMatrix(p_stCurrentMatrix);
//HIE_fn_vPopOnCameraMatrixStack();
}
else
if(hBoundingVolume&&!(lLocalMask &GLI_C_lIsNotDrawingSuperObjectBoundingVolume))
GLI_xSendObjectToViewportWithLights(hVpt, hBoundingVolume, lMask & lDrawMask &~GLI_C_lIsNotWired &~GLI_C_lIsNotDrawCollideInformation);
// reset lights
if (eCol != E_lc_NoColor)
{
for (lIndex = 0; lIndex < lNbLights; lIndex++)
GLI_xSetLightState(a_tdxhArrayOfLights[lIndex].hLight, a_tdxhArrayOfLights[lIndex].lInitialState);
}
if (fTransparency >= 0.0)
{
HIE_fn_vSetSuperObjectTransparenceLevel(pStruct, fTransparency);
}
// recursive function
if (HIE_fn_ulGetSuperObjectType(pStruct)==HIE_C_ulActor)
{
GLI_tdxHandleToLight hLight=HIE_fn_hGetSuperObjectLight(pStruct);
if(hLight) {
if (HIE_fn_bGetSuperObjectExcluLight(pStruct))
GLI_xSetViewportLightsOnOff(0);
GLI_vAddLightToViewport(hVpt,hLight);
}
bDummy = g_bShowCollisionMap;
g_bShowCollisionMap = FALSE;
M_ForAllTheElementsInList(pChild, this, pos)
pChild->Display(hVpt, HIE_fn_lGetSuperObjectDrawMask(pStruct),
a_tdxhArrayOfLights, lNbLights, pWorld, bUseLocalFlag);
g_bShowCollisionMap = bDummy;
if(hLight) {
GLI_vPopLightsInViewport(hVpt , 1);
if (HIE_fn_bGetSuperObjectExcluLight(pStruct))
GLI_xSetViewportLightsOnOff(1);
}
}
else
M_ForAllTheElementsInList(pChild, this, pos)
pChild->Display(hVpt, HIE_fn_lGetSuperObjectDrawMask(pStruct)&lDrawMask,
a_tdxhArrayOfLights, lNbLights, pWorld, bUseLocalFlag);
HIE_fn_vPopMatrix ();
HIE_fn_vPopOnCameraMatrixStack ();
}
//########################################################################################
//########################################################################################
//########################################################################################
void CPA_SuperObjectBase::DisplayWorld(GLD_tdxHandleToViewportAttributes hVpt, tdstSaveLight a_tdxhArrayOfLights[], long lNbLights, BOOL bUseLocalMask)
{
GEO_tdstColor stColor;
// default material
GLI_xCreateMaterial(&g_hMaterial);
stColor.xR = (float) 0.99;
stColor.xG = (float) 0.99;
stColor.xB = (float) 0.99;
GLI_xSetMaterialAmbientCoef (g_hMaterial, &stColor);
GLI_xSetMaterialType(g_hMaterial, C_lGouraudElement);
GLI_vSetDefaultMaterial(hVpt, g_hMaterial);
// reinit matrix
HIE_fn_vInitMatrixStack();
if( HIE_fn_bInitCameraMatrixStack(hVpt) == OK)
{
// display world (recursive function)
Display(hVpt, GLI_C_lAllIsEnable&(GLI_C_lIsNotDrawCollideInformation^0xffffffff),
a_tdxhArrayOfLights, lNbLights,
(HIE_tdxHandleToSuperObject) GetSuperObjectStruct(), bUseLocalMask);
}
}
// FBF 01 04 98 {
void CPA_SuperObjectBase::SetLocalColor (tdeLocalColor eNewColor)
{
m_eColor = eNewColor;
}
// FBF 01 04 98}
#endif // ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,392 @@
/*=========================================================================
*
* EDTSubm.cpp : popup menu
*
*
* Version 1.0
* Creation date
* Revision date
*
* FBF
*=======================================================================*/
#include "stdafx.h"
#include "acp_base.h"
#include "itf/customid.h"
#ifdef ACTIVE_EDITOR
#include "itf/CPAsubm.hpp"
#include "itf/CPADLLb.hpp"
///////////////////////////////////////////////////////////////////////////////
// MACROS
///////////////////////////////////////////////////////////////////////////////
#define M_Entry(p_oElement) ( (EDT_SubMenuEntry*) p_oElement )
#define M_Menu(p_oElement) ( (EDT_SubMenu*) p_oElement )
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// class EDT_SubMenuEntry
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Description : constructor
// ----------------------------------------------------------------------------
EDT_SubMenuEntry::EDT_SubMenuEntry(CPA_EditorBase *pOwner, char *p_cText, UINT uiMsgID, UINT uiIntID, BOOL _bCheck /*=FALSE*/, BOOL _bEnable /*=TRUE*/)
:EDT_SubMenuElement(C_SMEEntry)
{
ASSERT( p_cText );
m_p_cText = (char*)malloc(strlen(p_cText)+1);
strcpy(m_p_cText, p_cText);
m_pOwner = pOwner;
m_IDCmdMsg = uiMsgID;
m_uiID = uiIntID;
m_bChecked = _bCheck;
m_bEnabled = _bEnable;
}
// ----------------------------------------------------------------------------
// Description : destructor
// ----------------------------------------------------------------------------
EDT_SubMenuEntry::~EDT_SubMenuEntry()
{
if(m_p_cText)
free(m_p_cText);
}
// ----------------------------------------------------------------------------
// Description : call handle function
// ----------------------------------------------------------------------------
UINT EDT_SubMenuEntry::SendCommand(EDT_SubMenu *_p_oSubMenu)
{
if (m_pOwner)
m_pOwner->_OnSubMenuCommand(_p_oSubMenu,m_IDCmdMsg);
return NULL;
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// class EDT_SubMenu
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Description : constructor
// ----------------------------------------------------------------------------
EDT_SubMenu::EDT_SubMenu(tde_SubMenu _eSubMenu,UINT _uiIDStart /*=C_CustomIDUserEnd*/)
:EDT_SubMenuElement(C_SMEMenu)
{
m_eSubMenu = _eSubMenu;
m_uiInternalID = m_uiInternalIDStart = _uiIDStart;
m_bHasFather = FALSE;
m_p_oFather = NULL;
m_szName = NULL;
RemoveAll();
}
// ----------------------------------------------------------------------------
// Description : destructor
// ----------------------------------------------------------------------------
EDT_SubMenu::~EDT_SubMenu()
{
Clear();
if(m_szName)
free(m_szName);
}
// ----------------------------------------------------------------------------
// Description : clear SubMenu content
// ----------------------------------------------------------------------------
void EDT_SubMenu::Clear()
{
POSITION stPos = GetHeadPosition();
while(stPos)
{
EDT_SubMenuElement *p_oElement = GetNext( stPos );
if( p_oElement -> mfn_eGetElementType() == C_SMEMenu )
{
// p_oElement is a SubMenu
M_Menu(p_oElement) -> Clear();
}
delete p_oElement;
}
RemoveAll();
m_uiInternalID = m_uiInternalIDStart;
}
// ----------------------------------------------------------------------------
// Description : return SubMenuType
// ----------------------------------------------------------------------------
tde_SubMenu EDT_SubMenu::GetSubMenuType()
{
return m_eSubMenu;
}
// ----------------------------------------------------------------------------
// Description : set father of SubMenu
// ----------------------------------------------------------------------------
void EDT_SubMenu::fn_vSetFather(EDT_SubMenu *_p_oFather)
{
ASSERT( _p_oFather );
m_bHasFather = TRUE;
m_p_oFather = _p_oFather;
}
// ----------------------------------------------------------------------------
// Description : set SubMenu name
// ----------------------------------------------------------------------------
void EDT_SubMenu::fn_vSetName(char *_szName)
{
ASSERT( _szName );
m_szName = (char*)malloc(strlen(_szName)+1);
strcpy(m_szName, _szName);
}
// ----------------------------------------------------------------------------
// Description : return next internal ID
// ----------------------------------------------------------------------------
UINT EDT_SubMenu::mfn_vGetNextInternalID()
{
if( m_bHasFather )
return m_p_oFather -> mfn_vGetNextInternalID();
else
return m_uiInternalID++;
}
// ----------------------------------------------------------------------------
// Description : build SubMenu
// ----------------------------------------------------------------------------
void EDT_SubMenu::Build(CMenu *pPopupMenu /*=NULL*/)
{
if(pPopupMenu)
{
EDT_SubMenuElement *p_oElement;
CMenu *p_oMenu;
UINT uiFlags;
// delete SubMenu
DeleteEntirePopupMenu(pPopupMenu);
// if last entry is a separator, remove it
if (!IsEmpty())
{
// check last element
p_oElement = GetTail();
if (p_oElement->mfn_eGetElementType() == C_SMESeparator)
RemoveTail();
}
// add all entries
POSITION stPos = GetHeadPosition();
while(stPos)
{
p_oElement = GetNext(stPos);
// add entry
switch ( p_oElement -> mfn_eGetElementType() )
{
case C_SMESeparator: // add a separator
pPopupMenu -> AppendMenu(MF_SEPARATOR);
break;
case C_SMEEntry: // add an item
uiFlags = MF_STRING | (M_Entry(p_oElement)->GetCheck() ? MF_CHECKED : MF_UNCHECKED )
| (M_Entry(p_oElement)->GetEnable() ? MF_ENABLED : MF_GRAYED );
pPopupMenu -> AppendMenu(uiFlags, M_Entry(p_oElement)->GetInternalID(), M_Entry(p_oElement)->GetText());
break;
case C_SMEMenu: // add a SubMenu
// create SubMenu
p_oMenu = new CMenu();
p_oMenu -> CreatePopupMenu();
// fill it
M_Menu(p_oElement) -> Build( p_oMenu );
// add to current SubMenu
pPopupMenu -> AppendMenu ( MF_STRING|MF_POPUP|MF_ENABLED , (UINT)p_oMenu -> Detach() , M_Menu(p_oElement) -> m_szName ) ;
delete p_oMenu;
break;
}
}
}
}
// ----------------------------------------------------------------------------
// Description : delete CMenu content
// ----------------------------------------------------------------------------
void EDT_SubMenu::DeleteEntirePopupMenu(CMenu* pPopupMenu)
{
while(pPopupMenu->GetMenuItemCount() > 0)
{
UINT uiState = pPopupMenu->GetMenuState(0,MF_BYPOSITION);
if(HIWORD(uiState) != 0)
{
// first item is a SubMenu
DeleteEntirePopupMenu(pPopupMenu->GetSubMenu(0));
}
pPopupMenu->DeleteMenu(0,MF_BYPOSITION);
}
}
// ----------------------------------------------------------------------------
// Description : get a new SubMenu (must uses it as sub menu of 'this')
// ----------------------------------------------------------------------------
EDT_SubMenu *EDT_SubMenu::fn_p_oGetNewSubMenu(char *_szName, tde_SubMenu _eMenuType /*=C_SubSubMenu*/)
{
ASSERT( _szName );
EDT_SubMenu *p_oResult = new EDT_SubMenu( _eMenuType == C_SubSubMenu ? GetSubMenuType() : _eMenuType );
p_oResult -> fn_vSetName( _szName );
p_oResult -> fn_vSetFather( this );
return p_oResult;
}
// ----------------------------------------------------------------------------
// Description : add a separator
// ----------------------------------------------------------------------------
void EDT_SubMenu::AddASeparator()
{
AddTail(new EDT_SubMenuSeparator());
}
// ----------------------------------------------------------------------------
// Description : add an entry from DLL
// ----------------------------------------------------------------------------
void EDT_SubMenu::AddAnEntry(CPA_EditorBase *p_oOwner, char *p_cText, UINT uiEntryID, BOOL _bCheck /*=FALSE*/, BOOL _bEnable /*=TRUE*/)
{
AddTail(new EDT_SubMenuEntry(p_oOwner, p_cText, uiEntryID, mfn_vGetNextInternalID(), _bCheck, _bEnable));
}
// ----------------------------------------------------------------------------
// Description : add a SubMenu
// ----------------------------------------------------------------------------
void EDT_SubMenu::AddASubMenu(EDT_SubMenu *_p_oSubMenu)
{
ASSERT( _p_oSubMenu );
// SubMenu must be child of current SubMenu
ASSERT( _p_oSubMenu -> m_p_oFather == this );
// add SubMenu
AddTail( (EDT_SubMenuElement*)_p_oSubMenu );
}
// ----------------------------------------------------------------------------
// Description : handle selected item
// ----------------------------------------------------------------------------
UINT EDT_SubMenu::_OnCommand(UINT uiInternalID)
{
POSITION stPos;
EDT_SubMenuElement *p_oElement;
stPos = GetHeadPosition();
while(stPos)
{
p_oElement = GetNext(stPos);
if( (p_oElement -> mfn_eGetElementType() == C_SMEEntry) && (M_Entry(p_oElement) -> GetInternalID() == uiInternalID) )
{
// entry found!, launch command on owner
return M_Entry(p_oElement) -> SendCommand(this);
}
else if( (p_oElement -> mfn_eGetElementType() == C_SMEMenu) )
{
// search on submenu
UINT uiResult = M_Menu(p_oElement) -> _OnCommand( uiInternalID );
if( uiResult )
// entry found
return uiResult;
}
}
return NULL;
}
// ----------------------------------------------------------------------------
// Description : handle selected item
// ----------------------------------------------------------------------------
BOOL EDT_SubMenu::fn_bFindCmdID (UINT uiInternalID, CPA_EditorBase **pOwner, UINT *CmdID)
{
EDT_SubMenuElement *pElem;
POSITION pos;
pos = GetHeadPosition();
while(pos)
{
pElem = GetNext(pos);
if ((pElem->mfn_eGetElementType() == C_SMEEntry) && (M_Entry(pElem)->GetInternalID() == uiInternalID))
{
// entry found
*CmdID = M_Entry(pElem)->GetCmdID();
if (pOwner)
*pOwner = M_Entry(pElem)->GetOwner();
return TRUE;
}
else if ((pElem->mfn_eGetElementType() == C_SMEMenu))
{
// search on submenu
if (M_Menu(pElem)->fn_bFindCmdID(uiInternalID,pOwner,CmdID))
return TRUE;
}
}
// entry not found
return FALSE;
}
// JMD
char EDT_SubMenu::fn_cGrayedItem (CMenu *pPopupMenu, char *szItem) {
char cFinish = 0 ;
if(pPopupMenu) {
EDT_SubMenuElement *p_oElement;
int iID ;
LPCTSTR szText ;
// add all entries
POSITION stPos = GetHeadPosition();
while(stPos && !cFinish) {
p_oElement = GetNext(stPos);
// add entry
switch ( p_oElement -> mfn_eGetElementType() ) {
case C_SMEEntry: // add an item
iID = M_Entry(p_oElement)->GetInternalID();
szText = M_Entry(p_oElement)->GetText();
if ( !stricmp (szItem, szText) ) {
pPopupMenu->EnableMenuItem ( iID, MF_GRAYED | MF_BYCOMMAND ) ;
cFinish = 1 ;
}
break;
case C_SMEMenu: // add a SubMenu
iID = M_Menu(p_oElement)->m_uiInternalID;
szText = M_Menu(p_oElement)->m_szName ;
if ( !stricmp (szItem, szText) ) {
//pPopupMenu->EnableMenuItem ( iID, MF_BYCOMMAND ) ;
M_Menu(p_oElement)->fn_vGrayedAllMenuItem( pPopupMenu );
cFinish = 1 ;
}
else
cFinish = M_Menu(p_oElement)->fn_cGrayedItem( pPopupMenu, szItem );
break;
}
}
}
return (cFinish) ;
}
void EDT_SubMenu::fn_vGrayedAllMenuItem ( CMenu *pPopupMenu ){
EDT_SubMenuElement *p_oElement;
int iID ;
// add all entries
POSITION stPos = GetHeadPosition();
while(stPos) {
p_oElement = GetNext(stPos);
// add entry
switch ( p_oElement -> mfn_eGetElementType() ) {
case C_SMEEntry: // add an item
iID = M_Entry(p_oElement)->GetInternalID();
pPopupMenu->EnableMenuItem ( iID, MF_GRAYED | MF_BYCOMMAND ) ;
break;
case C_SMEMenu: // add a SubMenu
M_Menu(p_oElement)->fn_vGrayedAllMenuItem( pPopupMenu );
break;
}
}
}
#endif //ACTIVE_EDITOR

View File

@@ -0,0 +1,233 @@
/*=========================================================================
* CPAWButo.cpp : Implementation of Window Button for the PopUpToolBar.
* This is a part of the PCA project.
*
* Version 1.0
* Creation date 26/06/96
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "itf/CPAPopTB.hpp"
#include "itf/CPAWButo.hpp"
#include "itf/CPARes.h"
#include "itf/frmbsmn.hpp"
/////////////////////////////////////////////////////////////////////////////
// CPA_WndButton
CPA_WndButton::CPA_WndButton()
{
}
CPA_WndButton::~CPA_WndButton()
{
}
BEGIN_MESSAGE_MAP(CPA_WndButton, CWnd)
//{{AFX_MSG_MAP(CPA_WndButton)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_WndButton message handlers
int CPA_WndButton::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
int CPA_WndButton::CreateToolBarCtrl()
{
long i;
TBBUTTON a_stTBBut[C_MAX_BUTTON_PER_FAMILY];
m_oToolBarCtrl.AddBitmap(m_lNbButtonsTotal,m_lIdResource);
for (i = 0 ; i < m_lNbButtons ; i++ )
{
if ( m_a_stButtons[i].lId != NULL)
{
a_stTBBut[i].fsState = (m_a_stButtons[i].bPermit)?TBSTATE_ENABLED:TBSTATE_INDETERMINATE;// button state
a_stTBBut[i].fsStyle = TBSTYLE_BUTTON; // button style--see below
a_stTBBut[i].dwData = NULL; // application-defined value
a_stTBBut[i].iString = NULL; // zero-based index of button label string
if ( m_a_stButtons[i].lId == ID_SEPARATOR )
{
a_stTBBut[i].iBitmap = 0 ;
a_stTBBut[i].idCommand = 0 ;
a_stTBBut[i].fsStyle = TBSTYLE_SEP ;
}
else
{
a_stTBBut[i].iBitmap = m_a_stButtons[i].lIndexBitmap;
a_stTBBut[i].idCommand = m_a_stButtons[i].lId ;
}
}
}
m_oToolBarCtrl.AddButtons(m_lNbButtons, a_stTBBut );
m_oToolBarCtrl.AutoSize();
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
// Create the toolbar in the parent FrameWnd.
int CPA_WndButton::CreateToolBar()
{
CRect stRect;
if (!m_oToolBarCtrl.Create(CCS_NODIVIDER|WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),
this,m_lIdResource))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
m_p_oPopUpTBParent->GetItemRect(0,&stRect);
m_oToolBarCtrl.SetButtonSize(CSize(stRect.right-stRect.left-7, stRect.bottom-stRect.top-6));
m_oToolBarCtrl.SetBitmapSize(CSize(stRect.right-stRect.left-7, stRect.bottom-stRect.top-6));
CreateToolBarCtrl();
return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void CPA_WndButton::CreateWndButton(CPA_PopUpToolBar *p_oPopUpTB,
long lWndPosX,
long lWndPosY,
tdstButton a_stButtons[],
long lNbButtons,
long lFamily,
long lNbButtonsTotal,
long lIdResource)
{
CRect stRect;
CWnd *p_oWnd = p_oPopUpTB->GetParent()->GetParent();
CPoint pt(lWndPosX, lWndPosY);
p_oWnd->ScreenToClient(&pt);
Create( NULL, "toto",WS_BORDER|WS_VISIBLE|WS_CHILD,
CRect(pt.x,pt.y,0,0), p_oWnd, lIdResource);
g_bMouseLocked = TRUE;
m_lNbButtonsTotal = lNbButtonsTotal;
m_lIdResource = lIdResource;
m_lFamily = lFamily;
m_lNbButtons = lNbButtons;
m_p_oPopUpTBParent = p_oPopUpTB;
m_lIdChosenButton = 0;
memcpy(m_a_stButtons, a_stButtons,m_lNbButtons * sizeof(tdstButton));
CreateToolBar();
m_oToolBarCtrl.GetItemRect(0,&stRect);
SetWindowPos(&wndTopMost,0,0,m_lNbButtons*stRect.right,stRect.bottom,SWP_NOMOVE|SWP_NOZORDER|SWP_SHOWWINDOW);
m_p_oGrabCapture();
SetFocus();
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void CPA_WndButton::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
if (m_oToolBarCtrl.m_hWnd != NULL)
m_oToolBarCtrl.AutoSize();
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void CPA_WndButton::OnLButtonUp( UINT nflags, CPoint oPoint )
{
CWnd::OnLButtonUp(nflags,oPoint);
int i;
long lParam;
if(m_p_oPopUpTBParent->m_bJustPressed)
{
m_p_oPopUpTBParent->m_bJustPressed = FALSE;
if(m_p_oPopUpTBParent->m_bCurrentButtonAlone)
{
m_p_oPopUpTBParent->PressButton(m_p_oPopUpTBParent->m_lIdCurrentButton, FALSE);
m_p_oPopUpTBParent->GetParent()->SendMessage(WM_COMMAND, m_p_oPopUpTBParent->m_lIdCurrentButton);
DestroyWindow();
g_bMouseLocked = FALSE;
}
return;
}
for(i = 0; i < m_oToolBarCtrl.GetButtonCount(); i++)
{
if(m_oToolBarCtrl.IsButtonPressed(m_a_stButtons[i].lId))
{
m_lIdChosenButton = m_a_stButtons[i].lId;
break;
}
}
((FRMBaseMenu*)(m_p_oPopUpTBParent->GetParent()->GetParent()))->UpdateStatus(NULL,
C_STATUSPANE_INFOS,
C_STATUS_NORMAL);
m_p_oSurrenderCapture();
// tells popuptoolbar about buttonup...
lParam = (oPoint.x + (oPoint.y << 16));
m_p_oPopUpTBParent->SendMessage(WM_LBUTTONUP,nflags,lParam);
DestroyWindow();
g_bMouseLocked = FALSE;
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void CPA_WndButton::OnMouseMove( UINT nflags, CPoint oPoint )
{
CRect rect;
int i;
// first, release the buttons if necessary
for(i = 0; i < m_lNbButtons; i++)
{
m_oToolBarCtrl.GetItemRect(i, &rect);
// if the mouse is not on the button and if the button is pressed -> release it
if (m_oToolBarCtrl.IsButtonPressed(m_a_stButtons[i].lId) && !rect.PtInRect(oPoint))
{
m_oToolBarCtrl.PressButton( m_a_stButtons[i].lId, FALSE);
((FRMBaseMenu*)(m_p_oPopUpTBParent->GetParent()->GetParent()))->UpdateStatus(NULL,
C_STATUSPANE_INFOS,
C_STATUS_NORMAL);
}
}
//then, press the the good button if necessary
for(i = 0; i < m_lNbButtons; i++)
{
m_oToolBarCtrl.GetItemRect(i, &rect);
// if the mouse is on the button and if the button is not pressed -> press it
if (rect.PtInRect(oPoint) && !m_oToolBarCtrl.IsButtonPressed(m_a_stButtons[i].lId))
{
if (m_oToolBarCtrl.IsButtonEnabled(m_a_stButtons[i].lId))
{
m_oToolBarCtrl.PressButton(m_a_stButtons[i].lId, TRUE);
((FRMBaseMenu*)(m_p_oPopUpTBParent->GetParent()->GetParent()))->UpdateStatus(m_a_stButtons[i].szTipText,
C_STATUSPANE_INFOS,
C_STATUS_NORMAL);
}
}
}
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,255 @@
#include "stdafx.h"
#include "acp_base.h"
#ifdef ACTIVE_EDITOR
#include "itf/CPAWData.hpp"
#pragma warning(disable:4355)
CPA_WalkDataMgr::CPA_WalkDataMgr():WalkData(this, NULL) {
for (iVoid=0; iVoid<MAX_WALKDATA_ELEMENT; iVoid++) {
aWD [iVoid].ItsData = NULL;
aWD [iVoid].backnext = NO_ID;
aWD [iVoid].backprev = NO_ID;
aWD [iVoid].next = NO_ID;
aWD [iVoid].prev = NO_ID;
}
iVoid = 0;
iCount = 0;
}
CPA_WalkDataMgr::~CPA_WalkDataMgr() {
int i;
for (i=iCurrent; i!=NO_ID; i=aWD[i].backprev) {
delete ((WalkData *)aWD[i].ItsData);
}
}
void CPA_WalkDataMgr::InsertElement (CPA_DLLBase *pDLL, void *ItsData) {
GoElement (pDLL);
WalkData *pWDToInsertTo = (WalkData *)aWD[iCurrent].ItsData;
#ifdef CHECK // check if occurence already exists.
if (!pWDToInsertTo->CheckAndGoElement (ItsData)) {
pWDToInsertTo->InsertVoidElement (ItsData);
UpdateIVoid();
}
#else
pWDToInsertTo->InsertVoidElement (ItsData);
UpdateIVoid();
#endif
}
void CPA_WalkDataMgr::ActiveElement (CPA_DLLBase *pDLL) {
GoElement (pDLL);
ActiveCurrent();
}
/******************** private *******************/
void CPA_WalkDataMgr::UpdateAll () {
int i;
for (i=iCurrent; i!=NO_ID; i=aWD[i].backprev) {
((WalkData *)aWD[i].ItsData)->UpdateList();
}
}
void CPA_WalkDataMgr::UpdateIVoid() {
int i, j;
WalkData *pWD;
if (iCount!=MAX_WALKDATA_ELEMENT-1) {
iVoid = ++iCount;
}
else {// take an element already used
i=iLastUsed;
do {
pWD = (WalkData *)aWD[i].ItsData;
i=aWD[i].next;
}
while (pWD->iCurrent==NO_ID);
j = pWD->iLastUsed;
iVoid = j;
// tell DLL that the data is no longer of use.
pWD->MyDLL->fn_vEraseWalkDataStructure (aWD[j].ItsData);
// update list
if (j == pWD->iCurrent) // this WD had only one element
pWD->iCurrent = NO_ID;
else { // update the element linked to the one we took
pWD->iLastUsed = aWD[j].next;
aWD[pWD->iLastUsed].prev = NO_ID;
aWD[pWD->iLastUsed].backprev = NO_ID;
}
// clean new Void element (for safety)
aWD[j].next = aWD[j].prev = NO_ID;
aWD[j].backnext = aWD[j].backprev = NO_ID;
}
}
int CPA_WalkDataMgr::FindOrCreateWalkData (CPA_DLLBase *pDLL) {
int i, iInsertNode;
for (i=iCurrent; i!=NO_ID; i=aWD[i].backprev) {
if (((WalkData *)aWD[i].ItsData)->MyDLL == pDLL) {
iInsertNode = i;
break;
}
}
if (i==NO_ID) { // New Node
iInsertNode = iVoid;
InsertVoidElement((void *)new WalkData (this, pDLL));
UpdateIVoid();
}
return (iInsertNode);
}
void CPA_WalkDataMgr::GoElement (CPA_DLLBase *pDLL) {
int iNew;
UpdateAll ();
iNew = FindOrCreateWalkData (pDLL);
if (iNew != iCurrent) Go (iNew);
UpdateList ();
}
inline void CPA_WalkDataMgr::ActiveCurrent() {
((WalkData *)aWD[iCurrent].ItsData)->BackActive();
}
void CPA_WalkDataMgr::DBackward() {
if (iCurrent!=NO_ID)
if (((WalkData *)aWD[iCurrent].ItsData)->Backward())
ActiveCurrent();
}
void CPA_WalkDataMgr::DForward() {
if (iCurrent!=NO_ID)
if (((WalkData *)aWD[iCurrent].ItsData)->Forward())
ActiveCurrent();
}
void CPA_WalkDataMgr::EBackward() {
if (Backward ())
ActiveCurrent();
}
void CPA_WalkDataMgr::EForward() {
if (Forward ())
ActiveCurrent();
}
/************************* WalkData ************************/
WalkData::WalkData(CPA_WalkDataMgr *aWDM, CPA_DLLBase *pDLL) {
MyWDM = aWDM;
aWD = aWDM->aWD; // ne changera pas
iCurrent = NO_ID;
iFirst = NO_ID;
iLast = NO_ID;
iLastUsed = NO_ID;
MyDLL = pDLL;
}
inline void WalkData::ABLink (int a, int b) {aWD[a].next = b; aWD[b].prev = a;BLink(a,b);}
inline void WalkData::BLink (int a, int b) {aWD[a].backnext = b; aWD[b].backprev = a;}
void WalkData::UpdateList(){
int i;
if ((iCurrent==NO_ID) || (iLast==iCurrent)) return;
for (i=iLast; i!=NO_ID; i=aWD[i].backnext) { // updatelist
aWD[i].prev = aWD[i].backprev;
aWD[i].next = aWD[i].backnext;
};
iLast = iCurrent;
}
int WalkData::CheckAndGoElement (void *ItsData) {
int i;
for (i=iCurrent; i!=NO_ID; i=aWD[i].prev) {
if ((aWD[i].ItsData == ItsData) && (aWD[i].ItsData == ItsData)) {
if (i!=iCurrent) Go(i);
UpdateList();
return (TRUE);
}
}
return (FALSE);
}
void WalkData::InsertVoidElement (void *ItsData) {
UpdateList();
iLast = iFirst = MyWDM->iVoid;
if (iCurrent!=NO_ID)
ABLink (iCurrent, iFirst);
else {
iLastUsed = iFirst;
aWD[iFirst].prev = NO_ID;
aWD[iFirst].backprev = NO_ID;
}
aWD[iFirst].aWalkData = this;
aWD[iFirst].ItsData = ItsData;
aWD[iFirst].next = NO_ID;
aWD[iFirst].backnext = NO_ID;
iCurrent = iFirst;
}
int WalkData::Backward() {
int iNew;
if (iCurrent==NO_ID) return (FALSE);
iNew = aWD[iCurrent].prev;
if (iNew == NO_ID) return (FALSE);
Go (iNew);
return (TRUE);
}
int WalkData::Forward() {
int iNew;
if (iCurrent==NO_ID) return (FALSE);
iNew = aWD[iCurrent].next;
if (iNew == NO_ID) return (FALSE);
Go (iNew);
return (TRUE);
}
void WalkData::Go(int iNew) { // iNew must not be iCurrent nor NO_ID
int i, j, k;
j = aWD[iNew].backprev;
k = aWD[iNew].backnext;
if (j!=NO_ID)
BLink (j, k);
else {
aWD[k].backprev = NO_ID;
if (iLast==iNew) iLast = k;
else j=k; // to update iLast correctly
}
if (iLastUsed==iNew) iLastUsed = k;
BLink (iCurrent, iNew);
aWD[iNew].backnext = NO_ID;
iCurrent = iNew;
// update iLast if needed
for (i=j; (i!=iLast) && (i!=NO_ID); i=aWD[i].backnext);
if (i==iLast) iLast = j;
}
void WalkData::BackActive () {
if (iCurrent==NO_ID)
MyDLL->fn_vBackActiveMe (NULL);
else
MyDLL->fn_vBackActiveMe (aWD[iCurrent].ItsData);
}
#endif

View File

@@ -0,0 +1,509 @@
// class CPA_WORLD
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/CPAWorld.hpp"
#include "itf/cpasobj.hpp"
#include "itf/devmul3d.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAInter.hpp"
#include "itf/stddllid.h"
CPA_World::CPA_World(CPA_MainWorld *_p_oMainWorld, BOOL bTemporary)
{
CPA_CameraDLLBase* p_oCamDLL;
m_bIsTemporary = bTemporary;
m_p_oSprObjRoot = NULL;
m_p_oMultiDevice = NULL;
fn_vInitListObjects(_p_oMainWorld->GetListOfObjectDLLBase());
p_oCamDLL = (CPA_CameraDLLBase*) (_p_oMainWorld->GetObjectDLLWithName(C_szDLLCameraName));
m_oCameraSlots.SetInterface(p_oCamDLL);
}
CPA_World::~CPA_World()
{
while (!(m_lstListByDLL.IsEmpty()))
delete m_lstListByDLL.RemoveHead();
//CPA2 Corneliu Babiuc (multiple teleportation) 3-03-98
while (!(m_lstRegisterListByDLL.IsEmpty()))
delete m_lstRegisterListByDLL.RemoveHead();
//END CPA2 Corneliu Babiuc (multiple teleportation) 3-03-98
}
CPA_Interface * CPA_World::GetInterface (void)
{
return m_p_oMultiDevice->GetInterface();
}
/*===========================================================================
* Description: Init the lists
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vCreateListFromHierarchy(CPA_List<CPA_ObjectDLLBase> *_p_oListOfObjectDLL)
{
fn_vInitListObjects(_p_oListOfObjectDLL);
fn_vInitListAllObjects(m_p_oSprObjRoot);
}
/*===========================================================================
* Description: Init the lists from Objects DLLs
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vInitListObjects(CPA_List<CPA_ObjectDLLBase> *_p_oListOfObjectDLL)
{
CPA_ObjectDLLBase *p_oDLL;
POSITION pos;
// RAZ
m_lstListByDLL.RemoveAll();
m_stListAllObjects.RemoveAll();
m_stListAllDLLs.fn_vReinit();
//CPA2 Corneliu Babiuc (multiple registration)
m_lstRegisterListByDLL.RemoveAll();
m_stRegisterListAllDLLs.fn_vReinit();
//END CPA2 Corneliu Babiuc (multiple registration)
// check all objects dlls to find the available types
for (p_oDLL = _p_oListOfObjectDLL->GetHeadElement(pos); p_oDLL;
p_oDLL = _p_oListOfObjectDLL->GetNextElement(pos))
{
// create the corresponding ListByType
m_lstListByDLL.AddTail(new EDT_ListByDLL(p_oDLL));
//CPA2 Corneliu Babiuc (multiple registration)
m_lstRegisterListByDLL.AddTail(new EDT_ListByDLL(p_oDLL));
//END CPA2 Corneliu Babiuc (multiple registration)
p_oDLL->fn_vInitListByType(this);
}
}
/*===========================================================================
* Description: create and init the lists of models
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vAddANewListByType (char *szTypeName, CPA_ObjectDLLBase *pObjectDLL)
{
EDT_ListByType *pListType;
EDT_ListByDLL *pListDLL;
// find the corresponding DLL list
pListDLL = GetListFromObjectDLL(pObjectDLL);
if (!pListDLL)
{
pListDLL= new EDT_ListByDLL(pObjectDLL);
GetListOfListByDLL()->AddTail(pListDLL);
}
// create list by type
pListType = pListDLL->GetListByType(szTypeName);
if (!pListType)
{
pListType = new EDT_ListByType(pObjectDLL, szTypeName);
pListDLL->m_stListOfListByType.AddTail(pListType);
}
}
/*===========================================================================
* Description: Init the list of all objects in the hierarchy
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vInitListAllObjects(CPA_SuperObject *_p_EdObj)
{
CPA_SuperObject *p_EdChild;
p_EdChild = _p_EdObj->GetSuperObjectFirstChild();
while (p_EdChild)
{
// add the child to the list
m_stListAllObjects.AddTail(p_EdChild);
// next level of hierarchy
fn_vInitListAllObjects(p_EdChild);
// next brother
p_EdChild = _p_EdObj->GetSuperObjectNextChild(p_EdChild);
}
}
void CPA_World::InitWorldForDrawing()
{
ASSERT(m_p_oSprObjRoot != NULL);
// compute new world spherebox
// GLI_xComputeSuperObjectSphereBox(m_p_oSprObjRoot->GetStruct());
}
void CPA_World::fn_vSetRoot(CPA_SuperObject *_p_SprObj)
{
// if there is a multidevice, then clear old engine struct
if (m_p_oMultiDevice)
m_p_oMultiDevice->SetEngineWorld(NULL);
m_p_oSprObjRoot = _p_SprObj;
if (m_p_oSprObjRoot)
{
InitWorldForDrawing();
fn_vReinitListObjects();
fn_vFillListObjects(m_p_oSprObjRoot);
fn_vReinitSortedList();
if (m_p_oMultiDevice)
{
m_p_oMultiDevice->SetEngineWorld(m_p_oSprObjRoot->GetStruct());
if (m_p_oMultiDevice->GetInterface())
m_p_oMultiDevice->GetInterface()->fn_vChangeRoot();
}
}
}
/*===========================================================================
* Description: RAZ of all lists
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* test the type of the object
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vReinitListObjects(void)
{
EDT_ListByDLL *pListDLL;
POSITION pos;
// Reinit the list of all objects
m_stListAllDLLs.fn_vReinit();
m_stListAllObjects.RemoveAll();
// Reinit the lists by Types
for (pListDLL = m_lstListByDLL.GetHeadElement(pos); pListDLL;
pListDLL = m_lstListByDLL.GetNextElement(pos))
pListDLL->fn_vReinit();
}
/*===========================================================================
* Description: RAZ of all lists
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* test the type of the object
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vReinitSortedList(void)
{
EDT_ListByDLL *pListDLL;
POSITION pos;
// Reinit the list of all objects
m_stListAllDLLs.fn_vUpdateSortedList();
// Reinit the lists by Types
for (pListDLL = m_lstListByDLL.GetHeadElement(pos); pListDLL;
pListDLL = m_lstListByDLL.GetNextElement(pos))
pListDLL->fn_vUpdateSortedList();
}
/*===========================================================================
* Description: fill the list from the current hierarchy
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* test the type of the object
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vFillListObjects(CPA_SuperObject *pEdObj)
{
CPA_SuperObject *pChild;
EDT_ListByDLL *pListDLL;
// Find objects which type belongs to the Editor
if ((pEdObj->GetObjectType() != HIE_C_ulSuperObject)&&(!pEdObj->fn_bIsEditProtected()))
{
// update the corresponding list
pListDLL = GetListFromObject(pEdObj);
pListDLL->fn_vUpdateListObject(pEdObj, E_lum_Insert);
// Update the lists by Type
m_stListAllDLLs.fn_vUpdateListObject(pEdObj, E_lum_Insert);
}
// Fill the list of all objects
m_stListAllObjects.AddTail(pEdObj);
// Next level of hierarchy
pChild = pEdObj->GetSuperObjectFirstChild();
while (pChild)
{
fn_vFillListObjects(pChild);
pChild = pEdObj->GetSuperObjectNextChild(pChild);
}
}
//CPA2 Corneliu Babiuc (multiple registration) 02-07-98
/*===========================================================================
* Description: Find the list by type corresponding to the object
* (the list it must belong to).
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* test the type of the object
*---------------------------------------------------------------------------
* Revision date: Author:
* 02-07-98 Corneliu Babiuc (pass the list as parameter)
*=========================================================================*/
EDT_ListByDLL * CPA_World::GetListFromObject (CPA_List<EDT_ListByDLL> *p_lstListByDLL, CPA_SuperObject *pEdObj)
{
EDT_ListByDLL *pListDLL = NULL;
POSITION pos;
// protected childs can't be selected
if (!pEdObj)
return NULL;
/* for (pListDLL = m_lstListByDLL.GetHeadElement(pos); pListDLL;
pListDLL = m_lstListByDLL.GetNextElement(pos)) */
for (pListDLL = p_lstListByDLL->GetHeadElement(pos); pListDLL;
pListDLL = p_lstListByDLL->GetNextElement(pos))
//END CPA2 Corneliu Babiuc (multiple registration) 02-07-98
{
if (pEdObj->GetObjectDLL() == pListDLL->GetDLL())
return pListDLL;
}
return NULL;
}
//CPA2 Corneliu Babiuc (multiple registration) 02-07-98
/*===========================================================================
* Description: Find the lists corresponding to the type of object
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
* test the type of the object
*---------------------------------------------------------------------------
* Revision date: Author:
* 02-07-98 Corneliu Babiuc (pass the list as parameter)
*=========================================================================*/
EDT_ListByDLL * CPA_World::GetListFromObjectDLL (CPA_List<EDT_ListByDLL> *p_lstListByDLL, CPA_ObjectDLLBase *p_oDLL)
{
EDT_ListByDLL *pListDLL = NULL;
POSITION pos;
/* for (pListDLL = m_lstListByDLL.GetHeadElement(pos); pListDLL;
pListDLL = m_lstListByDLL.GetNextElement(pos)) */
for (pListDLL = p_lstListByDLL->GetHeadElement(pos); pListDLL;
pListDLL = p_lstListByDLL->GetNextElement(pos))
//END CPA2 Corneliu Babiuc (multiple registration) 02-07-98
{
if (p_oDLL == pListDLL->GetDLL())
return pListDLL;
}
return NULL;
}
/*===========================================================================
* Description: Update the lists when an object is deleted or inserted
* in the hierarchy (recursive function)
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vUpdateListObjects (CPA_SuperObject *pEdObj, tdeListUpdateMode eType, BOOL bUpdateObject)
{
CPA_SuperObject *pChild;
EDT_ListByDLL *pListDLL;
POSITION pos;
pListDLL = GetListFromObject(pEdObj);
// if the type is handled by the Editor
if (pListDLL)
pListDLL->fn_vUpdateListObject(pEdObj, eType);
m_stListAllDLLs.fn_vUpdateListObject(pEdObj, eType);
// update other lists
if ((eType == E_lum_Insert)||(eType == E_lum_ReInsert))
m_stListAllObjects.AddTail(pEdObj);
else if (eType == E_lum_Delete)
{
// update the list of all objects
pos = m_stListAllObjects.Find(pEdObj, NULL);
if (pos)
m_stListAllObjects.RemoveAt(pos);
// update selection
fn_vUpdateSelectLists(pEdObj, E_lum_Delete, TRUE);
}
// next level of the hierarchy
pChild = pEdObj->GetSuperObjectFirstChild();
while (pChild)
{
fn_vUpdateListObjects(pChild, eType, bUpdateObject);
pChild = pEdObj->GetSuperObjectNextChild(pChild);
}
}
/*===========================================================================
* Description: Update select lists when an object is selected or
* un-selected
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vUpdateSelectLists (CPA_SuperObject *pEdObj, tdeListUpdateMode eType, BOOL bIsSelected)
{
CPA_SuperObject *pChild;
EDT_ListByDLL *pListSelect;
// update list select
pListSelect = GetListFromObject(pEdObj);
if (pListSelect)
pListSelect->fn_vUpdateListSelect(pEdObj, eType, bIsSelected);
// update list all types
m_stListAllDLLs.fn_vUpdateListSelect(pEdObj, eType, bIsSelected);
// if necessary, update lists for the owner
if (pEdObj->GetSuperObjectOwner())
{
pListSelect = GetListFromObject(pEdObj->GetSuperObjectOwner());
if (pListSelect)
pListSelect->fn_vUpdateListProtect(pEdObj, eType, bIsSelected);
}
// next level of the hierarchy
pChild = pEdObj->GetSuperObjectFirstChild();
while (pChild)
{
fn_vUpdateSelectLists(pChild, eType, FALSE);
pChild = pEdObj->GetSuperObjectNextChild(pChild);
}
}
//CPA2 Corneliu Babiuc (multiple registration) 02-07-98
/*===========================================================================
* Description: Update registration lists when an object is added or
removed from registration
* Creation date:
* Author: Corneliu Babiuc
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vUpdateRegisterLists (CPA_SuperObject *pEdObj, tdeListUpdateMode eType, BOOL bIsSelected)
{
CPA_SuperObject *pChild;
EDT_ListByDLL *pListSelect;
// update list select
pListSelect = GetListFromObject(&m_lstRegisterListByDLL, pEdObj);
if (pListSelect)
pListSelect->fn_vUpdateListSelect(pEdObj, eType, bIsSelected);
// update list all types
m_stRegisterListAllDLLs.fn_vUpdateListSelect(pEdObj, eType, bIsSelected);
// if necessary, update lists for the owner
if (pEdObj->GetSuperObjectOwner())
{
pListSelect = GetListFromObject(&m_lstRegisterListByDLL, pEdObj->GetSuperObjectOwner());
if (pListSelect)
pListSelect->fn_vUpdateListProtect(pEdObj, eType, bIsSelected);
}
// next level of the hierarchy
pChild = pEdObj->GetSuperObjectFirstChild();
while (pChild)
{
fn_vUpdateRegisterLists(pChild, eType, FALSE);
pChild = pEdObj->GetSuperObjectNextChild(pChild);
}
}
//END CPA2 Corneliu Babiuc (multiple registration) 02-07-98
/*===========================================================================
* Description: insert super-object in a new world without updating object
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vInsertSuperObjectInNewWorld (CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, BOOL bUpdateDrawing)
{
// insert object in hierarchy
pEdObj->Isolate();
pParent->AddTail(pEdObj);
// update the corresponding list
fn_vUpdateListObjects(pEdObj, E_lum_Insert, FALSE);
// update validity
pEdObj->fn_vUpdateValidity(TRUE);
// update absolute position
if ((m_p_oMultiDevice)&&(m_p_oMultiDevice->GetInterface()))
{
if (bUpdateDrawing)
m_p_oMultiDevice->GetInterface()->fn_vUpdateAll(E_mc_UpdateAll);
}
}
/*===========================================================================
* Description: delete super-object in new world without updating object
* Creation date:
* Author: Shaitan
*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------
* Revision date: Author:
*=========================================================================*/
void CPA_World::fn_vDeleteSuperObjectInNewWorld (CPA_SuperObject *pEdObj, BOOL bUpdateDrawing)
{
// remove object from hierarchy
pEdObj->Isolate();
// update all the lists
fn_vUpdateListObjects(pEdObj, E_lum_Delete, FALSE);
// update validity
pEdObj->fn_vUpdateValidity(FALSE);
// update absolute position
if ((m_p_oMultiDevice)&&(m_p_oMultiDevice->GetInterface()))
{
if (bUpdateDrawing)
m_p_oMultiDevice->GetInterface()->fn_vUpdateAll(E_mc_UpdateAll);
}
}
#endif //ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,516 @@
/*=========================================================================
* DEVDevic.cpp : Implementation of device.
* This is a part of the CPA project.
*
* Version 1.0
* Creation date 26/06/96
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#include "acp_base.h"
#include "geo.h"
#include "gli.h"
#include "col.h"
#define HieFriend
#include "spo.h"
#include "main.h"
#include "lst.hpp"
#include "itf/CPARes.h"
#include "itf/DEVDevic.hpp"
#include "itf/DEVVp3D.hpp"
#include "itf/DEVVp2D.hpp"
#include "itf/DEVMulti.hpp"
#include "itf/DEVMul3D.hpp"
#include "itf/CPAProj.hpp"
#include "itf/cpamworl.hpp"
#include "itf/StdDLLId.h"
#include "itf/camdllb.hpp"
#include "itf/CPAConst.hpp"
// type of Device.
#define DEV_NORMAL 0
#define DEV_BACKGROUND 1
BEGIN_MESSAGE_MAP(DEV_Device, CWnd)
//{{AFX_MSG_MAP(DEV_Device)
ON_WM_DESTROY()
ON_WM_SIZE()
ON_WM_MOUSEACTIVATE()
ON_WM_CREATE()
ON_WM_WINDOWPOSCHANGING()
ON_WM_WINDOWPOSCHANGED()
ON_WM_PAINT()
ON_WM_NCACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//================================================================================
//================================================================================
DEV_Device::DEV_Device()
{
}
DEV_Device::~DEV_Device()
{
}
#ifndef ACTIVE_EDITOR
CFrameWnd *DEV_Device::GetParentFrame()
{
return GetParentMultiDevice()->GetParentFrame();
}
#endif
//================================================================================
//================================================================================
// return the number of Device
int DEV_Device::GetNumber()
{
return 0;
}
//================================================================================
//================================================================================
// Return the Camera if this is a device 3D else return NULL.
GLI_tdxHandleToCamera DEV_Device::GetCamera()
{
if (mViewType == C_DEVICE3D)
return ((DEV_ViewPort3D *)mpViewPort)->GetEngineCamera();
else return NULL;
}
//================================================================================
//================================================================================
// creation of a background Device
// first Device created
void DEV_Device::CreateDeviceBackground(void * device, UINT ViewType)
{
CRect stRect;
m_p_oWndParent = (CWnd*)device;
mType = DEV_BACKGROUND; // definition of type
mViewType = ViewType;
GetParentMultiDevice()->GetClientRect(&stRect);
Create(NULL, (LPCTSTR) "",
WS_OVERLAPPED | WS_CLIPSIBLINGS | WS_VISIBLE | WS_CHILD | WS_MAXIMIZE,
stRect, m_p_oWndParent, 1);
// positioning of Device in rear plan
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}
//================================================================================
//================================================================================
void DEV_Device::OnDestroy()
{
if (WaitForSingleObject(M_GetMainApp()->m_hDrawSem,10000) == WAIT_TIMEOUT)
ASSERT(0);
CWnd::OnDestroy();
// Destroy the DisplayViewport.
// fn_bDeleteViewport3D(mDisplayDevice3D, mViewPort.GetDisplayViewport3D());
GLD_bReleaseViewportAndDevice(m_hDisplayDevice,mpViewPort->m_hDisplayViewport);
mpViewPort->SendMessage(WM_DESTROY);
delete(mpViewPort);
ReleaseSemaphore(M_GetMainApp()->m_hDrawSem, 1, NULL);
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
void DEV_Device::OnSize(UINT type, int cx, int cy)
{
RECT r;
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
{
if (!IsFreezed())
{
CWnd::OnSize(type, cx, cy);
if (!IsFullScreen())
{
if (!GLD_bAdjustDeviceToWindow(m_hDisplayDevice))
{
ASSERT(0);
}
}
// Adjust the camera to the new size of the viewport (device)
if((mViewType == C_DEVICE3D) && (((DEV_ViewPort3D *) mpViewPort)->GetEngineCamera()))
GLI_xAdjustCameraToViewport
(
m_hDisplayDevice, mpViewPort->m_hDisplayViewport,
((DEV_ViewPort3D *) mpViewPort)->GetEngineCamera()
);
GAMITF_fn_vResizeGameViewport();
CWnd::GetClientRect(&r);
mpViewPort->SetWindowPos(&wndTopMost,r.left,r.top,r.right,r.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
}
}
}
//================================================================================
// When device gains the focus, it must say it to the contact (and so to one or
// more editor) to update viewport modes.
//================================================================================
BOOL DEV_Device::OnNcActivate(BOOL)
{
OnNcPaint();
return FALSE;
}
//================================================================================
//================================================================================
int DEV_Device::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
int iRes = CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
return iRes;
}
#ifndef ACTIVE_EDITOR
void DEV_Device::PostCreate()
{
GLD_tdstDeviceAttributes stDeviceAttr;
// Create the DisplayDevice.
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
//VL0
//stDeviceAttr.bFullScreen = TRUE;
//mbFullScreen = TRUE;
stDeviceAttr.bFullScreen = mbFullScreen = MAIN_fn_ulDeviceIsFullScreen();
//EVL0
stDeviceAttr.dwFullScreenModeX = MAIN_fn_ulGetDeviceWidth();
stDeviceAttr.dwFullScreenModeY = MAIN_fn_ulGetDeviceHeight();
stDeviceAttr.dwFullScreenModeBpp = 16;
stDeviceAttr.hFullScreenModeWnd = M_GetMainWnd()->GetSafeHwnd();
stDeviceAttr.hNormalModeWnd = CWnd::GetSafeHwnd();
stDeviceAttr.uiTypeDriver = C_DRIVER_SOFT | C_DRIVER_RGB; // marc : moteur D3D
if (!GLD_bCreateDevice(&stDeviceAttr, &m_hDisplayDevice))
{
ASSERT(0);
// M_GetMainApp()->fn_vDynaFatalError(GLD_szGetLastErrorString());
}
// Create the Viewport.
/* if (mViewType == C_DEVICE3D)
{
*/ mpViewPort = new(DEV_ViewPort3D);
((DEV_ViewPort3D *)mpViewPort)->CreateViewPort(this, m_hDisplayDevice);
/* }
else
{
mpViewPort = new(DEV_ViewPort2D);
((DEV_ViewPort2D *)mpViewPort)->CreateViewPort(this, m_hDisplayDevice);
}
*/ SetBackgroundColor(0, 0, 0);
// M_GetMainWnd->OnActivateApp(TRUE,NULL);
}
}
#endif
//================================================================================
//================================================================================
int DEV_Device::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
GLD_tdstDeviceAttributes stDeviceAttr;
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// Create the DisplayDevice.
//VL0
//stDeviceAttr.bFullScreen = FALSE;
//mbFullScreen = FALSE;
stDeviceAttr.bFullScreen = mbFullScreen = MAIN_fn_ulDeviceIsFullScreen();
//EVL
stDeviceAttr.dwFullScreenModeX = MAIN_fn_ulGetDeviceWidth();
stDeviceAttr.dwFullScreenModeY = MAIN_fn_ulGetDeviceHeight();
stDeviceAttr.dwFullScreenModeBpp = 16;
stDeviceAttr.hFullScreenModeWnd = M_GetMainWnd()->GetSafeHwnd();
stDeviceAttr.hNormalModeWnd = CWnd::GetSafeHwnd();
stDeviceAttr.uiTypeDriver = C_DRIVER_SOFT | C_DRIVER_RGB; // marc : moteur D3D
if (!GLD_bCreateDevice(&stDeviceAttr, &m_hDisplayDevice))
{
ASSERT(0);
// M_GetMainApp()->fn_vDynaFatalError(GLD_szGetLastErrorString());
}
// Create the Viewport.
/* if (mViewType == C_DEVICE3D)
{
*/ mpViewPort = new(DEV_ViewPort3D);
((DEV_ViewPort3D *)mpViewPort)->CreateViewPort(this, m_hDisplayDevice);
/* }
else
{
mpViewPort = new(DEV_ViewPort2D);
((DEV_ViewPort2D *)mpViewPort)->CreateViewPort(this, m_hDisplayDevice);
}
*/ Unfreeze();
SetBackgroundColor(0, 0, 0);
}
else
{
return CWnd::OnCreate(lpCreateStruct);
}
return 0;
}
//================================================================================
//================================================================================
void DEV_Device::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
CWnd::OnWindowPosChanging(lpwndpos);
if(mType == DEV_BACKGROUND)
{
lpwndpos->flags |= SWP_NOZORDER | SWP_NOMOVE;
}
}
//================================================================================
//================================================================================
void DEV_Device::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
{
RECT r;
CWnd::OnWindowPosChanged(lpwndpos);
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
{
GetClientRect(&r);
mpViewPort->SetWindowPos(&wndTopMost,r.left,r.top,r.right-r.left,r.bottom-r.top,0);
}
}
//================================================================================
//================================================================================
void DEV_Device::SetBackgroundColor(COLORREF Color)
{
mRed = GetRValue(Color);
mGreen = GetGValue(Color);
mBlue = GetBValue(Color);
GLD_bSetBackgroundColorForDevice(m_hDisplayDevice, Color);
CWnd::SendMessage(WM_PAINT);
}
//================================================================================
//================================================================================
void DEV_Device::SetBackgroundColor(char Red, char Green, char Blue)
{
mRed = Red;
mGreen = Green;
mBlue = Blue;
SetBackgroundColor(RGB(Red, Green, Blue));
}
//================================================================================
//================================================================================
void DEV_Device::GetBackgroundColor(char *Red, char *Green, char *Blue)
{
*Red = mRed;
*Green = mGreen;
*Blue = mBlue;
}
//================================================================================
//================================================================================
void DEV_Device::OnPaint()
{
CWnd::OnPaint();
}
//================================================================================
//================================================================================
BOOL DEV_Device::SwapFullScreen(BOOL)
{
/*
if (GLI_lWhatIsGLI() != GLI_C_VersionGlide)
{
if (!IsFullScreen())
{
//save the new pos for when we come back from fullscreen
M_GetMainWnd()->GetWindowRect(m_stRectWhileFullscreen);
}
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
M_GetMainApp()->m_bFlagTaken = TRUE;
GAMITF_fn_vResizeGameViewport();
if (!mbFullScreen)
{
if (!GLD_bSwapDeviceMode(m_hDisplayDevice))
{
ASSERT(0);
return FALSE;
}
mbFullScreen = TRUE;
}
else
{
mbFullScreen = FALSE;
}
//--------------------------------------------------------
M_GetMainApp()->m_bFlagTaken = FALSE;
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
#ifdef NDEBUG
if (mbFullScreen == TRUE)
{
RECT stRect,stRect2;
M_GetMainWnd()->GetWindowRect(&stRect2);
stRect.left = stRect2.left + 10;
stRect.top = stRect2.top + 10;
stRect.right = stRect2.left + 10;
stRect.bottom = stRect2.top + 10;
// we are in fullscreen
// confine cursor in the window
ClipCursor(&stRect);
// hide cursor
while (ShowCursor(FALSE) >= 0);
}
else
{
// we are not in fullscreen
// free cursor
ClipCursor(NULL);
// show cursor
while (ShowCursor(TRUE) < 0);
}
#endif
return TRUE;
}
else
*/
{
if (!IsFullScreen())
{
//save the new pos for when we come back from fullscreen
M_GetMainWnd()->GetWindowRect(m_stRectWhileFullscreen);
//M_GetMainWnd()->ShowWindow(FALSE);
}
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
WaitForSingleObject(M_GetMainApp()->m_hDrawSem, INFINITE);
M_GetMainApp()->m_bFlagTaken = TRUE;
//--------------------------------------------------------
// Freeze all devices
GetParentMultiDevice()->FreezeAll();
if (!GLD_bSetFullScreenModeForDevice(m_hDisplayDevice, MAIN_fn_ulGetDeviceWidth(),MAIN_fn_ulGetDeviceHeight() , 16, M_GetMainWnd()->GetSafeHwnd()))
{
ASSERT(0);
}
if (!GLD_bSwapDeviceMode(m_hDisplayDevice, TRUE))
{
ASSERT(0);
}
if(((DEV_ViewPort3D *) mpViewPort)->GetEngineCamera())
GLI_xAdjustCameraToViewport(m_hDisplayDevice, mpViewPort->m_hDisplayViewport, ((DEV_ViewPort3D *) mpViewPort)->GetEngineCamera());
GAMITF_fn_vResizeGameViewport();
if (!mbFullScreen)
{
mbFullScreen = TRUE;
GetParentMultiDevice()->FreezeAllButOne(0);
}
else
{
mbFullScreen = FALSE;
GetParentMultiDevice()->UnfreezeAll();
}
//--------------------------------------------------------
M_GetMainApp()->m_bFlagTaken = FALSE;
ReleaseSemaphore(M_GetMainApp()->m_hDrawSem, 1, NULL);
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
//M_GetMainWnd()->ShowWindow(TRUE);
#ifdef NDEBUG
if (mbFullScreen == TRUE)
{
RECT stRect,stRect2;
M_GetMainWnd()->GetWindowRect(&stRect2);
stRect.left = stRect2.left + 10;
stRect.top = stRect2.top + 10;
stRect.right = stRect2.left + 10;
stRect.bottom = stRect2.top + 10;
// we are in fullscreen
// confine cursor in the window
ClipCursor(&stRect);
// hide cursor
while (ShowCursor(FALSE) >= 0);
}
else
{
// we are in fullscreen
// confine cursor in the window
ClipCursor(NULL);
// show cursor
while (ShowCursor(TRUE) < 0);
}
#endif
}
return TRUE;
}
//================================================================================
//================================================================================

View File

@@ -0,0 +1,443 @@
/*=========================================================================
* DEVMul3D.cpp : Implementation of Multidevice 3D.
* This is a part of the PCA project.
*
* Version 1.0
* Creation date 17/07/96
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#include "acp_base.h"
#include "geo.h"
#include "gli.h"
#include "itf/CPARes.h"
#include "itf/DEVMul3D.hpp"
#include "itf/CPAProj.hpp"
#include "itf/CPAConst.hpp"
#include "itf/CPAkacnf.hpp"
#include "itf/cpaworld.hpp"
#include "itf/cpasobj.hpp"
#include "itf/CPAInter.hpp"
IMPLEMENT_DYNCREATE(DEV_MultiDevice3D, DEV_MultiDevice)
BEGIN_MESSAGE_MAP(DEV_MultiDevice3D, DEV_MultiDevice)
//{{AFX_MSG_MAP(DEV_MultiDevice3D)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//==========================================================================
DEV_MultiDevice3D::DEV_MultiDevice3D()
{
DEV_MultiDevice3D::Init();
}
DEV_MultiDevice3D::DEV_MultiDevice3D(int flags) :
DEV_MultiDevice(flags)
{
DEV_MultiDevice3D::Init();
}
DEV_MultiDevice3D::~DEV_MultiDevice3D()
{
}
void DEV_MultiDevice3D::Init(void)
{
#ifdef ACTIVE_EDITOR
m_p_oWorld = NULL;
#endif // ACTIVE_EDITOR
m_hSuperObjectWorld = NULL;
DEV_MultiDevice::Init();
}
//==========================================================================
int DEV_MultiDevice3D::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (DEV_MultiDevice::OnCreate(lpCreateStruct) == -1)
return -1;
//
// Init light.
//
GLI_xCreateLight(&m_hLight , GLI_C_lParallelLight);
#ifdef ACTIVE_EDITOR
m_p_oParent = GetParent();
#endif // ACTIVE_EDITOR
return 0;
}
#ifdef ACTIVE_EDITOR
//===========================================================================
// Description: Set the Rotation Unit.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
/*void DEV_MultiDevice3D::SetRotateUnitIndex(int iIndex, int iMul)
{
mxRotateUnit = GLI_M_Mul(C_DefaultRotateUnit, iMul);
miRotateUnitIndex = iIndex;
}
*/
//===========================================================================
// Description: Set the Translation Unit.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
/*void DEV_MultiDevice3D::SetTranslateUnitIndex(int iIndex, int iMul)
{
mxTranslateUnit = GLI_M_Mul(C_DefaultTranslateUnit, iMul);
miTranslateUnitIndex = iIndex;
}
*/
//===========================================================================
// Description: Sets a new world in the multidevice.
// this world will be the new current world
// Creation date: 25/09/96
// Author: FBF
//---------------------------------------------------------------------------
// Revision date:
// Author: FBF
//===========================================================================
void DEV_MultiDevice3D::SetWorld(CPA_World *p_oWorld)
{
if (m_cIsAdditional == 0)
{
// if there was allready a world, remove it
if (m_p_oWorld)
m_p_oWorld->SetMultiDevice(NULL);
SetEngineWorld(NULL);
m_p_oWorld = p_oWorld;
if (m_p_oWorld)
{
m_p_oWorld->SetMultiDevice(this);
if (m_p_oWorld->GetRoot())
SetEngineWorld(p_oWorld->GetRoot()->GetStruct());
}
if (GetInterface())
GetInterface()->fn_vChangeWorld();
}
else
{
GetPane_0_0()->SetWorld(p_oWorld);
}
}
CPA_World *DEV_MultiDevice3D::GetWorld()
{
if (m_cIsAdditional == 0)
return m_p_oWorld;
else
return GetPane_0_0()->GetWorld();
}
GLI_tdxHandleToLight DEV_MultiDevice3D::GetEngineLight()
{
if (m_cIsAdditional == 0)
return m_hLight;
else
return GetPane_0_0()->GetEngineLight();
}
HIE_tdxHandleToSuperObject DEV_MultiDevice3D::GetEngineWorld()
{
if (m_cIsAdditional == 0)
return m_hSuperObjectWorld;
else
return GetPane_0_0()->GetEngineWorld();
}
#endif
void DEV_MultiDevice3D::SetEngineWorld(HIE_tdxHandleToSuperObject hObj)
{
#ifdef ACTIVE_EDITOR
if (m_cIsAdditional == 0)
m_hSuperObjectWorld = hObj;
else
GetPane_0_0()->SetEngineWorld(hObj);
#else
m_hSuperObjectWorld = hObj;
#endif
}
#ifdef ACTIVE_EDITOR
//===========================================================================
// Description: Draw the World which is set by the function SetObject.
// Call the DrawObject function of all his device.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author: CB
//===========================================================================
void DEV_MultiDevice3D::DrawObject(void)
{
if (!IsActive())
return;
if (M_bEditorsActive())
{
DrawEditorObject();
return;
}
UINT i;
{
for (i = 0; i < MAX_DEVICE; i++)
{
if
(
(IsActivDevice(i))
&&
(
(GetDevice(i)->mbGameRefresh)
|| (M_bEditorsActive())
|| (mbForceDrawing)
)
)
{
#ifndef TEST_CPA_VERSION_3D
if(M_bEditorsActive() || i || (this != M_GetMainDevice()))
#endif // TEST_CPA_VERSION_3D
{
if(m_hSuperObjectWorld)
GetDevice(i)->DrawObject(m_hLight, m_hSuperObjectWorld);
else
GLD_bFlipDevice(GetDevice(i)->m_hDisplayDevice);
}
}
}
}
if
(
(m_p_oParent)
&& (m_p_oMultiToDraw == NULL)
&& (m_p_oParent->IsKindOf(RUNTIME_CLASS(FRMSplitter)))
&& (!mbForceDrawing)
)
{
m_p_oMultiToDraw = this;
((FRMSplitter *) m_p_oParent)->DrawObject(this);
m_p_oMultiToDraw = NULL;
}
mbForceDrawing = FALSE;
}
//===========================================================================
// Description: Draw the World which is set by the function SetObject.
// Call the DrawObject function of all his device.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author: CB
//===========================================================================
void DEV_MultiDevice3D::DrawEditorObject(void)
{
UINT i;
for (i = 0; i < MAX_DEVICE; i++)
{
if(IsActivDevice(i))
{
if (GetWorld())
GetDevice(i)->DrawEditorObject(m_hLight, GetWorld()->GetRoot());
else
GLD_bFlipDevice(GetDevice(i)->m_hDisplayDevice);
}
}
if
(
(m_p_oParent)
&& (m_p_oMultiToDraw == NULL)
&& (m_p_oParent->IsKindOf(RUNTIME_CLASS(FRMSplitter)))
)
{
m_p_oMultiToDraw = this;
((FRMSplitter *) m_p_oParent)->DrawObject(this);
m_p_oMultiToDraw = NULL;
}
mbForceDrawing = FALSE;
}
void DEV_MultiDevice3D::DrawObjectExcept0()
{
UINT i;
for (i = 1; i < MAX_DEVICE; i++)
{
if
(
(IsActivDevice(i))
&& (
(GetDevice(i)->mbGameRefresh)
|| (M_bEditorsActive())
|| (mbForceDrawing)
)
)
{
if(m_hSuperObjectWorld)
GetDevice(i)->DrawObject(m_hLight, m_hSuperObjectWorld);
else
GLD_bFlipDevice(GetDevice(i)->m_hDisplayDevice);
}
}
if
(
(m_p_oParent)
&& (m_p_oMultiToDraw == NULL)
&& (m_p_oParent->IsKindOf(RUNTIME_CLASS(FRMSplitter)))
&& (!mbForceDrawing)
)
{
m_p_oMultiToDraw = this;
((FRMSplitter *) m_p_oParent)->DrawObject(this);
m_p_oMultiToDraw = NULL;
}
mbForceDrawing = FALSE;
}
#endif // ACTIVE_EDITOR
//==========================================================================
//
// TO TEST ACP VERSION
//
//==========================================================================
#if defined(ACTIVE_EDITOR)
void fn_vRotateX ( POS_tdstCompletePosition *p_stMatrix ,
GLI_tdxValue xXAngle )
{
MTH3D_tdstVector stVectI,stVectJ,stVectK;
POS_fn_vGetRotationMatrix(p_stMatrix,&stVectI,&stVectJ,&stVectK);
MTH3D_M_vSetYofVector(&stVectJ,GLI_M_Cos(xXAngle)) ;
MTH3D_M_vSetZofVector(&stVectJ,GLI_M_Sin(xXAngle)) ;
MTH3D_M_vSetYofVector(&stVectK,GLI_M_Neg(GLI_M_Sin(xXAngle))) ;
MTH3D_M_vSetZofVector(&stVectK,GLI_M_Cos(xXAngle)) ;
POS_fn_vSetRotationMatrix(p_stMatrix,&stVectI,&stVectJ,&stVectK);
}
void fn_vRotateY ( POS_tdstCompletePosition *p_stMatrix ,
GLI_tdxValue xYAngle )
{
MTH3D_tdstVector stVectI,stVectJ,stVectK;
POS_fn_vGetRotationMatrix(p_stMatrix,&stVectI,&stVectJ,&stVectK);
MTH3D_M_vSetXofVector(&stVectI,GLI_M_Cos(xYAngle)) ;
MTH3D_M_vSetZofVector(&stVectI,GLI_M_Sin(xYAngle)) ;
MTH3D_M_vSetXofVector(&stVectK,GLI_M_Neg(GLI_M_Sin(xYAngle))) ;
MTH3D_M_vSetZofVector(&stVectK,GLI_M_Cos(xYAngle)) ;
POS_fn_vSetRotationMatrix(p_stMatrix,&stVectI,&stVectJ,&stVectK);
}
void fn_vRotateZ ( POS_tdstCompletePosition *p_stMatrix ,
GLI_tdxValue xZAngle )
{
MTH3D_tdstVector stVectI,stVectJ,stVectK;
POS_fn_vGetRotationMatrix(p_stMatrix,&stVectI,&stVectJ,&stVectK);
MTH3D_M_vSetXofVector(&stVectI,GLI_M_Cos(xZAngle));
MTH3D_M_vSetYofVector(&stVectI,GLI_M_Sin(xZAngle));
MTH3D_M_vSetXofVector(&stVectJ,GLI_M_Neg(GLI_M_Sin(xZAngle)));
MTH3D_M_vSetYofVector(&stVectJ,GLI_M_Cos(xZAngle));
POS_fn_vSetRotationMatrix(p_stMatrix,&stVectI,&stVectJ,&stVectK);
}
void DEV_MultiDevice3D::RotateObjectX()
{
POS_tdstCompletePosition p_stMatrix;
GLI_tdxValue xXAngle;
POS_fn_vSetIdentityMatrix(&p_stMatrix);
if (m_hSuperObjectWorld != NULL)
{
xXAngle = (GLI_tdxValue)0.1;
POS_fn_vSetIdentityMatrix(&p_stMatrix);
fn_vRotateX(&p_stMatrix, xXAngle);
POS_fn_vMulMatrixMatrix(HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld),
HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld),
&p_stMatrix);
POS_fn_vNormalizeMatrix(HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld));
}
}
void DEV_MultiDevice3D::RotateObjectY()
{
POS_tdstCompletePosition p_stMatrix;
GLI_tdxValue xYAngle;
POS_fn_vSetIdentityMatrix(&p_stMatrix);
if (m_hSuperObjectWorld != NULL)
{
xYAngle = (GLI_tdxValue)0.1;
POS_fn_vSetIdentityMatrix(&p_stMatrix);
fn_vRotateY(&p_stMatrix, xYAngle);
POS_fn_vMulMatrixMatrix(HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld),
HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld),
&p_stMatrix);
POS_fn_vNormalizeMatrix(HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld));
}
}
void DEV_MultiDevice3D::RotateObjectZ()
{
POS_tdstCompletePosition p_stMatrix;
GLI_tdxValue xZAngle;
POS_fn_vSetIdentityMatrix(&p_stMatrix);
if (m_hSuperObjectWorld != NULL)
{
xZAngle = (GLI_tdxValue)0.1;
POS_fn_vSetIdentityMatrix(&p_stMatrix);
fn_vRotateZ(&p_stMatrix, xZAngle);
POS_fn_vMulMatrixMatrix(HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld),
HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld),
&p_stMatrix);
POS_fn_vNormalizeMatrix(HIE_fn_hGetSuperObjectMatrix(m_hSuperObjectWorld));
}
}
void DEV_MultiDevice3D::RotateWorldX()
{
RotateObjectX();
}
void DEV_MultiDevice3D::RotateWorldY()
{
RotateObjectY();
}
void DEV_MultiDevice3D::RotateWorldZ()
{
RotateObjectZ();
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,986 @@
/*=========================================================================
* DEVMulti.cpp : Implementation of Multidevice.
* This is a part of the PCA project.
*
* Version 1.0
* Creation date 26/06/96
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#include "acp_base.h"
#include "geo.h"
#include "gli.h"
#include "itf/CPARes.h"
#include "itf/DEVMulti.hpp"
#include "itf/CPACont.hpp"
#include "itf/FRMBsMn.hpp"
#include "itf/CPAProj.hpp"
#include "itf/stddllid.h"
#include "itf/camdllb.hpp"
#include "itf/cpainter.hpp"
#include "itf/DevMul3D.hpp"
#include "itf/CPAMWorl.hpp"
//------------------------------------------------------------------
// Array of all the button-id possible for the Device ToolBar.
#ifdef ACTIVE_EDITOR
UINT pButtonsDevice[] =
{
CPA_IDB_OPENDEVICE,
CPA_IDB_DEVICE_TILE_HORZ,
CPA_IDB_DEVICE_TILE_VERT,
CPA_IDB_DEVICE_CASCADE,
};
#define nbButtonsDevice 4
//------------------------------------------------------------------
#endif // ACTIVE_EDITOR
IMPLEMENT_DYNCREATE(DEV_MultiDevice, CView)
BEGIN_MESSAGE_MAP(DEV_MultiDevice, CView)
//{{AFX_MSG_MAP(DEV_MultiDevice)
ON_WM_WINDOWPOSCHANGED()
ON_WM_CREATE()
ON_WM_DESTROY()
#ifdef ACTIVE_EDITOR
ON_MESSAGE(CPA_MSG_DRAWOBJECT, OnDrawObject)
ON_MESSAGE(CPA_MSG_DRAWOBJECTEXCEPT0, OnDrawObjectExcept0)
#endif // ACTIVE_EDITOR
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//--------------------------------------------------------------------------------
DEV_MultiDevice::DEV_MultiDevice()
{
mFlags = 0;
#ifdef ACTIVE_EDITOR
m_p_oContact = NULL;
m_p_oInterface = NULL;
m_p_oParent = NULL;
m_bActive = FALSE;
#endif // ACTIVE_EDITOR
}
DEV_MultiDevice::DEV_MultiDevice(int flags)
{
mFlags = (short) flags;
#ifdef ACTIVE_EDITOR
m_p_oContact = NULL;
m_p_oInterface = NULL;
m_p_oEditManager = NULL;
m_bActive = FALSE;
#endif // ACTIVE_EDITOR
}
DEV_MultiDevice::~DEV_MultiDevice()
{
#ifdef ACTIVE_EDITOR
if(m_cIsAdditional == 0)
{
delete m_p_oContact;
delete m_p_oEditManager;
}
m_p_oContact = NULL;
#endif // ACTIVE_EDITOR
}
void DEV_MultiDevice::Init()
{
#ifdef ACTIVE_EDITOR
int i;
for (i = 0; i < MAX_DEVICE; i++)
SetActivDevice(i,FALSE); // Definition of default active device
m_lFocusDevice = -1; // To signal that there no active device
m_lFocusPane = 0;
m_p_oContact = NULL; // No contact
m_p_oMultiToDraw = NULL;
m_cIsAdditional = 0;
m_p_oEditManager = new CPA_EditManager;
// register new multidevice
M_GetListOfAllDLL()->RegisterNewMultiDevice(this);
#else
mActivDeviceAlone = FALSE;
#endif // ACTIVE_EDITOR
mbOnDestroy = FALSE;
}
DEV_Device* DEV_MultiDevice::OpenNewDevice(int _iLeft, int _iTop, int _iWidth, int _iHeight)
{
DEV_Device *p_oResult = NULL;
#ifdef ACTIVE_EDITOR
if(!TestFlags(MD_ONEDEVICE))
{
long lNum;
lNum = GetNextNumDevice();
if (SetDevice(&mDevice[lNum], lNum))
{
// update pos & size
if( _iLeft <0 ) _iLeft = 10+lNum*20;
if( _iTop <0 ) _iTop = 30+lNum*20;
if( _iWidth <0 ) _iWidth = 300;
if( _iHeight <0 ) _iHeight = 200;
// create device
if (TestFlags(MD_VIEW2D))
GetDevice(lNum)->CreateDevice(this, _iLeft, _iTop, _iWidth, _iHeight, C_DEVICE2D);
else
GetDevice(lNum)->CreateDevice(this, _iLeft, _iTop, _iWidth, _iHeight, C_DEVICE3D);
p_oResult = GetDevice(lNum);
}
}
#endif // ACTIVE_EDITOR
return p_oResult;
}
void DEV_MultiDevice::CloseAllDevices()
{
#ifdef ACTIVE_EDITOR
OnCloseAllDevice();
#endif // ACTIVE_EDITOR
}
#ifdef ACTIVE_EDITOR
void DEV_MultiDevice::SetContact(CPA_Contact *p_oContact)
{
// if it's the main multidevice, ok
if (m_cIsAdditional == 0)
{
if (m_p_oContact != NULL)
m_p_oContact->SetDevice(NULL);
m_p_oContact = p_oContact;
if (p_oContact != NULL)
p_oContact->SetDevice(this);
}
// else, set the main multidevice interface
else
GetPane_0_0()->SetContact(p_oContact);
}
void DEV_MultiDevice::SetInterface(CPA_Interface *p_oInterface)
{
// if it's the main multidevice, ok
if (m_cIsAdditional == 0)
m_p_oInterface = p_oInterface;
// else, set the main multidevice interface
else
GetPane_0_0()->SetInterface(p_oInterface);
}
void DEV_MultiDevice::SetEditManager(CPA_EditManager *p_oMng)
{
// if it's the main multidevice, ok
if (m_cIsAdditional == 0)
m_p_oEditManager = p_oMng;
// else, set the main multidevice interface
else
GetPane_0_0()->SetEditManager(p_oMng);
}
void DEV_MultiDevice::SetFocusPane(long lPane)
{
// if it's the main multidevice, ok
if (m_cIsAdditional == 0)
m_lFocusPane = lPane;
// else, set the main multidevice interface
else
GetPane_0_0()->SetFocusPane(lPane);
}
CPA_Interface *DEV_MultiDevice::GetInterface()
{
// if it's the main multidevice, ok
if (m_cIsAdditional == 0)
return m_p_oInterface;
// else, return the main multidevice interface
return GetPane_0_0()->GetInterface();
}
CPA_Contact *DEV_MultiDevice::GetContact()
{
// if it's the main multidevice, ok
if (m_cIsAdditional == 0)
return m_p_oContact;
// else, return the main multidevice interface
return GetPane_0_0()->GetContact();
}
CPA_EditManager *DEV_MultiDevice::GetEditManager()
{
// if it's the main multidevice, ok
if (m_cIsAdditional == 0)
return m_p_oEditManager;
// else, return the main multidevice interface
return GetPane_0_0()->GetEditManager();
}
DEV_MultiDevice3D *DEV_MultiDevice::GetPane_0_0()
{
DEV_MultiDevice3D *p_oResult;
ASSERT(m_cIsAdditional != 0);
p_oResult = (DEV_MultiDevice3D *) ( ((FRMSplitter*)GetParent())->GetPane(0, 0));
return p_oResult;
}
#endif // ACTIVE_EDITOR
//--------------------------------------------------------------------------------
BOOL DEV_MultiDevice::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= WS_CLIPCHILDREN;
return CView::PreCreateWindow(cs);
}
//--------------------------------------------------------------------------------
void DEV_MultiDevice::OnDraw(CDC*)
{
}
//--------------------------------------------------------------------------------
// GET-FUNCTIONS
//--------------------------------------------------------------------------------
//===========================================================================
// Description: Return the device number num.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
DEV_Device* DEV_MultiDevice::GetDevice(int num)
{
#ifdef ACTIVE_EDITOR
return mpDevice[num];
#else
return &mDeviceAlone;
#endif // ACTIVE_EDITOR
}
//===========================================================================
// Description: Return the device which the have the focus.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
DEV_Device* DEV_MultiDevice::GetFocusDevice2()
{
#ifdef ACTIVE_EDITOR
if(m_lFocusDevice == -1)
return NULL;
else
return mpDevice[m_lFocusDevice];
#else
return &mDeviceAlone;
#endif // ACTIVE_EDITOR
}
//===========================================================================
// Description: Return the multidevice (in the splitter) which have the focus.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
DEV_Device* DEV_MultiDevice::GetFocusDevice()
{
#ifdef ACTIVE_EDITOR
if (m_cIsAdditional == 0)
{
if (m_lFocusPane == 0)
return GetFocusDevice2();
else if (m_lFocusPane == 1)
return ((DEV_MultiDevice *) ( ((FRMSplitter*)GetParent())->GetPane(0, 1)))->GetFocusDevice2();
else if (m_lFocusPane == 2)
return ((DEV_MultiDevice *) ( ((FRMSplitter*)GetParent())->GetPane(1, 0)))->GetFocusDevice2();
else if (m_lFocusPane == 3)
return ((DEV_MultiDevice *) ( ((FRMSplitter*)GetParent())->GetPane(1, 1)))->GetFocusDevice2();
else return NULL;
}
else
return GetPane_0_0()->GetFocusDevice();
#else
return GetFocusDevice2();
#endif
}
#ifdef ACTIVE_EDITOR
//===========================================================================
// Description: Return the number of first disactivate device.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
UINT DEV_MultiDevice::GetNextNumDevice()
{
UINT i = 0;
// Find first Device not active.
while ((i < MAX_DEVICE) && IsActivDevice(i)) i++;
return i;
}
#endif // ACTIVE_EDITOR
//--------------------------------------------------------------------------------
// SET-FUNCTIONS
//--------------------------------------------------------------------------------
//===========================================================================
// Description: Set the background color of all devices of the MultiDevice
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::SetBackgroundColor(COLORREF Color)
{
#ifdef ACTIVE_EDITOR
UINT i;
for (i = 0; i < MAX_DEVICE; i++)
if (IsActivDevice(i))
GetDevice(i)->SetBackgroundColor(Color);
#else
if (mActivDeviceAlone)
mDeviceAlone.SetBackgroundColor(Color);
#endif // ACTIVE_EDITOR
}
//===========================================================================
// Description: Set the background color of all devices of the MultiDevice
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::SetBackgroundColor(char Red, char Green, char Blue)
{
#ifdef ACTIVE_EDITOR
UINT i;
for (i = 0; i < MAX_DEVICE; i++)
if (IsActivDevice(i))
GetDevice(i)->SetBackgroundColor(Red,Green,Blue);
#else
if (mActivDeviceAlone)
mDeviceAlone.SetBackgroundColor(Red,Green,Blue);
#endif // ACTIVE_EDITOR
}
//===========================================================================
// Description: Get the background color of the active Device
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::GetBackgroundColor(char *Red, char *Green, char *Blue)
{
#ifdef ACTIVE_EDITOR
GetFocusDevice()->GetBackgroundColor(Red,Green,Blue);
#else
if (mActivDeviceAlone)
mDeviceAlone.GetBackgroundColor(Red,Green,Blue);
#endif // ACTIVE_EDITOR
}
#ifdef ACTIVE_EDITOR
//===========================================================================
// Description: Set the Device of number num by the value pDevice.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
BOOL DEV_MultiDevice::SetDevice(DEV_Device *pDevice, UINT num)
{
if (num == MAX_DEVICE)
{
MessageBox("No more Device");
return FALSE;
}
mpDevice[num] = pDevice;
mpDevice[num]->SetNumber(num);
return TRUE;
}
//===========================================================================
// Description: Set the focus to the device number num.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::UpdateColorTitle(void)
{
UINT i;
for(i = 0; i < MAX_DEVICE; i++)
if(IsActivDevice(i))
GetDevice(i)->DrawDeviceTitle();
}
void DEV_MultiDevice::SetFocusDevice(int num)
{
long lLast = m_lFocusDevice;
DEV_MultiDevice3D *pSingle;
FRMSplitter *pSplit;
if((num != -1) && (!mbOnDestroy))
{
((FRMSplitter *) GetParent())->SetActivePane(0, 0, this);
m_lFocusDevice = num;
GetDevice(num)->SetWindowPos(&wndTop,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
//GetDevice(num)->GetParentFrame()->MoveWindow(10,10,500,690,TRUE);
//GetDevice(num)->MoveWindow(10,10,500,690,TRUE);
// GetDevice(num)->SetWindowPos(&wndTop,0,0,500,500,0); //chbani
GetDevice(num)->GetViewPort()->SetFocus();
}
// refresh if we are ine fullscreen editor
if ( (num != -1) && !M_bFullScreenEditor())
{
// No refresh if we are in full screen
if(((DEV_MultiDevice3D *)M_GetMainWnd()->m_oSplitter.GetPane(0, 0))->GetFocusDevice()->IsFullScreen())
return;
}
// Refresh the titles
UpdateColorTitle();
if ( (num != -1) && (GetParent()->IsKindOf(RUNTIME_CLASS(FRMSplitter))) )
{
// Update color title of all devices of all splitter panes.
pSplit = (FRMSplitter *) GetParent();
pSingle = (DEV_MultiDevice3D *) pSplit->GetPane(0, 0);
if(pSingle != this)
pSingle->UpdateColorTitle();
else
SetFocusPane(0);
if(pSplit->GetColumnCount() == 2)
{
pSingle = (DEV_MultiDevice3D *) pSplit->GetPane(0, 1);
if(pSingle != this)
pSingle->UpdateColorTitle();
else
SetFocusPane(1);
}
if(pSplit->GetRowCount() == 2)
{
pSingle = (DEV_MultiDevice3D *) pSplit->GetPane(1, 0);
if(pSingle != this)
pSingle->UpdateColorTitle();
else
SetFocusPane(2);
if(pSplit->GetColumnCount() == 2)
{
pSingle = (DEV_MultiDevice3D *) pSplit->GetPane(1, 1);
if(pSingle != this)
pSingle->UpdateColorTitle();
else
SetFocusPane(3);
}
}
}
if (!M_GetMainApp()->m_bLeavingApplication)
{
//VL
//GetParentFrame()->mfn_vUpdateDeviceToolBar();
if (GetParent()->IsKindOf( RUNTIME_CLASS( FRMSplitter ) ))
{
GetParentFrame()->mfn_vUpdateDeviceToolBar();
}
//EVL
}
}
#endif // ACTIVE_EDITOR
//--------------------------------------------------------------------------------
// TEST-FUNCTIONS
//--------------------------------------------------------------------------------
#ifdef ACTIVE_EDITOR
//===========================================================================
// Description: Is pDevice is a pointer on a Device of the MultiDevice ?
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
BOOL DEV_MultiDevice::IsDevice(DEV_Device *pDevice)
{
int i;
for (i = 0; i < MAX_DEVICE; i++)
if (IsActivDevice(i) && (pDevice == GetDevice(i)))
return TRUE;
return FALSE;
}
#endif // ACTIVE_EDITOR
//--------------------------------------------------------------------------------
// ACTION-FUNCTIONS
//--------------------------------------------------------------------------------
//===========================================================================
// Description: Open the Background Device. This is the first Device of
// MultiDevice, and he always has the number 0. This Device
// is created by default.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::OnOpenDeviceBackground()
{
#ifdef ACTIVE_EDITOR
if (SetDevice(&mDevice[0], 0))
{
if (TestFlags(MD_VIEW2D))
GetDevice(0)->CreateDeviceBackground(this, C_DEVICE2D);
else
GetDevice(0)->CreateDeviceBackground(this, C_DEVICE3D);
// if this is not the game multidevice, create a default camera
/* if (M_GetMainWnd())
{
if (M_GetMainDevice() != this)
{
CPA_CameraDLLBase *p_oCamDLL = NULL;
CPA_Object *p_oCamera = NULL;
// we are not in the game device
// so, create a camera for this device
p_oCamDLL = (CPA_CameraDLLBase*) M_GetMainApp()->m_p_oMainWorld->GetObjectDLLWithName(C_szDLLCameraName);
ASSERT(p_oCamDLL != NULL);
p_oCamera = p_oCamDLL->CreateDefaultCamera();
ASSERT(p_oCamera != NULL);
((DEV_ViewPort3D*)GetDevice(0)->GetViewPort())->ChangeCamera(p_oCamera);
}
}
*/ }
#else
if (TestFlags(MD_VIEW2D))
mDeviceAlone.CreateDeviceBackground(this, C_DEVICE2D);
else
mDeviceAlone.CreateDeviceBackground(this, C_DEVICE3D);
#endif // ACTIVE_EDITOR
}
//===========================================================================
// Description: Freeze all the Devices but the device which has the
// number : Number.
// Device which is freeze is no more refresh.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::FreezeAllButOne(UINT Number)
{
#ifdef ACTIVE_EDITOR
UINT i;
for (i = 0; i < MAX_DEVICE; i++)
if (IsActivDevice(i))
{
if (i == Number)
GetDevice(i)->Unfreeze();
else GetDevice(i)->Freeze();
}
#else
if (mActivDeviceAlone)
mDeviceAlone.Freeze();
#endif // ACTIVE_EDITOR
}
//===========================================================================
// Description: Unfreeze all the device.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::UnfreezeAll()
{
#ifdef ACTIVE_EDITOR
UINT i;
for (i = 0; i < MAX_DEVICE; i++)
if (IsActivDevice(i))
GetDevice(i)->Unfreeze();
#else
if (mActivDeviceAlone)
mDeviceAlone.Unfreeze();
#endif // ACTIVE_EDITOR
}
//===========================================================================
// Description: Freeze all the device.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::FreezeAll()
{
#ifdef ACTIVE_EDITOR
UINT i;
for (i = 0; i < MAX_DEVICE; i++)
if (IsActivDevice(i))
GetDevice(i)->Freeze();
#else
if (mActivDeviceAlone)
mDeviceAlone.Freeze();
#endif // ACTIVE_EDITOR
}
/////////////////////////////////////////////////////////////////////////////
// DEV_MultiDevice message handlers
#ifdef ACTIVE_EDITOR
//===========================================================================
// Description: Open/Close a Device in the MultiDevice.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::OnOpenDevice()
{
CPA_SuperObject *p_oCameraSO;
CPA_CameraDLLBase *p_oCamDLL;
if(!TestFlags(MD_ONEDEVICE))
{
long lNum;
lNum = GetNextNumDevice();
if (SetDevice(&mDevice[lNum], lNum))
{
if (TestFlags(MD_VIEW2D))
GetDevice(lNum)->CreateDevice(this, 10+lNum*20, 30+lNum*20, 300, 200, C_DEVICE2D);
else
GetDevice(lNum)->CreateDevice(this, 10+lNum*20, 30+lNum*20, 300, 200, C_DEVICE3D);
}
// create the default camera for the device
p_oCamDLL = (CPA_CameraDLLBase*) M_GetMainApp()->m_p_oMainWorld->GetObjectDLLWithName(C_szDLLCameraName);
ASSERT(p_oCamDLL != NULL);
p_oCameraSO = p_oCamDLL->CreateDefaultCamera();
p_oCamDLL->InsertCameraInHierarchy(p_oCameraSO);
ASSERT(p_oCameraSO != NULL);
((DEV_ViewPort3D*)(GetDevice(lNum)->GetViewPort()))->ChangeCamera(p_oCameraSO);
GetParentFrame()->mfn_vUpdateDeviceToolBar();
}
else
MessageBox("No more Device");
}
void DEV_MultiDevice::OnCloseDevice()
{
GetFocusDevice()->SendMessage(WM_CLOSE, 0, 0);
GetParentFrame()->mfn_vUpdateDeviceToolBar();
}
void DEV_MultiDevice::OnCloseAllDevice()
{
for (int i = 1; i < MAX_DEVICE; i++)
if (IsActivDevice(i))
GetDevice(i)->SendMessage(WM_CLOSE, 0, 0);
GetParentFrame()->mfn_vUpdateDeviceToolBar();
}
#endif // ACTIVE_EDITOR
//===========================================================================
// Description: Create the ToolBar, the background Device, and the Light
// for displaying the world.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
int DEV_MultiDevice::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
#ifdef ACTIVE_EDITOR
CWnd::EnableToolTips(TRUE);
if (GetParent()->IsKindOf( RUNTIME_CLASS( FRMSplitter ) ))
{
GetParentFrame()->RecalcLayout();
}
else
{
ASSERT( GetParent()->IsKindOf( RUNTIME_CLASS( CFrameWnd ) ) );
((CFrameWnd *) GetParent())->RecalcLayout();
}
#else
GetParentFrame()->RecalcLayout();
#endif // ACTIVE_EDITOR
//
// Always create one Device on BackGround.
//
OnOpenDeviceBackground();
#ifndef ACTIVE_EDITOR
mActivDeviceAlone = TRUE;
#endif // ACTIVE_EDITOR
return 0;
}
#ifdef ACTIVE_EDITOR
//===========================================================================
// Description: Do an horizontal tile with all the device but the
// background one.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author: CB
//===========================================================================
void DEV_MultiDevice::OnDeviceTileHorz()
{
CRect stWinRect;
int nbDevice, i;
DEV_Device *a_p_oTabDevices[MAX_DEVICE];
int iHeight, iLastHeight;
GetClientRect(&stWinRect);
for(nbDevice = 0, i = 1; i <MAX_DEVICE; i++)
{
if(IsActivDevice(i))
a_p_oTabDevices[nbDevice++] = GetDevice(i);
}
if(nbDevice)
{
iHeight = stWinRect.bottom / nbDevice;
for(i = 0; i < nbDevice; i++)
{
iLastHeight = iHeight;
if(i == nbDevice - 1)
iHeight = stWinRect.bottom - (i * iLastHeight);
a_p_oTabDevices[i]->MoveWindow(0, i * iLastHeight, stWinRect.right, iHeight);
}
}
}
//===========================================================================
// Description: Do an vertical tile with all the device but the
// background one.
// Creation date: 26/07/96
// Author: LOL
//---------------------------------------------------------------------------
// Revision date:
// Author: CB
//===========================================================================
void DEV_MultiDevice::OnDeviceTileVert()
{
CRect stWinRect;
int nbDevice, i;
DEV_Device *a_p_oTabDevices[MAX_DEVICE];
int iWidth, iLastWidth;
GetClientRect(&stWinRect);
for(nbDevice = 0, i = 1; i <MAX_DEVICE; i++)
{
if(IsActivDevice(i))
a_p_oTabDevices[nbDevice++] = GetDevice(i);
}
if(nbDevice)
{
iWidth = stWinRect.right / nbDevice;
for(i = 0; i < nbDevice; i++)
{
iLastWidth = iWidth;
if(i == nbDevice - 1)
iWidth = stWinRect.right - (i * iLastWidth);
a_p_oTabDevices[i]->MoveWindow(i * iLastWidth, 0, iWidth, stWinRect.bottom);
}
}
}
//===========================================================================
// Description: Do an vertical tile with all the device but the
// background one.
// Creation date: 13/09/96
// Author: CB
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::OnDeviceCascade()
{
CRect stWinRect;
int nbDevice, i, j, lj;
DEV_Device *a_p_oTabDevices[MAX_DEVICE];
int iWidth, iTotalWidth, iHeight, iTotalHeight;
GetClientRect(&stWinRect);
for(nbDevice = 0, i = 1; i <MAX_DEVICE; i++)
{
if(IsActivDevice(i))
a_p_oTabDevices[nbDevice++] = GetDevice(i);
}
if(nbDevice)
{
j = 0;
for(i = 0; i < nbDevice; i++)
{
iWidth = 3*(stWinRect.right / 4);
iHeight = 3*(stWinRect.bottom / 4);
iTotalWidth = (iWidth + (j * (DEV_YCaption*2)));
iTotalHeight = (iHeight + (j * (DEV_YCaption*2)));
lj = j;
if((iTotalWidth > stWinRect.right) || (iTotalHeight > stWinRect.bottom))
{
iWidth = stWinRect.right - (j * (DEV_YCaption*2));
iHeight = stWinRect.bottom - (j * (DEV_YCaption*2));
j = 0;
}
else
j++;
a_p_oTabDevices[i]->MoveWindow
(
lj * (DEV_YCaption*2),
lj * (DEV_YCaption*2),
iWidth,
iHeight
);
}
}
}
//===========================================================================
// Description: Maximize/Restore active device.
// background one.
// Creation date: 18/09/96
// Author: CB
//---------------------------------------------------------------------------
// Revision date:
// Author:
//===========================================================================
void DEV_MultiDevice::OnMaximizeDevice(void)
{
DEV_Device *p_oDevice = GetFocusDevice();
p_oDevice->SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
void DEV_MultiDevice::OnRestoreDevice(void)
{
DEV_Device *p_oDevice = GetFocusDevice();
p_oDevice->SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
}
#endif // ACTIVE_EDITOR
//==========================================================================
//==========================================================================
void DEV_MultiDevice::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
{
RECT r;
CView::OnWindowPosChanged(lpwndpos);
GetClientRect(&r);
#ifdef ACTIVE_EDITOR
int i;
for(i = 0; i < MAX_DEVICE; i++)
{
if(IsActivDevice(i))
{
if(GetDevice(i)->IsMaximize())
GetDevice(i)->SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
}
#else
if (mActivDeviceAlone)
mDeviceAlone.SetWindowPos(&wndTop,r.left,r.top,r.right-r.left,r.bottom-r.top,0);
#endif // ACTIVE_EDITOR
}
//==========================================================================
void DEV_MultiDevice::OnDestroy()
{
#ifdef ACTIVE_EDITOR
if (m_cIsAdditional == 0)
#endif
{
M_GetMainApp()->m_bLeavingApplication = TRUE;
}
mbOnDestroy = TRUE;
CView::OnDestroy();
}
//==========================================================================
#ifdef ACTIVE_EDITOR
LONG DEV_MultiDevice::OnDrawObject(UINT, LONG)
{
DrawObject();
return 0;
}
LONG DEV_MultiDevice::OnDrawObjectExcept0(UINT, LONG)
{
DrawObjectExcept0();
return 0;
}
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,55 @@
/*=========================================================================
* DEVSgl3D.cpp : Implementation of Singledevice 3D.
* This is a part of the PCA project.
*
* Version 1.0
* Creation date 19/07/96
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#include "acp_base.h"
#include "geo.h"
#include "gli.h"
#include "itf/DEVSgl3D.hpp"
/////////////////////////////////////////////////////////////////////////////
// DEV_MultiDevice3D
IMPLEMENT_DYNCREATE(DEV_SingleDevice3D, DEV_MultiDevice3D)
BEGIN_MESSAGE_MAP(DEV_SingleDevice3D, DEV_MultiDevice3D)
//{{AFX_MSG_MAP(DEV_SingleDevice3D)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DEV_SingleDevice3D construction/destruction
DEV_SingleDevice3D::DEV_SingleDevice3D() :
DEV_MultiDevice3D(MD_ONEDEVICE)
{
}
DEV_SingleDevice3D::DEV_SingleDevice3D(int flags) :
DEV_MultiDevice3D(flags | MD_ONEDEVICE)
{
}
DEV_SingleDevice3D::~DEV_SingleDevice3D()
{
}
/////////////////////////////////////////////////////////////////////////////
// DEV_SingleDevice3D message handlers
int DEV_SingleDevice3D::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (DEV_MultiDevice3D::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}

View File

@@ -0,0 +1,56 @@
/*=========================================================================
* DEVSingl.cpp : Implementation of Singledevice.
* This is a part of the PCA project.
*
* Version 1.0
* Creation date 27/06/96
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#include "acp_base.h"
#include "geo.h"
#include "gli.h"
#include "itf/DEVMulti.hpp"
#include "itf/DEVSingl.hpp"
/////////////////////////////////////////////////////////////////////////////
// DEV_MultiDevice
IMPLEMENT_DYNCREATE(DEV_SingleDevice, DEV_MultiDevice)
BEGIN_MESSAGE_MAP(DEV_SingleDevice, DEV_MultiDevice)
//{{AFX_MSG_MAP(DEV_SingleDevice)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DEV_SingleDevice construction/destruction
DEV_SingleDevice::DEV_SingleDevice() :
DEV_MultiDevice(MD_ONEDEVICE)
{
}
DEV_SingleDevice::DEV_SingleDevice(int flags) :
DEV_MultiDevice(flags | MD_ONEDEVICE)
{
}
DEV_SingleDevice::~DEV_SingleDevice()
{
}
/////////////////////////////////////////////////////////////////////////////
// DEV_SingleDevice message handlers
int DEV_SingleDevice::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (DEV_MultiDevice::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}

View File

@@ -0,0 +1,238 @@
/*=========================================================================
*
* DEVTimer.hpp (PRIVATE HEADER): class DEV_Timer
*
*
* Version 1.0
* Creation date 97/01/15
* Revision date
*
* Benoit Germain
*=======================================================================*/
#ifdef ACTIVE_EDITOR
#include "stdafx.h"
#ifndef __DEVTIMER_HPP__
#define __DEVTIMER_HPP__
#include "acp_base.h"
//**************************************
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
//**************************************
/////////////////////////////////////////////////////////////////////////////
// DEV_TimerXXX class
/////////////////////////////////////////////////////////////////////////////
#define C_ulDefaultTimerElapse 100
//pointer to a function of the timer vector array of handlers
typedef void (*tdfn_vTimerVector)(void *);
template <class CWndDerivedClass>
class clVectorNode
{
//friend class CWndDerivedClass;
friend class DEV_Timer<CWndDerivedClass>;
private:
tdfn_vTimerVector m_fn_vVectorHandler;
CWndDerivedClass *m_p_oOwner;
//tdfn_vTimerVector fn_vVectorHandler;
clVectorNode *m_p_oNext;
public:
void m_vCallVector() { if ( m_fn_vVectorHandler ) m_fn_vVectorHandler(m_p_oOwner); };
clVectorNode *m_p_oGetNext() { return m_p_oNext; };
};
template <class CWndDerivedClass>
class DEV_Timer
{
friend class CWndDerivedClass;
public:
DEV_Timer(CWndDerivedClass *p_oOwner, unsigned long ulMilliseconds = C_ulDefaultTimerElapse);
~DEV_Timer();
void m_vAddHandler(CWndDerivedClass *p_oOwner, tdfn_vTimerVector fn_vVectorHandler);
BOOL m_bRemoveHandler(tdfn_vTimerVector fn_vVectorHandler);
void m_vRestartTimer(unsigned long ulMilliseconds = C_ulDefaultTimerElapse);
void m_vSuspendTimer();
void m_vOnTimer(CWndDerivedClass *p_oOwner);
protected:
private:
clVectorNode<CWndDerivedClass> *m_p_oGetVectorHead() { return m_p_oVectorHead; };
unsigned int m_uiTimerId;
clVectorNode<CWndDerivedClass> *m_p_oVectorHead;
CWndDerivedClass *m_p_oOwner;
};
/*===========================================================================
constructor / destructor
=========================================================================*/
template <class CWndDerivedClass>
DEV_Timer<CWndDerivedClass>::DEV_Timer<CWndDerivedClass>(CWndDerivedClass *p_oOwner, unsigned long ulMilliseconds)
{
if ( m_p_oOwner = p_oOwner )
{
m_p_oVectorHead = NULL;
// no timer yet
m_uiTimerId = 0;
// start it
m_vRestartTimer(ulMilliseconds);
}
}
/*===========================================================================*/
template <class CWndDerivedClass>
DEV_Timer<CWndDerivedClass>::~DEV_Timer<CWndDerivedClass>()
{
if ( m_p_oOwner )
{
// stop the timer event queue processing
m_vSuspendTimer();
// remove all the handler nodes
while ( m_p_oVectorHead && m_bRemoveHandler(m_p_oVectorHead->m_fn_vVectorHandler));
}
}
/*===========================================================================
stop the timer
=========================================================================*/
template <class CWndDerivedClass>
void DEV_Timer<CWndDerivedClass>::m_vSuspendTimer()
{
if ( m_p_oOwner )
{
if ( m_uiTimerId && m_p_oOwner->KillTimer(m_uiTimerId) )
m_uiTimerId = 0;
}
}
/*===========================================================================
start the timer
=========================================================================*/
template <class CWndDerivedClass>
void DEV_Timer<CWndDerivedClass>::m_vRestartTimer(unsigned long ulMilliseconds)
{
if ( m_p_oOwner )
{
// stop the timer before restarting in case this is just a timeout change
m_vSuspendTimer();
if ( ulMilliseconds )
m_uiTimerId = m_p_oOwner->SetTimer(1, ulMilliseconds, NULL);
}
}
/*===========================================================================
add a handler to the list of handlers
=========================================================================*/
template <class CWndDerivedClass>
void DEV_Timer<CWndDerivedClass>::m_vAddHandler(CWndDerivedClass *p_oOwner, tdfn_vTimerVector fn_vVectorHandler)
{
//TODO-BBB: I hope that no OnTimer scanning method is currently scanning the list...
if ( m_p_oOwner && m_p_oOwner == p_oOwner )
{
// remove the handler if it already existed
m_bRemoveHandler(fn_vVectorHandler);
if ( fn_vVectorHandler )
{
//allocate a new node
clVectorNode<CWndDerivedClass> *p_oVectorNode = new clVectorNode<CWndDerivedClass>;
if ( p_oVectorNode )
{
clVectorNode<CWndDerivedClass> *p_oOldHead = m_p_oVectorHead;
// set it
p_oVectorNode->m_fn_vVectorHandler = fn_vVectorHandler;
p_oVectorNode->m_p_oOwner = p_oOwner;
// insert it in the list
m_p_oVectorHead = p_oVectorNode;
m_p_oVectorHead->m_p_oNext = p_oOldHead;
}
}
}
}
/*===========================================================================
remove a handler from the queue if it exists,
returns TRUE if a handler is removed, else FALSE
=========================================================================*/
template <class CWndDerivedClass>
BOOL DEV_Timer<CWndDerivedClass>::m_bRemoveHandler(tdfn_vTimerVector fn_vVectorHandler)
{
BOOL bRetVal = FALSE;
if ( m_p_oOwner && m_p_oVectorHead )
{
clVectorNode<CWndDerivedClass> *p_oCurrentNode = m_p_oVectorHead;
clVectorNode<CWndDerivedClass> *p_oPrevNode = m_p_oVectorHead;
// stalk the list, stop when we find a handler that is ours
while ( p_oCurrentNode )
if ( p_oCurrentNode->m_fn_vVectorHandler == fn_vVectorHandler )
{
if ( p_oPrevNode == p_oCurrentNode ) // if we remove the head
m_p_oVectorHead = p_oCurrentNode->m_p_oNext; // make the head point to the next item
else
p_oPrevNode->m_p_oNext = p_oCurrentNode->m_p_oNext; // make the list skip the found node
// destroy the node
delete p_oCurrentNode;
p_oCurrentNode = NULL;
bRetVal = TRUE;
}
else
{
p_oPrevNode = p_oCurrentNode;
p_oCurrentNode = p_oCurrentNode->m_p_oNext;
}
}
return bRetVal;
}
template <class CWndDerivedClass>
void DEV_Timer<CWndDerivedClass>::m_vOnTimer(CWndDerivedClass *p_oOwner)
{
clVectorNode<CWndDerivedClass> *p_oCurrentNode = m_p_oGetVectorHead();
// if the world, the event editor and the current editor agree to it
if
(
p_oCurrentNode
&& M_VGetParentMultiDevice3DOf(p_oOwner)->GetWorld()->fn_bAcceptToRunTimerEngine()
&& M_VGetParentMultiDevice3DOf(p_oOwner)->GetInterface()->GetMainWorld()->GetCurrentEditor()->fn_bAcceptToRunTimerEngine()
&& M_VGetParentMultiDevice3DOf(p_oOwner)->GetInterface()->GetEditor()->fn_bAcceptToRunTimerEngine()
)
// call all the handlers is sequence
while( p_oCurrentNode )
{
p_oCurrentNode->m_vCallVector();
p_oCurrentNode = p_oCurrentNode->m_p_oGetNext();
}
}
#undef TIMERCLASS_TEMPLATE
#endif //__DEVTIMER_HPP__
#endif // ACTIVE_EDITOR

View File

@@ -0,0 +1,245 @@
/*=========================================================================
* DEVViewp.cpp : Implementation of Viewport.
* This is a part of the PCA project.
*
* Version 1.0
* Creation date 26/06/96
* Revision date
*
*
* (c) Ubi Studios 1996
*=======================================================================*/
#include "stdafx.h"
#include "acp_base.h"
#include "itf/customid.h"
#include "itf/CPARes.h"
#include "itf/DEVViewp.hpp"
#include "itf/DEVMulti.hpp"
#include "itf/CPACont.hpp"
#include "itf/CPAProj.hpp"
#define M_DegToRad(A) ((A)*0.01745329)
//=========================================================================
//=========================================================================
DEV_ViewPort::DEV_ViewPort()
{
}
DEV_ViewPort::~DEV_ViewPort()
{
}
//=========================================================================
//=========================================================================
DEV_MultiDevice * DEV_ViewPort::GetParentMultiDevice()
{
return (DEV_MultiDevice *) GetDevice()->GetWindowParent();
}
//=========================================================================
DEV_MultiDevice2D * DEV_ViewPort::GetParentMultiDevice2D()
{
return (DEV_MultiDevice2D *) GetDevice()->GetWindowParent();
}
//=========================================================================
DEV_MultiDevice3D * DEV_ViewPort::GetParentMultiDevice3D()
{
return (DEV_MultiDevice3D *) GetDevice()->GetWindowParent();
}
//=========================================================================
#ifdef ACTIVE_EDITOR
CPA_Contact * DEV_ViewPort::GetParentContact()
{
return GetParentMultiDevice()->GetContact();
}
#endif
//=========================================================================
#ifdef ACTIVE_EDITOR
FRMBaseMenu * DEV_ViewPort::GetParentFrame()
{
return GetParentMultiDevice()->GetParentFrame();
}
#else
CFrameWnd *DEV_ViewPort::GetParentFrame()
{
return GetParentMultiDevice()->GetParentFrame();
}
#endif
#ifdef ACTIVE_EDITOR
//=========================================================================
CPA_DialogBar * DEV_ViewPort::GetParentDialogBar()
{
#ifdef ACTIVE_EDITOR
if(!GetParentMultiDevice()->GetParent()->IsKindOf(RUNTIME_CLASS(FRMSplitter)))
{
return NULL;
}
#endif
return &GetParentFrame()->m_oGeneralDialogBar;
}
#endif
//=========================================================================
//=========================================================================
BEGIN_MESSAGE_MAP(DEV_ViewPort, CWnd)
//{{AFX_MSG_MAP(DEV_ViewPort)
ON_WM_WINDOWPOSCHANGING()
ON_WM_PAINT()
#ifdef ACTIVE_EDITOR
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDBLCLK()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
ON_WM_RBUTTONDBLCLK()
ON_WM_MOUSEMOVE()
ON_WM_KEYDOWN()
ON_WM_KEYUP()
ON_UPDATE_COMMAND_UI_RANGE(C_CustomIDStart, C_EDTPopUpMenuIDEnd, OnUpdateCommandUIRange)
// ON_COMMAND_RANGE(C_CustomIDUserStart, C_CustomIDUserEnd, OnCommandRange)
#endif // ACTIVE_EDITOR
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//=========================================================================
//=========================================================================
void DEV_ViewPort::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
CWnd::OnWindowPosChanging(lpwndpos);
lpwndpos->flags = SWP_NOZORDER | SWP_NOMOVE;
}
/////////////////////////////////////////////////////////////////////////////
//
// TO TRANSMIT MESSAGES TO CONTACT
//
/////////////////////////////////////////////////////////////////////////////
#ifdef ACTIVE_EDITOR
//---------------------------------------------------------------------------
int DEV_ViewPort::OnCreate( LPCREATESTRUCT lpCS)
{
int iResult = CWnd::OnCreate(lpCS);
m_p_oDevice = (DEV_Device*)GetParent();
return iResult;
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnLButtonDown(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
if(GetParentContact())
GetParentContact()->_OnLButtonDown(nFlags, NULL, 0, NULL);
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnLButtonUp(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
if(GetParentContact())
GetParentContact()->_OnLButtonUp(nFlags, NULL);
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnLButtonDblClk(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
if(GetParentContact())
GetParentContact()->_OnLButtonDblClk(nFlags, NULL, 0, NULL);
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnRButtonDown(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
if(GetParentContact())
GetParentContact()->_OnRButtonDown(nFlags, NULL, 0, NULL);
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnRButtonUp(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
if(GetParentContact())
GetParentContact()->_OnRButtonUp(nFlags, NULL);
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnRButtonDblClk(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
if(GetParentContact())
GetParentContact()->_OnRButtonDblClk(nFlags, NULL, 0, NULL);
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnMouseMove(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
if(GetParentContact())
GetParentContact()->_OnMouseMove(nFlags, NULL, NULL);
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if(GetParentContact())
GetParentContact()->_OnKeyDown(nChar, nRepCnt, nFlags);
}
//---------------------------------------------------------------------------
void DEV_ViewPort::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if(GetParentContact())
GetParentContact()->_OnKeyUp(nChar, nRepCnt, nFlags);
}
//---------------------------------------------------------------------------
BOOL DEV_ViewPort::OnCommand(WPARAM wParam, LPARAM lParam)
{
UINT IDCmdMsg = LOWORD(wParam);
if(GetParentContact())
{
if(GetParentContact()->_OnCommand(IDCmdMsg))
return TRUE;
}
return CWnd::OnCommand(wParam,lParam);
}
//---------------------------------------------------------------------------
/*
void DEV_ViewPort::OnCommandRange(UINT uiId)
{
if(GetParentContact())
GetParentContact()->_OnCommand(uiId);
}
*/
//---------------------------------------------------------------------------
void DEV_ViewPort::OnUpdateCommandUIRange(CCmdUI *pCmdUI)
{
if(GetParentContact())
GetParentContact()->_OnUpdateCommandUI(pCmdUI);
}
#endif // ACTIVE_EDITOR
//---------------------------------------------------------------------------
void DEV_ViewPort::OnPaint()
{
CWnd::OnPaint();
if (GLI_lWhatIsGLI() == GLI_C_VersionGlide)
{
/////////////////////////////////////////////////////
// First paint of a view : We run engine thread.
// We are then sure that all draw surface have been
// initialised.
static char s_cFirstPaint = 0;
if((s_cFirstPaint == 0) && (M_GetMainApp()->m_p_oEngineThread))
{
VERIFY(M_GetMainApp()->m_p_oEngineThread->ResumeThread() <= 1);
s_cFirstPaint = 1;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////
// //
// Management of the Module : Interface //
// //
/////////////////////////////////////////////////////////////
// //
// abbreviation of the module-name. Used in macro is 'Int' //
// //
/////////////////////////////////////////////////////////////
#ifndef __ERRINT_H__
#define __ERRINT_H__
//**************************************
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
//**************************************
#include "ERM.h"
#define C_szIntVersion "Int V5.0.0" /* The format is XXX Va.b.c with Xxx is the Tag of the module */
#define C_szIntFullName "Interface"/* the complete and clear name of the module */
#define C_szIntDate __DATE__ /*The format is "Mmm dd yyyy".You can use __DATE__ but be careful that you have the control of the compilation*/
#define __FATAL_ERR_INT__
#define __WARNING1_ERR_INT__
//----------
// Constant
//----------
// error of the Int Module
enum e_uwIntErrNumber{
E_uwIntFatalErr,
#ifdef __FATAL_ERR_INT__
// -----------------
E_uwIntFatalPbInit,
#endif //__FATAL_ERR_INT__
E_uwIntStartOfWarning,// important constant, it allows to recognize if an error is fatal or not.
#ifdef __WARNING1_ERR_INT__
// -------------------
E_uwIntWarningPbFree,
#endif //__WARNING1_ERR_INT__
E_uwIntErrNumber
};
//------------------
// Global Variables
//------------------
#undef EXTERN
#ifndef __DeclareGlobalVariableErrInt_h__
#define EXTERN extern /*external declaration*/
#else //__DeclareGlobalVariableErrInt_h__
#define EXTERN /*replace by nothing : we have to declare*/
#endif //__DeclareGlobalVariableErrInt_h__
EXTERN CPA_EXPORT unsigned char g_ucIntModuleId /*number of identification of the Erm module*/
#ifdef __DeclareGlobalVariableErrInt_h__
= C_ucModuleNotInitialized
#endif //__DeclareGlobalVariableErrInt_h__
;
#ifdef __ERROR_STRINGS__
EXTERN CPA_EXPORT char * g_a_szIntInformationModule []
#ifdef __DeclareGlobalVariableErrInt_h__
= {C_szIntVersion, C_szIntFullName, C_szIntDate}
#endif //__DeclareGlobalVariableErrInt_h__
;
EXTERN CPA_EXPORT char * g_szIntModuleName /* Obliged syntax 'g_sz'+[Abbreviation of ModuleName]+'ModuleName'*/
#ifdef __DeclareGlobalVariableErrInt_h__
= "Module Interface"
#endif //__DeclareGlobalVariableErrInt_h__
;
EXTERN CPA_EXPORT tdstErrorMsg g_a_stIntTabErr [] /* Obliged syntax 'g_a_st'+[Abbreviation of ModuleName]+'TabErr'*/
#ifdef __DeclareGlobalVariableErrInt_h__//Call from main program
={
#ifdef __FATAL_ERR_INT__
// -------------
E_uwIntFatalPbInit, "The memory allocation in the initialization of world fails",
#endif //__FATAL_ERR_INT__
#ifdef __WARNING1_ERR_INT__
// ----------------
E_uwIntWarningPbFree, "Can not free interface memory",
#endif //__WARNING1_ERR_INT__
0xFFFF, "\0"//fin
};
#endif //__DeclareGlobalVariableErrInt_h__
;
#endif //__ERROR_STRINGS__
#endif //__ERRINT_H__

View File

@@ -0,0 +1,325 @@
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "direct.h"
#include "itf/CPARes.h"
#include "errint.h"
#include "mmgint.h"
#include "itf/FRMBase.hpp"
#include "itf/FRMBsMn.hpp"
#include "itf/CPAProj.hpp"
IMPLEMENT_DYNCREATE(FRMBase, CFrameWnd)
BEGIN_MESSAGE_MAP(FRMBase, CFrameWnd)
ON_WM_NCLBUTTONDOWN()
ON_WM_SIZE()
ON_WM_NCHITTEST()
ON_WM_GETMINMAXINFO()
END_MESSAGE_MAP()
// Constructor
//------------------------------------------------------------------------
FRMBase::FRMBase(void)
{
m_bAlreadySize = FALSE;
m_cLock = 0;
m_uiHitTest = HTNOWHERE;
m_p_oMainWorld = NULL;
memset(&m_stWinTop, 0, sizeof(tdstFRMLink));
memset(&m_stWinBottom, 0, sizeof(tdstFRMLink));
memset(&m_stWinLeft, 0, sizeof(tdstFRMLink));
memset(&m_stWinRight, 0, sizeof(tdstFRMLink));
m_bKeepPos = TRUE;
m_iInitWidth = 0;
m_iInitHeight = 0;
m_dwCaptionStyle = 0;//WS_CAPTION|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SYSMENU;
m_oLastPos.SetRectEmpty();
}
// Create frame
//------------------------------------------------------------------------
BOOL FRMBase::CreateBase
(
LPCTSTR lpszWindowName,
int _iCol,
int _iRow,
CPA_MainWorld *_p_oMainWorld,
CCreateContext *pContext
)
{
BOOL bRes;
CFrameWnd *pParentWnd;
DWORD dwStyle;
m_iCol = _iCol;
m_iRow = _iRow;
m_p_oMainWorld = _p_oMainWorld;
// Style of window
if((m_iCol!=2)||(m_iRow!=2))
dwStyle = m_dwCaptionStyle|WS_DISABLED|WS_CLIPCHILDREN|WS_THICKFRAME|/*WS_OVERLAPPED|*/WS_CHILD|WS_CLIPSIBLINGS;
else
dwStyle = m_dwCaptionStyle|WS_DISABLED|WS_CLIPCHILDREN|WS_THICKFRAME;//WS_OVERLAPPED;
// Parent window : The first created one
// pParentWnd = g_oFrameGest.mp_oFirstWindow;
pParentWnd = &g_oBaseFrame;
// Create frame window
bRes = CFrameWnd::Create
(
NULL,
lpszWindowName,
dwStyle,
rectDefault,
pParentWnd,
NULL,
0,
pContext
);
ASSERT(bRes);
// Add frame to list of frames
g_oFrameGest.mfn_vAddOneFrame(this);
return bRes;
}
// To set caption title
//------------------------------------------------------------------------
void FRMBase::mfn_vEnableCaption(BOOL _bVal)
{
if(_bVal)
ModifyStyle(0, WS_CAPTION|m_dwCaptionStyle, WS_VISIBLE);
else
ModifyStyle(WS_CAPTION|m_dwCaptionStyle, 0, WS_VISIBLE);
if(g_oFrameGest.m_iCanRefresh >= 0)
{
RECT stRect;
GetWindowRect(&stRect);
g_oBaseFrame.ScreenToClient(&stRect);
m_oCurPos.left--;
MoveWindow(&stRect);
stRect.left++;
MoveWindow(&stRect);
}
}
//*************************************************************
// MESSAGES
//*************************************************************
// Select window, but not move it
//-------------------------------------------------------------
void FRMBase::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
if(nHitTest == HTCAPTION)
SetFocus();
else
CFrameWnd::OnNcLButtonDown(nHitTest, point);
}
// To test point under mouse
//-------------------------------------------------------------
UINT FRMBase::OnNcHitTest(CPoint point)
{
CSize sizeFrame(GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME));
UINT uiReponse = CFrameWnd::OnNcHitTest(point);
RECT stRect;
GetWindowRect(&stRect);
//
// Where is this ? : No corners
//
switch(uiReponse)
{
case HTTOPLEFT:
if(point.x < stRect.left + sizeFrame.cx)
uiReponse = HTLEFT;
else
uiReponse = HTTOP;
break;
case HTTOPRIGHT:
if(point.x > stRect.right - sizeFrame.cx)
uiReponse = HTRIGHT;
else
uiReponse = HTTOP;
break;
case HTBOTTOMRIGHT:
if(point.x > stRect.right - sizeFrame.cx)
uiReponse = HTRIGHT;
else
uiReponse = HTBOTTOM;
break;
case HTBOTTOMLEFT:
if(point.x < stRect.left + sizeFrame.cx)
uiReponse = HTLEFT;
else
uiReponse = HTBOTTOM;
break;
case HTSIZE:
return HTNOWHERE;
}
m_uiHitTest = uiReponse;
//
// Post process to eventually disable hit test
//
switch(m_uiHitTest)
{
case HTTOP:
case HTBOTTOM:
case HTLEFT:
case HTRIGHT:
if((m_iCol==2)&&(m_iRow==2))
{
if(M_bEditorsActive())
uiReponse = HTNOWHERE;
}
break;
}
switch(m_uiHitTest)
{
case HTTOP:
if(m_cLock & FRM_C_MoveTop)
uiReponse = HTNOWHERE;
break;
case HTBOTTOM:
if(m_cLock & FRM_C_MoveBottom)
uiReponse = HTNOWHERE;
break;
case HTLEFT:
if(m_cLock & FRM_C_MoveLeft)
uiReponse = HTNOWHERE;
break;
case HTRIGHT:
if(m_cLock & FRM_C_MoveRight)
uiReponse = HTNOWHERE;
break;
}
return uiReponse;
}
// When window is resized
//-------------------------------------------------------------
void FRMBase::OnSize(UINT nType, int cx, int cy)
{
char cMove = 0;
switch(m_uiHitTest)
{
case HTTOP:
cMove = FRM_C_MoveTop;
break;
case HTBOTTOM:
cMove = FRM_C_MoveBottom;
break;
case HTLEFT:
cMove = FRM_C_MoveLeft;
break;
case HTRIGHT:
cMove = FRM_C_MoveRight;
break;
}
CFrameWnd::OnSize(nType, cx, cy);
if(cMove && m_bAlreadySize == FALSE)
{
GetWindowRect(m_oCurPos);
g_oBaseFrame.ScreenToClient(m_oCurPos);
g_oFrameGest.m_iBeginSize++;
if(g_oFrameGest.m_iBeginSize == 1)
g_oFrameGest.mfn_vUpdateLastPos();
g_oFrameGest.mfn_vAWindowHasMoved(this, cMove);
g_oFrameGest.m_iBeginSize--;
if(g_oFrameGest.m_iBeginSize == 0)
g_oFrameGest.mfn_vRefreshWindows(FALSE);
}
}
void FRMBase::mfn_vComputeWidthWindow(int nWidth)
{
m_uiHitTest = HTRIGHT;
if(m_cLock & FRM_C_MoveRight)
{
m_uiHitTest = HTLEFT;
if(m_cLock & FRM_C_MoveLeft)
return;
}
if(m_uiHitTest == HTRIGHT)
m_oCurPos.right = m_oCurPos.left + nWidth;
else
m_oCurPos.left = m_oCurPos.right - nWidth;
}
void FRMBase::mfn_vWidthWindow(int nWidth)
{
CRect stPos = m_oCurPos;
mfn_vComputeWidthWindow(nWidth);
if(!stPos.EqualRect(m_oCurPos))
MoveWindow(m_oCurPos.left, m_oCurPos.top, m_oCurPos.right - m_oCurPos.left + 1, m_oCurPos.bottom - m_oCurPos.top + 1);
}
void FRMBase::mfn_vComputeHeightWindow(int nHeight)
{
m_uiHitTest = HTBOTTOM;
if(m_cLock & FRM_C_MoveBottom)
{
m_uiHitTest = HTTOP;
if(m_cLock & FRM_C_MoveTop)
return;
}
if(m_uiHitTest == HTBOTTOM)
m_oCurPos.bottom = m_oCurPos.top + nHeight;
else
m_oCurPos.top = m_oCurPos.bottom - nHeight;
}
void FRMBase::mfn_vHeightWindow(int nHeight)
{
CRect stPos = m_oCurPos;
mfn_vComputeHeightWindow(nHeight);
if(!stPos.EqualRect(m_oCurPos))
MoveWindow(m_oCurPos.left, m_oCurPos.top, m_oCurPos.right - m_oCurPos.left + 1, m_oCurPos.bottom - m_oCurPos.top + 1);
}
void FRMBase::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
CSize sizeScreen(GetSystemMetrics(SM_CXMAXIMIZED), GetSystemMetrics(SM_CYMAXIMIZED));
CSize sizeDlgFrame(GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME));
sizeScreen.cx -= 2*sizeDlgFrame.cx;
sizeScreen.cy -= ((2*sizeDlgFrame.cy)+GetSystemMetrics(SM_CYCAPTION));
lpMMI->ptMinTrackSize.x = 100;
lpMMI->ptMinTrackSize.y = 120;
lpMMI->ptMaxTrackSize.x = sizeScreen.cx - 100;
lpMMI->ptMaxTrackSize.y = sizeScreen.cy - 120;
if((m_cLock & FRM_C_MoveTop) && (m_cLock & FRM_C_MoveBottom))
lpMMI->ptMaxTrackSize.y = sizeScreen.cy;
if((m_cLock & FRM_C_MoveLeft) && (m_cLock & FRM_C_MoveRight))
lpMMI->ptMaxTrackSize.x = sizeScreen.cx;
if(!(m_cLock & FRM_C_MoveTop) && !(m_cLock & FRM_C_MoveBottom))
lpMMI->ptMaxTrackSize.y = sizeScreen.cy;
if(!(m_cLock & FRM_C_MoveLeft) && !(m_cLock & FRM_C_MoveRight))
lpMMI->ptMaxTrackSize.x = sizeScreen.cx;
}
#endif // ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,869 @@
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/FRMGest.hpp"
#include "itf/CPAProj.hpp"
#include "acp_driver.h"
// Global
FRMGest g_oFrameGest;
CList<CWnd *, CWnd *> g_oHideList;
//------------------------------------------------------------------------
BEGIN_MESSAGE_MAP(BaseFrame, CFrameWnd)
ON_WM_ACTIVATE()
ON_WM_SYSCOMMAND()
//CPA2 Gabi Dumitrascu 98/07/13
ON_WM_NCMOUSEMOVE()
ON_WM_NCHITTEST()
//End CPA2 Gabi Dumitrascu 98/07/13
END_MESSAGE_MAP()
//------------------------------------------------------------------------
BOOL bWasZoomed = FALSE;
void BaseFrame::mfnv_UpdateTitle(char *msg)
{
CString act, nouv = msg;
char actc[255], *p;
g_oBaseFrame.GetWindowText(act);
strcpy(actc, (char *) (LPCSTR) act);
p = strchr(actc, ']') + 1;
*p = '\0';
act = actc;
act += " " + nouv;
g_oBaseFrame.SetWindowText(act);
}
BOOL BaseFrame::PreTranslateMessage( MSG* pMsg )
{
BOOL bRes;
if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_KEYUP))
{
if(pMsg->message == WM_KEYDOWN)
bRes = M_GetMainApp()->fn_bTreatAppKeyboard((UINT) pMsg->wParam | 0x40000000);
else
bRes = M_GetMainApp()->fn_bTreatAppKeyboard((UINT) pMsg->wParam | 0xC0000000);
return bRes;
}
else
return M_GetMainWnd()->PreTranslateMessage(pMsg);
}
void BaseFrame::OnActivate(UINT State, CWnd *pwnd, BOOL bMini)
{
BOOL bActive;
static BOOL prevent = FALSE;
if(prevent)
return;
prevent = TRUE;
bActive = State != WA_INACTIVE;
if(IsIconic()&&bActive)
{
if(bWasZoomed)
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE);
else
SendMessage(WM_SYSCOMMAND, SC_RESTORE);
}
if(M_GetMainWnd())
M_GetMainWnd()->OnActivateApp(bActive, NULL);
if(bActive == FALSE)
{
if((pwnd==NULL)||(pwnd==M_GetMainWnd()))
GetDesktopWindow()->SetFocus();
else
pwnd->SetFocus();
}
// CFrameWnd::OnActivate(State, pwnd, bMini);
// if(bActive)
// SetFocus();
prevent = FALSE;
}
void BaseFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
static BOOL prevent = FALSE;
if(prevent)
return;
prevent = TRUE;
UINT uiTrueNID = nID & 0xFFFFFFF0;
if(uiTrueNID == SC_CLOSE)
TerminateProcess(GetCurrentProcess(),0);
if(uiTrueNID == SC_MINIMIZE)
{
bWasZoomed = IsZoomed();
OnActivate(WA_INACTIVE, NULL, FALSE);
}
/* if(!M_bEditorsActive())
{
UINT uiTrueNID = nID & 0xFFFFFFF0;
if((uiTrueNID == SC_MAXIMIZE) || (uiTrueNID == SC_RESTORE))
{
M_GetMainWnd()->OnActivateApp(TRUE, NULL);
// OnActivate(TRUE, NULL);
}
else if(uiTrueNID == SC_MINIMIZE)
{
M_GetMainWnd()->OnActivateApp(FALSE, NULL);
//OnActivate(FALSE, NULL);
}
}*/
CFrameWnd::OnSysCommand(nID, lParam);
if(!IsWindowVisible())
ShowWindow(TRUE);
prevent = FALSE;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : OnNcMouseMove
// Date : 98/07/13
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description :
// Author : Gabi Dumitrascu - CPA
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void BaseFrame::OnNcMouseMove (UINT nHitTest, CPoint point)
{
DEV_ViewPort *pViewPort = M_GetMainDevice2 ()->GetDevice (0)->GetViewPort ();
if (pViewPort)
{
POINTS pts;
pts.x = (short)point.x;
pts.y = (short)point.y;
pViewPort->SendMessage (WM_NCMOUSEMOVE, nHitTest, (LPARAM)&pts);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : OnNcHitTest
// Date : 98/07/13
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description :
// Author : Gabi Dumitrascu - CPA
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
UINT BaseFrame::OnNcHitTest (CPoint point)
{
DEV_ViewPort *pViewPort = M_GetMainDevice2 ()->GetDevice (0)->GetViewPort ();
if (pViewPort)
{
POINTS pts;
pts.x = (short)point.x;
pts.y = (short)point.y;
pViewPort->SendMessage (WM_NCHITTEST, (LPARAM)&pts);
}
return CFrameWnd::OnNcHitTest (point);
}
//------------------------------------------------------------------------
BaseFrame g_oBaseFrame;
// Constructor / Destructor
//------------------------------------------------------------------------
FRMGest::FRMGest(void)
{
int x, y, iAct = 1;
memset(ma_p_oWinArray, 0, sizeof(FRMBase *) * (FRM_C_MaxCol+2) * (FRM_C_MaxRow+2));
memset(ma_p_oOccupyArray, 0, sizeof(FRMBase *) * (FRM_C_MaxCol+2) * (FRM_C_MaxRow+2));
mp_oFirstWindow = NULL;
m_iCanRefresh = 0;
m_iBeginSize = 0;
// Default order to treat windows
for(x = 1; x <= FRM_C_MaxCol; x++)
for(y = 1; y <= FRM_C_MaxRow; y++)
ma_iOrder[x][y] = iAct++;
}
FRMGest::~FRMGest(void)
{
m_lstFrames.RemoveAll();
}
// Add one frame
//------------------------------------------------------------------------
void FRMGest::mfn_vAddOneFrame(FRMBase *_p_oFrm)
{
m_lstFrames.AddTail(_p_oFrm);
}
// Compute position of window when activated
// _p_oFrm : Frame that appears
// _p_oLast : Last frame at the same position
//------------------------------------------------------------------------
void FRMGest::mfn_vComputeActivatePos(FRMBase *_p_oFrm)
{
FRMBase *p_stOther;
if(_p_oFrm == NULL)
return;
if(_p_oFrm->m_iInitWidth)
_p_oFrm->mfn_vComputeWidthWindow(_p_oFrm->m_iInitWidth);
//
// We compute width depending of other windows
//
else
{
p_stOther = fn_vSearchHorizWindow(_p_oFrm, -1);
if(p_stOther)
_p_oFrm->m_oCurPos.left = p_stOther->m_oCurPos.right;
p_stOther = fn_vSearchHorizWindow(_p_oFrm, 1);
if(p_stOther)
_p_oFrm->m_oCurPos.right = p_stOther->m_oCurPos.left;
}
if(_p_oFrm->m_iInitHeight)
_p_oFrm->mfn_vComputeHeightWindow(_p_oFrm->m_iInitHeight);
//
// We compute height depending of other windows
//
else
{
p_stOther = fn_vSearchVertWindow(_p_oFrm, -1);
if(p_stOther)
_p_oFrm->m_oCurPos.top = p_stOther->m_oCurPos.bottom;
p_stOther = fn_vSearchVertWindow(_p_oFrm, 1);
if(p_stOther)
_p_oFrm->m_oCurPos.bottom = p_stOther->m_oCurPos.top;
}
}
// Expand position of window
//------------------------------------------------------------------------
void FRMGest::mfn_vExpandFrame(int x, int y)
{
int xt, yt;
BOOL bRes;
FRMBase *p_oFrm = ma_p_oOccupyArray[x][y];
// To the left
if(x != 1)
{
yt = y;
bRes = TRUE;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
if(ma_p_oOccupyArray[x-1][yt++])
bRes = FALSE;
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
if(ma_p_oOccupyArray[x-1][yt--])
bRes = FALSE;
if(bRes)
{
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
ma_p_oOccupyArray[x-1][yt++] = p_oFrm;
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
ma_p_oOccupyArray[x-1][yt--] = p_oFrm;
mfn_vExpandFrame(x-1, y);
}
}
// To the right
if(x != FRM_C_MaxCol)
{
yt = y;
bRes = TRUE;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
if(ma_p_oOccupyArray[x+1][yt++])
bRes = FALSE;
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
if(ma_p_oOccupyArray[x+1][yt--])
bRes = FALSE;
if(bRes)
{
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
ma_p_oOccupyArray[x+1][yt++] = p_oFrm;
yt = y;
while(ma_p_oOccupyArray[x][yt] == p_oFrm)
ma_p_oOccupyArray[x+1][yt--] = p_oFrm;
mfn_vExpandFrame(x+1, y);
}
}
// To the top
if(y != 1)
{
xt = x;
bRes = TRUE;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
if(ma_p_oOccupyArray[xt++][y-1])
bRes = FALSE;
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
if(ma_p_oOccupyArray[xt--][y-1])
bRes = FALSE;
if(bRes)
{
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
ma_p_oOccupyArray[xt++][y-1] = p_oFrm;
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
ma_p_oOccupyArray[xt--][y-1] = p_oFrm;
mfn_vExpandFrame(x, y-1);
}
}
// To the bottom
if(y != FRM_C_MaxRow)
{
xt = x;
bRes = TRUE;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
if(ma_p_oOccupyArray[xt++][y+1])
bRes = FALSE;
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
if(ma_p_oOccupyArray[xt--][y+1])
bRes = FALSE;
if(bRes)
{
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
ma_p_oOccupyArray[xt++][y+1] = p_oFrm;
xt = x;
while(ma_p_oOccupyArray[xt][y] == p_oFrm)
ma_p_oOccupyArray[xt--][y+1] = p_oFrm;
mfn_vExpandFrame(x, y+1);
}
}
}
void FRMGest::mfn_vSearchNextOrder(int iAct, int *p_iX, int *p_iY)
{
int x, y;
for(x = 1; x <= FRM_C_MaxCol; x++)
{
for(y = 1; y <= FRM_C_MaxRow; y++)
{
if(ma_iOrder[x][y] == (iAct+1))
{
*p_iX = x;
*p_iY = y;
return;
}
}
}
}
FRMBase *FRMGest::fn_vSearchHorizWindow(FRMBase *_p_oFrm, int dx)
{
int x = _p_oFrm->m_iCol + dx;
while(ma_p_oOccupyArray[x][_p_oFrm->m_iRow] == _p_oFrm)
x += dx;
return ma_p_oOccupyArray[x][_p_oFrm->m_iRow];
}
FRMBase *FRMGest::fn_vSearchVertWindow(FRMBase *_p_oFrm, int dy)
{
int y = _p_oFrm->m_iRow + dy;
while(ma_p_oOccupyArray[_p_oFrm->m_iCol][y] == _p_oFrm)
y += dy;
return ma_p_oOccupyArray[_p_oFrm->m_iCol][y];
}
// Try to expand all windows in each directions
//---------------------------------------------
void FRMGest::mfn_vExpandAll(void)
{
int i, x, y, iOrder = 0;
FRMBase *p_oTest;
CSize sizeFrame(GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME));
CSize sizeScreen(GetSystemMetrics(SM_CXMAXIMIZED), GetSystemMetrics(SM_CYMAXIMIZED));
CSize sizeDlgFrame(GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME));
sizeScreen.cx -= 2*sizeDlgFrame.cx;
sizeScreen.cy -= (sizeDlgFrame.cy+GetSystemMetrics(SM_CYCAPTION));
memcpy(ma_p_oOccupyArray, ma_p_oWinArray, sizeof(FRMBase *) * (FRM_C_MaxCol+2) * (FRM_C_MaxRow+2));
for(i = 0; i <= FRM_C_MaxCol * FRM_C_MaxRow; i++)
{
mfn_vSearchNextOrder(iOrder, &x, &y);
if(ma_p_oWinArray[x][y])
mfn_vExpandFrame(x, y);
iOrder++;
}
// To update locking
for(x = 1; x <= FRM_C_MaxCol; x++)
{
for(y = 1; y <= FRM_C_MaxRow; y++)
{
p_oTest = ma_p_oWinArray[x][y];
if(p_oTest)
p_oTest->m_cLock = 0;
}
}
// Some well known positions
// Update locking too
for(x = 1; x <= FRM_C_MaxCol; x++)
{
for(y = 1; y <= FRM_C_MaxRow; y++)
{
p_oTest = ma_p_oOccupyArray[x][y];
ASSERT(p_oTest);
if(x == 1)
{
p_oTest->m_oCurPos.left = 0;
if(M_bEditorsActive())
p_oTest->m_cLock |= FRM_C_MoveLeft;
}
if(y == 1)
{
p_oTest->m_oCurPos.top = 0;
if(M_bEditorsActive())
p_oTest->m_cLock |= FRM_C_MoveTop;
}
if(x == FRM_C_MaxCol)
{
p_oTest->m_oCurPos.right = sizeScreen.cx - 2*sizeFrame.cx;
if(M_bEditorsActive())
p_oTest->m_cLock |= FRM_C_MoveRight;
}
if(y == FRM_C_MaxRow)
{
p_oTest->m_oCurPos.bottom = sizeScreen.cy - 2*sizeFrame.cy;
if(M_bEditorsActive())
p_oTest->m_cLock |= FRM_C_MoveBottom;
}
}
}
}
// Update intial with and height of window
//------------------------------------------------------------------------
void FRMGest::mfn_vUpdateWidthHeight(FRMBase *_p_oFrm)
{
if(_p_oFrm->m_bKeepPos)
{
if(_p_oFrm->m_iInitWidth)
_p_oFrm->m_iInitWidth = _p_oFrm->m_oCurPos.right - _p_oFrm->m_oCurPos.left;
if(_p_oFrm->m_iInitHeight)
_p_oFrm->m_iInitHeight = _p_oFrm->m_oCurPos.bottom - _p_oFrm->m_oCurPos.top;
}
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// Activate window
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void FRMGest::mfn_vActivateWindow(FRMBase *_p_oFrm)
{
FRMBase *p_oLast = ma_p_oWinArray[_p_oFrm->m_iCol][_p_oFrm->m_iRow];
int x, y;
BOOL bFS1,bFS2;
DEV_MultiDevice *OldMulti=NULL, *NewMulti=NULL;
bFS1 = TRUE;
bFS2 = TRUE;
_p_oFrm->SetParent(&g_oBaseFrame);
if(_p_oFrm->IsIconic())
_p_oFrm->SendMessage(WM_SYSCOMMAND, SC_RESTORE);
_p_oFrm->EnableWindow(TRUE);
mfn_vUpdateLastPos();
_p_oFrm->GetWindowRect(&_p_oFrm->m_oLastPos);
g_oBaseFrame.ScreenToClient(&_p_oFrm->m_oLastPos);
_p_oFrm->GetWindowRect(&_p_oFrm->m_oCurPos);
g_oBaseFrame.ScreenToClient(&_p_oFrm->m_oCurPos);
//
// Activate new window
//
//_p_oFrm->SetParent(&g_oBaseFrame);
x = _p_oFrm->m_iCol;
y = _p_oFrm->m_iRow;
if (x == 2 && y == 2 && p_oLast && _p_oFrm)
{
OldMulti = ((FRMBaseMenu*)p_oLast)->GetMultiDevice();
NewMulti = ((FRMBaseMenu*)_p_oFrm)->GetMultiDevice();
if (OldMulti && NewMulti)
{
// check fullscreen
bFS2 = NewMulti->GetDevice(0)->IsFullScreen();
bFS1 = OldMulti->GetDevice(0)->IsFullScreen();
}
}
ma_p_oWinArray[x][y] = _p_oFrm;
_p_oFrm->fn_vOnActivate();
if(!M_bEditorsActive())
return;
//
// Expand position of window depending of neighbours
// - ma_p_oOccupyArray is initialised
// - Frames are locked depending of their position
//
mfn_vExpandAll();
//
// Compute position of window
//
mfn_vComputeActivatePos(_p_oFrm);
//
// Show window if it's enabled
//
if(m_iCanRefresh >= 0)
{
_p_oFrm->m_bAlreadySize = TRUE;
_p_oFrm->ShowWindow(TRUE);
_p_oFrm->m_bAlreadySize = FALSE;
}
//
// Recompute size of other windows for each border
// (only if necessary)
//
if(_p_oFrm->m_iInitWidth)
{
if(fn_vSearchHorizWindow(_p_oFrm, -1))
mfn_vAWindowHasMoved(_p_oFrm, FRM_C_MoveLeft);
if(fn_vSearchHorizWindow(_p_oFrm, 1))
mfn_vAWindowHasMoved(_p_oFrm, FRM_C_MoveRight);
}
if(_p_oFrm->m_iInitHeight)
{
if(fn_vSearchVertWindow(_p_oFrm, -1))
mfn_vAWindowHasMoved(_p_oFrm, FRM_C_MoveTop);
if(fn_vSearchVertWindow(_p_oFrm, 1))
mfn_vAWindowHasMoved(_p_oFrm, FRM_C_MoveBottom);
}
// Window has been one time activated
if(m_iCanRefresh >= 0)
mfn_vRefreshWindows(FALSE);
//
// Hide the window the window at this place
//
#ifdef USE_DIRECTX
if(NewMulti) NewMulti->GetDevice(0)->SetMainWindowForRender();//chbani
#else
if (bFS1 != bFS2)
{
OldMulti->GetDevice(0)->SwapFullScreen();
NewMulti->GetDevice(0)->SwapFullScreen();
}
#endif
if(p_oLast)
{
mfn_vUpdateWidthHeight(p_oLast);
p_oLast->m_bAlreadySize = TRUE;
// if(p_oLast != M_GetMainWnd())
p_oLast->ShowWindow(FALSE);
// else
// p_oLast->SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
p_oLast->m_bAlreadySize = FALSE;
}
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// Disactivate window
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void FRMGest::mfn_vDisactivateWindow(FRMBase *_p_oFrm)
{
mfn_vUpdateWidthHeight(_p_oFrm);
_p_oFrm->m_bAlreadySize = TRUE;
if(_p_oFrm != M_GetMainWnd())
{
if((m_iCanRefresh >= 0) || (m_iCanRefresh <= -4500))
_p_oFrm->ShowWindow(FALSE);
else
g_oHideList.AddTail((CWnd *) _p_oFrm);
}
_p_oFrm->m_bAlreadySize = FALSE;
ma_p_oWinArray[_p_oFrm->m_iCol][_p_oFrm->m_iRow] = NULL;
mfn_vExpandAll();
if(m_iCanRefresh >= 0)
mfn_vRefreshWindows(FALSE);
}
//************************************************************************
//************************************************************************
// To recompute the size of a window.
//------------------------------------------------------------------------
void FRMGest::mfn_vRecomputeSizeOpposite(FRMBase *_p_oFrm, FRMBase *_p_oRef, char cMove)
{
if(_p_oFrm == NULL)
return;
if(_p_oFrm == _p_oRef)
return;
switch(cMove)
{
case FRM_C_MoveTop:
_p_oFrm->m_oCurPos.bottom = _p_oRef->m_oCurPos.top;
break;
case FRM_C_MoveBottom:
_p_oFrm->m_oCurPos.top = _p_oRef->m_oCurPos.bottom;
break;
case FRM_C_MoveLeft:
_p_oFrm->m_oCurPos.right = _p_oRef->m_oCurPos.left;
break;
case FRM_C_MoveRight:
_p_oFrm->m_oCurPos.left = _p_oRef->m_oCurPos.right;
break;
}
}
//------------------------------------------------------------------------
void FRMGest::mfn_vRecomputeSizeSame(FRMBase *_p_oFrm, FRMBase *_p_oRef, char cMove)
{
if(_p_oFrm == NULL)
return;
if(_p_oFrm == _p_oRef)
return;
switch(cMove)
{
case FRM_C_MoveTop:
_p_oFrm->m_oCurPos.top = _p_oRef->m_oCurPos.top;
break;
case FRM_C_MoveBottom:
_p_oFrm->m_oCurPos.bottom = _p_oRef->m_oCurPos.bottom;
break;
case FRM_C_MoveLeft:
_p_oFrm->m_oCurPos.left = _p_oRef->m_oCurPos.left;
break;
case FRM_C_MoveRight:
_p_oFrm->m_oCurPos.right = _p_oRef->m_oCurPos.right;
break;
}
}
// When a window has moved
//------------------------------------------------------------------------
#define M_vFRMTestSizeWin(x, y, name1, name2)\
if\
(\
(ma_p_oOccupyArray[x][y])\
&& (_p_oFrm->name1.cLinkSame & cMove)\
&& (!(ma_p_oOccupyArray[x][y]->m_cLock & cMove))\
&& (ma_p_oOccupyArray[x][y]->name2.cLinkSame & cMove)\
)\
{\
mfn_vRecomputeSizeSame(ma_p_oOccupyArray[x][y], _p_oFrm, cMove);\
mfn_vAWindowHasMoved(ma_p_oOccupyArray[x][y], cMove);\
}
// When a window has been moved
//------------------------------------------------------------------------
void FRMGest::mfn_vAWindowHasMoved(FRMBase *_p_oFrm, char cMove)
{
int x, y, xt, yt;
if(_p_oFrm == NULL)
return;
if(_p_oFrm->m_bAlreadySize)
return;
_p_oFrm->m_bAlreadySize = TRUE;
//
// Normal resize due to position in array
//
x = _p_oFrm->m_iCol;
y = _p_oFrm->m_iRow;
switch(cMove)
{
case FRM_C_MoveTop:
for(xt = 1; xt <= FRM_C_MaxCol; xt++)
{
if(ma_p_oOccupyArray[xt][y] == _p_oFrm)
{
mfn_vRecomputeSizeOpposite(ma_p_oOccupyArray[xt][y-1], _p_oFrm, cMove);
mfn_vAWindowHasMoved(ma_p_oOccupyArray[xt][y-1], FRM_C_MoveBottom);
}
}
break;
case FRM_C_MoveBottom:
for(xt = 1; xt <= FRM_C_MaxCol; xt++)
{
if(ma_p_oOccupyArray[xt][y] == _p_oFrm)
{
mfn_vRecomputeSizeOpposite(ma_p_oOccupyArray[xt][y+1], _p_oFrm, cMove);
mfn_vAWindowHasMoved(ma_p_oOccupyArray[xt][y+1], FRM_C_MoveTop);
}
}
break;
case FRM_C_MoveLeft:
for(yt = 1; yt <= FRM_C_MaxRow; yt++)
{
if(ma_p_oOccupyArray[x][yt] == _p_oFrm)
{
mfn_vRecomputeSizeOpposite(ma_p_oOccupyArray[x-1][yt], _p_oFrm, cMove);
mfn_vAWindowHasMoved(ma_p_oOccupyArray[x-1][yt], FRM_C_MoveRight);
}
}
break;
case FRM_C_MoveRight:
for(yt = 1; yt <= FRM_C_MaxRow; yt++)
{
if(ma_p_oOccupyArray[x][yt] == _p_oFrm)
{
mfn_vRecomputeSizeOpposite(ma_p_oOccupyArray[x+1][yt], _p_oFrm, cMove);
mfn_vAWindowHasMoved(ma_p_oOccupyArray[x+1][yt], FRM_C_MoveLeft);
}
}
break;
}
//
// Size due to links
//
switch(cMove)
{
case FRM_C_MoveTop:
case FRM_C_MoveBottom:
for(yt = 1; yt <= FRM_C_MaxRow; yt++)
{
if(ma_p_oOccupyArray[x][yt] == _p_oFrm)
{
M_vFRMTestSizeWin(x-1, yt, m_stWinLeft, m_stWinRight);
M_vFRMTestSizeWin(x+1, yt, m_stWinRight, m_stWinLeft);
}
}
break;
case FRM_C_MoveLeft:
case FRM_C_MoveRight:
for(xt = 1; xt <= FRM_C_MaxCol; xt++)
{
if(ma_p_oOccupyArray[xt][y] == _p_oFrm)
{
M_vFRMTestSizeWin(xt, y-1, m_stWinTop, m_stWinBottom);
M_vFRMTestSizeWin(xt, y+1, m_stWinBottom, m_stWinTop);
}
}
break;
}
_p_oFrm->m_bAlreadySize = FALSE;
}
// Refresh all windows
//------------------------------------------------------------------------
void FRMGest::mfn_vRefreshWindows(BOOL _bForce)
{
int x, y;
if(m_iCanRefresh >= 0)
{
for(x = 1; x <= FRM_C_MaxCol; x++)
{
for(y = 1; y <= FRM_C_MaxRow; y++)
{
if(ma_p_oWinArray[x][y])
{
if
(
(!ma_p_oWinArray[x][y]->m_oCurPos.EqualRect(ma_p_oWinArray[x][y]->m_oLastPos))
|| (ma_p_oWinArray[x][y]->m_oLastPos.IsRectEmpty())
|| (_bForce)
)
{
ma_p_oWinArray[x][y]->MoveWindow(ma_p_oWinArray[x][y]->m_oCurPos);
if(!(ma_p_oWinArray[x][y]->GetStyle() & WS_VISIBLE))
{
ma_p_oWinArray[x][y]->m_bAlreadySize = TRUE;
ma_p_oWinArray[x][y]->ShowWindow(TRUE);
ma_p_oWinArray[x][y]->m_bAlreadySize = FALSE;
}
}
}
}
}
/*
* We hide all the eventual windows
*/
POSITION pos, lpos;
pos = g_oHideList.GetHeadPosition();
while(pos)
{
CWnd *pWnd = g_oHideList.GetAt(pos);
lpos = pos;
g_oHideList.GetNext(pos);
g_oHideList.RemoveAt(lpos);
pWnd->ShowWindow(SW_HIDE);
}
}
}
// Set/Reset refresh mode
//------------------------------------------------------------------------
void FRMGest::mfn_vSetRefresh(BOOL _bVal)
{
if(_bVal)
{
if(m_iCanRefresh < 0)
m_iCanRefresh++;
}
else
m_iCanRefresh--;
if(m_iCanRefresh == 0)
mfn_vRefreshWindows(TRUE);
}
// Update m_oLastPos of each windows
//------------------------------------------------------------------------
void FRMGest::mfn_vUpdateLastPos(void)
{
int x, y;
for(x = 1; x <= FRM_C_MaxCol; x++)
for(y = 1; y <= FRM_C_MaxRow; y++)
if(ma_p_oWinArray[x][y])
{
ma_p_oWinArray[x][y]->GetWindowRect(ma_p_oWinArray[x][y]->m_oLastPos);
g_oBaseFrame.ScreenToClient(&ma_p_oWinArray[x][y]->m_oLastPos);
}
}
#endif // ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,53 @@
/*=========================================================================
* MemInt.h : Manage the memory allocation for CPA module.
* This is a part of the CPA project.
*
* Version 1.0
* Creation date 03/10/96
* Revision date
* Author : Olivier Didelot
*
* (c) Ubi Studios 1996
*=======================================================================*/
//**************************************
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
//**************************************
#ifndef __MemInt_H__
#define __MemInt_H__
#include "MMG.h"
enum e_ucIntStaticBlocks{
E_ucIntBlock1,
E_ucIntBlock2,
E_ucIntBlock3,
E_ucIntBlock4,
E_ucIntMaxBlocksNb // maximum number of static block, You have to follow this syntax 'E_uc+ Abbreviation Module +MaxBlocksNb'
};
#undef EXTERN
#ifdef __DeclareGlobalVariableMemInt_h__
#define EXTERN /*nothing*/
#else // no __DeclareGlobalVariableMemInt_h__
#define EXTERN extern
#endif //__DeclareGlobalVariableMemInt_h__
EXTERN CPA_EXPORT tdstBlockInfo g_a_stIntBlocksInfo[E_ucIntMaxBlocksNb];
#ifdef __DYNAMIC_MALLOC_ALLOWED__
#ifdef __DEBUG_MALLOC_MODE__
EXTERN CPA_EXPORT tdstDynInfo g_stIntDynInfo;
#endif //__DEBUG_MALLOC_MODE__
#endif //__DYNAMIC_MALLOC_ALLOWED__
#endif //__MemInt_H__

View File

@@ -0,0 +1,53 @@
/*=========================================================================
* MmgInt.h : Manage the memory allocation for CPA module.
* This is a part of the CPA project.
*
* Version 1.0
* Creation date 03/10/96
* Revision date
* Author : Olivier Didelot
*
* (c) Ubi Studios 1996
*=======================================================================*/
//**************************************
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
//**************************************
#ifndef __MemInt_H__
#define __MemInt_H__
#include "MMG.h"
enum e_ucIntStaticBlocks{
E_ucIntBlock1,
E_ucIntBlock2,
E_ucIntBlock3,
E_ucIntBlock4,
E_ucIntMaxBlocksNb // maximum number of static block, You have to follow this syntax 'E_uc+ Abbreviation Module +MaxBlocksNb'
};
#undef EXTERN
#ifdef __DeclareGlobalVariableMmgInt_h__
#define EXTERN /*nothing*/
#else // no __DeclareGlobalVariableMmgInt_h__
#define EXTERN extern
#endif //__DeclareGlobalVariableMmgInt_h__
EXTERN CPA_EXPORT tdstBlockInfo g_a_stIntBlocksInfo[E_ucIntMaxBlocksNb];
#ifdef __DYNAMIC_MALLOC_ALLOWED__
#ifdef __DEBUG_MALLOC_MODE__
EXTERN CPA_EXPORT tdstDynInfo g_stIntDynInfo;
#endif //__DEBUG_MALLOC_MODE__
#endif //__DYNAMIC_MALLOC_ALLOWED__
#endif //__MemInt_H__

View File

@@ -0,0 +1,5 @@
SCC = This is a source code control file
[ITF.vcproj]
SCC_Aux_Path = "P4SCC#srvperforce-ma:1666##raymandata##Editor"
SCC_Project_Name = Perforce Project

View File

@@ -0,0 +1,25 @@
/*=========================================================================
*
* objdllb.cpp : Implementation file
*
*
* Version 1.0
* Creation date
* Revision date
*
* Shaitan
*=======================================================================*/
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/objdllb.hpp"
void CPA_ObjectDLLBase::fn_vOnCancelInsertion (CPA_SuperObject *pInstance)
{
/*
delete pInstance;
*/
}
#endif // ACTIVE_EDITOR

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// ACPProject.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,16 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows 95 Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

Binary file not shown.

View File

@@ -0,0 +1,33 @@
//=========================================================================
// ToolDLLb.cpp : base of Tools DLL
// This is a part of the CPA project.
//
// Version 1.0
// Creation date 10/12/96
// Revision date
//
// (c) Ubi Studio 1996
//
// DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT
// VINCENT GRECO OR CHRISTOPHE BEAUDET.
//=========================================================================
#include "stdafx.h"
#ifdef ACTIVE_EDITOR
#include "acp_base.h"
#include "itf/ToolDLLb.hpp"
#include "itf/CPAMWorl.hpp"
void CPA_ToolDLLBase::fn_vSetReceivingWindowMessages(BOOL _bWantToReceive /*=TRUE*/)
{
GetMainWorld()->fn_vSetReceivingWindowMsgState(this,_bWantToReceive);
}
// TO Want/won't to receive Evt Editor Messages
void CPA_ToolDLLBase::fn_vSetReceivingEvtEditorMessages(BOOL _bWantToReceive /*=TRUE*/)
{
GetMainWorld()->fn_vSetReceivingEvtEditorMsgState(this,_bWantToReceive);
}
#endif //ACTIVE_EDITOR