// Implementation for the class CMyDocument ///////////////////////////////////////////// #include "StdAfx.h" #include "_AInterf.hpp" #include "EDACDoc.hpp" #include "EDACDgMC.hpp" #include "EDACDgMN.hpp" #include "EDACDgCp.hpp" #include "EDACDgIf.hpp" #include "EDACActr.hpp" #include "EDACDgMC.hpp" #include "EDACDgMn.hpp" #include "EDACVwAc.hpp" #include "EDACVwMS.hpp" #include "EDACModl.hpp" #include "EDACCnst.hpp" #include "EDACGlob.hpp" #include "EDACStrg.hpp" #include "EDACDgML.hpp" #include "EDACDgIC.hpp" #include "Defines.hpp" //External Modules #include "TFa.h" #include "DPT.h" #include "Tot.h" #include "ErO.h" //End of External Modules //-----------------IR------------------------- #include "EdIRFrm.hpp" #include "EdIRBeEn.hpp" #include "EdIRDVVw.hpp" #include "EDACQuer.hpp" // Shaitan => state list in the level #include "ai_intf.hpp" // End Shaitan => state list in the level //-------------------------------------------- //ROMTEAM LoadAI (Cristi Petrescu 26/03/98) #include "dlgldai.hpp" #include "ITF/cpaproj.hpp" //ENDROMTEAM LoadAI (Cristi Petrescu) //CPA2 Stegaru Cristian 98/07/01 #include "..\inc\edactors\dlgcleanalwfile.h" //End CPA2 Stegaru Cristian 98/07/01 #undef CPA_WANTS_IMPORT #undef CPA_EXPORT #define CPA_WANTS_EXPORT //-----------------IR------------------------- #include "EdIRIRD.hpp" //-------------------------------------------- #include "_Actors.hpp" #undef CPA_WANTS_EXPORT #define CPA_WANTS_IMPORT #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //**************************************************************************** EdActors_MyDocument::EdActors_MyDocument() { //Creates lists of actors and models m_eCurrentDisplayMode = ED_ACTORS_eDisplayMode_Instance; m_pclCurrentActorsList = &m_clInstancesList; m_pclCurrentMiniStructureList = NULL; m_bAIFirstTime = TRUE; //Initializes editor's state m_pclDialogList = NULL; m_pclActorsView = NULL; m_pclMiniStrucView = NULL; //-----------------IR------------------------- m_pclDesignerVariablesView = NULL; //-------------------------------------------- m_pclSelectedActor = NULL; m_pclCurrentInstance = NULL; m_pclCurrentModel = NULL; m_pclCurrentFamily = NULL; //Editor's Setup var. Init. m_bMustConfirmUnallocation = TRUE; m_bMustConfirmAllocation = TRUE; m_bMustRefreshDatas = FALSE; m_bMustConfirmWatchSuppression = TRUE; m_bMustDisplayModelFieldsInInstance = TRUE; m_bMustDisplayUnallocatedMS = TRUE; m_bMustDisplayHelpOnActiveView = FALSE; m_bWatchAlwaysVisible = TRUE; m_bProposeUnloadedModels = FALSE;//TRUE; m_bRestoreGroup = FALSE; m_bAskForNewInstanceName = TRUE; //Colors for the name's (model or instance) static m_pub_colref_NameTextColor = RGB(0,0,0); m_pub_colref_NameBackgroundColor = RGB(224,224,224); //Colors for the model's static m_pub_colref_ModelTextColor = RGB(0,0,0); m_pub_colref_ModelBackgroundColor = RGB(224,224,224); //Colors for the family's static m_pub_colref_FamilyTextColor = RGB(0,0,0); m_pub_colref_FamilyBackgroundColor = RGB(224,224,224); //Colors for the fields' static m_pub_colref_FieldInstanceTextColor = RGB(0,0,0); m_pub_colref_FieldInstanceBackgroundColor = RGB(224,224,224); m_pub_colref_FieldInitialTextColor = RGB(0,0,0); m_pub_colref_FieldInitialBackgroundColor = RGB(224,224,224); m_pub_colref_FieldCurrentTextColor = RGB(0,0,0); m_pub_colref_FieldCurrentBackgroundColor = RGB(224,224,224); m_pub_colref_InWatchFieldTextColor = RGB(255,0,0); m_pub_colref_InWatchFieldBackgroundColor = RGB(160,160,160); m_pub_colref_FieldModelTextColor = RGB(0,0,0); m_pub_colref_FieldModelBackgroundColor = RGB(224,224,224); m_ulListViewHeight = 150; m_ulControlViewHeight = 150; m_ulMSViewHeight = 300; m_ulModelViewHeight = 200; m_ulAIViewHeight = 200; m_ulCharacEditorWidth = C_EDITOR_WIDTH; //ANNECY Shaitan Correction (16/04/98) { // m_ucCurrentDataLevel = 2; //ENDANNECY Shaitan Correction } m_bIAActivated = FALSE; m_bWatchActivated = FALSE; m_bVariablesActivated = FALSE; m_bDisplayCurrentValue = TRUE; m_bDisplayInitialValue = TRUE; m_pri_bTreeMustShowUnloadedObjects = FALSE; m_pri_bTreeMustOnlyShowFamiliesWithModels = FALSE; // m_pub_bMustShowLinks = FALSE; // m_pub_bMustDisplayHelpOnFields = FALSE; m_hPreviousCursorForHelpOnFields = NULL; //Loads cursor m_hHelpCursor = AfxGetApp()->LoadCursor(IDC_CURSOR_HELP); m_hHelpDisabledCursor = AfxGetApp()->LoadCursor(IDC_CURSOR_DISABLED_HELP); m_pub_bUnloadedModelsArePrepared = FALSE; m_pub_bWatchWindowIsVisible = FALSE; m_pub_hWatchIcon_Field = AfxGetApp()->LoadIcon(IDI_CAR_WATCH_FIELD); m_pub_hWatchIcon_Actor = AfxGetApp()->LoadIcon(IDI_CAR_WATCH_ACTOR); m_pub_hWatchIcon_MS = AfxGetApp()->LoadIcon(IDI_CAR_WATCH_MS); m_bDisplayActor = FALSE; m_pLoadedModel = NULL; //Other init. m_fn_vInitialize(); } //**************************************************************************** EdActors_MyDocument::~EdActors_MyDocument() { //Deletes list of enum descriptors POSITION pos = m_clListOfEnumDescriptors.GetHeadPosition(); while ( pos != NULL ) delete (m_clListOfEnumDescriptors.GetNext(pos)); //Deletes list of mask descriptors pos = m_clListOfMasksDescriptors.GetHeadPosition(); while ( pos != NULL ) delete (m_clListOfMasksDescriptors.GetNext(pos)); //Deletes editor Instances and Models // delete m_pclActorsList; // delete m_pclModelsList; m_fn_bWriteIniFile(); //CPA2 Stegaru Cristian 98-05 m_clUnloadedAlwaysList.DeleteAllObjects (); //End CPA2 Stegaru Cristian 98-05 } //**************************************************************************** //Extra init. void EdActors_MyDocument::m_fn_vInitialize() { //Constructs the list of Enum desciptors m_fn_vConstructListOfEnumDescriptors(); //Constructs the list of Mask desciptors m_fn_vConstructListOfMaskDescriptors(); //Fills the mini-structure list (controls) m_fn_vFillMiniStructureList(); //Init. the INI file name m_csIniFileName = M_GetMainApp()->m_csEditorDataPath + "Objects\\Actors\\" + C_szActorsIniFileName; //Reads INI file m_fn_bReadIniFile(); m_pri_fn_bLoadDimensions(); //HelpFilename m_csHelpFileNameAndPath = M_GetMainApp()->m_csEditorDataPath + CString("Objects\\Actors\\Help\\Actors.hlp >Normale"); //-----------------IR------------------------- m_csBrainHelpFileNameAndPath= M_GetMainApp()->m_csEditorDataPath + CString("Objects\\Actors\\Help\\EdIRfr.hlp"); m_bDesignerVarEditorIsVisible = TRUE; //-------------------------------------------- //Editor's data m_csModelsBitmapsPath = CString("Objects\\Actors\\Models\\Actors\\"); m_csModelsBitmapsCompletePath = M_GetMainApp()->m_csEditorDataPath + m_csModelsBitmapsPath; m_csModelsBitmapsPathForGenDoors = CString("Objects\\Actors\\Models\\GenDoors\\"); m_csModelsBitmapsCompletePathForGenDoors = M_GetMainApp()->m_csEditorDataPath + m_csModelsBitmapsPathForGenDoors; } /////////////////////////////////// // Models and Instances handling // /////////////////////////////////// //*************************************************************************** void EdActors_MyDocument::m_fn_vCreateCopiesOfActor(CPA_Actor *_pclSourceActor) { EdActors_CopyDialog dial(_pclSourceActor, &g_oBaseFrame); if ( dial.DoModal() == IDOK ) { if ( _pclSourceActor->m_fn_bIsAModel() ) m_fn_vCreateCopiesOfModel(_pclSourceActor, dial.m_lCopiesNumber, dial.m_csNewName); else if ( _pclSourceActor->m_fn_bIsAnInstance() ) m_fn_vCreateCopiesOfInstance(_pclSourceActor, dial.m_lCopiesNumber, dial.m_csNewName); } } ///////////////////// // Models handling // ///////////////////// //*************************************************************************** //Called to create a model and add it in the list of models CPA_SuperObject *EdActors_MyDocument::m_fn_pclCreateModel(CString &r_csModelBitmapName) { CPA_SuperObject *pclAddedModel = NULL; EdActors_ModelCreationDialog dial(&g_oBaseFrame); if ( dial.DoModal() == IDOK ) { pclAddedModel = dial.m_fn_pclGetNewModel(); r_csModelBitmapName = dial.m_fn_csGetBitmapName(); //Displays Model m_fn_vDisplayActor(((CPA_Actor *)(pclAddedModel->GetObject()))->m_fn_pclGetEditorActor(), ED_ACTORS_eModeOfActorSelection_Unknown); } return pclAddedModel; } //*************************************************************************** //Called to create a model and loads its data CPA_SuperObject *EdActors_MyDocument::m_fn_pclCreateModelForLoad(CString csName, CPA_Actor *pclEditorActor /*= NULL*/) { CPA_SuperObject *pclAddedModel = NULL; //Creates all needed objects /////////////////////////////// //Creates Editor's Actor CPA_Actor *pclNewEditorActor; if ( pclEditorActor == NULL ) pclNewEditorActor = new CPA_Actor(NULL, NULL, g_c_csActorModelType, NULL, NULL, NULL, csName); else pclNewEditorActor = pclEditorActor; //////////////////////////////////////////////////////// //Creates a SuperObject pclAddedModel = g_pclInterface->GetInterface()->GetNewSuperObject(E_ss_NoSave, C_Protected, "", ""); pclNewEditorActor->m_pub_fn_vSetSuperObject(pclAddedModel); pclAddedModel->SetModelName(pclNewEditorActor->GetName()); pclAddedModel->SetObject(pclNewEditorActor); //PROVISOIRE... pclAddedModel->GetStruct()->hLocalMatrix = (GEO_tdxHandleToMatrix)malloc(sizeof(POS_tdstCompletePosition)); POS_fn_vSetIdentityMatrix(pclAddedModel->GetStruct()->hLocalMatrix); return pclAddedModel; } //*************************************************************************** // Adds a (loaded) Model in the list void EdActors_MyDocument::m_fn_vAddLoadedModelInList(EdActors_EditorActorModel *pclModel, BOOL bMustAddInGlobalList /*= TRUE*/) { if ( ( pclModel != NULL ) && ( pclModel->m_pclActor->m_pub_fn_bCanBeInstantiated() ) ) { EDT_Model *pclNewEDTModel = NULL; CString csBitmapName; if ( pclModel->m_pclActor->m_fn_bIsAGenDoor() ) csBitmapName = m_csModelsBitmapsPathForGenDoors + pclModel->m_fn_csGetBitmapName(); else csBitmapName = m_csModelsBitmapsPath + pclModel->m_fn_csGetBitmapName(); //Adds in the Models Window pclNewEDTModel = new EDT_Model( g_pclInterface, M_MAKECHAR(g_c_csActorType), M_MAKECHAR(pclModel->m_fn_csGetActorName()), (char *)LPCTSTR(csBitmapName), g_pclInterface->GetInterface() ); g_pclInterface->GetInterface()->fn_bAddANewModel( pclNewEDTModel, M_MAKECHAR(g_c_csActorModelType), g_pclInterface); //Adds in internal list g_pclInterface->m_stListModels.AddTail(pclModel->m_pclActor->m_pub_fn_pclGetSuperObject()); } } //*************************************************************************** //Called to remove a Model from its list, and deletes corresponding Instances void EdActors_MyDocument::m_fn_vDeleteModel(CPA_Actor *_pclModelToDelete) { ERROR_ASSERT( _pclModelToDelete != NULL ); //Deletes all Instances of Model CPA_Actor *pclCurrentInstance; POSITION pos = _pclModelToDelete->m_fn_pclGetEditorModel()->m_clInstancesList.GetHeadPosition(); while ( pos != NULL ) { pclCurrentInstance = _pclModelToDelete->m_fn_pclGetEditorModel()->m_clInstancesList.GetNext(pos)->m_pclActor; } } //*************************************************************************** //Called to create single or multiple copy of a model void EdActors_MyDocument::m_fn_vCreateCopiesOfModel(CPA_Actor *_pclModelToCopy, long _lCopiesNumber, CString _csNewName) { CPA_Actor *pclAddedModel; CString csCurrentName = _csNewName; long c_lI; for (c_lI = 0; c_lI < _lCopiesNumber; c_lI ++) { if ( _lCopiesNumber > 1 ) csCurrentName.Format("%s_%ld", LPCTSTR(_csNewName), c_lI); CPA_SuperObject *pclSuperObject = g_pclInterface->GetInterface()->GetNewSuperObject(E_ss_NoSave, C_Protected, "", ""); pclAddedModel = new CPA_Actor(_pclModelToCopy, pclSuperObject, csCurrentName); pclAddedModel->m_fn_vMakeGenDoor(_pclModelToCopy->m_fn_bIsAGenDoor()); pclSuperObject->SetModelName(pclAddedModel->GetName()); pclSuperObject->SetObject(pclAddedModel); //PROVISOIRE... pclSuperObject->GetStruct()->hLocalMatrix = (GEO_tdxHandleToMatrix)malloc(sizeof(POS_tdstCompletePosition)); POS_fn_vSetIdentityMatrix(pclSuperObject->GetStruct()->hLocalMatrix); //Adds in Models Window m_fn_vAddLoadedModelInList(pclAddedModel->m_fn_pclGetEditorModel(), FALSE); } //Displays last created Model m_fn_vDisplayActor(pclAddedModel->m_fn_pclGetEditorActor(), ED_ACTORS_eModeOfActorSelection_Unknown); } //////////////////////// // Instances handling // //////////////////////// //*************************************************************************** //Called to create single or multiple instances from a model BOOL EdActors_MyDocument::m_fn_bCanInstantiateModel(CString csSourceModelName, CString &r_csRequiredName) { //Remove bloc-comments for programm to ask to user a Name for the Instance BOOL bReturnValue = FALSE; //Gets the default name if ( m_bAskForNewInstanceName ) { CString csDefaultName; CPA_List clList; g_pclInterface->GetMainWorld()->fn_lFindObjects(&clList, "", C_szActorInstanceTypeName,NO_CRITERIA); if ( clList.GetCount() > 0 ) csDefaultName = ((CPA_Actor *)clList.GetHead())->GetDefaultValidName(csSourceModelName + "_I"); //ANNECY BBB: new name is based on the model's EdActors_InstanceCreationDialog dial(csSourceModelName, csDefaultName, &g_oBaseFrame); if ( dial.DoModal() == IDOK ) { r_csRequiredName = dial.m_fn_csGetNewInstanceName(); bReturnValue = TRUE; } } else bReturnValue = TRUE; return bReturnValue; } //*************************************************************************** //Called to create a model and loads its data CPA_SuperObject *EdActors_MyDocument::m_fn_pclCreateInstanceForLoad(CString csName, EdActors_tdhHandleToActor hActor) { CPA_SuperObject *pclNewInstance = NULL; //Creates all needed objects /////////////////////////////// //Creates Editor's Actor CPA_Actor *pclNewEditorActor = new CPA_Actor(hActor, NULL, g_c_csActorType, NULL, NULL, NULL, csName); //////////////////////////////////////////////////////// //Creates a SuperObject pclNewInstance = g_pclInterface->GetInterface()->GetNewSuperObject( E_ss_NoSave, C_Protected, "", ""); pclNewEditorActor->m_pub_fn_vSetSuperObject(pclNewInstance); pclNewInstance->SetModelName(pclNewEditorActor->GetName()); pclNewInstance->SetObject(pclNewEditorActor); //PROVISOIRE... pclNewInstance->GetStruct()->hLocalMatrix = (GEO_tdxHandleToMatrix)malloc(sizeof(POS_tdstCompletePosition)); POS_fn_vSetIdentityMatrix(pclNewInstance->GetStruct()->hLocalMatrix); return pclNewInstance; } //*************************************************************************** //Called to create single or multiple copy of an existing instance void EdActors_MyDocument::m_fn_vCreateCopiesOfInstance( CPA_Actor *_pclInstanceToCopy, long _lCopiesNumber, CString _csNewName) { EdActors_InformationDialog InfoDial(&g_oBaseFrame, "Not available yet ..."); InfoDial.DoModal(); } //*************************************************************************** //Called to remove an Instance from the lists ( <--> DO for Delete) void EdActors_MyDocument::m_fn_vDeleteInstance(CPA_Actor *pclInstanceToDelete) { ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Deleting an Instance", "EdActors_MyDocument::m_fn_vDeleteInstance(...)", E_ERROR_GRAVITY_FATAL, "The Actor is not an Instance, but a Model !"); ERROR_ASSERT( pclInstanceToDelete->m_fn_bIsAnInstance() ); if ( !pclInstanceToDelete->m_fn_bIsAnAlways() ) m_clInstancesList.fn_bRemoveObject(pclInstanceToDelete); //Removes Motor Actor from Sector list HIE_tdxHandleToSuperObject hCharacter = pclInstanceToDelete->m_pub_fn_hGetMotorSuperObject(); fn_vRemoveObjectInSectorList(hCharacter); //Removes Instance from its Model list of Instances if ( !pclInstanceToDelete->m_fn_bIsAnAlways() ) { EdActors_EditorActorModel *pclEdModel = (EdActors_EditorActorModel *)pclInstanceToDelete->m_fn_pclGetModel()->m_fn_pclGetEditorActor(); EdActors_EditorActorInstance *pclEdInstance = (EdActors_EditorActorInstance *)pclInstanceToDelete->m_fn_pclGetEditorActor(); pclEdModel->m_fn_vRemoveFromInstancesList(pclEdInstance); //Removes from List pclInstanceToDelete->fn_bUnValidate(); //Notifies if (!pclInstanceToDelete->m_pub_fn_bIsCommon()) pclInstanceToDelete->fn_vNotifyUnSave(); //Sends a notification for the Level to be saved m_fn_vNotifyLevel(pclInstanceToDelete, FALSE); // ANNECY MT 13-02-97 { // Removes from Coherence Manager g_oCoherenceManager.m_fn_vDeleteObject(pclInstanceToDelete); // END ANNECY MT } } //Updates DialogList m_pclDialogList->fn_vUpdateSelection(E_lrm_ReinitList); //If Actors is edited, changes current actor if ( m_pub_fn_bCurrentModeIsInstance() ) { if ( m_pclCurrentInstance == pclInstanceToDelete->m_fn_pclGetEditorActor() ) { m_pclCurrentInstance = NULL; m_fn_vDisplayActor(m_pclCurrentModel, ED_ACTORS_eModeOfActorSelection_Unknown); } } } //*************************************************************************** //Called to re-put an Instance in the lists (<--> UNDO for Delete) void EdActors_MyDocument::m_fn_vUndeleteInstance(CPA_Actor *pclInstanceToUndelete) { ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Undeleting an Instance", "EdActors_MyDocument::m_fn_vUndeleteInstance(...)", E_ERROR_GRAVITY_FATAL, "The Actor is not an Instance, but a Model !"); ERROR_ASSERT( pclInstanceToUndelete->m_fn_bIsAnInstance() ); m_clInstancesList.fn_bAddObject(pclInstanceToUndelete); //Puts Motor Actor in Sector list HIE_tdxHandleToSuperObject hCharacter = pclInstanceToUndelete->m_pub_fn_hGetMotorSuperObject(); struct MTH3D_tdstVector_ tdstVector; POS_fn_vGetTranslationVector(fn_p_st3dDataGetMatrix(M_GetMSHandle(hCharacter,3dData)), &tdstVector); fn_vSectInfoInitForSingleCharacter(hCharacter, &tdstVector); //Adds Instance to its Model list of Instances EdActors_EditorActorModel *pclEdModel = (EdActors_EditorActorModel *)pclInstanceToUndelete->m_fn_pclGetModel()->m_fn_pclGetEditorActor(); EdActors_EditorActorInstance *pclEdInstance = (EdActors_EditorActorInstance *)pclInstanceToUndelete->m_fn_pclGetEditorActor(); pclEdModel->m_fn_vAddToInstancesList(pclEdInstance); //Puts in List pclInstanceToUndelete->fn_bValidate(); //Updates DialogList m_pclDialogList->fn_vUpdateSelection(E_lrm_ReinitList); //Notifies if (!pclInstanceToUndelete->m_pub_fn_bIsCommon()) pclInstanceToUndelete->fn_vNotifyRestore(); //Sends a notification for the Level to be saved m_fn_vNotifyLevel(pclInstanceToUndelete); // ANNECY MT 13-02-97 { // Removes from Coherence Manager g_oCoherenceManager.m_fn_vDestroyObject(pclInstanceToUndelete); // END ANNECY MT } } //*************************************************************************** //Called to set inital position of an actor as its actual's one void EdActors_MyDocument::m_fn_vSetCurrentActorPositionAsInitial(CPA_Actor *_pclActor) { HIE_tdxHandleToSuperObject hActorSO = _pclActor->m_pub_fn_hGetMotorSuperObject(); //Sets the Initial Matrix as the Current one (in motor Actor) memcpy( fn_p_st3dDataGetMatrixInit(M_GetMSHandle(hActorSO,3dData)), fn_p_st3dDataGetMatrix(M_GetMSHandle(hActorSO,3dData)), sizeof(POS_tdstCompletePosition) ); m_fn_vNotifyLevel(_pclActor); //If Actor is 'Ed', makes the same transformation to the Camera if ( MC_fn_ucIsCharacterInMainCharacterList(hActorSO) == 1 ) { //Gets camera character HIE_tdxHandleToSuperObject hCameraSO = CAM_fn_hGetActiveCamera(CAM_e_MainViewport); memcpy( fn_p_st3dDataGetMatrixInit(M_GetMSHandle(hCameraSO,3dData)), fn_p_st3dDataGetMatrix(M_GetMSHandle(hCameraSO,3dData)), sizeof(POS_tdstCompletePosition) ); CPA_Actor *pclCamera = (CPA_Actor *)g_pclInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(hCameraSO->hLinkedObject.p_Void, C_szActorInstanceTypeName);; m_fn_vNotifyLevel(pclCamera); EDACTORS_fn_vGiveProgressInfo("Camera initial position updated because Ed initial position changed"); } } ///////////////////// // Editor's aspect // ///////////////////// //*************************************************************************** // Checks if the mode is the right one to display this actor, // else changes it before editing new Actor (Instance or Model) void EdActors_MyDocument::m_fn_vDisplayActor(EdActors_EditorActor *pclNewSelectedActor, ED_ACTORS_tdeModeOfActorSelection _tdeSelectionType) { if ( !g_pclInterface->GetInterface()->fn_bIsLoadingWorld() ) { AfxGetApp()->DoWaitCursor(1); //ANNECY CB m_bDisplayActor = TRUE; m_pclMiniStrucView->ShowWindow(FALSE); //END //Checks if right Mode is on, else changes it if ( pclNewSelectedActor != NULL ) { //If new Actor is an Always Model, and we are not in Always mode if ( ( pclNewSelectedActor->m_pclActor->m_fn_bIsAnAlways() ) && (!pclNewSelectedActor->m_pclActor->m_fn_bIsAGenDoor()) /*&& ( !m_pub_fn_bCurrentModeIsAlwaysModel() )*/ ) m_fn_vSetMode(ED_ACTORS_eDisplayMode_AlwaysModel, pclNewSelectedActor->m_pclActor); //If new Actor is not an Always Model if ( !pclNewSelectedActor->m_pclActor->m_fn_bIsAnAlways() ) { //If current Mode was Always, forces change of Mode if ( m_pub_fn_bCurrentModeIsAlwaysModel() ) { if ( pclNewSelectedActor->m_fn_bIsAnInstance() ) m_fn_vSetMode(ED_ACTORS_eDisplayMode_Instance); //else it's a Model else m_fn_vSetMode(ED_ACTORS_eDisplayMode_Model); } else { if ( (pclNewSelectedActor->m_fn_bIsAnInstance()) && (m_pub_fn_bCurrentModeIsModel()) ) m_fn_vSetMode(ED_ACTORS_eDisplayMode_Instance); else if ( (!pclNewSelectedActor->m_fn_bIsAnInstance()) && (!m_pub_fn_bCurrentModeIsModel()) ) m_fn_vSetMode(ED_ACTORS_eDisplayMode_Model); } } } //Now Mode is the right one --> Displays the Actor if ( pclNewSelectedActor != m_pclSelectedActor ) { EdActors_EditorActor *pclOldSelectedActor = m_pclSelectedActor; //Selects new Actor m_pclSelectedActor = pclNewSelectedActor; if ( m_pub_fn_bCurrentModeIsInstance() || m_pub_fn_bCurrentModeIsAlwaysModel() ) { m_pclCurrentInstance = (EdActors_EditorActorInstance *)pclNewSelectedActor; if(m_pclCurrentInstance) { m_pclCurrentModel = (EdActors_EditorActorModel *)m_pclCurrentInstance->m_fn_pclGetModel()->m_fn_pclGetEditorActor(); m_pclCurrentFamily = m_pclCurrentModel->m_pclActor->m_pub_fn_pclGetFamily(); } } else if ( m_pub_fn_bCurrentModeIsModel() ) { m_pclCurrentModel = (EdActors_EditorActorModel *)pclNewSelectedActor; if(m_pclCurrentModel) m_pclCurrentFamily = m_pclCurrentModel->m_pclActor->m_pub_fn_pclGetFamily(); } if ( m_pclSelectedActor != NULL ) { //Type matches current mode ?? ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Displaying an Actor", "EdActors_MyDocument::m_fn_vDisplayActor(...)", E_ERROR_GRAVITY_FATAL, "Trying to display an Instance in Model mode, or reverse"); ERROR_ASSERT ( ( ( m_pclSelectedActor->m_fn_bIsAnInstance() ) && ( m_pub_fn_bCurrentModeIsInstance() || m_pub_fn_bCurrentModeIsAlwaysModel() ) ) || ( ( !m_pclSelectedActor->m_fn_bIsAnInstance() ) && ( m_pub_fn_bCurrentModeIsModel() ) ) ); m_fn_vSetPointersForSelectedActor(); //Sets current list (common MS list) for editor AND Actor char cListToSelect = m_pclSelectedActor->m_fn_ucGetCurrentMSListIndex(); if ( !m_bRestoreGroup ) if ( pclOldSelectedActor != NULL ) cListToSelect = pclOldSelectedActor->m_fn_ucGetCurrentMSListIndex(); m_fn_vSetCurrentList(cListToSelect, FALSE); //Refreshes controls (Read Only / Read Write) if ( m_pub_fn_bCurrentModeIsInstance() || m_pub_fn_bCurrentModeIsAlwaysModel() ) { m_fn_vUpdateControlsForInstance(); //Selects in 3D View, if not already done if ( _tdeSelectionType != ED_ACTORS_eModeOfActorSelection_InHierarchy ) { g_pclInterface->GetInterface()->fn_vCancelCurrentSelection(); g_pclInterface->GetInterface()->fn_vAddSelectedObject(m_pclSelectedActor->m_pclActor->m_pub_fn_pclGetSuperObject()); } } else if ( m_pub_fn_bCurrentModeIsModel() ) { m_fn_vUpdateControlsForModel(); } } else { m_fn_vSetPointersForSelectedActor(); //Default setting m_fn_vSetCurrentList(1, FALSE); } if ( m_pclActorsView != NULL ) m_pclActorsView->m_fn_vDisplayActor(m_pclSelectedActor); m_pclMiniStrucView->m_fn_vUpdateTree(); //Updates display in Dialog List if ( ( _tdeSelectionType != ED_ACTORS_eModeOfActorSelection_InListDialog ) && ( _tdeSelectionType != ED_ACTORS_eModeOfActorSelection_InTreeView ) ) g_pclInterface->m_pub_fn_vSetSelectionInDialogList((pclNewSelectedActor != NULL) ? pclNewSelectedActor->m_pclActor : NULL); } //-----------------IR------------------------- if ( ((CButton *)m_pclActorsView->GetDlgItem(IDC_CHECK_IA))->GetCheck() ) m_fn_vDisplayActorIA(); //-------------------------------------------- //ANNECY CB m_pclMiniStrucView->ShowWindow(TRUE); m_bDisplayActor = FALSE; //END AfxGetApp()->DoWaitCursor(-1); } } //-----------------IR------------------------- //*************************************************************************** void EdActors_MyDocument::m_fn_vDisplayActorIA() { if ( m_pub_fn_bCurrentModeIsInstance() || m_pub_fn_bCurrentModeIsAlwaysModel() ) { if(m_pclCurrentInstance) { EdActors_EditorActorModel *pclModel = (EdActors_EditorActorModel *)m_pclCurrentInstance->m_fn_pclGetModel()->m_fn_pclGetEditorActor(); EDAC_fn_vShowBrain(pclModel->m_pclBrain); if(m_pclDesignerVariablesView) { EdActors_EditorActorModel *pclModel = (EdActors_EditorActorModel *)m_pclCurrentInstance->m_fn_pclGetModel()->m_fn_pclGetEditorActor(); EDAC_fn_vDesignerVariableView_UpdateControls(m_pclDesignerVariablesView,&(pclModel->m_clListOfDesignerVariableControl)); EDAC_fn_vDesignerVariableView_UpdateDisplayWithValues(m_pclDesignerVariablesView,m_pclCurrentInstance->m_pclListOfDesignerVariableType); } } } else if ( m_pub_fn_bCurrentModeIsModel() ) { if(m_pclCurrentModel) { EDAC_fn_vShowBrain(m_pclCurrentModel->m_pclBrain); if(m_pclDesignerVariablesView) { EDAC_fn_vDesignerVariableView_UpdateControls(m_pclDesignerVariablesView,&(m_pclCurrentModel->m_clListOfDesignerVariableControl)); EDAC_fn_vDesignerVariableView_UpdateDisplayWithValues(m_pclDesignerVariablesView,m_pclCurrentModel->m_pclListOfDesignerVariableType); } } } } //-------------------------------------------- //*************************************************************************** //Indicates the current display mode ED_ACTORS_tdeDisplayMode EdActors_MyDocument::m_pub_fn_tdeGetCurrentDisplayMode() { return m_eCurrentDisplayMode; } //*************************************************************************** BOOL EdActors_MyDocument::m_pub_fn_bCurrentModeIsInstance() { return ( m_eCurrentDisplayMode == ED_ACTORS_eDisplayMode_Instance ); } //*************************************************************************** BOOL EdActors_MyDocument::m_pub_fn_bCurrentModeIsModel() { return ( m_eCurrentDisplayMode == ED_ACTORS_eDisplayMode_Model ); } //*************************************************************************** BOOL EdActors_MyDocument::m_pub_fn_bCurrentModeIsAlwaysModel() { return ( m_eCurrentDisplayMode == ED_ACTORS_eDisplayMode_AlwaysModel ); } //*************************************************************************** //Called to update editor (and watch) currently edited values void EdActors_MyDocument::m_fn_vUpdateEditedValues() { //Updates editor datas //PROVISOIRE... m_pclActorsView->m_fn_vDisplayActor(m_pclSelectedActor); //Updates Watch Window datas OAC_fn_vUpdateAllDataInWatchWindow(); } //*************************************************************************** //Sets the current mode : Instances if parameter is TRUE, else Model mode void EdActors_MyDocument::m_fn_vSetMode(ED_ACTORS_tdeDisplayMode _eNewMode, CPA_Actor *_pclNewActor /*= NULL*/) { BOOL bModeChanged = (_eNewMode != m_eCurrentDisplayMode); ED_ACTORS_tdeDisplayMode tdeOldMode = m_eCurrentDisplayMode; m_eCurrentDisplayMode = _eNewMode; //Sets right lists if ( ( m_pub_fn_bCurrentModeIsInstance() ) || ( m_pub_fn_bCurrentModeIsModel() ) ) { if ( m_pub_fn_bCurrentModeIsInstance() ) m_pclCurrentActorsList = &m_clInstancesList; else m_pclCurrentActorsList = &m_clModelsList; if ( tdeOldMode == ED_ACTORS_eDisplayMode_AlwaysModel && bModeChanged) { //Closes Character View CPA_DLLBase *p_clT3D_Dll = g_pclInterface->GetMainWorld()->GetToolDLLWithName(C_szDLLTool3DName); if ( p_clT3D_Dll ) p_clT3D_Dll->OnQueryClose(g_pclInterface, 0, 0); } } else if ( m_pub_fn_bCurrentModeIsAlwaysModel() ) { m_pclCurrentActorsList = &m_clAlwaysList; //Launches Chraracter View CPA_DLLBase *p_clT3D_Dll = g_pclInterface->GetMainWorld()->GetToolDLLWithName(C_szDLLTool3DName); if ( p_clT3D_Dll ) { if ( _pclNewActor != NULL ) { CPA_SuperObject *pclEdSO = _pclNewActor->m_pub_fn_pclGetSuperObject(); p_clT3D_Dll->OnQueryOpen(g_pclInterface, C_wTool3D_Char, (long)pclEdSO); } } } else m_pclCurrentActorsList = NULL; } //*************************************************************************** //Called to set the current MS List void EdActors_MyDocument::m_fn_vSetCurrentList(char cChoice, BOOL bMustRepaint) { //Sets selected actor's list if ( m_pclSelectedActor != NULL ) { //Hides old list of MS if ( m_pclCurrentMiniStructureList != NULL ) { POSITION OldListPos = m_pclCurrentMiniStructureList->GetHeadPosition(); while ( OldListPos != NULL ) m_pclCurrentMiniStructureList->GetNext(OldListPos)->m_fn_vHideAllControls(); } m_pclSelectedActor->m_fn_vSetCurrentMSListIndex(cChoice); } m_pclCurrentMiniStructureList = m_clListOfMSLists.m_fn_pclGetListFromIndex(cChoice); //Shows new list of MS if ( m_pclCurrentMiniStructureList != NULL ) { POSITION NewListPos = m_pclCurrentMiniStructureList->GetHeadPosition(); while ( NewListPos != NULL ) m_pclCurrentMiniStructureList->GetNext(NewListPos)->m_fn_vShowAllControls(); } if ( m_pclActorsView != NULL ) { //Updates buttons m_pclActorsView->m_fn_vUpdatePagesButtons(cChoice); //Redraws all tree if ( bMustRepaint ) m_pclMiniStrucView->m_fn_vUpdateTree(); } } //*************************************************************************** //Called to update controls when current actor's name has changed void EdActors_MyDocument::m_fn_vUpdateName() { //Updates static name m_pclActorsView->m_pclActorNameStatic->m_fn_vSetTextToDisplay(m_pclSelectedActor->m_fn_csGetActorName()); m_pclActorsView->m_pclActorNameStatic->InvalidateRect(NULL); } //*************************************************************************** void EdActors_MyDocument::m_fn_vUpdateControlsForInstance() { if ( m_pclSelectedActor != NULL ) { POSITION pos = m_clListOfMSLists.GetHeadPosition(); while (pos != NULL ) m_clListOfMSLists.GetNext(pos)->m_fn_vUpdateControlsForInstance(); //CPA2 Stegaru Cristian 98-05 ASSERT (m_pclActorsView); //enable it BOOL bEnabled = !m_pclSelectedActor->m_pclActor->m_fn_bIsAnAlways() /*&& !m_pclSelectedActor->m_pclActor->m_fn_bIsTheWorldActor()*/; m_pclActorsView->GetDlgItem(IDC_CHECK_ALWAYS_ACTIVE)->EnableWindow(bEnabled); //check it ((CButton *)m_pclActorsView->GetDlgItem(IDC_CHECK_ALWAYS_ACTIVE))->SetCheck (m_pclSelectedActor->m_pclActor->m_pub_fn_bIsAlwaysActive() ? 1 : 0); //End CPA2 Stegaru Cristian 98-05 // ANNECY MT - 19/11/98 { bEnabled = !m_pclSelectedActor->m_pclActor->m_fn_bIsAnAlways(); m_pclActorsView->GetDlgItem(IDC_CHECK_IN_ALL_SUBMAPS)->EnableWindow(bEnabled); //check it ((CButton *)m_pclActorsView->GetDlgItem(IDC_CHECK_IN_ALL_SUBMAPS))->SetCheck (m_pclSelectedActor->m_pclActor->m_pub_fn_bIsInAllSubMaps() ? 1 : 0); // END ANNECY MT } } } //*************************************************************************** void EdActors_MyDocument::m_fn_vUpdateControlsForModel() { if ( m_pclSelectedActor != NULL ) { POSITION pos = m_clListOfMSLists.GetHeadPosition(); while (pos != NULL ) m_clListOfMSLists.GetNext(pos)->m_fn_vUpdateControlsForModel(); //CPA2 Stegaru Cristian 98-05 ASSERT (m_pclActorsView); //enable it m_pclActorsView->GetDlgItem(IDC_CHECK_ALWAYS_ACTIVE)->EnableWindow(FALSE); //End CPA2 Stegaru Cristian 98-05 } } //*************************************************************************** //Displays the given Actor, then shows the given Data void EdActors_MyDocument::m_fn_vShowData(EdActors_EditorActor *pclActor, CTL_Editor_Data *pclData) { //Searches for the right Page of MS EdActors_ActorMiniStructure *pclAMS = NULL; char cMSPage = pclActor->m_fn_cDoesActorOwnData(pclData, pclAMS); ERROR_ASSERT( cMSPage != -1 ); ERROR_ASSERT( pclAMS != NULL ); if ( (cMSPage != -1) && (pclAMS != NULL) ) { pclActor->m_fn_vSetCurrentMSListIndex(cMSPage); //Displays the Actor m_fn_vDisplayActor(pclActor, ED_ACTORS_eModeOfActorSelection_Unknown); //Highlites the Data m_pclCurrentMiniStructureList->m_fn_vHighliteData(pclData); } } //*************************************************************************** //Re-init. the MS with init. values void EdActors_MyDocument::m_fn_vReInitMiniStructure(EdActors_ActorMiniStructure *pclActorMS) { if ( pclActorMS->m_fn_bIsAllocated() ) { CTL_Editor_Data *pclData; POSITION pos = pclActorMS->m_pclDataList->GetHeadPosition(); while ( pos != NULL ) { pclData = pclActorMS->m_pclDataList->GetNext(pos); if ( pclData->m_fn_bHasAnInitialData() ) pclData->m_fn_vUpdateData(pclData->m_fn_pclGetAssociatedInitialData()); } } } //*************************************************************************** //Re-init. all MS with init. values void EdActors_MyDocument::m_fn_vReInitAllMiniStructures(EdActors_EditorActor *pclActor) { POSITION pos = pclActor->m_clListOfAMSLists.GetHeadPosition(); EdActors_ActorMiniStructureList *pclCurrentAMSList; while ( pos != NULL ) { pclCurrentAMSList = pclActor->m_clListOfAMSLists.GetNext(pos); EdActors_ActorMiniStructure *pclAMS; POSITION AMSpos = pclCurrentAMSList->GetHeadPosition(); while ( AMSpos != NULL ) { pclAMS = pclCurrentAMSList->GetNext(AMSpos); m_fn_vReInitMiniStructure(pclAMS); } } } //*************************************************************************** void EdActors_MyDocument::m_fn_vHideGenDoors() { CPA_Actor *pclActor; Position pos = m_clInstancesList.GetHeadPosition(); while ( pos != 0 ) { pclActor = (CPA_Actor *)m_clInstancesList.GetNext(pos); if ( pclActor->m_fn_bIsAGenDoor() ) { CString csMessage = "A geometric object is not correct (Actor is '" + pclActor->GetName() + "')."; ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,"Hiding Gen Doors before Engine mode", "EdActors_MyDocument::m_fn_vHideGenDoors(...)", E_ERROR_GRAVITY_FATAL, csMessage); ERROR_ASSERT( pclActor->m_fn_pclGetIsolatedSuperObject() != NULL ); pclActor->m_fn_pclGetIsolatedSuperObject()->Isolate(TRUE); } } } //*************************************************************************** void EdActors_MyDocument::m_fn_vShowGenDoors() { static s_bFirstPassForGenDoors = TRUE; CPA_Actor *pclActor; Position pos = m_clInstancesList.GetHeadPosition(); while ( pos != 0 ) { pclActor = (CPA_Actor *)m_clInstancesList.GetNext(pos); if ( pclActor->m_fn_bIsAGenDoor() && !s_bFirstPassForGenDoors ) { if ( pclActor->m_fn_pclGetIsolatedSuperObject() != NULL ) g_pclInterface->GetInterface()->fn_bInsertObjectInHierarchy(pclActor->m_fn_pclGetIsolatedSuperObject(), pclActor->m_pub_fn_pclGetSuperObject(), FALSE, FALSE, FALSE); } } s_bFirstPassForGenDoors = FALSE; } //*************************************************************************** void EdActors_MyDocument::m_fn_vLoadObjectTables() { AfxGetApp()->DoWaitCursor(1); EDACTORS_fn_vGiveProgressInfo("Actors Editor is looking for unloaded Object Tables..."); CPA_Actor *pclActor; HIE_tdxHandleToSuperObject hMotorSO; EditorObjectTable *pclCurrentOT; Position pos = m_clInstancesList.GetHeadPosition(); while ( pos != 0 ) { pclActor = (CPA_Actor *)m_clInstancesList.GetNext(pos); hMotorSO = pclActor->m_pub_fn_hGetMotorSuperObject(); pclCurrentOT = pclActor->m_pub_fn_pclGetCurrentObjectTable(); if ( pclCurrentOT != NULL ) { if ( !pclCurrentOT->fn_bIsAvailable() ) { ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,"Loading all used Object Tables before Motor mode", "EdActors_MyDocument::m_fn_vLoadObjectTables(...)", E_ERROR_GRAVITY_FATAL, "An Object Table could not be loaded"); ERROR_VERIFY( pclCurrentOT->GetEditor()->fn_bLoadBaseObject(pclCurrentOT) ); pclActor->m_pub_fn_vUpdateObjectTablesList(pclCurrentOT); fn_v3dDataSetCurrentObjectsTable(M_GetMSHandle(hMotorSO,3dData), (tdxHandleToObjectsTablesList)pclCurrentOT->GetData()); } } } EDACTORS_fn_vGiveProgressInfo(""); AfxGetApp()->DoWaitCursor(-1); } //*************************************************************************** //To Display or Hide the IA Editor void EdActors_MyDocument::m_fn_vActivateIAEditor(BOOL bActivate /*= TRUE*/) { BOOL bIsActive=((CButton *)m_pclActorsView->GetDlgItem(IDC_CHECK_IA))->GetCheck(); if(bActivate) { if((bIsActive!=1) || (g_pclInterface->fn_bIsCurrentEditor()==FALSE)) { ((CButton *)m_pclActorsView->GetDlgItem(IDC_CHECK_IA))->SetCheck(bActivate); m_pclActorsView->OnCheckModels(); } } else { if(bIsActive!=0) { ((CButton *)m_pclActorsView->GetDlgItem(IDC_CHECK_IA))->SetCheck(bActivate); m_pclActorsView->OnCheckModels(); } } } //*************************************************************************** void EdActors_MyDocument::m_fn_vNotifyLevel(CPA_Actor *pclCauseActor, BOOL bAddSection /*= TRUE*/, CString csActorsName /*= ""*/) { char a_256cBuffer[256]; ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Notifying a level ('.lvl' or '.alw') to be saved", "EdActors_MyDocument::m_fn_vNotifyLevel(...)", E_ERROR_GRAVITY_FATAL, "The Actor which caused this notification is not correct (pointer is NULL)"); ERROR_ASSERT( pclCauseActor != NULL ); CString csLevelFileName; if ( pclCauseActor->m_fn_bIsAnAlways() ) //Notifies "ALW" csLevelFileName = fn_zsGetActualLevelFilename(a_256cBuffer, C_ScriptAlwaysSuffixe); else //Notifies "LVL" csLevelFileName = fn_zsGetActualLevelFilename(a_256cBuffer, C_ScriptLevelSuffixe); CString csActionName = ( pclCauseActor->m_fn_bIsAnAlways() ) ? C_SectionLevelAlways : C_SectionLevelCharacters; CString csSectionName; if ( csActorsName.IsEmpty() ) csSectionName = csLevelFileName + '^' + csActionName + ':' + pclCauseActor->GetName(); else csSectionName = csLevelFileName + '^' + csActionName + ':' + csActorsName; SCR_tde_Ntfy_Action tdeNotificationType = bAddSection ? SCR_EA_Ntfy_AddOrRebuildSection : SCR_EA_Ntfy_DeleteIfExists; SCR_fn_v_SvL1_RegisterNotify( (char *)LPCTSTR(csSectionName), CPA_Actor::s_m_fn_vCallBackSaveActor, NULL, tdeNotificationType); //Notifies Actor (pb with the Initial State) if ( bAddSection && ((!pclCauseActor->m_fn_bIsAnAlways() && !pclCauseActor->m_pub_fn_bIsCommon()) || !pclCauseActor->fn_bSectionExists())) pclCauseActor->fn_vNotifySave(); } //********************************************************************************************** void EdActors_MyDocument::m_fn_vNotifyFixFile() { CString csGameDataPath(fn_szGetGameDataPath()); CString csFixFileName = csGameDataPath + "\\Game.fix"; CString csSectionName = csFixFileName + "^PreloadSectionInFix:Characters" ; SCR_fn_v_SvL1_RegisterNotify( (char *)LPCTSTR(csSectionName), EdActors_MyDocument::s_m_fn_vCallBackSaveFixFile, NULL, SCR_EA_Ntfy_AddOrRebuildSection); } //********************************************************************************************** //Data Paths void EdActors_MyDocument::m_fn_vComputeDataPaths() { //Gets Level Name CString csLevelName = m_fn_csGetLevelName(); m_pub_csCommonDataPath = CString(fn_szGetCharactersDataPath()); m_pub_csLevelDataPath = m_pub_csCommonDataPath; } //********************************************************************************************** //Data Paths CString EdActors_MyDocument::m_fn_csGetLevelName() { //PROVISOIRE... will call a motor function char a_256cBuffer[256]; CString csLevelExtension(C_ScriptAlwaysSuffixe); CString csLevelFileName = fn_zsGetActualLevelFilename(a_256cBuffer, C_ScriptAlwaysSuffixe); short wIndex = csLevelFileName.ReverseFind('\\'); if ( wIndex != -1 ) csLevelFileName = csLevelFileName.Right(csLevelFileName.GetLength() - wIndex - 1); CString csLevelName = csLevelFileName.Left(csLevelFileName.GetLength() - csLevelExtension.GetLength() - 1); return csLevelName; } //********************************************************************************************** void EdActors_MyDocument::m_pub_fn_vCheckAllInstancesForActionChange(CPA_Action *_pclChangedAction) { CPA_Family *pclFamilyWhichOwnsChangedAction = (CPA_Family *)_pclChangedAction->GetOwner(); ERROR_ASSERT( pclFamilyWhichOwnsChangedAction != NULL ); CPA_Actor *pclCurrentActor; Position pos = m_clInstancesList.GetHeadPosition(); while ( pos != 0 ) { pclCurrentActor = (CPA_Actor *)m_clInstancesList.GetNext(pos); if ( pclCurrentActor->m_pub_fn_pclGetFamily() == pclFamilyWhichOwnsChangedAction ) { if ( pclCurrentActor->m_pub_fn_pclGetCurrentAction() == _pclChangedAction ) pclCurrentActor->m_pub_fn_vSetCurrentState(_pclChangedAction->mfn_p_oGetDefaultState()); if ( pclCurrentActor->m_pub_fn_pclGetInitialAction() == _pclChangedAction ) pclCurrentActor->m_pub_fn_vSetInitialState(_pclChangedAction->mfn_p_oGetDefaultState(), TRUE); } } } //********************************************************************************************** void EdActors_MyDocument::m_pub_fn_vCheckAllActorsForObjectTableChange(EditorObjectTable *_pclAddedOT) { //Gets the owner Family CPA_Family *_pclParentFamily = (CPA_Family *)_pclAddedOT->GetOwner(); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Re_building the Enum Descriptor of Actors for the Object Tables, because an OT has been loaded", "EdActors_MyDocument::m_pub_fn_vCheckAllActorsForObjectTableChange()", E_ERROR_GRAVITY_INSTABLE, "Can't find the Family for the loaded Object Table"); ERROR_ASSERT( _pclParentFamily != NULL ); //Modifies the enum desc. in all concerned Actors //Instances CPA_Actor *pclCurrentActor; Position pos = m_clInstancesList.GetHeadPosition(); while ( pos != 0 ) { pclCurrentActor = (CPA_Actor *)m_clInstancesList.GetNext(pos); if ( pclCurrentActor->m_pub_fn_pclGetFamily() == _pclParentFamily ) pclCurrentActor->m_pub_fn_vConstructEnumDescriptorForObjectsTables(); } //Models pos = m_clModelsList.GetHeadPosition(); while ( pos != 0 ) { pclCurrentActor = (CPA_Actor *)m_clModelsList.GetNext(pos); if ( pclCurrentActor->m_pub_fn_pclGetFamily() == _pclParentFamily ) pclCurrentActor->m_pub_fn_vConstructEnumDescriptorForObjectsTables(); } //Always Models pos = m_clAlwaysList.GetHeadPosition(); while ( pos != 0 ) { pclCurrentActor = (CPA_Actor *)m_clAlwaysList.GetNext(pos); if ( pclCurrentActor->m_pub_fn_pclGetFamily() == _pclParentFamily ) pclCurrentActor->m_pub_fn_vConstructEnumDescriptorForObjectsTables(); } } //********************************************************************************************** void EdActors_MyDocument::m_pub_fn_vUpdateActorsEnumDescriptor() { CTL_Editor_EnumDescriptor *pclEnumDescriptor = m_clListOfEnumDescriptors.m_fn_pclGetEnumDescriptorByName(g_c_csActorsEnumDescriptorName); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptor to represent the List of Actors", "EdActors_MyDocument::m_pub_fn_vUpdateActorsEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the Enum Descriptor in the Document"); ERROR_ASSERT( pclEnumDescriptor != NULL ); //Empties Enum descriptor pclEnumDescriptor->m_fn_vEmptyList(); //Fills it CPA_Actor *pclCurrentActor; Position pos = m_clInstancesList.GetHeadPosition(); while ( pos != 0 ) { pclCurrentActor = (CPA_Actor *)m_clInstancesList.GetNext(pos); pclEnumDescriptor->m_fn_pclAddElement(pclCurrentActor->GetName(), (long)(pclCurrentActor->m_pub_fn_hGetMotorSuperObject())); } //Always adds a NULL target pclEnumDescriptor->m_fn_pclAddElement("No Target!", 0L); } //********************************************************************************************** void EdActors_MyDocument::m_pub_fn_vUpdatePartGenEnumDescriptor() { CTL_Editor_EnumDescriptor *pclEnumDescriptor = m_clListOfEnumDescriptors.m_fn_pclGetEnumDescriptorByName(g_c_csPartGenEnumDescriptorName); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptor to represent the List of Particle Generators", "EdActors_MyDocument::m_pub_fn_vUpdatePartGenEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the Enum Descriptor in the Document"); ERROR_ASSERT( pclEnumDescriptor != NULL ); //Empties Enum descriptor pclEnumDescriptor->m_fn_vEmptyList(); //Gets list CPA_BaseObjectList *pclList = g_pclInterface->GetMainWorld()->fn_p_oGetOriginalObjectList(C_szPartGenGeneratorName); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptor to represent the List of Particle Generators", "EdActors_MyDocument::m_pub_fn_vUpdatePartGenEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the list of Editor Particle Generators"); ERROR_ASSERT( pclList != NULL ); if ( pclList != NULL ) { //Fills it CPA_BaseObject *pclCurrentPG; Position pos = pclList->GetHeadPosition(); while ( pos != 0 ) { pclCurrentPG = pclList->GetNext(pos); pclEnumDescriptor->m_fn_pclAddElement(pclCurrentPG->GetName(), (long)(pclCurrentPG->GetData())); } } //Always adds a NULL target pclEnumDescriptor->m_fn_pclAddElement("No Part. Gen. !", 0L); } //********************************************************************************************** void EdActors_MyDocument::m_pub_fn_vUpdateGameMaterialsEnumDescriptor() { //Gets the Enum descriptor CTL_Editor_EnumDescriptor *pclGMatEnumDescriptor = m_clListOfEnumDescriptors.m_fn_pclGetEnumDescriptorByName(g_c_csGameMaterialEnumDescriptorName); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors for the Game Materials", "EdActors_MyDocument::m_pub_fn_vUpdateGameMaterialsEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the Enum Descriptors in the Document"); ERROR_ASSERT( pclGMatEnumDescriptor != NULL ); //Empties Enum descriptor pclGMatEnumDescriptor->m_fn_vEmptyList(); //Fills them (according to SO LinkTable) //Gets SO LinkTable SCR_tdst_Link_Table *p_tdstLinkTable = GMT_fn_p_stGetLinkTable(); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors for the Game Materials", "EdActors_MyDocument::m_pub_fn_vUpdateGameMaterialsEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the Game Materials Link Table"); ERROR_ASSERT( p_tdstLinkTable != NULL ); unsigned int uiPos = 0; SCR_tdst_Link_Value *p_stValue; /* Get first element of array */ SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stValue, SCR_M_st_Link_GetDynamicArray(p_tdstLinkTable) ) while( p_stValue != NULL ) /* p_sValue is NULL at the end of the array */ { /* Test current retrieved value */ if( SCR_M_e_Link_GetState(p_stValue) == SCR_ELS_Link_Initialized ) { GMT_tdxHandleToGameMaterial tdxGameMat = (GMT_tdxHandleToGameMaterial)SCR_M_ul_Link_GetValue(p_stValue); //Gets the Name for the Card CString csObjectName(SCR_M_p_sz_Link_GetKey(p_stValue)); char a_256cFileName[256]; char a_256cActionName[256]; char a_256cName[256]; SCR_fn_v_RdL0_SplitSectionName((char *)LPCTSTR(csObjectName), a_256cFileName, a_256cActionName, a_256cName); csObjectName = a_256cName; ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors for the Game Materials", "EdActors_MyDocument::m_pub_fn_vUpdateGameMaterialsEnumDescriptor()", E_ERROR_GRAVITY_WARNING, "Name of Game Material is empty"); ERROR_ASSERT( !csObjectName.IsEmpty() ); //Adds to the enum desc. pclGMatEnumDescriptor->m_fn_pclAddElement(csObjectName, (long)tdxGameMat); } /* Get next element */ uiPos++; SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stValue, SCR_M_st_Link_GetDynamicArray(p_tdstLinkTable) ) } //Always adds a NULL pointer pclGMatEnumDescriptor->m_fn_pclAddElement("No Material!", 0L); } //********************************************************************************************** void EdActors_MyDocument::m_pub_fn_vUpdateSectorsEnumDescriptor() { //Gets the Enum descriptor CTL_Editor_EnumDescriptor *pclSectorsEnumDescriptor = m_clListOfEnumDescriptors.m_fn_pclGetEnumDescriptorByName(g_c_csSectorsEnumDescriptorName); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors to represent the Sectors", "EdActors_MyDocument::m_pub_fn_vUpdateSectorsEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the Enum Descriptors in the Document"); ERROR_ASSERT( pclSectorsEnumDescriptor != NULL ); //Empties Enum descriptor pclSectorsEnumDescriptor->m_fn_vEmptyList(); //Fills them (according to SO LinkTable) //Gets SO LinkTable SCR_tdst_Link_Table *p_tdstLinkTable = HIE_fn_p_stGetSuperObjectLinkTable(); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors to represent the Sectors", "EdActors_MyDocument::m_pub_fn_vUpdateSectorsEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the Super Objects Link Table"); ERROR_ASSERT( p_tdstLinkTable != NULL ); unsigned int uiPos = 0; SCR_tdst_Link_Value *p_stValue; /* Get first element of array */ SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stValue, SCR_M_st_Link_GetDynamicArray(p_tdstLinkTable) ) while( p_stValue != NULL ) /* p_sValue is NULL at the end of the array */ { /* Test current retrieved value */ if( SCR_M_e_Link_GetState(p_stValue) == SCR_ELS_Link_Initialized ) { HIE_tdxHandleToSuperObject hSO = (HIE_tdxHandleToSuperObject)SCR_M_ul_Link_GetValue(p_stValue); if ( HIE_fn_ulGetSuperObjectType(hSO) == HIE_C_ulSector ) { //Gets the Name for the Card CString csObjectName(SCR_M_p_sz_Link_GetKey(p_stValue)); char a_256cFileName[256]; char a_256cActionName[256]; char a_256cName[256]; SCR_fn_v_RdL0_SplitSectionName((char *)LPCTSTR(csObjectName), a_256cFileName, a_256cActionName, a_256cName); csObjectName = a_256cName; ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors to represent the Sectors", "EdActors_MyDocument::m_pub_fn_vUpdateSectorsEnumDescriptor()", E_ERROR_GRAVITY_WARNING, "Name of SuperObject is empty"); ERROR_ASSERT( !csObjectName.IsEmpty() ); //Adds to the enum desc. pclSectorsEnumDescriptor->m_fn_pclAddElement(csObjectName, (long)hSO); } } /* Get next element */ uiPos++; SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stValue, SCR_M_st_Link_GetDynamicArray(p_tdstLinkTable) ) } //Always adds a NULL pointer pclSectorsEnumDescriptor->m_fn_pclAddElement("No Sector!", 0L); } //********************************************************************************************** void EdActors_MyDocument::m_pub_fn_vUpdateGraphEnumDescriptor() { //Gets the Enum descriptor CTL_Editor_EnumDescriptor *pclGraphEnumDescriptor = m_clListOfEnumDescriptors.m_fn_pclGetEnumDescriptorByName(g_c_csGraphEnumDescriptorName); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors for the Graph", "EdActors_MyDocument::m_pub_fn_vUpdateGraphEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the Enum Descriptors in the Document"); ERROR_ASSERT( pclGraphEnumDescriptor != NULL ); //Empties Enum descriptor // pclGraphEnumDescriptor->m_fn_vEmptyList(); //Fills them (according to SO LinkTable) //Gets SO LinkTable SCR_tdst_Link_Table *p_tdstLinkTable = WPG_fnp_Graph_GetLinkTable(); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors for the Graph", "EdActors_MyDocument::m_pub_fn_vUpdateGraphEnumDescriptor()", E_ERROR_GRAVITY_FATAL, "Can't find the Graphs Link Table"); ERROR_ASSERT( p_tdstLinkTable != NULL ); unsigned int uiPos = 0; SCR_tdst_Link_Value *p_stValue; /* Get first element of array */ SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stValue, SCR_M_st_Link_GetDynamicArray(p_tdstLinkTable) ) //Always adds a NULL pointer pclGraphEnumDescriptor->m_fn_pclAddElement("Reseau Dynamique", -1L); while( p_stValue != NULL ) /* p_sValue is NULL at the end of the array */ { /* Test current retrieved value */ if( SCR_M_e_Link_GetState(p_stValue) == SCR_ELS_Link_Initialized ) { WP_tdHandleOfGraph hGraph = (WP_tdHandleOfGraph)SCR_M_ul_Link_GetValue(p_stValue); //Gets the Name for the Card CString csObjectName(SCR_M_p_sz_Link_GetKey(p_stValue)); char a_256cFileName[256]; char a_256cActionName[256]; char a_256cName[256]; SCR_fn_v_RdL0_SplitSectionName((char *)LPCTSTR(csObjectName), a_256cFileName, a_256cActionName, a_256cName); csObjectName = a_256cName; ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Building the Enum Descriptors for the Graphs", "EdActors_MyDocument::m_pub_fn_vUpdateGraphEnumDescriptor()", E_ERROR_GRAVITY_WARNING, "Name of Graph is empty"); ERROR_ASSERT( !csObjectName.IsEmpty() ); //Adds to the enum desc. pclGraphEnumDescriptor->m_fn_pclAddElement(csObjectName, (long)hGraph); } /* Get next element */ uiPos++; SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stValue, SCR_M_st_Link_GetDynamicArray(p_tdstLinkTable) ) } //Always adds a NULL pointer pclGraphEnumDescriptor->m_fn_pclAddElement("Pas de Reseau", 0L); } //********************************************************************************************** void EdActors_MyDocument::m_pub_fn_vConstructListOfAlways() { //Using motor Actors Link Table //Uses LinkTables SCR_tdst_Link_Table *p_stLinkTable = &(g_st3DOSLinkTable.stCharacter); unsigned int uiPos = 0; SCR_tdst_Link_Value *p_stValue; /* Get first element of array */ SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stValue, SCR_M_st_Link_GetDynamicArray(p_stLinkTable) ) while( p_stValue != NULL ) /* p_sValue is NULL at the end of the array */ { /* Test current retrieved value */ if( SCR_M_e_Link_GetState(p_stValue) == SCR_ELS_Link_Initialized ) { EdActors_tdhHandleToActor hAlwaysActor = (EdActors_tdhHandleToActor)SCR_M_ul_Link_GetValue(p_stValue); if ( fn_ucIsAnAlwaysModel(hAlwaysActor) != 0 ) { //Gets the Name for the Card CString csAlwaysName(SCR_M_p_sz_Link_GetKey(p_stValue)); char a_256cFileName[256]; char a_256cActionName[256]; char a_256cName[256]; SCR_fn_v_RdL0_SplitSectionName((char *)LPCTSTR(csAlwaysName), a_256cFileName, a_256cActionName, a_256cName); csAlwaysName = a_256cName; ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,"Creating an Editor Always from Motor actor", "EdActors_MyDocument::m_pub_fn_vConstructListOfAlways()", E_ERROR_GRAVITY_FATAL, "No motor name for the Always"); ERROR_ASSERT( !csAlwaysName.IsEmpty() ); //Gets Family CString csFamilyName = fn_szFindFamilyTypeNameOfFamilyType(fn_otStandardGameGetFamilyType(hAlwaysActor->h_StandardGame)); CPA_Family *pclBaseFamily = (CPA_Family *)g_pclInterface->GetMainWorld()->fn_p_oFindObject(csFamilyName, C_szFamilyTypeName); //Gets Model CString csModelName = fn_szFindModelTypeNameOfModelType(fn_otStandardGameGetModelType(hAlwaysActor->h_StandardGame)); csModelName = csFamilyName + "\\" + csModelName + "\\" + csModelName; CPA_Actor *pclBaseModel = m_fn_pclLoadModel(csModelName); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,"Creating an Editor Always from Motor actor", "EdActors_MyDocument::m_pub_fn_vConstructListOfAlways()", E_ERROR_GRAVITY_FATAL, "Family is unknown"); ERROR_ASSERT( pclBaseFamily != NULL ); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,"Creating an Editor Always from Motor actor", "EdActors_MyDocument::m_pub_fn_vConstructListOfAlways()", E_ERROR_GRAVITY_FATAL, "Model is not correct"); ERROR_ASSERT( pclBaseModel != NULL ); //Creates Editor Super Object CPA_SuperObject *pclNewAlwaysSO = g_pclInterface->GetInterface()->GetNewSuperObject(E_ss_NoSave, C_Protected, "", ""); pclNewAlwaysSO->SetTypeSO(C_Dynamic); //Creates an Editor Actor CPA_Actor *pclNewAlwaysActor = new CPA_Actor( hAlwaysActor, NULL, g_c_csActorType, pclBaseModel, pclBaseFamily, pclNewAlwaysSO, csAlwaysName); //Sets Object pclNewAlwaysSO->SetObject(pclNewAlwaysActor); pclNewAlwaysActor->m_pub_fn_vSetSuperObject(pclNewAlwaysSO); // make always pclNewAlwaysActor->m_fn_vMakeAlways(TRUE); //Is in common directory ? CString csAlwaysCompleteName(SCR_M_p_sz_Link_GetKey(p_stValue)); pclNewAlwaysActor->m_pub_fn_vSetCommon(EDACTORS_fn_bIsFileInCommon(csAlwaysCompleteName), TRUE); //pclNewAlwaysActor->m_pub_fn_vSetAlwaysActive(fn_bGetIfCharacterIsInAlwaysActiveCharacterList(pEngineInstance), TRUE); pclNewAlwaysActor->m_pub_fn_vSetInFix(fn_bStdGameIsLoadedInFix(hAlwaysActor->h_StandardGame), TRUE); //Add graphical childs //Calls motor functions HIE_tdxHandleToSuperObject hMotorSO = (HIE_tdxHandleToSuperObject)pclNewAlwaysSO->GetData(); fn_vAddChildToSuperObject(hMotorSO, //Motor SuperObject M_MAKECHAR(pclNewAlwaysActor->m_pub_fn_pclGetFamily()->GetName()),//Family Name M_MAKECHAR(pclNewAlwaysActor->m_fn_pclGetModel()->GetName()), //Model Name M_MAKECHAR(pclNewAlwaysActor->GetName())); //Perso. Name //Builds editor objects pclNewAlwaysActor->m_pub_fn_vAddChildsFromEngineChilds(); } } /* Get next element */ uiPos++; SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stValue, SCR_M_st_Link_GetDynamicArray(p_stLinkTable) ) } } /////////////////////// // Private functions // /////////////////////// //********************************************************************************************** void EdActors_MyDocument::m_fn_vSetPointersForSelectedActor() { m_fn_vSetPointersForActor(m_pclSelectedActor); } //********************************************************************************************** void EdActors_MyDocument::m_fn_vSetPointersForActor(EdActors_EditorActor *pclActor) { //Sets pointers for all lists if ( pclActor != NULL ) { POSITION AMSpos = pclActor->m_clListOfAMSLists.GetHeadPosition(); POSITION MSPos = m_clListOfMSLists.GetHeadPosition(); while ( MSPos != NULL ) m_fn_vSetPointers(m_clListOfMSLists.GetNext(MSPos), pclActor->m_clListOfAMSLists.GetNext(AMSpos)); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors,"Setting pointers on motor data for the newly selected actor", "EdActors_MyDocument::m_fn_vSetPointersForActor(...)", E_ERROR_GRAVITY_FATAL, "There are more ActorMS than controls"); ERROR_ASSERT( AMSpos == NULL ); } else { POSITION MSPos = m_clListOfMSLists.GetHeadPosition(); while ( MSPos != NULL ) m_fn_vSetPointers(m_clListOfMSLists.GetNext(MSPos), NULL); } } //********************************************************************************************** //Sets the pointer on a Data (the one of the Actor) in each control of each allocated MS void EdActors_MyDocument::m_fn_vSetPointers(EdActors_MiniStructureList *pclMSList, EdActors_ActorMiniStructureList *pclActorMSList) { if ( pclActorMSList != NULL ) { //Verifies if the number of MS for the editor and the actor are equal long lNumberOfEditorMS = pclMSList->GetCount(); long lNumberOfActorMS = pclActorMSList->GetCount(); ERROR_PREPARE_M(g_c_csActorModuleNameForErrors, "Setting pointers on motor data for the newly selected actor", "EdActors_MyDocument::m_fn_vSetPointers(...)", E_ERROR_GRAVITY_FATAL, "Number of MS in Actor and in Editor are not the same"); ERROR_ASSERT( lNumberOfEditorMS == lNumberOfActorMS ); //Updates datas pointers in the MS controls EdActors_MiniStructure *pclMiniStructure; EdActors_ActorMiniStructure *pclActorMS; POSITION EditorMSPos = pclMSList->GetHeadPosition(); POSITION ActorMSPos = pclActorMSList->GetHeadPosition(); while ( EditorMSPos != NULL ) { pclMiniStructure = pclMSList->GetNext(EditorMSPos); pclActorMS = pclActorMSList->GetNext(ActorMSPos); //------------------------- Sets mini-structure's pointers -------------------------- pclMiniStructure->m_pclActorMS = pclActorMS; pclActorMS->m_pclParentMS = pclMiniStructure; if ( pclActorMS->m_fn_bIsAllocated() ) { pclMiniStructure->m_clControlList.m_pub_fn_vUpdateControlsWithListOfData(pclActorMS->m_pclDataList); pclMiniStructure->m_fn_vHasBeenAllocated(); } } } else { EdActors_MiniStructure *pclMiniStructure; POSITION MSEditorPos = pclMSList->GetHeadPosition(); while ( MSEditorPos != NULL ) { pclMiniStructure = pclMSList->GetNext(MSEditorPos); //------------------------- Sets mini-structure's pointers -------------------------- pclMiniStructure->m_pclActorMS = NULL; } } } //*************************************************************************** //Loads the list of models void EdActors_MyDocument::m_fn_vLoadUnloadedModels() { // EdActors_Dialog_LoadModels LMDial(&g_oBaseFrame); // LMDial.DoModal(); if ( !m_pub_bUnloadedModelsArePrepared ) { //Loads the unloaded models from Families directories ... m_fn_vScanDirectoryForUnloadedModels(fn_szGetFamiliesDataPath(),0); m_pub_bUnloadedModelsArePrepared = TRUE; } } //*************************************************************************** // Copyright Xavier Billault !! void EdActors_MyDocument::m_fn_vScanDirectoryForUnloadedModels(CString csDirectory, int Level) { HANDLE h; WIN32_FIND_DATA hData; CString csName; CString csModelName; CString csFamilyName; short wIndex; h = FindFirstFile(csDirectory + "\\*", &hData); if( h != INVALID_HANDLE_VALUE ) { do { if( ( CString(hData.cFileName) != "." ) && ( CString(hData.cFileName) != ".." ) ) { if( hData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { if(Level<=1) m_fn_vScanDirectoryForUnloadedModels(csDirectory + "\\" + hData.cFileName, Level+1); else continue; } else if(Level == 2) { CFile cfSrcFile; CString csSrcFile = csDirectory + "\\" + hData.cFileName; //Looks if extension is a Model's one if ( g_csModelExtension.CompareNoCase(csSrcFile.Right(g_csModelExtension.GetLength())) == 0 ) { //Extracts Model' Name wIndex = csSrcFile.ReverseFind('\\'); if ( wIndex != -1 ) { csName = csSrcFile.Left(wIndex); wIndex = csName.ReverseFind('\\'); csModelName = csName.Right(csName.GetLength() - wIndex - 1); } else csModelName = "< Unknown >"; //Extracts Model' Family Name wIndex = csSrcFile.ReverseFind('\\'); if ( wIndex != -1 ) { csName = csSrcFile.Left(wIndex); wIndex = csName.ReverseFind('\\'); if ( wIndex != -1 ) { csName = csName.Left(wIndex); wIndex = csName.ReverseFind('\\'); csFamilyName = csName.Right(csName.GetLength() - wIndex - 1); } else csFamilyName = "< Unknown >"; } else csFamilyName = "< Unknown >"; //Looks if this Model is loaded BOOL bModelFound = FALSE; CPA_Actor *pclActor; Position ModelPos = g_pclInterface->m_clDocument.m_clModelsList.GetHeadPosition(); while ( (ModelPos != 0) && (!bModelFound) ) { pclActor = (CPA_Actor *)g_pclInterface->m_clDocument.m_clModelsList.GetNext(ModelPos); //Compares Models names AND Families names if ( pclActor->m_pub_fn_pclGetFamily() != NULL ) bModelFound = (( pclActor->GetName().CompareNoCase(csModelName) == 0 )&&( pclActor->m_pub_fn_pclGetFamily()->GetName().CompareNoCase(csFamilyName) == 0 )); else bModelFound = (( pclActor->GetName().CompareNoCase(csModelName) == 0 )&&(pclActor == m_pLoadedModel)); } if ( !bModelFound ) { //Displays a message (in status bar) CString csMessage = "Actors Editor prepares the Model '" + csModelName + "' for load"; EDACTORS_fn_vGiveProgressInfo(csMessage, -1); BOOL bIsLoadingWorld = g_pclInterface->GetInterface()->fn_bIsLoadingWorld(); g_pclInterface->GetInterface()->SetLoadingWorld(TRUE); //Gets the Editor Family CPA_Family *pclBaseFamily = (CPA_Family *)g_pclInterface->GetMainWorld()->fn_p_oFindObject(csFamilyName, C_szFamilyTypeName); //Constructs the new CPA_Actor CPA_Actor *pclNewModel = new CPA_Actor( NULL, NULL, g_c_csActorModelType, NULL, pclBaseFamily, //Family NULL, csModelName, FALSE ); pclNewModel->SetExistingSection(TRUE); pclNewModel->fn_vSetExistingSectionSubObject(TRUE); pclNewModel->SetAvailable(FALSE); pclNewModel->m_fn_vSetFamilyName(csFamilyName); m_clModelsList.fn_bAddObject(pclNewModel); g_pclInterface->GetInterface()->SetLoadingWorld(bIsLoadingWorld); } break; } } } } while ( FindNextFile(h,&hData) ); FindClose(h); } } //*************************************************************************** // Copyright Xavier Billault !! BOOL EdActors_MyDocument::m_fn_bScanDirectoryForUnloadedModels(CString csDirectory, int Level) { HANDLE h; WIN32_FIND_DATA hData; CString csName; CString csModelName; CString csFamilyName; short wIndex; BOOL bUnloadedModel = FALSE; h = FindFirstFile(csDirectory + "\\*", &hData); if( h != INVALID_HANDLE_VALUE ) { do { if( ( CString(hData.cFileName) != "." ) && ( CString(hData.cFileName) != ".." ) ) { if( hData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { if(Level<=1) { if (m_fn_bScanDirectoryForUnloadedModels(csDirectory + "\\" + hData.cFileName, Level+1)) return TRUE; } else continue; } else if(Level == 2) { CFile cfSrcFile; CString csSrcFile = csDirectory + "\\" + hData.cFileName; //Looks if extension is a Model's one if ( g_csModelExtension.CompareNoCase(csSrcFile.Right(g_csModelExtension.GetLength())) == 0 ) { //Extracts Model' Name wIndex = csSrcFile.ReverseFind('\\'); if ( wIndex != -1 ) { csName = csSrcFile.Left(wIndex); wIndex = csName.ReverseFind('\\'); csModelName = csName.Right(csName.GetLength() - wIndex - 1); } else csModelName = "< Unknown >"; //Extracts Model' Family Name wIndex = csSrcFile.ReverseFind('\\'); if ( wIndex != -1 ) { csName = csSrcFile.Left(wIndex); wIndex = csName.ReverseFind('\\'); if ( wIndex != -1 ) { csName = csName.Left(wIndex); wIndex = csName.ReverseFind('\\'); csFamilyName = csName.Right(csName.GetLength() - wIndex - 1); } else csFamilyName = "< Unknown >"; } else csFamilyName = "< Unknown >"; //Looks if this Model is loaded BOOL bModelFound = FALSE; CPA_Actor *pclActor; Position ModelPos = g_pclInterface->m_clDocument.m_clModelsList.GetHeadPosition(); while ( (ModelPos != 0) && (!bModelFound) ) { pclActor = (CPA_Actor *)g_pclInterface->m_clDocument.m_clModelsList.GetNext(ModelPos); //Compares Models names AND Families names if ( pclActor->m_pub_fn_pclGetFamily() != NULL ) bModelFound = ( ( pclActor->GetName().CompareNoCase(csModelName) == 0 ) && ( pclActor->m_pub_fn_pclGetFamily()->GetName().CompareNoCase(csFamilyName) == 0 ) ); } if (!bModelFound) return TRUE; break; } } } } while ( FindNextFile(h,&hData) ); FindClose(h); } return FALSE; } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : m_fnUpdateWithExternData // Date : 98-04 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::m_fnUpdateWithExternData () { if (NULL != m_pclSelectedActor && NULL != m_pclActorsView) m_pclActorsView->m_fn_vDisplayActor(m_pclSelectedActor); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : m_fn_ConstructListOfUnloadedAlways // Date : 98-05 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::m_fn_ConstructListOfUnloadedAlways () { char *szLevelsRelativePath = fn_szGetLevelsDataPath (); //find the base root char szBaseRoot [_MAX_PATH]; GetModuleFileName (NULL, szBaseRoot, _MAX_PATH); CString csBaseRoot (szBaseRoot); int iInx = csBaseRoot.ReverseFind ('\\'); ASSERT (-1 != iInx); csBaseRoot = csBaseRoot.Left (iInx + 1); // CString csRootLevels = csBaseRoot + szLevelsRelativePath + "\\"; int iRelativePathInx = csRootLevels.GetLength (); CString csRootAlwaysCharacters = csRootLevels + "_common\\families"; char *szActualLevelName = fn_p_szGetLevelName (); CString csActualLevelName = csRootLevels + szActualLevelName + "\\"; CString csAlwFileName = csActualLevelName + szActualLevelName + ".alw"; CStringList lstOfActualLevelAlwaysNames; mfn_vGetAlwaysNamesFromAlwFile (csAlwFileName, lstOfActualLevelAlwaysNames); mfn_vFillAlwaysObjectsFromDirectory (csRootAlwaysCharacters, iRelativePathInx, lstOfActualLevelAlwaysNames); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : CPA_UnloadedAlways // Date : 98-05 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// CPA_UnloadedAlways::CPA_UnloadedAlways (CPA_EditorBase * pEditor, const CString csType, CString csName/* = ""*/) : CPA_BaseObject (pEditor, csType) { m_bOnceDblClk = FALSE; m_bLoaded = FALSE; while (E_mc_TypeUnicity == fn_eRename (csName)) csName += "1"; } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : mfn_vGetAlwaysNamesFromAlwFile // Date : 98-05 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::mfn_vGetAlwaysNamesFromAlwFile (CString csFileName, CStringList &rlstOfAlwaysName) { CStdioFile file; if (!file.Open (csFileName, CFile::modeRead | CFile::typeText)) return; CString csFileEntry; while (file.ReadString (csFileEntry)) { csFileEntry.TrimLeft (); if (csFileEntry.IsEmpty ()) continue; if ('{' == csFileEntry [0]) //section's begin { CString csRealEntry = csFileEntry.Mid (1);//exclude the '{' csRealEntry.TrimLeft (); int iInx = csRealEntry.Find (':'); ASSERT (-1 != iInx); //assume the keyword is on the same line with the '{' character CString csKeyword = csRealEntry.Left (iInx); if ("InsertAlways" == csKeyword) //right entry in the section -> read the section { CString csAlwaysName = csRealEntry.Mid (iInx + 1); csAlwaysName.TrimRight (); //read a section BOOL bSectionRed = FALSE; while (file.ReadString (csFileEntry)) { csFileEntry.TrimLeft (); if ('}' == csFileEntry [0]) //section's end { bSectionRed = TRUE; break; } } if (!bSectionRed) { TRACE0 ("Invalid section in the alw file\n"); file.Close (); return; } rlstOfAlwaysName.AddTail (csAlwaysName); } } } file.Close (); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : mfn_vFillAlwaysObjectsFromDirectory // Date : 98-05 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::mfn_vFillAlwaysObjectsFromDirectory (CString csDirectoryName, int iRelativePathInx, CStringList &rlstOfCurrentLevelAlwaysName) { CTypedPtrList lstOfAlwEntry; mfn_vSearchDirForAlways (csDirectoryName, iRelativePathInx, lstOfAlwEntry); int iSufix = 0; POSITION pos = lstOfAlwEntry.GetHeadPosition (); while (pos) { AlwEntry *pAlwEntry = lstOfAlwEntry.GetNext (pos); if (!pAlwEntry) continue; BOOL bAlwaysOk = TRUE; POSITION pos2 = rlstOfCurrentLevelAlwaysName.GetHeadPosition (); while (pos2) { const CString csExcludedAlwaysName = rlstOfCurrentLevelAlwaysName.GetNext (pos2); if (0 == csExcludedAlwaysName.CompareNoCase (pAlwEntry->m_csAlwaysName)) { bAlwaysOk = FALSE; break; } } if (bAlwaysOk) { CString csSufix; csSufix.Format ("%s%d", "UnloadedAlways", iSufix++); CPA_UnloadedAlways *pAlways = new CPA_UnloadedAlways (g_pclInterface, g_c_csUnloadedAlwaysType, pAlwEntry->m_csAlwaysName + csSufix); if (!pAlways) return; //not enough memory // pAlways->SetAvailable (FALSE); pAlways->mfn_vSetUAlwaysName (pAlwEntry->m_csAlwaysName); pAlways->mfn_vSetAlwFile (pAlwEntry->m_csAlwFile); m_clUnloadedAlwaysList.fn_bAddObject (pAlways); } } } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : mfn_vSearchDirForAlways // Date : 98-05 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::mfn_vSearchDirForAlways (CString csDirectoryName, int iRelativePathInx, CTypedPtrList &rlstOfAlwEntry) { //search in depth all subdirectories until we get the directories named "charact" //in this directories look for *.car files whose names begin with "ALW_" struct _finddata_t findDataSubdir; long lSubdirHandle = _findfirst (csDirectoryName + "\\*.*", &findDataSubdir); CString csCharactDir ("charact"); if (-1 != lSubdirHandle) { do { if (_A_SUBDIR == (findDataSubdir.attrib & _A_SUBDIR)) { if (0 == csCharactDir.CompareNoCase (findDataSubdir.name)) mfn_vGetAlwaysFromCharactDirectory (csDirectoryName + "\\" + csCharactDir, iRelativePathInx, rlstOfAlwEntry); else if (CString (".") != findDataSubdir.name && CString ("..") != findDataSubdir.name) mfn_vSearchDirForAlways (csDirectoryName + "\\" + findDataSubdir.name, iRelativePathInx, rlstOfAlwEntry); } }while (-1 != _findnext (lSubdirHandle, &findDataSubdir)); } _findclose (lSubdirHandle); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : mfn_vGetAlwaysFromCharactDirectory // Date : 98-05 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::mfn_vGetAlwaysFromCharactDirectory (CString csDirectoryName, int iRelativePathInx, CTypedPtrList &rlstOfAlwEntry) { //search the alw file in the subdirectory struct _finddata_t findDataFile; CString csCarFile; long lFileHandle = _findfirst (csDirectoryName + '\\' + "*.car", &findDataFile); if (-1 != lFileHandle) { do { csCarFile = findDataFile.name; CString csPrefix = csCarFile.Left (4); if (0 == csPrefix.CompareNoCase ("ALW_")) //always character { int iInx = csCarFile.ReverseFind ('.'); ASSERT (-1 != iInx); CString csAlwaysName = csCarFile.Left (iInx); CString csRelativePath = csDirectoryName + "\\" + csCarFile; csRelativePath = csRelativePath.Mid (iRelativePathInx); AlwEntry *pAlwEntry = new AlwEntry (csAlwaysName, csRelativePath); rlstOfAlwEntry.AddTail (pAlwEntry); } }while (-1 != _findnext (lFileHandle, &findDataFile)); } _findclose (lFileHandle); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : m_fn_vLoadFamilyModels // Date : 98-06 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::m_fn_vLoadFamilyModels (CString csFamilyName) { if (csFamilyName.IsEmpty ()) return; CString csDirectory = fn_szGetFamiliesDataPath() + CString ("\\") + csFamilyName; m_fn_vScanDirectoryForUnloadedModels(csDirectory, 1); m_pclDialogList->fn_vUpdateSelection(E_lrm_ReinitList); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : mfn_vExtractAlwaysModelsFromBehaviour // Date : 98/06/30 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::mfn_vExtractAlwaysModelsFromBehaviour (CString &rcsAIText, CStringList &rlstOfAlways) { CStringList lstGenereName; lstGenereName.AddHead ("GenereObjet"); lstGenereName.AddHead ("ACT_GenerateObject"); lstGenereName.AddHead ("TEXT_Affiche"); lstGenereName.AddHead ("TEXT_DisplayText"); POSITION posGN = lstGenereName.GetHeadPosition (); while (NULL != posGN) { CString csGenereFunctionName = lstGenereName.GetNext (posGN); csGenereFunctionName.MakeLower(); CString csAIText = rcsAIText; csAIText.MakeLower(); BOOL bLastLineFound = FALSE; while (!csAIText.IsEmpty () && !bLastLineFound) { int iNewLineLimit = csAIText.Find ("\n"); CString csAILine; if (-1 == iNewLineLimit) { bLastLineFound = TRUE; csAILine = csAIText; } else { csAILine = csAIText.Left (iNewLineLimit); csAIText = csAIText.Mid (iNewLineLimit + 1); } csAILine.TrimLeft (); if (!csAILine.IsEmpty () && ';' != csAILine [0]) //for every valid line in the AIText(don't treat commented lines) { for (;;) { int iInx = csAILine.Find (csGenereFunctionName); if (-1 == iInx) break; CString csComplete = csAILine + csAIText; CString csArg = GetFunctionArgument (csComplete, iInx); if (!csArg.IsEmpty ()) { csArg.MakeLower(); if (rlstOfAlways.Find (csArg) == NULL) rlstOfAlways.AddTail (csArg); } csAILine = csAILine.Mid (csGenereFunctionName.GetLength ()); } } } } } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : GetFunctionArgument // Date : 98/06/30 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// CString EdActors_MyDocument::GetFunctionArgument (CString &rText, int iFunctionInx) { CString csArg; CString csFunctionText = rText.Mid (iFunctionInx); int i1Sep = csFunctionText.Find ('('); int i2Sep = csFunctionText.Find (')'); if (-1 != i1Sep && -1 != i2Sep && i2Sep > i1Sep) { CString csArgs = csFunctionText.Mid (i1Sep + 1, i2Sep - i1Sep - 1); int i1StrSep = csArgs.Find ('"'); if (-1 != i1StrSep) { CString csArgsSubStr = csArgs.Mid (i1StrSep + 1); int i2StrSep = csArgsSubStr.Find ('"'); ASSERT (-1 != i2StrSep); csArg = csArgsSubStr.Left (i2StrSep); } } return csArg; } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : mfn_vFillRefAlwaysForModel // Date : 98/07/16 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::mfn_vFillRefAlwaysForModel (CPA_Actor *pModel, CStringList &rlstOfRefAlways) { if (!pModel || !pModel->m_fn_bIsAModel ()) return; CPA_EdIR_Brain *pclBrain = ((EdActors_EditorActorModel *)pModel->m_fn_pclGetEditorActor())->m_pclBrain; if (pclBrain) { // behaviours POSITION posInIBehaviours = pclBrain->m_clListOfIntelligenceBehaviours.GetHeadPosition (); while (posInIBehaviours) { CPA_EdIR_MainBehaviour *pMainBehaviour = pclBrain->m_clListOfIntelligenceBehaviours.GetNext (posInIBehaviours); ASSERT (pMainBehaviour); mfn_vExtractAlwaysModelsFromBehaviour (pMainBehaviour->m_csText, rlstOfRefAlways); } // reflex POSITION posInRBehaviours = pclBrain->m_clListOfReflexBehaviours.GetHeadPosition (); while (posInRBehaviours) { CPA_EdIR_MainBehaviour *pMainBehaviour = pclBrain->m_clListOfReflexBehaviours.GetNext (posInRBehaviours); ASSERT (pMainBehaviour); mfn_vExtractAlwaysModelsFromBehaviour (pMainBehaviour->m_csText, rlstOfRefAlways); } // declarations POSITION posInDBehaviours = pclBrain->m_clListOfDeclarations.GetHeadPosition (); while (posInDBehaviours) { CPA_EdIR_MainBehaviour *pMainBehaviour = pclBrain->m_clListOfDeclarations.GetNext (posInDBehaviours); ASSERT (pMainBehaviour); mfn_vExtractAlwaysModelsFromBehaviour (pMainBehaviour->m_csText, rlstOfRefAlways); } // macros POSITION posInMBehaviours = pclBrain->m_clListOfMacros.GetHeadPosition (); while (posInMBehaviours) { CPA_EdIR_MainBehaviour *pMainBehaviour = pclBrain->m_clListOfMacros.GetNext (posInMBehaviours); ASSERT (pMainBehaviour); mfn_vExtractAlwaysModelsFromBehaviour (pMainBehaviour->m_csText, rlstOfRefAlways); } // subroutines POSITION posInSBehaviours = pclBrain->m_clListOfSubrs.GetHeadPosition (); while (posInSBehaviours) { CPA_EdIR_MainBehaviour *pMainBehaviour = pclBrain->m_clListOfSubrs.GetNext (posInSBehaviours); ASSERT (pMainBehaviour); mfn_vExtractAlwaysModelsFromBehaviour (pMainBehaviour->m_csText, rlstOfRefAlways); } } } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : mfn_vCheckModelToUpdateAlwFile // Date : 98/07/16 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void EdActors_MyDocument::mfn_vCheckModelToUpdateAlwFile (CPA_Actor *pModel) { if (!pModel || !pModel->m_fn_bIsAModel ()) return; CStringList lstOfRefAlways; mfn_vFillRefAlwaysForModel (pModel, lstOfRefAlways); CStringList lstOfReferencedAlwaysNotLoaded; CPA_BaseObject *pObject = NULL; POSITION pos = lstOfRefAlways.GetHeadPosition (); while (pos) { CString csRefAlwaysName = lstOfRefAlways.GetNext (pos); pObject = m_clAlwaysList.fn_p_oFindObject (csRefAlwaysName); if (NULL == pObject) lstOfReferencedAlwaysNotLoaded.AddTail (csRefAlwaysName); } if (!lstOfReferencedAlwaysNotLoaded.IsEmpty ()) { CDlgCleanAlwFile dlg (lstOfReferencedAlwaysNotLoaded, TASK_UPDATE_ALW_FILE); if (IDOK == dlg.DoModal ()) { //clean the alw file CStringList &rlstOfAlwaysToBeLoaded = lstOfReferencedAlwaysNotLoaded; //the dialog fills the list with the always to be removed //change the name in order not to propagate confusion g_pclInterface->M_GetEditManager ()->AskFor (new ModifUpdateAlwFile (g_pclInterface, rlstOfAlwaysToBeLoaded)); } } } // Shaitan => state list in the level ////////////////////// // Update References// ////////////////////// //************************************************************************ void EdActors_MyDocument::m_fn_vUpdateReferencesForAllActions (void) { POSITION pos, pos1, pos2; CPA_DLLBase *pclIADLL; CPA_BaseObject *pCurrentModel; CPA_BaseObject *pCurrentFamily; CPA_BaseObject *pCurrentInstance; CPA_List clListOfModels; CPA_List clListOfFamilies; CPA_List clListOfInstances; pclIADLL=(CPA_DLLBase*)(g_pclInterface->GetMainWorld()->GetToolDLLWithName(C_szDLLAIEditorName)); // make sure that all AIs have been parsed to update the references clListOfFamilies.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfFamilies, "", C_szFamilyTypeName); pos = clListOfFamilies.GetHeadPosition(); while (pos) { pCurrentFamily = clListOfFamilies.GetNext(pos); clListOfModels.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfModels, "", C_szActorModelTypeName, pCurrentFamily); pos1 = clListOfModels.GetHeadPosition(); while (pos1) { pCurrentModel = clListOfModels.GetNext(pos1); clListOfInstances.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfInstances, "", C_szActorInstanceTypeName, pCurrentModel); pos2 = clListOfInstances.GetHeadPosition(); if (pos2) { pCurrentInstance = clListOfInstances.GetNext(pos2); if(pclIADLL!=NULL) { tdstActorsIACom stCom; stCom.pvThis=pCurrentModel; stCom.pvData=pCurrentInstance; pclIADLL->OnQueryAction(g_pclInterface,C_uiAI_ProcessModifiedIA,(long)(&stCom)); } } } } // status bar message M_GetMainWnd()->UpdateStatus("All references of actions in all AIs were updated", C_STATUSPANE_INFOS, C_STATUS_NORMAL); } ////////////////////// // Update State List// ////////////////////// //************************************************************************ void EdActors_MyDocument::m_fn_vUpdateListOfUsedActionsForFamily (CPA_Family *pFamily) { POSITION pos, pos1; CPA_Action *pAction; CPA_Actor *pCurrentInstance; CPA_BaseObject *pCurrentModel; CPA_List clListOfModels; CPA_List clListOfInstances; char szSectionName[SCR_CV_ui_Cfg_MaxLenName]; char szMessage[256]; // clear the list of actions used by this family pFamily->m_oListOfUsedActions.RemoveAll(); // first, check the actions referenced in the AI pos = pFamily->m_oListOfActions.GetHeadPosition(); while (pos) { pAction = pFamily->m_oListOfActions.GetNext(pos); //if someone is referencing this action, it must be added in the list CList oFatherList; int iNbFathers = g_oCoherenceManager.m_fn_iGetFatherList(pAction, &oFatherList); if (iNbFathers > 0) pFamily->m_oListOfUsedActions.AddTail(pAction); } // then, check the initial action of each instance of the family clListOfModels.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfModels, "", C_szActorModelTypeName, pFamily); pos = clListOfModels.GetHeadPosition(); while (pos) { pCurrentModel = clListOfModels.GetNext(pos); clListOfInstances.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfInstances, "", C_szActorInstanceTypeName, pCurrentModel); pos1 = clListOfInstances.GetHeadPosition(); while (pos1) { pCurrentInstance = (CPA_Actor *) clListOfInstances.GetNext(pos1); // check initial action tdstEngineObject *p_stObject = (tdstEngineObject*) pCurrentInstance->GetStruct(); tdxHandleToState hState = fn_h3dDataGetInitialState(p_stObject->h_3dData); CPA_State *pState = (CPA_State *) g_pclInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(hState, C_szStateTypeName); pAction = pState->mfn_p_oGetAction(); if (!pFamily->m_oListOfUsedActions.Find(pAction)) pFamily->m_oListOfUsedActions.AddTail(pAction); } } // notifies the STL section for saving if (pFamily->m_oListOfUsedActions.GetCount() > 0) { sprintf(szSectionName,"%s\\%s\\Families\\%s\\%s.stl^%s", fn_szGetLevelsDataPath(), fn_p_szGetLevelName(), pFamily->GetName(), pFamily->GetName(), C_SectionCreateListOfState); SCR_fn_v_SvL1_RegisterNotify(szSectionName, s_m_fn_vCallBackSaveStateList, pFamily, SCR_EA_Ntfy_AddOrRebuildSection); } // status bar message sprintf(szMessage, "List of states updated for family %s", pFamily->GetName()); M_GetMainWnd()->UpdateStatus(szMessage, C_STATUSPANE_INFOS, C_STATUS_NORMAL); } // End Shaitan => state list in the level // Shaitan => module list in the level ////////////////////// // Update TBL List // ////////////////////// //************************************************************************ void EdActors_MyDocument::m_fn_vUpdateListOfUsedObjectTablesForFamily (CPA_Family *pFamily) { POSITION pos, pos1; EditorObjectTable *pObjectTable; CPA_Actor *pCurrentInstance; CPA_BaseObject *pCurrentModel; CPA_List clListOfModels; CPA_List clListOfInstances; char szMessage[256]; // clear the list of object tables used by this family pFamily->m_oListOfUsedObjectTables.RemoveAll(); // first, check the object tables referenced in the AI pos = pFamily->m_oListOfObjectTables.GetHeadPosition(); while (pos) { pObjectTable = pFamily->m_oListOfUsedObjectTables.GetNext(pos); //if someone is referencing this action, it must be added in the list CList oFatherList; int iNbFathers = g_oCoherenceManager.m_fn_iGetFatherList(pObjectTable, &oFatherList); if (iNbFathers > 0) pFamily->m_oListOfUsedObjectTables.AddTail(pObjectTable); } // then, check the initial object table of each instance of the family clListOfModels.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfModels, "", C_szActorModelTypeName, pFamily); pos = clListOfModels.GetHeadPosition(); while (pos) { pCurrentModel = clListOfModels.GetNext(pos); clListOfInstances.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfInstances, "", C_szActorInstanceTypeName, pCurrentModel); pos1 = clListOfInstances.GetHeadPosition(); while (pos1) { pCurrentInstance = (CPA_Actor *) clListOfInstances.GetNext(pos1); // check initial action tdstEngineObject *p_stObject = (tdstEngineObject*) pCurrentInstance->GetStruct(); tdxHandleToObjectsTablesList hObjectTable = fn_h3dDataGetInitialObjectsTable(p_stObject->h_3dData); pObjectTable = (EditorObjectTable *) g_pclInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(hObjectTable, C_szObjectTableTypeName); if (!pFamily->m_oListOfUsedObjectTables.Find(pObjectTable)) pFamily->m_oListOfUsedObjectTables.AddTail(pObjectTable); } } // check also the default object table of the family if (pFamily->GetStruct()) { tdxHandleToObjectsTablesList hObjectTable = fn_vGetDefaultObjectsTableOfFamily((tdxHandleToFamilyList) pFamily->GetStruct()); pObjectTable = (EditorObjectTable *) g_pclInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(hObjectTable, C_szObjectTableTypeName); if (!pFamily->m_oListOfUsedObjectTables.Find(pObjectTable)) pFamily->m_oListOfUsedObjectTables.AddTail(pObjectTable); } // status bar message sprintf(szMessage, "List of object tables updated for family %s", pFamily->GetName()); M_GetMainWnd()->UpdateStatus(szMessage, C_STATUSPANE_INFOS, C_STATUS_NORMAL); } ////////////////////// // Update PO List // ////////////////////// //************************************************************************ void EdActors_MyDocument::m_fn_vUpdateListOfUsedPOsForFamily (CPA_Family *pFamily) { POSITION pos, pos1; CPA_State *pState; CPA_Actor *pCurrentInstance; CPA_Action *pAction; CPA_Animation *pAnimation; CPA_BaseObject *pPO; CPA_BaseObject *pCurrentModel; EditorObjectTable *pObjectTable; CPA_List clListOfModels; CPA_List clListOfInstances; MS_tdxHandleTo3dData h_3dData = NULL; tdxHandleToObjectsTablesList hObjectTable; tdxHandleToObjectsTableElement hOTElement; struct tdstAnim3d_ *p_stCurrentAnim; struct tdstFrame3d_ *p_stCurrentFrame3d; struct tdstElement3d_ *p_stCurrentElement3d; unsigned short uwCurrentFrame; unsigned char ucElement; short wArrayOfIndexes[500]; short wMaxElement = 500; short wIndex; char szSectionName[SCR_CV_ui_Cfg_MaxLenName]; char szMessage[256]; // clear the list of POs used by this family pFamily->m_oListOfUsedPOs.RemoveAll(); for (wIndex = 0; wIndex < wMaxElement; wIndex++) wArrayOfIndexes[wIndex] = 0; // get an instance of this family clListOfModels.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfModels, "", C_szActorModelTypeName, pFamily); pos = clListOfModels.GetHeadPosition(); if (pos) { pCurrentModel = clListOfModels.GetNext(pos); clListOfInstances.RemoveAll(); g_pclInterface->GetMainWorld()->fn_lFindObjects(&clListOfInstances, "", C_szActorInstanceTypeName, pCurrentModel); pos1 = clListOfInstances.GetHeadPosition(); if (pos1) { pCurrentInstance = (CPA_Actor *) clListOfInstances.GetNext(pos1); h_3dData = /*(struct tdstEngineObject_ *) */pCurrentInstance->GetStruct()->h_3dData; } } if (h_3dData == NULL) return; // first, build the list of used indexes pos = pFamily->m_oListOfUsedActions.GetHeadPosition(); while (pos) { pAction = pFamily->m_oListOfUsedActions.GetNext(pos); // for each state of the action pos1 = pAction->m_oListOfStates.GetHeadPosition(); while (pos1) { pState = pAction->m_oListOfStates.GetNext(pos1); // get the corresponding animation pAnimation = pState->mfn_p_oGetAnimation(); // check engine animation p_stCurrentAnim = (pAnimation) ? (struct tdstAnim3d_ *) pAnimation->GetData() : NULL; if (p_stCurrentAnim) { fn_vFindUsedIndexes(wArrayOfIndexes, wMaxElement, p_stCurrentAnim, h_3dData); } } } // then build the corresponding list of POs pos = pFamily->m_oListOfUsedObjectTables.GetHeadPosition(); while (pos) { // get object table pObjectTable = pFamily->m_oListOfUsedObjectTables.GetNext(pos); hObjectTable = (tdxHandleToObjectsTablesList) pObjectTable->GetData(); // check each index for (wIndex = 0; wIndex < wMaxElement; wIndex++) { if (wArrayOfIndexes[wIndex] == 1) { hOTElement = fn_d_hGetElementByNumberInObjectsTable(hObjectTable, wIndex); if ((fn_wObjectsTableGetTypeOfTarget(hOTElement) == C_wTdO_PhysicalObject) || (fn_wObjectsTableGetTypeOfTarget( hOTElement ) == C_wTdO_Mirror)) { // get corresponding PO pPO = g_pclInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(fn_hObjectsTableGetTarget(hOTElement), C_szPhysicalObjectTypeName); // add it to the list if (pPO && !pFamily->m_oListOfUsedPOs.Find(pPO)) pFamily->m_oListOfUsedPOs.AddTail(pPO); } } } } // notifies the OTL section for saving if (pFamily->m_oListOfUsedPOs.GetCount() > 0) { sprintf(szSectionName,"%s\\%s\\Families\\%s\\%s.otl^%s", fn_szGetLevelsDataPath(), fn_p_szGetLevelName(), pFamily->GetName(), pFamily->GetName(), C_SectionCreateListOfPOs); SCR_fn_v_SvL1_RegisterNotify(szSectionName, s_m_fn_vCallBackSavePOList, pFamily, SCR_EA_Ntfy_AddOrRebuildSection); } // status bar message sprintf(szMessage, "List of POs updated for family %s", pFamily->GetName()); M_GetMainWnd()->UpdateStatus(szMessage, C_STATUSPANE_INFOS, C_STATUS_NORMAL); } // End Shaitan => module list in the level ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : ModifUpdateAlwFile // Date : 98/07/16 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// ModifUpdateAlwFile::ModifUpdateAlwFile (CPA_Actor_Editor_Interface *pInterface, CStringList &rlstAlwObjects, BOOL pBlock/* = FALSE*/) : CPA_Modif (UPDATE_ALW_FILE, "UpdateAlwFile", pBlock) { m_pInterface = pInterface; m_lstAlwObjects.AddHead (&rlstAlwObjects); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : Undo // Date : 98/07/16 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// BOOL ModifUpdateAlwFile::Undo () { ASSERT (m_pInterface); int iReinitDialog = 0; Position posAlw = m_pInterface->m_clDocument.m_clAlwaysList.GetHeadPosition (); while (posAlw) { CPA_Actor *pAlways = (CPA_Actor *)m_pInterface->m_clDocument.m_clAlwaysList.GetNext (posAlw); ASSERT (pAlways); BOOL bRemoveIt = NULL != m_lstAlwObjects.Find (pAlways->GetName ()); //remove the always that are choosed to be removed if (bRemoveIt) iReinitDialog = m_pInterface->mfn_bUnloadAlwaysFromLevel (pAlways) ? posAlw = m_pInterface->m_clDocument.m_clAlwaysList.GetHeadPosition (), //there is a bug in the list implementatin, so I have to reinitialize the list pos after I delete an element iReinitDialog + 1 : iReinitDialog; } if (0 < iReinitDialog) { ASSERT (m_pInterface->m_clDocument.m_pclDialogList); m_pInterface->m_clDocument.m_pclDialogList->fn_vReinitDialog (); } return TRUE; } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : Do // Date : 98/07/16 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Stegaru Cristian - CPA ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// BOOL ModifUpdateAlwFile::Do () { int iReinitDialog = 0; POSITION pos = m_lstAlwObjects.GetHeadPosition (); while (pos) { CString csAlwName = m_lstAlwObjects.GetNext (pos); if (csAlwName.IsEmpty ()) continue; CPA_UnloadedAlways *pUAlways = NULL; BOOL bFound = FALSE; Position posUA = m_pInterface->m_clDocument.m_clUnloadedAlwaysList.GetHeadPosition (); while (posUA) { pUAlways = (CPA_UnloadedAlways *)m_pInterface->m_clDocument.m_clUnloadedAlwaysList.GetNext (posUA); if (!csAlwName.CompareNoCase(pUAlways->mfn_csGetUAlwaysName())) { bFound = TRUE; break; } } if (!bFound) return FALSE; ASSERT (pUAlways); m_pInterface->m_clDocument.m_clUnloadedAlwaysList.fn_bRemoveObject (pUAlways); m_pInterface->mfn_vLoadAlways (pUAlways); pUAlways->mfn_vSetLoaded (TRUE); iReinitDialog++; } if (0 < iReinitDialog) m_pInterface->m_clDocument.m_pclDialogList->fn_vReinitDialog (); return TRUE; }