Add rayman2 source files

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

View File

@@ -0,0 +1,12 @@
// Saving functions
//////////////////////////////
// Mechanics Editor
/////////////////////////////////////////
#include "StdAfx.h"
void m_fn_vSaveMecaCard()
{
}

View File

@@ -0,0 +1,126 @@
// Allocation and free functions for all types of Mechanics
////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECAllo.hpp"
#include "_MecCard.hpp"
#include "_MInterf.hpp"
#include "IncMEC.h"
//Unallocation functions
// ANNECY AV CLEAN_MEC {
/*
//*************************************************************
void fn_vUnalloc1(CPA_Meca_Card *pclCard)
{
DNM_stMecWalkIdCard *p_tdstStruct = (DNM_stMecWalkIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc2(CPA_Meca_Card *pclCard)
{
DNM_tdstMecSkiIdCard *p_tdstStruct = (DNM_tdstMecSkiIdCard *)pclCard->m_fn_pvGetBaseAddress();
// free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc3(CPA_Meca_Card *pclCard)
{
DNM_stMecSwimIdCard *p_tdstStruct = (DNM_stMecSwimIdCard *)pclCard->m_fn_pvGetBaseAddress();
// free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc4(CPA_Meca_Card *pclCard)
{
DNM_tdstMecJumpIdCard *p_tdstStruct = (DNM_tdstMecJumpIdCard *)pclCard->m_fn_pvGetBaseAddress();
// free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc5(CPA_Meca_Card *pclCard)
{
DNM_stMecFlyIdCard *p_tdstStruct = (DNM_stMecFlyIdCard *)pclCard->m_fn_pvGetBaseAddress();
// free(p_tdstStruct);
}
*/
// END ANNECY AV }
//*************************************************************
void fn_vUnalloc6(CPA_Meca_Card *pclCard)
{
DNM_stMecCameraIdCard *p_tdstStruct = (DNM_stMecCameraIdCard *)pclCard->m_fn_pvGetBaseAddress();
// free(p_tdstStruct);
}
// ANNECY AV CLEAN_MEC {
/*
//*************************************************************
void fn_vUnalloc7(CPA_Meca_Card *pclCard)
{
DNM_stMecWalkIdCard *p_tdstStruct = (DNM_stMecWalkIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc8(CPA_Meca_Card *pclCard)
{
DNM_stMecWalkIdCard *p_tdstStruct = (DNM_stMecWalkIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc9(CPA_Meca_Card *pclCard)
{
DNM_stMecStoneIdCard *p_tdstStruct = (DNM_stMecStoneIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc10(CPA_Meca_Card *pclCard)
{
DNM_tdstMecHelicopterIdCard *p_tdstStruct = (DNM_tdstMecHelicopterIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc11(CPA_Meca_Card *pclCard)
{
DNM_tdstMecHookIdCard *p_tdstStruct = (DNM_tdstMecHookIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc12(CPA_Meca_Card *pclCard)
{
DNM_tdstMecShootingIdCard *p_tdstStruct = (DNM_tdstMecShootingIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc13(CPA_Meca_Card *pclCard)
{
DNM_tdstMecRaftIdCard *p_tdstStruct = (DNM_tdstMecRaftIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
//*************************************************************
void fn_vUnalloc14(CPA_Meca_Card *pclCard)
{
DNM_tdstMecWalkOPIdCard *p_tdstStruct = (DNM_tdstMecWalkOPIdCard *)pclCard->m_fn_pvGetBaseAddress();
//free(p_tdstStruct);
}
*/
// END ANNECY AV }
//ANNECY jt {
//*************************************************************
void fn_vUnallocRay2Egypte1(CPA_Meca_Card *pclCard)
{
DNM_tdstMecBaseIdCard *p_tdstStruct = (DNM_tdstMecBaseIdCard *)pclCard->m_fn_pvGetBaseAddress();
}
//ENDANNECY jt }

View File

@@ -0,0 +1,35 @@
// CallBacks
//
// YB
///////////////////////
#include "StdAfx.h"
#include "EMECClBk.hpp"
#include "EMECCStr.hpp"
#include "_MECCard.hpp"
//************************************************************************************
BOOL TME_fn_bControlCanBeDisplayedCallBack(CTL_Editor_Control *_pclSenderControl)
{
return TRUE;
}
//************************************************************************************
void TME_fn_vCallBackWhenADataHasChanged(CTL_Editor_Data *_pclChangedData,
CTL_tdeUpdateReason _eReason,
long _lUserDefinedReason /*/ 0*/)
{
if ( _eReason == CTL_UPDATE_REASON__DATA_MODIFIED_BY_USER )
{
//Gets Parent Card
CTL_OwnerData *pclOwnerData = _pclChangedData->m_pub_fn_pclGetOwnerDataWithName(TME_g_c_cs_DataOwnerData_ParentCard);
if ( pclOwnerData != NULL )
{
CPA_Meca_Card *pclParentCard = (CPA_Meca_Card *)pclOwnerData->m_pub_fn_pvGetDataPtr();
pclParentCard->fn_vNotifySave();
}
}
}

View File

@@ -0,0 +1,308 @@
// Implementation for the definition of the class representing a Mechanical Card
/////////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECCrdT.hpp"
#include "EMECVwMS.hpp"
#include "EMECDoc.hpp"
#include "EMECFmMn.hpp"
#include "EMECCnst.hpp"
#include "EMECDgQu.hpp"
#include "EMECClBk.hpp"
#include "EMECCStr.hpp"
#include "_Minterf.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//***************************************************************************
CPA_Meca_CardType::CPA_Meca_CardType(CString csName,
DNM_tdeMechanicsID tdeMotorID)
{
m_csName = csName;
m_tdeMotorID = tdeMotorID;
m_pclCurrentCard = NULL;
m_p_fn_vUnallocate = NULL;
m_p_fn_vFill = NULL;
m_p_fn_vSave = NULL;
m_crControlZone = CRect(0,0,0,0);
m_bControlsAreHidden = TRUE;
m_bAtLeastOneCardOfTheCardTypeHasBeenLoaded = FALSE;
}
//***************************************************************************
CPA_Meca_CardType::~CPA_Meca_CardType()
{
}
//**************************************************************************************
//********************************** Controls ****************************************
//**************************************************************************************
//**************************************************************************************
void CPA_Meca_CardType::m_fn_vAddDecimalControl(long double ldMinValue,
long double ldMaxValue,
char cDataLength,
BOOL bReadOnly,
CString _csControlName)
{
m_pri_fn_vAddOwnerDataToControl( m_clControlList.m_fn_pclAddDecimalControl( ldMinValue,
ldMaxValue,
cDataLength,
bReadOnly,
CTL_SPACING_TYPE__SINGLE_LINE,
FALSE,
_csControlName,
TRUE, 0 //ANNECY BBB
)
);
}
//**************************************************************************************
void CPA_Meca_CardType::m_fn_vAddBooleanControl(BOOL bReadOnly,
CString _csControlName)
{
m_pri_fn_vAddOwnerDataToControl( m_clControlList.m_fn_pclAddBooleanControl( bReadOnly,
CTL_SPACING_TYPE__SINGLE_LINE,
FALSE,
_csControlName,
TRUE, 0 //ANNECY BBB
)
);
}
//**************************************************************************************
void CPA_Meca_CardType::m_pri_fn_vAddOwnerDataToControl(CTL_Editor_Control *_pclControl)
{
if ( _pclControl != NULL )
{
//OwnerData
_pclControl->m_pub_fn_pclAddOwnerData((void *)this, TME_g_c_cs_ControlOwnerData_ParentCardType);
}
}
//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
//Creates all controls
long CPA_Meca_CardType::m_fn_lCreateMSControls( CWnd *pclWnd,
CRect crRect)
{
m_pclParentView = (CPA_Meca_MiniStrucView *)pclWnd;
//Adds an item in the tree
m_crDisplayRect = crRect;
//Creates controls of the data list
////
CTL_fn_vSetModuleInfo("TMe", CString("Type ") + m_csName); ///for TUT
////
//Creates controls of the data list
POSITION pos = m_clControlList.GetHeadPosition();
while ( pos != NULL )
(m_clControlList.GetNext(pos))->m_fn_bCreateControl(pclWnd);
////
CTL_fn_vResetModuleInfo();
////
return 0L;
}
//**************************************************************************************
//Hides all controls
void CPA_Meca_CardType::m_fn_vHideAllControls()
{
//Hides controls of the data list
m_clControlList.m_pub_fn_vHideAllControls();
m_bControlsAreHidden = TRUE;
}
//**************************************************************************************
long CPA_Meca_CardType::m_fn_lOpen(CRect crRect)
{
CPoint clTopLeft;
CPoint clTopRight;
clTopLeft.y = clTopRight.y = crRect.top;
clTopLeft.x = crRect.left + C_TABULATION;
clTopRight.x = crRect.right;
m_clControlList.m_pub_fn_vDisplayControlsInZone(clTopLeft, clTopRight);
m_bControlsAreHidden = FALSE;
return (clTopLeft.y - crRect.top);
}
//**************************************************************************************
void CPA_Meca_CardType::m_fn_vClose()
{
//Hides controls of the list
m_clControlList.m_pub_fn_vHideAllControls();
m_crControlZone = CRect(0,0,0,0);
m_bControlsAreHidden = TRUE;
}
//**************************************************************************************
void CPA_Meca_CardType::m_fn_vOffsetZone(long lOffset)
{
m_crControlZone.OffsetRect(0, lOffset);
}
//**************************************************************************************
void CPA_Meca_CardType::m_fn_vGetMotorDatas()
{
//Gets motor data for all controls of the data list
//And retrieves it in the control
m_clControlList.m_pub_fn_vUpdateControlsWithEditedData(TRUE);
}
//**************************************************************************************
CPA_Meca_Card *CPA_Meca_CardType::m_fn_pclGetEditedCard()
{
return m_pclCurrentCard;
}
//**************************************************************************************
void CPA_Meca_CardType::m_fn_vSetEditedCard(CPA_Meca_Card *pclNewCard)
{
// ERROR_ASSERT( (pclNewCard != NULL) && (pclNewCard->fn_bIsAvailable()) );
m_pclCurrentCard = pclNewCard;
}
//**************************************************************************************
CPA_Meca_CardList *CPA_Meca_CardType::m_fn_pclGetCardsList()
{
return (&m_clCardsList);
}
//**************************************************************************************
unsigned long CPA_Meca_CardType::m_fn_ulGetCardsNumber()
{
return m_clCardsList.GetCount();
}
//**************************************************************************************
BOOL CPA_Meca_CardType::m_fn_bControlsAreHidden()
{
return m_bControlsAreHidden;
}
//**************************************************************************************
CString CPA_Meca_CardType::m_fn_csGetCardTypeName()
{
return m_csName;
}
//**************************************************************************************
void CPA_Meca_CardType::m_fn_vSetCardTypeName(CString csNewName)
{
m_csName = csNewName;
}
//***************************************************************************
//Get : The ID of the type of Mechanics (image of Motor ID)
DNM_tdeMechanicsID CPA_Meca_CardType::m_fn_tdeGetMotorID()
{
return m_tdeMotorID;
}
//***************************************************************************
//The name of the File where this type of Cards are stored
CString CPA_Meca_CardType::m_fn_csGetFileName()
{
return m_csFileName;
}
//***************************************************************************
void CPA_Meca_CardType::m_fn_vSetFileName(CString csNewName)
{
m_csFileName = csNewName;
}
//***************************************************************************
//The name of the Action for this type of Cards
CString CPA_Meca_CardType::m_fn_csGetActionName()
{
return m_csActionName;
}
//***************************************************************************
void CPA_Meca_CardType::m_fn_vSetActionName(CString csNewName)
{
m_csActionName = csNewName;
}
//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
CPA_Meca_CardTypeList::CPA_Meca_CardTypeList()
{
}
//**************************************************************************************
CPA_Meca_CardTypeList::~CPA_Meca_CardTypeList()
{
m_fn_vEmptyList();
}
//**************************************************************************************
CPA_Meca_CardType* CPA_Meca_CardTypeList::m_fn_pclAddElement(CString csName,
DNM_tdeMechanicsID tdeMotorID)
{
CPA_Meca_CardType *pclNewElement = new CPA_Meca_CardType(csName, tdeMotorID);
AddTail(pclNewElement);
return pclNewElement;
}
//**************************************************************************************
void CPA_Meca_CardTypeList::m_fn_vEmptyList()
{
POSITION pos = GetHeadPosition();
while( pos != NULL )
delete (GetNext(pos));
RemoveAll();
}
//**************************************************************************************
//Gets a Type Card from its Motor ID
CPA_Meca_CardType* CPA_Meca_CardTypeList::m_fn_pclGetTypeCardFromID(DNM_tdeMechanicsID tdeMotorID)
{
CPA_Meca_CardType *pclTypeCard;
POSITION pos = GetHeadPosition();
BOOL bFound = FALSE;
while ( (pos != NULL) && (!bFound) )
{
pclTypeCard = GetNext(pos);
bFound = ( pclTypeCard->m_fn_tdeGetMotorID() == tdeMotorID );
}
if ( bFound )
return pclTypeCard;
else
return NULL;
}

View File

@@ -0,0 +1,109 @@
// CPAMDgIf.cpp : implementation file
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECDgIf.hpp"
#include "_MInterf.hpp"
//External Modules
#include "IncTUT.h"
//End of External Modules
#define C_INFO_DIALOG_TIMER 70 //An Id for the timer
#define C_TEMPO_TIMER 100 //(ms)
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_InformationDialog dialog
BEGIN_MESSAGE_MAP(CPA_Meca_InformationDialog, CDialog)
//{{AFX_MSG_MAP(CPA_Meca_InformationDialog)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//**************************************************************************
CPA_Meca_InformationDialog::CPA_Meca_InformationDialog(CWnd* pParent, CString csMessage)
: CDialog(CPA_Meca_InformationDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_Meca_InformationDialog)
m_csMessage = csMessage;
//}}AFX_DATA_INIT
m_hOldInstance = AfxGetResourceHandle();
AfxSetResourceHandle(g_stMecaDLLIdentity.hModule);
}
//**************************************************************************
CPA_Meca_InformationDialog::~CPA_Meca_InformationDialog()
{
AfxSetResourceHandle(m_hOldInstance);
}
//***************************************************************************
void CPA_Meca_InformationDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_Meca_InformationDialog)
DDX_Text(pDX, IDC_STATIC_TEXT, m_csMessage);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_InformationDialog message handlers
//***************************************************************************
BOOL CPA_Meca_InformationDialog::OnInitDialog()
{
CDialog::OnInitDialog();
//Init. timer
SetTimer(C_INFO_DIALOG_TIMER, C_TEMPO_TIMER, NULL);
//Loads Bitmaps
m_a_cbBitmaps[0].LoadBitmap(IDB_BITMAP_INFO1);
m_a_cbBitmaps[1].LoadBitmap(IDB_BITMAP_INFO2);
m_a_cbBitmaps[2].LoadBitmap(IDB_BITMAP_INFO3);
m_a_cbBitmaps[3].LoadBitmap(IDB_BITMAP_INFO4);
m_a_cbBitmaps[4].LoadBitmap(IDB_BITMAP_INFO5);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//***************************************************************************
void CPA_Meca_InformationDialog::OnOK()
{
KillTimer(C_INFO_DIALOG_TIMER);
EndDialog(IDOK);
}
//***************************************************************************
void CPA_Meca_InformationDialog::OnTimer(UINT nIDEvent)
{
static BOOL s_bFirstPass = TRUE;
static char s_cCurrentBitmapIndex = -1; //To begin with first bitmap
static char s_cIndexIncrement = 1;
s_cCurrentBitmapIndex += s_cIndexIncrement;
if ( ! s_bFirstPass )
{
if ( s_cCurrentBitmapIndex % (C_NUMBER_OF_BITMAPS-1) == 0 )
s_cIndexIncrement = -s_cIndexIncrement;
}
else
s_bFirstPass = FALSE;
((CStatic *)GetDlgItem(IDC_STATIC_IMAGE))->SetBitmap(HBITMAP(m_a_cbBitmaps[s_cCurrentBitmapIndex]));
CDialog::OnTimer(nIDEvent);
}

View File

@@ -0,0 +1,88 @@
// CPAMDgNC.cpp : implementation file
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECDgNC.hpp"
//External Modules
#include "IncTUT.h"
//End of External Modules
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_NewCardDialog dialog
BEGIN_MESSAGE_MAP(CPA_Meca_NewCardDialog, CDialog)
//{{AFX_MSG_MAP(CPA_Meca_NewCardDialog)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//**************************************************************************
CPA_Meca_NewCardDialog::CPA_Meca_NewCardDialog(CString csCardName,
CWnd* pParent /*=NULL*/)
: CDialog(CPA_Meca_NewCardDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_Meca_NewCardDialog)
m_csName = csCardName;
//}}AFX_DATA_INIT
}
//**************************************************************************
void CPA_Meca_NewCardDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_Meca_NewCardDialog)
DDX_Text(pDX, IDC_EDIT_NAME, m_csName);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_NewCardDialog message handlers
//**************************************************************************
BOOL CPA_Meca_NewCardDialog::OnInitDialog()
{
CDialog::OnInitDialog();
//////////////
//////////////
//Registers for TUT Module
TUT_M_vGetTutDll();
TUT_M_vRegisterControlID(IDC_EDIT_NAME, "TMe_NewCardDialog_NameEdit", TUT_e_TextEdit);
TUT_M_vRegisterControlID(IDOK, "TMe_InformationDialog_OKButton", TUT_e_Button);
TUT_M_vRegisterControlID(IDCANCEL, "TMe_InformationDialog_CancelButton", TUT_e_Button);
//End of Registers for TUT Module
//////////////
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//**************************************************************************
void CPA_Meca_NewCardDialog::OnDestroy()
{
//////////////
//////////////
//UnRegisters for TUT Module
TUT_M_vGetTutDll();
TUT_M_vUnregisterControlID(IDC_EDIT_NAME);
TUT_M_vUnregisterControlID(IDOK);
TUT_M_vUnregisterControlID(IDCANCEL);
//End of UnRegisters for TUT Module
//////////////
CDialog::OnDestroy();
}

View File

@@ -0,0 +1,182 @@
// CPAMDgQu.cpp : implementation file
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECDgQu.hpp"
#include "_MInterf.hpp"
//External Modules
#include "IncTUT.h"
//End of External Modules
#define C_QUESTION_DIALOG_TIMER 69 //An Id for the timer
#define C_TEMPO_TIMER 60 //(ms)
#define C_NUMBER_OF_FRAMES 15
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_QuestionDialog dialog
BEGIN_MESSAGE_MAP(CPA_Meca_QuestionDialog, CDialog)
//{{AFX_MSG_MAP(CPA_Meca_QuestionDialog)
ON_BN_CLICKED(IDNO, OnNo)
ON_BN_CLICKED(IDYES, OnYes)
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//**************************************************************************
CPA_Meca_QuestionDialog::CPA_Meca_QuestionDialog(CWnd* pParent, CString csMessage)
: CDialog(CPA_Meca_QuestionDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_Meca_QuestionDialog)
m_csMessage = csMessage;
//}}AFX_DATA_INIT
m_hOldInstance = AfxGetResourceHandle();
AfxSetResourceHandle(g_stMecaDLLIdentity.hModule);
}
//**************************************************************************
CPA_Meca_QuestionDialog::~CPA_Meca_QuestionDialog()
{
AfxSetResourceHandle(m_hOldInstance);
}
//***************************************************************************
void CPA_Meca_QuestionDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_Meca_QuestionDialog)
DDX_Text(pDX, IDC_STATIC_QUESTION, m_csMessage);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_QuestionDialog message handlers
//***************************************************************************
BOOL CPA_Meca_QuestionDialog::OnInitDialog()
{
CDialog::OnInitDialog();
//Init. timer
SetTimer(C_QUESTION_DIALOG_TIMER, C_TEMPO_TIMER, NULL);
//Loads Bitmaps
m_cbBitmap.LoadBitmap(IDB_BITMAP_QUESTION);
//////////////
//////////////
//Registers for TUT Module
TUT_M_vGetTutDll();
TUT_M_vRegisterControlID(IDYES, "TMe_QuestionDialog_YesButton", TUT_e_Button);
TUT_M_vRegisterControlID(IDNO, "TMe_QuestionDialog_NoButton", TUT_e_Button);
//End of Registers for TUT Module
//////////////
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//***************************************************************************
void CPA_Meca_QuestionDialog::OnDestroy()
{
//////////////
//////////////
//UnRegisters for TUT Module
TUT_M_vGetTutDll();
TUT_M_vUnregisterControlID(IDYES);
TUT_M_vUnregisterControlID(IDNO);
//End of UnRegisters for TUT Module
//////////////
CDialog::OnDestroy();
}
//***************************************************************************
void CPA_Meca_QuestionDialog::OnNo()
{
KillTimer(C_QUESTION_DIALOG_TIMER);
EndDialog(IDNO);
}
//***************************************************************************
void CPA_Meca_QuestionDialog::OnYes()
{
KillTimer(C_QUESTION_DIALOG_TIMER);
EndDialog(IDYES);
}
//***************************************************************************
void CPA_Meca_QuestionDialog::OnTimer(UINT nIDEvent)
{
/* static BOOL s_bFirstPass = TRUE;
static char s_cCurrentBitmapIndex = -1; //To begin with first bitmap
static char s_cIndexIncrement = 1;
s_cCurrentBitmapIndex += s_cIndexIncrement;
if ( ! s_bFirstPass )
{
if ( s_cCurrentBitmapIndex % (C_NUMBER_OF_FRAMES-1) == 0 )
s_cIndexIncrement = -s_cIndexIncrement;
}
else
s_bFirstPass = FALSE;
((CStatic *)GetDlgItem(IDC_STATIC_IMAGE))->SetBitmap(HBITMAP(m_a_cbBitmaps[s_cCurrentBitmapIndex]));
*/
static BOOL s_bFirstPass = TRUE;
static CRect crRect;
static char s_cCurrentIndex = -1;
static char s_cIndexIncrement = 1;
s_cCurrentIndex += s_cIndexIncrement;
if ( s_bFirstPass )
{
crRect.top = 0;
crRect.bottom = 56;
crRect.left = 0;
crRect.right = 56;
s_bFirstPass = FALSE;
}
else
{
if ( s_cCurrentIndex % (C_NUMBER_OF_FRAMES-1) == 0 )
s_cIndexIncrement = -s_cIndexIncrement;
}
//Computes Rect
crRect.left = (56 * s_cCurrentIndex)/ C_NUMBER_OF_FRAMES;
crRect.right = 56 - (56 * s_cCurrentIndex)/ C_NUMBER_OF_FRAMES;
CClientDC dc(GetDlgItem(IDC_EDIT_BIDON));
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(m_cbBitmap);
dc.StretchBlt( crRect.left,
crRect.top,
crRect.Width(),
crRect.Height(), &memDC, 0, 0, 56, 56, SRCCOPY);
CDialog::OnTimer(nIDEvent);
}

View File

@@ -0,0 +1,125 @@
// CPAMDgSp.cpp : implementation file
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECDgSp.hpp"
#include "_Minterf.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_EditorSetupDialog dialog
BEGIN_MESSAGE_MAP(CPA_Meca_EditorSetupDialog, CDialog)
//{{AFX_MSG_MAP(CPA_Meca_EditorSetupDialog)
ON_WM_PAINT()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_HELP, OnMyHelp)
END_MESSAGE_MAP()
//***************************************************************************
CPA_Meca_EditorSetupDialog::CPA_Meca_EditorSetupDialog(CWnd* pParent /*=NULL*/)
: CDialog(CPA_Meca_EditorSetupDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_Meca_EditorSetupDialog)
//}}AFX_DATA_INIT
}
//***************************************************************************
void CPA_Meca_EditorSetupDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_Meca_EditorSetupDialog)
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_EditorSetupDialog message handlers
//***************************************************************************
void CPA_Meca_EditorSetupDialog::OnOK()
{
UpdateData(TRUE);
CDialog::OnOK();
}
//***************************************************************************
void CPA_Meca_EditorSetupDialog::OnLButtonUp(UINT nFlags, CPoint point)
{
CWnd *pclWnd;
CRect crClientRect;
pclWnd = GetDlgItem(IDC_RECT_TEXT_FIELD_INST);
pclWnd->GetWindowRect(crClientRect);
ScreenToClient(crClientRect);
// if ( crClientRect.PtInRect(point) )
// if ( m_fn_bEditColor(g_colref_FieldInstanceTextColor) )
// InvalidateRect(NULL);
pclWnd = GetDlgItem(IDC_RECT_BG_FIELD_INST);
pclWnd->GetWindowRect(crClientRect);
ScreenToClient(crClientRect);
// if ( crClientRect.PtInRect(point) )
// if ( m_fn_bEditColor(g_colref_FieldInstanceBackgroundColor) )
// InvalidateRect(NULL);
CDialog::OnLButtonUp(nFlags, point);
}
//***************************************************************************
BOOL CPA_Meca_EditorSetupDialog::m_fn_bEditColor(COLORREF &r_Color)
{
CColorDialog dial(r_Color, CC_FULLOPEN, this);
if ( dial.DoModal() == IDOK )
{
r_Color = dial.GetColor();
return TRUE;
}
else
return FALSE;
}
//***************************************************************************
void CPA_Meca_EditorSetupDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect crClientRect;
CWnd *pclWnd;
pclWnd = GetDlgItem(IDC_RECT_TEXT_FIELD_INST);
pclWnd->GetClientRect(crClientRect);
crClientRect.InflateRect(-2,-2);
CClientDC dc3(pclWnd);
// dc3.FillSolidRect(crClientRect, g_colref_FieldInstanceTextColor);
pclWnd = GetDlgItem(IDC_RECT_BG_FIELD_INST);
pclWnd->GetClientRect(crClientRect);
crClientRect.InflateRect(-2,-2);
CClientDC dc4(pclWnd);
// dc4.FillSolidRect(crClientRect, g_colref_FieldInstanceBackgroundColor);
// Do not call CDialog::OnPaint() for painting messages
}
//***************************************************************************
long CPA_Meca_EditorSetupDialog::OnMyHelp(UINT, long lParam)
{
LPHELPINFO lphi = (LPHELPINFO)lParam;
::WinHelp(m_hWnd,
"c:\\acp\\dllbibli\\object\\actors\\help\\actors.hlp",
HELP_CONTEXTPOPUP,
lphi->dwContextId);
return TRUE;
}

View File

@@ -0,0 +1,530 @@
// Implementation for the class CMyDocument
/////////////////////////////////////////////
#include "StdAfx.h"
#include "SCR.h"
#include "EMECDoc.hpp"
#include "EMECVwMn.hpp"
#include "EMECVwMS.hpp"
#include "EMECStrg.hpp"
#include "EMECDgNC.hpp"
#include "_Minterf.hpp"
#include "x:\cpa\main\inc\_EditID.h"
//External modules
#include "ErO.h"
#include "Dpt.h"
//End of External modules
long g_lCurrentId = 2000;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//****************************************************************************
CPA_Meca_MyDocument::CPA_Meca_MyDocument()
{
// AfxEnableMemoryTracking(TRUE);
//Initializes editor's state
m_pclCurrentCardType = NULL;
m_pclCurrentCard = NULL;
m_pclControlView = NULL;
m_pclMiniStrucView = NULL;
m_pclDialogList = NULL;
//Editor's Setup var. Init.
m_ulListViewHeight = 170;
m_ulControlViewHeight = 250;
m_ulEditorWidth = 260;
//Other init.
m_fn_vInitialize();
}
//****************************************************************************
CPA_Meca_MyDocument::~CPA_Meca_MyDocument()
{
m_fn_bWriteIniFile();
}
//****************************************************************************
//Extra init.
void CPA_Meca_MyDocument::m_fn_vInitialize()
{
//Constructs the list of Enum desciptors
m_fn_vConstructListOfEnumDescriptors();
//Fills the mini-structure list (controls)
m_fn_vFillCardsTypeList();
//Init. the INI file name
m_csIniFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\Meca\\EdMeca.ini";
//Reads INI file
m_fn_bReadIniFile();
m_pub_fn_bLoadPreferences();
//PROVISOIRE...
m_csHelpFileNameAndPath = M_GetMainApp()->m_csEditorDataPath + "Tools\\Meca\\Meca.hlp >Normale";
}
/////////////////////
// Editor's aspect //
/////////////////////
//***************************************************************************
// ...
void CPA_Meca_MyDocument::m_fn_vEditCard(CPA_Meca_Card *pclNewCard)
{
m_pclCurrentCard = pclNewCard;
if ( m_pclMiniStrucView != NULL )
{
if ( pclNewCard != NULL )
{
if ( (pclNewCard->m_fn_pclGetCardType()->m_fn_bControlsAreHidden())
|| (m_pclCurrentCardType == NULL)
)
//Forces "Repaint"
m_fn_vDisplayCardType(pclNewCard->m_fn_pclGetCardType(), TRUE);
m_fn_vSetPointersForSelectedCard();
m_pclMiniStrucView->m_fn_vEditCard(m_pclCurrentCard);
m_pclControlView->m_fn_vUpdateCardsName();
//Sets new Card as Type Card's current Card
pclNewCard->m_fn_pclGetCardType()->m_fn_vSetEditedCard(pclNewCard);
}
else
{
if ( !m_pclCurrentCardType->m_fn_bControlsAreHidden() )
m_pclCurrentCardType->m_fn_vHideAllControls();
//Sets new Card as Type Card's current Card
m_pclCurrentCardType->m_fn_vSetEditedCard(pclNewCard);
}
}
}
//***************************************************************************
// ...
void CPA_Meca_MyDocument::m_fn_vDisplayCardType(CPA_Meca_CardType *pclNewCardType,
BOOL bForcesRepaint /*= FALSE*/)
{
if ( (pclNewCardType != m_pclCurrentCardType) || (bForcesRepaint) )
{
m_pclCurrentCardType = pclNewCardType;
if ( m_pclMiniStrucView )
m_pclMiniStrucView->m_fn_vDisplayCardType(m_pclCurrentCardType, TRUE);
if ( m_pclCurrentCardType != NULL )
{
if ( m_pclCurrentCardType->m_fn_ulGetCardsNumber() == 0 )
{
//PROVISOIRE...
m_pclCurrentCardType->m_fn_vHideAllControls();
//Refreshes buttons
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_DELETE))->EnableWindow( FALSE );
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_RENAME))->EnableWindow( FALSE );
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_COPY))->EnableWindow( FALSE );
m_pclCurrentCardType->m_fn_vSetEditedCard(NULL);
}
else
{
//Refreshes buttons
if ( m_pclCurrentCardType->m_fn_pclGetEditedCard() != NULL )
{
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_DELETE))->EnableWindow( TRUE );
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_RENAME))->EnableWindow( TRUE );
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_COPY))->EnableWindow( TRUE );
}
else
{
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_DELETE))->EnableWindow( FALSE );
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_RENAME))->EnableWindow( FALSE );
((CButton *)m_pclControlView->GetDlgItem(IDC_BUTTON_COPY))->EnableWindow( FALSE );
}
}
}
//Selects in the List Box
CListBox *pclTypeLB = (CListBox *)m_pclControlView->GetDlgItem(IDC_LIST_CARD_TYPES);
pclTypeLB->SelectString(-1, m_pclCurrentCardType->m_fn_csGetCardTypeName());
}
}
//***************************************************************************
// ...
void CPA_Meca_MyDocument::m_fn_vReInitDisplay()
{
CListBox *pclTypeLB = (CListBox *)m_pclControlView->GetDlgItem(IDC_LIST_CARD_TYPES);
pclTypeLB->SetCurSel(0);
m_pclControlView->OnSelchangeComboCardTypes();
//Updates Dialog List
m_pclDialogList->fn_vReinitDialog();
}
//**********************************************************************************************
CPA_Meca_Card *CPA_Meca_MyDocument::m_pub_fn_vCreateCopyOfCard(CPA_Meca_Card *_pclSourceCard)
{
ERROR_ASSERT( _pclSourceCard != NULL );
CPA_Meca_Card *pclNewCard = NULL;
//Creates Card
//////////////////
//Gets user wanted name
CString csCopyName = _pclSourceCard->GetName() + "_Copy";
CPA_Meca_NewCardDialog dial(csCopyName, m_pclControlView);
if ( dial.DoModal() == IDOK )
{
csCopyName = dial.m_csName;
CPA_Meca_CardType *pclCardType = _pclSourceCard->m_fn_pclGetCardType();
pclNewCard = pclCardType->m_fn_pclGetCardsList()->m_fn_pclAddElement(
csCopyName,
_pclSourceCard->m_fn_pclGetCardType(),
NULL,
_pclSourceCard->m_fn_pclGetCardType()->m_fn_csGetFileName(),
_pclSourceCard->m_fn_pclGetCardType()->m_fn_csGetActionName());
//Copies Data from source Card
POSITION SourcePos = _pclSourceCard->m_clDataList.GetHeadPosition();
POSITION NewCardPos = pclNewCard->m_clDataList.GetHeadPosition();
while ( SourcePos != NULL )
{
ERROR_ASSERT( NewCardPos != NULL );
pclNewCard->m_clDataList.GetNext(NewCardPos)->m_fn_vUpdateData(_pclSourceCard->m_clDataList.GetNext(SourcePos));
}
ERROR_ASSERT( NewCardPos == NULL );
}
return pclNewCard;
}
///////////////////////
// Private functions //
///////////////////////
//**********************************************************************************************
//Sets the pointer on a Data (the one of the Card) in each control of Card Type
void CPA_Meca_MyDocument::m_fn_vSetPointersForSelectedCard()
{
m_fn_vSetPointersForCard(m_pclCurrentCard);
}
//**********************************************************************************************
//Sets the pointer on a Data (the one of the Card) in each control of Card Type
void CPA_Meca_MyDocument::m_fn_vSetPointersForCard(CPA_Meca_Card *pclCard)
{
if ( pclCard != NULL )
{
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,
"Linking a Card to a Card Type (i.e. data to controls)",
"CPA_Meca_MyDocument::m_fn_vSetPointersForCard(...)",
E_ERROR_GRAVITY_FATAL,
"The given Card Type is invalid");
ERROR_ASSERT( m_pclCurrentCardType != NULL );
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,
"Linking a Card to a Card Type (i.e. data to controls)",
"CPA_Meca_MyDocument::m_fn_vSetPointersForCard(...)",
E_ERROR_GRAVITY_FATAL,
"The type of the Card differs from the one of the Type Card...");
ERROR_ASSERT( m_pclCurrentCardType == pclCard->m_fn_pclGetCardType() );
m_pclCurrentCardType->m_clControlList.m_pub_fn_vUpdateControlsWithListOfData(&pclCard->m_clDataList);
}
}
//**********************************************************************************************
//Removes a Card from a Card Type's list
void CPA_Meca_MyDocument::m_fn_vRemoveCard(CPA_Meca_Card *pclCard)
{
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,
"Trying to delete a Mechanical Card",
"CPA_Meca_MyDocument::m_fn_vRemoveCard(...)",
E_ERROR_GRAVITY_FATAL,
"The Card to be deleted is invalid");
ERROR_ASSERT( pclCard != NULL );
CPA_Meca_CardType *pclCardType = pclCard->m_fn_pclGetCardType();
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,
"Trying to delete a Mechanical Card",
"CPA_Meca_MyDocument::m_fn_vRemoveCard(...)",
E_ERROR_GRAVITY_FATAL,
"The type of the Card to be deleted is invalid");
ERROR_ASSERT( pclCardType != NULL );
POSITION pos = pclCardType->m_fn_pclGetCardsList()->Find(pclCard);
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,
"Trying to delete a Mechanical Card",
"CPA_Meca_MyDocument::m_fn_vRemoveCard(...)",
E_ERROR_GRAVITY_FATAL,
"The Card to be deleted has not been found in the Editor list");
ERROR_ASSERT( pos != NULL );
//Removes from list
pclCardType->m_fn_pclGetCardsList()->RemoveAt(pos);
//Notifies
pclCard->fn_vNotifyUnSave();
//deletes
delete pclCard;
//Selects another Card
m_fn_vEditCard(pclCardType->m_fn_pclGetCardsList()->m_pub_fn_pclGetFirstAvailableCard());
}
//**********************************************************************************************
void CPA_Meca_MyDocument::m_fn_vCheckSpacesInString(CString &r_csStringToCheck)
{
CString csSpace(" ");
for (int c_lI = 0; c_lI < r_csStringToCheck.GetLength(); c_lI ++)
if ( r_csStringToCheck[c_lI] == csSpace )
r_csStringToCheck.SetAt(c_lI, '_');
}
//**********************************************************************************************
void CPA_Meca_MyDocument::m_fn_vSearchForLoadedCards()
{
//Uses LinkTables
SCR_tdst_Link_Table *p_stLinkTable = DNM_fn_p_stGetLinkTableOfIdCard();
unsigned int uiPos = 0;
SCR_tdst_Link_Value *p_stValue;
CPA_Meca_Card *pclAddedCard = NULL;
CPA_Meca_CardType *pclConcernedCardType = NULL;
/* 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 )
{
DNM_tdxHandleToMecIdentityCard h_IdCard = (DNM_tdxHandleToMecIdentityCard)SCR_M_ul_Link_GetValue(p_stValue);
//Gets the Name for the Card
CString csCardName(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(csCardName), a_256cFileName, a_256cActionName, a_256cName);
csCardName = a_256cName;
//Gets the Motor Type for the Card
DNM_tdeMechanicsID tdeMotorType;
memcpy(&tdeMotorType, h_IdCard, sizeof(DNM_tdeMechanicsID));
//Adds to Card Type's list od Cards
pclConcernedCardType = m_clCardTypeList.m_fn_pclGetTypeCardFromID(tdeMotorType);
pclAddedCard = pclConcernedCardType->m_fn_pclGetCardsList()->m_fn_pclAddElement(csCardName,
pclConcernedCardType,
h_IdCard,
a_256cFileName,
a_256cActionName);
//Adds to the Main list
m_clListOfCards.fn_bAddObject(pclAddedCard);
pclAddedCard->SetExistingSection(TRUE);
pclConcernedCardType->m_bAtLeastOneCardOfTheCardTypeHasBeenLoaded = TRUE;
}
/* Get next element */
uiPos++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value,
uiPos,
p_stValue,
SCR_M_st_Link_GetDynamicArray(p_stLinkTable)
)
}
}
//**********************************************************************************************
void CPA_Meca_MyDocument::m_fn_vLoadUnloadedCards()
{
CPA_Meca_CardType *pclCurrentTypeCard;
POSITION pos= m_clCardTypeList.GetHeadPosition();
while ( pos != NULL )
{
pclCurrentTypeCard = m_clCardTypeList.GetNext(pos);
CString csCompleteFileName = fn_szGetMechanicsDataPath();
csCompleteFileName += CString("\\") + pclCurrentTypeCard->m_fn_csGetFileName();
CFile cfPrivateFile;
if ( cfPrivateFile.Open(csCompleteFileName, CFile::modeRead ) )
{
cfPrivateFile.Close();
char *szFileName = (char *)LPCTSTR(pclCurrentTypeCard->m_fn_csGetFileName());
//Gets all the sections in the corresponding file
SCR_fn_v_RdL0_OpenFile(szFileName);
//Gets a pointer on the file
SCR_tdst_File_Open *p_tdstFile = SCR_fnp_st_RdL0_GetOpenFile(szFileName);
unsigned int uiPos = 0;
SCR_tdst_Anl_SectionDes_ *p_stValue;
CPA_Meca_Card *pclAddedCard = NULL;
BOOL bCardIsNotLoaded;
/* Get first element of array */
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes_,
uiPos,
p_stValue,
p_tdstFile->stSectionsDes
)
while( p_stValue != NULL ) /* p_sValue is NULL at the end of the array */
{
//Gets the Name for the Card
CString csCardName(p_stValue->stBuffers.p_szBufferCompleteName);
char a_256cFileName[256];
char a_256cActionName[256];
char a_256cName[256];
SCR_fn_v_RdL0_SplitSectionName((char *)LPCTSTR(csCardName), a_256cFileName, a_256cActionName, a_256cName);
csCardName = a_256cName;
// Tests if Card is already loaded
bCardIsNotLoaded = ( g_pclInterface->GetMainWorld()->fn_p_oFindObject(csCardName, C_szMecaCardTypeName) == NULL );
//Creates an unloaded Card if necessary
if ( bCardIsNotLoaded )
{
//Adds to Card Type's list od Cards
pclAddedCard = pclCurrentTypeCard->m_fn_pclGetCardsList()->m_fn_pclAddElement(csCardName,
pclCurrentTypeCard,
NULL,
a_256cFileName,
a_256cActionName,
TRUE);
pclAddedCard->SetAvailable(FALSE);
//Adds to the Main list
m_clListOfCards.fn_bAddObject(pclAddedCard);
pclAddedCard->SetExistingSection(TRUE);
}
/* Get next element */
uiPos++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_SectionDes_,
uiPos,
p_stValue,
p_tdstFile->stSectionsDes
)
}
}
}
}
//**********************************************************************************************
void CPA_Meca_MyDocument::m_fn_vUpdateUnLoadedCards()
{
//Uses LinkTables
SCR_tdst_Link_Table *p_stLinkTable = DNM_fn_p_stGetLinkTableOfIdCard();
unsigned int uiPos = 0;
SCR_tdst_Link_Value *p_stValue;
CPA_Meca_Card *pclEditorCard = NULL;
CPA_Meca_CardType *pclConcernedCardType = NULL;
/* 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 )
{
DNM_tdxHandleToMecIdentityCard h_IdCard = (DNM_tdxHandleToMecIdentityCard)SCR_M_ul_Link_GetValue(p_stValue);
//Gets the Name for the Card
CString csCardName(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(csCardName), a_256cFileName, a_256cActionName, a_256cName);
csCardName = a_256cName;
//Gets the Motor Type for the Card
DNM_tdeMechanicsID tdeMotorType;
memcpy(&tdeMotorType, h_IdCard, sizeof(DNM_tdeMechanicsID));
//Adds to Card Type's list of Cards
pclConcernedCardType = m_clCardTypeList.m_fn_pclGetTypeCardFromID(tdeMotorType);
//Searches for object with same name
pclEditorCard = (CPA_Meca_Card *)g_pclInterface->GetBaseObject(csCardName, C_szMecaCardTypeName);
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,
"Updating unloaded Mechanical Cards (because a Family has been loaded)",
"CPA_Meca_MyDocument::m_fn_vUpdateUnLoadedCards()",
E_ERROR_GRAVITY_WARNING,
"No Editor Card found for one of the Motor Cards");
ERROR_ASSERT( pclEditorCard != NULL );
if( (pclEditorCard != NULL) && (!pclEditorCard->fn_bIsAvailable()) )
{
// Updates engine poniter
pclEditorCard->m_fn_vSetBaseAddress(h_IdCard);
pclEditorCard->SetAvailable(TRUE);
pclConcernedCardType->m_bAtLeastOneCardOfTheCardTypeHasBeenLoaded = TRUE;
pclConcernedCardType->m_p_fn_vFill(pclEditorCard);
DNM_tdstMecBaseIdCard *pMecCard = (DNM_tdstMecBaseIdCard *)pclEditorCard->m_fn_pvGetBaseAddress();
DNM_M_vBaseIdCardSetSlopeLimit ( pMecCard, MTH_M_xRadToDeg ( MTH_M_xATan (DNM_M_xBaseIdCardGetSlopeLimit(pMecCard))) );
}
}
/* Get next element */
uiPos++;
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value,
uiPos,
p_stValue,
SCR_M_st_Link_GetDynamicArray(p_stLinkTable)
)
}
}

View File

@@ -0,0 +1,91 @@
// Modification functions for Data
//////////////////////////////////////
#include "StdAfx.h"
#include "EMECDtMd.hpp"
//External Modules
#include "ErO.h"
#include "CTL.h"
//End of External Modules
//*******************************************************************************
void EMEC_fn_vModifFloatFromCosToDegre(CTL_Editor_Data *_pclBaseData)
{
ERROR_ASSERT( _pclBaseData != NULL );
ERROR_ASSERT( _pclBaseData->m_pub_fn_tdeGetDataType() == CTL_DATA_TYPE__DECIMAL );
CTL_Editor_DecimalData *pclTrueData = (CTL_Editor_DecimalData *)_pclBaseData;
long double ldValue = pclTrueData->m_ldCurrentValue;
ldValue = MTH_M_xACos(ldValue);
ldValue = MTH_M_xRadToDeg(ldValue);
pclTrueData->m_ldCurrentValue = ldValue;
}
//*******************************************************************************
void EMEC_fn_vModifFloatFromDegreToCos(CTL_Editor_Data *_pclBaseData)
{
ERROR_ASSERT( _pclBaseData != NULL );
ERROR_ASSERT( _pclBaseData->m_pub_fn_tdeGetDataType() == CTL_DATA_TYPE__DECIMAL );
CTL_Editor_DecimalData *pclTrueData = (CTL_Editor_DecimalData *)_pclBaseData;
long double ldValue = pclTrueData->m_ldCurrentValue;
ldValue = MTH_M_xDegToRad(ldValue);
ldValue = MTH_M_xCos(ldValue);
pclTrueData->m_ldCurrentValue = ldValue;
}
//*******************************************************************************
void EMEC_fn_vModifFloatFromRadianPerSecondToDegrePerSecond(CTL_Editor_Data *_pclBaseData)
{
ERROR_ASSERT( _pclBaseData != NULL );
ERROR_ASSERT( _pclBaseData->m_pub_fn_tdeGetDataType() == CTL_DATA_TYPE__DECIMAL );
CTL_Editor_DecimalData *pclTrueData = (CTL_Editor_DecimalData *)_pclBaseData;
long double ldValue = pclTrueData->m_ldCurrentValue;
ldValue = MTH_M_xRadToDeg(ldValue);
pclTrueData->m_ldCurrentValue = ldValue;
}
//*******************************************************************************
void EMEC_fn_vModifFloatFromDegrePerSecondToRadianPerSecond(CTL_Editor_Data *_pclBaseData)
{
ERROR_ASSERT( _pclBaseData != NULL );
ERROR_ASSERT( _pclBaseData->m_pub_fn_tdeGetDataType() == CTL_DATA_TYPE__DECIMAL );
CTL_Editor_DecimalData *pclTrueData = (CTL_Editor_DecimalData *)_pclBaseData;
long double ldValue = pclTrueData->m_ldCurrentValue;
ldValue = MTH_M_xDegToRad(ldValue);
pclTrueData->m_ldCurrentValue = ldValue;
}
//*******************************************************************************
void EMEC_fn_vModifFloatFromHertzToSecond(CTL_Editor_Data *_pclBaseData)
{
ERROR_ASSERT( _pclBaseData != NULL );
ERROR_ASSERT( _pclBaseData->m_pub_fn_tdeGetDataType() == CTL_DATA_TYPE__DECIMAL );
CTL_Editor_DecimalData *pclTrueData = (CTL_Editor_DecimalData *)_pclBaseData;
long double ldValue = pclTrueData->m_ldCurrentValue;
ldValue = 1 / ldValue;
pclTrueData->m_ldCurrentValue = ldValue;
}
//*******************************************************************************
void EMEC_fn_vModifFloatFromSecondToHertz(CTL_Editor_Data *_pclBaseData)
{
ERROR_ASSERT( _pclBaseData != NULL );
ERROR_ASSERT( _pclBaseData->m_pub_fn_tdeGetDataType() == CTL_DATA_TYPE__DECIMAL );
CTL_Editor_DecimalData *pclTrueData = (CTL_Editor_DecimalData *)_pclBaseData;
long double ldValue = pclTrueData->m_ldCurrentValue;
ldValue = 1 / ldValue;
pclTrueData->m_ldCurrentValue = ldValue;
}

View File

@@ -0,0 +1,158 @@
// MainFrm.cpp : implementation of the CPA_Meca_MainFrame class
////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECFmMn.hpp"
#include "EMECVwMn.hpp"
#include "EMECVwMS.hpp"
#include "EMECCnst.hpp"
#include "_Minterf.hpp"
//External Modules
#include "IncTUT.h"
//End of External Modules
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_MainFrame
BEGIN_MESSAGE_MAP(CPA_Meca_MainFrame, CSplitFrame)
//{{AFX_MSG_MAP(CPA_Meca_MainFrame)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_MainFrame construction/destruction
//*******************************************************************************
CPA_Meca_MainFrame::CPA_Meca_MainFrame()
{
}
//*******************************************************************************
CPA_Meca_MainFrame::~CPA_Meca_MainFrame()
{
}
//*******************************************************************************
/*UINT CPA_Meca_MainFrame::OnNcHitTest( CPoint point )
{
UINT nResponse = CWnd::OnNcHitTest(point);
if ( ( nResponse == HTBOTTOM ) //Re-size
|| ( nResponse == HTBOTTOMRIGHT ) //Re-size
|| ( nResponse == HTBOTTOMLEFT ) //Re-size
|| ( nResponse == HTTOP ) //Re-size
|| ( nResponse == HTTOPRIGHT ) //Re-size
|| ( nResponse == HTTOPLEFT ) //Re-size
|| ( nResponse == HTLEFT ) //Re-size
|| ( nResponse == HTRIGHT ) //Re-size
|| ( nResponse == HTCAPTION ) //Move
|| ( nResponse == HTZOOM ) //Max size
|| ( nResponse == HTSYSMENU ) //System Menu
|| ( nResponse == HTMENU ) //Menu
)
{
return 0;
}
else
return nResponse;
} */
//*******************************************************************************
BOOL CPA_Meca_MainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if ( !(CreateSplitter(C_cVerticalSplitter, 3)) )
return FALSE;
HINSTANCE hOldInstance = AfxGetResourceHandle();
//Creates Dialog List View
CPA_DialogList *pclDialogList = new CPA_DialogList;
g_pclInterface->m_clDocument.m_pclDialogList = pclDialogList;
pclDialogList->fn_vInitDialog(g_pclInterface, this);
SetPaneView(0, pclDialogList, "Available Cards", g_pclInterface->m_clDocument.m_ulListViewHeight);
//////////////
//////////////
//Registers for TUT Module
TUT_M_vGetTutDll();
TUT_M_vRegisterDialogList(pclDialogList, "TMe_DialogList_List",
"TMe_DialogList_NoTree", "TMe_DialogList_ComboBox", "TMe_DialogList_TestButton");
//End of Registers for TUT Module
//////////////
AfxSetResourceHandle(g_stMecaDLLIdentity.hModule);
//Creates MS view
if ( !CreateView(2,
RUNTIME_CLASS(CPA_Meca_MiniStrucView),
"Edition",
400) //The rest...
)
return FALSE;
//Creates Control view
if ( !CreateView(1,
RUNTIME_CLASS(CPA_Meca_ControlView),
"Types of Mechanics",
g_pclInterface->m_clDocument.m_ulControlViewHeight)
)
return FALSE;
//Manually calls OnInitialUpdate for all views !!!!!
CPA_Meca_MiniStrucView *pclMSView = (CPA_Meca_MiniStrucView *)m_fn_p_oGetPane(2);
pclMSView->OnInitialUpdate();
CPA_Meca_ControlView *pclControlView = (CPA_Meca_ControlView *)m_fn_p_oGetPane(1);
pclControlView->OnInitialUpdate();
AfxSetResourceHandle(hOldInstance);
return TRUE;
}
//*******************************************************************************
BOOL CPA_Meca_MainFrame::OnHelpInfo(HELPINFO* pHelpInfo)
{
::WinHelp(m_hWnd,
LPCTSTR(g_pclInterface->m_clDocument.m_csHelpFileNameAndPath),
HELP_FINDER,
0);
return FALSE;
}
//*******************************************************************************
//*******************************************************************************
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_MainFrame diagnostics
#ifdef _DEBUG
void CPA_Meca_MainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CPA_Meca_MainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_MainFrame message handlers

View File

@@ -0,0 +1,138 @@
#include "StdAfx.h"
#include "EMECDoc.hpp"
#include "EMECDgIf.hpp"
#include "_Minterf.hpp"
/////////////////////////////////////
// Ini file implementation //
/////////////////////////////////////
//***************************************************************************
BOOL CPA_Meca_MyDocument::m_fn_bReadIniFile()
{
CFile file;
if ( !file.Open(m_csIniFileName, CFile::modeRead) )
{
CString csMessage = "The Ini file ""EdMeca.ini"" is not present in ";
csMessage += m_csIniFileName.Left(m_csIniFileName.ReverseFind('\\'));
csMessage += "\nParameters are default ones, but they will be saved when you exit this application.";
CPA_Meca_InformationDialog dial(NULL, csMessage);
dial.DoModal();
return FALSE;
}
else
{
file.Close();
BOOL bReturn = TRUE;
return bReturn;
}
}
//***************************************************************************
BOOL CPA_Meca_MyDocument::m_fn_bWriteIniFile()
{
BOOL bReturn = TRUE;
return bReturn;
}
//Preferences
////////////////
#define C_EdMeca_szIniSection_Dimensions "Dimensions"
#define C_EdMeca_szIniEntry_ListHeight "ListHeight"
#define C_EdMeca_szIniEntry_ControlHeight "ControlHeight"
#define C_EdMeca_szIniEntry_EditorWidth "EditorWidth"
//#define C_EdMeca_szIniSection_ ""
//***************************************************************************
BOOL CPA_Meca_MyDocument::m_pub_fn_bSavePreferences()
{
BOOL bReturn = TRUE;
m_pri_fn_vGetEditorCurrentSettings();
CString csStringToWrite;
if ( bReturn )
{
csStringToWrite.Format("%ld", m_ulListViewHeight);
bReturn = WritePrivateProfileString(C_EdMeca_szIniSection_Dimensions,
C_EdMeca_szIniEntry_ListHeight,
LPCTSTR(csStringToWrite),
LPCTSTR(m_csIniFileName));
}
if ( bReturn )
{
csStringToWrite.Format("%ld", m_ulControlViewHeight);
bReturn = WritePrivateProfileString(C_EdMeca_szIniSection_Dimensions,
C_EdMeca_szIniEntry_ControlHeight,
LPCTSTR(csStringToWrite),
LPCTSTR(m_csIniFileName));
}
if ( bReturn )
{
csStringToWrite.Format("%ld", m_ulEditorWidth);
bReturn = WritePrivateProfileString(C_EdMeca_szIniSection_Dimensions,
C_EdMeca_szIniEntry_EditorWidth,
LPCTSTR(csStringToWrite),
LPCTSTR(m_csIniFileName));
}
return bReturn;
}
//***************************************************************************
BOOL CPA_Meca_MyDocument::m_pub_fn_bLoadPreferences()
{
BOOL bReturn = TRUE;
CFile file;
if ( !file.Open(m_csIniFileName, CFile::modeRead) )
bReturn = FALSE;
else
{
file.Close();
m_ulListViewHeight = GetPrivateProfileInt(C_EdMeca_szIniSection_Dimensions,
C_EdMeca_szIniEntry_ListHeight,
m_ulListViewHeight,
LPCTSTR(m_csIniFileName));
m_ulControlViewHeight = GetPrivateProfileInt( C_EdMeca_szIniSection_Dimensions,
C_EdMeca_szIniEntry_ControlHeight,
m_ulControlViewHeight,
LPCTSTR(m_csIniFileName));
m_ulEditorWidth = GetPrivateProfileInt( C_EdMeca_szIniSection_Dimensions,
C_EdMeca_szIniEntry_EditorWidth,
m_ulEditorWidth,
LPCTSTR(m_csIniFileName));
bReturn = TRUE;
}
return bReturn;
}
//***************************************************************************
void CPA_Meca_MyDocument::m_pri_fn_vGetEditorCurrentSettings()
{
//Gets views heights
m_ulListViewHeight = g_pclInterface->m_pclMecaMainFrame->GetPaneSize(0);
m_ulControlViewHeight = g_pclInterface->m_pclMecaMainFrame->GetPaneSize(1);
//Gets Charac frame width
CRect crFrameRect;
g_pclInterface->m_pclMecaMainFrame->GetClientRect(crFrameRect);
m_ulEditorWidth = crFrameRect.Width() - 1; //"-1" because FRMBase adds 1 to initial Width
}

View File

@@ -0,0 +1,431 @@
// Saving functions
//////////////////////////////
// Mechanics Editor
/////////////////////////////////////////
#include "StdAfx.h"
#include "_MecCard.hpp"
#include "EMECCrdT.hpp"
#include "EMECStrg.hpp"
#include "EMECFlds.hpp"
//External Modules
#include "ErO.h"
//End of External Modules
//*******************************************************************************************
// Will call one of the specific saving functions
void CPA_Meca_Card::m_fn_vSaveMecaCard(SCR_tdst_File_Description *p_tdstFile,
SCR_tde_Ntfy_Action _eAction)
{
ERROR_ASSERT( m_fn_pclGetCardType()->m_p_fn_vSave != NULL );
//Moves to the End of File
if ( _eAction == SCR_EA_Ntfy_AddSection )
SCR_fn_v_SvL1_ToEndSection(p_tdstFile);
m_fn_pclGetCardType()->m_p_fn_vSave(p_tdstFile, this);
SCR_M_SvL0_SaveBlankLine(p_tdstFile);
}
//*******************************************************************************************
void fn_vSaveCard6(SCR_tdst_File_Description *p_tdstFile, CPA_Meca_Card *pclCard)
{
CString csCurrentLine;
csCurrentLine.Format("%s:%s", C_SectionIdCardCamera,
pclCard->GetName());
SCR_M_SvL0_SaveBeginSection(p_tdstFile,
M_MAKECHAR(csCurrentLine),
SCR_CC_C_Cfg_EOL);
//Gets Base structure
DNM_stMecCameraIdCard * pStruct = (DNM_stMecCameraIdCard *)pclCard->m_fn_pvGetBaseAddress();
//Angular Speed
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryAngularSpeed,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%f",
DNM_M_xCameraIdCardGetAngularSpeed(pStruct));
//Linear Speed
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryLinearSpeed,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%f",
DNM_M_xCameraIdCardGetLinearSpeed(pStruct));
//Speeding Up
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntrySpeedingUp,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%f",
DNM_M_xCameraIdCardGetSpeedingUp(pStruct));
//Closes file's main section
SCR_M_SvL0_SaveEndSection(p_tdstFile, SCR_CC_C_Cfg_EOL);
}
//*******************************************************************************************
void fn_vSaveCardRay2Egypte1(SCR_tdst_File_Description *p_tdstFile, CPA_Meca_Card *pclCard)
{
CString csCurrentLine;
csCurrentLine.Format("%s:%s", C_SectionIdCardBase,
pclCard->GetName());
SCR_M_SvL0_SaveBeginSection(p_tdstFile,
M_MAKECHAR(csCurrentLine),
SCR_CC_C_Cfg_EOL);
//Gets Base structure
DNM_tdstMecBaseIdCard *pStruct = (DNM_tdstMecBaseIdCard *)pclCard->m_fn_pvGetBaseAddress();
// Animation
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseAnimation,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsAnimation(pStruct));
// Collide
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseCollide,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsCollide(pStruct));
// Gravity
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseGravity,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsGravity(pStruct));
// Tilt
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseTilt,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsTilt(pStruct));
// Gi
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseGi,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsGi(pStruct));
// Climb
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseClimb,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsClimb(pStruct));
// On ground
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseOnGround,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsOnGround(pStruct));
// Spider
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseSpider,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsSpider(pStruct));
// Shoot
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseShoot,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsShoot(pStruct));
// Swim
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseSwim,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsSwim(pStruct));
// Collision control
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseCollisionControl,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsCollisionControl(pStruct));
// Keep speed.z
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseKeepWallSpeedZ,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsKeepWallSpeedZ(pStruct));
// Speed limit
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseSpeedLimit,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsSpeedLimit(pStruct));
// Inertia
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseInertia,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsInertia(pStruct));
// Stream
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseStream,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsStream(pStruct));
// Stick on platform
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseStickOnPlatform,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsStickOnPlatform(pStruct));
// scale
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseUseScale,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%i",
DNM_M_bBaseIdCardIsScale(pStruct));
// Gravity factor
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseGravityFactor,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetGravityFactor(pStruct));
// slide
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseSlide,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetSlide(pStruct));
// rebound
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseRebound,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetRebound(pStruct));
// slope limit
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseSlopeLimit,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
MTH_M_xTan (MTH_M_xDegToRad (DNM_M_xBaseIdCardGetSlopeLimit(pStruct))) );
// inertia x
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseInertiaFactorX,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetInertiaFactorX(pStruct) );
// inertia y
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseInertiaFactorY,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetInertiaFactorY(pStruct) );
// inertia z
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseInertiaFactorZ,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetInertiaFactorZ(pStruct) );
// tilt intensity
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseTiltIntensity,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetTiltIntensity(pStruct) );
// tilt inertia
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseTiltInertia,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetTiltInertia(pStruct) );
// tilt origin
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseTiltOrigin,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
2,
"%lf",
DNM_M_xBaseIdCardGetTiltOrigin(pStruct) );
// max speed
SCR_M_SvL0_SaveEntry( p_tdstFile,
C_EntryBaseMaxSpeed,
SCR_CC_C_Cfg_NoChar);
SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
SCR_EF_SvL0_Scanf,
4,
"%lf,%lf,%lf",
MTH3D_M_xGetXofVector(DNM_M_pBaseIdCardGetMaxSpeed(pStruct)),
MTH3D_M_xGetYofVector(DNM_M_pBaseIdCardGetMaxSpeed(pStruct)),
MTH3D_M_xGetZofVector(DNM_M_pBaseIdCardGetMaxSpeed(pStruct))
);
//Closes file's main section
SCR_M_SvL0_SaveEndSection(p_tdstFile, SCR_CC_C_Cfg_EOL);
}
//ENDANNECY jt }

View File

@@ -0,0 +1,209 @@
// CPAMVwMS.cpp : implementation file
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECVwMS.hpp"
#include "EMECFmMn.hpp"
#include "EMECDoc.hpp"
#include "EMECCnst.hpp"
#include "_Minterf.hpp"
#include "help_def.h" //for Context Help
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_MiniStrucView
IMPLEMENT_DYNCREATE(CPA_Meca_MiniStrucView, CTL_Editor_BaseFormView)
BEGIN_MESSAGE_MAP(CPA_Meca_MiniStrucView, CTL_Editor_BaseFormView)
//{{AFX_MSG_MAP(CPA_Meca_MiniStrucView)
ON_WM_HELPINFO()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//***************************************************************************
CPA_Meca_MiniStrucView::CPA_Meca_MiniStrucView()
: CTL_Editor_BaseFormView(CPA_Meca_MiniStrucView::IDD, TRUE)
{
//{{AFX_DATA_INIT(CPA_Meca_MiniStrucView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pclOldCardType = NULL;
}
//***************************************************************************
CPA_Meca_MiniStrucView::~CPA_Meca_MiniStrucView()
{
}
//Member Functions
////////////////////////////
//***************************************************************************
void CPA_Meca_MiniStrucView::OnInitialUpdate()
{
CTL_Editor_BaseFormView::OnInitialUpdate();
m_fn_pclGetDocument()->m_pclMiniStrucView = this;
CRect crClientRect;
GetClientRect(crClientRect);
//Sets the edition rectangle
MoveWindow(CRect(0,0,100,100));
m_fn_vCreateAllMS();
}
//*********************************************************************************
// Creates the MS controls (and their data controls)
void CPA_Meca_MiniStrucView::m_fn_vCreateAllMS()
{
m_fn_vCreateMS(&(m_fn_pclGetDocument()->m_clCardTypeList));
}
//*********************************************************************************
// Creates the MS controls (and their data controls)
void CPA_Meca_MiniStrucView::m_fn_vCreateMS(CPA_Meca_CardTypeList *pclList)
{
//Creates the list of MS (non visible action)
CRect crCurrentRect(m_crEditionRect);
crCurrentRect.bottom = crCurrentRect.top + C_MS_LINE_HEIGHT;
CPA_Meca_CardType *pclCurrentCardType;
POSITION MiniStrucPos = pclList->GetHeadPosition();
while ( MiniStrucPos != NULL )
{
pclCurrentCardType = pclList->GetNext(MiniStrucPos);
pclCurrentCardType->m_fn_lCreateMSControls(this, crCurrentRect);
crCurrentRect.OffsetRect(0, C_MS_SPACING + C_MS_LINE_HEIGHT);
}
}
//*******************************************************************************
//Called (during motor for example) to update current data in editor
void CPA_Meca_MiniStrucView::m_fn_vUpdateAllDatas()
{
//Updates all controls
POSITION ControlPos = m_fn_pclGetDocument()->m_pclCurrentCardType->m_clControlList.GetHeadPosition();
while ( ControlPos != NULL )
m_fn_pclGetDocument()->m_pclCurrentCardType->m_clControlList.GetNext(ControlPos)->m_fn_vUpdate();
}
//*******************************************************************************
void CPA_Meca_MiniStrucView::m_fn_vEditCard(CPA_Meca_Card *pclNewCard)
{
m_fn_vUpdateAllDatas();
}
//*******************************************************************************
//To display a Card Type (<--> the associated controls)
void CPA_Meca_MiniStrucView::m_fn_vDisplayCardType(CPA_Meca_CardType *pclNewCardType,
BOOL bMustRepaint)
{
if ( (m_pclOldCardType != NULL) && (m_pclOldCardType != pclNewCardType) )
m_pclOldCardType->m_fn_vHideAllControls();
if ( (bMustRepaint) || (m_pclOldCardType != pclNewCardType) )
{
//If no Card has been selected yet, we chose the first one
//(else names are not displayed)
if ( pclNewCardType->m_fn_pclGetEditedCard() == NULL )
{
//To avoid a non-loaded Card to be selected
CPA_Meca_Card *pclCurrentCard = pclNewCardType->m_fn_pclGetCardsList()->m_pub_fn_pclGetFirstAvailableCard();
pclNewCardType->m_fn_vSetEditedCard(pclCurrentCard);
}
if ( pclNewCardType->m_fn_pclGetEditedCard() != NULL )
{
m_fn_pclGetDocument()->m_fn_vSetPointersForCard(pclNewCardType->m_fn_pclGetEditedCard());
pclNewCardType->m_fn_lOpen(m_crEditionRect);
m_pclOldCardType = pclNewCardType;
}
}
}
//*******************************************************************************
CPA_Meca_MyDocument* CPA_Meca_MiniStrucView::m_fn_pclGetDocument()
{
return g_pclInterface->m_fn_pclGetDocument();
}
//***************************************************************************
BOOL CPA_Meca_MiniStrucView::OnHelpInfo(HELPINFO* pHelpInfo)
{
CString csFileAndWindow = g_pclInterface->m_clDocument.m_csHelpFileNameAndPath;
::WinHelp(m_hWnd,
LPCTSTR(csFileAndWindow),
HELP_CONTEXT,
IDH_GENERAL);
//return CFormView::OnHelpInfo(pHelpInfo);
return FALSE;
}
//***************************************************************************
void CPA_Meca_MiniStrucView::OnSize(UINT nType, int cx, int cy)
{
CTL_Editor_BaseFormView::OnSize(nType, cx, cy);
CRect crClientRect;
GetClientRect(crClientRect);
//Sets the edition rectangle
m_crEditionRect.top = C_MAIN_VIEW_SPACING;
m_crEditionRect.bottom = crClientRect.bottom - C_MAIN_VIEW_SPACING;
m_crEditionRect.left = crClientRect.left + C_MAIN_VIEW_SPACING;
m_crEditionRect.right = crClientRect.right - C_MAIN_VIEW_SPACING - C_SCROLLBAR_WIDTH;
CPoint cpTopLeft(0,C_MAIN_VIEW_SPACING);
CPoint cpTopRight(crClientRect.Width(),C_MAIN_VIEW_SPACING);
if
(
m_fn_pclGetDocument()
&& (m_fn_pclGetDocument()->m_pclCurrentCardType)
&& !(m_fn_pclGetDocument()->m_pclCurrentCardType->m_clControlList.IsEmpty())
)
m_fn_pclGetDocument()->m_pclCurrentCardType->m_clControlList.m_pub_fn_vDisplayControlsInZone(cpTopLeft,cpTopRight);
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_MiniStrucView diagnostics
//***************************************************************************
//***************************************************************************
//***************************************************************************
#ifdef _DEBUG
void CPA_Meca_MiniStrucView::AssertValid() const
{
CTL_Editor_BaseFormView::AssertValid();
}
void CPA_Meca_MiniStrucView::Dump(CDumpContext& dc) const
{
CTL_Editor_BaseFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_MiniStrucView message handlers

View File

@@ -0,0 +1,438 @@
// Implementation of the CPA_Meca_ControlView class
///////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "EMECVwMn.hpp"
#include "EMECFmMn.hpp"
#include "EMECVwMS.hpp"
#include "EMECDoc.hpp"
#include "EMECCnst.hpp"
#include "EMECDgNC.hpp"
#include "EMECDgSp.hpp"
#include "EMECDgQu.hpp"
#include "_MecCard.hpp"
#include "_Minterf.hpp"
#include "help_def.h" //For Context help
//External Modules
#include "ErO.h"
#include "IncTUT.h"
//End of External Modules
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_ControlView
IMPLEMENT_DYNCREATE(CPA_Meca_ControlView, CFormView)
BEGIN_MESSAGE_MAP(CPA_Meca_ControlView, CFormView)
//{{AFX_MSG_MAP(CPA_Meca_ControlView)
ON_BN_CLICKED(IDC_BUTTON_CREATE, OnButtonCreate)
ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
ON_BN_CLICKED(IDC_BUTTON_RENAME, OnButtonRename)
ON_CBN_SELCHANGE(IDC_LIST_CARD_TYPES, OnSelchangeComboCardTypes)
ON_WM_HELPINFO()
ON_WM_SIZE()
ON_BN_CLICKED(IDC_BUTTON_COPY, OnButtonCopy)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_ControlView construction/destruction
//***************************************************************************
CPA_Meca_ControlView::CPA_Meca_ControlView() : CFormView( IDD_MECA_DIALOG_CONTROL )
{
}
//***************************************************************************
CPA_Meca_ControlView::~CPA_Meca_ControlView()
{
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_ControlView message handlers
//***************************************************************************
void CPA_Meca_ControlView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
EnableToolTips(TRUE);
m_fn_pclGetDocument()->m_pclControlView = this;
CRect crClientRect;
GetClientRect(crClientRect);
CRect crLastRect;
GetDlgItem(IDC_LIST_CARD_TYPES)->GetClientRect(crLastRect);
crClientRect.bottom = crLastRect.bottom + 5;
crClientRect.right = crLastRect.right + 5;
MoveWindow(crClientRect);
SetScrollSizes(MM_TEXT, CSize(crClientRect.Width() - 5, crClientRect.Height() - 5));
//Sets Icons for Butttons
HICON hIcon = AfxGetApp()->LoadIcon(IDI_ICON_BUTTON_CREATE);
((CButton *)GetDlgItem(IDC_BUTTON_CREATE))->SetIcon(hIcon);
hIcon = AfxGetApp()->LoadIcon(IDI_ICON_BUTTON_RENAME);
((CButton *)GetDlgItem(IDC_BUTTON_RENAME))->SetIcon(hIcon);
hIcon = AfxGetApp()->LoadIcon(IDI_ICON_BUTTON_DELETE);
((CButton *)GetDlgItem(IDC_BUTTON_DELETE))->SetIcon(hIcon);
hIcon = AfxGetApp()->LoadIcon(IDI_ICON_BUTTON_COPY);
((CButton *)GetDlgItem(IDC_BUTTON_COPY))->SetIcon(hIcon);
//Fills the list of cards types
CListBox *pclTypeLB = (CListBox *)GetDlgItem(IDC_LIST_CARD_TYPES);
pclTypeLB->ResetContent();
CPA_Meca_CardType *pclCardType;
short wIndex = 0;
POSITION pos = m_fn_pclGetDocument()->m_clCardTypeList.GetHeadPosition();
while ( pos != NULL )
{
pclCardType = m_fn_pclGetDocument()->m_clCardTypeList.GetNext(pos);
wIndex = pclTypeLB->AddString(pclCardType->m_fn_csGetCardTypeName());
pclTypeLB->SetItemDataPtr(wIndex, (void *)pclCardType);
}
//////////////
//////////////
//Registers for TUT Module
TUT_M_vGetTutDll();
TUT_M_vRegisterControlID(IDC_BUTTON_CREATE, "TMe_ControlView_CreateButton", TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_RENAME, "TMe_ControlView_RenameButton", TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_DELETE, "TMe_ControlView_DeleteButton", TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_COPY, "TMe_ControlView_CopyButton", TUT_e_Button);
TUT_M_vRegisterControlID(IDC_LIST_CARD_TYPES, "TMe_ControlView_ListBox", TUT_e_ListBox);
//End of Registers for TUT Module
//////////////
}
//*******************************************************************************
void CPA_Meca_ControlView::OnDestroy()
{
//////////////
//////////////
//UnRegisters for TUT Module
TUT_M_vGetTutDll();
TUT_M_vUnregisterControlID(IDC_BUTTON_CREATE);
TUT_M_vUnregisterControlID(IDC_BUTTON_RENAME);
TUT_M_vUnregisterControlID(IDC_BUTTON_DELETE);
TUT_M_vUnregisterControlID(IDC_BUTTON_COPY);
TUT_M_vUnregisterControlID(IDC_LIST_CARD_TYPES);
//End of UnRegisters for TUT Module
//////////////
CFormView::OnDestroy();
}
//*******************************************************************************
void CPA_Meca_ControlView::OnButtonCreate()
{
if ( m_fn_pclGetDocument()->m_pclCurrentCardType != NULL )
{
CString csNewCardProposedName = m_fn_pclGetDocument()->m_pclCurrentCardType->m_fn_csGetCardTypeName();
//Erases 's' at the End
if ( csNewCardProposedName.Right(1).CompareNoCase("s") == 0 )
csNewCardProposedName = csNewCardProposedName.Left(csNewCardProposedName.GetLength() - 1);
CString csTrueNewCardProposedName;
csTrueNewCardProposedName.Format("%s_%i", csNewCardProposedName,
m_fn_pclGetDocument()->m_pclCurrentCardType->m_fn_ulGetCardsNumber() + 1);
m_fn_pclGetDocument()->m_fn_vCheckSpacesInString(csTrueNewCardProposedName);
CPA_Meca_NewCardDialog dial(csTrueNewCardProposedName, this);
if ( dial.DoModal() == IDOK )
{
m_fn_pclGetDocument()->m_fn_vCheckSpacesInString(dial.m_csName);
//Adds to Card Type's list of Cards
CPA_Meca_Card *pclNewCard = m_fn_pclGetDocument()->m_pclCurrentCardType->m_fn_pclGetCardsList()->m_fn_pclAddElement(dial.m_csName,
m_fn_pclGetDocument()->m_pclCurrentCardType,
NULL,
m_fn_pclGetDocument()->m_pclCurrentCardType->m_fn_csGetFileName(),
m_fn_pclGetDocument()->m_pclCurrentCardType->m_fn_csGetActionName());
//Adds to the Main list
m_fn_pclGetDocument()->m_clListOfCards.fn_bAddObject(pclNewCard);
//Sets the text for the number of Cards
m_fn_vUpdateCardsNumber(pclNewCard->m_fn_pclGetCardType());
//Updates Dialog List
m_fn_pclGetDocument()->m_pclDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
//Edits new Card
m_fn_pclGetDocument()->m_fn_vEditCard(pclNewCard);
}
}
}
//*******************************************************************************
// Deletes a Card
void CPA_Meca_ControlView::OnButtonDelete()
{
CPA_Meca_Card *pclCurrentCard = m_fn_pclGetDocument()->m_pclCurrentCard;
CPA_Meca_CardType *pclCurrentCardType = pclCurrentCard->m_fn_pclGetCardType();
ERROR_ASSERT( pclCurrentCard != NULL );
ERROR_ASSERT( pclCurrentCardType != NULL );
CString csQuestion = "BE CAREFUL !\nYou are going to destroy a Mechanical Card !";
csQuestion += "Name is '" + pclCurrentCard->GetName() + "', of type '" + pclCurrentCardType->m_fn_csGetCardTypeName() + "'\n";
csQuestion += "Do you really want to continue ?";
CPA_Meca_QuestionDialog dial(this, csQuestion);
if ( dial.DoModal() == IDYES )
{
//Adds to the Main list
m_fn_pclGetDocument()->m_clListOfCards.fn_bRemoveObject(pclCurrentCard);
//Destroys the Card ...
//...from the list
m_fn_pclGetDocument()->m_fn_vRemoveCard(pclCurrentCard);
//Sets the text for the number of Cards
m_fn_vUpdateCardsNumber(pclCurrentCardType);
//Updates Dialog List
m_fn_pclGetDocument()->m_pclDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
}
}
//*******************************************************************************
void CPA_Meca_ControlView::OnButtonRename()
{
CPA_Meca_NewCardDialog dial(m_fn_pclGetDocument()->m_pclCurrentCard->m_fn_csGetCardName(),
this);
if ( dial.DoModal() == IDOK )
{
m_fn_pclGetDocument()->m_pclCurrentCard->fn_eRename(dial.m_csName);
//Updates Dialog List
m_fn_pclGetDocument()->m_pclDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
}
}
//*******************************************************************************
void CPA_Meca_ControlView::OnButtonCopy()
{
//Creates a copy of the currently selected Card
if ( m_fn_pclGetDocument()->m_pclCurrentCard != NULL )
{
CPA_Meca_Card *pclCopyCard = m_fn_pclGetDocument()->m_pub_fn_vCreateCopyOfCard(m_fn_pclGetDocument()->m_pclCurrentCard);
if (pclCopyCard == NULL)
return;
//ERROR_ASSERT( pclCopyCard != NULL );
//Adds to the Main list
m_fn_pclGetDocument()->m_clListOfCards.fn_bAddObject(pclCopyCard);
//Sets the text for the number of Cards
m_fn_vUpdateCardsNumber(pclCopyCard->m_fn_pclGetCardType());
//Updates Dialog List
m_fn_pclGetDocument()->m_pclDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
//Edits new Card
m_fn_pclGetDocument()->m_fn_vEditCard(pclCopyCard);
}
}
//*******************************************************************************
void CPA_Meca_ControlView::OnSelchangeComboCardTypes()
{
//Gets the new selected type
CPA_Meca_CardType *pclCardType = NULL;
CListBox *pclTypeLB = (CListBox *)GetDlgItem(IDC_LIST_CARD_TYPES);
short wIndex = pclTypeLB->GetCurSel();
if ( wIndex != CB_ERR )
{
pclCardType = (CPA_Meca_CardType *)pclTypeLB->GetItemDataPtr(wIndex);
//Sets document's pointer
m_fn_pclGetDocument()->m_fn_vDisplayCardType(pclCardType);
//Sets the text for the number of Cards
m_fn_vUpdateCardsNumber(pclCardType);
//Sets document's pointer
if ( pclCardType->m_fn_pclGetEditedCard() != NULL )
m_fn_pclGetDocument()->m_fn_vEditCard(pclCardType->m_fn_pclGetEditedCard());
}
//Refreshes controls
((CButton *)GetDlgItem(IDC_BUTTON_CREATE))->EnableWindow( wIndex != CB_ERR );
//Updates Dialog List
if ( pclCardType != NULL )
{
CString csType = "Cards of type '" + pclCardType->m_fn_csGetCardTypeName() + "'";
m_fn_pclGetDocument()->m_pclDialogList->fn_vInitButtonTest( csType,
TRUE,
TRUE);
m_fn_pclGetDocument()->m_pclDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
}
}
//*******************************************************************************
void CPA_Meca_ControlView::m_fn_vUpdateCardsNumber(CPA_Meca_CardType *_pclCardType)
{
if ( _pclCardType != NULL )
{
CString csNumberOfCards;
CString csCard = (_pclCardType->m_fn_pclGetCardsList()->GetCount() > 1) ? "Cards" : "Card";
csNumberOfCards.Format("%i %s", _pclCardType->m_fn_pclGetCardsList()->GetCount(),
LPCTSTR(csCard));
GetDlgItem(IDC_STATIC_CARD_NUMBER)->SetWindowText(csNumberOfCards);
}
}
//*******************************************************************************
void CPA_Meca_ControlView::m_fn_vUpdateCardsName()
{
if ( m_fn_pclGetDocument()->m_pclCurrentCard != NULL )
{
//Displays Card's Name in View's title bar
CString csCardName = m_fn_pclGetDocument()->m_pclCurrentCard->GetName();
if ( m_fn_pclGetDocument()->m_pclCurrentCard->m_pub_fn_bIsNotified() )
csCardName += " (** Modified **)";
GetDlgItem(IDC_TEXT_CARD_NAME)->SetWindowText(csCardName);
}
}
//*******************************************************************************
CPA_Meca_MyDocument* CPA_Meca_ControlView::m_fn_pclGetDocument()
{
return g_pclInterface->m_fn_pclGetDocument();
}
//*******************************************************************************
BOOL CPA_Meca_ControlView::OnHelpInfo(HELPINFO* pHelpInfo)
{
CString csFileAndWindow = g_pclInterface->m_clDocument.m_csHelpFileNameAndPath;
::WinHelp(m_hWnd,
LPCTSTR(csFileAndWindow),
HELP_CONTEXT,
IDH_GENERAL);
return FALSE;
}
//*************************************************************************
//Definition of texts for Tool Tips
BOOL CPA_Meca_ControlView::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
UINT nID =pNMHDR->idFrom;
nID = ::GetDlgCtrlID((HWND)nID);
BOOL bReturn = FALSE;
switch ( nID )
{
case IDC_BUTTON_CREATE:
strcpy(pTTT->szText,"Creates a Mechanics Card");
break;
case IDC_BUTTON_RENAME:
strcpy(pTTT->szText,"Renames the current Card");
break;
case IDC_BUTTON_DELETE:
strcpy(pTTT->szText,"Deletes the current Card");
break;
case IDC_BUTTON_COPY:
strcpy(pTTT->szText,"Creates a copy of the current Card");
break;
case IDC_LIST_CARD_TYPES:
strcpy(pTTT->szText,"All types of Mechanics Card");
break;
case IDC_STATIC_CARD_NUMBER:
strcpy(pTTT->szText,"Number of Cards for the current Type");
break;
default:
strcpy(pTTT->szText,"");
break;
};
return (TRUE);
}
#define EdMeca_C_ControlsSpacing 2
#define EdMeca_C_EditHeight 15
//*************************************************************************
void CPA_Meca_ControlView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
//Adjusts controls
CRect crCurrentRect;
long lBottom;
//ListBox
if ( GetDlgItem(IDC_LIST_CARD_TYPES) != NULL )
{
GetDlgItem(IDC_LIST_CARD_TYPES)->GetWindowRect(crCurrentRect);
ScreenToClient(crCurrentRect);
lBottom = cy - EdMeca_C_EditHeight - 2*EdMeca_C_ControlsSpacing;
crCurrentRect.bottom = lBottom;
GetDlgItem(IDC_LIST_CARD_TYPES)->MoveWindow(crCurrentRect);
}
//Edit (for the current Card's name)
if ( GetDlgItem(IDC_TEXT_CARD_NAME) != NULL )
{
GetDlgItem(IDC_TEXT_CARD_NAME)->GetWindowRect(crCurrentRect);
ScreenToClient(crCurrentRect);
crCurrentRect.top = lBottom + EdMeca_C_ControlsSpacing;
crCurrentRect.bottom = crCurrentRect.top + EdMeca_C_EditHeight;
GetDlgItem(IDC_TEXT_CARD_NAME)->MoveWindow(crCurrentRect);
}
}
//*******************************************************************************
//*******************************************************************************
/////////////////////////////////////////////////////////////////////////////
// CPA_Meca_ControlView diagnostics
#ifdef _DEBUG
void CPA_Meca_ControlView::AssertValid() const
{
CFormView::AssertValid();
}
void CPA_Meca_ControlView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG

View File

@@ -0,0 +1,255 @@
// The one and only file to be touched to accomodate this editor with your project
////////////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include <limits.h>
#include <float.h>
#include "EditMDef.hpp"
#include "EMECDoc.hpp"
#include "EMECAllo.hpp"
#include "EMECDtMd.hpp"
#include "EMECFlds.hpp"
#include "EMECClBk.hpp"
#include "EMECCStr.hpp"
#include "_Minterf.hpp"
//External Modules
#include "ErO.h"
#include "CTL.h"
//End of External Modules
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//**********************************************************************************************
void CPA_Meca_MyDocument::m_fn_vFillCardsTypeList()
{
CPA_Meca_CardType *pclCardType;
/// For Controls
CTL_fn_vSetDefaultCallBackFunctionWhenControlMustBeDisplayed(TME_fn_bControlCanBeDisplayedCallBack);
/// End of 'For Controls'
///////// Adds a Card Type ///////////
pclCardType = m_clCardTypeList.m_fn_pclAddElement("Camera Cards", DNM_eCamera);
/// Defines it ///
pclCardType->m_p_fn_vUnallocate = &fn_vUnalloc6;
pclCardType->m_p_fn_vFill = &fn_vFillCard6;
pclCardType->m_p_fn_vSave = &fn_vSaveCard6;
pclCardType->m_fn_vSetFileName("Camera.mec");
pclCardType->m_fn_vSetActionName(C_SectionIdCardCamera);
//+++++++++++++++++++++++++++++++ Describes the Card Type +++++++++++++++++++++++++++++++
pclCardType->m_fn_vAddDecimalControl(-FLT_MAX, FLT_MAX, EDMEC_FLOAT, EDMEC_READ_WRITE, "Linear Speed");
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pclCardType->m_fn_vAddDecimalControl( -FLT_MAX, FLT_MAX, EDMEC_FLOAT, EDMEC_READ_WRITE, "Angular Delta (rad/s)");
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pclCardType->m_fn_vAddDecimalControl(-FLT_MAX, FLT_MAX, EDMEC_FLOAT, EDMEC_READ_WRITE, "Speeding Up (m/s)");
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
///////// Base ///////////
pclCardType = m_clCardTypeList.m_fn_pclAddElement("Base Cards", DNM_eBase);
/// Defines it ///
pclCardType->m_p_fn_vUnallocate = &fn_vUnallocRay2Egypte1;
pclCardType->m_p_fn_vFill = &fn_vFillCardRay2Egypte1;
pclCardType->m_p_fn_vSave = &fn_vSaveCardRay2Egypte1;
pclCardType->m_fn_vSetFileName("Base.mec");
pclCardType->m_fn_vSetActionName(C_SectionIdCardBase);
//+++++++++++++++++++++++++++++++ Describes the Card Type +++++++++++++++++++++++++++++++
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Animation);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Collide);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Gravity);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Tilt);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Gi);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_OnGround);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Climb);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Spider);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Shoot);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Swim);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_CollisionControl);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_KeepSpeedZ);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_SpeedLimit);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Inertia);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Stream);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_StickOnPlatform);
pclCardType->m_fn_vAddBooleanControl(EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Scale);
pclCardType->m_fn_vAddDecimalControl(-100, 100, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_GravityFactor);
pclCardType->m_fn_vAddDecimalControl(-100, 100, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Slide);
pclCardType->m_fn_vAddDecimalControl(-100, 100, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_Rebound);
pclCardType->m_fn_vAddDecimalControl(-90, 90, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_SlopeLimit);
pclCardType->m_fn_vAddDecimalControl(-10, 10, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_InertiaFactorX);
pclCardType->m_fn_vAddDecimalControl(-10, 10, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_InertiaFactorY);
pclCardType->m_fn_vAddDecimalControl(-10, 10, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_InertiaFactorZ);
pclCardType->m_fn_vAddDecimalControl(-10, 10, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_TiltIntensity);
pclCardType->m_fn_vAddDecimalControl(-10, 10, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_TiltInertia);
pclCardType->m_fn_vAddDecimalControl(-10, 10, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_TiltOrigin);
pclCardType->m_fn_vAddDecimalControl(-100, 100, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_MaxSpeed + " x");
pclCardType->m_fn_vAddDecimalControl(-100, 100, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_MaxSpeed + " y");
pclCardType->m_fn_vAddDecimalControl(-100, 100, EDMEC_FLOAT, EDMEC_READ_WRITE,g_c_cs_FieldName_Base_MaxSpeed + " z");
/// For Controls
CTL_fn_vSetDefaultCallBackFunctionWhenControlMustBeDisplayed(NULL);
/// End of 'For Controls'
}
#define TME_M_ADD_OWNER_DATA(a) \
a->m_pub_fn_pclAddOwnerData((void *)pclCard, TME_g_c_cs_DataOwnerData_ParentCard);
//**********************************************************************************************
void fn_vFillCard6(CPA_Meca_Card *pclCard)
{
if ( !pclCard->m_bDataCreated )
{
/// For Controls
CTL_fn_vSetDefaultCallBackFunctionWhenDataHasChanged(TME_fn_vCallBackWhenADataHasChanged);
/// End of 'For Controls'
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, "Linear Speed"));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, "Angular Delta (rad/s)"));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, "Speeding Up (m/s)"));
pclCard->m_bDataCreated = TRUE;
/// For Controls
CTL_fn_vSetDefaultCallBackFunctionWhenDataHasChanged(NULL);
/// End of 'For Controls'
}
if ( pclCard->m_fn_pvGetBaseAddress() == NULL )
{
POSITION pos = pclCard->m_clDataList.GetHeadPosition();
while ( pos != NULL )
(pclCard->m_clDataList.GetNext(pos))->m_fn_vSetMotorDataPtr(NULL);
}
else
{
POSITION pos = pclCard->m_clDataList.GetHeadPosition();
//Gets the struct
DNM_stMecCameraIdCard * pStruct = (DNM_stMecCameraIdCard *)pclCard->m_fn_pvGetBaseAddress();
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xLinearSpeed)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xAngularSpeed)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xSpeedingUp)));
ERROR_ASSERT(pos == NULL);
}
}
void fn_vFillCardRay2Egypte1(CPA_Meca_Card *pclCard)
{
if ( !pclCard->m_bDataCreated )
{
/// For Controls
CTL_fn_vSetDefaultCallBackFunctionWhenDataHasChanged(TME_fn_vCallBackWhenADataHasChanged);
/// End of 'For Controls'
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0001, g_c_cs_FieldName_Base_Animation));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0002, g_c_cs_FieldName_Base_Collide));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0004, g_c_cs_FieldName_Base_Gravity));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0008, g_c_cs_FieldName_Base_Tilt));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0010, g_c_cs_FieldName_Base_Gi));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0020, g_c_cs_FieldName_Base_OnGround));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0040, g_c_cs_FieldName_Base_Climb));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0080, g_c_cs_FieldName_Base_Spider));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0001, g_c_cs_FieldName_Base_Shoot));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0002, g_c_cs_FieldName_Base_Swim));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0002, g_c_cs_FieldName_Base_CollisionControl));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0004, g_c_cs_FieldName_Base_KeepSpeedZ));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0008, g_c_cs_FieldName_Base_SpeedLimit));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0010, g_c_cs_FieldName_Base_Inertia));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0020, g_c_cs_FieldName_Base_Stream));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0040, g_c_cs_FieldName_Base_StickOnPlatform));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddBitFieldBooleanData(0x0080, g_c_cs_FieldName_Base_Scale));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_GravityFactor));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_Slide));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_Rebound));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_SlopeLimit));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_InertiaFactorX));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_InertiaFactorY));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_InertiaFactorZ));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_TiltIntensity));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_TiltInertia));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_TiltOrigin));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_MaxSpeed + " x" ));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_MaxSpeed + " y" ));
TME_M_ADD_OWNER_DATA(pclCard->m_clDataList.m_fn_pclAddDecimalData(EDMEC_FLOAT, g_c_cs_FieldName_Base_MaxSpeed + " z" ));
pclCard->m_bDataCreated = TRUE;
/// For Controls
CTL_fn_vSetDefaultCallBackFunctionWhenDataHasChanged(NULL);
/// End of 'For Controls'
}
if ( pclCard->m_fn_pvGetBaseAddress() == NULL )
{
POSITION pos = pclCard->m_clDataList.GetHeadPosition();
while ( pos != NULL )
(pclCard->m_clDataList.GetNext(pos))->m_fn_vSetMotorDataPtr(NULL);
}
else
{
POSITION pos = pclCard->m_clDataList.GetHeadPosition();
//Gets the struct
DNM_tdstMecBaseIdCard *pStruct = (DNM_tdstMecBaseIdCard *)pclCard->m_fn_pvGetBaseAddress();
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->ulFlags)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->ulFlags)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->ulFlags)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->ulFlags)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->ulFlags)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->ulFlags)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->ulFlags)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->ulFlags)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 1);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 2);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 1);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 1);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 1);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 1);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 1);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 1);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr(((char *)(&(pStruct->ulFlags))) + 1);
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xGravity)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xSlide)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xRebound)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xSlopeLimit)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xInertiaX)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xInertiaY)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xInertiaZ)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xTiltIntensity)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xTiltInertia)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_xTiltOrigin)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_stMaxSpeed.xX)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_stMaxSpeed.xY)));
pclCard->m_clDataList.GetNext(pos)->m_fn_vSetMotorDataPtr((void *)(&(pStruct->m_stMaxSpeed.xZ)));
ERROR_ASSERT(pos == NULL);
}
}
//**********************************************************************************************
//Constructs the objects representing the enum definitions
void CPA_Meca_MyDocument::m_fn_vConstructListOfEnumDescriptors()
{
}

View File

@@ -0,0 +1,10 @@
LIBRARY
EXPORTS
fn_p_szGetCPAVersion
fn_p_stGetDLLIdentity
fn_p_oGetDLL
fn_vInitDll
SECTIONS
.data READ WRITE

View File

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

View File

@@ -0,0 +1,124 @@
//
// Common functions for Object DLL capabilities
// C. Beaudet
//
#include "StdAfx.h"
#include "afxdllx.h"
#include "ACP_Base.h"
#include "ITF.h"
#include "IncMEC.h"
#define D_State_Define
#include "IncGAM.h"
#undef D_State_Define
#include "GLI.h"
#include "_Minterf.hpp"
#include "EMECStrg.hpp"
//------------------------------------------------------------------------
// Global vars
static CList<CPA_DLLBase*,CPA_DLLBase*> g_oListOfInstances; //private internal
static char *gs_p_szCPAVersion = C_szCPAVersion;
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
#ifdef DLL_ONLY_ONE_INSTANCE
static CPA_Meca_Interface *gs_p_oMecaInterface = NULL;
#endif
//------------------------------------------------------------------------
// functions that are present in all DLL :
//------------------------------------------------------------------------
//========================================================================
// Get current CPA version
//========================================================================
extern "C" char __declspec(dllexport) *fn_p_szGetCPAVersion(void)
{
return gs_p_szCPAVersion;
}
//========================================================================
// Get type of this DLL
//========================================================================
extern "C" tdstDLLIdentity __declspec(dllexport) *fn_p_stGetDLLIdentity(void)
{
g_stMecaDLLIdentity.eType = TOOL_DLL;
g_stMecaDLLIdentity.csName = C_szDLLMecaName;
g_stMecaDLLIdentity.hModule = NULL;
g_stMecaDLLIdentity.p_oListOfInstances = &g_oListOfInstances;
return &g_stMecaDLLIdentity;
}
//========================================================================
// DLL int function
//========================================================================
extern "C" void __declspec(dllexport) fn_vInitDll(void)
{
new CDynLinkLibrary(extensionDLL);
}
//========================================================================
// DLL entry point
//========================================================================
extern "C" int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
if (!AfxInitExtensionModule(extensionDLL, hInstance))
return 0;
}
return 1;
}
//========================================================================
// Get the DLL
//========================================================================
extern "C" CPA_DLLBase __declspec(dllexport) *fn_p_oGetDLL(long lKey)
{
#ifdef DLL_ONLY_ONE_INSTANCE
switch(lKey)
{
case 0: // the game world
if (gs_p_oMYTOOLInterface == NULL)
{
gs_p_oMecaInterface = new CPA_Meca_Interface();
ERROR_ASSERT(gs_p_oMecaInterface != NULL);
// YB //
g_pclInterface = gs_p_oMecaInterface;
// End YB //
}
return gs_p_oMecaInterface;
break;
default:
return NULL;
}
#else //DLL_ONLY_ONE_INSTANCE
switch(lKey)
{
case 0: // the game world
// YB //
g_pclInterface = new CPA_Meca_Interface();
return g_pclInterface;
// End YB //
break;
default:
return NULL;
}
#endif //DLL_ONLY_ONE_INSTANCE
}
//------------------------------------------------------------------------
// functions that are present in this type of DLL only :
//------------------------------------------------------------------------
#undef DLL_ONLY_ONE_INSTANCE

View File

@@ -0,0 +1,479 @@
// Implementation for the definition of the class representing a Mechanical Card
/////////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "_MecCard.hpp"
#include "_Minterf.hpp"
#include "EMECStrg.hpp"
#include "EMECVwMn.hpp"
#include "Dpt.h"
#include "ErO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//***************************************************************************
CPA_Meca_Card::CPA_Meca_Card( CString csName,
CPA_Meca_CardType *pclCardType,
CString csEngineFileName,
CString csEngineActionName,
void *pvBaseAddress,
BOOL bCanbBeLoaded /*= FALSE*/)
: CPA_SaveObject( g_pclInterface,
g_c_csMecaCardTypeName,
E_ss_Responsible)
{
//Internal inits
m_pri_bIsNotified = FALSE;
//Section object
SetSectionData(this);
SetCallBackSave(s_m_fn_vCallBackSaveMecaCard);
SetDataPath(fn_szGetMechanicsDataPath());
m_pub_fn_vSetCompleteFileName(csEngineFileName);
m_pub_fn_vSetActionName(csEngineActionName);
SetReferencedSectionName(m_pri_fn_csComputeReferencedSectionName());
//Base objet
fn_bSetOwner(NULL);
//Name
if ( fn_eRename(csName) != E_mc_None )
SetDefaultValidName();
fn_vUpdateSectionName();
if ( pvBaseAddress != NULL )
SetExistingSection(TRUE);
else
{
if ( bCanbBeLoaded )
SetExistingSection(TRUE);
else
SetExistingSection(FALSE);
}
if ( !fn_bSectionExists() )
fn_vNotifySave();
//Specific Inits
m_pclCardType = pclCardType;
m_bDataCreated = FALSE;
//Allocates the structure
if ( pvBaseAddress == NULL )
{
if ( !bCanbBeLoaded )
m_fn_vSetBaseAddress( DNM_fn_xIdentityCardCreate(m_pclCardType->m_fn_tdeGetMotorID()) );
}
else
//There is an exiting Card (loaded by Motor)
m_fn_vSetBaseAddress( pvBaseAddress );
if ( !bCanbBeLoaded )
{
//Calls the filling function
ERROR_ASSERT( m_pclCardType->m_p_fn_vFill != NULL );
m_pclCardType->m_p_fn_vFill(this);
//Updates Editor values with motor ones
m_pri_fn_vGetAllMotorValues();
}
}
//***************************************************************************
CPA_Meca_Card::~CPA_Meca_Card()
{
//Unallocates the structure
ERROR_ASSERT( m_pclCardType->m_p_fn_vUnallocate != NULL );
m_pclCardType->m_p_fn_vUnallocate(this);
}
//***************************************************************************
void *CPA_Meca_Card::GetEngineStruct()
{
return m_fn_pvGetBaseAddress();
}
//***************************************************************************
void *CPA_Meca_Card::m_fn_pvGetBaseAddress()
{
return m_pvBaseAddress;
}
//***************************************************************************
void CPA_Meca_Card::m_fn_vSetBaseAddress(void *pvNewAddress)
{
//Base Object
fn_vUpdateData(pvNewAddress);
//Internal
m_pvBaseAddress = pvNewAddress;
}
//***************************************************************************
CString CPA_Meca_Card::m_fn_csGetCardName()
{
return CString(GetName());
}
//***************************************************************************
void CPA_Meca_Card::m_fn_vSetCardName(CString csNewName)
{
fn_eRename(csNewName);
}
//***************************************************************************
CPA_Meca_CardType *CPA_Meca_Card::m_fn_pclGetCardType()
{
return m_pclCardType;
}
//***************************************************************************
void CPA_Meca_Card::m_fn_pclSetCardType(CPA_Meca_CardType *pclNewType)
{
m_pclCardType = pclNewType;
}
//***************************************************************************
void CPA_Meca_Card::m_pri_fn_vGetAllMotorValues()
{
POSITION pos = m_clDataList.GetHeadPosition();
while ( pos != NULL )
m_clDataList.GetNext(pos)->m_fn_vGetMotorData();
}
//******************************************************************************
CString CPA_Meca_Card::m_pri_fn_csComputeReferencedSectionName()
{
CString csReferencedSectioName;
csReferencedSectioName = m_pub_fn_csGetReferencedFileName() + '^' + m_pub_fn_csGetActionName() + ':' + GetName();
return csReferencedSectioName;
}
//******************************************************************************
//Not to be used ...
CString CPA_Meca_Card::m_pri_fn_csComputeCompleteSectionName()
{
CString csCompleteSectioName;
CString csFileName /*= GetFileName()*/;
//Adds the Path to the file name
short wIndex = csFileName.ReverseFind('\\');
//If no Path is present
if ( wIndex == -1 )
{
//Security...
if ( csFileName == "NoFileName" )
{
csFileName = m_pclCardType->m_fn_csGetFileName();
// SetActionName(m_pclCardType->m_fn_csGetActionName());
}
csFileName = "GameData\\World\\Libraries\\Mechanics\\" + csFileName;
// SetFileName(csFileName);
}
// csCompleteSectioName = GetFileName() + '^' + GetActionName() + ':' + GetName();
return csCompleteSectioName;
}
//For Save
//******************************************************************************
/*void CPA_Meca_Card::fn_vNotify(SCR_tde_Ntfy_Action _eAction)
{
switch( _eAction )
{
case SCR_EA_Ntfy_RebuildSection:
case SCR_EA_Ntfy_ModifySection:
case SCR_EA_Ntfy_AddSection:
SCR_fn_v_SvL1_RegisterNotify( (char*)LPCTSTR(GetCompleteSectionName()),
s_m_fn_vCallBackSaveMecaCard,
(void *)this,
_eAction);
break ;
case SCR_EA_Ntfy_DeleteSection:
SCR_fn_v_SvL1_RegisterNotify( (char*)LPCTSTR(GetCompleteSectionName()),
NULL,
(void *)this,
_eAction);
break ;
}
}
*/
//******************************************************************************
CString CPA_Meca_Card::m_pub_fn_csGetActionName()
{
return m_pri_csActionName;
}
//******************************************************************************
void CPA_Meca_Card::m_pub_fn_vSetActionName(CString csNewName)
{
m_pri_csActionName = csNewName;
}
//******************************************************************************
CString CPA_Meca_Card::m_pub_fn_csGetCompleteFileName()
{
return m_pri_csCompleteFileName;
}
//******************************************************************************
CString CPA_Meca_Card::m_pub_fn_csGetReferencedFileName()
{
return m_pri_csReferencedFileName;
}
//******************************************************************************
void CPA_Meca_Card::m_pub_fn_vSetCompleteFileName(CString csNewName)
{
m_pri_csCompleteFileName = csNewName;
short wIndexInString = csNewName.ReverseFind('\\');
if ( wIndexInString != -1 )
m_pri_csReferencedFileName = csNewName.Right(csNewName.GetLength() - wIndexInString - 1);
else
m_pri_csReferencedFileName = m_pri_csCompleteFileName;
}
//******************************************************************************
BOOL CPA_Meca_Card::m_pub_fn_bIsNotified()
{
return m_pri_bIsNotified;
}
//Notifications
//******************************************************************************
void CPA_Meca_Card::fn_vNotifySave()
{
CPA_SaveObject::fn_vNotifySave();
//Marks the Card
if ( !m_pri_bIsNotified )
{
m_pri_bIsNotified = TRUE;
g_pclInterface->m_clDocument.m_pclControlView->m_fn_vUpdateCardsName();
}
}
//******************************************************************************
void CPA_Meca_Card::fn_vNotifyUnSave()
{
CPA_SaveObject::fn_vNotifyUnSave();
//Marks the Card
if ( m_pri_bIsNotified )
{
m_pri_bIsNotified = FALSE;
g_pclInterface->m_clDocument.m_pclControlView->m_fn_vUpdateCardsName();
}
}
//******************************************************************************
void CPA_Meca_Card::fn_vNotifyRestore()
{
CPA_SaveObject::fn_vNotifyRestore();
//Marks the Card
if ( !m_pri_bIsNotified )
{
m_pri_bIsNotified = TRUE;
g_pclInterface->m_clDocument.m_pclControlView->m_fn_vUpdateCardsName();
}
}
//******************************************************************************
void CPA_Meca_Card::fn_vNotifyRename()
{
CPA_SaveObject::fn_vNotifyRename();
//Marks the Card
if ( !m_pri_bIsNotified )
{
m_pri_bIsNotified = TRUE;
g_pclInterface->m_clDocument.m_pclControlView->m_fn_vUpdateCardsName();
}
}
//******************************************************************************
void CPA_Meca_Card::s_m_fn_vCallBackSaveMecaCard( SCR_tdst_File_Description *_p_stFile,
char *_p_szSectionName,
void *_p_vData,
SCR_tde_Ntfy_Action _eAction)
{
CPA_Meca_Card *p_clMecaCard = (CPA_Meca_Card *)_p_vData ;
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,"Saving a Mechanical Card",
"CPA_Meca_Card::s_m_fn_vCallBackSaveMecaCard(...)",
E_ERROR_GRAVITY_FATAL,
"Pointer on Card is NULL ; Card could not be saved.");
ERROR_ASSERT( p_clMecaCard != NULL );
if ( p_clMecaCard != NULL )
{
switch ( _eAction )
{
case SCR_EA_Ntfy_AddSection:
case SCR_EA_Ntfy_AddOrModifySection:
case SCR_EA_Ntfy_AddOrRebuildSection:
case SCR_EA_Ntfy_RebuildSection:
case SCR_EA_Ntfy_ModifySection:
//Saves Mecanichal Card
p_clMecaCard->m_fn_vSaveMecaCard(_p_stFile, _eAction);
p_clMecaCard->m_pri_bIsNotified = FALSE;
p_clMecaCard->fn_vSectionSaved();
break ;
case SCR_EA_Ntfy_DeleteIfExists:
case SCR_EA_Ntfy_DeleteSection:
p_clMecaCard->fn_vSectionDeleted();
break;
}
}
}
//******************************************************************************
BOOL CPA_Meca_Card::m_fn_bLoadIfUnloaded()
{
if ( !fn_bIsAvailable() )
{
//Loads the corresponding section
CString csSectionName = GetCompleteSectionName();
SCR_tdst_Cxt_Values *p_stValues;
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char *)LPCTSTR(csSectionName),
SCR_CDF_uw_Anl_Normal);
//Displays the last loaded Actor
void *pvBaseAddress = (void *)p_stValues->a_ulValues[0];
m_fn_vSetBaseAddress(pvBaseAddress);
//Calls the filling function
ERROR_ASSERT( m_pclCardType->m_p_fn_vFill != NULL );
m_pclCardType->m_p_fn_vFill(this);
// update parameter
DNM_tdstMecBaseIdCard *pMecCard = (DNM_tdstMecBaseIdCard *)m_fn_pvGetBaseAddress();
DNM_M_vBaseIdCardSetSlopeLimit ( pMecCard, MTH_M_xRadToDeg ( MTH_M_xATan (DNM_M_xBaseIdCardGetSlopeLimit(pMecCard))) );
//Updates Editor values with motor ones
m_pri_fn_vGetAllMotorValues();
SetAvailable(TRUE);
//Edits
g_pclInterface->m_clDocument.m_fn_vEditCard(this);
m_pclCardType->m_bAtLeastOneCardOfTheCardTypeHasBeenLoaded = TRUE;
return TRUE;
}
else
return FALSE;
}
//**************************************************************************************
//Virtual functions
//**************************************************************************************
//**************************************************************************************
long CPA_Meca_Card::GetDataType(void)
{
return 0;
}
//**************************************************************************************
void *CPA_Meca_Card::GetData(void)
{
return m_fn_pvGetBaseAddress();
}
//**************************************************************************************
BOOL CPA_Meca_Card::fn_bCanBeNotified(void)
{
return TRUE;
}
//**************************************************************************************
//** CPA_Meca_CardList class ***********************************************************
//**************************************************************************************
CPA_Meca_CardList::CPA_Meca_CardList()
{
}
//**************************************************************************************
CPA_Meca_CardList::~CPA_Meca_CardList()
{
m_fn_vEmptyList();
}
//**************************************************************************************
CPA_Meca_Card* CPA_Meca_CardList::m_fn_pclAddElement( CString csName,
CPA_Meca_CardType *pclCardType,
void *pvBaseAddress,
CString csFileName /*= ""*/,
CString csSectionName /*= ""*/,
BOOL bCanbBeLoaded /*= FALSE*/)
{
CPA_Meca_Card *pclNewElement = new CPA_Meca_Card( csName,
pclCardType,
csFileName,
csSectionName,
pvBaseAddress,
bCanbBeLoaded);
AddTail(pclNewElement);
return pclNewElement;
}
//**************************************************************************************
void CPA_Meca_CardList::m_fn_vEmptyList()
{
POSITION pos = GetHeadPosition();
while( pos != NULL )
delete (GetNext(pos));
RemoveAll();
}
//**************************************************************************************
//Returns the first available (i.e. loaded) Card in the List
CPA_Meca_Card *CPA_Meca_CardList::m_pub_fn_pclGetFirstAvailableCard()
{
CPA_Meca_Card *pclCurrentCard;
BOOL bFound = FALSE;
POSITION pos = GetHeadPosition();
while ( (pos != NULL) && (!bFound) )
{
pclCurrentCard = GetNext(pos);
bFound = pclCurrentCard->fn_bIsAvailable();
}
if ( bFound )
return pclCurrentCard;
else
return NULL;
}

View File

@@ -0,0 +1,575 @@
//#################################################################################
//
// BASE CLASS OF YOUR DLL interface
//
//#################################################################################
#include "StdAfx.h"
#include "ACP_Base.h"
#include "ITF.h"
#include "IncMEC.h"
#define D_State_Define
#include "IncGAM.h"
#undef D_State_Define
#include "GLI.h"
#include "SCR.h"
#include "_Minterf.hpp"
#include "EMECStrg.hpp"
#include "EMECVwMn.hpp"
#include "Meca_Res.h"
#include "ErO.h"
#include "IncTUT.h"
#include "X:\CPA\Main\Inc\_EditID.h"
// infos
static CString g_csTMEName = C_szDLLMecaName;
static CString g_csTMEAuthor = "Y. Babitch";
static CString g_csTMEVersion = "V 4.0.2 18/03/99";
static CString g_csTMEFrenchHelpFile = "Meca.hlp";
static CString g_csTMEEnglishHelpFile = "";
BOOL g_bTipFirstTime = TRUE;
CPA_Meca_Interface *g_pclInterface;
#define C_EdMeca_MenuID_OpenID 31
#define C_EdMeca_MenuID_CloseID 32
#define C_EdMeca_MenuID_SaveDimensions 35
#define C_EdMeca_PopupID_Exit_Editor 41
// the DLL global definition
tdstDLLIdentity g_stMecaDLLIdentity;
//--------------------------------------------------------------------------------
// CONSTRUCTOR.
// You must put here all your DLL interface definitions.
//--------------------------------------------------------------------------------
CPA_Meca_Interface::CPA_Meca_Interface(void)
{
// ************************** private internal
m_p_stDLLIdentity = &g_stMecaDLLIdentity;
// 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;
// Specific Init.
m_pclMecaMainFrame = NULL;
m_csEditorVersion = "4.0.0 [" + CString(__DATE__) + "] (<using CTL version " + CTL_fn_csGetVersion() + ">)";
SetEditorInfo(g_csTMEName, g_csTMEAuthor, g_csTMEVersion, g_csTMEFrenchHelpFile, g_csTMEEnglishHelpFile);
SetCurrent(FALSE);
//For errors
ERROR_g_fn_vAddAModuleDescriptor( g_c_csMecaModuleNameForErrors,
m_csEditorVersion,
"Yves BABITCH",
"01 48 18 53 74 (Montreuil)",
"ybabitch@ubisoft.fr",
"Daniel PALIX",
"04 50 51 26 63 (Annecy)",
"dpalix@ubisoft.fr",
"",
"",
""
);
m_pri_pclSelectedCard = NULL;
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vJustAfterRegistered(void)
{
CString a_csTypes[] =
{
g_c_csMecaCardTypeName,
};
fn_vRegisterObjectsType(a_csTypes, 1);
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vConstruct()
{
//Windows constructions
//Creates the main frame
if ( m_pclMecaMainFrame == NULL )
{
m_pclMecaMainFrame = new CPA_Meca_MainFrame;
m_pclMecaMainFrame->CreateBase( "",
1,
2,
GetInterface()->GetMainWorld() );
m_pclMecaMainFrame->mfn_vEnableCaption(FALSE);
m_pclMecaMainFrame->m_iInitWidth = m_clDocument.m_ulEditorWidth;
m_pclMecaMainFrame->m_bKeepPos = TRUE;
m_pclMecaMainFrame->m_stWinRight.cLinkSame = FRM_C_MoveLeft;
}
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,
"Construction of Mechanics Editor",
"CPA_Meca_Interface::fn_vConstruct()",
E_ERROR_GRAVITY_FATAL,
"Dialog List could not be created for this Editor");
ERROR_ASSERT( m_clDocument.m_pclDialogList != NULL );
m_clDocument.m_pclDialogList->fn_vInitAllLists();
m_clDocument.m_pclDialogList->fn_vReinitDialog();
//////////////
//////////////
//Registers for TUT Module
TUT_M_vGetTutDll();
TUT_M_vRegisterControl(m_pclMecaMainFrame->m_hWnd, "TME_MainFrame", TUT_e_Window);
//End of Registers for TUT Module
//////////////
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vLevelChanges()
{
//Researches for existing Mechanics (loaded by Motor)
m_fn_pclGetDocument()->m_fn_vSearchForLoadedCards();
//Loads others
m_fn_pclGetDocument()->m_fn_vLoadUnloadedCards();
//Displays in the Editor
m_fn_pclGetDocument()->m_fn_vReInitDisplay();
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vAfterSaveAll(void)
{
m_fn_pclGetDocument()->m_pclControlView->m_fn_vUpdateCardsName();
}
//**************************************************************************************
BOOL CPA_Meca_Interface::fn_bLoadBaseObject(CPA_BaseObject *p_oObject)
{
ERROR_PREPARE_M(g_c_csMecaModuleNameForErrors,
"Trying to load a mechanical Card",
"CPA_Meca_Interface::fn_bLoadBaseObject(...)",
E_ERROR_GRAVITY_FATAL,
"The given object is not of the right type");
ERROR_ASSERT( p_oObject->fn_bIsOfType(C_szMecaCardTypeName) );
//Loads the Card
return ((CPA_Meca_Card *)p_oObject)->m_fn_bLoadIfUnloaded();
}
//**************************************************************************************
tdePermission CPA_Meca_Interface::fn_eAcceptNewEditor(CPA_EditorBase *pNewEditor)
{
return C_Allow;
}
//**************************************************************************************
BOOL CPA_Meca_Interface::fn_bCanActivateEditor(CPA_List<CPA_BaseObject> *pParams)
{
return TRUE;
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vOnActivateEditor(CPA_List<CPA_BaseObject> *pParams,
BOOL bBackActivated)
{
m_fn_vShowEditor();
}
//**************************************************************************************
BOOL CPA_Meca_Interface::fn_bCanCloseEditor(void)
{
return TRUE;
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vOnCloseEditor(void)
{
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vBeforeEngine(void)
{
m_fn_vHideEditor();
//ANNECY jt {
CPA_BaseObject* poBaseObject;
Position xPos;
CPA_BaseObjectList* poListOfCard = GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (g_c_csMecaCardTypeName);
for ( poBaseObject = poListOfCard->GetHeadElement(xPos); xPos; poBaseObject = poListOfCard->GetNextElement(xPos) )
{
if ( poBaseObject->fn_bIsValid() )
{
CPA_Meca_Card* poCard = (CPA_Meca_Card*)poBaseObject;
if (poCard->m_bDataCreated)
{
if (poCard->m_fn_pclGetCardType()->m_fn_csGetCardTypeName()=="Base Cards")
{
DNM_tdstMecBaseIdCard *pMecCard = (DNM_tdstMecBaseIdCard *)poCard->m_fn_pvGetBaseAddress();
DNM_M_vBaseIdCardSetSlopeLimit ( pMecCard, MTH_M_xTan (MTH_M_xDegToRad (DNM_M_xBaseIdCardGetSlopeLimit(pMecCard))) );
}
}
}
}
//ENDANNECY jt }
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vBeforeEditor(void)
{
if ( fn_bIsCurrentEditor() )
m_fn_vShowEditor();
//ANNECY jt {
CPA_BaseObject* poBaseObject;
Position xPos;
CPA_BaseObjectList* poListOfCard = GetInterface()->GetMainWorld()->fn_p_oGetOriginalObjectList (g_c_csMecaCardTypeName);
for ( poBaseObject = poListOfCard->GetHeadElement(xPos); xPos; poBaseObject = poListOfCard->GetNextElement(xPos) )
{
if ( poBaseObject->fn_bIsValid() )
{
CPA_Meca_Card* poCard = (CPA_Meca_Card*)poBaseObject;
if (poCard->m_bDataCreated)
{
if (poCard->m_fn_pclGetCardType()->m_fn_csGetCardTypeName()=="Base Cards")
{
DNM_tdstMecBaseIdCard *pMecCard = (DNM_tdstMecBaseIdCard *)poCard->m_fn_pvGetBaseAddress();
DNM_M_vBaseIdCardSetSlopeLimit ( pMecCard, MTH_M_xRadToDeg ( MTH_M_xATan (DNM_M_xBaseIdCardGetSlopeLimit(pMecCard))) );
poCard->m_pri_fn_vGetAllMotorValues();
}
}
}
}
//ENDANNECY jt }
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vHasLostFocus(void)
{
}
//**************************************************************************************
BOOL CPA_Meca_Interface::fn_bHasGainedFocus(void)
{
// display Tip of the Day
GetInterface()->fn_vDisplayTipOfDay("Mechanics", "TME", g_bTipFirstTime);
g_bTipFirstTime = FALSE;
return TRUE;
}
//**************************************************************************************
//Begin Mircea Dunka 31 Aug 1998 - DialogBar interface
void CPA_Meca_Interface::fn_vDefineDlgBarBtnIcon (tde_DlgBarCategory wCategory, tds_DlgBarBtn *_pDlgBarBtn)
{
if(wCategory == C_DlgBarCategoryEditor)
{
_pDlgBarBtn->hIcon = ::LoadIcon((HINSTANCE)(GetDLLIdentity()->hModule), MAKEINTRESOURCE(IDI_TME_DLGBAR_ICON));
CString oCst;
oCst = C_szDLLMecaName;
if( (M_GetMainApp()) && (M_GetMainApp()->mp_oAppKeyboard) )
{
oCst += " (";
oCst += M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Mechanic Editor"));
oCst += ")";
}
strcpy(_pDlgBarBtn->szToolTip, (char*)(LPCTSTR)oCst);
_pDlgBarBtn->uID = (UINT)this;
}
}
//end Mircea Dunka 31 Aug 1998
//**************************************************************************************
BOOL CPA_Meca_Interface::fn_bDefineSubMenu(EDT_SubMenu *_p_oEDTSubMenu)
{
if ( _p_oEDTSubMenu->GetSubMenuType() == C_SubMenuEditor )
{
CString csMenuDescString;
CString csMenuAccelString = M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Mechanic Editor"));
csMenuDescString.Format("%s\t%s", C_szDLLMecaName, csMenuAccelString);
if ( fn_bIsCurrentEditor() )
_p_oEDTSubMenu->AddAnEntry(this, M_MAKECHAR(csMenuDescString), C_EdMeca_MenuID_CloseID, TRUE);
else
_p_oEDTSubMenu->AddAnEntry(this, M_MAKECHAR(csMenuDescString), C_EdMeca_MenuID_OpenID, FALSE);
}
else if ( _p_oEDTSubMenu->GetSubMenuType() == C_SubMenuPreference )
{
if ( fn_bIsCurrentEditor() )
_p_oEDTSubMenu->AddAnEntry(this, "Save dimensions (Mechanics)", C_EdMeca_MenuID_SaveDimensions, FALSE);
}
return TRUE;
}
//**************************************************************************************
void CPA_Meca_Interface::_OnSubMenuCommand( EDT_SubMenu *_p_oEDTSubMenu,
UINT uiMsgID)
{
switch (uiMsgID)
{
case C_EdMeca_MenuID_OpenID:
if ( !fn_bIsCurrentEditor() )
GetMainWorld()->fn_bActivateEditor(this, NULL);
break;
case C_EdMeca_MenuID_CloseID:
if ( fn_bIsCurrentEditor() )
GetMainWorld()->fn_bCloseEditor(this);
break;
case C_EdMeca_MenuID_SaveDimensions:
if ( fn_bIsCurrentEditor() )
m_clDocument.m_pub_fn_bSavePreferences();
break;
}
}
//**************************************************************************************
//**************************************************************************************
// Popup
//**************************************************************************************
BOOL CPA_Meca_Interface::fn_bDefinePopupMenu(EDT_PopUpMenu *pPopup,
CPA_List<CPA_SuperObject> *pSelection,
BOOL bIsAlone)
{
BOOL bReturn = FALSE;
if ( !bIsAlone )
{
if ( fn_bIsCurrentEditor() )
{
pPopup->AddAnEntry(this, "Exit Mechanics Editor", C_EdMeca_PopupID_Exit_Editor);
bReturn = TRUE;
}
}
return bReturn;
}
//**************************************************************************************
void CPA_Meca_Interface::_OnPopUpMenuCommand(UINT m_IDCmdMsg)
{
switch (m_IDCmdMsg)
{
case C_EdMeca_PopupID_Exit_Editor:
if ( fn_bIsCurrentEditor() )
GetMainWorld()->fn_bCloseEditor(this);
break;
}
}
//**************************************************************************************
//**************************************************************************************
//Lists Dialog
//**************************************************************************************
#define C_szCards "Cards"
//**************************************************************************************
void CPA_Meca_Interface::GetListsForDialog(CPA_DialogList *pDialog)
{
pDialog->fn_vAddANewList(C_szCards, &(m_clDocument.m_clListOfCards));
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vInitDefaultParameters(CPA_DialogList *pDialog)
{
pDialog->SetDefaultButtonState(FALSE);
pDialog->SetDefaultTestName("<< No Filter >>");
pDialog->SetDefaultTypeName(C_szCards);
}
//**************************************************************************************
void CPA_Meca_Interface::fn_vSetANewTest( CPA_DialogList *pDialog,
CString csCurrentList)
{
CString csButtonText = "All cards";
BOOL bButtonMustBeEnabled = TRUE;
BOOL bButtonState = FALSE;
if ( csCurrentList.Compare(C_szCards) == 0 )
{
if ( m_fn_pclGetDocument()->m_pclCurrentCardType != NULL )
csButtonText = CString("Cards of type '")
+ m_fn_pclGetDocument()->m_pclCurrentCardType->m_fn_csGetCardTypeName()
+ CString("'");
else
csButtonText = "All cards";
bButtonMustBeEnabled = TRUE;
bButtonState = TRUE;
}
pDialog->fn_vInitButtonTest((char *)LPCTSTR(csButtonText),
bButtonState,
bButtonMustBeEnabled);
}
//**************************************************************************************
BOOL CPA_Meca_Interface::fn_bTestFunction(CString csCurrentType,
CString csTestName,
CPA_BaseObject *pEdObj)
{
BOOL bReturnValue = TRUE;
if ( csCurrentType.Compare(C_szCards) == 0 )
{
if ( m_fn_pclGetDocument()->m_pclCurrentCardType != NULL )
bReturnValue = ( ((CPA_Meca_Card *)pEdObj)->m_fn_pclGetCardType() == m_fn_pclGetDocument()->m_pclCurrentCardType );
}
return bReturnValue;
}
//**************************************************************************************
BOOL CPA_Meca_Interface::fn_bOnButtonTest(CPA_DialogList *pDialog,
CString csTypeName,
tdeListDrawMode eDraw)
{
BOOL bReturnValue = FALSE;
//Shows all Cards
m_fn_pclGetDocument()->m_pclCurrentCardType = NULL;
pDialog->fn_vUpdateSelection(E_lrm_ReinitList);
pDialog->fn_vInitButtonTest("All cards",
TRUE,
TRUE);
return bReturnValue;
}
//***********************************************************************
BOOL CPA_Meca_Interface::fn_bOnSelChangeComboList(CPA_DialogList *pDialog,
CString csTypeName)
{
if ( csTypeName.CompareNoCase(C_szCards) == 0 )
{
//Shows all Cards
m_fn_pclGetDocument()->m_pclCurrentCardType = NULL;
pDialog->fn_vUpdateSelection(E_lrm_ReinitList);
pDialog->fn_vInitButtonTest("All cards",
TRUE,
TRUE);
}
return FALSE;
}
//***********************************************************************
BOOL CPA_Meca_Interface::fn_bOnSelChangeListObjects(CPA_DialogList *pDialog,
CString csTypeName,
CPA_BaseObject *pSelectedObject,
BOOL bUnselect)
{
if ( csTypeName.CompareNoCase(C_szCards) == 0 )
{
//Displays Card
CPA_Meca_Card *pclCard = (CPA_Meca_Card *)pSelectedObject;
if ( bUnselect )
m_pri_pclSelectedCard = NULL;
else
{
if ( pclCard->fn_bIsAvailable() )
{
m_fn_pclGetDocument()->m_fn_vEditCard(pclCard);
m_pri_pclSelectedCard = pclCard;
}
// else
// if ( m_fn_pclGetDocument()->m_pclCurrentCardType != NULL )
// m_pri_pclSelectedCard = m_fn_pclGetDocument()->m_pclCurrentCardType ->m_fn_pclGetEditedCard();
}
pDialog->fn_vUpdateSelection(E_lrm_ChangeSelection);
}
return TRUE;
}
//***********************************************************************
CPA_BaseObject *CPA_Meca_Interface::GetDialogSelection( CPA_DialogList *pDialog,
CString csTypeName,
tdeListDrawMode eDrawMode)
{
if ( csTypeName.CompareNoCase(C_szCards) == 0 )
return m_pri_pclSelectedCard;
return NULL;
}
//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
// Specific members
//***********************************************************************
void CPA_Meca_Interface::m_fn_vShowEditor()
{
g_oFrameGest.mfn_vSetRefresh(FALSE);
if ( m_pclMecaMainFrame != NULL )
g_oFrameGest.mfn_vActivateWindow(m_pclMecaMainFrame);
g_oFrameGest.mfn_vSetRefresh(TRUE);
}
//***********************************************************************
void CPA_Meca_Interface::m_fn_vHideEditor()
{
g_oFrameGest.mfn_vSetRefresh(FALSE);
if ( m_pclMecaMainFrame != NULL )
g_oFrameGest.mfn_vDisactivateWindow(m_pclMecaMainFrame);
g_oFrameGest.mfn_vSetRefresh(TRUE);
}
//**************************************************************************************
CPA_Meca_MyDocument *CPA_Meca_Interface::m_fn_pclGetDocument()
{
ERROR_ASSERT ( AfxIsValidAddress(&m_clDocument, sizeof(CPA_Meca_MyDocument)) );
return &m_clDocument;
}
//**************************************************************************************
long CPA_Meca_Interface::OnQueryAction(CPA_EditorBase * /*p_oSender*/, WPARAM _wParam, LPARAM _lParam)
{
switch (_wParam )
{
case Cw_TME_Query_updateAfterLoading:
//Researches for existing Mechanics (loaded by Motor)
m_fn_pclGetDocument()->m_fn_vUpdateUnLoadedCards();
break;
}
return 0L;
}