reman3/Rayman_X/cpa/tempgrp/TGM/Src/DlgPreloadGMT.cpp

152 lines
4.5 KiB
C++

// DlgPreloadGMT.cpp : implementation file
//
#include "stdafx.h"
#include "..\Res\matres.h"
#include "dlgpreloadgmt.h"
#include "ACP_Base.h"
#include "ITF.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgPreloadGMT dialog
CDlgPreloadGMT::CDlgPreloadGMT(CWnd* pParent /*=NULL*/)
: CDialog(CDlgPreloadGMT::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgPreloadGMT)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_szText[0] = 0;
}
void CDlgPreloadGMT::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgPreloadGMT)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgPreloadGMT, CDialog)
//{{AFX_MSG_MAP(CDlgPreloadGMT)
ON_LBN_DBLCLK(IDC_LIST_GMT, OnDblclkListGmt)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgPreloadGMT message handlers
BOOL CDlgPreloadGMT::OnInitDialog()
{
CString csFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\Material\\Material.ini";
char sz255GMTFileName[255],
sz8FileToLoadSection[8],
sz3FileNumber[3];
unsigned char FileNumber = 1;
CListBox *pLB = (CListBox*) GetDlgItem (IDC_LIST_GMT);
CDialog::OnInitDialog();
// TODO: Add extra initialization here
pLB -> ResetContent ();
// List all GMT of the Preload section from Material.ini
do
{
strcpy(sz8FileToLoadSection, "File");
strcat(sz8FileToLoadSection, itoa(FileNumber++, sz3FileNumber, 10) );
GetPrivateProfileString("Preload", sz8FileToLoadSection, "", sz255GMTFileName, 255, csFileName);
if(sz255GMTFileName[0])
{
pLB -> AddString(sz255GMTFileName+(strchr(sz255GMTFileName,'\\')-sz255GMTFileName+1) );
}
} while(sz255GMTFileName[0]);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgPreloadGMT::OnOK()
{
CListBox *pLB = (CListBox*) GetDlgItem (IDC_LIST_GMT);
CString csFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\Material\\Material.ini";
int iIndex = pLB -> GetCurSel ();
if (iIndex != LB_ERR)
{
char sz255GMT[_MAX_FNAME],
sz8FileToLoadSection[8],
sz3FileNumber[3],
sz255GMTFileName[255],
szGMTLine[255][255];
unsigned char ucFileNumber = 1,
ucLineNumber = 0,
ucTmpFileNumber;
char *p_cPoint;
int i=0,
j=0;
// GET the file to remove from the Preload section from Material.ini file
pLB -> GetText (iIndex , m_szText);
// toto.gmt ==> toto\toto.gmt
strcpy(sz255GMT, m_szText);
p_cPoint = strrchr(sz255GMT,'.');
if(p_cPoint) *p_cPoint = 0;
strcat(sz255GMT, "\\");
strcat(sz255GMT,m_szText);
// Search Position of the item into the Preload section
do
{
strcpy(sz8FileToLoadSection, "File");
strcat(sz8FileToLoadSection, itoa(ucFileNumber++, sz3FileNumber, 10) );
GetPrivateProfileString("Preload", sz8FileToLoadSection, "", sz255GMTFileName, 255, csFileName);
} while( strcmp(sz255GMT,sz255GMTFileName) != 0 );
// Get next lines
ucTmpFileNumber = ucFileNumber-1;
do
{
strcpy(sz8FileToLoadSection, "File");
strcat(sz8FileToLoadSection, itoa(ucFileNumber++, sz3FileNumber, 10) );
GetPrivateProfileString("Preload", sz8FileToLoadSection, "", sz255GMTFileName, 255, csFileName);
if(sz255GMTFileName[0])
{
strcpy(szGMTLine[ucLineNumber++], sz255GMTFileName);
}
} while(sz255GMTFileName[0]);
// Rewrite sections
for(i=ucTmpFileNumber;i<ucTmpFileNumber+ucLineNumber;i++)
{
strcpy(sz8FileToLoadSection, "File");
strcat(sz8FileToLoadSection, itoa(i, sz3FileNumber, 10) );
WritePrivateProfileString("Preload", sz8FileToLoadSection, szGMTLine[j++], csFileName);
}
// Remove Last line
strcpy(sz8FileToLoadSection, "File");
strcat(sz8FileToLoadSection, itoa(i, sz3FileNumber, 10) );
WritePrivateProfileString("Preload", sz8FileToLoadSection, NULL, csFileName);
}
CDialog::OnOK();
}
void CDlgPreloadGMT::OnDblclkListGmt()
{
OnOK ();
}