/* ======================================================================================= Name: DlgMain.cpp : implementation file Author: Mihaela Tancu Date: 2 June 1998 ======================================================================================= */ #include #include #include #include "stdafx.h" #include "BinaryTool.h" #include "DlgMain.h" #include "IniData.h" #include "io.h" #include "GIItem.h" #include "GIType.h" #include "Levels.h" #include "Anims.h" #include "Binary.h" #include "l_global_v6.h" #include "makeanim.h" #include "DlgWarning.h" #include "stdafx.h" #include "ERM.h" #include "MMG.h" #include "TMP.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define C_BinPass1 "2" #define C_BinPass2 "3" #define C_TemporaryDirectory "TestCRB" #define C_CRBExecutable "CRB.exe" #define C_World "World" #define C_Levels "Levels" #define NombreDanimationsParDirectory 1000 #define FAMILY_NAME_LENGTH 32 /* ======================================================================================= * Color for line in Rich edit ctrl ======================================================================================= */ BOOL bOneLevelMode, bLevelMode; xString sLevel[100]; long lLevelNum=0; char szDestBinDir[256]; char sInitialDir[256]; char szSource[256]; char sSource[256]; BOOL bOneTextureMode, bTextureMode; xString sTextures[100]; long lTextureNum=0; BOOL bOneAnimMode, bAnimMode; xString sAnims[100]; long lAnimNum=0; BOOL bYes = FALSE; BOOL bBatch = TRUE; BOOL bAll = TRUE; BOOL bTbl = TRUE; BOOL bBMP = TRUE; BOOL bTGA = TRUE; BOOL bConvert16 = TRUE; BOOL bConvert32 = FALSE; BOOL bAuto = FALSE; // YLG correction char sMes[50], sOK[50], sCancel[50]; // When binarizaing first level, some special operations are done : // texture copy, binarisation of fix. BOOL bFirstLevel = TRUE; ///////////////////////////////////////////////////////////////////////////// // CDlgMain dialog CDlgMain::CDlgMain(CWnd* pParent) : CDialog(CDlgMain::IDD, pParent) { //{{AFX_DATA_INIT(CDlgMain) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT //initialize the values for the edit controls and the //push buttons from the right part of the window m_a_uiRadioButtons[0] = IDC_BUTTON_DEBUG; m_a_uiRadioButtons[1] = IDC_BUTTON_RELEASE; m_cNbRadioButtons = 2; m_a_uiEditControls[0] = IDC_EDIT_DESTBIND; m_a_uiEditControls[1] = IDC_EDIT_SOURCE; m_a_uiEditControls[2] = IDC_EDIT_EXEC; m_cNbEditBox = 3; m_a_uiRightButtons[0] = IDC_BUTTON_BROWSE2; m_a_uiRightButtons[1] = IDC_BUTTON_BROWSE3; m_a_uiRightButtons[2] = IDC_BUTTON_ALL; m_a_uiRightButtons[3] = IDC_BUTTON_ALLINLIST; m_a_uiRightButtons[4] = IDC_BUTTON_CLEAR; m_a_uiRightButtons[5] = IDC_BUTTON_CLEARALL; m_a_uiRightButtons[6] = IDC_BUTTON_CONVERT; m_a_uiRightButtons[7] = IDC_BUTTON_CHANGE; m_cNbRightButtons = 8; m_a_uiRightBut[0] = IDC_BUTTON_CONVANI; m_a_uiRightBut[1] = IDC_BUTTON_CONVTEX; m_a_uiRightBut[2] = IDC_BUTTON_CONVLEVEL; m_a_uiRightBut[3] = IDC_BUTTON_USED; m_a_uiRightBut[4] = IDC_BUTTON_A; m_a_uiRightBut[5] = IDC_BUTTON_Z; m_a_uiRightBut[6] = IDC_BUTTON_BMP; m_a_uiRightBut[7] = IDC_BUTTON_TGA; m_a_uiRightBut[8] = IDC_BUTTON_C16; m_a_uiRightBut[9] = IDC_BUTTON_C32; m_cNbRightBut = 10; // initialize also the group buttons for sizing the window m_a_uiGroupButtons[0] = IDC_STATIC_GR1; m_a_uiGroupButtons[1] = IDC_STATIC_GR2; m_a_uiGroupButtons[2] = IDC_STATIC_VERS; m_a_uiGroupButtons[3] = IDC_STATIC_EXEC; m_a_uiGroupButtons[4] = IDC_STATIC_DSC; m_a_uiGroupButtons[5] = IDC_BUTTON_FIX; m_cNbGroupButtons = 6; // initial is FALSE, and is putting on TRUE in the function OnInitDialog m_bInit = FALSE; //initialize for the cross m_bFirstShow = TRUE; m_oCrossDC.CreateCompatibleDC(NULL); m_oCrossBitmap.LoadBitmap(IDB_BITMAP_CROIX); m_oCrossDC.SelectObject(m_oCrossBitmap); //initial the total number of selections is 0 m_iCountOfSelections=0; m_bConversion = FALSE; //and there are no types m_p_oTypeAnims = NULL; m_p_oTypeTextures = NULL; m_p_oTypeLevels = NULL; } CDlgMain::~CDlgMain() { //delete the cross m_oCrossBitmap.DeleteObject(); m_oCrossDC.DeleteDC(); mfn_vFreeMemory(); } void CDlgMain::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlgMain) // NOTE: the ClassWizard will add DDX and DDV calls here DDX_Control(pDX, IDC_PANEL, m_oPanel); DDX_Control(pDX, IDC_STATIC_PROGRESS, m_oProgress); //}}AFX_DATA_MAP } /* ======================================================================================= Name: On command Description: intercept the ... Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::OnCommand(WPARAM wParam, LPARAM lParam) { if (HIWORD(wParam) == 0) { } return CDialog::OnCommand(wParam, lParam); } BEGIN_MESSAGE_MAP(CDlgMain, CDialog) //{{AFX_MSG_MAP(CDlgMain) ON_WM_DESTROY() ON_WM_PAINT() ON_WM_DRAWITEM() ON_WM_SIZING() ON_NOTIFY(TCN_SELCHANGE, IDC_PANEL, OnSelchangePanel) ON_BN_CLICKED(IDC_HELP, OnHelp) ON_BN_CLICKED(IDC_QUIT, OnQuit) ON_BN_CLICKED(IDC_BUTTON_ALL, OnSelectAll) ON_BN_CLICKED(IDC_BUTTON_ALLINLIST, OnSelectAllInList) ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnClear) ON_BN_CLICKED(IDC_BUTTON_CLEARALL, OnClearAll) ON_BN_CLICKED(IDC_BUTTON_BROWSE2, OnButtonBrowseDestBinD) ON_BN_CLICKED(IDC_BUTTON_BROWSE3, OnButtonBrowseSource) ON_BN_CLICKED(IDC_BUTTON_DEBUG, OnButtonDebug) ON_BN_CLICKED(IDC_BUTTON_RELEASE, OnButtonRelease) ON_BN_CLICKED(IDC_BUTTON_CONVANI, OnConvAnim) ON_BN_CLICKED(IDC_BUTTON_CONVTEX, OnConvTextures) ON_BN_CLICKED(IDC_BUTTON_CONVLEVEL, OnConvLevels) ON_BN_CLICKED(IDC_BUTTON_USED, OnUsed) ON_BN_CLICKED(IDC_BUTTON_A, OnAll) ON_BN_CLICKED(IDC_BUTTON_Z, OnTbl) ON_BN_CLICKED(IDC_BUTTON_BMP, OnBMP) ON_BN_CLICKED(IDC_BUTTON_TGA, OnTGA) ON_BN_CLICKED(IDC_BUTTON_C16, OnConvert16) ON_BN_CLICKED(IDC_BUTTON_C32, OnConvert32) ON_BN_CLICKED(IDC_BUTTON_AUTO, OnGenerateAuto) // ON_BN_CLICKED(IDC_BUTTON_D3D, OnButtonD3D) // ON_BN_CLICKED(IDC_BUTTON_DFX, OnButtonDFX) ON_BN_CLICKED(IDC_BUTTON_FIX, OnButtonFix) ON_BN_CLICKED(IDC_BUTTON_CONVERT, OnBinarise) ON_BN_CLICKED(IDC_BUTTON_CHANGE, OnButtonBrowseExeFile) ON_BN_CLICKED(IDC_BUTTON_BIN, OnButtonBin) ON_WM_SIZE() ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeListType) ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeListObject) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDlgMain message handlers BOOL CDlgMain::PreTranslateMessage(MSG* pMsg) { int iIndexAction = m_oListObject->GetCurSel(); BOOL bResult = FALSE; // default if ( pMsg->hwnd == GetDlgItem(IDC_LIST2)->m_hWnd ) { switch ( pMsg->message ) { case WM_LBUTTONDOWN: bResult = OnLButtonDownListBoxObject ( pMsg ) ; break; case WM_KEYDOWN: bResult = OnKeyDownListBoxObject( pMsg ); break; default: bResult = CDialog::PreTranslateMessage(pMsg); } } return bResult; } /* ======================================================================================= Name: OnButtonBin Description: Function for Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnButtonBin() { if (((CButton *)GetDlgItem(IDC_BUTTON_BIN))->GetCheck()) //if it is checked ... bDsc = TRUE; else bDsc = FALSE; } /* ======================================================================================= Name: OnDrawItem Description: Handle function for message WM_DRAWITEM on List Box with Names (objects) and in the list box with types Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDIS) { if ( (nIDCtl == IDC_LIST2) && (m_oListObject->IsWindowEnabled() ) && (lpDIS->itemID != LB_ERR) ) //draw for the second list box with objects m_fn_vOnDrawItemListBoxObject ( lpDIS ) ; else if ( (nIDCtl == IDC_LIST1) && (m_oListType->IsWindowEnabled() ) && (lpDIS->itemID != LB_ERR)) //draw for the first list box with types m_fn_vOnDrawItemListBoxType ( lpDIS ) ; else CDialog::OnDrawItem(nIDCtl, lpDIS); } /* ======================================================================================= Name: OnButtonDebug Description: Function for changing the result directory if the debug radio button is set Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnButtonDebug() { char _szMessage[5000]; BOOL bSet=TRUE, bDisplay=FALSE; if (((CButton *)GetDlgItem(IDC_BUTTON_DEBUG))->GetCheck()) { ((CButton *)GetDlgItem(IDC_BUTTON_DEBUG))->SetCheck(1); bDebug = TRUE; /* if (b3DCard) if (bDebug) { if (!SetCurrentDirectory( g_stInitialData.szDestBinDD3D )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDD3D ),"DestBinDD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDD3D); } else { if (!SetCurrentDirectory( g_stInitialData.szDestBinRD3D )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRD3D ),"DestBinRD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRD3D); } else*/ if (bDebug) { if (!SetCurrentDirectory( g_stInitialData.szDestBinDDFX )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDDFX ),"DestBinDDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDDFX); } else { if (!SetCurrentDirectory( g_stInitialData.szDestBinRDFX )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRDFX ),"DestBinRDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRDFX); } GetDlgItem(IDC_EDIT_DESTBIND)->GetWindowText(szDestBinDir, 256); if (!bAuto) // YLG Correction fn_IniData_vGetDatasFromStartFile(TRUE); if (!strcmp(g_stInitialData.szExeFile, "")) GetDlgItem(IDC_EDIT_EXEC)->SetWindowText( "" ); else GetDlgItem(IDC_EDIT_EXEC)->SetWindowText( g_stInitialData.szExeFile ); } } /* ======================================================================================= Name: OnButtonD3D Description: Function for changing the result directory if the debug radio button is set Author: Mihaela Tancu ======================================================================================= */ /*void CDlgMain::OnButtonD3D() { char _szMessage[5000]; BOOL bSet=TRUE, bDisplay=FALSE; if (((CButton *)GetDlgItem(IDC_BUTTON_D3D))->GetCheck()) { ((CButton *)GetDlgItem(IDC_BUTTON_D3D))->SetCheck(1); b3DCard = TRUE; if (b3DCard) if (bDebug) { if (!SetCurrentDirectory( g_stInitialData.szDestBinDD3D )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDD3D ),"DestBinDD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDD3D); } else { if (!SetCurrentDirectory( g_stInitialData.szDestBinRD3D )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRD3D ),"DestBinRD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRD3D); } else if (bDebug) { if (!SetCurrentDirectory( g_stInitialData.szDestBinDDFX )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDDFX ),"DestBinDDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDDFX); } else { if (!SetCurrentDirectory( g_stInitialData.szDestBinRDFX )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRDFX ),"DestBinRDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRDFX); } GetDlgItem(IDC_EDIT_DESTBIND)->GetWindowText(szDestBinDir, 256); } } */ /* ======================================================================================= Name: OnButtonDFX Description: Function for changing the result directory if the debug radio button is set Author: Mihaela Tancu ======================================================================================= */ /*void CDlgMain::OnButtonDFX() { char _szMessage[5000]; BOOL bSet=TRUE, bDisplay=FALSE; if (((CButton *)GetDlgItem(IDC_BUTTON_DFX))->GetCheck()) { ((CButton *)GetDlgItem(IDC_BUTTON_DFX))->SetCheck(1); b3DCard = FALSE; if (b3DCard) if (bDebug) { if (!SetCurrentDirectory( g_stInitialData.szDestBinDD3D )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDD3D ),"DestBinDD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDD3D); } else { if (!SetCurrentDirectory( g_stInitialData.szDestBinRD3D )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRD3D ),"DestBinRD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRD3D); } else if (bDebug) { if (!SetCurrentDirectory( g_stInitialData.szDestBinDDFX )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDDFX ),"DestBinDDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDDFX); } else { if (!SetCurrentDirectory( g_stInitialData.szDestBinRDFX )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRDFX ),"DestBinRDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRDFX); } GetDlgItem(IDC_EDIT_DESTBIND)->GetWindowText(szDestBinDir, 256); } } */ /* ======================================================================================= Name: OnDestroy Description: Handle function for message WM_DESTROY Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnDestroy() { //if you want to save the modifications if you select the /\ button (to close the dialog) /* ======================================================================================= * save new position and size of the main window ======================================================================================= */ if (m_bInit) { GetWindowRect( &g_stWinPosSize.stMainPos ); fn_IniData_vWriteWindowPosSize(); fn_IniData_vSetMode( bDebug ); fn_IniData_vSetCompleteBinarization( bDsc ); fn_IniData_vSetFix( bFix1 ); } SCR_fn_v_RdL0_Close(); CDialog::OnDestroy(); } /* ======================================================================================= Name: m_fn_TabC_vDisableAllButtons Description: Enable the buttons for all the tabs Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_TabC_vDisableAllButtons() { // Show or hide the buttons from the first panel // according to the parameter bChange GetDlgItem(IDC_HELPBUTTON)->EnableWindow(FALSE); GetDlgItem(IDC_QUIT)->EnableWindow(FALSE); } /* ======================================================================================= Name: m_fn_TabC_vEnableButtons Description: Enable the buttons for all the tabs Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_TabC_vEnableButtons() { // Show or hide the buttons from the first panel // according to the parameter bChange // GetDlgItem(IDC_HELPBUTTON)->EnableWindow(TRUE); GetDlgItem(IDC_QUIT)->EnableWindow(TRUE); } /* ======================================================================================= Name: OnBinarise Description: Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnBinarise() { int i, k, j=2; m_bConversion = TRUE; m_fn_TabC_vDisableAllButtons(); m_fn_TabC_vShowControlsPanelRes() ; m_oPanel.SetCurSel(2); m_fn_TabC_vShowControlsPanelRes() ; RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); if (!bYes) { m_fn_ComRes_vDeleteLines( &m_oRichEditCom); m_fn_ComRes_vDeleteLines( &m_oRichEditRes); } m_oProgress.SetRange( 0, m_iCountOfSelections+1 ); m_oProgress.SetPos( 1 ); // If "Force binarization of fix" is checked, the next level is treated as first level // (ie: binarisation of fix, copy of textures...) if( bFix1 ) bFirstLevel = TRUE; //if the families are selected if (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) { if(bOneAnimMode) bOneAnimMode = (m_p_oTypeAnims->m_iSelected != m_p_oTypeAnims->m_oList.GetCount()); bAnimMode = TRUE; for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeAnims->m_oList.RemoveHead(); if (p_oItem->m_bActived) { strcpy(sAnims[lAnimNum], p_oItem->m_fn_p_oGetName()); m_fn_ComRes_vWriteLine( "Binary Tool", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( " --> binarize animations for family ", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( sAnims[lAnimNum], C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "Start binarizing animations for family ", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( sAnims[lAnimNum], C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( "...\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); //Mihaela Tancu - New auto //fn_vBinarizeAnimations(sAnims[lAnimNum]); char szCurrentDir[256]/*, szAnimDir[256], szAnimDest[256]*/; GetCurrentDirectory(_MAX_PATH, szCurrentDir); SetCurrentDirectory(sInitialDir); fn_cExecuteMakeanim("Makeanim.exe", bBatch, bAll, bTbl, sAnims[lAnimNum]); m_fn_ComRes_vWriteLine( "Finish binarizing animations for family ", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( sAnims[lAnimNum], C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); /* if (bAll) { strcpy(szAnimDir, sInitialDir); strcat(szAnimDir, "\\gamedata\\world\\graphics\\anims\\"); strcat(szAnimDir, sAnims[lAnimNum]); strcpy(szAnimDest, szDestBinDir); strcat(szAnimDest, "\\world\\graphics\\anims\\"); strcat(szAnimDest, sAnims[lAnimNum]); SAVE_fn_bCopyDirectory(szAnimDir, szAnimDest, TRUE, "A3I"); } if (bTbl) { strcpy(szAnimDir, sInitialDir); strcat(szAnimDir, "\\gamedata\\world\\levels\\_common\\families\\"); strcat(szAnimDir, sAnims[lAnimNum]); strcpy(szAnimDest, szDestBinDir); strcat(szAnimDest, "\\world\\levels\\_common\\families\\"); strcat(szAnimDest, sAnims[lAnimNum]); SAVE_fn_bCopyDirectory(szAnimDir, szAnimDest, TRUE, "TBL"); }*/ SetCurrentDirectory(szCurrentDir); //Mihaela Tancu - New auto RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); lAnimNum++; k=i+j; m_oProgress.SetPos( k ); MLT_vEraseSTALib(); } m_p_oTypeAnims->m_oList.AddTail(p_oItem); } bOneAnimMode=TRUE; j=j+i; } //if the levels are selected if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected) { BOOL bErrorOccuredWhileBinarizingLevel = FALSE; if(bOneLevelMode) bOneLevelMode = (m_p_oTypeLevels->m_iSelected != m_p_oTypeLevels->m_oList.GetCount()); bLevelMode = TRUE; MLT_vInitALWLoad(); MLT_vInitLVLLoad(); MLT_vInitTEXLoad(); // Convert anims. if( bConvAnim ) { for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeLevels->m_oList.RemoveHead(); if (p_oItem->m_bActived) { strcpy(sLevel[lLevelNum], p_oItem->m_fn_p_oGetName()); m_fn_ComRes_vWriteLine( "BinaryTool --> Animations\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "Start binarizing...\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); if (GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled()) { m_fn_ComRes_vWriteLine( "\n binarize animations for the level ", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( sLevel[lLevelNum], C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( sLevel[lLevelNum], C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); fn_vAnimationsOnly( sLevel[lLevelNum]); } //Mihaela Tancu - Makeanim new } m_p_oTypeLevels->m_oList.AddTail(p_oItem); } } /* * Convert and Copy the graphics\Texture and Vignette directories */ if( bConvTextures || bFirstLevel ) { m_fn_ComRes_vWriteLine( "BinaryTool --> Textures\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "\nCopy textures to the bin directory \n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); RedrawWindow(NULL, NULL, RDW_INVALIDATE |RDW_UPDATENOW ); fn_vCopyTextures( sInitialDir, szDestBinDir, bConvTextures ); } for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeLevels->m_oList.RemoveHead(); m_p_oTypeLevels->m_oList.AddTail(p_oItem); if (p_oItem->m_bActived) { strcpy(sLevel[lLevelNum], p_oItem->m_fn_p_oGetName()); //Mihaela Tancu - Makeanim new if (bConvLevels && GetDlgItem(IDC_BUTTON_CONVLEVEL)->IsWindowEnabled()) //the level should be converted { m_fn_ComRes_vWriteLine( "BinaryTool --> Level\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "\n binarize the level ", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( sLevel[lLevelNum], C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "\nStart binarizing the level...\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); RedrawWindow(NULL, NULL, RDW_INVALIDATE |RDW_UPDATENOW ); if( m_fn_iInitBinGame(sLevel[lLevelNum], p_oItem) == -1 ) { bErrorOccuredWhileBinarizingLevel = TRUE; break; } m_fn_ComRes_vWriteLine( "\nFinish binarizing the level...\n\n\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); bFirstLevel = FALSE; } m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); lLevelNum++; k=i+j; m_oProgress.SetPos( k ); RedrawWindow(NULL, NULL, RDW_INVALIDATE |RDW_UPDATENOW ); } } m_fn_ComRes_vWriteLine( "Finish binarizing...\n\n\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); bOneLevelMode=TRUE; j=j+i; if( ! bErrorOccuredWhileBinarizingLevel ) { strcpy(g_szStartPrgIniFile, sInitialDir); if (g_szStartPrgIniFile[strlen(g_szStartPrgIniFile) - 1] != '\\') strcat( g_szStartPrgIniFile, "\\"); strcat( g_szStartPrgIniFile, C_szStartPrgIniFile ); char szDir1[MAX_PATH] ; //Mihaela Tancu - Correction if ((g_szStartPrgIniFile[0]==toupper(szDestBinDir[0])) || (g_szStartPrgIniFile[0]==tolower(szDestBinDir[0]))) //the exe of the game and //Mihaela Tancu - Correction //the destination directory are on the same drive { char /*szPath[ MAX_PATH ], */szDir[MAX_PATH] ; char *p_Char, *p_Char1; char szExeDir[ MAX_PATH ], szDestDir[MAX_PATH]; int /*i,*/ j, iCounter=0, iCounter1=0; if ((p_Char=strstr(szDestBinDir, g_szStartPrgIniFile))!=NULL) //the destination directory is a //sub-directory of the exe directory { strcpy(szDir1, szDestBinDir+strlen(sInitialDir)+1); } else { strcpy(szExeDir, sInitialDir+2); p_Char = strstr(szExeDir, "\\"); if (p_Char) { strcpy(szDir, p_Char+1); p_Char1 = strstr(szDir, "\\"); if (p_Char1) szDir[strlen(p_Char)-strlen(p_Char1)-1]='\0'; } strcpy(szDestDir, szDestBinDir+2); p_Char = strstr(szDestDir, "\\"); if (p_Char) { strcpy(szDir1, p_Char+1); p_Char1 = strstr(szDir1, "\\"); if (p_Char1) szDir1[strlen(p_Char)-strlen(p_Char1)-1]='\0'; } while (!stricmp(szDir, szDir1)) { iCounter++; strcpy(szExeDir, szExeDir+strlen(szDir)+1); p_Char = strstr(szExeDir, "\\"); if (p_Char) { strcpy(szDir, p_Char+1); p_Char1 = strstr(szDir, "\\"); if (p_Char1) szDir[strlen(p_Char)-strlen(p_Char1)-1]='\0'; } strcpy(szDestDir, szDestDir+strlen(szDir1)+1); p_Char = strstr(szDestDir, "\\"); if (p_Char) { strcpy(szDir1, p_Char+1); p_Char1 = strstr(szDir1, "\\"); if (p_Char1) szDir1[strlen(p_Char)-strlen(p_Char1)-1]='\0'; } } strcpy(szDir, p_Char+1); strcpy(szDir1, sInitialDir); while(p_Char=strstr(szDir1, "\\")) { strcpy(szDir1, p_Char+1); iCounter1++; } strcpy(szDir1, ""); for (j=0; jm_iSelected) { if(bOneTextureMode) bOneTextureMode = (m_p_oTypeTextures->m_iSelected != m_p_oTypeTextures->m_oList.GetCount()); bTextureMode = TRUE; for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeTextures->m_oList.RemoveHead(); if (p_oItem->m_bActived) { strcpy(sTextures[lTextureNum], p_oItem->m_fn_p_oGetName()); m_fn_ComRes_vWriteLine( "BinaryTool --> binarize the textures from ", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( sTextures[lTextureNum], C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( " directory\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); //Mihaela Tancu - New auto // fn_vBinarizeTexturesDir(sTextures[lTextureNum]); char szCurrentDir[256]; GetCurrentDirectory(_MAX_PATH, szCurrentDir); SetCurrentDirectory(sInitialDir); fn_cExecuteConvImg("ConvImg.exe", sSource, szDestBinDir, bBMP, bTGA, bConvert16, bConvert32, sTextures[lTextureNum]); SetCurrentDirectory(szCurrentDir); m_fn_ComRes_vWriteLine( "Finish binarization of textures...\n\n\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); //Mihaela Tancu - New auto RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); lTextureNum++; k=i+j; m_oProgress.SetPos( k ); } m_p_oTypeTextures->m_oList.AddTail(p_oItem); } bOneTextureMode=TRUE; j=j+i; } m_fn_vSelectAll(FALSE); m_oListType->Invalidate(TRUE); m_fn_vEnableButtons(FALSE); m_fn_TabC_vEnableButtons(); GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(FALSE); m_bConversion = FALSE; } /* ======================================================================================= Name: m_fn_vInitBinTextures Description: Copy files .gf from source corresponding directory to destination directory Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vInitBinTextures(char *sString) { char szTempName[_MAX_PATH]; char szCurrentDir[_MAX_PATH]; char szDirName[_MAX_PATH]; /* * Copy the graphics\Texture directory */ m_fn_ComRes_vWriteLine( "Binary Tool", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( " --> ", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( sString, C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditCom, &m_stCharFormatCom); m_fn_ComRes_vWriteLine( "Copy all the files *.gf from the Texture directory", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); strcpy(szCurrentDir, sInitialDir); strcpy(szTempName,szDestBinDir); strcat(szTempName,"\\"); strcat(szTempName,C_World); strcat(szTempName,"\\Graphics"); SAVE_fn_bCreateDirectory(szTempName); strcat(szTempName,"\\Textures"); strcat(szTempName, "\\"); strcat(szTempName,sString); m_fn_ComRes_vWriteLine( " --> ", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( sString, C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); strcpy(szDirName,szCurrentDir); strcat(szDirName,"\\GameData\\World\\Graphics\\Textures"); strcat(szDirName, "\\"); strcat(szDirName, sString); SAVE_fn_bCopyDirectory(szDirName, szTempName, TRUE, "GF"); } /* ======================================================================================= Name: m_fn_iGetAllTextures Description: Get all Textures Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_iGetAllTextures(GI_Item * p_oItem) { char szFile[500]; sprintf(szFile, "%s\\World\\Levels\\%s\\%s.tex", g_stInitialData.szSource, p_oItem->m_szName, p_oItem->m_szName); MLT_vLoadTEXFileInLib(szFile); } /* ======================================================================================= Name: m_fn_vInitBinGame Description: Binarize the level give as parameter Author: Mihaela Tancu ======================================================================================= */ int CDlgMain::m_fn_iInitBinGame(char *sString, GI_Item *p_oItem) { char szLevelName[_MAX_PATH], szDir[_MAX_PATH]; char szLevelsDirectory[ _MAX_PATH ]; char szProgramName[_MAX_PATH]; char szBinDirectory[ _MAX_PATH ]; char szCurrentDir[_MAX_PATH]; char szFileName[_MAX_PATH]; char szTempName[_MAX_PATH]; char szTempDir[_MAX_PATH]; char szDirName[_MAX_PATH]; char szFile[ _MAX_PATH ]; char szSoundDirectory[_MAX_PATH]; char p_szCommanLine[500]; char cChar; // char cFirst=1; char cDebug=1; char cErrorCode; FILE *pFile; char *p_cSeparator ; GetCurrentDirectory(_MAX_PATH, szDir); SetCurrentDirectory(sInitialDir); strcpy(szCurrentDir, sInitialDir); strcpy(p_szCommanLine, "-dir:"); strcat(p_szCommanLine, szDestBinDir); strcat(p_szCommanLine, " -level:"); strcat(p_szCommanLine, sString); strcat(p_szCommanLine, " -first:"); if (!strcmp(sLevel[0], sString)) strcat(p_szCommanLine, "1"); else strcat(p_szCommanLine, "0"); strcat(p_szCommanLine, " -version:Glide "); strcat(p_szCommanLine, "-debug:"); if (bDebug) strcat(p_szCommanLine, "1"); else strcat(p_szCommanLine, "0"); strcat(p_szCommanLine, "-dsc:"); if (bDsc) strcat(p_szCommanLine, "2"); else strcat(p_szCommanLine, "1"); /* directory of the binarized data */ if(strstr(p_szCommanLine,"-dir:")) sscanf(strstr(p_szCommanLine,"-dir:")+5,"%s",szDirName); else return 0; /* the level that we want to binarize*/ if(strstr(p_szCommanLine,"-level:")) { sscanf(strstr(p_szCommanLine,"-level:")+7,"%s",szTempName); strcpy(szLevelName, _strupr(szTempName)); } else return 0; /* if(strstr(p_szCommanLine,"-first:")) { sscanf(strstr(p_szCommanLine,"-first:")+7,"%s",cChar1); cChar1[1] = '\0'; if (strcmp(cChar1, "0")==0) cFirst = 0; } */ if(strstr(p_szCommanLine,"-debug:")) { sscanf(strstr(p_szCommanLine,"-debug:")+7,"%c",&cChar); if (strcmp(&cChar, "0")==0) cDebug = 0; } if(strstr(p_szCommanLine,"-version:")) { sscanf(strstr(p_szCommanLine,"-version:")+9,"%s",szTempName); } else return 0; strcpy( szProgramName, g_stInitialData.szExeFile ); /* * path of the binary directory */ strcpy(szBinDirectory, szDirName); /* * path of the levels directory (source) */ //dir source + World\\levels strcpy(szLevelsDirectory, g_stInitialData.szSource); strcat(szLevelsDirectory, "\\World\\levels"); //Mihaela Tancu - New /* * Convert and Copy the graphics\Texture directory */ // if( cFirst ) // fn_vCopyTextures( szCurrentDir, szDestBinDir, bConvTextures ); //Mihaela Tancu - New // ANNECY MT - 15/02/99 { /* * path of sound directory (source) */ pFile = fopen("SoundVersion.ini","rt"); if(pFile) { fgets(szSoundDirectory,_MAX_PATH,pFile); if(szSoundDirectory[ strlen(szSoundDirectory) - 1] == 0x0a) szSoundDirectory[ strlen(szSoundDirectory) - 1] = 0; fclose(pFile); } else { pFile = fopen("Version.ini","rt"); if(pFile) { fgets(szSoundDirectory,255,pFile); p_cSeparator = strchr (szSoundDirectory,','); if (p_cSeparator) { *p_cSeparator = 0; } else if(szSoundDirectory[ strlen(szSoundDirectory) - 1] == 0x0a) { szSoundDirectory[ strlen(szSoundDirectory) - 1] = 0; } } } // END ANNECY MT } //Mihaela Tancu - Binary!!! strcpy(szFileName, szCurrentDir); strcat(szFileName, "\\StartPrg.ini"); remove(szFileName); //Mihaela Tancu - Binary!!! /* * First Pass */ m_fn_ComRes_vWriteLine( " First Pass for ", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( szProgramName, C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); SetCurrentDirectory(szCurrentDir); strcpy(szTempName, szCurrentDir); strcat(szTempName, "\\"); strcat(szTempName, szProgramName); //Mihaela Tancu if (bDsc) cErrorCode = fn_cExecuteGameFirst(szTempName, szLevelName, C_BinPass1); else cErrorCode = fn_cExecuteGame(szTempName, szLevelName, C_BinPass1); if (cErrorCode != 0) { char szErrorString[500]; sprintf( szErrorString, "Error: Program exited with error code %i\n", (int)cErrorCode ); m_fn_ComRes_vWriteLine( szErrorString, C_ComRes_cOkLine ,&m_oRichEditRes, &m_stCharFormatRes); return -1; } //Mihaela Tancu RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW ); /* * copy some files created in the level directory */ m_fn_ComRes_vWriteLine( " Copy files from level directory...\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); strcpy(szTempDir, szLevelsDirectory); strcat(szTempDir, "\\"); strcat(szTempDir, szLevelName); fn_cCopyAnyFilesOfADirectory(szTempDir,szCurrentDir,"0"); /* * copy some files created in the Gamedata directory */ m_fn_ComRes_vWriteLine( " Copy files from gamedata directory...\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); fn_cCopyAnyFilesOfADirectory(szLevelsDirectory,szCurrentDir,"0"); /* * Second pass */ m_fn_ComRes_vWriteLine( " Second Pass for ", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( szProgramName, C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); m_fn_ComRes_vWriteLine( "\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); if ( (cErrorCode = fn_cExecuteGame(szTempName, szLevelName, C_BinPass2)) !=0 ) { char szErrorString[500]; sprintf( szErrorString, " Error: Program exited with error code %i\n", (int)cErrorCode ); m_fn_ComRes_vWriteLine( szErrorString, C_ComRes_cOkLine ,&m_oRichEditRes, &m_stCharFormatRes); return -1; } RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); /* * copy some files created in the level directory */ m_fn_ComRes_vWriteLine( " Copy files from level directory...\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); fn_cCopyAnyFilesOfADirectory(szTempDir,szCurrentDir,"1"); /* * copy some files created in the Gamedata directory */ m_fn_ComRes_vWriteLine( " Copy files from gamedata directory...\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); fn_cCopyAnyFilesOfADirectory(szLevelsDirectory,szCurrentDir,"1"); strcpy(szTempName,szCurrentDir); // YLG modif strcat(szTempName, "\\"); strcat(szTempName, C_CRBExecutable); //Mihaela Tancu - FIX if (bFirstLevel) { /* * CRB on fix */ m_fn_ComRes_vWriteLine( " Execute CRB on Fix\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); fn_cExecuteCRB(szTempName, "Fix"); RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); } //Mihaela Tancu - FIX /* * CRB on Level */ m_fn_ComRes_vWriteLine( " Execute CRB on Level\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); fn_cExecuteCRB(szTempName, szLevelName); RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); /* * Create the bin directory and copy the binarized data */ m_fn_ComRes_vWriteLine( " Copy the binarized files to the bin directory...\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); SAVE_fn_bCreateDirectory(szBinDirectory); strcpy(szTempName,szBinDirectory); strcat(szTempName,"\\"); strcat(szTempName,C_World); SAVE_fn_bCreateDirectory(szTempName); strcat(szTempName,"\\"); strcat(szTempName,C_Levels); SAVE_fn_bCreateDirectory(szTempName); if (bFirstLevel) //Mihaela Tancu - FIX // { fn_cCopyBinarizedFiles(szCurrentDir, szTempName, "FIX"); strcat(szTempName,"\\"); strcat(szTempName,szLevelName); SAVE_fn_bCreateDirectory(szTempName); fn_cCopyBinarizedFiles(szCurrentDir, szTempName, szLevelName); // } //Mihaela Tancu - FIX //Mihaela Tancu - FIX // if (bFirstLevel) // { //delete the files related with fix, from cpa/exe/main and cpa/exe/main/gamedata/world/levels WIN32_FIND_DATA stFindData; HANDLE hFind; char a256_cFileFound[256]; char a4_cFileExtension[256]; char a256_cSrcDirectory[256]; char a256_cTmpFile[256]; char a256_cFileName[256]; strcpy(a256_cSrcDirectory,szCurrentDir); strcat(a256_cSrcDirectory,"\\*.*"); if( (hFind = FindFirstFile(a256_cSrcDirectory, &stFindData )) == INVALID_HANDLE_VALUE) return 0; strcpy(a256_cTmpFile,szLevelName); strcat(a256_cTmpFile, "0"); do { if(! ( stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )) { strcpy(a256_cFileName, _strupr(stFindData.cFileName)); fn_vGetFileExtension( a256_cFileName, a4_cFileExtension); if ((strcmp(a4_cFileExtension,"RTB")==0) || (strcmp(a4_cFileExtension,"RTS")==0) || (strcmp(a4_cFileExtension,"RTT")==0) || (strcmp(a4_cFileExtension,"RTP")==0) || (strcmp(a4_cFileExtension,"RTV")==0) || (strcmp(a4_cFileExtension,"RTL")==0) ) { if (strstr(stFindData.cFileName, szLevelName)) { strcpy(a256_cFileFound, szCurrentDir); strcat(a256_cFileFound,"\\"); strcat(a256_cFileFound,a256_cFileName); remove(a256_cFileFound); } else { if (strcmp(a256_cFileName, "FIXLVL.RTB")==0) { strcpy(a256_cFileFound, szCurrentDir); strcat(a256_cFileFound,"\\"); strcat(a256_cFileFound,a256_cFileName); remove(a256_cFileFound); } } } else { if ((strcmp(a4_cFileExtension,"SNA")==0) || (strcmp(a4_cFileExtension,"GPT")==0) || (strcmp(a4_cFileExtension,"SND")==0) || (strcmp(a4_cFileExtension,"PTX")==0) || (strcmp(a4_cFileExtension,"VGM")==0) || ((strcmp(a4_cFileExtension,"DSB")==0) && bDsc) || (strcmp(a4_cFileExtension,"LSY")==0) ) { strcpy(a256_cFileFound, szCurrentDir); strcat(a256_cFileFound,"\\"); strcat(a256_cFileFound,a256_cFileName); remove(a256_cFileFound); } } } } while(FindNextFile( hFind, &stFindData )); FindClose( hFind ); strcpy(a256_cSrcDirectory,szCurrentDir); strcat(a256_cSrcDirectory,"\\gamedata\\world\\levels\\*.*"); if( (hFind = FindFirstFile(a256_cSrcDirectory, &stFindData )) == INVALID_HANDLE_VALUE) return 0; strcpy(a256_cTmpFile,szLevelName); strcat(a256_cTmpFile, "0"); do { if(! ( stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )) { strcpy(a256_cFileName, _strupr(stFindData.cFileName)); fn_vGetFileExtension( a256_cFileName, a4_cFileExtension); if ((strcmp(a4_cFileExtension,"RTB")==0) || (strcmp(a4_cFileExtension,"RTS")==0) || (strcmp(a4_cFileExtension,"RTT")==0) || (strcmp(a4_cFileExtension,"RTP")==0) || (strcmp(a4_cFileExtension,"RTV")==0) || (strcmp(a4_cFileExtension,"RTL")==0) ) { strcpy(a256_cFileFound, szCurrentDir); strcat(a256_cFileFound,"\\gamedata\\world\\levels\\"); strcat(a256_cFileFound,a256_cFileName); remove(a256_cFileFound); } else { if ((strcmp(a4_cFileExtension,"SNA")==0) || (strcmp(a4_cFileExtension,"GPT")==0) || (strcmp(a4_cFileExtension,"SND")==0) || (strcmp(a4_cFileExtension,"PTX")==0) || (strcmp(a4_cFileExtension,"VGM")==0) || ((strcmp(a4_cFileExtension,"DSB")==0) && bDsc) || (strcmp(a4_cFileExtension,"LSY")==0) ) { strcpy(a256_cFileFound, szCurrentDir); strcat(a256_cFileFound,"\\gamedata\\world\\levels\\"); strcat(a256_cFileFound,a256_cFileName); remove(a256_cFileFound); } } } } while(FindNextFile( hFind, &stFindData )); FindClose( hFind ); // } //Mihaela Tancu - FIX /* * copy files from gamedata root */ RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); if (bFirstLevel) { strcpy(szTempDir,szBinDirectory); strcpy(szDirName,szCurrentDir); strcat(szDirName,"\\Gamedata"); SAVE_fn_bMoveDirectory(szDirName, szTempDir, FALSE, "*.*"); if (!bDsc) { strcpy(szFile, szDirName); strcat(szFile, "\\Game.dsb"); remove(szFile); } m_fn_ComRes_vWriteLine( " Copy Sound directory\n", C_ComRes_cErrorLine ,&m_oRichEditRes, &m_stCharFormatRes); /* * Copy sound directory */ strcpy(szTempName,szBinDirectory); strcat(szTempName,"\\"); strcat(szTempName,C_World); strcpy(szTempDir, szTempName); strcat(szTempDir,"\\Sound"); // ANNECY MT - 15/02/99 { // Copy GameData Directory strcpy(szDirName,szCurrentDir); strcat(szDirName,"\\GameData\\World\\Sound"); SAVE_fn_bCopyDirectory(szDirName, szTempDir, TRUE, "*.*"); // Copy Specific Directory strcpy(szDirName,szCurrentDir); strcat(szDirName,"\\"); strcat(szDirName,szSoundDirectory); strcat(szDirName,"\\World\\Sound"); SAVE_fn_bCopyDirectory(szDirName, szTempDir, TRUE, "*.*"); // END ANNECY MT } } fn_bDeleteTemporaryFiles(szCurrentDir, szLevelName); RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); SetCurrentDirectory(szDir); return 0; } /* ======================================================================================= Name: OnButtonRelease Description: Function for changing the result directory if the release radio button is set Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnButtonRelease() { char _szMessage[5000]; BOOL bSet=TRUE, bDisplay=FALSE; if (((CButton *)GetDlgItem(IDC_BUTTON_RELEASE))->GetCheck()) { ((CButton *)GetDlgItem(IDC_BUTTON_RELEASE))->SetCheck(1); bDebug = FALSE; /* if (b3DCard) if (bDebug) { if (!SetCurrentDirectory( g_stInitialData.szDestBinDD3D )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDD3D ),"DestBinDD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDD3D); } else { if (!SetCurrentDirectory( g_stInitialData.szDestBinRD3D )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRD3D ),"DestBinRD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRD3D); } else */ if (bDebug) { if (!SetCurrentDirectory( g_stInitialData.szDestBinDDFX )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDDFX ),"DestBinDDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDDFX); } else { if (!SetCurrentDirectory( g_stInitialData.szDestBinRDFX )) GetDlgItem(IDC_EDIT_DESTBIND)->SetWindowText( "" ); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRDFX ),"DestBinRDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRDFX); } GetDlgItem(IDC_EDIT_DESTBIND)->GetWindowText(szDestBinDir, 256); if (!bAuto) // YLG Correction fn_IniData_vGetDatasFromStartFile(TRUE); if (!strcmp(g_stInitialData.szExeFile, "")) GetDlgItem(IDC_EDIT_EXEC)->SetWindowText( "" ); else GetDlgItem(IDC_EDIT_EXEC)->SetWindowText( g_stInitialData.szExeFile ); } } /* ======================================================================================= Name: OnMeasureItem Description: Handle function for message WM_MEASUREITEM Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) { CDialog::OnMeasureItem(nIDCtl, lpMeasureItemStruct); } /* ======================================================================================= Name: OnSelchangeListObject Description: Handle function for message LBN_SELCHANGE in list box with objects Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnSelchangeListObject() { } /* ======================================================================================= Name: OnLButtonDownListBoxObject Description: Handle function for message WM_LBUTTONDOWN on ListBox Name (objects) Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::OnLButtonDownListBoxObject(MSG *pMsg) { CListBox *pLB = m_oListObject; POINT xPos; CRect oRect; BOOL bOutside; int iIndex; BOOL bResult = TRUE; //get the x and y coordinates xPos.x = LOWORD(pMsg->lParam); xPos.y = HIWORD(pMsg->lParam); iIndex = pLB -> ItemFromPoint ( xPos, bOutside ) ; pLB -> GetItemRect ( iIndex , &oRect ) ; if( (oRect . PtInRect ( xPos ) ) && ( xPos.x < 16 ) ) { //determine the object under the cursor in front of which the user clicked GI_Item *p_oItem = (GI_Item*) pLB->GetItemData( iIndex ); ASSERT( p_oItem ) ; //and if the user click in front change the activation (validate/invalidate the activation). if( m_fn_bOnChangeActivation ( p_oItem, iIndex ) ) bResult = TRUE; else bResult = CDialog::PreTranslateMessage(pMsg); } else bResult = CDialog::PreTranslateMessage(pMsg); return bResult; } /* ======================================================================================= Name: OnKeyDownListBoxObject Description: Handle function for message WM_KEYDOWN on ListBox Name (objects) Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::OnKeyDownListBoxObject(MSG *pMsg) { return TRUE; } /* ======================================================================================= Name: OnInitDialog Description: Handle function for message WM_INITDIALOG Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::OnInitDialog() { RECT stRect; RECT stDlgRect; long lDlgWidth; long lDlgHeight; char fVersion[9] = "1.0"; char sConfFile[50]; char sRead[256], *p_char; char sLevels[50][256]; char szSel[50][50]; int iNbSel=0, i, iNbSeq=0; GI_Item *p_oItem; GI_Type *p_oType; char szExeFile[50][256]; char szSource[50][256]; char szDestBinRDFX[50][256]; char sVersion[50][256]; char sOption[25][5]; char sBinAnims[25][5]; char sBinTextures[25][5]; char sBinLevels[25][5]; char sBatch[25][5]; char sAll[25][5]; char sTbl[25][5]; char sBMP[25][5]; char sTGA[25][5]; char sConvert16[25][5]; char sConvert32[25][5]; // CDialog::OnInitDialog(); MLT_vInitSystem(); GetCurrentDirectory(256, sInitialDir); // obtained the height and the width of the main window GetClientRect( &stDlgRect ); lDlgWidth = stDlgRect.right - stDlgRect.left + 1; lDlgHeight = stDlgRect.bottom - stDlgRect.top + 1; // for every edit box in the window save its left position for (int iEdit = 0; iEdit < m_cNbEditBox; iEdit ++) { GetDlgItem(m_a_uiEditControls[iEdit])->GetWindowRect( &stRect ); m_a_iSizeLeft[iEdit] = lDlgWidth - (stRect.right - stRect.left + 1); } /* ======================================================================================= * Create RichEditControl result ======================================================================================= */ // Create a richEdit control in the result panel GetDlgItem( IDC_STATIC_RESULTEDIT)->GetWindowRect( &stRect ); m_oRichEditRes.Create ( WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | ES_AUTOHSCROLL | ES_READONLY, stRect, this, IDC_RICHEDIT_RESULT ); m_oRichEditRes.SetBackgroundColor( FALSE, RGB( 255, 255,255) ); m_oRichEditRes.GetDefaultCharFormat( m_stCharFormatRes ); m_stCharFormatRes.dwEffects = 0; m_stCharFormatRes.crTextColor = RGB(255,255,255); strcpy ( m_stCharFormatRes.szFaceName, "Arial" ); m_stCharFormatRes.dwMask = CFM_COLOR | CFM_BOLD | CFM_FACE; m_oRichEditRes.SetDefaultCharFormat( m_stCharFormatRes ); /* ======================================================================================= * Create RichEditControl command ======================================================================================= */ // the same for the command rich edit control GetDlgItem( IDC_STATIC_COMMANDEDIT)->GetWindowRect( &stRect ); stRect.top -= 23; m_oRichEditCom.Create ( WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | ES_AUTOHSCROLL | ES_READONLY, stRect, this, IDC_RICHEDIT_COMMAND ); m_oRichEditCom.SetBackgroundColor( FALSE, RGB( 255, 255,255) ); m_oRichEditCom.GetDefaultCharFormat( m_stCharFormatCom ); m_stCharFormatCom.dwEffects = 0; m_stCharFormatCom.crTextColor = RGB(0,0,0); strcpy ( m_stCharFormatCom.szFaceName, "Arial" ); m_stCharFormatCom.dwMask = CFM_COLOR | CFM_BOLD | CFM_FACE; m_oRichEditCom.SetDefaultCharFormat( m_stCharFormatCom ); // the position and size of the main window //Mihaela Tancu - New auto strcpy(sConfFile, sInitialDir); strcat(sConfFile, "\\Auto.ini"); FILE *f; if (_access( sConfFile, 0) != -1) // if the configuration file exists { // fn_IniData_vGetDatasFromFile( TRUE ); bAuto = TRUE; // YLG Correction bYes = TRUE; bDsc = TRUE; bBatch = FALSE; bAll = FALSE; bTbl = FALSE; bBMP = FALSE; bTGA = FALSE; bConvert16 = FALSE; bConvert32 = FALSE; // read the file f = fopen(sConfFile, "r"); while(fgets(sRead, 256, f) != NULL) { if (strstr(sRead, "ExeFile")) { strcpy(szExeFile[iNbSeq], sRead+8); szExeFile[iNbSeq][strlen(szExeFile[iNbSeq])-1]='\0'; } if (strstr(sRead, "SourceDir")) { strcpy(szSource[iNbSeq], sRead+10); szSource[iNbSeq][strlen(szSource[iNbSeq])-1]='\0'; } if (strstr(sRead, "DestDir")) { strcpy(szDestBinRDFX[iNbSeq], sRead+8); szDestBinRDFX[iNbSeq][strlen(szDestBinRDFX[iNbSeq])-1]='\0'; } if (strstr(sRead, "Version")) { strcpy(sVersion[iNbSeq], sRead+8); sVersion[iNbSeq][strlen(sVersion[iNbSeq])-1]='\0'; } if (strstr(sRead, "Options")) { strcpy(sOption[iNbSeq], sRead+8); sOption[iNbSeq][strlen(sOption[iNbSeq])-1]='\0'; } if (strstr(sRead, "BinAnims")) { strcpy(sBinAnims[iNbSeq], sRead+9); sBinAnims[iNbSeq][strlen(sBinAnims[iNbSeq])-1]='\0'; } if (strstr(sRead, "Batch")) { strcpy(sBatch[iNbSeq], sRead+6); sBatch[iNbSeq][strlen(sBatch[iNbSeq])-1]='\0'; } if (strstr(sRead, "All")) { strcpy(sAll[iNbSeq], sRead+4); sAll[iNbSeq][strlen(sAll[iNbSeq])-1]='\0'; } if (strstr(sRead, "Tbl")) { strcpy(sTbl[iNbSeq], sRead+4); sTbl[iNbSeq][strlen(sTbl[iNbSeq])-1]='\0'; } if (strstr(sRead, "BinTextures")) { strcpy(sBinTextures[iNbSeq], sRead+12); sBinTextures[iNbSeq][strlen(sBinTextures[iNbSeq])-1]='\0'; } if (strstr(sRead, "BinLevels")) { strcpy(sBinLevels[iNbSeq], sRead+10); sBinLevels[iNbSeq][strlen(sBinLevels[iNbSeq])-1]='\0'; } /* if (strstr(sRead, "Used")) { strcpy(sUsed[iNbSeq], sRead+5); sUsed[iNbSeq][strlen(sUsed[iNbSeq])-1]='\0'; } */ if (strstr(sRead, "BMP")) { strcpy(sBMP[iNbSeq], sRead+4); sBMP[iNbSeq][strlen(sBMP[iNbSeq])-1]='\0'; } if (strstr(sRead, "TGA")) { strcpy(sTGA[iNbSeq], sRead+4); sTGA[iNbSeq][strlen(sTGA[iNbSeq])-1]='\0'; } if (strstr(sRead, "Convert16")) { strcpy(sConvert16[iNbSeq], sRead+10); sConvert16[iNbSeq][strlen(sConvert16[iNbSeq])-1]='\0'; } if (strstr(sRead, "Convert32")) { strcpy(sConvert32[iNbSeq], sRead+10); sConvert32[iNbSeq][strlen(sConvert32[iNbSeq])-1]='\0'; } if (strstr(sRead, "Maps")) { strcpy(sLevels[iNbSeq], sRead); } if (strstr(sRead, "END")) //it is the end of the sequence { iNbSeq++; //get all data // convert the levels } } strcpy(g_stInitialData.szExeFile, szExeFile[0]); strcpy(g_stInitialData.szSource, szSource[0]); strcpy(sSource, g_stInitialData.szSource); // if (!strcmp(sOption[0], "DFX")) { //b3DCard = FALSE; if (!stricmp(sVersion[0], "Debug")) { bDebug = TRUE; strcpy(g_stInitialData.szDestBinDDFX, szDestBinRDFX[0]); strcpy(szDestBinDir, szDestBinRDFX[0]); } else if (!stricmp(sVersion[0], "Release")) { bDebug = FALSE; strcpy(g_stInitialData.szDestBinRDFX, szDestBinRDFX[0]); strcpy(szDestBinDir, szDestBinRDFX[0]); } } /* else if (!strcmp(sOption[0], "D3D")) { b3DCard = TRUE; if (!stricmp(sVersion[0], "Debug")) { bDebug = TRUE; strcpy(g_stInitialData.szDestBinDD3D, szDestBinRDFX[0]); strcpy(szDestBinDir, szDestBinRDFX[0]); } else if (!stricmp(sVersion[0], "Release")) { bDebug = FALSE; strcpy(g_stInitialData.szDestBinRD3D, szDestBinRDFX[0]); strcpy(szDestBinDir, szDestBinRDFX[0]); } } */ if (!strcmp(sBinAnims[0], "1")) { bConvAnim = TRUE; if (!strcmp(sBatch[0], "1")) bBatch = TRUE; else bBatch = FALSE; if (!strcmp(sAll[0], "1")) bAll = TRUE; else bAll = FALSE; if (!strcmp(sTbl[0], "1")) bTbl = TRUE; else bTbl = FALSE; } else bConvAnim = FALSE; if (!strcmp(sBinTextures[0], "1")) { bConvTextures = TRUE; if (!strcmp(sBMP[0], "1")) bBMP = TRUE; else bBMP = FALSE; if (!strcmp(sTGA[0], "1")) bTGA = TRUE; else bTGA = FALSE; if (!strcmp(sConvert16[0], "1")) bConvert16 = TRUE; else bConvert16 = FALSE; if (!strcmp(sConvert32[0], "1")) bConvert32 = TRUE; else bConvert32 = FALSE; } else bConvTextures = FALSE; if (!strcmp(sBinLevels[0], "1")) bConvLevels = TRUE; else bConvLevels = FALSE; /* if (!strcmp(sUsed[0], "1")) bUsed = TRUE; else bUsed = FALSE; */ fclose(f); fn_IniData_vGetWindowPosSize(); if (!bAuto) // YLG Correction fn_IniData_vGetDatasFromStartFile(TRUE); } else //Mihaela Tancu - New auto { bAuto = FALSE; // YLG Correction fn_IniData_vGetDatasFromFile( TRUE ); strcpy(sSource, g_stInitialData.szSource); } m_fn_bWarningUser(); //insert the panels TC_ITEM TabCtrlItem; TabCtrlItem.mask = TCIF_TEXT; TabCtrlItem.pszText = "Directories"; m_oPanel.InsertItem( 0, &TabCtrlItem ); TabCtrlItem.pszText = "Selection"; m_oPanel.InsertItem( 1, &TabCtrlItem ); TabCtrlItem.pszText = "Result"; m_oPanel.InsertItem( 2, &TabCtrlItem ); char szVersion[25], *p_szVersion; p_szVersion = szVersion + GetDlgItem( IDC_STATIC_VERS1)->GetWindowText( szVersion, 20); *p_szVersion++ = ' '; strcpy( p_szVersion, fVersion ); GetDlgItem( IDC_STATIC_VERS1)->SetWindowText( szVersion); // at initializing show only the buttons for the first panel (Directories) m_fn_TabC_vShowControlsPanelDir() ; m_oListType = (CListBox *)GetDlgItem(IDC_LIST1); m_oListObject = (CListBox *)GetDlgItem(IDC_LIST2); m_fn_vUpdateAll(); // show the window with its position and size m_bInit = TRUE; MoveWindow( &g_stWinPosSize.stMainPos ); if (!bDebug) ((CButton *)GetDlgItem(IDC_BUTTON_RELEASE))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_DEBUG))->SetCheck(1); /* if (!b3DCard) ((CButton *)GetDlgItem(IDC_BUTTON_DFX))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_D3D))->SetCheck(1); */ if (!bFix1) ((CButton *)GetDlgItem(IDC_BUTTON_FIX))->SetCheck(0); else ((CButton *)GetDlgItem(IDC_BUTTON_FIX))->SetCheck(1); if (bConvAnim) ((CButton *)GetDlgItem(IDC_BUTTON_CONVANI))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_CONVANI))->SetCheck(0); if (bConvTextures) ((CButton *)GetDlgItem(IDC_BUTTON_CONVTEX))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_CONVTEX))->SetCheck(0); if (bConvLevels) ((CButton *)GetDlgItem(IDC_BUTTON_CONVLEVEL))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_CONVLEVEL))->SetCheck(0); if (bBatch) ((CButton *)GetDlgItem(IDC_BUTTON_USED))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_USED))->SetCheck(0); if (bAll) ((CButton *)GetDlgItem(IDC_BUTTON_A))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_A))->SetCheck(0); if (bTbl) ((CButton *)GetDlgItem(IDC_BUTTON_Z))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_Z))->SetCheck(0); if (bBMP) ((CButton *)GetDlgItem(IDC_BUTTON_BMP))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_BMP))->SetCheck(0); if (bTGA) ((CButton *)GetDlgItem(IDC_BUTTON_TGA))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_TGA))->SetCheck(0); if (bConvert16) ((CButton *)GetDlgItem(IDC_BUTTON_C16))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_C16))->SetCheck(0); if (bConvert32) ((CButton *)GetDlgItem(IDC_BUTTON_C32))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_C32))->SetCheck(0); //Mihaela Tancu - New auto if (bDsc) ((CButton *)GetDlgItem(IDC_BUTTON_BIN))->SetCheck(1); else ((CButton *)GetDlgItem(IDC_BUTTON_BIN))->SetCheck(0); //Mihaela Tancu - New auto GetDlgItem(IDC_EDIT_DESTBIND)->GetWindowText(szDestBinDir, 256); GetDlgItem(IDC_EDIT_EXEC)->SetWindowText(g_stInitialData.szExeFile ); // init others modules (ERM MMG SCR) fn_v_InitMemV6i(); //*** ACP initialisations *** TMP_fn_vFirstInit(); // FIL_fn_vFirstInit(); //Mihaela Tancu - New auto if (bYes) { m_oPanel.SetCurSel(1); m_fn_TabC_vShowControlsPanelSel() ; RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); int iIndex = m_oListType->FindString(-1, "Levels"); if (iIndex==LB_ERR) if (AfxMessageBox( "There is nothing to convert! Please, choose another type of object for conversion", MB_OK)) return FALSE; m_oListType->SetCurSel(iIndex); OnSelchangeListType() ; for (int j=0; jGetCurSel( ); p_oType = (GI_Type *)m_oListType->GetItemData( iIndex ); for (i=0; iFindStringExact( -1, szSel[i] ); if (iIndex == LB_ERR) continue; p_oItem = (GI_Item *)m_oListObject->GetItemData( iIndex ); if (!p_oItem->m_bActived) { p_oType->m_iSelected++; m_iCountOfSelections++; } p_oItem->m_bActived = TRUE; } // after modifying the state of the objects, enable/disable the selection buttons m_fn_vEnableButtonAll(); m_fn_vEnableButtonConvert(); if (p_oType->m_iSelected==m_oListObject->GetCount()) GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(FALSE); else GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(TRUE); if (p_oType->m_iSelected>0) GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_USED)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_A)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_CONVANI)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); GetDlgItem(IDC_BUTTON_AUTO)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected || /*bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled() || bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled()||*/ m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected || m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); m_oListType->Invalidate(TRUE); OnBinarise(); if (j != iNbSeq-1) { strcpy(g_stInitialData.szExeFile, szExeFile[j+1]); strcpy(g_stInitialData.szSource, szSource[j+1]); strcpy(sSource, g_stInitialData.szSource); // strcpy(g_stInitialData.szDestBinRDFX, szDestBinRDFX[j+1]); /* if (!stricmp(sVersion[j+1], "Debug")) { bDebug = TRUE; strcpy(g_stInitialData.szDestBinDDFX, szDestBinRDFX[j+1]); } else if (!stricmp(sVersion[j+1], "Release")) { bDebug = FALSE; strcpy(g_stInitialData.szDestBinRDFX, szDestBinRDFX[j+1]); } strcpy(szDestBinDir, szDestBinRDFX[j+1]); */ // if (!strcmp(sOption[j+1], "DFX")) { //b3DCard = FALSE; if (!stricmp(sVersion[j+1], "Debug")) { bDebug = TRUE; strcpy(g_stInitialData.szDestBinDDFX, szDestBinRDFX[j+1]); strcpy(szDestBinDir, szDestBinRDFX[j+1]); } else if (!stricmp(sVersion[j+1], "Release")) { bDebug = FALSE; strcpy(g_stInitialData.szDestBinRDFX, szDestBinRDFX[j+1]); strcpy(szDestBinDir, szDestBinRDFX[j+1]); } } /* else if (!strcmp(sOption[j+1], "D3D")) { b3DCard = TRUE; if (!stricmp(sVersion[j+1], "Debug")) { bDebug = TRUE; strcpy(g_stInitialData.szDestBinDD3D, szDestBinRDFX[j+1]); strcpy(szDestBinDir, szDestBinRDFX[j+1]); } else if (!stricmp(sVersion[j+1], "Release")) { bDebug = FALSE; strcpy(g_stInitialData.szDestBinRD3D, szDestBinRDFX[j+1]); strcpy(szDestBinDir, szDestBinRDFX[j+1]); } } */ GetDlgItem( IDC_EDIT_SOURCE )->SetWindowText( g_stInitialData.szSource ); GetDlgItem( IDC_EDIT_DESTBIND )->SetWindowText( szDestBinDir ); GetDlgItem( IDC_EDIT_EXEC )->SetWindowText( g_stInitialData.szExeFile ); if (!bDebug) { ((CButton *)GetDlgItem(IDC_BUTTON_RELEASE))->SetCheck(1); ((CButton *)GetDlgItem(IDC_BUTTON_DEBUG))->SetCheck(0); } else { ((CButton *)GetDlgItem(IDC_BUTTON_RELEASE))->SetCheck(0); ((CButton *)GetDlgItem(IDC_BUTTON_DEBUG))->SetCheck(1); } /* if (!b3DCard) { ((CButton *)GetDlgItem(IDC_BUTTON_DFX))->SetCheck(1); ((CButton *)GetDlgItem(IDC_BUTTON_D3D))->SetCheck(0); } else { ((CButton *)GetDlgItem(IDC_BUTTON_DFX))->SetCheck(0); ((CButton *)GetDlgItem(IDC_BUTTON_D3D))->SetCheck(1); } */ if (!strcmp(sBinAnims[j+1], "1")) { bConvAnim = TRUE; if (!strcmp(sBatch[j+1], "1")) { bBatch = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_USED))->SetCheck(1); } else { bBatch = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_USED))->SetCheck(0); } if (!strcmp(sAll[j+1], "1")) { bAll = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_A))->SetCheck(1); } else { bAll = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_A))->SetCheck(0); } if (!strcmp(sTbl[j+1], "1")) { bTbl = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_Z))->SetCheck(1); } else { bTbl = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_Z))->SetCheck(0); } ((CButton *)GetDlgItem(IDC_BUTTON_CONVANI))->SetCheck(1); } else { bConvAnim = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVANI))->SetCheck(0); } if (!strcmp(sBinTextures[j+1], "1")) { bConvTextures = TRUE; if (!strcmp(sBMP[j+1], "1")) { bBMP = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_BMP))->SetCheck(1); } else { bBMP = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_BMP))->SetCheck(0); } if (!strcmp(sTGA[j+1], "1")) { bTGA = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_TGA))->SetCheck(1); } else { bTGA = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_TGA))->SetCheck(0); } if (!strcmp(sConvert16[j+1], "1")) { bConvert16 = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_C16))->SetCheck(1); } else { bConvert16 = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_C16))->SetCheck(0); } if (!strcmp(sConvert32[j+1], "1")) { bConvert32 = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_C32))->SetCheck(1); } else { bConvert32 = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_C32))->SetCheck(0); } ((CButton *)GetDlgItem(IDC_BUTTON_CONVTEX))->SetCheck(1); } else { bConvTextures = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVTEX))->SetCheck(0); } if (!strcmp(sBinLevels[j+1], "1")) { bConvLevels = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVLEVEL))->SetCheck(1); } else { bConvLevels = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVLEVEL))->SetCheck(0); } } //fn_IniData_vSetSource( g_stInitialData.szSource ); } bYes = FALSE; } //Mihaela Tancu - New auto return TRUE; // return TRUE unless you set the focus to a control } /* ======================================================================================= Name: m_fn_vShowPartialWarning Description: Show a message for the directories (if they don't exist or are not set) Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vShowPartialWarning(BOOL bSet, char *szPath, char *_szMessage, BOOL * bDisplay, int iID, char *szDir) { // if bSet, set the text in the edit box // else, inform user that the directory (sub-directory) does not exist if (bSet) GetDlgItem(iID)->SetWindowText( szDir ); else { int iSize= strlen(_szMessage); sprintf( _szMessage+iSize, "\tThe directory %s does not exist (or is not set). Please, choose another %s directory!\n\n", szPath, szPath ); GetDlgItem( iID ) ->SetWindowText( ""); strcpy(szDir, ""); *bDisplay = TRUE; } } /* ======================================================================================= Name: OnHelp Description: Handle function for message BN_CLICKED on Help button Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnHelp() { // TODO: Add your control notification handler code here } /* ======================================================================================= Name: OnSelectAll Description: Handle function for message BN_CLICKED on All button Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnSelectAll() { // TODO: Add your control notification handler code here // select all the objects in all the lists associated with the types // enable (Clear, Clear All, Convert) / disable (All, AllInList) m_fn_vSelectAll(TRUE); m_oListType->Invalidate(TRUE); m_fn_vEnableButtons(TRUE); } /* ======================================================================================= Name: OnSelectAllInList Description: Handle function for message BN_CLICKED on AllInList button Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnSelectAllInList() { //change all the objects in active and enable/disable the buttons for selection m_fn_vSelectAllForType(TRUE); m_fn_vEnableButtonAll(); GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_CLEARALL)->EnableWindow(TRUE); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected) { GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_CONVANI)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_AUTO)->EnableWindow(TRUE); } if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected) /* && bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled() || bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled())*/ GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(TRUE); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled()) { GetDlgItem(IDC_BUTTON_USED)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(TRUE); } if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled()) { GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(TRUE); } if (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) { GetDlgItem(IDC_BUTTON_USED)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(TRUE); } if (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) { GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(TRUE); } if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected /*&& bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled() || bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled()) */|| (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected)) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); } /* ======================================================================================= Name: OnClear Description: Handle function for message BN_CLICKED on Clear button Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnClear() { //change all the objects in the current list to inactive and enable/disable the buttons m_fn_vSelectAllForType(FALSE); m_fn_vEnableButtonConvert(); m_fn_vEnableButtonAll(); GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(TRUE); } /* ======================================================================================= Name: OnClearAll Description: Handle function for message BN_CLICKED on ClearAll button Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnClearAll() { // change the state of all the objects to inactive and enable/disable selections buttons m_fn_vSelectAll(FALSE); m_oListType->Invalidate(TRUE); m_fn_vEnableButtons(FALSE); } /* ======================================================================================= Name: OnQuit Description: Handle function for message BN_CLICKED on Quit button Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnQuit() { // TODO: Add your control notification handler code here if (AfxMessageBox( "Are you sure you want to Quit ?", MB_YESNO | MB_ICONQUESTION) == IDNO) return; CDialog::OnCancel(); } /* ======================================================================================= Name: OnPaint Description: Handle function for message WM_PAINT Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnPaint() { CPaintDC dc(this); // device context for painting CDialog::OnPaint(); } /* ======================================================================================= Name: OnSelchangePanel Description: Handle function for message TCN_SELCHANGE Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnSelchangePanel(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here int nPanel = m_oPanel.GetCurSel(); //before changing the panel 0 to 1 or 2, test if the datas are valid BOOL bResult = m_fn_vTestIniDatas(); // get the current panel and for it show only its controls // and hide the others switch(nPanel) { case 0://the panels with directories m_fn_TabC_vShowControlsPanelDir() ; break; case 1: //the panel with selections if (bResult) { m_fn_TabC_vShowControlsPanelDir() ; m_oPanel.SetCurSel(0); } else m_fn_TabC_vShowControlsPanelSel() ; break; case 2://the panel with the comands and results if (bResult) { m_fn_TabC_vShowControlsPanelDir() ; m_oPanel.SetCurSel(0); } else m_fn_TabC_vShowControlsPanelRes() ; break; } *pResult = 0; } /* ======================================================================================= Name: OnButtonBrowseDestBinD Description: Handle function for message BN_CLICKED on first ... button Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnButtonBrowseDestBinD() { // TODO: Add your control notification handler code here char szPath[ MAX_PATH ], szDir[MAX_PATH], szDir1[MAX_PATH] ; char *p_Char, *p_Char1; char szExeDir[ MAX_PATH ], szDestDir[MAX_PATH]; int i, j, iCounter=0, iCounter1=0; // prepare the structure for the browsing m_fn_vBrowseDirectory(szPath, &i, NULL); if (i) { // set that path for the Game Data directory /* if (b3DCard) { if (bDebug) { fn_IniData_vSetDestBinDD3D( szPath ); strcpy(g_stInitialData.szDestBinDD3D, szPath); } else { fn_IniData_vSetDestBinRD3D( szPath ); strcpy(g_stInitialData.szDestBinRD3D, szPath); } } else */ { if (bDebug) { fn_IniData_vSetDestBinDDFX( szPath ); strcpy(g_stInitialData.szDestBinDDFX, szPath); } else { fn_IniData_vSetDestBinRDFX( szPath ); strcpy(g_stInitialData.szDestBinRDFX, szPath); } } /* ======================================================================================= * write local path in the edit box control ======================================================================================= */ GetDlgItem( IDC_EDIT_DESTBIND )->SetWindowText( szPath ); strcpy(szDestBinDir, szPath); strcpy(g_szStartPrgIniFile, sInitialDir); //sInitialDir is the directory of the exe of the game //szDestBinDir is the directory of the destination data if (g_szStartPrgIniFile[0]==szDestBinDir[0]) //the exe of the game and //the destination directory are on the same drive { if ((p_Char=strstr(szDestBinDir, g_szStartPrgIniFile))!=NULL) //the destination directory is a //sub-directory of the exe directory { strcpy(szDir, szDestBinDir+strlen(sInitialDir)+1); if (g_szStartPrgIniFile[strlen(g_szStartPrgIniFile) - 1] != '\\') strcat( g_szStartPrgIniFile, "\\"); strcat( g_szStartPrgIniFile, C_szStartPrgIniFile ); if (bDebug) fn_IniData_vSetGDDebugBin(szDir); else fn_IniData_vSetGDReleaseBin(szDir); } else { strcpy(szExeDir, sInitialDir+2); p_Char = strstr(szExeDir, "\\"); if (p_Char) { strcpy(szDir, p_Char+1); p_Char1 = strstr(szDir, "\\"); if (p_Char1) szDir[strlen(p_Char)-strlen(p_Char1)-1]='\0'; } strcpy(szDestDir, szDestBinDir+2); p_Char = strstr(szDestDir, "\\"); if (p_Char) { strcpy(szDir1, p_Char+1); p_Char1 = strstr(szDir1, "\\"); if (p_Char1) szDir1[strlen(p_Char)-strlen(p_Char1)-1]='\0'; } while (!stricmp(szDir, szDir1)) { iCounter++; strcpy(szExeDir, szExeDir+strlen(szDir)+1); p_Char = strstr(szExeDir, "\\"); if (p_Char) { strcpy(szDir, p_Char+1); p_Char1 = strstr(szDir, "\\"); if (p_Char1) szDir[strlen(p_Char)-strlen(p_Char1)-1]='\0'; } strcpy(szDestDir, szDestDir+strlen(szDir)+1); p_Char = strstr(szDestDir, "\\"); if (p_Char) { strcpy(szDir1, p_Char+1); p_Char1 = strstr(szDir1, "\\"); if (p_Char1) szDir1[strlen(p_Char)-strlen(p_Char1)-1]='\0'; } } strcpy(szDir, p_Char+1); strcpy(szDir1, sInitialDir); while(p_Char=strstr(szDir1, "\\")) { strcpy(szDir1, p_Char+1); iCounter1++; } strcpy(szDir1, ""); for (j=0; jSetWindowText( szPath ); //remove all the elements in the lists with objects mfn_vFreeMemory(); m_p_oTypeAnims = NULL; m_p_oTypeLevels = NULL; m_p_oTypeTextures = NULL; //reset the contains of the list boxes ((CListBox *)GetDlgItem(IDC_LIST1))->ResetContent(); ((CListBox *)GetDlgItem(IDC_LIST2))->ResetContent(); m_fn_vUpdateAll(); //reset the total number of selections m_iCountOfSelections = 0; } } /* ======================================================================================= Name: OnSize Description: Handle function for message WM_SIZE Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here RECT stRect; CWnd *p_oWnd; int iWnd; long lWidth; if (m_bInit) if (nType != SIZE_MINIMIZED) { /* ======================================================================================= * resize edit box controls ======================================================================================= */ for (iWnd = 0; iWnd < m_cNbEditBox; iWnd ++) { p_oWnd = GetDlgItem( m_a_uiEditControls[iWnd] ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.right = stRect.left + (cx - m_a_iSizeLeft[iWnd]); p_oWnd->MoveWindow(&stRect, FALSE); } /* ======================================================================================= * resize right button controls ======================================================================================= */ for (iWnd = 0; iWnd < m_cNbRightButtons; iWnd ++) { p_oWnd = GetDlgItem( m_a_uiRightButtons[iWnd] ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.right = cx-87; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); } for (iWnd = 0; iWnd < m_cNbRightBut; iWnd ++) { p_oWnd = GetDlgItem( m_a_uiRightBut[iWnd] ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.right = cx-69; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); } /* ======================================================================================= * resize HELP and QUIT button controls ======================================================================================= */ p_oWnd = GetDlgItem( IDC_QUIT ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.bottom = cy - 15; stRect.top = stRect.bottom - 20; stRect.right = cx-27; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_HELPBUTTON ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.bottom = cy - 15; stRect.top = stRect.bottom - 20; stRect.right = cx-117; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); /* ======================================================================================= * resize the groups ======================================================================================= */ for (iWnd = 0; iWnd < m_cNbGroupButtons; iWnd ++) { p_oWnd = GetDlgItem( m_a_uiGroupButtons[iWnd] ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.right = cx-68; p_oWnd->MoveWindow(&stRect, FALSE); } /* ======================================================================================= * resize the panels ======================================================================================= */ p_oWnd = GetDlgItem( IDC_PANEL ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.bottom = cy - 45; stRect.right = cx-27; p_oWnd->MoveWindow(&stRect, FALSE); /* ======================================================================================= * resize the group selection ======================================================================================= */ p_oWnd = GetDlgItem( IDC_STATIC_GRALL ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.right = cx-63; stRect.left = stRect.right - lWidth; long lDim = stRect.left; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_STATIC_OPT ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.right = cx-63; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_STATIC_COPT ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.right = cx-63; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_STATIC_MOPT ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.right = cx-63; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); /* ======================================================================================= * resize the lists ======================================================================================= */ p_oWnd = GetDlgItem( IDC_LIST1 ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.right = cx/3 - 7; stRect.bottom = cy - 65; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_STATIC_LIST1 ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.right = cx/3 - 7; stRect.bottom = cy - 65; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_LIST2 ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.left = cx/3 + 7; stRect.right = lDim-17; stRect.bottom = cy - 65; p_oWnd->MoveWindow(&stRect, FALSE); /* ======================================================================================= * resize the result windows (Command and Result) ======================================================================================= */ p_oWnd = GetDlgItem( IDC_STATIC_VERS1 ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right-stRect.left; stRect.bottom = cy - 10; stRect.top = stRect.bottom - 20; stRect.right = cx-197; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_RICHEDIT_COMMAND ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.right = cx - 57; stRect.bottom = cy/3; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_STATIC_RES ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.top = cy/3 + 17; stRect.bottom = stRect.top + 20; p_oWnd->MoveWindow(&stRect, FALSE); p_oWnd = GetDlgItem( IDC_RICHEDIT_RESULT ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.right = cx - 57; stRect.top = cy/3 + 34; stRect.bottom = cy-85; p_oWnd->MoveWindow(&stRect, FALSE); /* ======================================================================================= * resize Progress Bar ======================================================================================= */ p_oWnd = GetDlgItem( IDC_STATIC_PROGRESS ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.right = cx-64; stRect.left = stRect.right - lWidth; stRect.top=cy-75; stRect.bottom=cy -52; p_oWnd->MoveWindow(&stRect, FALSE); Invalidate(); } } /* ======================================================================================= Name: OnSizing Description: Handle function for message WM_SIZING Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnSizing( UINT nSide, LPRECT lpRect ) { long lWidth = lpRect->right - lpRect->left + 1; long lHeight= lpRect->bottom - lpRect->top + 1; // do not permit to minimize the main window more than // some predefined constants:C_iMainWindowWidth (520) // and C_iMainWindowHeight (423) // the width cannot be less than C_iMainWindowWidth if (lWidth < C_iMainWindowWidth) { switch (nSide) { case WMSZ_LEFT: case WMSZ_TOPLEFT: case WMSZ_BOTTOMLEFT: lpRect->left = lpRect->right - C_iMainWindowWidth; break; case WMSZ_RIGHT: case WMSZ_TOPRIGHT: case WMSZ_BOTTOMRIGHT: lpRect->right = lpRect->left + C_iMainWindowWidth; break; } } // the height cannot be less than C_iMainWindowHeight if (lHeight < C_iMainWindowHeight) { switch (nSide) { case WMSZ_BOTTOM: case WMSZ_BOTTOMLEFT: case WMSZ_BOTTOMRIGHT: lpRect->bottom = lpRect->top + C_iMainWindowHeight; break; case WMSZ_TOP: case WMSZ_TOPLEFT: case WMSZ_TOPRIGHT: lpRect->top = lpRect->bottom - C_iMainWindowHeight; } } CDialog::OnSizing( nSide, lpRect ); } /* ======================================================================================= Name: mfn_vFreeMemoryForType() Description: Freeing all the allocated memory for a type Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::mfn_vFreeMemoryForType(GI_Type **_p_oType) { if (*_p_oType) { int iSize=(*_p_oType)->m_oList.GetCount(); //for all the elements in the list, remove them from list and delete the object for (int i=0; im_oList.RemoveHead(); delete p_oItem; } } if (*_p_oType) delete *_p_oType; } /* ======================================================================================= Name: mfn_vFreeMemory() Description: Freeing all the allocated memory Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::mfn_vFreeMemory() { mfn_vFreeMemoryForType(&m_p_oTypeAnims ) ; mfn_vFreeMemoryForType(&m_p_oTypeLevels ) ; mfn_vFreeMemoryForType(&m_p_oTypeTextures ) ; } /* ======================================================================================= Name: OnSelchangeListType Description: Handle function for message LBN_SELCHANGE on list box with types Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnSelchangeListType() { // TODO: Add your control notification handler code here char szPath[ MAX_PATH ]; //reset the contents of the list box with objects m_oListObject->ResetContent(); int iIndex = m_oListType->GetCurSel(); m_oListType->GetText(iIndex, szPath); GI_Type *p_oType = (GI_Type *)m_oListType->GetItemData(iIndex); // update the list of objects corresponding to the type selected if (m_p_oTypeAnims) m_fn_vUpdateListBox(&m_p_oTypeAnims->m_oList, szPath, "Animations"); if (m_p_oTypeTextures) m_fn_vUpdateListBox(&m_p_oTypeTextures->m_oList, szPath, "Textures"); if (m_p_oTypeLevels) m_fn_vUpdateListBox(&m_p_oTypeLevels->m_oList, szPath, "Levels"); // enable/disable the selection buttons corresponding with the current selections if (p_oType->m_iSelected==m_oListObject->GetCount()) GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(FALSE); else GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(TRUE); if (p_oType->m_iSelected>0) GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(FALSE); } ///////////////////////////////////////////////////////////////////// // Functions ///////////////////////////////////////////////////////////////////// /* ======================================================================================= Name: m_fn_vOnDrawItemListBoxType Description: Function for changing the color of one item in the list box with types Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vOnDrawItemListBoxType(LPDRAWITEMSTRUCT lpDIS) { // TODO: Add your message handler code here and/or call default CDC *p_oDC = CDC::FromHandle(lpDIS->hDC); CBrush oBrush; COLORREF xTextColor; BOOL bSelected = (lpDIS->itemState & ODS_SELECTED ); GI_Type *p_oType= (GI_Type *)m_oListType->GetItemData( lpDIS->itemID ); oBrush.CreateSolidBrush( GetSysColor( bSelected ? COLOR_GRAYTEXT /*COLOR_HIGHLIGHT*/ : COLOR_WINDOW) ); // change the color of the type in the list box according with: // if for that type are no objects selected, draw it in black // if for that type are some objects selected, draw it in blue // if of the type are all the objects selected, draw it in green if (p_oType->m_iSelected == 0) xTextColor = RGB(0, 0,0); //black int iSize = p_oType->m_oList.GetCount() ; if (p_oType->m_iSelected < iSize && p_oType->m_iSelected >0) xTextColor = RGB(0, 0, 255); //blue if (p_oType->m_iSelected == iSize && iSize>0) xTextColor = RGB(0, 127,0); //green p_oType->m_xTextColor = xTextColor; xTextColor = p_oType->m_xTextColor; p_oDC->FillRect( &lpDIS->rcItem, &oBrush ); p_oDC->SetBkMode( TRANSPARENT); p_oDC->SetTextColor( xTextColor ); p_oDC->DrawText( p_oType -> m_fn_p_oGetName(), &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER ); oBrush.DeleteObject(); } /* ======================================================================================= Name: m_fn_vOnDrawItemListBoxObject Description: Function for drawing the cross before of one active item in the list box with objects Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vOnDrawItemListBoxObject(LPDRAWITEMSTRUCT lpDIS) { CDC *pDC = CDC::FromHandle( lpDIS->hDC ); CListBox *pLB = m_oListObject; BOOL bSelected = (lpDIS->itemState & ODS_SELECTED ); GI_Item *p_oItem = (GI_Item*)pLB->GetItemData( lpDIS->itemID ); pDC->FillSolidRect( &lpDIS->rcItem, GetSysColor( COLOR_WINDOW )); //draw a cross in front of an active object if (p_oItem -> m_bActived) pDC->BitBlt( lpDIS->rcItem.left + 2, lpDIS->rcItem.top + 1, 12, 12, &m_oCrossDC, 0, 0, SRCAND ); pDC->SetBkMode( TRANSPARENT); pDC->SetTextColor( GetSysColor( COLOR_WINDOWTEXT ) ); lpDIS->rcItem.left += 16; pDC->DrawText( p_oItem -> m_fn_p_oGetName(), &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER ); //invert lpDIS->rcItem.left -= 1; if (bSelected) pDC->InvertRect( &lpDIS->rcItem ); } /* ======================================================================================= Name: m_fn_TabC_vChangeShowControlsPanelDir Description: Show Or Hide the buttons for the "Directories" tab Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_TabC_vChangeShowControlsPanelDir(BOOL bChange) { // Show or hide the buttons from the first panel // according to the parameter bChange GetDlgItem(IDC_HELPBUTTON)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_BIN)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_DEBUG)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_RELEASE)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_BROWSE2)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_BROWSE3)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_CHANGE)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_RAW)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_GAME)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_GR1)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_GR2)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_EXEC)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_VERS)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_DSC)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_FIX)->ShowWindow(bChange); GetDlgItem(IDC_EDIT_DESTBIND)->ShowWindow(bChange); GetDlgItem(IDC_EDIT_SOURCE)->ShowWindow(bChange); GetDlgItem(IDC_EDIT_EXEC)->ShowWindow(bChange); // GetDlgItem(IDC_BUTTON_D3D)->ShowWindow(bChange); // GetDlgItem(IDC_BUTTON_DFX)->ShowWindow(bChange); if (m_bConversion && bChange) //is conversion GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(FALSE); } /* ======================================================================================= Name: OnConvAnim Description: Handle function for message BN_CLICKED on Convert Animations Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnConvAnim() { if (((CButton *)GetDlgItem(IDC_BUTTON_CONVANI))->GetCheck()) { //if it is checked ... bConvAnim = TRUE; } else { bConvAnim = FALSE; } if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim)) { GetDlgItem(IDC_BUTTON_USED)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(TRUE); } else { GetDlgItem(IDC_BUTTON_USED)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(FALSE); } /* if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && (bConvAnim || bConvTextures))) GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(FALSE); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled() || bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled()|| m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected || m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); */ if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && !bConvAnim && !bConvTextures && !bConvLevels)) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); } /* ======================================================================================= Name: OnUsed Description: Handle function for message BN_CLICKED on Used Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnUsed() { if (((CButton *)GetDlgItem(IDC_BUTTON_USED))->GetCheck()) { //if it is checked ... bBatch = TRUE; } else bBatch = FALSE; } /* ======================================================================================= Name: OnAll Description: Handle function for message BN_CLICKED on Used Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnAll() { if (((CButton *)GetDlgItem(IDC_BUTTON_A))->GetCheck()) { //if it is checked ... bAll = TRUE; } else bAll = FALSE; } /* ======================================================================================= Name: OnTbl Description: Handle function for message BN_CLICKED on Tbl Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnTbl() { if (((CButton *)GetDlgItem(IDC_BUTTON_Z))->GetCheck()) { //if it is checked ... bTbl = TRUE; } else bTbl = FALSE; } /* ======================================================================================= Name: OnFix Description: Handle function for message BN_CLICKED on Fix Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnButtonFix() { if (((CButton *)GetDlgItem(IDC_BUTTON_FIX))->GetCheck()) //if it is checked ... bFix1 = TRUE; else bFix1 = FALSE; } /* ======================================================================================= Name: OnBMP Description: Handle function for message BN_CLICKED on BMP Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnBMP() { if (((CButton *)GetDlgItem(IDC_BUTTON_BMP))->GetCheck()) { //if it is checked ... bBMP = TRUE; } else bBMP = FALSE; } /* ======================================================================================= Name: OnTGA Description: Handle function for message BN_CLICKED on TGA Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnTGA() { if (((CButton *)GetDlgItem(IDC_BUTTON_TGA))->GetCheck()) { //if it is checked ... bTGA = TRUE; } else bTGA = FALSE; } /* ======================================================================================= Name: OnConvert16 Description: Handle function for message BN_CLICKED on Convert16 Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnConvert16() { if (((CButton *)GetDlgItem(IDC_BUTTON_C16))->GetCheck()) { //if it is checked ... bConvert16 = TRUE; } else bConvert16 = FALSE; } /* ======================================================================================= Name: OnConvert32 Description: Handle function for message BN_CLICKED on Convert32 Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnConvert32() { if (((CButton *)GetDlgItem(IDC_BUTTON_C32))->GetCheck()) { //if it is checked ... bConvert32 = TRUE; } else bConvert32 = FALSE; } /* ======================================================================================= Name: OnGenerateAuto Description: Handle function for message BN_CLICKED on Generate auto.ini Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnGenerateAuto() { char szName[_MAX_PATH]; FILE *file; int i, j; BOOL bOK; strcpy(szName, sInitialDir); strcat(szName, "\\Auto.ini"); if (file = fopen(szName, "rt")) //the file exist { strcpy(sMes, "\n\tThe file Auto.ini already exist.\n"); strcat(sMes, "\nSelect yes for adding a sequence to the existing file, or no for creating a new file."); strcpy(sOK, "Yes"); strcpy(sCancel, "No"); CDlgWarning dlgWarning; int nResponse = dlgWarning.DoModal(); if (nResponse == IDOK) { bOK = TRUE; fclose(file); } else if (nResponse == IDCANCEL) { bOK = FALSE; fclose(file); remove(szName); } } if (file=fopen(szName, "at")) { fprintf(file, "ExeFile=%s\n", g_stInitialData.szExeFile); fprintf(file, "SourceDir=%s\n", g_stInitialData.szSource); fprintf(file, "DestDir=%s\n", szDestBinDir); if (bDebug) fprintf(file, "Version=Debug\n"); else fprintf(file, "Version=Release\n"); fprintf(file, "Option=%d\n", bFix1); fprintf(file, "BinAnims=%d\n", bConvAnim); if (bConvAnim) { fprintf(file, "Batch=%d\n", bBatch); fprintf(file, "All=%d\n", bAll); fprintf(file, "Tbl=%d\n", bTbl); } fprintf(file, "BinTextures=%d\n", bConvTextures); if (bConvTextures) { fprintf(file, "BMP=%d\n", bBMP); fprintf(file, "TGA=%d\n", bTGA); fprintf(file, "Convert16=%d\n", bConvert16); fprintf(file, "Convert32=%d\n", bConvert32); } fprintf(file, "BinLevels=%d\n", bConvLevels); fprintf(file, "Maps="); j=0; for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeLevels->m_oList.RemoveHead(); if (p_oItem->m_bActived) { if (!j) { fprintf(file, p_oItem->m_fn_p_oGetName()); j++; } else fprintf(file,",%s", p_oItem->m_fn_p_oGetName()); } m_p_oTypeLevels->m_oList.AddTail(p_oItem); } fprintf(file, "\nEND\n"); fclose(file); } } /* ======================================================================================= Name: OnConvTextures Description: Handle function for message BN_CLICKED on Convert Textures Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnConvTextures() { if (((CButton *)GetDlgItem(IDC_BUTTON_CONVTEX))->GetCheck()) { //if it is checked ... bConvTextures = TRUE; } else bConvTextures = FALSE; if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures)) { GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(TRUE); } else { GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(FALSE); } /* if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && (bConvAnim || bConvTextures))) GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(FALSE); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled() || bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled()|| m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected || m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); */ if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && !bConvAnim && !bConvTextures && !bConvLevels)) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); } /* ======================================================================================= Name: OnConvLevels Description: Handle function for message BN_CLICKED on Convert Levels Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnConvLevels() { if (((CButton *)GetDlgItem(IDC_BUTTON_CONVLEVEL))->GetCheck()) { //if it is checked ... bConvLevels = TRUE; } else bConvLevels = FALSE; if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && !bConvAnim && !bConvTextures && !bConvLevels)) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); } /* ======================================================================================= Name: mfn_vConvAnim Description: Function for setting/resetting the flag telling if the animations are converted or not Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::mfn_vConvAnim() { if (((CButton *)GetDlgItem(IDC_BUTTON_CONVANI))->GetCheck()) { //if it is checked, set the flag bConvAnim = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVANI))->SetCheck(0); } else { //if it is not checked, reset the flag bConvAnim = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVANI))->SetCheck(1); } } /* ======================================================================================= Name: mfn_vConvTextures Description: Function for setting/resetting the flag telling if the textures are converted or not Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::mfn_vConvTextures() { if (((CButton *)GetDlgItem(IDC_BUTTON_CONVTEX))->GetCheck()) { //if it is checked, set the flag bConvTextures = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVTEX))->SetCheck(0); } else { //if it is not checked, reset the flag bConvTextures = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVTEX))->SetCheck(1); } } /* ======================================================================================= Name: mfn_vConvLevels Description: Function for setting/resetting the flag telling if the textures are converted or not Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::mfn_vConvLevels() { if (((CButton *)GetDlgItem(IDC_BUTTON_CONVLEVEL))->GetCheck()) { //if it is checked, set the flag bConvLevels = TRUE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVLEVEL))->SetCheck(0); } else { //if it is not checked, reset the flag bConvLevels = FALSE; ((CButton *)GetDlgItem(IDC_BUTTON_CONVLEVEL))->SetCheck(1); } } /* ======================================================================================= Name: m_fn_TabC_vChangeShowControlsPanelSel Description: Show Or Hide the buttons for the "Selection" tab Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_TabC_vChangeShowControlsPanelSel(BOOL bChange) { // Show or hide the buttons from the second panel // according to the parameter bChange GetDlgItem(IDC_HELPBUTTON)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_ALL)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_GRALL)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_OPT)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_COPT)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_MOPT)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_ALLINLIST)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_CONVERT)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_CONVTEX)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_CONVLEVEL)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_CONVANI)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_USED)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_A)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_Z)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_BMP)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_TGA)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_C16)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_C32)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_AUTO)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_CLEAR)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_CLEARALL)->ShowWindow(bChange); GetDlgItem(IDC_BUTTON_CONVANI)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& m_iCountOfSelections && (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected/* && (bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled()) || (bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled())*/) || (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected)); GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected /*&& (bConvAnim || bConvTextures)*/)); // YLG Correction GetDlgItem(IDC_BUTTON_USED)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_A)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_AUTO)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& m_iCountOfSelections); GetDlgItem(IDC_BUTTON_CLEARALL)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& m_iCountOfSelections); if (bChange) { // show/hide the buttons or enable/disable buttons GetDlgItem(IDC_LIST1)->ShowWindow(!(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()==0)); GetDlgItem(IDC_STATIC_LIST1)->ShowWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()==0); GetDlgItem(IDC_LIST2)->ShowWindow(!((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()==0); GetDlgItem(IDC_BUTTON_ALL)->EnableWindow(!((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()==0); GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(!((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()==0); } else { GetDlgItem(IDC_LIST1)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_LIST1)->ShowWindow(bChange); GetDlgItem(IDC_LIST2)->ShowWindow(bChange); } GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(FALSE); } /* ======================================================================================= Name: m_fn_TabC_vChangeShowControlsPanelRes Description: Show Or Hide the buttons for the "Result" tab Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_TabC_vChangeShowControlsPanelRes(BOOL bChange) { // Show or hide the buttons from the third panel // according to the parameter bChange GetDlgItem(IDC_HELPBUTTON)->EnableWindow(FALSE); GetDlgItem(IDC_STATIC_RES)->ShowWindow(bChange); GetDlgItem(IDC_STATIC_COM)->ShowWindow(bChange); GetDlgItem(IDC_RICHEDIT_COMMAND)->ShowWindow(bChange); GetDlgItem(IDC_RICHEDIT_RESULT)->ShowWindow(bChange); if (m_bConversion && bChange) //is conversion GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(TRUE); } /* ======================================================================================= Name: m_fn_TabC_vShowControlsPanelDir Description: Show only the buttons for the "Directories" tab Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_TabC_vShowControlsPanelDir() { // when is selected the first panel show only its controls m_fn_TabC_vChangeShowControlsPanelDir(TRUE); m_fn_TabC_vChangeShowControlsPanelSel(FALSE); m_fn_TabC_vChangeShowControlsPanelRes(FALSE); } /* ======================================================================================= Name: m_fn_TabC_vShowControlsPanelSel Description: Show only the buttons for the "Selection" tab Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_TabC_vShowControlsPanelSel() { // when is selected the second panel show only its controls m_fn_TabC_vChangeShowControlsPanelDir(FALSE); m_fn_TabC_vChangeShowControlsPanelSel(TRUE); m_fn_TabC_vChangeShowControlsPanelRes(FALSE); } /* ======================================================================================= Name: m_fn_TabC_vShowControlsPanelRes Description: Show only the buttons for the "Result" tab Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_TabC_vShowControlsPanelRes() { // when is selected the third panel show only its controls m_fn_TabC_vChangeShowControlsPanelDir(FALSE); m_fn_TabC_vChangeShowControlsPanelSel(FALSE); m_fn_TabC_vChangeShowControlsPanelRes(TRUE); } /* ======================================================================================= Name: m_fn_ComRes_vWriteLine Description: Add a line of the specified color in the rich edit box specified Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_ComRes_vWriteLine( char *szLine, char cLineType ,CRichEditCtrl* _oRichEdit, CHARFORMAT* _stCharFormat) { long lOldLength; long lNewLength; long lSize; _stCharFormat->crTextColor = gs_a_xLineColor[ cLineType ]; _stCharFormat->dwEffects = 0; // write a line in the rich edit control // with different color (red or black) for Ok or for Error lOldLength = _oRichEdit->GetTextLength(); lNewLength = lOldLength + strlen( szLine ); lSize = _oRichEdit->GetLimitText(); if (lNewLength > lSize) { lSize += 10000; _oRichEdit->LimitText( lSize ); } _oRichEdit->ReplaceSel( szLine ); _oRichEdit->SetSel( lOldLength, -1 ); _oRichEdit->SetSelectionCharFormat( *_stCharFormat ); _oRichEdit->SetSel( lNewLength, lNewLength ); } /* ======================================================================================= Name: m_fn_ComRes_vDeleteLines Description: Delete all the text in the rich edir box control Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_ComRes_vDeleteLines( CRichEditCtrl *_oRichEdit) { //delete the content of the rich edit control (result and command) _oRichEdit->SetWindowText( "" ); } /* ======================================================================================= Name: m_fn_vChange Description: Change the state of one object (item), and the total/local number of selections Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vChange(GI_Item *p_oItem, GI_Type *p_oType, BOOL bSet ) { // set/reset the state of the object, // increment/decrement the local (p_oType->m_iSelected) and // total number of selections (m_iCountOfSelections) if (!bSet) { p_oItem->m_bActived = TRUE; m_iCountOfSelections++; p_oType->m_iSelected++; } else { p_oItem->m_bActived = FALSE; m_iCountOfSelections--; p_oType->m_iSelected--; } } /* ======================================================================================= Name: m_fn_bOnChangeActivation Description: Change the state of an object similar with the selection from the vss checkout window under visual c Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::m_fn_bOnChangeActivation(GI_Item *_p_oItem, int iIndexItem ) { BOOL bResult = TRUE; CListBox *pLB = m_oListObject; int iNbSel = pLB -> GetSelCount(); GI_Item *p_oItem; int iIndex = m_oListType->GetCurSel(); GI_Type *p_oType = (GI_Type *)m_oListType->GetItemData(iIndex); int iSize = p_oType->m_oList.GetCount(); if( iNbSel > 0 ) { // if there are selection(s) in the list box int *a_iSel = (int*) malloc( iNbSel * sizeof( int ) ); pLB -> GetSelItems( iNbSel, a_iSel ); if ( iNbSel == 1 ) { // only one selection p_oItem = (GI_Item *) pLB -> GetItemData( a_iSel[0] ); // change the state of the item in front of which the user clicked if (p_oItem==_p_oItem) m_fn_vChange(p_oItem, p_oType, p_oItem->m_bActived ); else m_fn_vChange(_p_oItem, p_oType, _p_oItem->m_bActived ); pLB->Invalidate(TRUE); } else // several objects selected { BOOL bActivate = ! _p_oItem -> m_bActived; GI_Item **p_oItemMul; p_oItemMul = (GI_Item **)malloc (iNbSel * sizeof( GI_Item* ) ); BOOL bIs=FALSE; for ( int iIndex = 0 ; iIndex < iNbSel ; iIndex++ ) { p_oItemMul[iIndex] = (GI_Item *) pLB -> GetItemData( a_iSel[iIndex] ); if (p_oItemMul[iIndex]==_p_oItem) bIs = TRUE; } for (iIndex = 0 ; iIndex < iNbSel ; iIndex++ ) { if (bIs) //if the user clicked in front of one of the selected items { if( !bActivate && p_oItemMul[iIndex] -> m_bActived ) { p_oItemMul[iIndex]->m_bActived = FALSE; m_iCountOfSelections--; p_oType->m_iSelected--; } else if (bActivate && !p_oItemMul[iIndex] -> m_bActived ) { p_oItemMul[iIndex]->m_bActived = TRUE; m_iCountOfSelections++; p_oType->m_iSelected++; } } pLB->Invalidate(TRUE); } // if the user clicked in front of an item which is not // selected if (!bIs) m_fn_vChange(_p_oItem, p_oType, _p_oItem->m_bActived ); } free( a_iSel ); // after modifying the state of the objects, enable/disable the selection buttons m_fn_vEnableButtonAll(); m_fn_vEnableButtonConvert(); if (p_oType->m_iSelected==m_oListObject->GetCount()) GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(FALSE); else GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(TRUE); if (p_oType->m_iSelected>0) GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_USED)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_A)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim) ); GetDlgItem(IDC_BUTTON_CONVANI)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_AUTO)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount() && (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures) ); GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(((CListBox *)GetDlgItem(IDC_LIST1))->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected/* && bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled() || bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled()*/|| m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected || m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); } m_oListType->Invalidate(TRUE); return bResult ; } /* ======================================================================================= Name: m_fn_bWarningUser Description: Inform the user, if the exe file and the directories does not exist or are not set Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::m_fn_bWarningUser() { //init the strings for the edit box controls char _szMessage[5000]; BOOL bSet=TRUE, bDisplay=FALSE; // tests if the local path for the executable file exists, if not inform user and set it to c: // if the executable file does not exist inform the user to choose an executable file //tests all the directories if they exist sprintf( _szMessage,"Warning(s) : \n\n"); int iSize= strlen(_szMessage); /* if (b3DCard) if (bDebug) m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDD3D ),"DestBinDD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDD3D); else m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRD3D ),"DestBinRD3D", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRD3D); else */ if (bDebug) m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinDDFX ),"DestBinDDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinDDFX); else m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szDestBinRDFX ),"DestBinRDFX", _szMessage, &bDisplay, IDC_EDIT_DESTBIND, g_stInitialData.szDestBinRDFX); m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szSource ),"Source", _szMessage, &bDisplay, IDC_EDIT_SOURCE, g_stInitialData.szSource); if (!m_fn_bExistDirectories(g_stInitialData.szSource)) sprintf( _szMessage,"\tYou have to select another source directory, because it does not contain any directories !\n\n"); if (bDisplay) AfxMessageBox( _szMessage, MB_OK | MB_ICONSTOP ); return bDisplay; } /* ======================================================================================= Name: m_fn_vTestIniDatas Description: Call the function m_fn_bWarningUser Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::m_fn_vTestIniDatas() { return m_fn_bWarningUser(); } /* ======================================================================================= Name: m_fn_vUpdateListBox Description: Add the objects from the list with objects to the list box with objects Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vUpdateListBox(CList *_oListObjects, char *szPath, char *szType) { GI_Item *p_oItem; int iSize=_oListObjects->GetCount(); // only if the szPath is the same as szType if (!strcmp(szPath, szType)) { for (int i=0; iRemoveHead(); int iIndex = m_oListObject -> AddString(p_oItem->m_fn_p_oGetName()); if( iIndex != LB_ERR ) m_oListObject -> SetItemData( iIndex, (DWORD) p_oItem ); _oListObjects->AddTail(p_oItem); } // implicitly the first object in the second list box is selected!!! m_oListObject -> SetSel( 0); } } /* ======================================================================================= Name: m_fn_iAddTestDirType Description: Find the number of elements for a type (written, because is possible to have a Banks directory which can contain directories instead of files *.mod and in this way it appeared in the list without any elements. Using this function every type appears in the list box only if it contained the corresponding data!!! Author: Mihaela Tancu ======================================================================================= */ int CDlgMain::m_fn_iAddTestDirType(char* szFiles) { HANDLE hHandle; WIN32_FIND_DATA stFindFileData; if (!m_fn_bGetFiles(szFiles, &hHandle, &stFindFileData)) return 0; int iTypes=0; // determine if in the directory is something useful for the selected type do if(stFindFileData.dwFileAttributes) { if(strlen(stFindFileData.cFileName) == 0) break; if(strcmp(stFindFileData.cFileName, ".") == 0) continue; if(strcmp(stFindFileData.cFileName, "..") == 0) continue; iTypes++; } while(FindNextFile(hHandle, &stFindFileData)); // return the number of the useful information FindClose(hHandle); return iTypes; } /* ======================================================================================= Name: m_fn_vSetTypeInList Description: If the number of useful information is not null, add that type in the list box with types Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vSetTypeInList(GI_Type ** _p_oType, char *szType, int iNumber) { if (m_oListType->FindString(-1, szType)==LB_ERR ) { if (iNumber) { // only if the iNumber is not equal to 0 int iIndex = m_oListType -> AddString(szType); GI_Type *p_oType = new GI_Type(szType, 0, RGB(0, 0, 0)); if( iIndex != LB_ERR ) { // add the new type in the list box with types m_oListType -> SetItemData( iIndex, (DWORD) p_oType ); *_p_oType = p_oType; } } } } /* ======================================================================================= Name: m_fn_vAddType Description: Add a type in the list box with types Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vAddType(GI_Type * p_oType, char *szReturn, char *szType, char *szDir, int *iNumber) { char _szType[MAX_PATH]; strcpy(_szType, g_stInitialData.szSource); strcat (_szType, szDir); if (SetCurrentDirectory(_szType)) { // if the directory exist // if the directory contain datas (directories for anims, families and levels, // or files *.mod for banks and classes !!! int iTextures=0, iAnims=0, iLevels=0; // for Anims if (!strcmp(szType, "Animations")) { iAnims=m_fn_iAddTestDirType("*.*"); m_fn_vSetTypeInList(&m_p_oTypeAnims, szType, iAnims); } // for Textures if (!strcmp(szType, "Textures")) { iTextures=m_fn_iAddTestDirType("*.*"); m_fn_vSetTypeInList(&m_p_oTypeTextures, szType, iTextures); } // for Levels if (!strcmp(szType, "Levels")) { iLevels=m_fn_iAddTestDirType("*.*"); m_fn_vSetTypeInList(&m_p_oTypeLevels, szType, iLevels); } (*iNumber)++; // increment the number of types } strcpy(szReturn, _szType); } /* ======================================================================================= Name: m_fn_vGetAllTypes Description: Get all types for the list box with types. Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vGetAllTypes() { char szAnims[MAX_PATH]; char szTextures[MAX_PATH]; char szLevels[MAX_PATH]; int iNumber=0; // set all the lists with objects m_fn_vAddType(m_p_oTypeAnims, szAnims, "Animations","\\World\\Levels\\_Common\\Families" , &iNumber); m_fn_vAddType(m_p_oTypeTextures, szTextures, "Textures","\\World\\Graphics\\Textures" , &iNumber); m_fn_vAddType(m_p_oTypeLevels, szLevels, "Levels","\\World\\Levels" , &iNumber); if (!iNumber ) // in the list boxes will be nothing, so reset its contents { ((CListBox *)GetDlgItem(IDC_LIST1))->ResetContent(); ((CListBox *)GetDlgItem(IDC_LIST2))->ResetContent(); } m_fn_vGetSetDatasInList(szAnims, szTextures, szLevels); } /* ======================================================================================= Name: m_fn_vGetSetDatasInList Description: Get the datas from the directories and set the lists with objects Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vGetSetDatasInList( char *szAnims, char *szTextures, char *szLevels) { if (m_oListType->GetCount()) { // get all datas for all the existing types in the list box with types m_fn_vGetDatas(strcat(szAnims, "\\*.*")); m_fn_vGetDatas(strcat(szLevels, "\\*.*")); m_fn_vGetDatas(strcat(szTextures, "\\*.*")); } } /* ======================================================================================= Name: m_fn_vCreateLists Description: Add an item to the list, if is satisfied the following condition: the string szAnims is found in szPath Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vCreateLists( CList *_oListObject, char *szPath, char *szType, GI_Item * _p_oItem ) { char *Pdest = strstr( szPath, szType ); if (!Pdest) return; if ((Pdest!=NULL) && (strstr(Pdest, "_Common"))) return; // add an item to the list, if the szAnims is found in // the szPath string if (!_p_oItem) return; if ( Pdest != NULL ) _oListObject -> AddTail( _p_oItem); } /* ======================================================================================= Name: m_fn_vGetDatas Description: Get all datas (objects) for all the types Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vGetDatas(char *szPath) { HANDLE hHandle; WIN32_FIND_DATA stFindFileData; if (!m_fn_bGetFiles(szPath, &hHandle, &stFindFileData)) return; // get the datas for the banks and classes // get the datas for the anims, textures and levels do if(stFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if(strlen(stFindFileData.cFileName) == 0) break; if(strcmp(stFindFileData.cFileName, ".") == 0) continue; if(strcmp(stFindFileData.cFileName, "..") == 0) continue; if (m_oListObject -> FindString(-1,stFindFileData.cFileName)== LB_ERR ) { // create the lists with objects associated with a type, by looking in the // directory and taking the names of the files it contains. GI_Item * p_oItem = new GI_Item(FALSE, stFindFileData.cFileName); if (m_p_oTypeAnims) m_fn_vCreateLists(&m_p_oTypeAnims->m_oList, szPath, "Families", p_oItem); if (m_p_oTypeTextures) m_fn_vCreateLists(&m_p_oTypeTextures->m_oList, szPath, "Textures", p_oItem); if (m_p_oTypeLevels && strcmp(p_oItem->m_szName, "_Common")&& strcmp(p_oItem->m_szName, "_common")) m_fn_vCreateLists(&m_p_oTypeLevels->m_oList, szPath, "Levels", p_oItem); if (!strcmp(p_oItem->m_szName, "_Common") || !strcmp(p_oItem->m_szName, "_common")) delete p_oItem; } } while(FindNextFile(hHandle, &stFindFileData)); FindClose(hHandle); } /* ======================================================================================= Name: m_fn_iGetAllFamilies Description: Get the total number of animations Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_iGetAllFamilies(GI_Item * p_oItem) { int i; char szFile[500]; sprintf(szFile, "%s\\World\\Levels\\%s\\%s.alw", g_stInitialData.szSource, p_oItem->m_szName, p_oItem->m_szName); MLT_vLoadALWFileInLib(szFile); for(i=0; im_oListOfFamilies.IsEmpty() && !p_oItem->m_oListOfFamilies.Find(g_hAlwaysInFile[i]->sLinkCharacter)) p_oItem->m_oListOfFamilies.AddTail(g_hAlwaysInFile[i]->sLinkCharacter); else if (p_oItem->m_oListOfFamilies.IsEmpty()) p_oItem->m_oListOfFamilies.AddTail(g_hAlwaysInFile[i]->sLinkCharacter); sprintf(szFile, "%s\\World\\Levels\\%s\\%s.lvl", g_stInitialData.szSource, p_oItem->m_szName, p_oItem->m_szName); MLT_vLoadLVLFileInLib(szFile); for(i=0; im_oListOfFamilies.IsEmpty() && !p_oItem->m_oListOfFamilies.Find(g_hInsertCharacterInFile[i]->sLinkCharacter)) p_oItem->m_oListOfFamilies.AddTail(g_hInsertCharacterInFile[i]->sLinkCharacter); else if (p_oItem->m_oListOfFamilies.IsEmpty()) p_oItem->m_oListOfFamilies.AddTail(g_hInsertCharacterInFile[i]->sLinkCharacter); } /* ======================================================================================= Name: m_fn_iGetAllAnimations Description: Get the total number of animations Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_iGetAllAnimations(GI_Item * p_oItem) { int i; char szFile[500]; sprintf(szFile, "%s\\World\\Levels\\_Common\\Families\\%s\\%s.sta", g_stInitialData.szSource, p_oItem->m_szName, p_oItem->m_szName); MLT_vLoadSTAFileInLib(szFile); for(i=0; isAnimation, "") && !p_oItem->m_oListOfAnimations.IsEmpty() && (!p_oItem->m_oListOfAnimations.Find(g_hAnimInFile[i]->sAnimation))) p_oItem->m_oListOfAnimations.AddTail(g_hAnimInFile[i]->sAnimation); else if (p_oItem->m_oListOfAnimations.IsEmpty()) p_oItem->m_oListOfAnimations.AddTail(g_hAnimInFile[i]->sAnimation); } } /* ======================================================================================= Name: m_fn_iGetAllObjects Description: Get the total number of objects in all lists Author: Mihaela Tancu ======================================================================================= */ int CDlgMain::m_fn_iGetAllObjects() { int iResult=0; // for all the types in the list box with types, add the size of the list box at the iResult if (m_p_oTypeAnims) iResult = m_p_oTypeAnims->m_oList.GetCount(); if (m_p_oTypeTextures) iResult += m_p_oTypeTextures->m_oList.GetCount(); if (m_p_oTypeLevels) iResult += m_p_oTypeLevels->m_oList.GetCount(); return iResult; } /* ======================================================================================= Name: m_fn_vSelectAllInList Description: Select/deselect the items in the list according with the parameter bSet Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vSelectAllInList(GI_Type * _p_oType, BOOL bSet) { int iSize, j=0; if (_p_oType) { iSize = _p_oType->m_oList.GetCount(); // for all the items (objects) in the list box, make them active/inactive according to the bSet flag. for (int i=0; i< iSize; i++) { GI_Item *p_oItem = _p_oType->m_oList.RemoveHead(); if (p_oItem->m_bActived) j++; p_oItem->m_bActived = bSet; _p_oType->m_oList.AddTail(p_oItem); } // modify the number of selected objects in the list according with the flag bSet if (bSet) _p_oType->m_iSelected = _p_oType->m_oList.GetCount(); else _p_oType->m_iSelected = 0; m_oListObject->Invalidate(TRUE); // update the total number of selections (for all the lists with objects) if (bSet) m_iCountOfSelections += iSize - j; else m_iCountOfSelections -= j; //Size; } } /* ======================================================================================= Name: m_fn_vSelectAll Description: Select/deselect all the objects in all lists according with parameter bSet Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vSelectAll(BOOL bSet) { // call the function for all the existing types in the list box // with type m_fn_vSelectAllInList(m_p_oTypeAnims, bSet); m_fn_vSelectAllInList(m_p_oTypeLevels, bSet); m_fn_vSelectAllInList(m_p_oTypeTextures, bSet); } /* ======================================================================================= Name: m_fn_vEnableButtons Description: Modify the state of the selection buttons Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vEnableButtons(BOOL bSet) { // enable/disable selections buttons according to bSet GetDlgItem(IDC_BUTTON_ALLINLIST)->EnableWindow(!bSet); GetDlgItem(IDC_BUTTON_ALL)->EnableWindow(!bSet); GetDlgItem(IDC_BUTTON_CLEAR)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_CLEARALL)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_CONVANI)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_USED)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_A)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(bSet); GetDlgItem(IDC_BUTTON_AUTO)->EnableWindow(bSet); } /* ======================================================================================= Name: m_fn_vSelectAllForType Description: Select all the items (objects) for a selected type and change the color of the type (if it is necessary) Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vSelectAllForType(BOOL bSet) { char szPath[MAX_PATH]; // get the selected type int iIndex = m_oListType->GetCurSel(); m_oListType->GetText(iIndex, szPath); GI_Type *p_oType = (GI_Type *)m_oListType->GetItemData(iIndex); // for the selected type, select all its objects m_fn_vSelectAllInList(p_oType, bSet); m_oListType->Invalidate(TRUE); } /* ======================================================================================= Name: m_fn_bGetFiles Description: Test if the directory contain any data Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::m_fn_bGetFiles(char *szFile, HANDLE *hHandle, WIN32_FIND_DATA *stFindFileData) { memset(&(*stFindFileData),0,sizeof(*stFindFileData)); *hHandle = FindFirstFile(szFile, &(*stFindFileData)); //return a boolean for telling if some files *.* exists in the directory or not if( *hHandle == INVALID_HANDLE_VALUE) return FALSE; return TRUE; } /* ======================================================================================= Name: m_fn_vEnableButtonAll Description: Change the state of the button All Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vEnableButtonAll() { // enable/disable the All button according to total number of selections if (m_iCountOfSelections==m_fn_iGetAllObjects()) GetDlgItem(IDC_BUTTON_ALL)->EnableWindow(FALSE); else GetDlgItem(IDC_BUTTON_ALL)->EnableWindow(TRUE); } /* ======================================================================================= Name: m_fn_vEnableButtonConvert Description: Change the state for the Convert and Clear all buttons Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vEnableButtonConvert() { // enable/disable the All button according to total number of selections if (!m_iCountOfSelections) { GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_CONVANI)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_CLEARALL)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_USED)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_AUTO)->EnableWindow(FALSE); } else { // YLG Correction /* if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected) GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(FALSE); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && (bConvAnim || bConvTextures)) GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(FALSE); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected) { GetDlgItem(IDC_BUTTON_CONVANI)->EnableWindow(TRUE); } else { GetDlgItem(IDC_BUTTON_CONVANI)->EnableWindow(FALSE); } if ((m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim)) { GetDlgItem(IDC_BUTTON_USED)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(TRUE); } else { GetDlgItem(IDC_BUTTON_USED)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(FALSE); } if ((m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures)) { GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(TRUE); } else { GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(FALSE); } if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim && GetDlgItem(IDC_BUTTON_CONVANI)->IsWindowEnabled() || bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled()|| m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected || m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_CLEARALL)->EnableWindow(TRUE); */ if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected) { GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_AUTO)->EnableWindow(TRUE); } else { GetDlgItem(IDC_BUTTON_CONVLEVEL)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_AUTO)->EnableWindow(FALSE); } if ((m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvAnim)) { GetDlgItem(IDC_BUTTON_USED)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(TRUE); } else { GetDlgItem(IDC_BUTTON_USED)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_A)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_Z)->EnableWindow(FALSE); } if ((m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && bConvTextures)) { GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(TRUE); } else { GetDlgItem(IDC_BUTTON_BMP)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_TGA)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_C16)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_C32)->EnableWindow(FALSE); } if (bConvTextures) GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVTEX)->EnableWindow(FALSE); if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected || // bConvTextures && GetDlgItem(IDC_BUTTON_CONVTEX)->IsWindowEnabled()|| m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected || m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_CONVERT)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_CLEARALL)->EnableWindow(TRUE); } } /* ======================================================================================= Name: m_fn_vBrowseDirectory() Description: browse the directory Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vBrowseDirectory(char* szPath, int *p_iResult, ITEMIDLIST *p_stItemRoot) { BROWSEINFO stBI; ITEMIDLIST *p_stItem; char szDisplayName[ MAX_PATH ]; // prepare the structure for the browsing stBI.hwndOwner = this->GetSafeHwnd(); stBI.pidlRoot = p_stItemRoot; stBI.pszDisplayName = szDisplayName; stBI.lpszTitle = "Choose Target Path"; stBI.ulFlags = 0; stBI.lpfn = NULL; *p_iResult = 0; if ((p_stItem = SHBrowseForFolder( &stBI )) != NULL) { // obtain the new path SHGetPathFromIDList( p_stItem, szPath ); *p_iResult = 1; } } /* ======================================================================================= Name: m_fn_bExistDirectories Description: Test if in a given directory are any directories (used for RawData directory, it have to have sub-directories) Author: Mihaela Tancu ======================================================================================= */ BOOL CDlgMain::m_fn_bExistDirectories(char *_szPath) { int i=0; char szPath[MAX_PATH]; strcpy(szPath, _szPath); strcat (szPath, "\\*"); HANDLE hHandle; WIN32_FIND_DATA stFindFileData; if (!m_fn_bGetFiles(szPath, &hHandle, &stFindFileData)) return FALSE; // if there is a directory different from . and .. than increment // the number of the sub-directories do if(stFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if(strcmp(stFindFileData.cFileName, ".") == 0) continue; if(strcmp(stFindFileData.cFileName, "..") == 0) continue; i++; } while(FindNextFile(hHandle, &stFindFileData)); FindClose(hHandle); return i; } /* ======================================================================================= Name: m_fn_vUpdateAll Description: Update all the datas Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::m_fn_vUpdateAll() { m_fn_vGetAllTypes(); // select the first type in the list box m_oListType->SetCurSel( 0 ); char szPath[MAX_PATH]; m_oListType->GetText(0, szPath); // update the lists with objects (for the existing types). if (m_p_oTypeAnims) m_fn_vUpdateListBox(&m_p_oTypeAnims->m_oList, szPath, "Animations"); if (m_p_oTypeLevels) m_fn_vUpdateListBox(&m_p_oTypeLevels->m_oList, szPath, "Levels"); if (m_p_oTypeTextures) m_fn_vUpdateListBox(&m_p_oTypeTextures->m_oList, szPath, "Textures"); } /* ======================================================================================= Name: OnButtonBrowseExeFile Description: Handle function for message BN_CLICKED on Change button Author: Mihaela Tancu ======================================================================================= */ void CDlgMain::OnButtonBrowseExeFile() { // TODO: Add your control notification handler code here static char BASED_CODE szFilter[] = "Executable file(*.exe)|*.exe||"; char szFileName[ _MAX_PATH ]; char *p_szShortName; DWORD dwFlags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; CFileDialog oFD( TRUE, "exe", g_stInitialData.szExeFile, dwFlags, szFilter, this); // changing the executable file if (SetCurrentDirectory( sInitialDir )) { if (oFD.DoModal() == IDOK) { strcpy ( szFileName, (char *) (LPCTSTR) oFD.GetPathName() ); // obtain the name of the executable without its path p_szShortName = strrchr(szFileName,'\\'); if( p_szShortName ) { *p_szShortName = '\0'; p_szShortName++; } else p_szShortName = szFileName; // after obtaining the local path and the name of the executable file // set this value in the variable for it:g_stInitialData.szLocalPath // and set the new name of the executable in edit box control if (stricmp(szFileName, sInitialDir)) //_access( p_szShortName, 0) == -1)) //the file does not exist strcpy(p_szShortName, g_stInitialData.szExeFile); if (bDebug) fn_IniData_vSetSPDebug( p_szShortName ); else fn_IniData_vSetSPRelease( p_szShortName ); strcpy( g_stInitialData.szExeFile, p_szShortName); GetDlgItem( IDC_EDIT_EXEC )->SetWindowText( p_szShortName ); } } }