reman3/Rayman_X/cpa/Appli/Max23Dos/Win_M23D/src/DlgMain3.cpp

2589 lines
89 KiB
C++

/*=========================================================================
*
* DlgMain3.cpp - implementation file for main window class
* Other functions
*
* Version 1.0
* Revision date
*
*=======================================================================*/
#include <io.h>
#include <fcntl.h>
#include "stdafx.h"
#include "DlgMain.h"
#include "system.h"
#include "print.h"
#include "IniData.h"
//---------------------------------------------------------------------------
//==================================================//
// WARNINGS //
//==================================================//
/****************************************************************************
* Description: all the function m_fn_bWarningUser
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
BOOL CDlgMain::m_fn_vTestIniDatas()
{
return m_fn_bWarningUser();
}
/****************************************************************************
* Description: Inform the user, if the exe file and the directories does not exist or are not set
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
BOOL CDlgMain::m_fn_bWarningUser()
{
//init the strings for the edit box controls
BOOL bDisplay = FALSE;
char _szMessage[500];
char szPath[MAX_PATH];
xString sDir;
if(!m_bConversion)
{
sprintf( _szMessage,"Warning(s) : \n\n");
int iSize= strlen(_szMessage);
GetCurrentDirectory(256, sDir);
//tests all the directories if they exist
if (SetCurrentDirectory( g_stInitialData.szGameSpecific1 ))
GetDlgItem(IDC_EDIT_GAMESPECIFIC1)->SetWindowText( g_stInitialData.szGameSpecific1 );
if (SetCurrentDirectory( g_stInitialData.szGameSpecific2 ))
GetDlgItem(IDC_EDIT_GAMESPECIFIC2)->SetWindowText( g_stInitialData.szGameSpecific2 );
if (SetCurrentDirectory( g_stInitialData.szRawSpecific1 ))
GetDlgItem(IDC_EDIT_RAWSPECIFIC1)->SetWindowText( g_stInitialData.szRawSpecific1 );
if (SetCurrentDirectory( g_stInitialData.szRawSpecific2 ))
GetDlgItem(IDC_EDIT_RAWSPECIFIC2)->SetWindowText( g_stInitialData.szRawSpecific2 );
m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szGameData ),"GameData", _szMessage, &bDisplay, IDC_EDIT_GAMEDATA, g_stInitialData.szGameData);
m_fn_vShowPartialWarning(SetCurrentDirectory( g_stInitialData.szRawData ),"RawData", _szMessage, &bDisplay, IDC_EDIT_RAWDATA, g_stInitialData.szRawData);
strcpy(szPath, g_stInitialData.szGameData );
strcat(szPath, "\\");
if (!m_fn_bExistDirectories(g_stInitialData.szGameData))
sprintf( _szMessage,"\tYou have to select another GameData directory, because it does not contain any directories !\n\n");
if (bDisplay) AfxMessageBox( _szMessage, MB_OK | MB_ICONSTOP );
SetCurrentDirectory( sDir);
}
return bDisplay;
}
/****************************************************************************
* Description: Show a message for the directories (if they don't exist or are not set)
*
* Parameters: bSet : flag to set the path
* szPath : path for the directory
* _szMessage : warning message
* bDisplay : returns the state
* iID : ID of the control to update
* szDir : path for the directory
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vShowPartialWarning (BOOL bSet, char *szPath, char *_szMessage, BOOL * bDisplay, int iID, char *szDir)
{
if (bSet)
GetDlgItem(iID)->SetWindowText( szDir );
else
{
int iSize= strlen(_szMessage);
if ((!strcmp(szPath, "Textures"))||(!strcmp(szPath, "Default")))
sprintf( _szMessage+iSize, "\tThe sub-directory %s of GameData directory, does not exist (or is not set). Please, choose another %s sub-directory!\n\n", szPath, szPath );
else
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;
}
}
//==================================================//
// MAIN PANEL : SHOW CONTROLS //
//==================================================//
/****************************************************************************
* Description: Show only the buttons for the "Options" panel
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vShowControlsPanelDir()
{
m_fn_TabC_vChangeShowControlsPanelDir(TRUE);
m_fn_TabC_vChangeShowControlsPanelSel(FALSE);
m_fn_TabC_vChangeShowControlsPanelRes(FALSE);
}
/****************************************************************************
* Description: Show only the buttons for the "Selection" panel
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vShowControlsPanelSel()
{
m_fn_TabC_vChangeShowControlsPanelDir(FALSE);
m_fn_TabC_vChangeShowControlsPanelSel(TRUE);
m_fn_TabC_vChangeShowControlsPanelRes(FALSE);
m_fn_vUpdateForSelectConfig();
}
/****************************************************************************
* Description: Show only the buttons for the "Result" panel
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vShowControlsPanelRes()
{
m_fn_TabC_vChangeShowControlsPanelDir(FALSE);
m_fn_TabC_vChangeShowControlsPanelSel(FALSE);
m_fn_TabC_vChangeShowControlsPanelRes(TRUE);
}
//==================================================//
// MAIN PANEL : CHANGE CONTROLS //
//==================================================//
/****************************************************************************
* Description: Show or hide the buttons for the "Options" panel
*
* Parameters: bChange : show or hide
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vChangeShowControlsPanelDir(BOOL bChange)
{
GetDlgItem(IDC_GROUP_SOURCEDIRECTORIES)->ShowWindow(bChange);
GetDlgItem(IDC_GROUP_DESTDIRECTORIES)->ShowWindow(bChange);
m_oConfigPanel.BringWindowToTop();
m_oConfigPanel.ShowWindow(bChange);
if (bChange)
{
switch(m_oConfigPanel.GetCurSel())
{
case 0:
m_fn_vShowControlsPanelCurrent();
m_oButtonRegisterOption.ShowWindow(FALSE);
m_oButtonCreateOption.ShowWindow(FALSE);
break;
case 1:
m_fn_vShowControlsPanelCustom();
m_oButtonRegisterOption.ShowWindow(TRUE);
m_oButtonCreateOption.ShowWindow(TRUE);
break;
}
}
else
{
m_fn_vChangeShowControlsPanelCurrent(FALSE);
m_fn_vChangeShowControlsPanelCustom(FALSE);
}
m_oEditRegisterOption.ShowWindow(FALSE);
m_oEditCreateOption.ShowWindow(FALSE);
m_oEditRegisterSelect.ShowWindow(FALSE);
m_oEditCreateSelect.ShowWindow(FALSE);
GetDlgItem(IDC_STATIC_GAMEDATA)->ShowWindow(bChange);
m_oCheckGameData.ShowWindow(bChange);
m_oCheckGameSP1.ShowWindow(bChange);
m_oCheckGameSP2.ShowWindow(bChange);
GetDlgItem(IDC_EDIT_GAMEDATA)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_GAMESPECIFIC1)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_GAMESPECIFIC2)->ShowWindow(bChange);
GetDlgItem(IDC_BROWSE_GAMEDATA)->ShowWindow(bChange);
GetDlgItem(IDC_BROWSE_GAMESPECIFIC1)->ShowWindow(bChange);
GetDlgItem(IDC_BROWSE_GAMESPECIFIC2)->ShowWindow(bChange);
m_oEditGameSp1.ShowWindow(bChange);
m_oEditGameSp2.ShowWindow(bChange);
GetDlgItem(IDC_GROUP_MAINOPTIONS)->ShowWindow(bChange);
m_oCheckRayman2.ShowWindow(bChange);
m_oCheckModifLst.ShowWindow(bChange);
m_oCheckEraseMdf.ShowWindow(bChange);
if (m_bConversion && bChange)
GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(FALSE);
if (m_bConversion) //the conversion is on
{ m_oCheckRayman2.EnableWindow(FALSE);
m_oCheckModifLst.EnableWindow(FALSE);
m_oCheckEraseMdf.EnableWindow(FALSE);
}
else
{ m_oCheckRayman2.EnableWindow(TRUE);
m_oCheckModifLst.EnableWindow(TRUE);
m_oCheckEraseMdf.EnableWindow(TRUE);
}
}
/****************************************************************************
* Description: Show or hide the buttons for the "Selection" panel
*
* Parameters: bChange : show or hide
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vChangeShowControlsPanelSel(BOOL bChange)
{
GetDlgItem(IDC_STATIC_LISTMESSAGE)->ShowWindow(bChange && !m_oListType->GetCount());
m_oListType->ShowWindow(bChange && m_oListType->GetCount());
m_oListObject->ShowWindow(bChange && m_oListType->GetCount());
GetDlgItem(IDC_GROUP_SELECTIONCONFIG)->ShowWindow(bChange);
m_oEditRegisterSelect.ShowWindow(FALSE);
m_oEditCreateSelect.ShowWindow(FALSE);
m_oButtonRegisterSelect.ShowWindow(bChange);
m_oButtonCreateSelect.ShowWindow(bChange);
m_oButtonDeleteSelect.ShowWindow(bChange);
m_oButtonSaveSelect.ShowWindow(bChange);
m_oComboChooseSelect.ShowWindow(bChange);
GetDlgItem(IDC_GROUP_SELECTION)->ShowWindow(bChange);
m_oSelectAll.ShowWindow(bChange);
m_oSelectList.ShowWindow(bChange);
m_oClearList.ShowWindow(bChange);
m_oClearAll.ShowWindow(bChange);
m_oConvert.ShowWindow(bChange);
GetDlgItem(IDC_GROUP_CONFLICT)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_ZOO)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_SCT)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_SPO)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_GMT)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_VMT)->ShowWindow(bChange);
m_oCheckZooMax.ShowWindow(bChange);
m_oCheckZooEds.ShowWindow(bChange);
m_oCheckSctMax.ShowWindow(bChange);
m_oCheckSctEds.ShowWindow(bChange);
m_oCheckSpoMax.ShowWindow(bChange);
m_oCheckSpoEds.ShowWindow(bChange);
m_oCheckGmtMax.ShowWindow(bChange);
m_oCheckGmtEds.ShowWindow(bChange);
m_oCheckVmtMax.ShowWindow(bChange);
m_oCheckVmtEds.ShowWindow(bChange);
GetDlgItem(IDC_GROUP_OPTIONS)->ShowWindow(bChange);
m_oCheckCopyAnims.ShowWindow(bChange);
m_oCheckCopyTextures.ShowWindow(bChange);
m_oCheckGenerateRLI.ShowWindow(bChange);
m_oCheckUpdateGameDsc.ShowWindow(bChange);
m_oCheckCreateFamily.ShowWindow(bChange);
GetDlgItem(IDC_GROUP_ERASE)->ShowWindow(bChange);
m_oCheckEraseDup.ShowWindow(bChange);
m_oCheckEraseUnused.ShowWindow(bChange);
GetDlgItem(IDC_GROUP_FAMILIES)->ShowWindow(bChange);
m_oCheckAskFamily.ShowWindow(bChange);
m_oCheckCommon.ShowWindow(bChange);
m_oCheckSpecific.ShowWindow(bChange);
GetDlgItem(IDC_GROUP_CONFIG)->ShowWindow(bChange);
m_oEditRegisterOption.ShowWindow(FALSE);
m_oEditCreateOption.ShowWindow(FALSE);
m_oButtonRegisterOption.ShowWindow(bChange);
m_oButtonCreateOption.ShowWindow(bChange);
m_oButtonDeleteOption.ShowWindow(bChange);
m_oButtonSaveOption.ShowWindow(bChange);
m_oComboChooseOption.ShowWindow(bChange);
if (m_bConversion && bChange)
{
m_fn_TabC_vDisableSelButtons() ;
GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(FALSE);
}
else
{
m_oButtonRegisterSelect.EnableWindow(m_oListType->GetCount() && !m_bConversion);
m_oButtonCreateSelect.EnableWindow(m_oListType->GetCount() && !m_bConversion);
m_oButtonDeleteSelect.EnableWindow(m_oListType->GetCount() && !m_bConversion && g_iCurrentIndexSelect);
m_oButtonSaveSelect.EnableWindow(m_oListType->GetCount() && !m_bConversion && g_iCurrentIndexSelect);
m_oComboChooseSelect.EnableWindow(m_oListType->GetCount() && !m_bConversion);
m_oClearList.EnableWindow(m_oListType->GetCount()&& m_iCountOfSelections);
m_oClearAll.EnableWindow(m_oListType->GetCount()&& m_iCountOfSelections);
if (bChange)
{
m_oSelectAll.EnableWindow(m_oListType->GetCount());
m_oSelectList.EnableWindow(m_oListType->GetCount());
}
m_oConvert.EnableWindow(m_oListType->GetCount()&& m_iCountOfSelections);
m_oCheckZooMax.EnableWindow(m_oListType->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)||(m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected)||(m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected));
m_oCheckZooEds.EnableWindow(m_oListType->GetCount()&& (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)||(m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected)||(m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected));
m_oCheckSctMax.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && g_bRaymanII)) ;
m_oCheckSctEds.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected && g_bRaymanII)) ;
m_oCheckSpoMax.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)) ;
m_oCheckSpoEds.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)) ;
m_oCheckGmtMax.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)||(m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected)||(m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)) ;
m_oCheckGmtEds.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)||(m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected)||(m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)) ;
m_oCheckVmtMax.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)||(m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected)||(m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)) ;
m_oCheckVmtEds.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)||(m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected)||(m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)) ;
m_oCheckCopyAnims.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected)) ;
m_oCheckCopyTextures.EnableWindow(m_oListType->GetCount()&&((m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected) || (m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected))) ;
m_oCheckGenerateRLI.EnableWindow(m_oListType->GetCount() && (!m_bConversion && m_iCountOfSelections && (((m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected) && g_bGenerateRLI) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)))) ;
m_oCheckUpdateGameDsc.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected));
m_oCheckCreateFamily.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)) ;
m_oCheckEraseDup.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)) ;
m_oCheckEraseUnused.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)) ;
m_oCheckAskFamily.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected));
m_oCheckCommon.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected));
m_oCheckSpecific.EnableWindow(m_oListType->GetCount()&&(m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected));
m_oButtonRegisterOption.EnableWindow(m_oListType->GetCount() && !m_bConversion);
m_oButtonCreateOption.EnableWindow(m_oListType->GetCount() && !m_bConversion);
m_oButtonDeleteOption.EnableWindow(m_oListType->GetCount() && !m_bConversion && g_iCurrentIndexOption);
m_oButtonSaveOption.EnableWindow(m_oListType->GetCount() && !m_bConversion && g_iCurrentIndexOption);
m_oComboChooseOption.EnableWindow(m_oListType->GetCount() && !m_bConversion);
GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(FALSE);
}
}
/****************************************************************************
* Description: Show or hide the buttons for the "Result" panel
*
* Parameters: bChange : show or hide
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vChangeShowControlsPanelRes(BOOL bChange)
{
if (bChange)
{
GetDlgItem(IDC_STATIC_COMMAND)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_RICHEDIT_COMMAND)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_STATIC_RESULT)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_RICHEDIT_RESULT)->ShowWindow(SW_SHOW);
}
else
{
GetDlgItem(IDC_STATIC_COMMAND)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RICHEDIT_COMMAND)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_RESULT)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RICHEDIT_RESULT)->ShowWindow(SW_HIDE);
}
if (m_bConversion && bChange)
GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(TRUE);
}
//==================================================//
// MAIN PANEL : ENABLE BUTTONS //
//==================================================//
/****************************************************************************
* Description: Enable the buttons for all the tabs
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vEnableButtons()
{
GetDlgItem(IDC_BROWSE_RAWDATA)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_RAWSPECIFIC1)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_RAWSPECIFIC2)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_GAMEDATA)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_GAMESPECIFIC1)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_GAMESPECIFIC2)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_ANIMS)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_BANKS)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_CLASSES)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_FAMILIES)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_LEVELS)->EnableWindow(TRUE);
GetDlgItem(IDC_BROWSE_TEXTURES)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_HELP)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_QUIT)->EnableWindow(TRUE);
m_oCheckRayman2.EnableWindow(TRUE);
m_oCheckModifLst.EnableWindow(TRUE);
m_oCheckEraseMdf.EnableWindow(TRUE);
m_oButtonRegisterDir.EnableWindow(TRUE);
m_oButtonCreateDir.EnableWindow(TRUE);
m_oButtonDeleteDir.EnableWindow(g_iCurrentIndexDir);
m_oButtonSaveDir.EnableWindow(g_iCurrentIndexDir);
m_oComboChooseDir.EnableWindow(TRUE);
m_oButtonRegisterSelect.EnableWindow(TRUE);
m_oButtonCreateSelect.EnableWindow(TRUE);
m_oButtonDeleteSelect.EnableWindow(g_iCurrentIndexSelect);
m_oButtonSaveSelect.EnableWindow(g_iCurrentIndexSelect);
m_oComboChooseSelect.EnableWindow(TRUE);
m_oButtonRegisterOption.EnableWindow(TRUE);
m_oButtonCreateOption.EnableWindow(TRUE);
m_oButtonDeleteOption.EnableWindow(g_iCurrentIndexOption);
m_oButtonSaveOption.EnableWindow(g_iCurrentIndexOption);
m_oComboChooseOption.EnableWindow(TRUE);
m_oCheckRawSP1.EnableWindow(TRUE);
m_oCheckRawSP2.EnableWindow(TRUE);
m_oCheckGameSP1.EnableWindow(TRUE);
m_oCheckGameSP2.EnableWindow(TRUE);
m_oEditRawSp1.EnableWindow(TRUE);
m_oEditRawSp2.EnableWindow(TRUE);
m_oEditGameSp1.EnableWindow(TRUE);
m_oEditGameSp2.EnableWindow(TRUE);
m_oCheckRawData.EnableWindow(TRUE);
m_oCheckGameData.EnableWindow(TRUE);
}
/****************************************************************************
* Description: Disable the buttons for all the tabs
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vDisableAllButtons()
{
m_oEditRawSp1.EnableWindow(FALSE);
m_oEditRawSp2.EnableWindow(FALSE);
m_oCheckRawData.EnableWindow(FALSE);
m_oCheckRawSP1.EnableWindow(FALSE);
m_oCheckRawSP2.EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_RAWDATA)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_RAWSPECIFIC1)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_RAWSPECIFIC2)->EnableWindow(FALSE);
m_oButtonRegisterDir.EnableWindow(FALSE);
m_oButtonCreateDir.EnableWindow(FALSE);
m_oButtonDeleteDir.EnableWindow(FALSE);
m_oButtonSaveDir.EnableWindow(FALSE);
m_oComboChooseDir.EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_ANIMS)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_BANKS)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_CLASSES)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_FAMILIES)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_LEVELS)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_TEXTURES)->EnableWindow(FALSE);
m_oEditGameSp1.EnableWindow(FALSE);
m_oEditGameSp2.EnableWindow(FALSE);
m_oCheckGameData.EnableWindow(FALSE);
m_oCheckGameSP1.EnableWindow(FALSE);
m_oCheckGameSP2.EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_GAMEDATA)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_GAMESPECIFIC1)->EnableWindow(FALSE);
GetDlgItem(IDC_BROWSE_GAMESPECIFIC2)->EnableWindow(FALSE);
m_oCheckRayman2.EnableWindow(FALSE);
m_oCheckModifLst.EnableWindow(FALSE);
m_oCheckEraseMdf.EnableWindow(FALSE);
m_fn_TabC_vDisableSelButtons();
GetDlgItem(IDC_BUTTON_HELP)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_QUIT)->EnableWindow(FALSE);
}
/****************************************************************************
* Description: Disable the buttons for the second panel
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_TabC_vDisableSelButtons()
{
m_oButtonRegisterSelect.EnableWindow(FALSE);
m_oButtonCreateSelect.EnableWindow(FALSE);
m_oButtonDeleteSelect.EnableWindow(FALSE);
m_oButtonSaveSelect.EnableWindow(FALSE);
m_oComboChooseSelect.EnableWindow(FALSE);
m_oSelectAll.EnableWindow(FALSE);
m_oSelectList.EnableWindow(FALSE);
m_oClearList.EnableWindow(FALSE);
m_oClearAll.EnableWindow(FALSE);
m_oConvert.EnableWindow(FALSE);
m_oCheckZooMax.EnableWindow(FALSE);
m_oCheckZooEds.EnableWindow(FALSE);
m_oCheckSctMax.EnableWindow(FALSE);
m_oCheckSctEds.EnableWindow(FALSE);
m_oCheckSpoMax.EnableWindow(FALSE);
m_oCheckSpoEds.EnableWindow(FALSE);
m_oCheckGmtMax.EnableWindow(FALSE);
m_oCheckGmtEds.EnableWindow(FALSE);
m_oCheckVmtMax.EnableWindow(FALSE);
m_oCheckVmtEds.EnableWindow(FALSE);
m_oCheckCopyAnims.EnableWindow(FALSE);
m_oCheckCopyTextures.EnableWindow(FALSE);
m_oCheckGenerateRLI.EnableWindow(FALSE);
m_oCheckUpdateGameDsc.EnableWindow(FALSE);
m_oCheckCreateFamily.EnableWindow(FALSE);
m_oCheckEraseDup.EnableWindow(FALSE);
m_oCheckEraseUnused.EnableWindow(FALSE);
m_oCheckAskFamily.EnableWindow(FALSE);
m_oCheckCommon.EnableWindow(FALSE);
m_oCheckSpecific.EnableWindow(FALSE);
m_oButtonRegisterOption.EnableWindow(FALSE);
m_oButtonCreateOption.EnableWindow(FALSE);
m_oButtonDeleteOption.EnableWindow(FALSE);
m_oButtonSaveOption.EnableWindow(FALSE);
m_oComboChooseOption.EnableWindow(FALSE);
}
//==================================================//
// CONFIG PANEL : SHOW CONTROLS //
//==================================================//
/****************************************************************************
* Description: Show only the buttons for the "Current" panel
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vShowControlsPanelCurrent()
{
m_fn_vChangeShowControlsPanelCurrent(TRUE);
m_fn_vChangeShowControlsPanelCustom(FALSE);
}
/****************************************************************************
* Description: Show only the buttons for the "Custom" panel
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vShowControlsPanelCustom()
{
m_fn_vChangeShowControlsPanelCurrent(FALSE);
m_fn_vChangeShowControlsPanelCustom(TRUE);
m_oButtonDeleteDir.EnableWindow(g_iCurrentIndexDir);
m_oButtonSaveDir.EnableWindow(g_iCurrentIndexDir);
// update directory pahs for Default config
if (!g_iCurrentIndexDir)
m_fn_vSetDefaultDirConfig();
}
//==================================================//
// CONFIG PANEL : CHANGE CONTROLS //
//==================================================//
/****************************************************************************
* Description: Show or hide the buttons for the "Current" panel
*
* Parameters: bChange : show or hide
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vChangeShowControlsPanelCurrent(BOOL bChange)
{
GetDlgItem(IDC_STATIC_RAWDATA)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_RAWDATA)->BringWindowToTop();
m_oCheckRawData.ShowWindow(bChange);
m_oCheckRawSP1.ShowWindow(bChange);
m_oCheckRawSP2.ShowWindow(bChange);
GetDlgItem(IDC_EDIT_RAWDATA)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_RAWSPECIFIC1)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_RAWSPECIFIC2)->ShowWindow(bChange);
GetDlgItem(IDC_BROWSE_RAWDATA)->ShowWindow(bChange);
GetDlgItem(IDC_BROWSE_RAWSPECIFIC1)->ShowWindow(bChange);
GetDlgItem(IDC_BROWSE_RAWSPECIFIC2)->ShowWindow(bChange);
m_oEditRawSp1.ShowWindow(bChange);
m_oEditRawSp2.ShowWindow(bChange);
}
/****************************************************************************
* Description: Show or hide the buttons for the "Custom" panel
*
* Parameters: bChange : show or hide
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vChangeShowControlsPanelCustom(BOOL bChange)
{
//buttons from the panel Custom
m_oEditRegisterDir.ShowWindow(FALSE);
m_oEditCreateDir.ShowWindow(FALSE);
m_oButtonRegisterDir.ShowWindow(bChange);
m_oButtonCreateDir.ShowWindow(bChange);
m_oButtonDeleteDir.ShowWindow(bChange);
m_oButtonSaveDir.ShowWindow(bChange);
m_oComboChooseDir.ShowWindow(bChange);
GetDlgItem(IDC_BROWSE_ANIMS)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_ANIMS)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_ANIMS)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_ANIMS)->BringWindowToTop();
GetDlgItem(IDC_BROWSE_BANKS)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_BANKS)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_BANKS)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_BANKS)->BringWindowToTop();
GetDlgItem(IDC_BROWSE_CLASSES)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_CLASSES)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_CLASSES)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_CLASSES)->BringWindowToTop();
GetDlgItem(IDC_BROWSE_FAMILIES)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_FAMILIES)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_FAMILIES)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_FAMILIES)->BringWindowToTop();
GetDlgItem(IDC_BROWSE_LEVELS)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_LEVELS)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_LEVELS)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_LEVELS)->BringWindowToTop();
GetDlgItem(IDC_BROWSE_TEXTURES)->ShowWindow(bChange);
GetDlgItem(IDC_EDIT_TEXTURES)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_TEXTURES)->ShowWindow(bChange);
GetDlgItem(IDC_STATIC_TEXTURES)->BringWindowToTop();
}
//==================================================//
// BROWSE FUNCTIONS //
//==================================================//
/****************************************************************************
* Description: browse starting with the specified directory .
*
* Parameters: szPath : directory to start from
* p_iResult : result of the search
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vBrowseStartingFromDirectory(char* szPath, int *p_iResult)
{
ITEMIDLIST *p_stItemRoot;
unsigned long p_sNumber;
IShellFolder* p_ShellFolder;
SHGetDesktopFolder( &p_ShellFolder );
// transform a usual string to an unicode string
int nLen = MultiByteToWideChar(CP_ACP, 0,g_stInitialData.szGameData, -1, NULL, NULL);
LPWSTR lpszW = new WCHAR[nLen];
MultiByteToWideChar(CP_ACP, 0, g_stInitialData.szGameData, -1, lpszW, nLen);
// prepare the structure for browsing starting from one specific directory
p_ShellFolder->ParseDisplayName( m_hWnd, NULL, lpszW , &p_sNumber, &p_stItemRoot, NULL);
delete[] lpszW;
m_fn_vBrowseDirectory(szPath, p_iResult, p_stItemRoot) ;
}
/****************************************************************************
* Description: browse the specified directory .
*
* Parameters: szPath : directory to start from
* p_iResult : result of the search
* p_stItemRoot : root item
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
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 path for directory";
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;
}
}
//==================================================//
// SEARCH FUNCTIONS //
//==================================================//
/****************************************************************************
* Description: Test if in a given directory are any directories
*
* Parameters: _szPath : name of the directory
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
BOOL CDlgMain::m_fn_bExistDirectories(char *_szPath)
{
int i=0;
char szPath[MAX_PATH];
HANDLE hHandle;
WIN32_FIND_DATA stFindFileData;
strcpy(szPath, _szPath);
strcat (szPath, "\\*");
if (!m_fn_bGetFiles(szPath, &hHandle, &stFindFileData)) return FALSE;
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;
}
/****************************************************************************
* Description: Test if the directory contain any data.
*
* Parameters: szFile : name of the directory
* hHandle : search handle
* stFindFileData : search data
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
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;
}
//==================================================//
// GET DATA & TYPES //
//==================================================//
/****************************************************************************
* Description: Get all available types for the list box with types.
*
* Parameters: szName : name of the directory
* szObject : object to search
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vGetAllTypes()
{
char szAnims[MAX_PATH];
char szBanks[MAX_PATH];
char szClasses[MAX_PATH];
char szFamilies[MAX_PATH];
char szLevels[MAX_PATH];
char szTextures[MAX_PATH];
int iNumber=0;
// set all the lists with objects
m_fn_vAddType(m_p_oTypeAnims, szAnims, "Anims","\\World\\Graphics\\Anims" , &iNumber);
m_fn_vAddType(m_p_oTypeBanks, szBanks, "Banks","\\World\\Graphics\\Objects\\Banks" , &iNumber);
m_fn_vAddType(m_p_oTypeClasses, szClasses, "Classes","\\World\\Graphics\\Objects\\Classes" , &iNumber);
m_fn_vAddType(m_p_oTypeFamilies, szFamilies, "Families","\\World\\Families" , &iNumber);
m_fn_vAddType(m_p_oTypeLevels, szLevels, "Levels","\\World\\Levels" , &iNumber);
m_fn_vAddType(m_p_oTypeTextures, szTextures, "Textures","\\World\\Graphics\\Textures" , &iNumber);
if (!iNumber )
{ m_oListType->ResetContent();
m_oListObject->ResetContent();
}
m_fn_vGetSetDatasInList(szAnims, szBanks, szClasses, szFamilies, szLevels, szTextures);
}
/****************************************************************************
* Description: Get all datas (objects) for all the types.
*
* Parameters: szName : name of the directory
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vGetDatas(char *szType, char *szPath)
{
HANDLE hHandle;
WIN32_FIND_DATA stFindFileData;
if (!m_fn_bGetFiles(szPath, &hHandle, &stFindFileData))
return;
// get the datas for the banks and classes
if (!strcmp(szType, "Banks")||!strcmp(szType, "Classes"))
{
do if(stFindFileData.dwFileAttributes)
{
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 )
{
GI_Item * p_oItem = new GI_Item(FALSE, MLT_p_cGetFileNameWithoutExt(stFindFileData.cFileName));
if (m_p_oTypeBanks && !strcmp(szType, "Banks"))
m_fn_vCreateLists(&m_p_oTypeBanks->m_oList, szPath, "Banks", p_oItem);
if (m_p_oTypeClasses && !strcmp(szType, "Classes"))
m_fn_vCreateLists(&m_p_oTypeClasses->m_oList, szPath, "Classes", p_oItem);
}
}
while(FindNextFile(hHandle, &stFindFileData));
}
else
{
// get the datas for the anims, families 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 )
{
GI_Item * p_oItem = new GI_Item(FALSE, stFindFileData.cFileName);
if (m_p_oTypeAnims && !strcmp(szType, "Anims"))
m_fn_vCreateLists(&m_p_oTypeAnims->m_oList, szPath, "Anims", p_oItem);
if (m_p_oTypeFamilies && !strcmp(szType, "Families"))
m_fn_vCreateLists(&m_p_oTypeFamilies->m_oList, szPath, "Families", p_oItem);
if (m_p_oTypeLevels && !strcmp(szType, "Levels"))
m_fn_vCreateLists(&m_p_oTypeLevels->m_oList, szPath, "Levels", p_oItem);
if (m_p_oTypeTextures && !strcmp(szType, "Textures"))
m_fn_vCreateLists(&m_p_oTypeTextures->m_oList, szPath, "Textures", p_oItem);
}
}
while(FindNextFile(hHandle, &stFindFileData));
}
FindClose(hHandle);
}
/****************************************************************************
* Description: Get the datas from the directories and set the lists with objects.
*
* Parameters: szAnims : anims directory
* szBanks : banks directory
* szClasses : classes directory
* szFamilies : families directory
* szLevels : levels directory
* szTextures : textures directory
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vGetSetDatasInList( char *szAnims, char *szBanks, char *szClasses, char *szFamilies, char *szLevels, char * szTextures)
{
if (m_oListType->GetCount())
{ // get all datas for all the existing types in the list box with types
m_fn_vGetDatas("Anims", strcat(szAnims, "\\*.*"));
m_fn_vGetDatas("Banks", strcat(szBanks, "\\*.mod"));
m_fn_vGetDatas("Classes", strcat(szClasses, "\\*.mod"));
m_fn_vGetDatas("Families", strcat(szFamilies, "\\*.*"));
m_fn_vGetDatas("Levels", strcat(szLevels, "\\*.*"));
m_fn_vGetDatas("Textures", strcat(szTextures, "\\*.*"));
}
}
//==================================================//
// CREATE LISTS //
//==================================================//
/****************************************************************************
* Description: Find the number of elements for a type.
*
* Parameters: szFiles : name of the directory
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
int CDlgMain::m_fn_iAddTestDirType(char* szFiles)
{
int iTypes=0;
HANDLE hHandle;
WIN32_FIND_DATA stFindFileData;
if (!m_fn_bGetFiles(szFiles, &hHandle, &stFindFileData))
return 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;
}
/****************************************************************************
* Description: Add an item to the list
*
* Parameters: _oListObject : obejct list
* szPath : directory
* szType : name of type
* _p_oItem :new object
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vCreateLists(CList<GI_Item *,GI_Item *> *_oListObject, char *szPath, char *szType, GI_Item * _p_oItem )
{
// add an item to the list
_oListObject -> AddTail( _p_oItem);
}
/****************************************************************************
* Description: add that type in the list box with types
*
* Parameters: _p_oType : pointer on the new type
* szType : name of type
* iNumber : number of data for this type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
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
*_p_oType = p_oType;
m_oListType -> SetItemData( iIndex, (DWORD) *_p_oType );
}
}
}
}
/****************************************************************************
* Description: add that type in the list box with types
*
* Parameters: _p_oType : new type
* szReturn : returns the seult
* szType : name of type
* szDir : name of directory
* iNumber : number of data for this type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddType(GI_Type * p_oType, char *szReturn, char *szType, char *szDir, int *iNumber)
{ char _szType[MAX_PATH];
xString sDir;
switch(g_iRaw)
{
case 0:
strcpy(_szType, g_stInitialData.szRawData);
break;
case 1:
strcpy(_szType, g_stInitialData.szRawSpecific1);
break;
case 2:
strcpy(_szType, g_stInitialData.szRawSpecific2);
break;
}
strcat (_szType, szDir);
GetCurrentDirectory(256, sDir);
if (SetCurrentDirectory(_szType))
{
int iBanks=0, iAnims=0, iClasses=0, iFamilies=0, iLevels=0, iTextures = 0;
// for Anims
if (!strcmp(szType, "Anims"))
{
iAnims=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeAnims, szType, iAnims);
}
// for Banks
if (!strcmp(szType, "Banks"))
{
iBanks=m_fn_iAddTestDirType("*.mod");
m_fn_vSetTypeInList(&m_p_oTypeBanks, szType, iBanks);
}
// for Classes
if (!strcmp(szType, "Classes"))
{
iClasses=m_fn_iAddTestDirType("*.mod");
m_fn_vSetTypeInList(&m_p_oTypeClasses, szType, iClasses);
}
// for Families
if (!strcmp(szType, "Families"))
{
iFamilies=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeFamilies, szType, iFamilies);
}
// for Levels
if (!strcmp(szType, "Levels"))
{
iLevels=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeLevels, szType, iLevels);
}
// for Textures
if (!strcmp(szType, "Textures"))
{
iTextures=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeTextures, szType, iTextures);
}
// increment the number of types
(*iNumber)++;
}
strcpy(szReturn, _szType);
SetCurrentDirectory(sDir);
}
/****************************************************************************
* Description: add anims type in the list box with types
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddAnim(void)
{
int iObjects=0;
xString sDir;
GetCurrentDirectory(256, sDir);
if (SetCurrentDirectory(g_szAnims))
{ iObjects=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeAnims, "Anims", iObjects);
}
SetCurrentDirectory(sDir);
}
/****************************************************************************
* Description: add all anims
*
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddAnims(void)
{
xString sDir;
m_fn_vAddAnim();
strcpy(sDir, g_szAnims);
strcat(sDir, "\\*.*");
if (m_oListType->GetCount())
m_fn_vGetDatas("Anims", sDir);
if (m_p_oTypeAnims)
if (!m_p_oTypeAnims->m_oList.GetCount())
//delete the anims from the type list box!!!
m_oListType->DeleteString(m_oListType->FindString(-1, "Anims"));
}
/****************************************************************************
* Description: add banks type in the list box with types
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddBank(void)
{
int iBanks=0;
xString sDir;
GetCurrentDirectory(256, sDir);
if (SetCurrentDirectory(g_szBanks))
{ iBanks=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeBanks, "Banks", iBanks);
}
SetCurrentDirectory(sDir);
}
/****************************************************************************
* Description: add all banks
*
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddBanks(void)
{
xString sDir;
m_fn_vAddBank();
strcpy(sDir, g_szBanks);
strcat(sDir, "\\*.mod");
if (m_oListType->GetCount())
m_fn_vGetDatas("Banks", sDir);
if (m_p_oTypeBanks)
if (!m_p_oTypeBanks->m_oList.GetCount())
//delete the banks from the type list box!!!
m_oListType->DeleteString(m_oListType->FindString(-1, "Banks"));
}
/****************************************************************************
* Description: add classes type in the list box with types
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddClass(void)
{
int iClass=0;
xString sDir;
GetCurrentDirectory(256, sDir);
if (SetCurrentDirectory(g_szClasses))
{ iClass=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeClasses, "Classes", iClass);
}
SetCurrentDirectory(sDir);
}
/****************************************************************************
* Description: add all classes
*
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddClasses(void)
{
xString sDir;
m_fn_vAddClass();
strcpy(sDir, g_szClasses);
strcat(sDir, "\\*.mod");
if (m_oListType->GetCount())
m_fn_vGetDatas("Classes", sDir);
if (m_p_oTypeClasses)
if( !m_p_oTypeClasses->m_oList.GetCount())
//delete the classes from the type list box!!!
m_oListType->DeleteString(m_oListType->FindString(-1, "Classes"));
}
/****************************************************************************
* Description: add family type in the list box with types
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddFamily(void)
{
int iFamilies=0;
xString sDir;
GetCurrentDirectory(256, sDir);
if (SetCurrentDirectory(g_szFamilies))
{ iFamilies=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeFamilies, "Families", iFamilies);
}
SetCurrentDirectory(sDir);
}
/****************************************************************************
* Description: add all families
*
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddFamilies(void)
{ xString sDir;
m_fn_vAddFamily();
strcpy(sDir, g_szFamilies);
strcat(sDir, "\\*.*");
if (m_oListType->GetCount())
m_fn_vGetDatas("Families", sDir);
if (m_p_oTypeFamilies)
if (!m_p_oTypeFamilies->m_oList.GetCount())
//delete the families from the type list box!!!
m_oListType->DeleteString(m_oListType->FindString(-1, "Families"));
}
/****************************************************************************
* Description: add levels type in the list box with types
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddLevel(void)
{ int iLevels=0;
xString sDir;
GetCurrentDirectory(256, sDir);
if (SetCurrentDirectory(g_szLevels))
{ iLevels=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeLevels, "Levels", iLevels);
}
SetCurrentDirectory(sDir);
}
/****************************************************************************
* Description: add all levels
*
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddLevels(void)
{ xString sDir;
m_fn_vAddLevel();
strcpy(sDir, g_szLevels);
strcat(sDir, "\\*.*");
if (m_oListType->GetCount())
m_fn_vGetDatas("Levels", sDir);
if (m_p_oTypeLevels)
if (!m_p_oTypeLevels->m_oList.GetCount())
//delete the levels from the type list box!!!
m_oListType->DeleteString(m_oListType->FindString(-1, "Levels"));
}
/****************************************************************************
* Description: add textures type in the list box with types
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddTexture(void)
{
int iTextures=0;
xString sDir;
GetCurrentDirectory(256, sDir);
if (SetCurrentDirectory(g_szTextures))
{ iTextures=m_fn_iAddTestDirType("*.*");
m_fn_vSetTypeInList(&m_p_oTypeTextures, "Textures", iTextures);
}
SetCurrentDirectory(sDir);
}
/****************************************************************************
* Description: add all textures
*
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vAddTextures(void)
{
xString sDir;
m_fn_vAddTexture();
strcpy(sDir, g_szTextures);
strcat(sDir, "\\*.*");
if (m_oListType->GetCount())
m_fn_vGetDatas("Textures", sDir);
if (m_p_oTypeTextures)
if (!m_p_oTypeTextures->m_oList.GetCount())
//delete the textures from the type list box!!!
m_oListType->DeleteString(m_oListType->FindString(-1, "Textures"));
}
//==================================================//
// GET NUMBER OF OBJECTS //
//==================================================//
/****************************************************************************
* Description: Get the total number of objects in all lists.
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
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_oTypeBanks)
iResult += m_p_oTypeBanks->m_oList.GetCount();
if (m_p_oTypeClasses)
iResult += m_p_oTypeClasses->m_oList.GetCount();
if (m_p_oTypeFamilies)
iResult += m_p_oTypeFamilies->m_oList.GetCount();
if (m_p_oTypeLevels)
iResult += m_p_oTypeLevels->m_oList.GetCount();
if (m_p_oTypeTextures)
iResult += m_p_oTypeTextures->m_oList.GetCount();
return iResult;
}
//==================================================//
// UPDATE LIST BOXES //
//==================================================//
/****************************************************************************
* Description: Add the objects to the list box
*
* Parameters: _oListObjects : object list
* szPath : directory
* szType : type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vUpdateListBox(CList<GI_Item *,GI_Item *> *_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; i<iSize; i++)
{
// add the objects in the list box with objects
p_oItem = _oListObjects->RemoveHead();
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);
}
}
/****************************************************************************
* Description: Update all the datas
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vUpdateAll()
{
if (g_bStandardConfig)
m_fn_vGetAllTypes();
else
{ m_fn_vAddAnims();
m_fn_vAddTextures();
m_fn_vAddBanks();
m_fn_vAddClasses();
m_fn_vAddFamilies();
m_fn_vAddLevels();
}
// 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, "Anims");
if (m_p_oTypeBanks)
m_fn_vUpdateListBox(&m_p_oTypeBanks->m_oList, szPath, "Banks");
if (m_p_oTypeClasses)
m_fn_vUpdateListBox(&m_p_oTypeClasses->m_oList, szPath, "Classes");
if (m_p_oTypeFamilies)
m_fn_vUpdateListBox(&m_p_oTypeFamilies->m_oList, szPath, "Families");
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");
}
//==================================================//
// DRAW ITEMS IN LIST BOX //
//==================================================//
/****************************************************************************
* Description: Function for changing the color of one item in the list box with types
*
* Parameters: lpDIS : item to draw
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vOnDrawItemListBoxType(LPDRAWITEMSTRUCT lpDIS)
{
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_WINDOW) );
// change the color of the type in the list box according
if (p_oType->m_iSelected == 0)
xTextColor = RGB(0, 0,0);
int iSize = p_oType->m_oList.GetCount() ;
if (p_oType->m_iSelected < iSize && p_oType->m_iSelected >0)
xTextColor = RGB(0, 0, 255);
if (p_oType->m_iSelected == iSize && iSize>0)
xTextColor = RGB(0, 127,0);
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();
}
/****************************************************************************
* Description: Function for drawing the cross before of one active item
*
* Parameters: lpDIS : item to draw
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vOnDrawItemListBoxObject(LPDRAWITEMSTRUCT lpDIS)
{
CDC *pDC = CDC::FromHandle( lpDIS->hDC );
CListBox *pLB = m_oListObject;
GI_Item *p_oItem = (GI_Item*)pLB->GetItemData( lpDIS->itemID );
COLORREF xTextColor;
pDC->SetBkColor( GetSysColor( COLOR_WINDOWTEXT ) );
pDC->FillSolidRect( &lpDIS->rcItem, GetSysColor( COLOR_WINDOW ));
//draw a cross in front of an active object
if (p_oItem -> m_bActived)
{
xTextColor = RGB(0, 0, 255);
pDC->SetTextColor( xTextColor );
}
else
{
xTextColor = RGB(0, 0, 0);
pDC->SetTextColor( xTextColor );
}
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;
if (p_oItem -> m_bActived)
{
xTextColor = RGB(0, 0, 255);
pDC->SetTextColor( xTextColor );
}
else
{
xTextColor = RGB(0, 0, 0);
pDC->SetTextColor( xTextColor );
}
pDC->DrawText( p_oItem -> m_fn_p_oGetName(), &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER );
}
//==================================================//
// UPDATE STATE OF OBJECTS //
//==================================================//
/****************************************************************************
* Description: Change the state of an object
*
* Parameters: _p_oItem : item to change
* iIndexItem : index of the item
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
BOOL CDlgMain::m_fn_bOnChangeActivation(GI_Item *_p_oItem, int iIndexItem )
{
int file;
int iNbSel;
int iSize;
int iIndex = m_oListType->GetCurSel();
BOOL bResult = TRUE;
xString sName;
GI_Item *p_oItem;
GI_Type *p_oType = (GI_Type *)m_oListType->GetItemData(iIndex);
CListBox *pLB = m_oListObject;
iNbSel = pLB->GetSelCount();
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(p_oItemMul);
}
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())
m_oSelectList.EnableWindow(FALSE);
else
m_oSelectList.EnableWindow(TRUE);
if (p_oType->m_iSelected>0)
m_oClearList.EnableWindow(TRUE);
else
m_oClearList.EnableWindow(FALSE);
// g_bGenerateRLI = FALSE;
if (m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)
{
for (int i=0; i<m_p_oTypeBanks->m_oList.GetCount(); i++)
{
// add the objects in the list box with objects
p_oItem = m_p_oTypeBanks->m_oList.RemoveHead();
if (p_oItem->m_bActived)
{
if (g_bStandardConfig)
{
switch (g_iRaw)
{
case 0:
sprintf(sName, "%s\\World\\Graphics\\Objects\\Banks\\%s.spo", g_stInitialData.szRawData , p_oItem->m_szName);
break;
case 1:
sprintf(sName, "%s\\World\\Graphics\\Objects\\Banks\\%s.spo", g_stInitialData.szRawSpecific1 , p_oItem->m_szName);
break;
case 2:
sprintf(sName, "%s\\World\\Graphics\\Objects\\Banks\\%s.spo", g_stInitialData.szRawSpecific2 , p_oItem->m_szName);
break;
}
}
else
sprintf(sName, "%s\\%s.spo", g_szBanks, p_oItem->m_szName);
if ((file = open(sName, O_RDONLY))!=-1)
{
g_bGenerateRLI = TRUE;
close(file);
}
}
m_p_oTypeBanks->m_oList.AddTail(p_oItem);
}
}
if ((m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected && g_bGenerateRLI)||(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected))
m_oCheckGenerateRLI.EnableWindow(TRUE);
else
m_oCheckGenerateRLI.EnableWindow(FALSE);
if (m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)
m_oCheckCreateFamily.EnableWindow(TRUE);
else
m_oCheckCreateFamily.EnableWindow(FALSE);
}
m_oListType->Invalidate(TRUE);
g_bChangeComboSelect = TRUE;
return bResult ;
}
/****************************************************************************
* Description: Change the state of one object
*
* Parameters: _p_oItem : item to change
* p_oType : type
* bSet : new state
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vChange(GI_Item *p_oItem, GI_Type *p_oType, BOOL bSet )
{
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--;
}
}
//==================================================//
// SELECTION OF THE ITEMS //
//==================================================//
/****************************************************************************
* Description: reset the content of the dialogs
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vResetSelection()
{
//remove all the elements in the lists with objects
m_fn_vFreeMemory();
m_p_oTypeAnims = NULL;
m_p_oTypeBanks = NULL;
m_p_oTypeClasses = NULL;
m_p_oTypeFamilies = NULL;
m_p_oTypeLevels = NULL;
m_p_oTypeTextures = NULL;
//reset the contains of the list boxes
m_oListType->ResetContent();
m_oListObject->ResetContent();
m_fn_vUpdateAll();
//reset the total number of selections
m_iCountOfSelections = 0;
}
/****************************************************************************
* Description: Select/deselect all the objects in all lists according with parameter bSet
*
* Parameters: bSet : selection flag
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vSelectAll(BOOL bSet)
{
m_fn_vSelectAllInList(m_p_oTypeAnims, bSet);
m_fn_vSelectAllInList(m_p_oTypeBanks, bSet);
m_fn_vSelectAllInList(m_p_oTypeClasses, bSet);
m_fn_vSelectAllInList(m_p_oTypeFamilies, bSet);
m_fn_vSelectAllInList(m_p_oTypeLevels, bSet);
m_fn_vSelectAllInList(m_p_oTypeTextures, bSet);
}
/****************************************************************************
* Description: Select all the items (objects) for a selected type
*
* Parameters: bSet : selection flag
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vSelectAllForType(BOOL bSet)
{
char szPath[MAX_PATH];
int iIndex = m_oListType->GetCurSel();
GI_Type *p_oType = (GI_Type *)m_oListType->GetItemData(iIndex);
m_oListType->GetText(iIndex, szPath);
m_fn_vSelectAllInList(p_oType, bSet);
m_oListType->Invalidate(TRUE);
}
/****************************************************************************
* Description: Select/deselect the items in the list according with the parameter bSet
*
* Parameters: _p_oType : type
* bSet : selection flag
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
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;
}
}
//==================================================//
// ENABLE / DISABLE BUTTONS //
//==================================================//
/****************************************************************************
* Description: Modify the state of the selection buttons.
*
* Parameters: szName : name of the directory
* szObject : object to search
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vEnableButtons(BOOL bSet)
{
m_oSelectList.EnableWindow(!bSet);
m_oSelectAll.EnableWindow(!bSet);
m_oClearList.EnableWindow(bSet);
m_oClearAll.EnableWindow(bSet);
m_oCheckZooMax.EnableWindow(bSet);
m_oCheckZooEds.EnableWindow(bSet);
m_oCheckSctMax.EnableWindow(bSet);
m_oCheckSctEds.EnableWindow(bSet);
m_oCheckSpoMax.EnableWindow(bSet);
m_oCheckSpoEds.EnableWindow(bSet);
m_oCheckGmtMax.EnableWindow(bSet);
m_oCheckGmtEds.EnableWindow(bSet);
m_oCheckVmtMax.EnableWindow(bSet);
m_oCheckVmtEds.EnableWindow(bSet);
m_oCheckCopyTextures.EnableWindow(bSet);
m_oCheckGenerateRLI.EnableWindow(bSet);
m_oCheckUpdateGameDsc.EnableWindow(bSet);
m_oCheckAskFamily.EnableWindow(bSet);
m_oCheckCommon.EnableWindow(bSet&&!g_iData&&!g_bAskFamily);
m_oCheckSpecific.EnableWindow(bSet&&!g_iData&&!g_bAskFamily);
m_oCheckCreateFamily.EnableWindow(bSet);
m_oConvert.EnableWindow(bSet);
}
/****************************************************************************
* Description: Change the state of the button All
*
* Parameters: szName : name of the directory
* szObject : object to search
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vEnableButtonAll()
{
if (m_iCountOfSelections==m_fn_iGetAllObjects())
m_oSelectAll.EnableWindow(FALSE);
else
m_oSelectAll.EnableWindow(TRUE);
}
/****************************************************************************
* Description: Change the state for the Convert button
*
* Parameters: szName : name of the directory
* szObject : object to search
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vEnableButtonConvert()
{
// enable/disable the All button according to total number of selections
if (!m_iCountOfSelections)
{
m_oConvert.EnableWindow(FALSE);
m_oCheckZooMax.EnableWindow(FALSE);
m_oCheckZooEds.EnableWindow(FALSE);
m_oCheckSpoMax.EnableWindow(FALSE);
m_oCheckSpoEds.EnableWindow(FALSE);
m_oCheckGmtMax.EnableWindow(FALSE);
m_oCheckGmtEds.EnableWindow(FALSE);
m_oCheckVmtMax.EnableWindow(FALSE);
m_oCheckVmtEds.EnableWindow(FALSE);
m_oClearAll.EnableWindow(FALSE);
m_oCheckAskFamily.EnableWindow(FALSE);
m_oCheckCommon.EnableWindow(FALSE);
m_oCheckSpecific.EnableWindow(FALSE);
m_oCheckCopyAnims.EnableWindow(FALSE);
m_oCheckCopyTextures.EnableWindow(FALSE);
m_oCheckGenerateRLI.EnableWindow(FALSE);
m_oCheckUpdateGameDsc.EnableWindow(FALSE);
m_oCheckEraseDup.EnableWindow(FALSE);
m_oCheckEraseUnused.EnableWindow(FALSE);
m_oCheckCreateFamily.EnableWindow(FALSE);
if (g_bRaymanII)
{
m_oCheckSctMax.EnableWindow(FALSE);
m_oCheckSctEds.EnableWindow(FALSE);
}
}
else
{
m_oConvert.EnableWindow(TRUE);
m_oClearAll.EnableWindow(TRUE);
if ((m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)||(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected))
m_oCheckGenerateRLI.EnableWindow(TRUE);
else
m_oCheckGenerateRLI.EnableWindow(FALSE);
if ((m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected) || (m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected) || (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected))
m_oCheckCopyTextures.EnableWindow(TRUE);
else
m_oCheckCopyTextures.EnableWindow(FALSE);
if (m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected)
{
m_oCheckCopyAnims.EnableWindow(TRUE);
m_oCheckAskFamily.EnableWindow(TRUE);
if (!g_iData && !g_bAskFamily)
m_oCheckCommon.EnableWindow(TRUE);
if (g_iData && !g_bAskFamily)
m_oCheckSpecific.EnableWindow(TRUE);
}
else
{
m_oCheckCopyAnims.EnableWindow(FALSE);
m_oCheckAskFamily.EnableWindow(FALSE);
if (!g_iData && g_bAskFamily)
m_oCheckCommon.EnableWindow(FALSE);
if (g_iData && g_bAskFamily)
m_oCheckSpecific.EnableWindow(FALSE);
}
if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)
{
m_oCheckSpoMax.EnableWindow(TRUE);
m_oCheckSpoEds.EnableWindow(TRUE);
if (g_bRaymanII)
{
m_oCheckSctMax.EnableWindow(TRUE);
m_oCheckSctEds.EnableWindow(TRUE);
}
m_oCheckUpdateGameDsc.EnableWindow(TRUE);
m_oCheckEraseDup.EnableWindow(TRUE);
m_oCheckEraseUnused.EnableWindow(TRUE);
}
else
{
m_oCheckSpoMax.EnableWindow(FALSE);
m_oCheckSpoEds.EnableWindow(FALSE);
if (g_bRaymanII)
{
m_oCheckSctMax.EnableWindow(FALSE);
m_oCheckSctEds.EnableWindow(FALSE);
}
m_oCheckUpdateGameDsc.EnableWindow(FALSE);
m_oCheckEraseDup.EnableWindow(FALSE);
m_oCheckEraseUnused.EnableWindow(FALSE);
}
if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)
|| (m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)
|| (m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected))
{
m_oCheckGmtMax.EnableWindow(TRUE);
m_oCheckGmtEds.EnableWindow(TRUE);
m_oCheckVmtMax.EnableWindow(TRUE);
m_oCheckVmtEds.EnableWindow(TRUE);
}
else
{
m_oCheckGmtMax.EnableWindow(FALSE);
m_oCheckGmtEds.EnableWindow(FALSE);
m_oCheckVmtMax.EnableWindow(FALSE);
m_oCheckVmtEds.EnableWindow(FALSE);
}
if (m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)
m_oCheckCreateFamily.EnableWindow(TRUE);
else
m_oCheckCreateFamily.EnableWindow(FALSE);
if ((m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected)
|| (m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected)
|| (m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected))
{
m_oCheckZooMax.EnableWindow(TRUE);
m_oCheckZooEds.EnableWindow(TRUE);
}
else
{
m_oCheckZooMax.EnableWindow(FALSE);
m_oCheckZooEds.EnableWindow(FALSE);
}
}
}
//==================================================//
// OPTIONS //
//==================================================//
/****************************************************************************
* Description: set all the control buttons from the second list box
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vSetOptions()
{
m_oCheckZooEds.SetCheck(!g_bIgnoreZoo);
m_oCheckZooMax.SetCheck(g_bIgnoreZoo);
m_oCheckSctEds.SetCheck(!g_bIgnoreSct);
m_oCheckSctMax.SetCheck(g_bIgnoreSct);
m_oCheckSpoEds.SetCheck(!g_bIgnoreSpo);
m_oCheckSpoMax.SetCheck(g_bIgnoreSpo);
m_oCheckGmtEds.SetCheck(!g_bIgnoreGmt);
m_oCheckGmtMax.SetCheck(g_bIgnoreGmt);
m_oCheckVmtEds.SetCheck(!g_bIgnoreTex);
m_oCheckVmtMax.SetCheck(g_bIgnoreTex);
m_oCheckCopyAnims.SetCheck(g_bCopyAnims);
m_oCheckCopyTextures.SetCheck(g_bCopyTextures);
m_oCheckGenerateRLI.SetCheck(g_bGenerateRLI);
m_oCheckUpdateGameDsc.SetCheck(g_bUpdateGameDSC);
m_oCheckCreateFamily.SetCheck(g_bCreateBasicFamily);
m_oCheckEraseDup.SetCheck(g_bEraseDuplicated);
m_oCheckEraseUnused.SetCheck(g_bEraseUnused);
m_oCheckCommon.SetCheck(g_bCommonFamily);
m_oCheckSpecific.SetCheck(g_bSpecificFamily);
m_oCheckAskFamily.SetCheck(g_bAskFamily);
}
/****************************************************************************
* Description: Function for setting/resetting the flag for ignore options
*
* Parameters: iId : control ID
* bChange : corresponding flag
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vChangeCheck(int iId, int iId1, BOOL *bChange)
{
*bChange = ! ((CButton *)GetDlgItem(iId))->GetCheck();
((CButton *)GetDlgItem(iId1))->SetCheck(!(*bChange));
((CButton *)GetDlgItem(iId))->SetCheck((*bChange));
if (iId==IDC_CHECK_RAYMAN2)
{
m_oCheckSctMax.EnableWindow((*bChange));
m_oCheckSctEds.EnableWindow((*bChange));
}
}
/****************************************************************************
* Description: Function for setting/resetting the flag for ignore options
*
* Parameters: iId : control ID
* bChange : corresponding flag
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vChangeCheckButton(int iId, BOOL *bChange)
{
*bChange = ! ((CButton *)GetDlgItem(iId))->GetCheck();
((CButton *)GetDlgItem(iId))->SetCheck((*bChange));
}
//==================================================//
// FREE ALLOCATED MEMORY //
//==================================================//
/****************************************************************************
* Description: Free all the allocated memory.
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vFreeMemory()
{
m_fn_vFreeMemoryForType(&m_p_oTypeAnims ) ;
m_fn_vFreeMemoryForType(&m_p_oTypeBanks ) ;
m_fn_vFreeMemoryForType(&m_p_oTypeClasses ) ;
m_fn_vFreeMemoryForType(&m_p_oTypeFamilies ) ;
m_fn_vFreeMemoryForType(&m_p_oTypeLevels ) ;
m_fn_vFreeMemoryForType(&m_p_oTypeTextures ) ;
}
/****************************************************************************
* Description: Free all the allocated memory for a type.
*
* Parameters: _p_oType : type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_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; i<iSize; i++)
{
GI_Item* p_oItem = (*_p_oType)->m_oList.RemoveHead();
delete p_oItem;
}
}
if (*_p_oType)
delete *_p_oType;
}
//==================================================//
// WRITE THE LOG FILE FROM RICH EDIT //
//==================================================//
/****************************************************************************
* Description: Write in the Win_M23D.log file the informations from the third panel
*
* Parameters: bTest : flag to check directory
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
int CDlgMain::m_fn_vWriteInFile( BOOL bTest)
{
FILE *fileW;
xString sDirectory;
// save the current directory
GetCurrentDirectory(256, sDirectory);
switch (g_iData)
{
case 0:
SetCurrentDirectory(g_sGameCommon);
break;
case 1:
if (bTest)
SetCurrentDirectory(g_sGameCommon);
else
SetCurrentDirectory(g_sGameSpecific1);
break;
case 2:
if (bTest)
SetCurrentDirectory(g_sGameCommon);
else
SetCurrentDirectory(g_sGameSpecific2);
break;
}
fileW = fopen("Win_M23D.log", "at+");
int nIndex = m_oRichEditRes.GetLineCount();
char szBuffer[500];
for (int k=m_nIndexLast; k<nIndex; k++)
{
strcpy(szBuffer, "");
int iNumber =m_oRichEditRes.GetLine(k, szBuffer, 100);
if (iNumber<=2)
strcpy(szBuffer, "");
else
szBuffer[iNumber-1]='\0';
fputs(szBuffer, fileW);
fputs("\n", fileW);
}
m_nIndexLast = nIndex;
fputs("*****************************************************\n", fileW);
fputs("\n", fileW);
fputs("\n", fileW);
fclose (fileW);
SetCurrentDirectory(sDirectory);
return TRUE;
}
//==================================================//
// USE FILE LIST //
//==================================================//
/****************************************************************************
* Description: Read the objects from the .ini file and select them in the second list box
*
* Parameters: szName : name of the directory
* p_oType : type of objects
* bTwo : flag for type selection
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vReadIniFile(char *szName, GI_Type *p_oType, BOOL bTwo)
{
int file, j;
int iNbSel, i, iIndex;
char szSel[30][20];
char sName[20], sFileName[20];
FILE *fileR;
GI_Item *p_oItem;
xString sDirectory, sRead, sDir;
GetCurrentDirectory(256, sDirectory);
m_fn_vSelectDir(sDir, szName);
strcpy(sFileName, szName);
strcat(sFileName, ".ini");
fileR = fopen(sFileName, "rt");
i=0;
if (!fileR)
{
SetCurrentDirectory(sDirectory);
if (AfxMessageBox( "There is no .ini file for the selected type", MB_OK))
return;
}
char * sNb;
switch (g_iData)
{
case 0:
while((fgets(sRead, 256, fileR) != NULL) && strstr(sRead, "[GameData]") );
if (strstr(sRead, "\n"))
sRead[strlen(sRead)-1]='\0';
strcpy(szSel[i], sRead);
i++;
break;
case 1:
sNb = fgets(sRead, 256, fileR);
while((sNb != NULL) && !strstr(sRead, "[GameSpecific1]") )
fgets(sRead, 256, fileR);
break;
case 2:
sNb = fgets(sRead, 256, fileR);
while((sNb != NULL) && !strstr(sRead, "[GameSpecific2]") )
fgets(sRead, 256, fileR);
break;
}
if (strstr(sRead, "[GameSpecific1]") && !g_iData)
{
AfxMessageBox( "The .ini file for the selected type doesn't contain any selected objects. Please, use Build File List or Add to File List options!", MB_OK);
fclose(fileR);
SetCurrentDirectory(sDirectory);
return;
}
while( fgets(sRead, 256, fileR) != NULL)
{
if (strstr(sRead, "[GameSpecific1]"))
break;
if (strstr(sRead, "[GameSpecific2]"))
break;
if (strstr(sRead, "\n"))
sRead[strlen(sRead)-1]='\0';
strcpy(szSel[i], sRead);
i++;
}
iNbSel=i;
if (!iNbSel)
AfxMessageBox( "The .ini file for the selected type doesn't contain any selected objects. Please, use Build File List or Add to File List options!", MB_OK);
fclose(fileR);
SetCurrentDirectory(sDirectory);
if (bTwo)
{
iIndex= m_oListType->FindStringExact( -1, szName );
m_oListType->SetCurSel(iIndex);
OnSelchangeListType() ;
}
j=0;
for (i=0; i<iNbSel; i++)
{
iIndex= m_oListObject->FindStringExact( -1, szSel[i] );
if (iIndex == LB_ERR)
{
j++;
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;
}
if (g_bStandardConfig)
if (j==iNbSel && j)
AfxMessageBox( "The .ini file contains only objects that cannot be found in rawdata directory!", MB_OK);
m_fn_vEnableButtonAll();
m_fn_vEnableButtonConvert();
if (p_oType->m_iSelected==m_oListObject->GetCount())
m_oSelectList.EnableWindow(FALSE);
else
m_oSelectList.EnableWindow(TRUE);
if (p_oType->m_iSelected>0)
m_oClearList.EnableWindow(TRUE);
else
m_oClearList.EnableWindow(FALSE);
// g_bGenerateRLI = FALSE;
if (m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected)
{
p_oItem = m_p_oTypeBanks->m_oList.GetHead();
POSITION pos= m_p_oTypeBanks->m_oList.GetHeadPosition( );
for (i=0; i<m_p_oTypeBanks->m_oList.GetCount(); i++)
{
// add the objects in the list box with objects
if (p_oItem->m_bActived)
{
if (g_bStandardConfig)
sprintf(sName, "%s\\World\\Graphics\\Objects\\Banks\\%s.spo", g_stInitialData.szRawData, p_oItem->m_szName);
else
sprintf(sName, "%s\\%s.spo", g_szBanks, p_oItem->m_szName);
if ((file = open(sName, O_RDONLY))!=-1)
{
g_bGenerateRLI = TRUE;
close(file);
}
}
if (pos) m_p_oTypeBanks->m_oList.GetNext( pos );
}
}
if ((m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected && g_bGenerateRLI)||(m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected))
m_oCheckGenerateRLI.EnableWindow(TRUE);
else
m_oCheckGenerateRLI.EnableWindow(FALSE);
if (bTwo)
{
m_oListType->SetCurSel(0);
OnSelchangeListType();
}
m_oListObject->Invalidate(TRUE);
}
/****************************************************************************
* Description: Search the .ini file for an object specified.
*
* Parameters: szName : name of the directory
* szObject : object to search
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
BOOL CDlgMain::m_fn_bSearchInFile(char *szName, char *szObject)
{
char sFileName[20], *sNb;
FILE *fileR;
xString sDirectory, sRead, sDir;
GetCurrentDirectory(256, sDirectory);
m_fn_vSelectDir(sDir, szName);
strcpy(sFileName, szName);
strcat(sFileName, ".ini");
fileR = fopen(sFileName, "rt");
if (!fileR)
{
SetCurrentDirectory(sDirectory);
return FALSE;
}
switch (g_iData)
{
case 0:
while((fgets(sRead, 256, fileR) != NULL) && !strstr(sRead, "[GameSpecific1]") )
{
sRead[strlen(sRead)-1]='\0';
if (!strcmp(sRead, szObject))
{ fclose(fileR);
SetCurrentDirectory(sDirectory);
return TRUE;
}
}
break;
case 1:
while((fgets(sRead, 256, fileR) != NULL) && !strstr(sRead, "[GameSpecific1]"));
sNb = fgets(sRead, 256, fileR);
while((sNb != NULL) && !strstr(sRead, "[GameSpecific2]") )
{
sRead[strlen(sRead)-1]='\0';
if (!strcmp(sRead, szObject))
{ fclose(fileR);
SetCurrentDirectory(sDirectory);
return TRUE;
}
sNb = fgets(sRead, 256, fileR);
}
break;
case 2:
while((fgets(sRead, 256, fileR) != NULL) && !strstr(sRead, "[GameSpecific2]"));
while(fgets(sRead, 256, fileR) != NULL)
{
sRead[strlen(sRead)-1]='\0';
if (!strcmp(sRead, szObject))
{ fclose(fileR);
SetCurrentDirectory(sDirectory);
return TRUE;
}
}
break;
}
fclose(fileR);
SetCurrentDirectory(sDirectory);
return FALSE;
}
/****************************************************************************
* Description: Set the objects selected in the .ini file specified.
*
* Parameters: szName : name of the directory
* szObject : object to search
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vSetFromFileList(char *szName, char *szObject)
{
if (!stricmp(szName, "All"))
{
int iIndex = m_oListType->FindString(-1, szObject);
if (iIndex==LB_ERR)
if (AfxMessageBox( "There is nothing to convert! Please, choose another type of object for conversion", MB_OK))
return;
GI_Type *p_oType = (GI_Type *)m_oListType->GetItemData(iIndex);
m_fn_vSelectAllInList(p_oType, TRUE);
}
if (!stricmp(szName, "fList"))
{
int iIndex = m_oListType->FindString(-1, szObject);
if (iIndex==LB_ERR)
if (AfxMessageBox( "There is nothing to convert! Please, choose another type of object for conversion", MB_OK))
return;
GI_Type *p_oType = (GI_Type *)m_oListType->GetItemData( iIndex );
char szName[20];
strcpy(szName, p_oType -> m_fn_p_oGetName());
m_fn_vReadIniFile(szName, p_oType, 1);
}
}
/****************************************************************************
* Description: Set the objects selected in the .ini file specified.
*
* Parameters: sDir : returs directory
* szName : type name
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void CDlgMain::m_fn_vSelectDir(xString sDir, char *szName)
{
if (g_bStandardConfig)
{
switch (g_iRaw)
{
case 0:
if (!strcmp(szName, "Anims")|| !strcmp(szName, "Textures"))
sprintf(sDir, "%s\\World\\Graphics\\%s\\", g_stInitialData.szRawData, szName);
if (!strcmp(szName, "Banks") || !strcmp(szName, "Classes"))
sprintf(sDir, "%s\\World\\Graphics\\Objects\\%s\\", g_stInitialData.szRawData, szName);
if (!strcmp(szName, "Families") || !strcmp(szName, "Levels"))
sprintf(sDir, "%s\\World\\%s\\", g_stInitialData.szRawData, szName);
SetCurrentDirectory(sDir);
break;
case 1:
if (!strcmp(szName, "Anims")|| !strcmp(szName, "Textures"))
sprintf(sDir, "%s\\World\\Graphics\\%s\\", g_stInitialData.szRawSpecific1, szName);
if (!strcmp(szName, "Banks") || !strcmp(szName, "Classes"))
sprintf(sDir, "%s\\World\\Graphics\\Objects\\%s\\", g_stInitialData.szRawSpecific1, szName);
if (!strcmp(szName, "Families") || !strcmp(szName, "Levels"))
sprintf(sDir, "%s\\World\\%s\\", g_stInitialData.szRawSpecific1, szName);
SetCurrentDirectory(sDir);
break;
case 2:
if (!strcmp(szName, "Anims")|| !strcmp(szName, "Textures"))
sprintf(sDir, "%s\\World\\Graphics\\%s\\", g_stInitialData.szRawSpecific2, szName);
if (!strcmp(szName, "Banks") || !strcmp(szName, "Classes"))
sprintf(sDir, "%s\\World\\Graphics\\Objects\\%s\\", g_stInitialData.szRawSpecific2, szName);
if (!strcmp(szName, "Families") || !strcmp(szName, "Levels"))
sprintf(sDir, "%s\\World\\%s\\", g_stInitialData.szRawSpecific2, szName);
SetCurrentDirectory(sDir);
break;
}
}
else
{ if (!strcmp(szName, "Anims"))
sprintf(sDir, "%s\\", g_szAnims);
if (!strcmp(szName, "Banks"))
sprintf(sDir, "%s\\", g_szBanks);
if (!strcmp(szName, "Classes"))
sprintf(sDir, "%s\\", g_szClasses);
if (!strcmp(szName, "Families"))
sprintf(sDir, "%s\\", g_szFamilies);
if (!strcmp(szName, "Levels"))
sprintf(sDir, "%s\\", g_szLevels);
if (!strcmp(szName, "Textures"))
sprintf(sDir, "%s\\", g_szTextures);
SetCurrentDirectory(sDir);
}
}