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,170 @@
/*
=======================================================================================
Name : ChkData.cpp
Author : vincent lhullier Date :08/09/97
Description : main Application
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#include "SCR.h"
#include "ChkData.h"
#include "ChkDataDlg.h"
#include "IniData.h"
#include "Tree_fct.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
The one and only CChkDataApp object
=======================================================================================
*/
CChkDataApp theApp;
/*
=======================================================================================
CChkDataApp
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : message map
----------------------------------------------------------------------------------------
*/
BEGIN_MESSAGE_MAP(CChkDataApp, CWinApp)
//{{AFX_MSG_MAP(CChkDataApp)
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/*
----------------------------------------------------------------------------------------
Description : constructor
----------------------------------------------------------------------------------------
*/
CChkDataApp::CChkDataApp()
{
}
/*
---------------------------------------------------------------------------------------
call back for wait dialog
---------------------------------------------------------------------------------------
*/
BOOL CALLBACK fn_bWaitDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static UINT uiTimer;
static char cInit;
BOOL bResult;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
switch (uMsg)
{
case WM_INITDIALOG:
SetWindowText(hwndDlg, "Load files infos" );
cInit = 1;
return TRUE;
case WM_SHOWWINDOW:
if (cInit)
{
cInit = 0;
uiTimer = SetTimer( hwndDlg, 1, 100, NULL );
}
break;
case WM_TIMER:
KillTimer( hwndDlg, uiTimer );
bResult = fn_Tree_bBuildFromDisk( &g_p_stRootProject, g_stIniData.szLocalPath, GetDlgItem( hwndDlg, IDC_STATIC_PROJECT ) );
EndDialog( hwndDlg, bResult?1:0 );
break;
}
return FALSE;
}
/*
----------------------------------------------------------------------------------------
Description : CChkDataApp initialization
----------------------------------------------------------------------------------------
*/
BOOL CChkDataApp::InitInstance()
{
// Standard initialization
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
/*
* Init script and memory module
*/
Mmg_fn_vFirstInitMmgModule(1);
SCR_fn_v_RdL0_Init();
SCR_fn_v_Link_InitTable( &g_stSectionTypeLinkTable );
SCR_fn_v_Link_InitTable( &g_stSectionLinkTable );
SCR_fn_v_Link_InitTable( &g_stRefLinkTable );
SCR_fn_v_Link_InitTable( &g_stFileLinkTable );
fn_IniD_vGetAllFromIniFile( TRUE );
fn_IniD_vGetWindowPreference();
int iResult = DialogBox( AfxGetInstanceHandle(), MAKEINTRESOURCE( IDD_DIALOG_WAIT ), ::GetDesktopWindow(), fn_bWaitDialogProc );
if ( iResult != 1)
{
AfxMessageBox("Can't read file and disk information", MB_OK, MB_ICONSTOP );
return FALSE;
}
strcpy( g_p_stRootProject->szName, g_stIniData.szLocalPath + g_stIniData.lRootForSectionLength );
if (_access( g_stIniData.szSectionFile, 0) == 0)
fn_Scr_vLoadSectionTypes();
CChkDataDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
fn_Tree_vFreeFileTypeList();
fn_Tree_vFreeProjectTree( g_p_stRootProject, TRUE );
fn_IniD_vFreeFileList( &g_stIniData.stCheckConfig );
fn_Scr_vFreeSectionTypeList();
SCR_fn_v_Link_CloseTable( &g_stSectionTypeLinkTable );
fn_Scr_vFreeSectionList();
SCR_fn_v_Link_CloseTable( &g_stSectionLinkTable );
SCR_fn_v_Link_CloseTable( &g_stRefLinkTable );
fn_Scr_vFreeLTFile();
SCR_fn_v_Link_CloseTable( &g_stFileLinkTable );
/*
* close memory and script module
*/
SCR_fn_v_RdL0_Close();
Mmg_fn_vStopMmgModule();
return FALSE;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,521 @@
/*
=======================================================================================
Name :IniData.cpp
Author : VL Date :16/07/97
Description :function to get ini data, check this data, write them ...
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#include <io.h>
#include <sys/stat.H>
#include "constant.h"
#include "IniData.h"
#include "Tree_Fct.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
tdstWindowsPref g_stWinPref;
tdstIniData g_stIniData; // data in ini file
tdstIniData g_stDefaultData = // default value for data
{
"X:\\CPA\\Exe\\Main\\Gamedata",
"X:\\CPA\\Exe\\Main\\",
0,
"chkData.log",
"SectType.txt",
0,
{ "CheckFileList", -1, "NoFileListConfig", "", 0, NULL },
{
"GameData\\World\\Graphics\\Textures",
"GameData",
"GameData\\World",
"GameData\\World\\Levels",
"GameData\\World\\Levels\\_Common\\Families",
"GameData\\World\\Levels",
"GameData\\World\\Graphics\\Anims",
"GameData\\World\\Graphics\\Objects\\Classes",
"GameData\\World\\Graphics\\Objects\\Banks",
"GameData\\World\\Libraries\\Mechanics",
"GameData\\World\\Sound",
"GameData\\World\\Graphics\\Visuals",
"GameData\\World\\Libraries\\Materials",
"GameData\\World\\Libraries\\Environment",
"GameData\\SaveGame",
"GameData\\Vignette",
"GameData\\Options",
"GameData\\World\\Levels"
},
18,
{
{g_stIniData.stAvailablePaths.szGraphicsBanks, "GraphicsBanks"},
{g_stIniData.stAvailablePaths.szLevels, "Levels"},
{g_stIniData.stAvailablePaths.szFamilies, "Families"},
{g_stIniData.stAvailablePaths.szTexture, "Texture" } ,
{g_stIniData.stAvailablePaths.szGameData, "GameData"} ,
{g_stIniData.stAvailablePaths.szWorld, "World"},
{g_stIniData.stAvailablePaths.szCharacters, "Characters"},
{g_stIniData.stAvailablePaths.szAnimations, "Animations"},
{g_stIniData.stAvailablePaths.szGraphicsClasses, "GraphicsClasses"},
{g_stIniData.stAvailablePaths.szMechanics, "Mechanics"},
{g_stIniData.stAvailablePaths.szSound, "Sound"},
{g_stIniData.stAvailablePaths.szVisuals, "Visuals"},
{g_stIniData.stAvailablePaths.szMaterials, "Materials"},
{g_stIniData.stAvailablePaths.szEnvironment, "Environment"},
{g_stIniData.stAvailablePaths.szSaveGame, "SaveGame"},
{g_stIniData.stAvailablePaths.szVignettes, "Vignettes"},
{g_stIniData.stAvailablePaths.szOptions, "Options"},
{g_stIniData.stAvailablePaths.szZdx, "Zdx"}
}
};
char g_szIniFile[MAX_PATH];
/*
=======================================================================================
Macros
=======================================================================================
*/
/*
* Macro to bound size of a rect
*/
#define M_vCheckRectSize( _p_stRect, _iMinWidth, _iMinHeight )\
{\
if (_p_stRect->right - _p_stRect->left + 1 < _iMinWidth )\
_p_stRect->right = _p_stRect->left + _iMinWidth ;\
if (_p_stRect->bottom - _p_stRect->top + 1 < _iMinHeight )\
_p_stRect->bottom = _p_stRect->top + _iMinHeight;\
}
/*
=======================================================================================
Functions to manage file list
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : free fileList in Init Data structure
----------------------------------------------------------------------------------------
*/
void fn_IniD_vFreeFileList( tdstFileListConfig *_p_stFileList )
{
int iFile;
if ( _p_stFileList == NULL)
return;
if (_p_stFileList->lNumberOfFiles != 0)
{
for (iFile = 0; iFile < _p_stFileList->lNumberOfFiles; iFile++)
free ( _p_stFileList->d_szFile[iFile] );
free ( _p_stFileList->d_szFile );
_p_stFileList->lNumberOfFiles = 0;
}
}
/*
----------------------------------------------------------------------------------------
Description : write file list config in ini file
----------------------------------------------------------------------------------------
*/
void fn_IniD_vWriteFileList( tdstFileListConfig *_p_stFileList )
{
int iOldFileNumber;
int iFile;
char szString[40];
if (_p_stFileList == NULL)
return;
/* set ini file in RW mode if in ReadOnly mode */
if (_access( g_szIniFile, 2) == -1)
_chmod ( g_szIniFile, _S_IWRITE );
iOldFileNumber = GetPrivateProfileInt( _p_stFileList->szId, "Number", 0, g_szIniFile );
if ( iOldFileNumber == 0 ) // new config
g_stIniData.cNumberOfConfigs++;
WritePrivateProfileString( "Vss", _p_stFileList->szKey, _p_stFileList->szId, g_szIniFile );
WritePrivateProfileString( _p_stFileList->szId, "Name", _p_stFileList->szName, g_szIniFile );
WritePrivateProfileString( _p_stFileList->szId, "Number", itoa( _p_stFileList->lNumberOfFiles, szString, 10 ), g_szIniFile );
for ( iFile = 0; iFile < _p_stFileList->lNumberOfFiles; iFile ++)
{
sprintf( szString, "File%04d", iFile );
WritePrivateProfileString( _p_stFileList->szId, szString, _p_stFileList->d_szFile[iFile], g_szIniFile );
}
for ( ;iFile < iOldFileNumber; iFile ++)
{
sprintf( szString, "File%04d", iFile );
WritePrivateProfileString( _p_stFileList->szId, szString, NULL, g_szIniFile );
}
}
/*
----------------------------------------------------------------------------------------
Description : get file list config from ini file
----------------------------------------------------------------------------------------
*/
BOOL fn_IniD_bGetFileList( tdstFileListConfig *_p_stFileList, char _cConfig )
{
long lNbFiles;
int iFile;
int iDeleteFile;
char szKey[10];
char **d_szFileName;
if (_p_stFileList == NULL)
return FALSE;
if ( (_cConfig < 0) || (_cConfig >= g_stIniData.cNumberOfConfigs) )
return FALSE;
sprintf( _p_stFileList->szId, "FileList-Config%02d", _cConfig );
/* get config name */
GetPrivateProfileString( _p_stFileList->szId, "Name", "No name", _p_stFileList->szName, 40, g_szIniFile);
/* get number of file */
lNbFiles = GetPrivateProfileInt( _p_stFileList->szId, "Number", 0, g_szIniFile);
if (lNbFiles == 0)
return FALSE;
/* allocate memory for pointer to file names */
d_szFileName = (char **) malloc ( lNbFiles * sizeof( char *) );
/* get each file name */
for (iFile = 0; iFile < lNbFiles; iFile ++)
{
d_szFileName[iFile] = (char *) malloc( _MAX_PATH );
sprintf( szKey, "File%04d", iFile );
GetPrivateProfileString( _p_stFileList->szId, szKey, "Error", d_szFileName[iFile], MAX_PATH, g_szIniFile );
if (strcmp( d_szFileName[iFile], "Error") == 0)
{
for (iDeleteFile = 0; iDeleteFile <= iFile; iDeleteFile ++)
free ( d_szFileName[iDeleteFile] );
free (d_szFileName);
return FALSE;
}
}
/* update ini data */
fn_IniD_vFreeFileList( _p_stFileList );
_p_stFileList->lNumberOfFiles = lNbFiles;
_p_stFileList->d_szFile = d_szFileName;
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Set file list to default value
----------------------------------------------------------------------------------------
*/
void fn_IniD_vSetSingleFileList( tdstFileListConfig *_p_stFileList, char *_szFileName )
{
if ( _p_stFileList == NULL )
return;
fn_IniD_vFreeFileList( _p_stFileList );
_p_stFileList->lNumberOfFiles = 1;
_p_stFileList->d_szFile = (char **) malloc( sizeof( char *) );
_p_stFileList->d_szFile[0] = (char *) malloc( MAX_PATH );
sprintf( _p_stFileList->d_szFile[0], "-R %s", _szFileName );
}
/*
----------------------------------------------------------------------------------------
Description : get index of a config from id of the config
_szId -> string id of config
Returns (char ) index of config (-1 if not a valid string id
----------------------------------------------------------------------------------------
*/
char fn_IniD_cGetIndexFromId( char *_szId )
{
if ( strlen( _szId ) != 17 )
return -1;
if ( strncmp( _szId, "FileList-Config", 15 ) != 0)
return -1;
if ( !isdigit( _szId[15] ) || !isdigit( _szId[16] ) )
return -1;
return (_szId[15] - '0') * 10 + (_szId[16] - '0');
}
/*
----------------------------------------------------------------------------------------
get number of file list config
----------------------------------------------------------------------------------------
*/
char fn_IniD_cGetNumberOfConfig( void )
{
return g_stIniData.cNumberOfConfigs;
}
/*
----------------------------------------------------------------------------------------
get name of a config
----------------------------------------------------------------------------------------
*/
void fn_IniD_vGetConfigName( char _cConfig, char *_szName )
{
char szConfigId[20];
sprintf( szConfigId, "FileList-Config%02d", _cConfig );
GetPrivateProfileString( szConfigId, "Name", "Error", _szName, 40, g_szIniFile );
}
/*
=======================================================================================
function to get/set single initial data
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Get extensions status
----------------------------------------------------------------------------------------
*/
BOOL fn_IniD_bGetFileTypeConsiderStatus( char *_szExt )
{
int iResult;
iResult = GetPrivateProfileInt( "FileType", _szExt, 1, g_szIniFile );
return (iResult == 1);
}
/*
----------------------------------------------------------------------------------------
Set extensions status
----------------------------------------------------------------------------------------
*/
void fn_IniD_vSetFileTypeConsiderStatus( char *_szExt, BOOL _bConsider )
{
/* set ini file in RW mode if in ReadOnly mode */
if (_access( g_szIniFile, 2) == -1)
_chmod ( g_szIniFile, _S_IWRITE );
WritePrivateProfileString( "FileType", _szExt, _bConsider ? "1" : "0", g_szIniFile );
}
/*
----------------------------------------------------------------------------------------
set local path in ini file
----------------------------------------------------------------------------------------
*/
void fn_IniD_vSetLocalPath( char *_szPath )
{
/* set ini file in RW mode if in ReadOnly mode */
if (_access( g_szIniFile, 2) == -1)
_chmod ( g_szIniFile, _S_IWRITE );
WritePrivateProfileString( "Local", "DataRootPath", _szPath, g_szIniFile );
}
/*
----------------------------------------------------------------------------------------
set result file name
----------------------------------------------------------------------------------------
*/
void fn_IniD_vSetModifListFile( char *_szFileName )
{
/* set ini file in RW mode if in ReadOnly mode */
if (_access( g_szIniFile, 2) == -1)
_chmod ( g_szIniFile, _S_IWRITE );
WritePrivateProfileString( "Result", "File", _szFileName, g_szIniFile );
}
/*
----------------------------------------------------------------------------------------
Analyse string that describe a rect
----------------------------------------------------------------------------------------
*/
void fn_IniD_vAnalyseRectData( char *_szString, RECT *_p_stRect )
{
char *p_szValue[5], *p_szEnd;
char cVal;
memset( _p_stRect, 0, sizeof( RECT ) );
if ( (p_szValue[0] = strchr(_szString, '(' )) == NULL)
return;
if ( (p_szValue[1] = strchr (++p_szValue[0], ',')) == NULL)
return;
if ( (p_szValue[2] = strchr (++p_szValue[1], ',')) == NULL)
return;
if ( (p_szValue[3] = strchr (++p_szValue[2], ',')) == NULL)
return;
p_szValue[3] ++;
p_szValue[4] = _szString + strlen( _szString );
for (cVal = 0; cVal < 4; cVal ++)
{
while ( !isdigit(*p_szValue[cVal]) )
{
if (p_szValue[cVal] == p_szValue[cVal+1])
return;
p_szValue[cVal]++;
}
p_szEnd = p_szValue[cVal] + 1;
while ( isdigit(*p_szEnd))
{
if (p_szEnd == p_szValue[cVal+1])
return;
p_szEnd++;
}
*p_szEnd = 0;
}
_p_stRect->left = atoi( p_szValue[0] );
_p_stRect->top = atoi( p_szValue[1] );
_p_stRect->right = atoi( p_szValue[2] );
_p_stRect->bottom = atoi( p_szValue[3] );
}
/*
=======================================================================================
function for windows preference data
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : get position and size of windows
----------------------------------------------------------------------------------------
*/
void fn_IniD_vGetWindowPreference( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char szString[100];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* main window */
GetPrivateProfileString( "WinPref", "Main", "", szString, 100, g_szIniFile );
fn_IniD_vAnalyseRectData( szString, &g_stWinPref.stMainPos );
M_vCheckRectSize( (&g_stWinPref.stMainPos), C_iMainMinWidth, C_iMainMinHeight );
}
/*
----------------------------------------------------------------------------------------
Description : write position and size of windows
----------------------------------------------------------------------------------------
*/
void fn_IniD_vWriteWindowPreference( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char szValue[50];
RECT *p_stRect;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* set ini file in RW mode if in ReadOnly mode */
if (_access( g_szIniFile, 2) == -1)
_chmod ( g_szIniFile, _S_IWRITE );
/* main window */
p_stRect = &g_stWinPref.stMainPos;
sprintf( szValue, "(%4d,%4d,%4d,%4d)", p_stRect->left, p_stRect->top, p_stRect->right, p_stRect->bottom );
WritePrivateProfileString( "WinPref", "Main ", szValue, g_szIniFile );
}
/*
*=======================================================================================
* function for all initial data
*=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
transform ini file to keep file compatible
----------------------------------------------------------------------------------------
*/
void fn_IniD_vTransformIniFileToBeCompatible( void )
{
}
/*
----------------------------------------------------------------------------------------
Description : read ini data to fill inidata structure
and set additional ini data
_bFirst -> indicate that it's the first initialisation
----------------------------------------------------------------------------------------
*/
void fn_IniD_vGetAllFromIniFile( BOOL _bFirst )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char szConfigId[20];
char szConfigName[40];
tdstFileListConfig *p_stConfig;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (_bFirst)
{
/*
* transform eventually ini file
*/
fn_IniD_vTransformIniFileToBeCompatible();
/*
* Build ini file
*/
GetCurrentDirectory( MAX_PATH, g_szIniFile );
if (g_szIniFile[strlen(g_szIniFile) - 1] != '\\')
strcat( g_szIniFile, "\\");
strcat( g_szIniFile, C_szIniFile );
memcpy ( &g_stIniData, &g_stDefaultData, sizeof( tdstIniData ) );
memset ( &g_stWinPref, 0, sizeof( tdstWindowsPref ) );
fn_IniD_vGetWindowPreference();
/* retrieve number of config */
g_stIniData.cNumberOfConfigs = 0;
while (1)
{
sprintf( szConfigId, "FileList-Config%02d", g_stIniData.cNumberOfConfigs);
GetPrivateProfileString( szConfigId, "Name", "Error", szConfigName, 40, g_szIniFile );
if (strcmp(szConfigName, "Error") == 0)
break;
g_stIniData.cNumberOfConfigs++;
}
}
GetPrivateProfileString( "Local", "DataRootPath", g_stDefaultData.szLocalPath, g_stIniData.szLocalPath, MAX_PATH, g_szIniFile );
GetPrivateProfileString( "Local", "RootForSection", g_stDefaultData.szRootForSection, g_stIniData.szRootForSection, MAX_PATH, g_szIniFile );
g_stIniData.lRootForSectionLength = strlen( g_stIniData.szRootForSection );
GetPrivateProfileString( "Result", "File", g_stDefaultData.szResultFile, g_stIniData.szResultFile, MAX_PATH, g_szIniFile );
/*
* get check file list Id
*/
p_stConfig = &g_stIniData.stCheckConfig;
GetPrivateProfileString( "Vss", p_stConfig->szKey, g_stDefaultData.stCheckConfig.szId, p_stConfig->szId, 20, g_szIniFile );
p_stConfig->cIndex = fn_IniD_cGetIndexFromId( p_stConfig->szId );
if (p_stConfig->cIndex != -1)
fn_IniD_bGetFileList( p_stConfig, p_stConfig->cIndex );
else
fn_IniD_vSetSingleFileList( p_stConfig, g_stIniData.szLocalPath + g_stIniData.lRootForSectionLength );
}

View File

@@ -0,0 +1,298 @@
/*
=======================================================================================
Name :progbar.cpp
Author :Vincent Lhullier Date :15/07/97
Description :A beautiful progress bar
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#include "progbar.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
CMyProgressBar implementation
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : constructor
----------------------------------------------------------------------------------------
*/
CMyProgressBar::CMyProgressBar()
{
m_bInit = FALSE;
}
/*
----------------------------------------------------------------------------------------
Description : destructor
----------------------------------------------------------------------------------------
*/
CMyProgressBar::~CMyProgressBar()
{
}
/*
----------------------------------------------------------------------------------------
Description : message map
----------------------------------------------------------------------------------------
*/
BEGIN_MESSAGE_MAP(CMyProgressBar, CProgressCtrl)
//{{AFX_MSG_MAP(CMyProgressBar)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*
=======================================================================================
CMyProgressBar message handlers
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : WM_PAINT Message
----------------------------------------------------------------------------------------
*/
void CMyProgressBar::OnPaint()
{
RECT stWinRect;
RECT stDrawRect;
int iCol;
// char szPercent[5];
CPaintDC dc(this); // device context for painting
GetClientRect( &stWinRect );
stDrawRect = stWinRect;
iCol = (stDrawRect.right * OffsetPos(0)) / (m_iEnd - m_iStart + 1);
if ( iCol > 256 )
{
stDrawRect.right = iCol - 257;
dc.FillSolidRect( &stDrawRect, m_xForegroundColor );
dc.BitBlt( iCol - 256, 0, 256, stDrawRect.bottom, &m_oDC, 0, 0, SRCCOPY );
}
else
{
dc.BitBlt( 0, 0, iCol, stDrawRect.bottom, &m_oDC, 256 - iCol, 0, SRCCOPY );
}
if ( m_cNumberOfFrames )
{
dc.BitBlt( iCol - m_cFrameWidth, 0, m_cFrameWidth, stDrawRect.bottom, &m_oAnimDC, m_cCurrentFrame * m_cFrameWidth, 0, SRCINVERT );
m_cCurrentFrame = (m_cCurrentFrame + 1) % m_cNumberOfFrames;
}
stDrawRect.left = iCol + 1;
stDrawRect.right = stWinRect.right;
dc.FillSolidRect( &stDrawRect, m_xBackgroundColor );
/*
itoa( (100 * OffsetPos(0)) / (m_iEnd - m_iStart + 1), szPercent, 10 );
strcat( szPercent, "%" );
dc.DrawState ( CPoint( stWinRect.right / 2 - 32, 0), CSize( 64, 16), (LPCTSTR) szPercent, DST_TEXT , TRUE, 0, (HBRUSH) NULL );
dc.DrawState ( CPoint( stWinRect.right / 2 + 32, 0), CSize( 64, 16), (LPCTSTR) szPercent, DST_TEXT | DSS_MONO, TRUE, 0, (HBRUSH) NULL );
dc.DrawState ( CPoint( stWinRect.right / 2 - 96, 0), CSize( 64, 16), (LPCTSTR) szPercent, DST_TEXT | DSS_NORMAL, TRUE, 0, (HBRUSH) NULL );
dc.DrawState ( CPoint( stWinRect.right / 2 + 96, 0), CSize( 64, 16), (LPCTSTR) szPercent, DST_TEXT | DSS_UNION, TRUE, 0, (HBRUSH) NULL );
*/
}
/*
=======================================================================================
Specific functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : set range of progression
_iStart -> beginning value
_iEnd -> end value
----------------------------------------------------------------------------------------
*/
void CMyProgressBar::m_fn_vSetRange( int _iStart, int _iEnd )
{
m_iStart = _iStart;
m_iEnd = _iEnd;
SetRange( _iStart, _iEnd );
}
/*
----------------------------------------------------------------------------------------
Description : initialize DC and bitmap to draw
----------------------------------------------------------------------------------------
*/
void CMyProgressBar::m_fn_vInitDC( void )
{
if (!m_bInit)
{
RECT stRect;
GetClientRect( &stRect );
m_oDC.CreateCompatibleDC( GetDC() );
m_oBitmap.CreateCompatibleBitmap( GetDC() , 256, stRect.bottom );
m_oDC.SelectObject( &m_oBitmap );
m_oAnimDC.CreateCompatibleDC( GetDC() );
m_oAnimBitmap.CreateCompatibleBitmap( GetDC() , 256, stRect.bottom );
m_oAnimDC.SelectObject( &m_oBitmap );
m_cNumberOfFrames = 0;
m_bInit = TRUE;
}
}
/*
----------------------------------------------------------------------------------------
Description : set position of progression to beginning value, change drawing type
----------------------------------------------------------------------------------------
*/
void CMyProgressBar::m_fn_vReinit( void )
{
SetPos( m_iStart );
}
/*
=======================================================================================
function to prepare drawing
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : colored bar with random color value
_xBackground -> background color
----------------------------------------------------------------------------------------
*/
void CMyProgressBar::m_fn_vInitDrawing( COLORREF _xBackground )
{
char cColor;
int a_iColor[3];
srand( (unsigned) time ( NULL ) );
for (cColor = 0; cColor < 3; cColor ++ )
{
a_iColor[ cColor ] = (rand() % 3) - 2;
if (a_iColor[ cColor ] == 0)
a_iColor[ cColor ] = rand() & 0xFF;
}
m_fn_vInitDrawing( a_iColor[0], a_iColor[1], a_iColor[2], _xBackground );
}
/*
----------------------------------------------------------------------------------------
Description : colored bar with given color
_iRed -> red value (-2 = increasing, -1 = decreasing)
_iGreen -> green value
_iBlue -> blue value
_xBackground -> background color
----------------------------------------------------------------------------------------
*/
void CMyProgressBar::m_fn_vInitDrawing( int _iRed, int _iGreen, int _iBlue, COLORREF _xBackground )
{
char cColor;
int iColor;
unsigned char ucColor[3];
int a_iColor[3];
RECT stRect;
a_iColor[0] = _iRed;
a_iColor[1] = _iGreen;
a_iColor[2] = _iBlue;
m_fn_vInitDC();
for (cColor = 0; cColor < 3; cColor ++ )
{
if (a_iColor[ cColor ] == -2)
ucColor[ cColor ] = (unsigned char) 0xFF;
else if (a_iColor[ cColor ] == -1)
ucColor[ cColor ] = (unsigned char) 0x7F;
else
ucColor[ cColor ] = (unsigned char) a_iColor[ cColor ];
}
m_xBackgroundColor = _xBackground;
m_xForegroundColor = RGB( ucColor[0], ucColor[1], ucColor[2] );
GetClientRect( &stRect );
stRect.left = 0;
stRect.right = 2;
for (iColor = 0; iColor < 128; iColor ++)
{
m_oDC.FillSolidRect( &stRect, RGB( ucColor[0], ucColor[1], ucColor[2] ) );
for (cColor = 0; cColor < 3; cColor++)
{
if (a_iColor[ cColor ] == -2)
ucColor[ cColor ]--;
else if (a_iColor[ cColor ] == -1)
ucColor[ cColor ]++;
}
stRect.left += 2;
stRect.right += 2;
}
}
/*
----------------------------------------------------------------------------------------
Description : draw a bitmap
uiBitmap -> id of bimap
_xForeground -> foreground color
_xBackground -> background color
----------------------------------------------------------------------------------------
*/
void CMyProgressBar::m_fn_vInitDrawing( UINT _uiBitmap, COLORREF _xForeground, COLORREF _xBackground )
{
m_fn_vInitDC();
m_oBitmap.DeleteObject();
m_oBitmap.LoadBitmap( _uiBitmap );
m_oDC.SelectObject( &m_oBitmap );
m_xBackgroundColor = _xBackground;
m_xForegroundColor = _xForeground;
}
void CMyProgressBar::m_fn_vInitAnim( UINT _uiBitmap, char _cFrame, char _cFrameWidth )
{
if ( (m_cNumberOfFrames = _cFrame) == 0)
return;
m_cFrameWidth = _cFrameWidth;
m_fn_vInitDC();
m_oAnimBitmap.DeleteObject();
m_oAnimBitmap.LoadBitmap( _uiBitmap );
m_oAnimDC.SelectObject( &m_oAnimBitmap );
m_cCurrentFrame = 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
/*
=======================================================================================
Name : SpecRef.cpp
Author : vincent lhullier Date :10/09/97
Description : functions to transform special references
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#include "SpecRef.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
globals
=======================================================================================
*/
tdstSpecialReference g_a_stSpecialRef[ C_lNumberOfSpecialRefs ] =
{
{ "PHY", "CS", 0, fn_vTransformCSRef }
};
/*
=======================================================================================
functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : called for a special reference
_szSectionType -> section type
_szEntryName -> entry name
_cParam -> parameter index
_szRef -> reference to transform
----------------------------------------------------------------------------------------
*/
void fn_SpRef_vTransformSpecialRef( char *_szSectionType, char *_szEntryName, char _cParam, char *_szRef )
{
char cSpecialRef;
tdstSpecialReference *p_stRef = g_a_stSpecialRef;
for (cSpecialRef = 0; cSpecialRef < C_lNumberOfSpecialRefs; cSpecialRef++, p_stRef++ )
{
if
(
( stricmp( _szSectionType, p_stRef->szSectionType) == 0)
&& ( stricmp( _szEntryName, p_stRef->szEntry ) == 0)
&& ( _cParam == p_stRef->cParam )
)
{
p_stRef->pfn_vTransform( _szRef );
return;
}
}
}
/*
----------------------------------------------------------------------------------------
Description : transform bad CS reference from
<filename>^CS:<name> to <filename>^AllCollideSets^CS:<Name>
_szRef -> bad reference : <filename>
----------------------------------------------------------------------------------------
*/
void fn_vTransformCSRef( char *_szRef )
{
char szEnd[ 100 ];
char *szSectionName;
if ((szSectionName = strchr( _szRef, '^' )) == NULL)
return;
szSectionName++;
if ( strnicmp( szSectionName, "CS", 2 ) == 0)
{
strcpy( szEnd, szSectionName );
strcpy( szSectionName, "AllCollideSets^" );
strcat( szSectionName, szEnd );
}
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

View File

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

View File

@@ -0,0 +1,859 @@
/*
=======================================================================================
Name : VssFunct.cpp
Author : vincent lhullier Date :27/07/97
Description : Manage vss tree, file of list to obtain
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#include <io.h>
#include "Tree_Fct.h"
#include "IniData.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
GLOBALS
=======================================================================================
*/
tdstProject *g_p_stRootProject = NULL;
char g_szFullName[MAX_PATH];
char **gs_d_szFile;
char **gs_d_szProj;
/*
* globals for list of extension
*/
long g_lNumberOfFileTypes = 0;
long g_lNumberMaxOfFileTypes = 0;
tdstFileType *g_d_stFileType = NULL;
HWND g_hProjectWindow;
/*
=======================================================================================
File type functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : free list of file type
----------------------------------------------------------------------------------------
*/
void fn_Tree_vFreeFileTypeList( void )
{
if (g_lNumberMaxOfFileTypes != 0)
{
free ( g_d_stFileType );
g_d_stFileType = NULL;
g_lNumberOfFileTypes = 0;
g_lNumberMaxOfFileTypes = 0;
}
}
/*
----------------------------------------------------------------------------------------
Description : search if a file type is in list or not
----------------------------------------------------------------------------------------
*/
tdstFileType *fn_Tree_p_stIsAFileType( char *_szFileType )
{
long lFileType;
tdstFileType *p_stFT = g_d_stFileType;
for (lFileType = 0; lFileType < g_lNumberOfFileTypes; lFileType++, p_stFT++ )
{
if (stricmp( p_stFT->szExt, _szFileType) == 0)
return p_stFT;
}
return NULL;
}
/*
----------------------------------------------------------------------------------------
Description : add a file type in list
----------------------------------------------------------------------------------------
*/
tdstFileType *fn_Tree_p_stAddFileType( char *_szFileType )
{
tdstFileType *p_stFT;
char *p_szExt;
if ( (p_stFT = fn_Tree_p_stIsAFileType( _szFileType )) != NULL)
return p_stFT;
if (g_lNumberOfFileTypes == g_lNumberMaxOfFileTypes )
{
g_lNumberMaxOfFileTypes += 50;
if (g_lNumberMaxOfFileTypes == 50)
{
g_d_stFileType = (tdstFileType *) malloc (g_lNumberMaxOfFileTypes * sizeof( tdstFileType ) );
}
else
{
g_d_stFileType = (tdstFileType *) realloc( g_d_stFileType, g_lNumberMaxOfFileTypes * sizeof( tdstFileType ) );
}
}
p_stFT = &g_d_stFileType[ g_lNumberOfFileTypes++ ];
p_szExt = p_stFT->szExt;
while (*_szFileType != 0)
*p_szExt++ = tolower( *_szFileType++ );
*p_szExt = 0;
p_stFT->lUsed = 0;
p_stFT->bConsider = fn_IniD_bGetFileTypeConsiderStatus( p_stFT->szExt );
return p_stFT;
}
/*
----------------------------------------------------------------------------------------
Description : add the type of given file in list and increase used count of file type
----------------------------------------------------------------------------------------
*/
void fn_Tree_vAddFileTypeFromFile( char *_szFile )
{
char *szExt;
tdstFileType *p_stFT;
if ( (szExt = strrchr(_szFile, '.')) == NULL)
szExt = _szFile + strlen( _szFile );
else
szExt++;
p_stFT = fn_Tree_p_stAddFileType( szExt );
p_stFT->lUsed++;
}
/*
----------------------------------------------------------------------------------------
Description : get file type of a given file
_szFileName -> file name
Returns (tdstFileType ) file type
----------------------------------------------------------------------------------------
*/
tdstFileType *fn_Tree_p_stGetFileFileType( char *_szFileName )
{
char *szExt;
if ( (szExt = strrchr(_szFileName, '.')) == NULL)
szExt = _szFileName + strlen( _szFileName );
else
szExt++;
return fn_Tree_p_stIsAFileType( szExt );
}
/*
----------------------------------------------------------------------------------------
Description : return bConsider flag of extension of given file
_szFile -> file name
Returns (BOOL ) bConsider flag of extension
----------------------------------------------------------------------------------------
*/
BOOL fn_Tree_bConsiderFile( char *_szFile )
{
tdstFileType *p_stFT;
p_stFT = fn_Tree_p_stGetFileFileType( _szFile );
if (p_stFT == NULL)
return FALSE;
return p_stFT->bConsider;
}
/*
=======================================================================================
TREE FUNCTIONS
=======================================================================================
*/
/*
---------------------------------------------------------------------------------------
fill a tdstProject structure with name and describing an empty project
---------------------------------------------------------------------------------------
*/
void fn_Tree_vInitProject( tdstProject *_p_stProj, char *_szName )
{
_p_stProj->szName = (char *) malloc( strlen(_szName) + 1 );
strcpy( _p_stProj->szName, _szName );
_p_stProj->bGet = FALSE;
_p_stProj->bRecurse = FALSE;
_p_stProj->lNumberOfSubProjects = 0;
_p_stProj->d_stSubProject = NULL;
_p_stProj->lNumberOfFiles = 0;
_p_stProj->d_stFile = NULL;
}
/*
---------------------------------------------------------------------------------------
fill a tdstProject structure with pointer name and describing an empty project
---------------------------------------------------------------------------------------
*/
void fn_Tree_vInitProjectWithPointerName( tdstProject *_p_stProj, char *_szName )
{
_p_stProj->szName = _szName;
_p_stProj->bGet = FALSE;
_p_stProj->bRecurse = FALSE;
_p_stProj->lNumberOfSubProjects = 0;
_p_stProj->d_stSubProject = NULL;
_p_stProj->lNumberOfFiles = 0;
_p_stProj->d_stFile = NULL;
}
/*
---------------------------------------------------------------------------------------
fill a tdstFile structure with name
---------------------------------------------------------------------------------------
*/
void fn_Tree_vInitFile( tdstFile *_p_stFile, char *_szName )
{
_p_stFile->szName = (char *) malloc( strlen(_szName) + 1 );
strcpy( _p_stFile->szName, _szName );
_p_stFile->bGet = FALSE;
}
/*
---------------------------------------------------------------------------------------
fill a tdstFile structure with pointer name
---------------------------------------------------------------------------------------
*/
void fn_Tree_vInitFileWithPointerName( tdstFile *_p_stFile, char *_szName )
{
_p_stFile->szName = _szName;
_p_stFile->bGet = FALSE;
}
/*
---------------------------------------------------------------------------------------
retrieve a subproject
---------------------------------------------------------------------------------------
*/
tdstProject *fn_Tree_p_stGetProject( tdstProject *_p_stInProj, char *_szName )
{
char *p_cCur;
char *p_cNext;
tdstProject *p_stCurProj;
long lSubProj;
if (_p_stInProj == NULL)
return NULL;
p_cCur = _szName;
while (1)
{
p_cCur = strchr( p_cCur, '/' );
if (p_cCur == NULL)
break;
*p_cCur = '\\';
}
if ( strnicmp( _szName, _p_stInProj->szName, strlen( _p_stInProj->szName )) != 0)
return NULL;
p_cCur = _szName + strlen( _p_stInProj->szName );
p_stCurProj = _p_stInProj;
while (*p_cCur != 0)
{
p_cCur ++;
p_cNext = strchr(p_cCur, '\\');
if (p_cNext != NULL) *p_cNext = 0;
for (lSubProj = 0; lSubProj < p_stCurProj->lNumberOfSubProjects; lSubProj++)
{
if (stricmp( p_stCurProj->d_stSubProject[lSubProj].szName, p_cCur) == 0)
break;
}
if (lSubProj == p_stCurProj->lNumberOfSubProjects)
return NULL;
p_stCurProj = &p_stCurProj->d_stSubProject[lSubProj];
p_cCur += strlen( p_cCur );
if (p_cNext != NULL) *p_cNext = '\\';
}
return p_stCurProj;
}
/*
---------------------------------------------------------------------------------------
retrieve a file with name
---------------------------------------------------------------------------------------
*/
tdstFile *fn_Tree_p_stGetFile( tdstProject *_p_stInProj, char *_szName )
{
tdstProject *p_stProj;
tdstFile *p_stFile;
char *p_szShortName;
long lFile = 0;
p_szShortName = strrchr( _szName, '\\' );
*p_szShortName++ = 0;
p_stProj = fn_Tree_p_stGetProject( _p_stInProj, _szName );
*(p_szShortName - 1) = '\\';
if ( p_stProj == NULL)
return NULL;
for ( p_stFile = p_stProj->d_stFile; lFile < p_stProj->lNumberOfFiles; lFile++, p_stFile ++)
{
if (stricmp( p_szShortName, p_stFile->szName) == 0)
return p_stFile;
}
return NULL;
}
/*
---------------------------------------------------------------------------------------
free a project information
---------------------------------------------------------------------------------------
*/
void fn_Tree_vFreeProject( tdstProject *_p_stProj, BOOL _bDelete )
{
long lIndex;
/* free files */
if (_p_stProj == NULL)
return;
if (_p_stProj->d_stFile)
{
for (lIndex = 0; lIndex < _p_stProj->lNumberOfFiles; lIndex ++)
free ( _p_stProj->d_stFile[lIndex].szName );
free (_p_stProj->d_stFile );
_p_stProj->d_stFile = NULL;
_p_stProj->lNumberOfFiles = 0;
}
/* free sub project */
if (_p_stProj->d_stSubProject )
{
for (lIndex = 0; lIndex < _p_stProj->lNumberOfSubProjects; lIndex ++)
fn_Tree_vFreeProject( &_p_stProj->d_stSubProject[lIndex], TRUE );
free (_p_stProj->d_stSubProject );
_p_stProj->d_stSubProject = NULL;
_p_stProj->lNumberOfSubProjects = 0;
}
/* free project */
if (_bDelete)
free ( _p_stProj->szName );
}
/*
---------------------------------------------------------------------------------------
free a project information tree
---------------------------------------------------------------------------------------
*/
void fn_Tree_vFreeProjectTree( tdstProject *_p_stProj, BOOL _bDelete )
{
fn_Tree_vFreeProject( _p_stProj, _bDelete );
if (_bDelete)
{
free ( _p_stProj );
_p_stProj = NULL;
}
}
/*
----------------------------------------------------------------------------------------
Description : free list of file in a vss project structure
----------------------------------------------------------------------------------------
*/
void fn_Tree_vFreeProjectFileList( tdstProject *_p_stProj )
{
long lIndex;
if (_p_stProj->d_stFile)
{
for (lIndex = 0; lIndex < _p_stProj->lNumberOfFiles; lIndex ++)
free ( _p_stProj->d_stFile[lIndex].szName );
free (_p_stProj->d_stFile );
_p_stProj->d_stFile = NULL;
_p_stProj->lNumberOfFiles = 0;
}
}
/*
---------------------------------------------------------------------------------------
set all vss project to not obtain
---------------------------------------------------------------------------------------
*/
void fn_Tree_vGetNothing( tdstProject *_p_stProj)
{
long lSubProj;
long lFile = 0;
tdstFile *p_stFile = _p_stProj->d_stFile;
/*
* dont obtain current project
*/
_p_stProj->bGet = FALSE;
_p_stProj->bRecurse = FALSE;
/*
* dont obtain files
*/
for (; lFile < _p_stProj->lNumberOfFiles; lFile++, p_stFile ++)
{
p_stFile->bGet = FALSE;
}
/*
* dont obtain sub project
*/
for (lSubProj = 0; lSubProj < _p_stProj->lNumberOfSubProjects; lSubProj ++)
fn_Tree_vGetNothing( &_p_stProj->d_stSubProject[lSubProj] );
}
/*
---------------------------------------------------------------------------------------
refresh obtaining state for vss tree
---------------------------------------------------------------------------------------
*/
void fn_Tree_vRefreshWithFileList( tdstProject *_p_stProj, tdstFileListConfig *_p_stFileList )
{
int iFile;
char *szFileName;
tdstProject *p_stSubProj;
tdstFile *p_stFile;
BOOL bRecurse;
BOOL bFile;
fn_Tree_vGetNothing( _p_stProj );
for (iFile = 0; iFile < _p_stFileList->lNumberOfFiles; iFile ++)
{
szFileName = _p_stFileList->d_szFile[iFile];
if (*szFileName == '-')
{
switch( *(szFileName + 1) )
{
case 'R':
bRecurse = TRUE;
bFile = FALSE;
break;
case 'P':
bRecurse = FALSE;
bFile = FALSE;
break;
default:
bRecurse = FALSE;
bFile = FALSE;
}
szFileName += 3;
}
else
{
bRecurse = FALSE;
bFile = TRUE;
}
if (bFile)
{
if ( (p_stFile = fn_Tree_p_stGetFile( _p_stProj, szFileName ) ) != NULL)
p_stFile->bGet = TRUE;
}
else
{
if ( (p_stSubProj = fn_Tree_p_stGetProject( _p_stProj, szFileName ) ) != NULL)
{
p_stSubProj->bGet = TRUE;
p_stSubProj->bRecurse = bRecurse;
}
}
}
}
/*
---------------------------------------------------------------------------------------
count recursively number of file to get all folder name the user want to obtain
---------------------------------------------------------------------------------------
*/
void fn_Tree_vGetNumberOfFilesOrProjectsToGet( tdstProject *_p_stProj, long *_p_lNbFiles )
{
long lSubProj;
long lFile;
tdstFile *p_stFile;
if (_p_stProj->bGet)
{
(*_p_lNbFiles)++;
if (_p_stProj->bRecurse)
return;
}
else
{
for (lFile = 0, p_stFile = _p_stProj->d_stFile; lFile < _p_stProj->lNumberOfFiles; lFile++, p_stFile++ )
if (p_stFile->bGet)
(*_p_lNbFiles) ++;
}
for (lSubProj = 0; lSubProj < _p_stProj->lNumberOfSubProjects; lSubProj ++)
fn_Tree_vGetNumberOfFilesOrProjectsToGet( &_p_stProj->d_stSubProject[lSubProj], _p_lNbFiles );
}
/*
---------------------------------------------------------------------------------------
write recursively file to obtain in given array of string
---------------------------------------------------------------------------------------
*/
void fn_Tree_vGetFilesOrProjectToGet( tdstProject *_p_stProj, long *_p_lNbFiles, char **_d_szFile )
{
long lSubProj;
long lFile;
tdstFile *p_stFile;
if (_p_stProj->bGet)
{
strcpy ( _d_szFile[ *_p_lNbFiles ], (_p_stProj->bRecurse)?"-R ":"-P");
strcat( _d_szFile[ (*_p_lNbFiles)++ ], g_szFullName );
if (_p_stProj->bRecurse)
return;
}
else
{
for (lFile = 0, p_stFile = _p_stProj->d_stFile; lFile < _p_stProj->lNumberOfFiles; lFile++, p_stFile++ )
if (p_stFile->bGet)
sprintf(_d_szFile[ (*_p_lNbFiles)++ ], "%s\\%s", g_szFullName, p_stFile->szName );
}
for (lSubProj = 0; lSubProj < _p_stProj->lNumberOfSubProjects; lSubProj ++)
{
strcat( g_szFullName, "\\");
strcat( g_szFullName, _p_stProj->d_stSubProject[lSubProj].szName );
fn_Tree_vGetFilesOrProjectToGet( &_p_stProj->d_stSubProject[lSubProj], _p_lNbFiles, _d_szFile );
*strrchr( g_szFullName, '\\' ) = 0;
}
}
/*
---------------------------------------------------------------------------------------
count recursively all files to obtain (not project)
---------------------------------------------------------------------------------------
*/
void fn_Tree_vGetNumberOfFilesToGet( tdstProject *_p_stProj, long *_p_lNbFiles, BOOL _bAll )
{
long lFile = 0;
tdstProject *p_stSubProj = _p_stProj->d_stSubProject;
tdstFile *p_stFile = _p_stProj->d_stFile;
/*
* add number of obtained file in current project
*/
if (_p_stProj->bGet || _bAll)
(*_p_lNbFiles) += _p_stProj->lNumberOfFiles;
else
{
for ( ; lFile < _p_stProj->lNumberOfFiles; p_stFile++, lFile++ )
if (p_stFile->bGet)
(*_p_lNbFiles)++;
}
/*
* call recursively function for each sub project
*/
for (lFile = 0; lFile < _p_stProj->lNumberOfSubProjects; lFile++, p_stSubProj++)
{
fn_Tree_vGetNumberOfFilesToGet( p_stSubProj, _p_lNbFiles, (_p_stProj->bRecurse) || _bAll );
}
}
/*
---------------------------------------------------------------------------------------
write recursively file to obtain (no project) in given array of string
---------------------------------------------------------------------------------------
*/
void fn_Tree_vGetFilesToGet( tdstProject *_p_stProj, long *_p_lNbFiles, char **_d_szFile, BOOL _bAll )
{
long lFile = 0;
tdstProject *p_stSubProj = _p_stProj->d_stSubProject;
tdstFile *p_stFile = _p_stProj->d_stFile;
for ( ; lFile < _p_stProj->lNumberOfFiles; lFile++, p_stFile ++)
{
if ( _bAll || (_p_stProj->bGet) || (p_stFile->bGet) )
sprintf( _d_szFile[ (*_p_lNbFiles)++ ], "%s\\%s", g_szFullName, p_stFile->szName );
}
for (lFile = 0; lFile < _p_stProj->lNumberOfSubProjects; lFile ++, p_stSubProj++)
{
strcat( g_szFullName, "\\");
strcat( g_szFullName, p_stSubProj->szName );
fn_Tree_vGetFilesToGet( p_stSubProj, _p_lNbFiles, _d_szFile, _bAll || _p_stProj->bRecurse );
*strrchr( g_szFullName, '\\' ) = 0;
}
}
/*
----------------------------------------------------------------------------------------
Description : build list of files to get
_p_stProj -> project to look in
**_ppp_szFile -> pointer on a list that will be filled
Returns (long ) number of files in list
----------------------------------------------------------------------------------------
*/
long fn_Tree_lBuildListOfFilesToGet( tdstProject *_p_stProj, char ***_ppp_szFile )
{
long lNbFiles, lFile;
lNbFiles = 0;
fn_Tree_vGetNumberOfFilesToGet( _p_stProj, &lNbFiles, FALSE );
if (lNbFiles == 0)
return 0;
*_ppp_szFile = (char **) malloc (lNbFiles * sizeof ( char *) );
for (lFile = 0; lFile < lNbFiles; lFile ++)
(*_ppp_szFile)[lFile] = (char *) malloc ( MAX_PATH );
strcpy (g_szFullName, _p_stProj->szName );
lNbFiles = 0;
fn_Tree_vGetFilesToGet( _p_stProj, &lNbFiles, *_ppp_szFile, FALSE );
return lNbFiles;
}
/*
----------------------------------------------------------------------------------------
Description : free a list of files previously build with fn_TREE_lBuildListOfFilesToGet
function
_lNumberOfFiles -> number of files in list
*_pp_szFile -> list of file
----------------------------------------------------------------------------------------
*/
void fn_Tree_vFreeListOfFilesToGet( long _lNumberOfFiles, char **_pp_szFile )
{
long lFile;
if (_lNumberOfFiles == 0)
return;
for (lFile = 0; lFile < _lNumberOfFiles; lFile ++)
free( _pp_szFile[lFile] );
free( _pp_szFile );
}
/*
---------------------------------------------------------------------------------------
dump a list in a file
---------------------------------------------------------------------------------------
*/
void fn_TREE_vDumpListInFile( char *szTitle, long lNbFiles, char **d_szFileName )
{
FILE *hpFile;
long lFile;
CTime oTime = GetCurrentTime();
hpFile = fopen( "filelst.txt", "at" );
if (hpFile == NULL)
return;
fprintf( hpFile, "*********** %s (%d files) **************\n", (char*)(LPCTSTR) (oTime.Format( "%d/%m/%y %H:%M:%S" )), lNbFiles );
fprintf( hpFile, "%s\n\n", szTitle );
for ( lFile = 0; lFile < lNbFiles; lFile ++)
{
fprintf( hpFile, "%s\n", d_szFileName[ lFile ] );
}
fclose( hpFile );
}
/*
---------------------------------------------------------------------------------------
set new list of file from analysis of vss tree obtaining state
---------------------------------------------------------------------------------------
*/
BOOL fn_TREE_bGetFileList( tdstProject *_p_stProj, tdstFileListConfig *_p_stFileList, char _cConfig, char *_szFileListName )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char szFileListId[20];
long lNbFiles;
char **d_szFile;
long lFile;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
sprintf(szFileListId, "FileList-Config%02d", _cConfig);
lNbFiles = 0;
fn_Tree_vGetNumberOfFilesOrProjectsToGet( _p_stProj, &lNbFiles );
if (lNbFiles == 0)
return FALSE;
d_szFile = (char **) malloc (lNbFiles * sizeof ( char *) );
for (lFile = 0; lFile < lNbFiles; lFile ++)
d_szFile[lFile] = (char *) malloc ( MAX_PATH );
strcpy (g_szFullName, _p_stProj->szName );
lNbFiles = 0;
fn_Tree_vGetFilesOrProjectToGet( _p_stProj, &lNbFiles, d_szFile );
fn_IniD_vFreeFileList( _p_stFileList );
strcpy( _p_stFileList->szId, szFileListId );
strcpy( _p_stFileList->szName, _szFileListName );
_p_stFileList->lNumberOfFiles = lNbFiles;
_p_stFileList->d_szFile = d_szFile;
//fn_vUpdateFilesToObtainList();
return TRUE;
}
/*
=======================================================================================
Function for local tree
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : fill project with local content
_p_stProject -> project to fill
_szEndName -> end of current path which is a global var )
----------------------------------------------------------------------------------------
*/
void fn_Tree_vFillProjectFromDisk( tdstProject *_p_stProject, char *_szEndName )
{
long lNbFiles = 0;
long lNbProjs = 0;
tdstProject *p_stSubProj;
WIN32_FIND_DATA stFindData;
HANDLE hFind;
if (g_hProjectWindow != NULL)
SetWindowText( g_hProjectWindow, _p_stProject->szName );
strcpy( _szEndName, "*.*" );
hFind = FindFirstFile(g_szFullName, &stFindData );
*_szEndName = 0;
if( hFind != INVALID_HANDLE_VALUE)
{
do
{
if ( stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
if ( *stFindData.cFileName != '.')
{
gs_d_szProj[ lNbProjs ] = (char *) malloc( strlen(stFindData.cFileName) + 1 );
strcpy ( gs_d_szProj[ lNbProjs ], stFindData.cFileName );
lNbProjs++;
}
}
else
{
gs_d_szFile[ lNbFiles ] = (char *) malloc( strlen(stFindData.cFileName) + 1 );
strcpy ( gs_d_szFile[ lNbFiles ], stFindData.cFileName );
lNbFiles++;
}
} while(FindNextFile( hFind, &stFindData ));
FindClose( hFind );
}
/*
* allocate memory for all files and all sub projects
*/
if (lNbProjs)
{
_p_stProject->lNumberOfSubProjects = lNbProjs;
_p_stProject->d_stSubProject = (tdstProject *) malloc ( lNbProjs * sizeof( tdstProject) );
for (lNbProjs = 0; lNbProjs < _p_stProject->lNumberOfSubProjects; lNbProjs ++)
fn_Tree_vInitProjectWithPointerName( &_p_stProject->d_stSubProject[ lNbProjs ], gs_d_szProj[lNbProjs] );
}
if ( lNbFiles )
{
if (lNbFiles > 2048)
AfxMessageBox( "more than 2048 files in a folder\r\nthere will soon be a big bug !!!\r\nContact me .\r\n", MB_ICONSTOP | MB_OK);
_p_stProject->lNumberOfFiles = lNbFiles;
_p_stProject->d_stFile = (tdstFile *) malloc ( lNbFiles * sizeof( tdstFile) );
for (lNbFiles = 0; lNbFiles < _p_stProject->lNumberOfFiles; lNbFiles ++)
{
fn_Tree_vInitFileWithPointerName( &_p_stProject->d_stFile[ lNbFiles ], gs_d_szFile[ lNbFiles ] );
fn_Tree_vAddFileTypeFromFile( gs_d_szFile[ lNbFiles ] );
}
}
/*
* construct sub project tree
*/
for (p_stSubProj = _p_stProject->d_stSubProject, lNbProjs = 0; lNbProjs < _p_stProject->lNumberOfSubProjects; lNbProjs ++, p_stSubProj++)
{
lNbFiles = sprintf( _szEndName, "%s\\", p_stSubProj->szName );
fn_Tree_vFillProjectFromDisk( p_stSubProj, _szEndName + lNbFiles );
*_szEndName = 0;
}
}
/*
----------------------------------------------------------------------------------------
Description : build local tree
_p_stRootProject -> project to fill (correspond to root project)
_szRootName -> project name (root)
Returns (BOOL ) TRUE if tree has been build, otherwise FALSE
----------------------------------------------------------------------------------------
*/
BOOL fn_Tree_bBuildFromDisk( tdstProject **_pp_stRootProject, char *_szRootName, HWND _hProjectWindow )
{
/*
* check existance of root project
*/
if (_access( _szRootName, 0) != 0 )
return FALSE;
if (*_pp_stRootProject != NULL)
fn_Tree_vFreeProjectTree(*_pp_stRootProject, TRUE );
fn_Tree_vFreeFileTypeList();
g_hProjectWindow = _hProjectWindow;
/*
* create and initialize root project
*/
*_pp_stRootProject = (tdstProject *) malloc( sizeof (tdstProject) );
fn_Tree_vInitProject( *_pp_stRootProject, _szRootName );
// allocate memory for name storage
gs_d_szFile = (char **) malloc ( 2048 * sizeof( char *) );
gs_d_szProj = (char **) malloc ( 2048 * sizeof( char *) );
// get recursively and from root project vss tree
sprintf( g_szFullName, "%s\\", _szRootName );
fn_Tree_vFillProjectFromDisk( *_pp_stRootProject, g_szFullName + strlen( g_szFullName) );
free( gs_d_szFile );
free( gs_d_szProj );
return TRUE;
}