reman3/Rayman_X/cpa/tempgrp/TAc/src/ACinterf.cpp

2135 lines
86 KiB
C++

/*=============================================================================
*
* Filename: ACInterf.cpp
* Version: 1.0
* Date: 30/12/96
* Author: Marc Trabucato & V.L.
*
* Description: Base class of Action DLL Interface
*
*===========================================================================*/
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
//
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ACP_Base.h"
#include "ITF.h"
#include "x:\cpa\main\inc\_editid.h"
#include "DPT.h"
#include "TAC.h"
#include "TFa.h"
#include "TAn.h"
#include "OAc.h"
#include "ErO.h"
#include "TUT.h"
#include "ACinterf.hpp"
//#include "FAInterf.hpp"
#include "DlgActCt.hpp"
#include "DlgActLs.hpp"
#include "DlgState.hpp"
#include "DlgZA.hpp"
#include "DlgZAL.hpp"
#include "DlgZALst.hpp"
#include "DlgAct.hpp"
#include "DlgAnim.hpp"
#include "DlgNmLst.hpp"
#include "FAModif.hpp"
#include "ACModif.hpp"
#include "STModif.hpp"
#include "ZAModif.hpp"
// infos
static CString g_csTACName = "Action";
static CString g_csTACAuthor = "Marc Trabucato";
static CString g_csTACVersion = "V 6.0.2 18/03/98";
static CString g_csTACFrenchHelpFile = "Action.hlp";
static CString g_csTACEnglishHelpFile = "";
BOOL g_bTipFirstTime = TRUE;
/******************************************************************************
* the DLL global definition
******************************************************************************/
tdstDLLIdentity g_stTActionIdentity;
/******************************************************************************
* CONSTANTS
******************************************************************************/
// Editor state
#define C_lEDST_Active 1
#define C_lEDST_Inactive 0
// SubMenu ID
#define C_uiTACPopupEdit 10
#define C_uiTACPrefSaveDim 20
#define C_uiTACPrefLoadFam 21
#define C_uiTACPrefLoadAnm 22
// DialogList popup menu
#define C_uiTACPreLoadAnimations 1
// Dialog List Name
#define C_szFamilyList "Family"
// Error type
#define C_lNotEnoughtStates 1
/******************************************************************************
* MACROS
******************************************************************************/
#define M_GetFamilyList() (M_GetMainWorld () -> fn_p_oGetObjectList ( C_szFamilyTypeName ) )
#define M_MakeDo( p_oModify ) (M_GetEditManager () -> AskFor( p_oModify ))
#define M_IsCurrentFamily( p_oFamily ) ( m_p_oCurrentFamily == p_oFamily )
#define M_IsCurrentAction( p_oAction ) ( m_p_oCurrentAction == p_oAction )
#define M_IsCurrentState( p_oState ) ( m_p_oCurrentState == p_oState )
#define M_IsCurrentNameList( p_oList ) ( m_p_oCurrentNameList == p_oList )
#define M_Char(string) ( (char*)(LPCTSTR)(string) )
#define M_TACStatus(szText,cType) M_GetMainWnd()->UpdateStatus(szText, C_STATUSPANE_INFOS, cType)
#define M_TACInfo(szText) M_TACStatus(szText, C_STATUS_NORMAL)
#define M_TACWarning(szText) M_TACStatus(szText, C_STATUS_WARNING)
#define M_TACError(szText) M_TACStatus(szText, C_STATUS_ERROR)
#define M_BeginLoad(szText,hCursor)\
{\
M_TACWarning(szText);\
HCURSOR hCurWait = AfxGetApp() -> LoadStandardCursor( IDC_WAIT );\
hCursor = ::SetCursor( hCurWait );\
}
#define M_EndLoad(szText,hCursor)\
{\
::SetCursor( hCursor );\
M_TACInfo(szText);\
Sleep( 200 );\
M_TACInfo( "" );\
}
/******************************************************************************
* implementation of TAction_Interface class functions
******************************************************************************/
/*-----------------------------------------------------------------------------
* Description : constructor
*---------------------------------------------------------------------------*/
TAction_Interface::TAction_Interface(void)
{
// ************************** private internal
m_p_stDLLIdentity = &g_stTActionIdentity;
// Does your DLL can output in main game view ?
m_stBaseDLLDefinition.bCanOutputIn3DView = FALSE;
// Does your DLL can be refresh by engine ?
m_stBaseDLLDefinition.bCanBeRefreshedByEngine = FALSE;
// TODO : Add your own code here
SetEditorInfo(g_csTACName, g_csTACAuthor, g_csTACVersion, g_csTACFrenchHelpFile, g_csTACEnglishHelpFile);
//
m_p_oSplitterLeftSTM = NULL ;
m_p_oSplitterBottomSTM = NULL ;
m_p_oSplitterLeftZAM = NULL ;
m_p_oSplitterBottomZAM = NULL ;
m_p_oDialogListSTM = NULL ;
m_p_oDialogListZAM = NULL ;
m_p_oDlgActionContents = NULL ;
m_p_oDlgActionList = NULL ;
m_p_oDlgState = NULL ;
m_p_oDlgZAListContent = NULL ;
m_p_oDlgZAList = NULL ;
m_p_oDlgZA = NULL ;
m_p_oDlgActions = NULL ;
m_p_oDlgAnimList = NULL ;
m_p_oDlgNameList = NULL ;
m_lEditorState = C_lEDST_Inactive;
m_p_oCurrentFamily = NULL ;
m_p_oCurrentAction = NULL ;
m_p_oCurrentState = NULL ;
m_p_oCurrentNameList = NULL ;
m_p_oCurrentZAList = NULL ;
m_p_oCurrentZA = NULL ;
m_bStateMode = TRUE ;
m_bAllFamilies = FALSE;
m_p_oCurrentAnimFamily = NULL ;
// CPA_Ed_1 Mihaela Tancu begin
m_iIndexListBox = -1;
m_hDlgActionContentsHwnd = NULL;
// CPA_Ed_1 Mihaela Tancu end
// Init ErO Module
ERROR_g_fn_vAddAModuleDescriptor(C_szTACModuleNameErO, "v4.8.0",
"Marc Trabucato", "0'.50.52.98.84 (Annecy)","mtrabucato@ubisoft.fr",
"Daniel PALIX","04 50 51 26 63 (Annecy)","dpalix@ubisoft.fr",
"Fabien Bole-Feysot","04 50 52 98 84 (Annecy)","fbolefeysot@ubisoft.fr" );
}
/*=============================================================================
* Loading functions
=============================================================================*/
BOOL TAction_Interface::mfn_bCheckStatesTransitions( CPA_Family *_p_oFamily )
{
BOOL bResult = TRUE;
CString csMessage;
POSITION stPos = _p_oFamily -> m_oListOfStates . GetHeadPosition () ;
while ( stPos )
{
CPA_State *p_oState = _p_oFamily -> m_oListOfStates . GetNext ( stPos ) ;
// update Transition
if( ! p_oState -> mfn_bUpdateTransitionStateList() )
{
// error on updating
csMessage = "Error on Interrupt Action List of state : " +
p_oState -> GetName() +
" (Family : " +
p_oState -> GetOwner() -> GetName() +
")";
M_TACError(M_Char(csMessage));
bResult = FALSE;
break;
}
}
return bResult;
}
// ----------------------------------------------------------------------------
// Description :
// ----------------------------------------------------------------------------
BOOL TAction_Interface::mfn_bLoadStatesMechanics( CPA_Family *_p_oFamily )
{
BOOL bResult = TRUE;
CString csMessage;
POSITION stPos = _p_oFamily -> m_oListOfStates . GetHeadPosition () ;
while ( stPos )
{
CPA_State *p_oState = _p_oFamily -> m_oListOfStates . GetNext ( stPos ) ;
p_oState -> mfn_vInitMechanics();
// force mechanic to be loaded
CPA_SaveObject *p_oMeca = p_oState -> mfn_p_oGetMecaCard();
if( p_oMeca && ! p_oMeca -> fn_bIsAvailable() )
{
HCURSOR hCursor;
char szText[256];
strcpy( szText, "Load mechanic : ");
strcat( szText, p_oMeca -> fn_p_szGetName() );
M_BeginLoad( p_oMeca -> fn_p_szGetName(), hCursor );
if( ! p_oMeca -> GetEditor() -> fn_bLoadBaseObject( p_oMeca ) )
{
// error on loading
csMessage = "Can\'t load mechanic : " + p_oMeca -> GetName();
M_TACError(M_Char(csMessage));
bResult = FALSE;
break;
}
strcat( szText, " ==> 100 %" );
M_EndLoad( szText, hCursor );
}
// update engine handle
p_oState -> mfn_vSetMecaCard( p_oMeca );
}
return bResult;
}
// ----------------------------------------------------------------------------
// Description :
// ----------------------------------------------------------------------------
BOOL TAction_Interface::mfn_bLoadStatesAnimations( CPA_Family *_p_oFamily )
{
BOOL bResult = TRUE;
CString csMessage;
POSITION stPos = _p_oFamily -> m_oListOfStates . GetHeadPosition () ;
while ( stPos )
{
CPA_State *p_oState = _p_oFamily -> m_oListOfStates . GetNext ( stPos ) ;
// update animation
// force anim to be loaded
CPA_Animation *p_oAnimation = p_oState -> mfn_p_oGetAnimation();
if( p_oAnimation && ! p_oAnimation -> fn_bIsAvailable() )
{
HCURSOR hCursor;
char szText[256];
strcpy( szText, "Load animation : ");
strcat( szText, p_oAnimation -> fn_p_szGetName() );
M_BeginLoad( szText, hCursor );
// load animation
if( ! p_oAnimation -> GetEditor() -> fn_bLoadBaseObject( p_oAnimation ) )
{
// error on loading
csMessage = "Can\'t load animation : " + p_oAnimation -> GetName();
M_TACError(M_Char(csMessage));
bResult = FALSE;
break;
}
strcat( szText, " ==> 100 %" );
M_EndLoad( szText, hCursor );
// update engine handle
p_oState -> mfn_vSetAnimation( p_oAnimation );
}
}
return bResult;
}
// ----------------------------------------------------------------------------
// Description : update editor state before engine is run
// ----------------------------------------------------------------------------
BOOL TAction_Interface::mfn_bUpdateStateBeforeRunningEngine( CPA_Family *_p_oFamily )
{
return ( mfn_bLoadStatesAnimations( _p_oFamily ) &&
mfn_bCheckStatesTransitions( _p_oFamily ) &&
mfn_bLoadStatesMechanics( _p_oFamily ) );
}
// ----------------------------------------------------------------------------
// Description :
// ----------------------------------------------------------------------------
BOOL TAction_Interface::mfn_bUpdateStateBeforeSaving( CPA_Family *_p_oFamily )
{
return ( mfn_bCheckStatesTransitions( _p_oFamily ) );
}
// ----------------------------------------------------------------------------
// Description : check if all ZDM ZA have at least one activated zone
///////////////////////////////////////////////////////////////////////////////
// New : now, a ZDM ZA can have no activated zone
// ----------------------------------------------------------------------------
BOOL TAction_Interface::mfn_bCheckFamiliesZA()
{
/*****************
CString csMessage;
CPA_BaseObjectList *p_oList;
Position xPos;
// check ZA for all families
p_oList = GetMainWorld() -> fn_p_oGetOriginalObjectList( C_szZATypeName );
xPos = p_oList -> GetHeadPosition();
while( xPos )
{
CPA_ZonesActivating *p_oZA = (CPA_ZonesActivating*) p_oList -> GetNext( xPos );
CPA_tdoNameList *p_oNameList = (CPA_tdoNameList*)p_oZA -> GetOwner();
int iNbZdmActived = p_oZA -> m_oListOfZDxNameIdx . GetCount();
if( p_oNameList -> fn_bIsOfType( C_szZDmNameListType ) && // ZDM Names List
p_oZA -> m_oListOfZDxNameIdx . IsEmpty() // no zone actived
)
{
csMessage = "Error : no zone actived on activation : " +
p_oZA -> GetName() +
" (Names List : " +
p_oZA -> GetOwner() -> GetName() +
" Family : " +
p_oZA -> GetOwner() -> GetOwner() -> GetName() +
")";
M_TACError(M_Char(csMessage));
return FALSE;
}
}
********************/
return TRUE;
}
// ----------------------------------------------------------------------------
// Description :
// ----------------------------------------------------------------------------
BOOL TAction_Interface::mfn_bCheckFamiliesZAList()
{
CString csMessage;
CPA_BaseObjectList *p_oList;
Position xPos;
// check ZAList for all families
p_oList = GetMainWorld() -> fn_p_oGetOriginalObjectList( C_szZAListTypeName );
xPos = p_oList -> GetHeadPosition();
while( xPos )
{
CPA_ZonesActivatingList *p_oZAList = (CPA_ZonesActivatingList*) p_oList -> GetNext( xPos );
if( ! p_oZAList -> mfn_bUpdate() )
{
csMessage = "Error on Activation List : " +
p_oZAList -> GetName() +
" (Names List : " +
p_oZAList -> GetOwner() -> GetName() +
" Family : " +
p_oZAList -> GetOwner() -> GetOwner() -> GetName() +
")";
M_TACError(M_Char(csMessage));
return FALSE;
}
}
return TRUE;
}
// ----------------------------------------------------------------------------
// Description : update engine CsaList before engine is run
// ----------------------------------------------------------------------------
BOOL TAction_Interface::mfn_bUpdateCsaListBeforeRunningEngine()
{
return ( mfn_bCheckFamiliesZA() && mfn_bCheckFamiliesZAList() );
}
// ----------------------------------------------------------------------------
// Description : update engine CsaList before saving
// ----------------------------------------------------------------------------
BOOL TAction_Interface::mfn_bUpdateCsaListBeforeSaving()
{
return ( mfn_bCheckFamiliesZA() && mfn_bCheckFamiliesZAList() );
}
/*-----------------------------------------------------------------------------
* Description : create all states
*---------------------------------------------------------------------------*/
void TAction_Interface::mfn_vUpdateAllStates( CPA_Family *_p_oFamily )
{
POSITION stPos = _p_oFamily -> m_oListOfStates . GetHeadPosition();
while( stPos )
{
CPA_State *p_oState = _p_oFamily -> m_oListOfStates . GetNext( stPos );
// update Next State
p_oState -> mfn_vInitNextState();
// update Transitional List
//p_oState -> mfn_vFillTransitionalList();
p_oState -> mfn_vFillTransitionStateList();
}
stPos = _p_oFamily -> m_oListOfActions . GetHeadPosition();
while( stPos )
{
CPA_Action *p_oAction = _p_oFamily -> m_oListOfActions . GetNext( stPos );
// CPA_Ed_1 Mihaela Tancu begin
p_oAction->mfn_vSetListOfStates(); //sort the list with states at the loading
// CPA_Ed_1 Mihaela Tancu end
}
}
// Shaitan => state list in the level
/*-----------------------------------------------------------------------------
* Description : update list of used actions
*---------------------------------------------------------------------------*/
void TAction_Interface::mfn_vUpdateListOfUsedActions( CPA_Family *_p_oFamily )
{
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
// check if the family is optimized
sprintf(szFileName,"%s\\%s\\Families\\%s\\%s.stl^%s",
fn_szGetLevelsDataPath(),
fn_p_szGetLevelName(),
_p_oFamily->GetName(),
_p_oFamily->GetName(),
C_SectionCreateListOfState);
if (SCR_fn_c_RdL0_IsSectionExists(szFileName))
{
// first get the engine callback function for otl file
SCR_tdst_Anl_Callback *pCallback = SCR_fnp_st_RdL0_GetRegisterCallback(C_SectionCreateListOfState, SCR_CRC_c_RdL0_ForSection);
SCR_tdpfn_Anl_Callback pPreviousCallback = pCallback->pfn_eCallback;
// then unregister it
SCR_fn_v_RdL0_DeleteRegisterCallback(C_SectionCreateListOfState, SCR_CRC_c_RdL0_ForSection, SCR_CDR_c_RdL0_Match);
// register the new callback
SCR_fn_v_RdL0_RegisterCallback(C_SectionCreateListOfState, m_fn_tdeCallBackLoadUsedActions,SCR_CRC_c_RdL0_ForSection);
// then force the script to analyze the section
SCR_M_RdL0_SetContextLong(C_ChildContext,0,_p_oFamily);
SCR_fnp_st_RdL0_AnalyseSection(szFileName, SCR_CDF_uw_Anl_ForceAnalyse);
// unregister the editor callback
SCR_fn_v_RdL0_DeleteRegisterCallback(C_SectionCreateListOfState, SCR_CRC_c_RdL0_ForSection, SCR_CDR_c_RdL0_Match);
// restore the normal loading function
SCR_fn_v_RdL0_RegisterCallback(C_SectionCreateListOfState, pPreviousCallback,SCR_CRC_c_RdL0_ForSection);
}
}
/*-----------------------------------------------------------------------------
* Description : load used actions
*---------------------------------------------------------------------------*/
SCR_tde_Anl_ReturnValue TAction_Interface::m_fn_tdeCallBackLoadUsedActions(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction)
{
SCR_tde_Anl_ReturnValue eReturnValue = SCR_ERV_Anl_NormalReturn;
tdxHandleToState hState = NULL;
CPA_Family *pFamily;
CPA_Action *pAction;
CPA_State *pState;
if ( M_IsEntry )
{
SCR_M_RdL0_GetContextLong(C_ThisContext,0,CPA_Family *,pFamily);
if ( M_ActionIs( C_Entry_State ) )
{
char szSection[SCR_CV_ui_Cfg_MaxLenName];
SCR_tdst_Link_Value *p_tdst_LinkEntry;
sprintf(szSection, "%s\\%s", fn_szGetFamiliesDataPath(), _ap_szParams[0]);
p_tdst_LinkEntry = SCR_fnp_st_Link_SearchKey(&g_st3DOSLinkTable.stState, szSection);
if (p_tdst_LinkEntry && ( SCR_M_e_Link_GetState(p_tdst_LinkEntry) == SCR_ELS_Link_Initialized))
hState = (tdxHandleToState) SCR_M_ul_Link_GetValue(p_tdst_LinkEntry);
if (hState)
{
pState = (CPA_State *)pFamily->GetMainWorld()->fn_p_oFindObjectWithEngine(hState, C_szStateTypeName);
if (pState)
{
pAction = pState->mfn_p_oGetAction();
if (!pFamily->m_oListOfUsedActions.Find(pAction))
pFamily->m_oListOfUsedActions.AddTail(pAction);
}
}
}
}
return ( eReturnValue );
}
// End Shaitan => module list in the level // End Shaitan => state list in the level
/*-----------------------------------------------------------------------------
* Description : load all actions
*---------------------------------------------------------------------------*/
void TAction_Interface::mfn_vLoadAllActions(CPA_Family *_p_oFamily)
{
char szActionFileName[SCR_CV_ui_Cfg_MaxLenName];
char *szFamily = M_Char(_p_oFamily->GetName());
// Shaitan => state list in the level
char szStateFileName[SCR_CV_ui_Cfg_MaxLenName];
sprintf(szStateFileName,"%s\\%s.sta",szFamily,szFamily);
if (SCR_fn_c_RdL0_IsSectionExists(szStateFileName))
{
SCR_M_RdL0_SetContextLong(C_GrandChildContext, 0, (long)_p_oFamily->GetStruct());
SCR_fnp_st_RdL0_AnalyseSection(szStateFileName, SCR_CDF_uw_Anl_Normal);
}
// End Shaitan => state list in the level
//
// construct filename that contains list of actions for the given family
sprintf( szActionFileName, "%s\\%s\\%s.ace", fn_szGetFamiliesDataPath(), szFamily, szFamily );
// set Family in current context
SCR_M_RdL0_SetContextLong( 2, 0, _p_oFamily);
// analyse file
if( SCR_fn_c_RdL0_IsSectionExists( szActionFileName ) )
SCR_fnp_st_RdL0_AnalyseSection( szActionFileName, SCR_CDF_uw_Anl_Normal );
//
if( _p_oFamily -> m_oListOfStates . GetCount() != LST2_M_StaticGetNumberOfElements( & _p_oFamily -> GetStruct() -> hForStateArray ) )
{
mfn_vWriteErrorOnFile(C_lNotEnoughtStates, _p_oFamily);
ERROR_PREPARE_M( C_szTACModuleNameErO, "Load actions & states : Actions file (.ace) and states file (.sta) are uncoherent",
"TAction_Interface::mfn_vLoadAllActions",
E_ERROR_GRAVITY_FATAL,
"Number of editor states is different from number of engine states"
);
ERROR_ASSERT( 0 );
}
}
/*-----------------------------------------------------------------------------
* Description : write a file with error
*---------------------------------------------------------------------------*/
void TAction_Interface::mfn_vWriteErrorOnFile(long _lErrorType,void *_p_void)
{
FILE *pFile = NULL;
char szFileName[255];
char szText[255];
CString csTime;
CTime oTime = CTime::GetCurrentTime();
CPA_Family *p_oFamily;
int iIndex;
tdxHandleToState hState;
SCR_tdst_Link_Value *p_tdst_LinkEntry;
CPA_BaseObjectList *p_oList;
// compute file name
strcpy(szFileName, fn_szGetGameDataPath());
strcat(szFileName, "\\TACError.txt");
// open file
pFile = fopen(szFileName, "at");
if (!pFile)
return;
// write date
csTime.Format("Date : %d/%d/%d %d:%d:%d\n\n", oTime.GetDay(), oTime.GetMonth(), oTime.GetYear(),
oTime.GetHour(), oTime.GetMinute(), oTime.GetSecond());
fputs((char*)(LPCTSTR)csTime, pFile);
// write error
switch ( _lErrorType )
{
case C_lNotEnoughtStates:
p_oFamily = (CPA_Family*) _p_void;
// write family name
sprintf( szText, "Number of editor states is different from number of engine states on family \"%s\"\n\n", p_oFamily -> fn_p_szGetName() );
fputs( szText, pFile );
fputs( "Engine state(s) without editor state(s) : \n\n", pFile );
// write all engine states without editor state
p_oList = GetBaseObjectList( C_szStateTypeName );
iIndex = 0;
LST2_M_StaticForEachElementOf( & p_oFamily -> GetStruct() -> hForStateArray, hState, iIndex)
{
// search editor state
CPA_BaseObject *p_oState = p_oList -> fn_p_oFindObjectWithdData( hState, "", p_oFamily );
if( p_oState == NULL )
{
// editor state not found, error
p_tdst_LinkEntry = SCR_fnp_st_Link_SearchValue( &g_st3DOSLinkTable.stState, (unsigned long)hState );
if ( p_tdst_LinkEntry && ( SCR_M_e_Link_GetState(p_tdst_LinkEntry) == SCR_ELS_Link_Initialized ) )
{
// engine object found
strcpy( szText, "->" );
SCR_fn_v_RdL0_SplitSectionName( SCR_M_p_sz_Link_GetKey(p_tdst_LinkEntry), NULL, NULL, szText + strlen( szText ) );
strcat( szText, "\n");
fputs( szText, pFile );
}
}
}
break;
}
// write end fine
fputs("\n##########################################################\n", pFile);
fclose(pFile);
}
/*-----------------------------------------------------------------------------
* Description : load actions for a given family
*---------------------------------------------------------------------------*/
void TAction_Interface::mfn_vLoadActions(CPA_Family *_p_oFamily)
{
// load actions
mfn_vLoadAllActions(_p_oFamily);
// update all states
mfn_vUpdateAllStates(_p_oFamily);
// Shaitan => state list in the level
// update list of used actions
mfn_vUpdateListOfUsedActions(_p_oFamily);
// End Shaitan => state list in the level
// update family
if( ( _p_oFamily -> mfn_p_oGetInitialAction() == NULL ) && ( _p_oFamily -> m_oListOfActions . GetCount() > 0 ) )
_p_oFamily -> mfn_vSetInitialAction( _p_oFamily -> m_oListOfActions . GetHeadElement() );
}
/*-----------------------------------------------------------------------------
* Description :
*---------------------------------------------------------------------------*/
void TAction_Interface::mfn_vUpdateMechanics()
{
CPA_BaseObjectList *p_oList = GetBaseObjectList( C_szStateTypeName );
Position xPos = p_oList -> GetHeadPosition();
while( xPos )
{
CPA_State *p_oState = (CPA_State*)p_oList -> GetNext( xPos );
p_oState -> mfn_vInitMechanics();
}
}
/*=============================================================================
* Commom DLL functions
=============================================================================*/
/*-----------------------------------------------------------------------------
* Description : register object type and callback load functions
*---------------------------------------------------------------------------*/
void TAction_Interface::fn_vJustAfterRegistered()
{
CString a_csType[] = { C_szActionTypeName , C_szStateTypeName ,
C_szZAListTypeName , C_szZATypeName };
fn_vRegisterObjectsType ( a_csType , 4 ) ;
// register section for SCRIPT analysis
SCR_fn_v_RdL0_RegisterCallback( "CreateNewEDTAction", CPA_Action::fn_AddNewAction, SCR_CRC_c_RdL0_ForSection );
// init
CPA_State::Init();
CPA_ZdxIndex::Init();
CPA_ZonesActivating::Init();
CPA_ActivationState::Init();
CPA_ZonesActivatingList::Init();
}
/*-----------------------------------------------------------------------------
* Description : construct view for interface
*---------------------------------------------------------------------------*/
void TAction_Interface::fn_vConstruct()
{
#ifndef __INACTIVE_INTERFACE__
CString csFileName;
char szDimension[256];
int iDim;
RECT xRect;
::GetClientRect( GetDesktopWindow(), &xRect );
int x = xRect . right - 200;
TUT_M_vGetTutDll();
csFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\Action\\Action.ini";
// Open Mode
GetPrivateProfileString ("Preference", "Open Mode", "STM", szDimension, 256, (char*)(LPCSTR)csFileName);
m_bStateMode = !strcmpi( szDimension, "STM" );
/////////////
// STATE MODE
/////////////
/*
* FRMBase left
*/
// Get Preferences
GetPrivateProfileString ("Preference", "STM Left Frame Width", "200", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterLeftSTM = new CSplitFrame () ;
m_p_oSplitterLeftSTM -> CreateBase ( "Actions" , 1, 2, GetMainWorld () );
m_p_oSplitterLeftSTM -> m_iInitWidth = iDim;
m_p_oSplitterLeftSTM -> mfn_vEnableCaption(FALSE);
m_p_oSplitterLeftSTM -> m_stWinRight . cLinkSame = FRM_C_MoveBottom ;
m_p_oSplitterLeftSTM -> CreateSplitter ( C_cVerticalSplitter , 3 ) ;
// first pane : Dialog list with family list
GetPrivateProfileString ("Preference", "STM DialogList Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oDialogListSTM = new CPA_DialogList ();
m_p_oDialogListSTM -> fn_vInitDialog(this, m_p_oSplitterLeftSTM);
m_p_oDialogListSTM -> SetDefaultDisplay( FALSE );
m_p_oSplitterLeftSTM -> SetPaneView(0, m_p_oDialogListSTM, "Families", iDim );
TUT_M_vRegisterDialogList( m_p_oDialogListSTM, "TAC_STM_FAMILYLIST_LIST", "TAC_STM_FAMILYLIST_TREE", "TAC_STM_FAMILYLIST_COMBO", "TAC_STM_FAMILYLIST_BT");
HINSTANCE hOldInst = AfxGetResourceHandle();
AfxSetResourceHandle( m_p_stDLLIdentity->hModule );
// second pane 'STATE MODE' : action list
GetPrivateProfileString ("Preference", "STM ActionList Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterLeftSTM -> CreateView( 1, RUNTIME_CLASS ( CDlgActionList ), "Actions", iDim ) ;
m_p_oDlgActionList = (CDlgActionList*)m_p_oSplitterLeftSTM -> m_fn_p_oGetPane ( 1 ) ;
m_p_oDlgActionList -> fn_vSetParentDLL ( this ) ;
// third pane 'STATE MODE' : Action content (list of action state)
GetPrivateProfileString ("Preference", "STM stateList Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterLeftSTM -> CreateView ( 2, RUNTIME_CLASS ( CDlgActionContents ) , "Action Contents" , iDim ) ;
m_p_oDlgActionContents = (CDlgActionContents*)m_p_oSplitterLeftSTM -> m_fn_p_oGetPane ( 2 ) ;
m_p_oDlgActionContents -> fn_vSetParentDLL ( this ) ;
// CPA_Ed_1 Mihaela Tancu begin
m_hDlgActionContentsHwnd = m_p_oDlgActionContents->m_hWnd;
// CPA_Ed_1 Mihaela Tancu end
/*
* FRMBase bottom
*/
GetPrivateProfileString ("Preference", "STM Bottom Frame Height", "220", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterBottomSTM = new CSplitFrame () ;
m_p_oSplitterBottomSTM -> CreateBase ( "AnimActions" , 2, 3, GetMainWorld () ) ;
m_p_oSplitterBottomSTM -> m_iInitHeight = 200;
m_p_oSplitterBottomSTM -> mfn_vEnableCaption(FALSE);
m_p_oSplitterBottomSTM -> CreateSplitter ( C_cHorizontalSplitter , 2 ) ;
// first pane 'STATE MODE' : state parameters
GetPrivateProfileString ("Preference", "STM StateContent Width", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterBottomSTM -> CreateView ( 0, RUNTIME_CLASS ( CDlgState ) , "State" , x*2/3 ) ;
m_p_oDlgState = (CDlgState*)m_p_oSplitterBottomSTM -> m_fn_p_oGetPane ( 0 ) ;
m_p_oDlgState -> fn_vSetParentDLL ( this ) ;
// second pane 'STATE MODE' : Anim List
GetPrivateProfileString ("Preference", "STM AnimationList Width", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterBottomSTM -> CreateView ( 1, RUNTIME_CLASS ( CDlgAnimList ) , "Animations" , 0 ) ;
m_p_oDlgAnimList = (CDlgAnimList*)m_p_oSplitterBottomSTM -> m_fn_p_oGetPane ( 1 ) ;
m_p_oDlgAnimList -> mfn_vSetParentDLL ( this ) ;
AfxSetResourceHandle( hOldInst );
/////////////
// ZA MODE
/////////////
GetPrivateProfileString ("Preference", "ZAM Left Frame Width", "200", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterLeftZAM = new CSplitFrame () ;
m_p_oSplitterLeftZAM -> CreateBase ( "Actions" , 1, 2, GetMainWorld () );
m_p_oSplitterLeftZAM -> m_iInitWidth = iDim;
m_p_oSplitterLeftZAM -> mfn_vEnableCaption(FALSE);
m_p_oSplitterLeftZAM -> m_stWinRight . cLinkSame = FRM_C_MoveBottom ;
m_p_oSplitterLeftZAM -> CreateSplitter ( C_cVerticalSplitter , 4 ) ;
// first pane : Dialog list with family list
GetPrivateProfileString ("Preference", "ZAM DialogList Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oDialogListZAM = new CPA_DialogList ();
m_p_oDialogListZAM -> fn_vInitDialog(this, m_p_oSplitterLeftZAM);
m_p_oDialogListZAM -> SetDefaultDisplay( FALSE );
m_p_oSplitterLeftZAM -> SetPaneView(0, m_p_oDialogListZAM, "Families", iDim );
TUT_M_vRegisterDialogList( m_p_oDialogListZAM, "TAC_ZAM_FAMILYLIST_LIST", "TAC_ZAM_FAMILYLIST_TREE", "TAC_ZAM_FAMILYLIST_COMBO", "TAC_ZAM_FAMILYLIST_BT");
hOldInst = AfxGetResourceHandle();
AfxSetResourceHandle( m_p_stDLLIdentity->hModule );
// second pane 'ZA MODE' : Names List
GetPrivateProfileString ("Preference", "ZAM NamesList Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterLeftZAM -> CreateView ( 1, RUNTIME_CLASS ( CDlgNameList ) , "Names List" , iDim ) ;
m_p_oDlgNameList = (CDlgNameList*)m_p_oSplitterLeftZAM -> m_fn_p_oGetPane ( 1 ) ;
m_p_oDlgNameList -> mfn_vSetParentDLL ( this ) ;
// third pans 'ZA MODE' : ZAList
GetPrivateProfileString ("Preference", "ZAM ZAList Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterLeftZAM -> CreateView ( 2, RUNTIME_CLASS ( CDlgZAL ) , "Activation Lists" , iDim ) ;
m_p_oDlgZAList = (CDlgZAL*)m_p_oSplitterLeftZAM -> m_fn_p_oGetPane ( 2 ) ;
m_p_oDlgZAList -> mfn_vSetParentDLL ( this ) ;
// fourth pane 'ZA MODE' : Actions
GetPrivateProfileString ("Preference", "ZAM ActionList Height", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterLeftZAM -> CreateView ( 3, RUNTIME_CLASS ( CDlgAction ) , "Actions" , iDim ) ;
m_p_oDlgActions = (CDlgAction*)m_p_oSplitterLeftZAM -> m_fn_p_oGetPane ( 3 ) ;
m_p_oDlgActions -> mfn_vSetParentDLL ( this ) ;
/*
* FRMBase bottom
*/
GetPrivateProfileString ("Preference", "ZAM Bottom Frame Height", "200", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterBottomZAM = new CSplitFrame () ;
m_p_oSplitterBottomZAM -> CreateBase ( "AnimActions" , 2, 3, GetMainWorld () ) ;
m_p_oSplitterBottomZAM -> m_iInitHeight = iDim;
m_p_oSplitterBottomZAM -> mfn_vEnableCaption(FALSE);
m_p_oSplitterBottomZAM -> CreateSplitter ( C_cHorizontalSplitter , 2 ) ;
// first pane 'ZA MODE' : ZAList Content
GetPrivateProfileString ("Preference", "ZAM ZAList Content Width", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterBottomZAM -> CreateView ( 0, RUNTIME_CLASS ( CDlgZAList ) , "Activations List Content" , iDim ) ;
m_p_oDlgZAListContent = (CDlgZAList*)m_p_oSplitterBottomZAM -> m_fn_p_oGetPane ( 0 ) ;
m_p_oDlgZAListContent -> mfn_vSetParentDLL ( this ) ;
// second pane 'ZA MODE' : ZA
GetPrivateProfileString ("Preference", "ZAM ActivationList Width", "0", szDimension, 256, (char*)(LPCSTR)csFileName);
iDim = atoi(szDimension);
m_p_oSplitterBottomZAM -> CreateView ( 1, RUNTIME_CLASS ( CDlgZonesActivation ) , "Activations" , iDim ) ;
m_p_oDlgZA = (CDlgZonesActivation*)m_p_oSplitterBottomZAM -> m_fn_p_oGetPane ( 1 ) ;
m_p_oDlgZA -> mfn_vSetParentDLL ( this ) ;
//
m_p_oDlgActions -> mfn_vSetDlgZAList( m_p_oDlgZAListContent );
m_p_oDlgZAListContent -> mfn_vSetDlgZA( m_p_oDlgZA );
m_p_oDlgZA -> mfn_vSetDlgZAList( m_p_oDlgZAListContent );
// Register the frames to the tutorial manager
TUT_M_vRegisterControl (m_p_oSplitterLeftSTM -> m_hWnd , "TAC_LeftFrame_State" , TUT_e_Window);
TUT_M_vRegisterControl (m_p_oSplitterBottomSTM -> m_hWnd , "TAC_BottomFrame_State" , TUT_e_Window);
TUT_M_vRegisterControl (m_p_oSplitterLeftZAM -> m_hWnd , "TAC_LeftFrame_Activation" , TUT_e_Window);
TUT_M_vRegisterControl (m_p_oSplitterBottomZAM -> m_hWnd , "TAC_BottomFrame_Activation" , TUT_e_Window);
AfxSetResourceHandle( hOldInst );
//mfn_vRestorePreferences();
#endif /* __INACTIVE_INTERFACE__ */
}
/*-----------------------------------------------------------------------------
* Description : Before editor becomes active
*---------------------------------------------------------------------------*/
void TAction_Interface::fn_vBeforeEditor()
{
// activate Frame
if(m_lEditorState == C_lEDST_Active)
{
mfn_vSetEditMode( m_bStateMode, TRUE );
}
}
/*-----------------------------------------------------------------------------
* Description : verify datas coherence
*---------------------------------------------------------------------------*/
BOOL TAction_Interface::fn_bAcceptToRunEngine()
{
// update Families (is on level)
CPA_BaseObjectList *p_oList = GetMainWorld() -> fn_p_oGetOriginalObjectList( C_szActorInstanceTypeName );
if( p_oList )
{
Position xPos = p_oList -> GetHeadPosition();
while( xPos )
{
CPA_BaseObject *p_oActor = p_oList -> GetNext( xPos );
((CPA_Family*) p_oActor -> GetOwner() -> GetOwner()) -> mfn_vSetOnLevel( TRUE );
}
}
// update state
p_oList = GetMainWorld() -> fn_p_oGetOriginalObjectList( C_szFamilyTypeName );
if( p_oList )
{
Position xPos = p_oList -> GetHeadPosition();
while( xPos )
{
CPA_Family *p_oFamily = (CPA_Family*) p_oList -> GetNext( xPos );
if( p_oFamily -> mfn_bIsLoadedOnCurrentLevel() )
{
if( !mfn_bUpdateStateBeforeRunningEngine( p_oFamily ) )
return FALSE;
}
}
}
// update Csa List (ZA & ZAList)
if( !mfn_bUpdateCsaListBeforeRunningEngine() )
return FALSE;
// all OK
return TRUE;
}
/*-----------------------------------------------------------------------------
* Description : verify datas coherence
*---------------------------------------------------------------------------*/
BOOL TAction_Interface::fn_bAcceptToSave()
{
// update Families (is on level)
CPA_BaseObjectList *p_oList = GetMainWorld() -> fn_p_oGetOriginalObjectList( C_szActorInstanceTypeName );
if( p_oList )
{
Position xPos = p_oList -> GetHeadPosition();
while( xPos )
{
CPA_BaseObject *p_oActor = p_oList -> GetNext( xPos );
((CPA_Family*) p_oActor -> GetOwner() -> GetOwner()) -> mfn_vSetOnLevel( TRUE );
}
}
// update state
p_oList = GetMainWorld() -> fn_p_oGetOriginalObjectList( C_szFamilyTypeName );
if( p_oList )
{
Position xPos = p_oList -> GetHeadPosition();
while( xPos )
{
CPA_Family *p_oFamily = (CPA_Family*) p_oList -> GetNext( xPos );
if( p_oFamily -> mfn_bIsLoadedOnCurrentLevel() )
{
if( !mfn_bUpdateStateBeforeSaving( p_oFamily ) )
return FALSE;
}
}
}
// update Csa List (ZA & ZAList)
if( !mfn_bUpdateCsaListBeforeSaving() )
return FALSE;
// all OK
return TRUE;
}
/*-----------------------------------------------------------------------------
* Description : Before engine becomes active
*---------------------------------------------------------------------------*/
void TAction_Interface::fn_vBeforeEngine(void)
{
// desactivate frames
if(m_lEditorState == C_lEDST_Active)
{
g_oFrameGest.mfn_vSetRefresh(FALSE);
g_oFrameGest.mfn_vDisactivateWindow ( m_bStateMode ? m_p_oSplitterBottomSTM : m_p_oSplitterBottomZAM ) ;
g_oFrameGest.mfn_vDisactivateWindow ( m_bStateMode ? m_p_oSplitterLeftSTM : m_p_oSplitterLeftZAM ) ;
g_oFrameGest.mfn_vSetRefresh(TRUE);
}
}
/*=============================================================================
* Menus methods
=============================================================================*/
//**************************************************************************************
//Begin Mircea Dunka 31 Aug 1998 - DialogBar interface
void TAction_Interface::fn_vDefineDlgBarBtnIcon (tde_DlgBarCategory wCategory, tds_DlgBarBtn *_pDlgBarBtn)
{
if(wCategory == C_DlgBarCategoryEditor)
{
_pDlgBarBtn->hIcon = ::LoadIcon((HINSTANCE)(GetDLLIdentity()->hModule), MAKEINTRESOURCE(IDI_TAC_DLGBAR_ICON));
CString oCst;
oCst = "Action";
if( (M_GetMainApp()) && (M_GetMainApp()->mp_oAppKeyboard) )
{
oCst += " (";
oCst += M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Actions Editor"));
oCst += ")";
}
strcpy(_pDlgBarBtn->szToolTip, (char*)(LPCTSTR)oCst);
_pDlgBarBtn->uID = (UINT)this;
}
}
//end Mircea Dunka 31 Aug 1998
/*-----------------------------------------------------------------------------
* Description : Add entry in editor menu
*---------------------------------------------------------------------------*/
BOOL TAction_Interface::fn_bDefineSubMenu(EDT_SubMenu *_p_oEDTSubMenu)
{
#ifndef __INACTIVE_INTERFACE__
if (_p_oEDTSubMenu->GetSubMenuType() == C_SubMenuEditor)
{
// submenu "Editor"
CString oCst;
oCst = "Action";
if( M_GetMainApp()->mp_oAppKeyboard )
{
oCst += "\t";
oCst += M_GetMainApp() -> mp_oAppKeyboard -> mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Actions Editor"));
}
_p_oEDTSubMenu->AddAnEntry(this, (char*)(LPCTSTR)oCst, C_uiTACPopupEdit, m_lEditorState == C_lEDST_Active);
return TRUE;
}
else if (_p_oEDTSubMenu->GetSubMenuType() == C_SubMenuPreference)
{
CPA_EditorBase *p_oDLL;
BOOL bCompleteLoad;
// submenu "Preference"
_p_oEDTSubMenu->AddAnEntry(this, "Save Dialogs Dimensions", C_uiTACPrefSaveDim);
_p_oEDTSubMenu->AddASeparator();
// Complete Load for Families
p_oDLL = GetMainWorld()->GetToolDLLWithName( C_szDLLFamilyName );
if( p_oDLL )
{
bCompleteLoad = (BOOL)p_oDLL -> OnQueryInfos( this, C_uiGetCompleteLoadModeTFA, 0 );
_p_oEDTSubMenu->AddAnEntry(this, "Complete Load for Families", C_uiTACPrefLoadFam, bCompleteLoad);
}
// Complete Load for Animations
p_oDLL = GetMainWorld()->GetToolDLLWithName( C_szDLLAnimationName );
if( p_oDLL )
{
bCompleteLoad = (BOOL)p_oDLL -> OnQueryInfos( this, C_cGetCompleteLoadModeTAN, 0 );
_p_oEDTSubMenu->AddAnEntry(this, "Complete Load for Animations", C_uiTACPrefLoadAnm, bCompleteLoad);
}
return TRUE;
}
#endif /* __INACTIVE_INTERFACE__ */
return FALSE;
}
/*-----------------------------------------------------------------------------
* Description : Manage choice of Action entry in editor menu
*---------------------------------------------------------------------------*/
void TAction_Interface::_OnSubMenuCommand(EDT_SubMenu *_p_oEDTSubMenu,UINT uiMsgID)
{
if( (_p_oEDTSubMenu->GetSubMenuType() == C_SubMenuEditor) && ( uiMsgID == C_uiTACPopupEdit ) )
{
if(m_lEditorState == C_lEDST_Active)
GetMainWorld()->fn_bCloseEditor( this ); // desactive editor
else
GetMainWorld()->fn_bActivateEditor( this, NULL ); // active editor
}
else if( _p_oEDTSubMenu->GetSubMenuType() == C_SubMenuPreference )
{
CPA_EditorBase *p_oDLL;
BOOL bCompleteLoad;
switch( uiMsgID )
{
case C_uiTACPrefSaveDim:
mfn_vSavePreferences();
break;
case C_uiTACPrefLoadFam:
p_oDLL = GetMainWorld()->GetToolDLLWithName( C_szDLLFamilyName );
bCompleteLoad = (BOOL)p_oDLL -> OnQueryInfos( this, C_uiGetCompleteLoadModeTFA, 0 );
p_oDLL -> OnQueryAction( this, C_uiSetCompleteLoadModeTFA, !bCompleteLoad );
break;
case C_uiTACPrefLoadAnm:
p_oDLL = GetMainWorld()->GetToolDLLWithName( C_szDLLAnimationName );
bCompleteLoad = (BOOL)p_oDLL -> OnQueryInfos( this, C_cGetCompleteLoadModeTAN, 0 );
p_oDLL -> OnQueryAction( this, C_cSetCompleteLoadModeTAN, !bCompleteLoad );
break;
}
}
}
/*-----------------------------------------------------------------------------
* Description : Add entry in Popup Menu
*---------------------------------------------------------------------------*/
BOOL TAction_Interface::fn_bDefinePopupMenu(EDT_PopUpMenu *pPopup, CPA_List<CPA_SuperObject> *pSelection, BOOL bAsCurrentEditor)
{
if(bAsCurrentEditor)
{
// TAction is current editor
pPopup->AddAnEntry(this, "Exit Action Editor", C_uiTACPopupEdit);
return TRUE;
}
return FALSE;
}
/*-----------------------------------------------------------------------------
* Description : Manage choice of Action entry in PopupMenu
*---------------------------------------------------------------------------*/
void TAction_Interface::_OnPopUpMenuCommand(UINT m_IDCmdMsg)
{
if( m_IDCmdMsg == C_uiTACPopupEdit )
{
if(m_lEditorState == C_lEDST_Active)
GetMainWorld()->fn_bCloseEditor( this ); // desactive editor
else
GetMainWorld()->fn_bActivateEditor( this, NULL ); // active editor
}
}
/*=============================================================================
* Current editor methods
=============================================================================*/
BOOL TAction_Interface::fn_bCanActivateEditor(CPA_List<CPA_BaseObject> *pParams)
{
#ifndef __INACTIVE_INTERFACE__
return (m_lEditorState == C_lEDST_Inactive);
#else
return FALSE;
#endif /* __INACTIVE_INTERFACE__ */
}
BOOL TAction_Interface::fn_bCanCloseEditor(void)
{
return (m_lEditorState != C_lEDST_Inactive);
}
//--------------------------------------------------------------------------------
// called when current editor becomes active
//--------------------------------------------------------------------------------
void TAction_Interface::fn_vOnActivateEditor(CPA_List<CPA_BaseObject> *pParams, BOOL bBackActivated)
{
// set editor as active
m_lEditorState = C_lEDST_Active;
// update mechanics
mfn_vUpdateMechanics();
// use first element of list (if exists)
if( pParams && (pParams -> GetCount()) )
{
CPA_BaseObject *p_oBaseObject = pParams -> GetHead () ;
if( p_oBaseObject -> fn_bIsOfType( C_szFamilyTypeName ) ) // family
OnQueryOpen( this, C_uiOpenWithFamily, (LPARAM)(CPA_Family*)p_oBaseObject );
else if( p_oBaseObject -> fn_bIsOfType( C_szActionTypeName ) ) // action
OnQueryOpen( this, C_uiOpenWithAction, (LPARAM)(CPA_Action*)p_oBaseObject );
else if( p_oBaseObject -> fn_bIsOfType( C_szStateTypeName ) ) // state
OnQueryOpen( this, C_uiOpenWithState, (LPARAM)(CPA_State*)p_oBaseObject );
else if( p_oBaseObject -> fn_bIsOfType( C_szZDeNameListType ) ||
p_oBaseObject -> fn_bIsOfType( C_szZDdNameListType ) ||
p_oBaseObject -> fn_bIsOfType( C_szZDmNameListType ) ||
p_oBaseObject -> fn_bIsOfType( C_szZDrNameListType ) ) // NamesList
OnQueryOpen( this, C_uiOpenWithNameList, (LPARAM)(CPA_tdoNameList*)p_oBaseObject );
else if( p_oBaseObject -> fn_bIsOfType( C_szZAListTypeName ) ) // ZAList
OnQueryOpen( this, C_uiOpenWithZAList, (LPARAM)(CPA_ZonesActivatingList*)p_oBaseObject );
else if( p_oBaseObject -> fn_bIsOfType( C_szZATypeName ) ) // ZA
OnQueryOpen( this, C_uiOpenWithZA, (LPARAM)(CPA_ZonesActivating*)p_oBaseObject );
else if( p_oBaseObject -> fn_bIsOfType( C_szActorInstanceTypeName ) ) // Actor
{
tdxHandleToState hState = fn_h3dDataGetCurrentState( ((CPA_Actor*)p_oBaseObject) -> GetStruct() -> h_3dData );
p_oBaseObject = p_oBaseObject -> GetOwner(); // model
if( p_oBaseObject )
{
p_oBaseObject = p_oBaseObject -> GetOwner(); // family
if( p_oBaseObject && p_oBaseObject -> fn_bIsOfType( C_szFamilyTypeName ) )
{
if( hState )
{
CPA_State* p_oState = (CPA_State*)GetBaseObject( hState, C_szStateTypeName, p_oBaseObject );
if( p_oState )
OnQueryOpen( this, C_uiOpenWithState, (LPARAM)(CPA_State*)p_oBaseObject );
else
OnQueryOpen( this, C_uiOpenWithFamily, (LPARAM)(CPA_Family*)p_oState );
}
else
OnQueryOpen( this, C_uiOpenWithFamily, (LPARAM)(CPA_Family*)p_oBaseObject );
}
}
}
}
else
{
// use selection if exists
if (M_GetCountSelected() == 1)
{
CPA_SuperObject *p_oSuperObject = M_GetSingleSelection() ;
if( p_oSuperObject )
{
CPA_BaseObject *p_oBaseObject = p_oSuperObject -> GetObject(); // actor
if( p_oBaseObject && p_oBaseObject -> fn_bIsOfType( C_szActorInstanceTypeName ) )
{
tdxHandleToState hState = fn_h3dDataGetCurrentState( M_GetMSHandle( p_oSuperObject -> GetStruct(), 3dData ) );
p_oBaseObject = p_oBaseObject -> GetOwner(); // model
if( p_oBaseObject )
{
p_oBaseObject = p_oBaseObject -> GetOwner(); // family
if( p_oBaseObject && p_oBaseObject -> fn_bIsOfType( C_szFamilyTypeName ) )
{
CPA_State* p_oState = (CPA_State*)GetBaseObject( hState, C_szStateTypeName, p_oBaseObject );
if( p_oState )
{
OnQueryOpen( this, C_uiOpenWithState, (LPARAM)(CPA_State*)p_oState );
return;
}
else
{
OnQueryOpen( this, C_uiOpenWithFamily, (LPARAM)(CPA_Family*)p_oBaseObject );
return;
}
}
}
}
}
}
// use previous selection (if exists)
if( m_p_oCurrentState )
OnQueryOpen( this, C_uiOpenWithState, (LPARAM)m_p_oCurrentState );
else if( m_p_oCurrentAction )
OnQueryOpen( this, C_uiOpenWithAction, (LPARAM)m_p_oCurrentAction );
else if( m_p_oCurrentFamily )
OnQueryOpen( this, C_uiOpenWithFamily, (LPARAM)m_p_oCurrentFamily );
else if( m_p_oCurrentNameList )
OnQueryOpen( this, C_uiOpenWithNameList, (LPARAM)m_p_oCurrentNameList );
else if( m_p_oCurrentZAList )
OnQueryOpen( this, C_uiOpenWithZAList, (LPARAM)m_p_oCurrentZAList );
else if( m_p_oCurrentZA )
OnQueryOpen( this, C_uiOpenWithZA, (LPARAM)m_p_oCurrentZA );
else
OnQueryOpen( this, C_uiOpenWithNone,0);
}
// display Tip of the Day
GetInterface()->fn_vDisplayTipOfDay("Actions", "TAC", g_bTipFirstTime);
g_bTipFirstTime = FALSE;
}
//--------------------------------------------------------------------------------
// called when material editor becomes inactive
//--------------------------------------------------------------------------------
void TAction_Interface::fn_vOnCloseEditor()
{
// set editor as inactive
m_lEditorState = C_lEDST_Inactive;
OnQueryClose( this, 0,0);
}
/*=============================================================================
* TOOL DLL functions
=============================================================================*/
//--------------------------------------------------------------------------------
// OnQueryOpen : called when editor becomes active
//--------------------------------------------------------------------------------
long TAction_Interface::OnQueryOpen(CPA_EditorBase*, WPARAM _wParam, LPARAM lParam)
{
#ifndef __INACTIVE_INTERFACE__
switch( _wParam )
{
case C_uiOpenWithNone:
case C_uiOpenWithFamily:
break;
case C_uiOpenWithAction:
case C_uiOpenWithState:
m_bStateMode = TRUE;
break;
case C_uiOpenWithNameList:
m_bStateMode = FALSE;
case C_uiOpenWithZAList:
break;
}
mfn_vSetEditMode( m_bStateMode, TRUE );
switch( _wParam )
{
case C_uiOpenWithNone:
m_p_oCurrentFamily = NULL;
mfn_vSetCurrentFamily( m_p_oCurrentFamily ) ;
break;
case C_uiOpenWithFamily:
m_p_oCurrentFamily = (CPA_Family*)lParam;
mfn_vSetCurrentFamily( m_p_oCurrentFamily ) ;
break;
case C_uiOpenWithAction:
m_p_oCurrentFamily = (CPA_Family*)((CPA_Action*)lParam)->GetOwner();
mfn_vSetCurrentFamily( m_p_oCurrentFamily ) ;
m_p_oCurrentAction = (CPA_Action*)lParam;
mfn_vSetCurrentAction( m_p_oCurrentAction ) ;
break;
case C_uiOpenWithState:
m_p_oCurrentFamily = (CPA_Family*)((CPA_State*)lParam) -> GetOwner();
mfn_vSetCurrentFamily( m_p_oCurrentFamily ) ;
m_p_oCurrentAction = ((CPA_State*)lParam) -> mfn_p_oGetAction();
mfn_vSetCurrentAction( m_p_oCurrentAction ) ;
m_p_oCurrentState = (CPA_State*)lParam;
mfn_vSetCurrentState( m_p_oCurrentState ) ;
break;
case C_uiOpenWithNameList:
m_p_oCurrentFamily = (CPA_Family*)((CPA_tdoNameList*)lParam) -> GetOwner();
mfn_vSetCurrentFamily( m_p_oCurrentFamily ) ;
m_p_oCurrentNameList = (CPA_tdoNameList*)lParam;
mfn_vSetCurrentNameList( m_p_oCurrentNameList );
break;
case C_uiOpenWithZAList:
m_p_oCurrentFamily = (CPA_Family*)((CPA_ZonesActivatingList*)lParam) -> GetOwner() -> GetOwner();
mfn_vSetCurrentFamily( m_p_oCurrentFamily ) ;
m_p_oCurrentNameList = (CPA_tdoNameList*)((CPA_ZonesActivatingList*)lParam) -> GetOwner();
mfn_vSetCurrentNameList( m_p_oCurrentNameList );
m_p_oCurrentZAList = (CPA_ZonesActivatingList*)lParam;
mfn_vSetCurrentZAList( m_p_oCurrentZAList );
break;
case C_uiOpenWithZA:
m_p_oCurrentFamily = (CPA_Family*)((CPA_ZonesActivating*)lParam) -> GetOwner() -> GetOwner();
mfn_vSetCurrentFamily( m_p_oCurrentFamily ) ;
m_p_oCurrentNameList = (CPA_tdoNameList*)((CPA_ZonesActivating*)lParam) -> GetOwner();
mfn_vSetCurrentNameList( m_p_oCurrentNameList );
m_p_oCurrentZA = (CPA_ZonesActivating*)lParam;
mfn_vSetCurrentZA( m_p_oCurrentZA );
break;
}
#endif /* __INACTIVE_INTERFACE__ */
return 0;
}
/*-----------------------------------------------------------------------------
* OnQueryAction
*---------------------------------------------------------------------------*/
long TAction_Interface::OnQueryAction(CPA_EditorBase *p_oSender, WPARAM wAction, LPARAM lParam)
{
tdstLoadInfo *p_stLoadInfo;
tdstModifZone *p_stZone;
switch( wAction )
{
case C_uiLoadAllActions:
mfn_vLoadActions( (CPA_Family *) lParam );
break;
case C_uiRemoveZone:
p_stZone = (tdstModifZone*)lParam;
mfn_vRemoveZoneFromNamesList( p_stZone -> p_oNameList, p_stZone -> wIndex );
break;
case C_uiInsertZone:
p_stZone = (tdstModifZone*)lParam;
mfn_vInsertZoneToNamesList( p_stZone -> p_oNameList, p_stZone -> wIndex ) ;
break;
case C_uiLoadZA:
p_stLoadInfo = (tdstLoadInfo*)lParam;
return (long)mfn_p_oCreateNewZA( p_stLoadInfo -> m_p_oNameList, p_stLoadInfo -> m_szName );
break;
case C_uiLoadZAList:
p_stLoadInfo = (tdstLoadInfo*)lParam;
return (long)mfn_p_oCreateNewZAList( p_stLoadInfo -> m_p_oNameList, p_stLoadInfo -> m_szName );
break;
case C_uiUpdateFamiliesList:
if( m_lEditorState == C_lEDST_Active )
{
// Dialog Lists
m_p_oCurrentFamily = (CPA_Family*) (m_bStateMode ? m_p_oDialogListSTM -> GetSelectedObject() : m_p_oDialogListZAM -> GetSelectedObject());
m_p_oDialogListZAM -> fn_vInitAllLists();
m_p_oDialogListZAM -> fn_vReinitDialog() ;
m_p_oDialogListZAM -> fn_vUpdateSelection( E_lrm_ChangeSelection );
m_p_oDialogListSTM -> fn_vInitAllLists();
m_p_oDialogListSTM -> fn_vReinitDialog() ;
m_p_oDialogListSTM -> fn_vUpdateSelection( E_lrm_ChangeSelection );
//
m_p_oDlgState -> mfn_vFillFamilyList();
m_p_oDlgAnimList -> mfn_vFillCBFamilies();
mfn_vSetCurrentFamily( m_p_oCurrentFamily );
}
break;
case C_uiUpdateZAList:
{
CPA_BaseObjectList *p_oList = GetBaseObjectList( C_szZAListTypeName );
Position xPos = p_oList -> GetHeadPosition();
while( xPos )
{
CPA_ZonesActivatingList *p_oZAList = (CPA_ZonesActivatingList*)p_oList -> GetNext( xPos );
if( p_oZAList -> GetOwner() -> GetOwner() == (CPA_BaseObject*)lParam )
p_oZAList -> mfn_vFillZAList();
}
}
break;
case C_uiUpdateAnimList:
if( ( m_lEditorState == C_lEDST_Active ) && m_bStateMode )
{
m_p_oDlgAnimList -> mfn_vSetFamily( m_p_oCurrentFamily );
m_p_oDlgState -> mfn_vFillAnimationList( m_p_oCurrentFamily );
}
break;
}
return 0;
}
/*-----------------------------------------------------------------------------
* Create a New ZA
*---------------------------------------------------------------------------*/
CPA_BaseObject *TAction_Interface::mfn_p_oCreateNewZA(CPA_tdoNameList *_p_oName, char *_szName)
{
SCR_tdst_Link_Value *p_tdst_LKValue;
char szLinkName[SCR_CV_ui_Cfg_MaxLenName];
BOOL bPreviousLoadingWorld = GetInterface() -> fn_bIsLoadingWorld();
// construct Complete section name
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
// BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE BIDOUILLE
//
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
strcpy( szLinkName, fn_szGetZdxDataPath() );
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
strcat( szLinkName, "\\" );
strcat( szLinkName, _szName );
// search on LinkTable
p_tdst_LKValue = SCR_fnp_st_Link_SearchKey( &g_st3DOSLinkTable.stACZ, szLinkName );
if ( !p_tdst_LKValue )
{
// ZA not yet loaded, load now
SCR_tdst_Cxt_Values *p_stValues = SCR_fnp_st_RdL0_AnalyseSection( _szName, SCR_CDF_uw_Anl_Normal );
ZDX_tdxHandleToZoneSetList hZoneSetListe=(ZDX_tdxHandleToZoneSetList)(p_stValues->a_ulValues[0]);
// add to LinkTable
SCR_fnp_st_Link_CreateOrGetLinkFromKey( &g_st3DOSLinkTable.stACZ, szLinkName);
p_tdst_LKValue = SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stACZ, szLinkName,(unsigned long)hZoneSetListe);
}
if ( p_tdst_LKValue && (SCR_M_e_Link_GetState( p_tdst_LKValue ) != SCR_ELS_Link_NotInitialized ) )
{
ZDX_tdxHandleToZoneSetList hEngineZA = (ZDX_tdxHandleToZoneSetList)SCR_M_ul_Link_GetValue( p_tdst_LKValue );
char szName[SCR_CV_ui_Cfg_MaxLenName];
SCR_fn_v_RdL0_SplitSectionName(_szName,NULL,NULL,szName);
GetInterface() -> SetLoadingWorld( TRUE );
CPA_ZonesActivating *p_oZA = new CPA_ZonesActivating( this, _p_oName, szName, hEngineZA);
GetInterface() -> SetLoadingWorld( bPreviousLoadingWorld );
return (CPA_BaseObject*)p_oZA;
}
return NULL;
}
/*-----------------------------------------------------------------------------
* Create a New ZAList
*---------------------------------------------------------------------------*/
CPA_BaseObject *TAction_Interface::mfn_p_oCreateNewZAList(CPA_tdoNameList *_p_oName, char *_szName)
{
SCR_tdst_Link_Value *p_tdst_LKValue;
char szLinkName[SCR_CV_ui_Cfg_MaxLenName];
BOOL bPreviousLoadingWorld = GetInterface() -> fn_bIsLoadingWorld();
// construct Complete section name
strcpy( szLinkName, fn_szGetFamiliesDataPath() );
strcat( szLinkName, "\\" );
strcat( szLinkName, _szName );
// search on LinkTable
p_tdst_LKValue = SCR_fnp_st_Link_SearchKey( & g_st3DOSLinkTable.stACZList, szLinkName );
if ( !p_tdst_LKValue )
{
SCR_tdst_Cxt_Values *p_stValues = SCR_fnp_st_RdL0_AnalyseSection( _szName, SCR_CDF_uw_Anl_Normal );
ZDX_tdxHandleToCsaList hCsaList = (ZDX_tdxHandleToCsaList) (p_stValues->a_ulValues[0]);
// add to LinkTable
SCR_fnp_st_Link_CreateOrGetLinkFromKey( &g_st3DOSLinkTable.stACZList, szLinkName);
p_tdst_LKValue = SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stACZList, szLinkName,(unsigned long)hCsaList);
}
if ( p_tdst_LKValue && (SCR_M_e_Link_GetState( p_tdst_LKValue ) != SCR_ELS_Link_NotInitialized ) )
{
ZDX_tdxHandleToCsaList hEngineZA = (ZDX_tdxHandleToCsaList)SCR_M_ul_Link_GetValue( p_tdst_LKValue );
char szName[SCR_CV_ui_Cfg_MaxLenName];
SCR_fn_v_RdL0_SplitSectionName(_szName,NULL,NULL,szName);
GetInterface() -> SetLoadingWorld( TRUE );
CPA_ZonesActivatingList *p_oZAList = new CPA_ZonesActivatingList( this, _p_oName, szName, hEngineZA );
GetInterface() -> SetLoadingWorld( bPreviousLoadingWorld );
return (CPA_BaseObject*)p_oZAList;
}
return NULL;
}
/*=============================================================================
* Editor Modif
=============================================================================*/
void TAction_Interface::fn_vOnSelect(CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus)
{
if( eStatus == C_AsCurrentEditor )
{
if( eType == C_EDTDo )
{
CPA_BaseObject *p_oBaseObject = pEdObj -> GetObject();
if( p_oBaseObject && p_oBaseObject -> fn_bIsOfType( C_szActorInstanceTypeName ) )
{
tdxHandleToState hState = fn_h3dDataGetCurrentState( M_GetMSHandle( pEdObj -> GetStruct(), 3dData ) );
p_oBaseObject = p_oBaseObject -> GetOwner(); // model
if( p_oBaseObject )
{
p_oBaseObject = p_oBaseObject -> GetOwner(); // family
if( p_oBaseObject && p_oBaseObject -> fn_bIsOfType( C_szFamilyTypeName ) )
{
m_p_oCurrentFamily = (CPA_Family*) p_oBaseObject;
mfn_vSetCurrentFamily( m_p_oCurrentFamily );
if( m_bStateMode )
{
CPA_State* p_oState = (CPA_State*)GetBaseObject( hState, C_szStateTypeName, p_oBaseObject );
if( p_oState )
{
m_p_oCurrentAction = (CPA_Action*) p_oState -> mfn_p_oGetAction();
mfn_vSetCurrentAction( m_p_oCurrentAction );
m_p_oCurrentState = p_oState;
mfn_vSetCurrentState( p_oState );
}
}
}
}
}
}
}
}
/*=============================================================================
* Dialog List
=============================================================================*/
//--------------------------------------------------------------------------------
// set dialog list lists
//--------------------------------------------------------------------------------
void TAction_Interface::GetListsForDialog(CPA_DialogList *pDialog)
{
//ANNECY Shaitan Correction 16/02/98
// pDialog->fn_vAddANewList( C_szFamilyList, GetMainWorld()->fn_p_oGetOriginalObjectList(C_szFamilyTypeName));
pDialog->fn_vAddANewList( C_szFamilyList, GetMainWorld()->fn_p_oGetOriginalObjectList(C_szFamilyTypeName),
NULL, NULL, E_lo_Alpha, TRUE, C_lDrawName, FALSE);
//ENDANNECY Shaitan Correction
}
//--------------------------------------------------------------------------------
// set dialog default parameters
//--------------------------------------------------------------------------------
void TAction_Interface::fn_vInitDefaultParameters(CPA_DialogList *pDialog)
{
pDialog -> SetDefaultTestName ( "" ) ;
pDialog -> SetDefaultButtonState ( FALSE ) ;
pDialog -> SetDefaultTypeName( C_szFamilyList ) ;
}
//--------------------------------------------------------------------------------
// Get dialog list selection
//--------------------------------------------------------------------------------
CPA_BaseObject* TAction_Interface::GetDialogSelection (CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDrawMode)
{
return ((CPA_BaseObject*) m_p_oCurrentFamily);
}
//--------------------------------------------------------------------------------
// called when doubleclick on an item
//--------------------------------------------------------------------------------
BOOL TAction_Interface::fn_bOnDblClkListObjects(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pSelectedObject)
{
if( pSelectedObject && ! pSelectedObject -> fn_bIsAvailable() )
{
char szMessage[255];
HCURSOR hCursor;
// update statusbar
strcpy( szMessage, "Laod Family : " );
strcat( szMessage, pSelectedObject -> fn_p_szGetName() );
M_BeginLoad( szMessage, hCursor );
// load object
pSelectedObject -> GetEditor() -> fn_bLoadBaseObject( pSelectedObject );
// update display
mfn_vSetCurrentFamily( (CPA_Family*) pSelectedObject );
// update statusbar
strcat( szMessage, " => 100% Completed" );
M_EndLoad( szMessage, hCursor );
}
return TRUE;
}
//--------------------------------------------------------------------------------
// called when selection change in list
//--------------------------------------------------------------------------------
BOOL TAction_Interface::fn_bOnSelChangeListObjects(CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject, BOOL _bUnselect)
{
if( m_lEditorState == C_lEDST_Active )
{
if( !_bUnselect && ( pSelectedObject -> fn_bIsAvailable() ) )
mfn_vChangeFamily ( (CPA_Family*) pSelectedObject ) ;
else
mfn_vChangeFamily ( (CPA_Family*) NULL ) ;
}
return FALSE;
}
//--------------------------------------------------------------------------------
// called when popup menu is to be show
//--------------------------------------------------------------------------------
BOOL TAction_Interface::fn_bAddEntriesToListPopup(CPA_DialogList *pDialog, CString csListName, CMenu *pMenu, UINT uiCustomEntriesStart)
{
if( (pDialog == m_p_oDialogListSTM) && m_p_oCurrentFamily )
{
pMenu -> AppendMenu( MF_STRING, uiCustomEntriesStart+C_uiTACPreLoadAnimations, "PreLoad Animations" );
return TRUE;
}
return FALSE;
}
//--------------------------------------------------------------------------------
// called when popup entry has been selected
//--------------------------------------------------------------------------------
void TAction_Interface::fn_vOnCommandInListPopup(CPA_DialogList *pDialog, CString csListName, UINT uiCustomEntry)
{
if( pDialog == m_p_oDialogListSTM )
{
CPA_EditorBase *p_oDLL;
HCURSOR hCursor;
switch( uiCustomEntry )
{
case C_uiTACPreLoadAnimations:
ASSERT( m_p_oCurrentFamily );
p_oDLL = GetMainWorld()->GetToolDLLWithName( C_szDLLAnimationName );
if( p_oDLL )
{
M_BeginLoad( "Load animations", hCursor );
p_oDLL -> OnQueryAction( this, C_cPreLoadAllAnimation, (long)m_p_oCurrentFamily );
M_EndLoad( "Load animations => 100% Completed", hCursor );
}
break;
}
}
}
/*=============================================================================
* Action DLL specific functions
=============================================================================*/
//--------------------------------------------------------------------------------
// Set Editor Mode (edit States or edit ZA)
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vSetEditMode( BOOL _bStateMode/*=TRUE*/, BOOL _bActive/*=TRUE*/ )
{
if( _bActive || (_bStateMode != m_bStateMode) )
{
m_bStateMode = _bStateMode;
g_oFrameGest . mfn_vSetRefresh ( FALSE ) ;
// active splitter
g_oFrameGest . mfn_vActivateWindow ( m_bStateMode ? m_p_oSplitterBottomSTM : m_p_oSplitterBottomZAM ) ;
g_oFrameGest . mfn_vActivateWindow ( m_bStateMode ? m_p_oSplitterLeftSTM : m_p_oSplitterLeftZAM ) ;
//
g_oFrameGest.mfn_vSetRefresh ( TRUE ) ;
// Dialog Lists
m_p_oDialogListSTM -> fn_vInitAllLists();
m_p_oDialogListSTM -> fn_vReinitDialog();
m_p_oDialogListZAM -> fn_vInitAllLists();
m_p_oDialogListZAM -> fn_vReinitDialog();
if( m_bStateMode )
{
m_p_oDialogListSTM -> fn_vUpdateSelection( E_lrm_ChangeSelection );
m_p_oDlgState -> mfn_vFillFamilyList();
m_p_oDlgAnimList -> mfn_vFillCBFamilies();
}
else
{
m_p_oDialogListZAM -> fn_vUpdateSelection( E_lrm_ChangeSelection );
}
}
}
//--------------------------------------------------------------------------------
// called to change current family
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vChangeFamily(CPA_Family *_p_oFamily)
{
Family_StateChange *p_oChangeMode = new Family_StateChange( this, C_eFamily, _p_oFamily, m_p_oCurrentFamily );
M_MakeDo( p_oChangeMode );
}
//--------------------------------------------------------------------------------
// called to change current action
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vChangeAction(CPA_Action *_p_oAction)
{
Family_StateChange *p_oChangeMode = new Family_StateChange( this, C_eAction, _p_oAction, m_p_oCurrentAction );
M_MakeDo( p_oChangeMode );
}
//--------------------------------------------------------------------------------
// called to change current state
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vChangeState(CPA_State *_p_oState)
{
Family_StateChange *p_oChangeMode = new Family_StateChange( this, C_eState, _p_oState, m_p_oCurrentState );
M_MakeDo( p_oChangeMode );
}
//--------------------------------------------------------------------------------
// called to change current Names List
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vChangeNameList(CPA_tdoNameList *_p_oList)
{
Family_StateChange *p_oChangeMode = new Family_StateChange( this, C_eNameList, _p_oList, m_p_oCurrentNameList );
M_MakeDo( p_oChangeMode );
}
//--------------------------------------------------------------------------------
// called when selected family change
// update display about family only
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vSetCurrentFamily( CPA_Family *_p_oNewFamily)
{
// update current family
m_p_oCurrentFamily = _p_oNewFamily;
m_p_oDialogListSTM -> fn_vUpdateSelection( E_lrm_ChangeSelection );
m_p_oDialogListZAM -> fn_vUpdateSelection( E_lrm_ChangeSelection );
// STATE MODE
m_p_oDlgState -> mfn_vSetCurrentFamily( m_p_oCurrentFamily );
m_p_oDlgAnimList -> mfn_vSetFamily( m_p_oCurrentFamily );
if(_p_oNewFamily)
{
m_p_oDlgActionList -> fn_vSetActionList( &_p_oNewFamily -> m_oListOfActions ) ;
}
else
{
m_p_oDlgActionList -> fn_vSetActionList( NULL ) ;
}
// ZA MODE
m_p_oDlgNameList -> mfn_vSetFamily( m_p_oCurrentFamily );
m_p_oDlgActions -> mfn_vSetCurrentFamily( m_p_oCurrentFamily );
}
//--------------------------------------------------------------------------------
// set current action, display list of states of this action
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vSetCurrentAction( CPA_Action *_p_oAction )
{
m_p_oCurrentAction = _p_oAction ;
// STATE MODE
m_p_oDlgActionList->fn_vSetAction(m_p_oCurrentAction);
m_p_oDlgActionContents->fn_vSetAction(m_p_oCurrentAction);
// ZA MODE
m_p_oDlgActions -> mfn_vSetCurrentFamily(m_p_oCurrentFamily);
}
//--------------------------------------------------------------------------------
// set current state, display parametes of this state
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vSetCurrentState( CPA_State *_p_oState )
{
m_p_oCurrentState = _p_oState;
// STATE MODE
m_p_oDlgActionContents -> fn_vSetState( m_p_oCurrentState ) ;
m_p_oDlgState -> fn_vSetCurrentState ( m_p_oCurrentState );
}
//--------------------------------------------------------------------------------
// set current Names List
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vSetCurrentNameList(CPA_tdoNameList *_p_oList )
{
m_p_oCurrentNameList = _p_oList;
// ZA MODE
m_p_oDlgNameList -> mfn_vSetCurrentNamesList( m_p_oCurrentNameList );
m_p_oDlgZAList -> mfn_vSetCurrentNameList( m_p_oCurrentNameList );
m_p_oDlgZA -> mfn_vSetCurrentNamesList( m_p_oCurrentNameList );
}
//--------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vSetCurrentActionList( int *_a_ItemList, long _lNumberOfItems )
{
// ZA MODE
m_p_oDlgActions -> mfn_vSetCurrentActionList( _a_ItemList,_lNumberOfItems );
}
//--------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vSetCurrentZAList( CPA_ZonesActivatingList *_p_oZAList )
{
m_p_oCurrentZAList = _p_oZAList;
// ZA MODE
m_p_oDlgZAList -> mfn_vSetCurrentZAList( m_p_oCurrentZAList );
m_p_oDlgZAListContent -> mfn_vSetCurrentZAList( m_p_oCurrentZAList );
}
//--------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vSetCurrentZA( CPA_ZonesActivating *_p_oZA )
{
// ZA MODE
m_p_oCurrentZA = _p_oZA;
m_p_oDlgZA -> mfn_vUpdateDisplay( m_p_oCurrentZA, 0 );
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Actions
//////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------------------
// update display when all actions of current family are deleted
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vAllActionsDeleted ( CPA_Family *_p_oFamily )
{
if ( M_IsCurrentFamily( _p_oFamily ) )
{
m_p_oCurrentAction = NULL;
m_p_oCurrentState = NULL;
mfn_vSetCurrentFamily( _p_oFamily ) ;
mfn_vSetCurrentAction( NULL ) ;
}
}
//--------------------------------------------------------------------------------
// update display when an action has been created
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vActionCreated ( CPA_Family *_p_oFamily , CPA_Action *_p_oAction)
{
if ( M_IsCurrentFamily( _p_oFamily ) )
{
mfn_vSetCurrentFamily( _p_oFamily ) ;
mfn_vSetCurrentAction( _p_oAction ) ;
}
}
//--------------------------------------------------------------------------------
// update display when one action has been created
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vActionDeleted ( CPA_Family *_p_oFamily )
{
if ( M_IsCurrentFamily( _p_oFamily ) )
{
mfn_vSetCurrentFamily( _p_oFamily ) ;
mfn_vSetCurrentAction( NULL ) ;
}
}
//--------------------------------------------------------------------------------
// update display when one state has been created
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vStateCreated ( CPA_Action *_p_oAction , CPA_State *_p_oState )
{
if ( M_IsCurrentAction( _p_oAction ) )
{
//if( m_p_oDlgState ) m_p_oDlgState -> mfn_vFillStateList( _p_oState ) ;
mfn_vSetCurrentAction( _p_oAction ) ;
mfn_vSetCurrentState( _p_oState ) ;
}
}
//--------------------------------------------------------------------------------
// update display when one state has been deleted
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vStateDeleted ( CPA_Action *_p_oAction )
{
if ( M_IsCurrentAction( _p_oAction ) )
{
//m_p_oDlgState -> mfn_vFillStateList( _p_oAction ) ;
mfn_vSetCurrentAction( _p_oAction ) ;
mfn_vSetCurrentState( NULL );
}
}
//--------------------------------------------------------------------------------
// update display when one state has changed
//--------------------------------------------------------------------------------
void TAction_Interface::mfn_vStateChanged( CPA_State *_p_oState , tdeChangingState _eChange)
{
if( M_IsCurrentState( _p_oState ) )
{
m_p_oDlgState -> mfn_vStateChanged ( _p_oState , _eChange ) ;
}
}
// ----------------------------------------------------------------------------
// update display when one ZAList has been created
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vZAListCreated( CPA_ZonesActivatingList *_p_oZAList )
{
if( M_IsCurrentFamily( (CPA_Family*)_p_oZAList -> GetOwner() -> GetOwner() ) )
{
m_p_oDlgZAList -> mfn_vSetCurrentZAList( _p_oZAList );
m_p_oDlgZAListContent -> mfn_vSetCurrentZAList( _p_oZAList );
}
}
// ----------------------------------------------------------------------------
// update display when one ZAList has been deleted
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vZAListDeleted( CPA_tdoNameList *_p_oNameList )
{
if( M_IsCurrentFamily( (CPA_Family*)_p_oNameList -> GetOwner() ) )
{
m_p_oDlgNameList -> mfn_vSetFamily( m_p_oCurrentFamily );
m_p_oDlgZAList -> mfn_vSetCurrentNameList( _p_oNameList );
m_p_oDlgZA -> mfn_vSetCurrentNamesList( _p_oNameList );
m_p_oDlgZAListContent -> mfn_vSetCurrentNamesList( _p_oNameList );
}
}
// ----------------------------------------------------------------------------
//
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vZAToStateChanged( CPA_List<CPA_State> *_p_oListOfStates )
{
m_p_oDlgZAListContent -> mfn_vUpdateStates( _p_oListOfStates );
}
// ----------------------------------------------------------------------------
// update display when one ZAList has been deleted
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vZACreated( CPA_ZonesActivating *_p_oZA )
{
m_p_oDlgZAListContent -> mfn_vSetZA( _p_oZA, FALSE );
m_p_oDlgZA -> mfn_vUpdateDisplay( _p_oZA, 0 );
}
// ----------------------------------------------------------------------------
// update display when one ZA has changed
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vZAChanged( CPA_ZonesActivating *_p_oZA, int _iIndex )
{
m_p_oDlgZAListContent -> mfn_vSetZA( _p_oZA, FALSE );
m_p_oDlgZA -> mfn_vUpdateDisplay( _p_oZA, _iIndex );
}
// ----------------------------------------------------------------------------
// update display when one ZAList has been deleted
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vZADeleted( CPA_ZonesActivating *_p_oZA )
{
m_p_oDlgZAListContent -> mfn_vSetZA( NULL, FALSE );
m_p_oDlgZA -> mfn_vSetCurrentNamesList( m_p_oCurrentNameList );
}
// ----------------------------------------------------------------------------
// remove zone from ZA list
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vRemoveZoneFromNamesList( CPA_tdoNameList *_p_oNameList, unsigned short _usIndex )
{
CPA_List<CPA_BaseObject> oList;
fn_lFindObjects (&oList, "", C_szZATypeName, (CPA_BaseObject*)_p_oNameList );
// fill comboBox
POSITION xPos = oList . GetHeadPosition();
while ( xPos )
{
CPA_ZonesActivating *p_oZA = (CPA_ZonesActivating*) oList . GetNext( xPos );
p_oZA -> mfn_vRemoveZone( _usIndex );
}
oList . RemoveAll();
}
// ----------------------------------------------------------------------------
// insert zone to ZA list
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vInsertZoneToNamesList( CPA_tdoNameList *_p_oNameList, unsigned short _usIndex )
{
if( _usIndex < _p_oNameList -> GetCount() )
{
// name realy inserted (not added on tail)
CPA_List<CPA_BaseObject> oList;
fn_lFindObjects (&oList, "", C_szZATypeName, (CPA_BaseObject*)_p_oNameList );
// fill comboBox
POSITION xPos = oList . GetHeadPosition();
while ( xPos )
{
CPA_ZonesActivating *p_oZA = (CPA_ZonesActivating*) oList . GetNext( xPos );
p_oZA -> mfn_vInsertZone( _usIndex );
}
oList . RemoveAll();
}
}
// ----------------------------------------------------------------------------
// Rebuild all ZAList from a Family
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vNotifyAllZAList(CPA_Family *_p_oFamily, BOOL _bUpdateList /*=TRUE*/ )
{
CPA_BaseObjectList *p_oListofZAList = GetBaseObjectList( C_szZAListTypeName );
Position xPos = p_oListofZAList -> GetHeadPosition();
while( xPos )
{
CPA_ZonesActivatingList *p_oZAList = (CPA_ZonesActivatingList*) p_oListofZAList -> GetNext( xPos );
if( p_oZAList -> GetOwner() -> GetOwner() == (CPA_BaseObject*)_p_oFamily )
{
p_oZAList -> mfn_vMustBeUpdated();
if( _bUpdateList )
p_oZAList -> mfn_vUpdateEditorList();
//p_oZAList -> fn_vNotifySave();
}
}
}
// ----------------------------------------------------------------------------
// Save Preferences
// ----------------------------------------------------------------------------
void TAction_Interface::mfn_vSavePreferences(void)
{
CString csFileName;
CString csDimension;
csFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\Action\\Action.ini";
char *p_szFileName = (char*)(LPCSTR)csFileName;
// Open MODE
WritePrivateProfileString ("Preference", "Open Mode", m_bStateMode ? "STM" : "ZAM" , p_szFileName);
//////////////////
// STATE MODE //
//////////////////
// Left Frame size
csDimension.Format("%ld", m_p_oSplitterLeftSTM -> m_oCurPos.right - m_p_oSplitterLeftSTM -> m_oCurPos.left);
WritePrivateProfileString ("Preference", "STM Left Frame Width", (char*)(LPCSTR)csDimension, p_szFileName);
// Left Frame dialog sizes
csDimension.Format("%ld", m_p_oSplitterLeftSTM -> GetPaneSize(0));
WritePrivateProfileString ("Preference", "STM DialogList Height", (char*)(LPCSTR)csDimension, p_szFileName);
csDimension.Format("%ld", m_p_oSplitterLeftSTM -> GetPaneSize(1));
WritePrivateProfileString ("Preference", "STM ActionList Height", (char*)(LPCSTR)csDimension, p_szFileName);
csDimension.Format("%ld", m_p_oSplitterLeftSTM -> GetPaneSize(2));
WritePrivateProfileString ("Preference", "STM StateList Height", (char*)(LPCSTR)csDimension, p_szFileName);
// Bottom Frame Height
csDimension.Format("%ld", m_p_oSplitterBottomSTM -> m_oCurPos.bottom - m_p_oSplitterBottomSTM -> m_oCurPos.top);
WritePrivateProfileString ("Preference", "STM Bottom Frame Height", (char*)(LPCSTR)csDimension, p_szFileName);
// Bottom Frame dialog sizes
csDimension.Format("%ld", m_p_oSplitterBottomSTM -> GetPaneSize(0));
WritePrivateProfileString ("Preference", "STM StateContent Width", (char*)(LPCSTR)csDimension, p_szFileName);
csDimension.Format("%ld", m_p_oSplitterBottomSTM -> GetPaneSize(1));
WritePrivateProfileString ("Preference", "STM AnimationList Width", (char*)(LPCSTR)csDimension, p_szFileName);
///////////////
// ZA MODE //
///////////////
// Left Frame size
csDimension.Format("%ld", m_p_oSplitterLeftZAM -> m_oCurPos.right - m_p_oSplitterLeftSTM -> m_oCurPos.left);
WritePrivateProfileString ("Preference", "ZAM Left Frame Width", (char*)(LPCSTR)csDimension, p_szFileName);
// Left Frame dialog sizes
csDimension.Format("%ld", m_p_oSplitterLeftZAM -> GetPaneSize(0));
WritePrivateProfileString ("Preference", "ZAM DialogList Height", (char*)(LPCSTR)csDimension, p_szFileName);
csDimension.Format("%ld", m_p_oSplitterLeftZAM -> GetPaneSize(1));
WritePrivateProfileString ("Preference", "ZAM NamesList Height", (char*)(LPCSTR)csDimension, p_szFileName);
csDimension.Format("%ld", m_p_oSplitterLeftZAM -> GetPaneSize(2));
WritePrivateProfileString ("Preference", "ZAM ZAList Height", (char*)(LPCSTR)csDimension, p_szFileName);
csDimension.Format("%ld", m_p_oSplitterLeftZAM -> GetPaneSize(3));
WritePrivateProfileString ("Preference", "ZAM ActionList Height", (char*)(LPCSTR)csDimension, p_szFileName);
// Bottom Frame size
csDimension.Format("%ld", m_p_oSplitterBottomZAM -> m_oCurPos.bottom - m_p_oSplitterBottomZAM -> m_oCurPos.top);
WritePrivateProfileString ("Preference", "ZAM Bottom Frame Height", (char*)(LPCSTR)csDimension, p_szFileName);
// Bottom Frame dialog sizes
csDimension.Format("%ld", m_p_oSplitterBottomZAM -> GetPaneSize(0));
WritePrivateProfileString ("Preference", "ZAM ZAList Content Width", (char*)(LPCSTR)csDimension, p_szFileName);
csDimension.Format("%ld", m_p_oSplitterBottomZAM -> GetPaneSize(1));
WritePrivateProfileString ("Preference", "ZAM ActivationList Width", (char*)(LPCSTR)csDimension, p_szFileName);
// write on file
WritePrivateProfileString (NULL , NULL, NULL, p_szFileName);
}