/*========================================================================= * * DlgMain2.cpp - implementation file for main window class * Conversion functions * * Version 1.0 * Revision date * *=======================================================================*/ #include "stdafx.h" #include "DlgMain.h" #include "main.h" #include "system.h" #include "print.h" #include "DlgWarning.h" #include "IniData.h" #include "SpoLoad.h" #include "Anims.h" #include "Banks.h" #include "Classes.h" #include "Families.h" #include "Levels.h" #include "Textures.h" //--- Globals --------------------------------------------------------------- int g_iResultIndex[100]; int g_iCommandIndex[1000]; //--- Global statics -------------------------------------------------------- char gs_szCom[20000]; //--------------------------------------------------------------------------- /**************************************************************************** * Description: Convert the selected objects * * Parameters: *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void CDlgMain::m_fn_vConvertData() { int i; int j=2, l=1; char szCommand[20000]; FILE *fileW; xString sRaw, sGame; xString sDirectory, sGameDir; xString sComment, sDate, sTime; // init conversion flags m_bConversion = TRUE; // disable buttons during conversion m_fn_TabC_vDisableAllButtons(); // activate result panel m_fn_TabC_vShowControlsPanelRes() ; m_oMainPanel.SetCurSel(2); m_fn_TabC_vShowControlsPanelRes() ; RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); // init all variables MLT_vInitVariables(); // set default game directories sprintf(g_sGameData,g_stInitialData.szGameData); sprintf(g_sGameCommon,"%s", g_stInitialData.szGameData); sprintf(g_sGameSpecific1,"%s", g_stInitialData.szGameSpecific1); sprintf(g_sGameSpecific2,"%s", g_stInitialData.szGameSpecific2); // set default raw directories sprintf(g_sRawData, "%s", g_stInitialData.szRawData); sprintf(g_sRawCommon,"%s", g_stInitialData.szRawData); sprintf(g_sRawSpecific1,"%s", g_stInitialData.szRawSpecific1); sprintf(g_sRawSpecific2,"%s", g_stInitialData.szRawSpecific2); // empty the result windows fn_ComRes_vDeleteLines( &m_oRichEditCom); fn_ComRes_vDeleteLines( &m_oRichEditRes); // init parameters strcpy(gs_szCom, ""); for ( i=0; i<100; i++) g_iResultIndex[i] = 0; // update specific directories if (g_iData==2) MLT_vSetDataSpecific2(); if (g_iData==1) MLT_vSetDataSpecific1(); // build the command line m_fn_vBuildCommandLine(szCommand); // chnage directory GetCurrentDirectory(256, sDirectory); switch (g_iData) { case 0: strcpy(sGameDir, g_sGameCommon); strcpy(sGame, g_stInitialData.szGameData); break; case 1: strcpy(sGameDir, g_sGameSpecific1); strcpy(sGame, g_stInitialData.szGameSpecific1); break; case 2: strcpy(sGameDir, g_sGameSpecific2); strcpy(sGame, g_stInitialData.szGameSpecific2); break; } SetCurrentDirectory(sGameDir); switch (g_iRaw) { case 0: strcpy(sRaw, g_stInitialData.szRawData); break; case 1: strcpy(sRaw, g_stInitialData.szRawSpecific1); break; case 2: strcpy(sRaw, g_stInitialData.szRawSpecific2); break; } // write the command line in the result file if (!g_bFamilyMode || !m_bRun) { fileW = fopen("Win_M23D.log", "at+"); fputs("*****************************************************\n", fileW); fputs("Conversion date : ", fileW); _strtime(sTime); _strdate(sDate); sprintf(sComment, "%s %s\n", sDate, sTime); fputs(sComment, fileW); fputs("Conversion command : \n", fileW); fputs(szCommand, fileW); fputs("\n", fileW); fputs("---------------------Result-------------------------\n", fileW); fclose(fileW); } SetCurrentDirectory(sDirectory); MLT_vSetData(); // init progress line m_oProgress.SetRange( 0, m_iCountOfSelections+1 ); m_oProgress.SetPos( 1 ); // convert all types m_fn_vConvertAnimations(sGameDir, sRaw, sGame, &j, &l); m_fn_vConvertTextures(sGameDir, sRaw, sGame, &j, &l); m_fn_vConvertBanks(sGameDir, sRaw, sGame, &j, &l); m_fn_vConvertClasses(sGameDir, sRaw, sGame, &j, &l); m_fn_vConvertFamilies(sGameDir, sRaw, sGame, &j, &l); m_fn_vConvertLevels(sGameDir, sRaw, sGame, &j, &l); // update dialog m_fn_vEnableButtons(FALSE); GetDlgItem(IDC_STATIC_PROGRESS)->ShowWindow(FALSE); m_fn_TabC_vEnableButtons(); m_bConversion = FALSE; RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); // reinit conversion parameters m_iInd = 0; m_nIndexLast = 0; g_bApplyAll=FALSE; //set also the objects from the second list box!!! m_oMainPanel.SetCurSel(2); m_fn_TabC_vShowControlsPanelRes() ; RedrawWindow(NULL,NULL, RDW_INVALIDATE |RDW_UPDATENOW ); } /**************************************************************************** * Description: init all the options from the command line and from INI file * * Parameters: szCommand : command line *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void CDlgMain::m_fn_vBuildCommandLine (char *szCommand) { int i; //if the animations are selected if (m_p_oTypeAnims && m_p_oTypeAnims->m_iSelected) { if(g_bOneAnimMode) g_bOneAnimMode = (m_p_oTypeAnims->m_iSelected != m_p_oTypeAnims->m_oList.GetCount()); g_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(g_sAnim[g_lAnimNum], p_oItem->m_fn_p_oGetName()); g_lAnimNum++; strcat(gs_szCom, "##Animation "); strcat(gs_szCom, g_sAnim[g_lAnimNum-1]); strcat(gs_szCom, " \n"); } m_p_oTypeAnims->m_oList.AddTail(p_oItem); } g_bOneAnimMode=TRUE; } //if the textures are selected if (m_p_oTypeTextures && m_p_oTypeTextures->m_iSelected) { if(g_bOneTextureMode) g_bOneTextureMode = (m_p_oTypeTextures->m_iSelected != m_p_oTypeTextures->m_oList.GetCount()); g_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(g_sTexture[g_lTextureNum], p_oItem->m_fn_p_oGetName()); g_lTextureNum++; strcat(gs_szCom, "##Texture "); strcat(gs_szCom, g_sTexture[g_lTextureNum-1]); strcat(gs_szCom, " \n"); } m_p_oTypeTextures->m_oList.AddTail(p_oItem); } g_bOneTextureMode=TRUE; } //if the banks are selected if (m_p_oTypeBanks && m_p_oTypeBanks->m_iSelected) { if(g_bOneBankMode) g_bOneBankMode = (m_p_oTypeBanks->m_iSelected != m_p_oTypeBanks->m_oList.GetCount()); g_bBankMode = TRUE; for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeBanks->m_oList.RemoveHead(); if (p_oItem->m_bActived) { strcpy(g_sBank[g_lBankNum], p_oItem->m_fn_p_oGetName()); g_lBankNum++; strcat(gs_szCom, "##Bank "); strcat(gs_szCom, g_sBank[g_lBankNum-1]); strcat(gs_szCom, g_bIgnoreZoo ? " - Take Zones & Collisions from 3Dsmax" : " - Take Zones & Collisions from Editors"); strcat(gs_szCom, g_bIgnoreGmt ? " - Take Material Interactive Properties from 3Dsmax" : " - Take Material Interactive Properties from Editors"); strcat(gs_szCom, g_bIgnoreTex ? " - Take Material Visual Properties from 3Dsmax" : " - Take Material Visual Properties from Editors"); if (g_bCopyTextures) strcat(gs_szCom, " - Copy Textures"); if (g_bGenerateRLI) strcat(gs_szCom, " - Generate Blend RLI"); if (g_bCreateBasicFamily) strcat(gs_szCom, " - Create basic family"); strcat(gs_szCom, " \n"); } m_p_oTypeBanks->m_oList.AddTail(p_oItem); } g_bOneBankMode=TRUE; } //if the classes are selected if (m_p_oTypeClasses && m_p_oTypeClasses->m_iSelected) { if(g_bOneClassMode) g_bOneClassMode = (m_p_oTypeClasses->m_iSelected != m_p_oTypeClasses->m_oList.GetCount()); g_bClassMode = TRUE; for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeClasses->m_oList.RemoveHead(); if (p_oItem->m_bActived) { strcpy(g_sClass[g_lClassNum], p_oItem->m_fn_p_oGetName()); g_lClassNum++; strcat(gs_szCom, "##Class "); strcat(gs_szCom, g_sClass[g_lClassNum-1]); strcat(gs_szCom, g_bIgnoreZoo ? " - Take Zones & Collisions from 3Dsmax" : " - Take Zones & Collisions from Editors"); strcat(gs_szCom, g_bIgnoreGmt ? " - Take Material Interactive Properties from 3Dsmax" : " - Take Material Interactive Properties from Editors"); strcat(gs_szCom, g_bIgnoreTex ? " - Take Material Visual Properties from 3Dsmax" : " - Take Material Visual Properties from Editors"); if (g_bCopyTextures) strcat(gs_szCom, " - Copy Textures"); strcat(gs_szCom, " \n"); } m_p_oTypeClasses->m_oList.AddTail(p_oItem); } g_bOneClassMode=TRUE; } //if the families are selected if (m_p_oTypeFamilies && m_p_oTypeFamilies->m_iSelected) { if(g_bOneFamilyMode) g_bOneFamilyMode = (m_p_oTypeFamilies->m_iSelected != m_p_oTypeFamilies->m_oList.GetCount()); g_bFamilyMode = TRUE; for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeFamilies->m_oList.RemoveHead(); if (p_oItem->m_bActived) { strcpy(g_sFamily[g_lFamilyNum], p_oItem->m_fn_p_oGetName()); g_lFamilyNum++; strcat(gs_szCom, "##Family "); strcat(gs_szCom, g_sFamily[g_lFamilyNum-1]); strcat(gs_szCom, g_bIgnoreZoo ? " - Take Zones & Collisions from 3Dsmax" : " - Take Zones & Collisions from Editors"); if (g_bCopyAnims) strcat(gs_szCom, " - Copy Anims"); strcat(gs_szCom, " \n"); } m_p_oTypeFamilies->m_oList.AddTail(p_oItem); } g_bOneFamilyMode=TRUE; } //if the levels are selected if (m_p_oTypeLevels && m_p_oTypeLevels->m_iSelected) { if(g_bOneLevelMode) g_bOneLevelMode = (m_p_oTypeLevels->m_iSelected != m_p_oTypeLevels->m_oList.GetCount()); g_bLevelMode = TRUE; for (i=0; im_oList.GetCount(); i++) { GI_Item * p_oItem = m_p_oTypeLevels->m_oList.RemoveHead(); if (p_oItem->m_bActived) { strcpy(g_sLevel[g_lLevelNum], p_oItem->m_fn_p_oGetName()); g_lLevelNum++; strcat(gs_szCom, "##Level "); strcat(gs_szCom, g_sLevel[g_lLevelNum-1]); strcat(gs_szCom, g_bIgnoreZoo ? " - Take Zones & Collisions from 3Dsmax" : " - Take Zones & Collisions from Editors"); strcat(gs_szCom, g_bIgnoreSct ? " - Take Sectors Information from 3Dsmax" : " - Take Sectors Information from Editors"); strcat(gs_szCom, g_bIgnoreSpo ? " - Take SPO Flags from 3Dsmax" : " - Take SPO Flags from Editors"); strcat(gs_szCom, g_bIgnoreGmt ? " - Take Material Interactive Properties from 3Dsmax" : " - Take Material Interactive Properties from Editors"); strcat(gs_szCom, g_bIgnoreTex ? " - Take Material Visual Properties from 3Dsmax" : " - Take Material Visual Properties from Editors"); if (g_bCopyTextures) strcat(gs_szCom, " - Copy Textures"); if (g_bGenerateRLI) strcat(gs_szCom, " - Generate Blend RLI"); if (g_bUpdateGameDSC) strcat(gs_szCom, " - Update level in game.dsc file"); if (g_bEraseDuplicated) strcat(gs_szCom, " - Erase duplicated points"); if (g_bEraseUnused) strcat(gs_szCom, " - Erase unused points"); strcat(gs_szCom, " \n"); } m_p_oTypeLevels->m_oList.AddTail(p_oItem); } g_bOneLevelMode=TRUE; } // write the complete line fn_vAfxOutputStringCom(gs_szCom, C_ComRes_cNormalLine); //fn_ComRes_vWriteLine( gs_szCom, C_ComRes_cNormalLine ,&m_oRichEditCom, &m_stCharFormatCom); strcat(szCommand, gs_szCom); strcpy(gs_szCom, ""); } /**************************************************************************** * Description: convert all selected animations * * Parameters: sGameDir : game directory * sRaw : chosen raw directory * sGame : chosen game directory * j : * l : *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void CDlgMain::m_fn_vConvertAnimations (char *sGameDir, char *sRaw, char *sGame, int *j, int *l) { xString sDirectory; FILE *fileW; int i; // compute the anim if there is one g_cCategoryType = C_Anim; if(g_bAnimMode) { int k; // update anims.txt GetCurrentDirectory(256, sDirectory); SetCurrentDirectory(sGameDir); fileW = fopen("Anims.txt", "at+"); fputs("Conversion date :", fileW); xString sComment, sDate, sTime; _strtime(sTime); _strdate(sDate); sprintf(sComment, "%s %s\n", sDate, sTime); fputs(sComment, fileW); fclose (fileW); SetCurrentDirectory(sDirectory); // convert all animations for (i=0; i Canceled", fileW); fputs("\n", fileW); } fputs("*****************************************************\n", fileW); fputs("\n", fileW); fputs("\n", fileW); fclose (fileW); // update log file fileW = fopen("Win_M23D.log", "at+"); fputs("*****************************************************\n", fileW); fputs("Conversion date : \n", fileW); _strtime(sTime); _strdate(sDate); sprintf(sComment, "%s %s\n", sDate, sTime); fputs(sComment, fileW); fputs("Conversion command : ", fileW); strcpy(gs_szCom, ""); for(ii = 0; ii < g_lFamilyNum; ii++) { strcat(gs_szCom, "##Family "); strcat(gs_szCom, g_sFamily[ii]); strcat(gs_szCom, g_bIgnoreZoo ? " - Take Zones & Collisions from 3Dsmax" : " - Take Zones & Collisions from Editors"); if (g_bCopyAnims) strcat(gs_szCom, " - Copy Anims"); strcat(gs_szCom, " \n"); } fputs(gs_szCom, fileW); fputs("\n", fileW); fputs("---------------------Result-------------------------\n", fileW); //the command was wrote in the file Win_M23D.log fclose(fileW); m_fn_vWriteInFile( bCommon[0] ); SetCurrentDirectory(sDirectory); } } /**************************************************************************** * Description: convert all selected levels * * Parameters: sGameDir : game directory * sRaw : chosen raw directory * sGame : chosen game directory * j : * l : *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void CDlgMain::m_fn_vConvertLevels (char *sGameDir, char *sRaw, char *sGame, int *j, int *l) { xString sDirectory; FILE *fileW; int i; // compute the Levels if there is one g_cCategoryType = C_Level; if (g_bLevelMode) { int k; xString sGameLevel; //multitextures g_bLevelConversion = TRUE; // read SPO flags MLT_vReadSPOFlagsFile(g_stInitialData.szRawData); // change directory GetCurrentDirectory(256, sDirectory); SetCurrentDirectory(sGameDir); strcpy(sGameLevel, sGameDir); // update Levels.txt fileW = fopen("Levels.txt", "at+"); fputs("Conversion date :", fileW); xString sComment, sDate, sTime; _strtime(sTime); _strdate(sDate); sprintf(sComment, "%s %s\n", sDate, sTime); fputs(sComment, fileW); fclose (fileW); SetCurrentDirectory(sDirectory); // update DSC file m_fn_vUpdateGameDSC(); for (i=0; i