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,6 @@
// stdafx.cpp : source file that includes just the standard includes
// Err.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,12 @@
; Waw.def : Declares the module parameters for the DLL.
LIBRARY
DESCRIPTION 'Waw Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
WAW_fn_vInitModule
WAW_fn_vInitWatchWindow
WAW_fn_vRefreshWatchWindow

View File

@@ -0,0 +1,60 @@
///////////////////////////////////////////////////////////////////////////////
//
// Implementation file for Data used by WAW
//
///////////////////////////////////////////////////////////////////////////////
#include <StdAfx.h>
#include "WAW_Main.hpp"
#include "WAW_Data.hpp"
#include "WAW_Strg.hpp"
#include "ErO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern WAW_MainDialog * WAW_g_pclWatchWindow;
//***********************************************
// Constructor
//***********************************************
WAW_Data::WAW_Data( CString _csDataName, CString _csDataValue, WAW_tdstUserInfo * _pstUserInfo, void * _pvUserData )
{
m_pri_csDataName = _csDataName;
m_pri_csDataValue = _csDataValue;
m_pri_pstUserInfo = _pstUserInfo;
m_pri_pvUserData = _pvUserData;
m_pri_bIsData = TRUE;
}
//***************************
// Destructor
//***************************
WAW_Data::~WAW_Data()
{}
WAW_Data * WAW_Data::m_pub_fn_pclGetParentData()
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Get the parent of a Data",
"WAW_Data::m_pub_fn_pclGetParentData",
E_ERROR_GRAVITY_FATAL,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return NULL;
HTREEITEM hParentItem = pclTreeCtrl->GetParentItem( m_pri_hTreeItem );
if( hParentItem == NULL ) return NULL;
return (WAW_Data*)pclTreeCtrl->GetItemData( hParentItem );
}

View File

@@ -0,0 +1,217 @@
///////////////////////////////////////////////////////////////////////////////
//
// Implementation for List of Data
//
///////////////////////////////////////////////////////////////////////////////
#include <StdAfx.h>
#include "WAW_User.hpp"
#include "WAW_Main.hpp"
#include "WAW_List.hpp"
#include "WAW_Strg.hpp"
#include "ErO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern WAW_MainDialog * WAW_g_pclWatchWindow;
extern CList<WAW_hUserInfo,WAW_hUserInfo> WAW_g_clListOfUser;
#define WAW_M_bCheckInfo(_hInfo) (WAW_g_clListOfUser.Find((_hInfo)) != NULL)
WAW_DataList::WAW_DataList( CString _csUserModuleName ) : CList<WAW_Data*,WAW_Data*>()
{
WAW_hUserInfo hInfo = WAW_fn_hFindInfo( _csUserModuleName );
if( hInfo == NULL ) return;
m_pri_hUserInfo = hInfo;
//m_pub_fn_vGetAll();
}
WAW_DataList::WAW_DataList( WAW_hUserInfo _hInfo ) : CList<WAW_Data*,WAW_Data*>()
{
if( !WAW_M_bCheckInfo( _hInfo ) ) return;
m_pri_hUserInfo = _hInfo;
m_pub_fn_vGetAll();
}
void WAW_DataList::m_pub_fn_vGetAll()
{
RemoveAll();
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Construct a list of Data",
"WAW_DataList::WAW_DataList",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return;
HTREEITEM hItem = pclTreeCtrl->GetNextItem( NULL, TVGN_ROOT );
m_pri_fn_vFillList( pclTreeCtrl, hItem );
}
void WAW_DataList::m_pri_fn_vFillList( CTreeCtrl * _pclTree, HTREEITEM _hItem )
{
while( _hItem != NULL )
{
WAW_Data * pclData = (WAW_Data*)_pclTree->GetItemData( _hItem );
if( pclData->m_pri_pstUserInfo == m_pri_hUserInfo ) AddTail( pclData );
m_pri_fn_vFillList( _pclTree, _pclTree->GetChildItem( _hItem ) );
_hItem = _pclTree->GetNextItem( _hItem, TVGN_NEXT );
}
}
void WAW_DataList::m_pub_fn_vGetData()
{
m_pub_fn_vGetAll();
m_pub_fn_vSelectData();
}
void WAW_DataList::m_pub_fn_vSelectData()
{
POSITION pos = GetHeadPosition();
POSITION posOld = NULL;
while( pos != NULL )
{
posOld = pos;
WAW_Data * pclData = GetNext( pos );
if( !pclData->m_pri_bIsData ) RemoveAt( posOld );
}
}
void WAW_DataList::m_pub_fn_vGetNode()
{
m_pub_fn_vGetAll();
m_pub_fn_vSelectNode();
}
void WAW_DataList::m_pub_fn_vSelectNode()
{
POSITION pos = GetHeadPosition();
POSITION posOld = NULL;
while( pos != NULL )
{
posOld = pos;
WAW_Data * pclData = GetNext( pos );
if( pclData->m_pri_bIsData ) RemoveAt( posOld );
}
}
void WAW_DataList::m_pub_fn_vGetWithName( CString _csName )
{
m_pub_fn_vGetAll();
m_pub_fn_vSelectWithName( _csName );
}
void WAW_DataList::m_pub_fn_vSelectWithName( CString _csName )
{
POSITION pos = GetHeadPosition();
POSITION posOld = NULL;
while( pos != NULL )
{
posOld = pos;
WAW_Data * pclData = GetNext( pos );
if( pclData->m_pri_csDataName != _csName ) RemoveAt( posOld );
}
}
void WAW_DataList::m_pub_fn_vGetChildren( CString _csName )
{
m_pub_fn_vGetAll();
m_pub_fn_vSelectChildren( _csName );
}
void WAW_DataList::m_pub_fn_vSelectChildren( CString _csName )
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Select the children of a Data",
"WAW_DataList::m_pub_fn_vSelectChildren",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return;
POSITION pos = GetHeadPosition();
POSITION posOld = NULL;
while( pos != NULL )
{
posOld = pos;
WAW_Data * pclData = GetNext( pos );
HTREEITEM hParentItem = pclTreeCtrl->GetParentItem( pclData->m_pri_hTreeItem );
if( hParentItem != NULL )
{
WAW_Data * pclParentData = (WAW_Data*)pclTreeCtrl->GetItemData( hParentItem );
if( pclParentData->m_pri_csDataName != _csName ) RemoveAt( posOld );
}
else RemoveAt( posOld );
}
}
void WAW_DataList::m_pub_fn_vGetVisible()
{
m_pub_fn_vGetAll();
m_pub_fn_vSelectVisible();
}
void WAW_DataList::m_pub_fn_vSelectVisible()
{
m_pri_fn_vUpdateVisible();
POSITION pos = GetHeadPosition();
POSITION posOld = NULL;
while( pos != NULL )
{
posOld = pos;
WAW_Data * pclData = GetNext( pos );
if( pclData->m_pri_bVisible == FALSE ) RemoveAt( posOld );
}
}
void WAW_DataList::m_pri_fn_vUpdateVisible()
{
POSITION pos = GetHeadPosition();
while( pos != NULL )
{
WAW_Data * pclData = GetNext( pos );
pclData->m_pri_bVisible = FALSE;
}
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Select the visible Data",
"WAW_DataList::m_pub_fn_vSelectVisible",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return;
HTREEITEM hItem = pclTreeCtrl->GetFirstVisibleItem();
while( hItem != NULL )
{
WAW_Data * pclData = (WAW_Data*)pclTreeCtrl->GetItemData( hItem );
pclData->m_pri_bVisible = TRUE;
hItem = pclTreeCtrl->GetNextVisibleItem( hItem );
}
}

View File

@@ -0,0 +1,310 @@
///////////////////////////////////////////////////////////////////////////////
// //
// Implementation of Watch Dialog and List //
// //
///////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#define ACTIVE_EDITOR
#define CPA_WANTS_IMPORT
#include "ACP_base.h"
#include "IncItf.h"
#undef ACTIVE_EDITOR
#undef CPA_WANTS_IMPORT
#include "WAW_Main.hpp"
#include "WAW_Data.hpp"
#include "WAW_User.hpp"
#include "WAW_Strg.hpp"
#include "ErO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern HMODULE WAW_g_hModule;
extern WAW_MainDialog * WAW_g_pclWatchWindow;
/////////////////////////////////////////////////////////////////////////////
// WAW_MainDialog dialog
WAW_MainDialog::WAW_MainDialog(CWnd* pParent /*=NULL*/)
: CDialog(WAW_MainDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(WAW_MainDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
HINSTANCE hOldInstance = AfxGetResourceHandle();
AfxSetResourceHandle( WAW_g_hModule );
BOOL bValue = CDialog::Create(WAW_MainDialog::IDD, &g_oBaseFrame);
// pParent);
m_pri_iPosX = 50;
m_pri_iPosY = 50;
m_pri_iPosCx = 200;
m_pri_iPosCy = 200;
AfxSetResourceHandle( hOldInstance );
}
void WAW_MainDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(WAW_MainDialog)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(WAW_MainDialog, CDialog)
//{{AFX_MSG_MAP(WAW_MainDialog)
ON_NOTIFY(TVN_KEYDOWN, IDC_TREE_WAW, OnKeydownTreeWaw)
ON_NOTIFY(TVN_DELETEITEM, IDC_TREE_WAW, OnDeleteitemTreeWaw)
ON_WM_SIZE()
ON_WM_CLOSE()
ON_WM_MOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// WAW_MainDialog message handlers
BOOL WAW_MainDialog::OnInitDialog()
{
CDialog::OnInitDialog();
char * pcPath = new char[MAX_PATH];
GetModuleFileName( WAW_g_hModule, pcPath, MAX_PATH );
m_pri_csInitFileName = pcPath;
delete[] pcPath;
int i = m_pri_csInitFileName.ReverseFind( '\\' );
m_pri_csInitFileName = m_pri_csInitFileName.Left( i+1 ) + "WAWInit.ini";
m_pri_fn_bLoadInitFile();
//Always visible at the beginning
SetWindowPos( &CWnd::wndTop/*Most*/, m_pri_iPosX, m_pri_iPosY, m_pri_iPosCx, m_pri_iPosCy, SWP_HIDEWINDOW);
CRect *pclRect = new CRect;
GetWindowRect( pclRect );
ScreenToClient( pclRect );
pclRect->DeflateRect( 10, 30, 10, 10 );
m_pub_fn_pclGetTreeCtrl()->MoveWindow( pclRect );
delete pclRect;
ShowWindow( FALSE );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void WAW_MainDialog::OnKeydownTreeWaw(NMHDR* pNMHDR, LRESULT* pResult)
{
TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*)pNMHDR;
if ( pTVKeyDown->wVKey == 46 ) //"Suppr" was pressed
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Delete Data in Watch Window",
"WAW_MainDialog::OnKeydownTreeWaw",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return;
HTREEITEM hItem = pclTreeCtrl->GetSelectedItem();
if (hItem == NULL)
return;
WAW_Data * pclData = (WAW_Data*)pclTreeCtrl->GetItemData( hItem );
WAW_fn_bDeleteData( pclData );
}
*pResult = 0;
}
void WAW_MainDialog::OnDeleteitemTreeWaw(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM hItem = pNMTreeView->itemOld.hItem;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Send a message for deleted Data in Watch Window",
"WAW_MainDialog::OnDeleteitemTreeWaw",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
WAW_Data * pclData = (WAW_Data*)pclTreeCtrl->GetItemData( hItem );
if( pclData->m_pri_pstUserInfo->m_pfnCallBack!= NULL )
{
if( pclData->m_pri_bIsData )
pclData->m_pri_pstUserInfo->m_pfnCallBack( WAW_eDeletedData, (void*)pclData );
// else
// pclData->m_pri_pstUserInfo->m_pfnCallBack( WAW_eDeletedNode, (void*)pclData );
}
*pResult = 0;
}
void WAW_MainDialog::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CTreeCtrl * pclTreeCtrl = m_pub_fn_pclGetTreeCtrl();
if( pclTreeCtrl == NULL ) return;
CRect *pclRect = new CRect;
GetWindowRect( pclRect );
ScreenToClient( pclRect );
pclRect->DeflateRect( 10, 30, 10, 10 );
pclTreeCtrl->MoveWindow( pclRect );
delete pclRect;
RECT * pstRect = new RECT;
GetWindowRect( pstRect );
m_pri_iPosX = pstRect->left;
m_pri_iPosY = pstRect->top;
m_pri_iPosCx = pstRect->right - pstRect->left;
m_pri_iPosCy = pstRect->bottom - pstRect->top;
m_pri_fn_bSaveInitFile();
}
void WAW_MainDialog::OnMove(int x, int y)
{
CDialog::OnMove(x, y);
RECT * pstRect = new RECT;
GetWindowRect( pstRect );
m_pri_iPosX = pstRect->left;
m_pri_iPosY = pstRect->top;
m_pri_iPosCx = pstRect->right - pstRect->left;
m_pri_iPosCy = pstRect->bottom - pstRect->top;
m_pri_fn_bSaveInitFile();
}
void WAW_MainDialog::OnClose()
{
WAW_fn_vSendMessage( WAW_eHideWindow, NULL );
CDialog::OnClose();
}
//*****************************************************************************
//*** Specific Members ********************************************************
//*****************************************************************************
CListCtrl * WAW_MainDialog::m_pub_fn_pclGetListCtrl()
{
return (CListCtrl*)GetDlgItem( IDC_LIST_WAW );
}
CTreeCtrl * WAW_MainDialog::m_pub_fn_pclGetTreeCtrl()
{
return (CTreeCtrl*)GetDlgItem( IDC_TREE_WAW );
}
BOOL WAW_MainDialog::m_pri_fn_bLoadInitFile()
{
CFile file;
if ( !file.Open(m_pri_csInitFileName, CFile::modeRead) ) return FALSE;
file.Close();
m_pri_iPosX = GetPrivateProfileInt(WAW_g_C_csSectionPosition,
WAW_g_C_csEntryX,
m_pri_iPosX,
LPCTSTR(m_pri_csInitFileName));
m_pri_iPosY = GetPrivateProfileInt(WAW_g_C_csSectionPosition,
WAW_g_C_csEntryY,
m_pri_iPosY,
LPCTSTR(m_pri_csInitFileName));
m_pri_iPosCx = GetPrivateProfileInt(WAW_g_C_csSectionPosition,
WAW_g_C_csEntryCx,
m_pri_iPosCx,
LPCTSTR(m_pri_csInitFileName));
m_pri_iPosCy = GetPrivateProfileInt(WAW_g_C_csSectionPosition,
WAW_g_C_csEntryCy,
m_pri_iPosCy,
LPCTSTR(m_pri_csInitFileName));
return TRUE;
}
BOOL WAW_MainDialog::m_pri_fn_bSaveInitFile()
{
CString csWriteString;
BOOL bReturn = TRUE;
RECT * pstRect = new RECT;
GetWindowRect( pstRect );
//ScreenToClient( pstRect );
if ( bReturn )
{
csWriteString.Format( "%ld", m_pri_iPosX/*pstRect->left*/ );
bReturn = WritePrivateProfileString(WAW_g_C_csSectionPosition,
WAW_g_C_csEntryX,
LPCTSTR(csWriteString),
LPCTSTR(m_pri_csInitFileName));
}
if ( bReturn )
{
csWriteString.Format( "%ld", m_pri_iPosY/*pstRect->top*/ );
bReturn = WritePrivateProfileString(WAW_g_C_csSectionPosition,
WAW_g_C_csEntryY,
LPCTSTR(csWriteString),
LPCTSTR(m_pri_csInitFileName));
}
if ( bReturn )
{
csWriteString.Format( "%ld", m_pri_iPosCx/*pstRect->right - pstRect->left*/ );
bReturn = WritePrivateProfileString(WAW_g_C_csSectionPosition,
WAW_g_C_csEntryCx,
LPCTSTR(csWriteString),
LPCTSTR(m_pri_csInitFileName));
}
if ( bReturn )
{
csWriteString.Format( "%ld", m_pri_iPosCy/*pstRect->bottom - pstRect->top*/ );
bReturn = WritePrivateProfileString(WAW_g_C_csSectionPosition,
WAW_g_C_csEntryCy,
LPCTSTR(csWriteString),
LPCTSTR(m_pri_csInitFileName));
}
return bReturn;
}

View File

@@ -0,0 +1,484 @@
///////////////////////////////////////////////////////////////////////////////
//
// Implementation file
//
///////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "WAW_Main.hpp"
#include "WAW_User.hpp"
#include "WAW_Strg.hpp"
#include "WAW_Data.hpp"
#include "ErO.h"
//*** Global Variables for Watch Dialog
WAW_MainDialog * WAW_g_pclWatchWindow = NULL;
CList<WAW_hUserInfo,WAW_hUserInfo> WAW_g_clListOfUser;
BOOL WAW_g_bAcceptMessage = TRUE;
CImageList * WAW_g_pclImageList = NULL;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define WAW_M_bCheckInfo(_hInfo) (WAW_g_clListOfUser.Find((_hInfo)) != NULL)
//******************************
// Create the Main Dialog Window
//******************************
void WAW_fn_vInitWatchWindow()
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Create the Watch Window Main Dialog",
"WAW_fn_vInitWatchWindow",
E_ERROR_GRAVITY_INSTABLE,
"The Main Dialog is not allocated" );
if( WAW_g_pclWatchWindow == NULL )
WAW_g_pclWatchWindow = new WAW_MainDialog( AfxGetMainWnd() );
ERROR_ASSERT( WAW_g_pclWatchWindow != NULL );
if( WAW_g_pclImageList == NULL )
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Create the Watch Window Image List",
"WAW_fn_vInitWatchWindow",
E_ERROR_GRAVITY_INSTABLE,
"The Image List is not allocated" );
WAW_g_pclImageList = new CImageList;
ERROR_ASSERT( WAW_g_pclImageList != NULL );
if( WAW_g_pclImageList == NULL ) return;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Create the Watch Window Image List",
"WAW_fn_vInitWatchWindow",
E_ERROR_GRAVITY_INSTABLE,
"The Image List is not created" );
BOOL bResult = WAW_g_pclImageList->Create( 16, 16, ILC_COLOR16, 10, 5 );
ERROR_ASSERT( bResult != NULL );
if( bResult == FALSE ) return;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Create the Watch Window Image List",
"WAW_fn_vInitWatchWindow",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return;
pclTreeCtrl->SetImageList( WAW_g_pclImageList, TVSIL_NORMAL );
}
}
void WAW_fn_vRefreshWatchWindow()
{
if( WAW_g_bAcceptMessage )
WAW_fn_vSendMessage( WAW_eUpdateData, NULL );
}
void WAW_fn_vSendMessage( WAW_tdeMessage _eMessage, void* _pvData )
{
// if the dialog window is not created, there is no message
if( WAW_g_pclWatchWindow == NULL ) return;
POSITION pos = WAW_g_clListOfUser.GetHeadPosition();
while( pos != NULL )
{
WAW_hUserInfo hInfo = WAW_g_clListOfUser.GetNext( pos );
if( hInfo->m_pfnCallBack != NULL ) hInfo->m_pfnCallBack( _eMessage, _pvData );
}
}
CWnd * WAW_fn_pclGetWatchWindowDialog()
{
return (CWnd*)WAW_g_pclWatchWindow;
}
CWnd * WAW_fn_pclGetWatchWindowTree()
{
if( WAW_g_pclWatchWindow != NULL )
return (CWnd*)WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
else
return NULL;
}
//*******************************
// Display the Watch Window
//*******************************
void WAW_fn_vDisplayWatchWindow()
{
WAW_fn_vSendMessage( WAW_eShowWindow, NULL );
WAW_g_pclWatchWindow->ShowWindow( TRUE );
}
void WAW_fn_vHideWatchWindow()
{
WAW_fn_vSendMessage( WAW_eHideWindow, NULL );
WAW_g_pclWatchWindow->ShowWindow( FALSE );
}
void WAW_fn_vSetWatchWindowTopMost( BOOL _bTopMost )
{
if( _bTopMost )
WAW_g_pclWatchWindow->SetWindowPos( &CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
else
WAW_g_pclWatchWindow->SetWindowPos( &CWnd::wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
WAW_hUserInfo WAW_fn_hFindInfo( CString _csUserModuleName )
{
BOOL bExist = FALSE;
WAW_hUserInfo hUserInfo = NULL;
POSITION pos = WAW_g_clListOfUser.GetHeadPosition();
while( (pos != NULL) && (!bExist) )
{
hUserInfo = WAW_g_clListOfUser.GetNext( pos );
bExist = ( hUserInfo->m_csUserModuleName == _csUserModuleName );
}
if( bExist ) return hUserInfo;
else return NULL;
}
//***************************************************************************************
// Register module using the Watch Window
//
// Input : _csUserModuleName, a name to identify the module
// _pfnCallBack, the CallBack used by the Watch Window to communicate
//
// Output : Handle of User Information, usefull to identify Module when it will add Data
//***************************************************************************************
WAW_hUserInfo WAW_fn_hUserRegister( CString _csUserModuleName, WAW_CallBack _pfnCallBack)
{
WAW_hUserInfo hUserInfo = WAW_fn_hFindInfo( _csUserModuleName );
if( hUserInfo != NULL ) return hUserInfo;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Register new user for Watch Window",
"WAW_fn_vUserRegister",
E_ERROR_GRAVITY_INSTABLE,
"The new User is not allocated" );
WAW_tdstUserInfo * pstInfo = new WAW_tdstUserInfo;
ERROR_ASSERT( pstInfo != NULL );
pstInfo->m_csUserModuleName = _csUserModuleName;
pstInfo->m_pfnCallBack = _pfnCallBack;
WAW_g_clListOfUser.AddTail( pstInfo );
return pstInfo;
}
//*************************************************************************************************
// Add a Data in the Watch Window
//
// Input : _hInfo, the handle of user info given when the user registered
// _pclParentData, the parent of the data to add
// _csDataName, the name of the added data
// _csDataValue, a string representing the value of the added data
// _pvUserData, a pointer to a possibly usefull data for the user
//
// Outpout : a pointer to the WAW_Data added or NULL if a problem is encounted
//*************************************************************************************************
WAW_Data * WAW_fn_pclAddData( CString _csUserModuleName, WAW_Data * _pclParentData, CString _csDataName, CString _csDataValue, void *_pvUserData )
{
WAW_hUserInfo hInfo = WAW_fn_hFindInfo( _csUserModuleName );
if( hInfo != NULL )
return WAW_fn_pclAddData( hInfo, _pclParentData, _csDataName, _csDataValue, _pvUserData );
else return NULL;
}
WAW_Data * WAW_fn_pclAddData( WAW_hUserInfo _hInfo, WAW_Data * _pclParentData, CString _csDataName, CString _csDataValue, void *_pvUserData )
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Add Data in Watch Window",
"WAW_fn_pclAddData",
E_ERROR_GRAVITY_INSTABLE,
"The WAW_hUserInfo is invalid" );
ERROR_ASSERT( WAW_M_bCheckInfo( _hInfo ) );
if( !WAW_M_bCheckInfo( _hInfo ) ) return NULL;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Add Data in Watch Window",
"WAW_fn_pclAddData",
E_ERROR_GRAVITY_INSTABLE,
"The new Data is not allocated" );
WAW_Data *pclData = new WAW_Data( _csDataName, _csDataValue, _hInfo, _pvUserData );
ERROR_ASSERT( pclData != NULL );
if( pclData == NULL ) return NULL;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Add Data in Watch Window",
"WAW_fn_pclAddData",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return NULL;
HTREEITEM hParentItem = ( _pclParentData == NULL ? NULL : _pclParentData->m_pri_hTreeItem );
HTREEITEM hChildItem = pclTreeCtrl->GetChildItem( hParentItem );
while( hChildItem != NULL )
{
if( ((WAW_Data*)pclTreeCtrl->GetItemData( hChildItem ))->m_pub_fn_csGetDataName() == _csDataName )
return (WAW_Data*)pclTreeCtrl->GetItemData( hChildItem );
hChildItem = pclTreeCtrl->GetNextItem( hChildItem, TVGN_NEXT );
}
if( hParentItem == NULL ) hParentItem = TVI_ROOT;
TV_INSERTSTRUCT stItem;
stItem.hParent = hParentItem;
stItem.hInsertAfter = TVI_LAST;
stItem.item.mask = TVIF_TEXT | TVIF_STATE;
CString csDataString = _csDataName + " : " + _csDataValue;
stItem.item.pszText = (char*)LPCTSTR( csDataString );
stItem.item.state = TVIS_EXPANDED;
stItem.item.stateMask = TVIS_EXPANDED;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Add Data in Watch Window",
"WAW_fn_pclAddData",
E_ERROR_GRAVITY_INSTABLE,
"The new subitem is not added in CTree" );
HTREEITEM hItem = pclTreeCtrl->InsertItem( &stItem );
ERROR_ASSERT( hItem != NULL );
if( hItem == NULL ) return NULL;
pclData->m_pri_hTreeItem = hItem;
pclTreeCtrl->SetItemData( hItem, (DWORD)pclData );
return pclData;
}
//*************************************************************************************************
// Add a Node in the Watch Window
//
// Input : _hInfo, the handle of user info given when the user registered
// _pclParentData, the parent of the node to add
// _csDataName, the name of the added node
// _pvUserData, a pointer to a possibly usefull data for the user
//
// Outpout : a pointer to the WAW_Data added or NULL if a problem is encounted
//
//*************************************************************************************************
WAW_Data * WAW_fn_pclAddNode( CString _csUserModuleName, WAW_Data * _pclParentData, CString _csNodeName, void *_pvUserData )
{
WAW_hUserInfo hInfo = WAW_fn_hFindInfo( _csUserModuleName );
if( hInfo != NULL )
return WAW_fn_pclAddNode( hInfo, _pclParentData, _csNodeName, _pvUserData );
else return NULL;
}
WAW_Data * WAW_fn_pclAddNode( WAW_hUserInfo _hInfo, WAW_Data * _pclParentData, CString _csNodeName, void *_pvUserData )
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Add Node in Watch Window",
"WAW_fn_pclAddNode",
E_ERROR_GRAVITY_INSTABLE,
"The WAW_hUserInfo is invalid" );
ERROR_ASSERT( WAW_M_bCheckInfo( _hInfo ) );
if( !WAW_M_bCheckInfo( _hInfo ) ) return NULL;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Add Node in Watch Window",
"WAW_fn_pclAddNode",
E_ERROR_GRAVITY_INSTABLE,
"The new Node is not allocated" );
WAW_Data *pclData = new WAW_Data( _csNodeName, "", _hInfo, _pvUserData );
ERROR_ASSERT( pclData != NULL );
if( pclData == NULL ) return NULL;
pclData->m_pri_bIsData = FALSE;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Add Node in Watch Window",
"WAW_fn_pclAddNode",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return NULL;
HTREEITEM hParentItem = ( _pclParentData == NULL ? NULL : _pclParentData->m_pri_hTreeItem );
HTREEITEM hChildItem = pclTreeCtrl->GetChildItem( hParentItem );
while( hChildItem != NULL )
{
if( ((WAW_Data*)pclTreeCtrl->GetItemData( hChildItem ))->m_pub_fn_csGetDataName() == _csNodeName )
return (WAW_Data*)pclTreeCtrl->GetItemData( hChildItem );
hChildItem = pclTreeCtrl->GetNextItem( hChildItem, TVGN_NEXT );
}
if( hParentItem == NULL ) hParentItem = TVI_ROOT;
TV_INSERTSTRUCT stItem;
stItem.hParent = hParentItem;
stItem.hInsertAfter = TVI_LAST;
stItem.item.mask = TVIF_TEXT | TVIF_STATE;
stItem.item.pszText = (char*)LPCTSTR( _csNodeName );
stItem.item.state = TVIS_EXPANDED;
stItem.item.stateMask = TVIS_EXPANDED;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Add Node in Watch Window",
"WAW_fn_pclAddNode",
E_ERROR_GRAVITY_INSTABLE,
"The new subitem is not added in CTree" );
HTREEITEM hItem = pclTreeCtrl->InsertItem( &stItem );
ERROR_ASSERT( hItem != NULL );
if( hItem == NULL ) return NULL;
pclData->m_pri_hTreeItem = hItem;
pclTreeCtrl->SetItemData( hItem, (DWORD)pclData );
return pclData;
}
//*****************************************************************************
// Update the value of a Data placed in the Watch Window
//
// Input : _pclData, a pointer to the Data to update
// _csDataValue, a string representing the new value of the Data
//
// Output : TRUE if succesfull, otherwise FALSE
//*****************************************************************************
BOOL WAW_fn_bUpdateData( WAW_Data * _pclData, CString _csDataValue )
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Update Data in Watch Window",
"WAW_fn_bUpdateData",
E_ERROR_GRAVITY_WARNING,
"The Data to update is NULL : operation aborted" );
ERROR_ASSERT( _pclData != NULL );
if( _pclData == NULL ) return FALSE;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Update Data in Watch Window",
"WAW_fn_pclUpdateData",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return NULL;
if( _pclData->m_pri_csDataValue != _csDataValue )
{
CString csDataString = _pclData->m_pub_fn_csGetDataName() + " : " + _csDataValue;
BOOL bOk = pclTreeCtrl->SetItemText( _pclData->m_pri_hTreeItem, (char*)LPCTSTR( csDataString ) );
if( bOk ) _pclData->m_pri_csDataValue = _csDataValue;
return bOk;
}
return TRUE;
}
//*********************************************************
// Delete a specific Data from the Watch Window
//
// Input : _pclData, the pointer to the Data to delete
//
// Output : TRUE if successfull, otherwise FALSE
//*********************************************************
BOOL WAW_fn_bDeleteData( WAW_Data *_pclData )
{
WAW_g_bAcceptMessage = FALSE;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Remove a Data from the Watch Window",
"WAW_fn_bRemoveData",
E_ERROR_GRAVITY_WARNING,
"The Data to remove is NULL : operation aborted" );
ERROR_ASSERT( _pclData != NULL );
if( _pclData == NULL ) return FALSE;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Remove a Data from the Watch Window",
"WAW_fn_bRemoveData",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return FALSE;
HTREEITEM hParentItem = pclTreeCtrl->GetParentItem( _pclData->m_pri_hTreeItem );
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Remove a Data from the Watch Window",
"WAW_fn_bRemoveData",
E_ERROR_GRAVITY_WARNING,
"The Data to remove is not deleted in CTreeCtrl" );
BOOL bOk = pclTreeCtrl->DeleteItem( _pclData->m_pri_hTreeItem );
ERROR_ASSERT( bOk );
delete _pclData;
WAW_g_bAcceptMessage = TRUE;
if( hParentItem != NULL ) return WAW_fn_bCheckForEmptyNode( hParentItem );
else return bOk;
}
BOOL WAW_fn_bCheckForEmptyNode( HTREEITEM _hItem )
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Check if the parent of a deleted data must be deleted",
"WAW_fn_bCheckForEmptyNode",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return FALSE;
WAW_Data * pclData = (WAW_Data*)pclTreeCtrl->GetItemData( _hItem );
if( pclData->m_pri_bIsData || pclTreeCtrl->ItemHasChildren( _hItem ) ) return TRUE;
else return WAW_fn_bDeleteData( pclData );
}
BOOL WAW_fn_bSetDataIcon( WAW_Data * _pclData, HICON _hIcon, HICON _hSelectedIcon )
{
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Associate an icon to a data",
"WAW_fn_bSetDataIcon",
E_ERROR_GRAVITY_WARNING,
"The Data is NULL : operation aborted" );
ERROR_ASSERT( _pclData != NULL );
if( _pclData == NULL ) return FALSE;
ERROR_PREPARE_M( WAW_g_C_csModuleNameForError,
"Associate an icon to a data",
"WAW_fn_bSetDataIcon",
E_ERROR_GRAVITY_INSTABLE,
"The pointer to CTreeCtrl is NULL" );
CTreeCtrl * pclTreeCtrl = WAW_g_pclWatchWindow->m_pub_fn_pclGetTreeCtrl();
ERROR_ASSERT( pclTreeCtrl != NULL );
if( pclTreeCtrl == NULL ) return NULL;
int iIndex = WAW_g_pclImageList->Add( _hIcon );
if( iIndex == -1 )
return FALSE;
int iSelectedIndex = (_hSelectedIcon != NULL ? WAW_g_pclImageList->Add( _hSelectedIcon ) : iIndex );
if( iSelectedIndex == -1 ) return FALSE;
return pclTreeCtrl->SetItemImage( _pclData->m_pri_hTreeItem, iIndex, iSelectedIndex );
}

View File

@@ -0,0 +1,38 @@
#include "StdAfx.h"
#include "WAW_Main.hpp"
#include "WAW_Strg.hpp"
#include "ErO.h"
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
//*** Global variables **************************
// The WAW Module
HMODULE WAW_g_hModule = 0;
extern WAW_MainDialog * WAW_g_pclWatchWindow;
//========================================================================
// Get current CPA version
//========================================================================
void __declspec(dllexport) WAW_fn_vInitModule( HMODULE _hModule )
{
WAW_g_hModule = _hModule;
//Register module for ErO
ERROR_g_fn_vAddAModuleDescriptor( WAW_g_C_csModuleNameForError,
WAW_g_C_csModuleVersion,
"David REIZER",
"01 48 18 53 74 (Montreuil)",
"dreizer@ubisoft.fr",
"Daniel PALIX",
"04 50 51 26 63 (Annecy)",
"dpalix@ubisoft.fr",
"",
"",
"" );
}