// ShipTexturesDlg.cpp : implementation file // Goober5000 #include "stdafx.h" #include "fred.h" #include "ShipTexturesDlg.h" #include "model/model.h" #include "bmpman/bmpman.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CShipTexturesDlg dialog CShipTexturesDlg::CShipTexturesDlg(CWnd* pParent /*=NULL*/) : CDialog(CShipTexturesDlg::IDD, pParent) { //{{AFX_DATA_INIT(CShipTexturesDlg) m_new_texture = _T(""); m_old_texture_list = 0; //}}AFX_DATA_INIT self_ship = -1; active_texture_index = -1; modified = 0; texture_count = 0; } void CShipTexturesDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CShipTexturesDlg) DDX_Text(pDX, IDC_NEW_TEXTURE, m_new_texture); DDX_CBIndex(pDX, IDC_OLD_TEXTURE_LIST, m_old_texture_list); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CShipTexturesDlg, CDialog) //{{AFX_MSG_MAP(CShipTexturesDlg) ON_WM_CLOSE() ON_CBN_SELCHANGE(IDC_OLD_TEXTURE_LIST, OnSelchangeOldTextureList) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CShipTexturesDlg message handlers void CShipTexturesDlg::OnOK() { int i, k, write_index, z, not_found, temp_bmp, temp_frames, temp_fps; CString missing_files, message; char buf[10]; // update, in case of a last-minute edit OnSelchangeOldTextureList(); // quick skip if nothing modified if (query_modified()) { // sort according to new sort_textures(SORT_NEW); // check for filenames not found not_found = 0; missing_files = _T(""); for (i=0; i 1) ? " files:\n" : " file:\n"); message += missing_files; message += "\nContinue anyway?"; z = MessageBox(message, ((not_found > 1) ? "Some textures were not found." : "A texture was not found."), MB_OKCANCEL | MB_ICONEXCLAMATION | MB_DEFBUTTON2); if (z == IDCANCEL) { return; } } // re-sort according to old sort_textures(); // overwrite old stuff k = 0; write_index = 0; while (k<(MAX_SHIPS * MAX_MODEL_TEXTURES)) { if (stricmp(Fred_texture_replacements[k].ship_name, Ships[self_ship].ship_name)) { // move up, but when copying, src and dest can't be the same if (k != write_index) { texture_set(&Fred_texture_replacements[write_index], &Fred_texture_replacements[k]); } write_index++; } k++; } Fred_num_texture_replacements = write_index; // finally, assign duplicate textures to Fred array for (i=0; iResetContent(); // look for textures to populate the combo box for (i=0; in_textures; i++) { // get texture file name bm_get_filename(pm->maps[i].base_map.original_texture, texture_file); // skip blank textures if (!strlen(texture_file)) continue; // get rid of file extension p = strchr( texture_file, '.' ); if ( p ) { mprintf(( "ignoring extension on file '%s'\n", texture_file )); *p = 0; } // check for duplicate textures in list duplicate = -1; for (j=0; j= 0) continue; // make old texture lowercase strlwr(texture_file); // now add it to the box z = box->AddString(texture_file); // and add it to the field as well strcpy(old_texture_name[texture_count], texture_file); // increment texture_count++; // sort sort_textures(); } // now look for new textures k=0; while (k < Fred_num_texture_replacements) { if (!stricmp(Ships[self_ship].ship_name, Fred_texture_replacements[k].ship_name)) { // look for corresponding old texture for (i=0; inew_texture_id = src->new_texture_id; strcpy(dest->ship_name, src->ship_name); strcpy(dest->old_texture, src->old_texture); strcpy(dest->new_texture, src->new_texture); return dest; }