diff --git a/stepmania/src/smpackage/EditInsallations.cpp b/stepmania/src/smpackage/EditInsallations.cpp index fc16059998..bb081f06e6 100644 --- a/stepmania/src/smpackage/EditInsallations.cpp +++ b/stepmania/src/smpackage/EditInsallations.cpp @@ -55,7 +55,7 @@ BOOL EditInsallations::OnInitDialog() CStringArray asInstallDirs; GetStepManiaInstallDirs( asInstallDirs ); - for( int i=0; ifirst ); SortCStringArray( asKeys ); - for( int i=0; iGetStartPosition(); pos != NULL; ) + for( IniFile::key::const_iterator val = pKey->begin(); val != pKey->end(); ++val ) { - CString sName, sValue; - pKey->GetNextAssoc( pos, sName, sValue ); - asNames.Add( sName ); + CString sName = val->first, sValue = val->second; + asNames.push_back( sName ); } SortCStringArray( asNames ); - for( int j=0; j= 3 && + line[0] == '\xef' && + line[1] == '\xbb' && + line[2] == '\xbf' + ) { - if( line[0] == '[' && line[line.GetLength()-1] == ']' ) //if a section heading + /* Obnoxious NT marker for UTF-8. Remove it. */ + line.Delete(0, 3); + } + + if (line == "") + continue; + + StripCrnl(line); + + if ((line.GetLength() >= 2 && line[0] == '/' && line[1] == '/') || line[0] == '#') + continue; /* comment */ + + if (line[0] == '[' && line[line.GetLength()-1] == ']') //if a section heading + { + keyname = line; + keyname.Delete(0); + keyname.Delete(keyname.GetLength()-1); + } + else //if a value + { + int iEqualIndex = line.Find("="); + if( iEqualIndex != -1 ) { - keyname = line; - keyname.TrimLeft('['); - keyname.TrimRight(']'); - } - else //if a value - { - int iIndexOfEqual = line.Find("="); - if( iIndexOfEqual == -1 ) // this is a malformed line - continue; - valuename = line.Left( iIndexOfEqual ); - value = line.Right(line.GetLength()-valuename.GetLength()-1); + CString valuename = line.Left(iEqualIndex); + CString value = line.Right(line.GetLength()-valuename.GetLength()-1); SetValue(keyname,valuename,value); } } } - file.Close(); + + fclose(f); return 1; } -//writes data stored in class to ini file +// writes data stored in class to ini file void IniFile::WriteFile() { - CStdioFile file; - if( !file.Open(path, CFile::modeCreate | CFile::modeWrite ) ) - { - error = "Unable to open ini for writing."; + FILE* fp = fopen( path, "w" ); + + if( fp == NULL ) return; - } - // foreach key - for( int keynum = 0; keynum <= names.GetUpperBound(); keynum++ ) + for (keymap::const_iterator k = keys.begin(); k != keys.end(); ++k) { - CString sTemp; - sTemp.Format( "[%s]\n", names[keynum] ); - file.WriteString( sTemp ); + if (k->second.empty()) + continue; - CMapStringToString &map = keys[keynum]; + fprintf( fp, "[%s]\n", (const char *) k->first ); - CStringArray as; + for (key::const_iterator i = k->second.begin(); i != k->second.end(); ++i) + fprintf( fp, "%s=%s\n", (const char *)i->first, (const char *)i->second ); - // for each value_name/value pair - for( POSITION pos = map.GetStartPosition(); pos != NULL; ) - { - CString value_name; - CString value; - map.GetNextAssoc( pos, value_name, value ); - - sTemp.Format( "%s=%s\n", value_name, value ); - as.Add( sTemp ); - } - - SortCStringArray( as ); - for( int i=0; isecond.size(); } -//gets value of [keyname] valuename = -//overloaded to return CString, int, and double -BOOL IniFile::GetValue(CString keyname, CString valuename, CString value_out) +// gets value of [keyname] valuename = +bool IniFile::GetValue(const CString &keyname, const CString &valuename, CString& value) const { - int keynum = FindKey(keyname);//, valuenum = FindValue(keynum,valuename); - if( keynum == -1 ) + keymap::const_iterator k = keys.find(keyname); + if (k == keys.end()) { error = "Unable to locate specified key."; - return FALSE; + return false; } - CMapStringToString &map = keys[keynum]; - if( !map.Lookup(valuename, value_out) ) + key::const_iterator i = k->second.find(valuename); + + if (i == k->second.end()) { error = "Unable to locate specified value."; - return FALSE; - } - return TRUE; -} - -//gets value of [keyname] valuename = -//overloaded to return CString, int, and double -CString IniFile::GetValue(CString keyname, CString valuename) -{ - int keynum = FindKey(keyname);//, valuenum = FindValue(keynum,valuename); - if( keynum == -1 ) - { - error = "Unable to locate specified key."; - return ""; + return false; } - CMapStringToString &map = keys[keynum]; - CString value; - if( !map.Lookup(valuename, value) ) - { - error = "Unable to locate specified value."; - return ""; - } - return value; + value = i->second; + return true; } -//gets value of [keyname] valuename = -//overloaded to return CString, int, and double -int IniFile::GetValueI(CString keyname, CString valuename) +// gets value of [keyname] valuename = +bool IniFile::GetValueI(const CString &keyname, const CString &valuename, int& value) const { - return atoi( GetValue(keyname,valuename) ); + CString sValue; + if( !GetValue(keyname,valuename,sValue) ) + return false; + sscanf( sValue, "%d", &value ); + return true; } -//gets value of [keyname] valuename = -//overloaded to return CString, int, and double -double IniFile::GetValueF(CString keyname, CString valuename) +bool IniFile::GetValueU(const CString &keyname, const CString &valuename, unsigned &value) const { - return atof( GetValue(keyname, valuename) ); + CString sValue; + if( !GetValue(keyname,valuename,sValue) ) + return false; + sscanf( sValue, "%u", &value ); + return true; } -//sets value of [keyname] valuename =. -//specify the optional paramter as false (0) if you do not want it to create -//the key if it doesn't exist. Returns true if data entered, false otherwise -//overloaded to accept CString, int, and double -BOOL IniFile::SetValue(CString keyname, CString valuename, CString value, BOOL create) +// gets value of [keyname] valuename = +bool IniFile::GetValueF(const CString &keyname, const CString &valuename, float& value) const { - int keynum = FindKey(keyname); - - if( keynum == -1 ) //if key doesn't exist - { - if( !create ) //and user does not want to create it, - return FALSE; //stop entering this key - names.SetSize(names.GetSize()+1); - keys.SetSize(keys.GetSize()+1); - keynum = names.GetSize()-1; - names[keynum] = keyname; - } - - // insert value - CMapStringToString &map = keys[keynum]; - CString oldvalue; - if( !map.Lookup(valuename, oldvalue) && !create ) - return FALSE; - map[valuename] = value; - return TRUE; + CString sValue; + if( !GetValue(keyname,valuename,sValue) ) + return false; + sscanf( sValue, "%f", &value ); + return true; } -//sets value of [keyname] valuename =. -//specify the optional paramter as false (0) if you do not want it to create -//the key if it doesn't exist. Returns true if data entered, false otherwise -//overloaded to accept CString, int, and double -BOOL IniFile::SetValueI(CString keyname, CString valuename, int value, BOOL create) +// gets value of [keyname] valuename = +bool IniFile::GetValueB(const CString &keyname, const CString &valuename, bool& value) const { - CString temp; - temp.Format("%d",value); - return SetValue(keyname, valuename, temp, create); + CString sValue; + if( !GetValue(keyname,valuename,sValue) ) + return false; + value = atoi(sValue) != 0; + return true; } -//sets value of [keyname] valuename =. -//specify the optional paramter as false (0) if you do not want it to create -//the key if it doesn't exist. Returns true if data entered, false otherwise -//overloaded to accept CString, int, and double -BOOL IniFile::SetValueF(CString keyname, CString valuename, double value, BOOL create) +// sets value of [keyname] valuename =. +// specify the optional paramter as false (0) if you do not want it to create +// the key if it doesn't exist. Returns true if data entered, false otherwise +bool IniFile::SetValue(const CString &keyname, const CString &valuename, const CString &value, bool create) { - CString temp; - temp.Format("%e",value); - return SetValue(keyname, valuename, temp, create); + if (!create && keys.find(keyname) == keys.end()) //if key doesn't exist + return false; // stop entering this key + + // find value + if (!create && keys[keyname].find(valuename) == keys[keyname].end()) + return false; + + keys[keyname][valuename] = value; + return true; } -//deletes specified value -//returns true if value existed and deleted, false otherwise -BOOL IniFile::DeleteValue(CString keyname, CString valuename) +// sets value of [keyname] valuename =. +// specify the optional paramter as false (0) if you do not want it to create +// the key if it doesn't exist. Returns true if data entered, false otherwise +bool IniFile::SetValueI(const CString &keyname, const CString &valuename, int value, bool create) { - int keynum = FindKey(keyname); - if( keynum == -1 ) - return FALSE; - - CMapStringToString &map = keys[keynum]; - return map.RemoveKey( valuename ); + return SetValue(keyname, valuename, ssprintf("%d",value), create); } -//deletes specified key and all values contained within -//returns true if key existed and deleted, false otherwise -BOOL IniFile::DeleteKey(CString keyname) +bool IniFile::SetValueU(const CString &keyname, const CString &valuename, unsigned value, bool create) { - int keynum = FindKey(keyname); - if (keynum == -1) - return 0; - keys.RemoveAt(keynum); - names.RemoveAt(keynum); - return 1; + return SetValue(keyname, valuename, ssprintf("%u",value), create); } -///////////////////////////////////////////////////////////////////// -// Private Functions -///////////////////////////////////////////////////////////////////// - -//returns index of specified key, or -1 if not found -int IniFile::FindKey(CString keyname) +bool IniFile::SetValueF(const CString &keyname, const CString &valuename, float value, bool create) { - int keynum = 0; - while ( keynum < keys.GetSize() && names[keynum] != keyname) - keynum++; - if (keynum == keys.GetSize()) - return -1; - return keynum; + return SetValue(keyname, valuename, ssprintf("%f",value), create); } +bool IniFile::SetValueB(const CString &keyname, const CString &valuename, bool value, bool create) +{ + return SetValue(keyname, valuename, ssprintf("%d",value), create); +} + +// deletes specified value +// returns true if value existed and deleted, false otherwise +bool IniFile::DeleteValue(const CString &keyname, const CString &valuename) +{ + keymap::iterator k = keys.find(keyname); + if (k == keys.end()) + return false; + + key::iterator i = k->second.find(valuename); + if(i == k->second.end()) + return false; + + k->second.erase(i); + return true; +} + +// deletes specified key and all values contained within +// returns true if key existed and deleted, false otherwise +bool IniFile::DeleteKey(const CString &keyname) +{ + keymap::iterator k = keys.find(keyname); + if (k == keys.end()) + return false; + + keys.erase(k); + return true; +} + +const IniFile::key *IniFile::GetKey(const CString &keyname) const +{ + keymap::const_iterator i = keys.find(keyname); + if(i == keys.end()) return NULL; + return &i->second; +} + +void IniFile::SetValue(const CString &keyname, const key &key) +{ + keys[keyname]=key; +} + +void IniFile::RenameKey(const CString &from, const CString &to) +{ + if(keys.find(from) == keys.end()) + return; + if(keys.find(to) != keys.end()) + return; + + keys[to] = keys[from]; + keys.erase(from); +} diff --git a/stepmania/src/smpackage/IniFile.h b/stepmania/src/smpackage/IniFile.h index 8ffb19aab5..7c7a1c6db2 100644 --- a/stepmania/src/smpackage/IniFile.h +++ b/stepmania/src/smpackage/IniFile.h @@ -1,72 +1,59 @@ +#ifndef INIFILE_H +#define INIFILE_H /* ----------------------------------------------------------------------------- - File: IniFile.h + Class: IniFile Desc: Wrapper for reading and writing an .ini file. - Copyright (c) 2001-2002 by the persons listed below. All rights reserved. + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Adam Clauss + Chris Danford ----------------------------------------------------------------------------- */ - -#ifndef _INIFILE_H_ -#define _INIFILE_H_ - -#include -//#include - +#include +using namespace std; class IniFile { - //all private variables public: + // all keys are of this type + typedef map key; + typedef map keymap; + + typedef keymap::const_iterator const_iterator; + const_iterator begin() const { return keys.begin(); } + const_iterator end() const { return keys.end(); } + +private: //stores pathname of ini file to read/write CString path; - - //all keys are of this time - typedef CMapStringToString key; - //list of keys in ini - CArray keys; - - //corresponding list of keynames - CStringArray names; + // keys in ini + keymap keys; - - //all private functions -//private: - - //returns index of specified key, or -1 if not found - int FindKey(CString keyname); - - - //public variables public: //will contain error info if one occurs //ended up not using much, just in ReadFile and GetValue - CString error; - - - //public functions -public: - //default constructor - IniFile(); + mutable CString error; //constructor, can specify pathname here instead of using SetPath later - IniFile(CString inipath); + IniFile(CString inipath = ""); //default destructor virtual ~IniFile(); //sets path of ini file to read and write from void SetPath(CString newpath); + CString GetPath() const { return path; } //reads ini file specified using IniFile::SetPath() //returns true if successful, false otherwise - BOOL ReadFile(); + bool ReadFile(); //writes data stored in class to ini file void WriteFile(); @@ -75,38 +62,47 @@ public: void Reset(); //returns number of keys currently in the ini - int GetNumKeys(); - - //returns a pointer to the key for direct modification - CMapStringToString* GetKeyPointer( CString keyname ); + int GetNumKeys() const; //returns number of values stored for specified key - int GetNumValues( CString keyname ); + int GetNumValues(const CString &keyname) const; //gets value of [keyname] valuename = - //overloaded to return CString, int, and double, //returns "", or 0 if key/value not found. Sets error member to show problem - BOOL GetValue(CString keyname, CString valuename, CString value_out); - CString GetValue(CString keyname, CString valuename); - int GetValueI(CString keyname, CString valuename); - double GetValueF(CString keyname, CString valuename); + bool GetValue(const CString &key, const CString &valuename, CString& value) const; + bool GetValueI(const CString &key, const CString &valuename, int& value) const; + bool GetValueU(const CString &key, const CString &valuename, unsigned& value) const; + bool GetValueF(const CString &key, const CString &valuename, float& value) const; + bool GetValueB(const CString &key, const CString &valuename, bool& value) const; + bool GetValue(const CString &key, const CString &valuename, int& value) const { return GetValueI(key, valuename, value); } + bool GetValue(const CString &key, const CString &valuename, float& value) const { return GetValueF(key, valuename, value); } + bool GetValue(const CString &key, const CString &valuename, bool& value) const { return GetValueB(key, valuename, value); } //sets value of [keyname] valuename =. //specify the optional paramter as false (0) if you do not want it to create //the key if it doesn't exist. Returns true if data entered, false otherwise - //overloaded to accept CString, int, and double - BOOL SetValue(CString key, CString valuename, CString value, BOOL create = 1); - BOOL SetValueI(CString key, CString valuename, int value, BOOL create = 1); - BOOL SetValueF(CString key, CString valuename, double value, BOOL create = 1); + bool SetValue(const CString &key, const CString &valuename, const CString &value, bool create = 1); + bool SetValueI(const CString &key, const CString &valuename, int value, bool create = 1); + bool SetValueU(const CString &key, const CString &valuename, unsigned value, bool create = 1); + bool SetValueF(const CString &key, const CString &valuename, float value, bool create = 1); + bool SetValueB(const CString &key, const CString &valuename, bool value, bool create = 1); + bool SetValue(const CString &key, const CString &valuename, int value, bool create = 1) { return SetValueI(key, valuename, value, create); } //deletes specified value //returns true if value existed and deleted, false otherwise - BOOL DeleteValue(CString keyname, CString valuename); + bool DeleteValue(const CString &keyname, const CString &valuename); //deletes specified key and all values contained within //returns true if key existed and deleted, false otherwise - BOOL DeleteKey(CString keyname); + bool DeleteKey(const CString &keyname); + + const key *GetKey(const CString &keyname) const; + void SetValue(const CString &keyname, const key &key); + + /* Rename a key. For example, call RenameKey("foo", "main") after + * reading an INI where [foo] is an alias to [main]. If to already + * exists, nothing happens. */ + void RenameKey(const CString &from, const CString &to); }; - #endif diff --git a/stepmania/src/smpackage/RageUtil.cpp b/stepmania/src/smpackage/RageUtil.cpp index a404fb0da1..829841b21b 100644 --- a/stepmania/src/smpackage/RageUtil.cpp +++ b/stepmania/src/smpackage/RageUtil.cpp @@ -12,6 +12,7 @@ */ #include "RageUtil.h" +#include ULONG randseed = time(NULL); @@ -34,8 +35,8 @@ float TimeToSeconds( CString sHMS ) CStringArray arrayBits; split( sHMS, ":", arrayBits, false ); - while( arrayBits.GetSize() < 3 ) - arrayBits.InsertAt( 0, "0" ); // pad missing bits + while( arrayBits.size() < 3 ) + arrayBits.insert(arrayBits.begin(), "0" ); // pad missing bits float fSeconds = 0; fSeconds += atoi( arrayBits[0] ) * 60 * 60; @@ -84,22 +85,20 @@ CString vssprintf( LPCTSTR fmt, va_list argList) //----------------------------------------------------------------------------- CString join( const CString &Deliminator, const CStringArray& Source) { - if( Source.GetSize() == 0 ) + if( Source.empty() ) return ""; - CString csReturn; CString csTmp; // Loop through the Array and Append the Deliminator - for( int iNum = 0; iNum < Source.GetSize()-1; iNum++ ) { - csTmp += Source.GetAt(iNum); + for( unsigned iNum = 0; iNum < Source.size()-1; iNum++ ) { + csTmp += Source[iNum]; csTmp += Deliminator; } - csTmp += Source.GetAt( Source.GetSize()-1 ); + csTmp += Source.back(); return csTmp; } - //----------------------------------------------------------------------------- // Name: split() // Desc: @@ -122,7 +121,7 @@ void split( const CString &Source, const CString &Deliminator, CStringArray& Add if( newCString.IsEmpty() && bIgnoreEmpty ) ; // do nothing else - AddIt.Add(AddCString); + AddIt.push_back(AddCString); tmpCString = newCString.Mid(pos + Deliminator.GetLength()); newCString = tmpCString; @@ -132,10 +131,12 @@ void split( const CString &Source, const CString &Deliminator, CStringArray& Add if( newCString.IsEmpty() && bIgnoreEmpty ) ; // do nothing else - AddIt.Add(newCString); + AddIt.push_back(newCString); } + + //----------------------------------------------------------------------------- // Name: splitpath() // Desc: @@ -212,49 +213,36 @@ void splitpath( const bool UsingDirsOnly, const CString &Path, CString& Drive, C //----------------------------------------------------------------------------- void splitrelpath( const CString &Path, CString& Dir, CString& FName, CString& Ext ) { - // need to split on both forward slashes and back slashes - CStringArray sPathBits; + /* Find the last slash or backslash. */ + int Last = max(Path.ReverseFind('/'), Path.ReverseFind('\\')); - CStringArray sBackShashPathBits; - split( Path, "\\", sBackShashPathBits, true ); - - for( int i=0; i 1 ) // file has extension and possibly multiple periods + else if( sFNameAndExtBits.size() > 1 ) // file has extension and possibly multiple periods { - Ext = sFNameAndExtBits[ sFNameAndExtBits.GetSize()-1 ]; + Ext = sFNameAndExtBits[ sFNameAndExtBits.size()-1 ]; // subtract the Ext and last period from FNameAndExt FName = sFNameAndExt.Left( sFNameAndExt.GetLength()-Ext.GetLength()-1 ); @@ -284,9 +272,9 @@ void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bRe continue; if( bReturnPathToo ) - AddTo.Add( sDir + sDirName ); + AddTo.push_back( sDir + sDirName ); else - AddTo.Add( sDirName ); + AddTo.push_back( sDirName ); } while( ::FindNextFile( hFind, &fd ) ); @@ -460,7 +448,7 @@ int GetHashForDirectory( CString sDir ) CStringArray arrayFiles; GetDirListing( sDir+"\\*.*", arrayFiles, false ); - for( int i=0; i 0; } -void SortCStringArray( CStringArray &arrayCStrings, const bool bSortAcsending ) +void SortCStringArray( CStringArray &arrayCStrings, const bool bSortAscending ) { - qsort( arrayCStrings.GetData(), arrayCStrings.GetSize(), sizeof(CString), bSortAcsending ? CompareCStringsAsc : CompareCStringsDesc ); + sort( arrayCStrings.begin(), arrayCStrings.end(), + CompareCStringsDesc); } - +void StripCrnl(CString &s) +{ + while( s.GetLength() && (s[s.GetLength()-1] == '\r' || s[s.GetLength()-1] == '\n') ) + s.Delete(s.GetLength()-1); +} LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata) { diff --git a/stepmania/src/smpackage/RageUtil.h b/stepmania/src/smpackage/RageUtil.h index c8b4ed40ff..7336f77491 100644 --- a/stepmania/src/smpackage/RageUtil.h +++ b/stepmania/src/smpackage/RageUtil.h @@ -157,9 +157,8 @@ bool IsAFile( const CString &sPath ); bool IsADirectory( const CString &sPath ); DWORD GetFileSizeInBytes( const CString &sFilePath ); -int CompareCStringsAsc(const void *arg1, const void *arg2); -int CompareCStringsDesc(const void *arg1, const void *arg2); void SortCStringArray( CStringArray &AddTo, const bool bSortAcsending = true ); +void StripCrnl(CString &s); LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata); diff --git a/stepmania/src/smpackage/SMPackageInstallDlg.cpp b/stepmania/src/smpackage/SMPackageInstallDlg.cpp index 362e8bc568..a8e39d9eda 100644 --- a/stepmania/src/smpackage/SMPackageInstallDlg.cpp +++ b/stepmania/src/smpackage/SMPackageInstallDlg.cpp @@ -260,10 +260,8 @@ void CSMPackageInstallDlg::RefreshInstallationList() CStringArray asInstallDirs; GetStepManiaInstallDirs( asInstallDirs ); - for( int i=0; i +#include +using namespace std; + #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE @@ -83,9 +87,9 @@ CString ReplaceInvalidFileNameChars( CString sOldFileName ) return sNewFileName; } -void GetFilePaths( CString sDirOrFile, CStringArray& asPathToFilesOut ) +void GetFilePaths( CString sDirOrFile, vector &asPathToFilesOut ) { - CStringArray asDirectoriesToExplore; + vector asDirectoriesToExplore; // HACK: // Must use backslashes in the path, or else WinZip and WinRAR don't see the files. @@ -99,18 +103,18 @@ void GetFilePaths( CString sDirOrFile, CStringArray& asPathToFilesOut ) if( IsAFile(sDirOrFile) ) { - asPathToFilesOut.Add( sDirOrFile ); + asPathToFilesOut.push_back( sDirOrFile ); return; } GetDirListing( sDirOrFile, asPathToFilesOut, false, true ); GetDirListing( sDirOrFile, asDirectoriesToExplore, true, true ); - while( asDirectoriesToExplore.GetSize() > 0 ) + while( asDirectoriesToExplore.size() > 0 ) { GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asPathToFilesOut, false, true ); GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asDirectoriesToExplore, true, true ); - asDirectoriesToExplore.RemoveAt( 0 ); + asDirectoriesToExplore.erase( 0 ); } } @@ -163,15 +167,15 @@ bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExp zip.SetGlobalComment( sComment ); /* Find files to add to zip. */ - int i; - CStringArray asFilePaths; - for( i=0; i asFilePaths; + for( i=0; i1?"s":"", join("', '",asExportedPackages) ); + if( asFailedPackages.size() == 0 ) + sMessage = ssprintf("Successfully exported the package%s '%s' to your Desktop.", asFailedPackages.size()>1?"s":"", join("', '",asExportedPackages) ); else sMessage = ssprintf(" The packages %s failed to export.", join(", ",asFailedPackages) ); AfxMessageBox( sMessage ); @@ -392,7 +396,7 @@ void CSmpackageExportDlg::GetCheckedPaths( CStringArray& aPathsOut ) sPath.TrimRight('\\'); // strip off last slash - aPathsOut.Add( sPath ); + aPathsOut.push_back( sPath ); } } @@ -416,7 +420,7 @@ void CSmpackageExportDlg::RefreshInstallationList() CStringArray asInstallDirs; GetStepManiaInstallDirs( asInstallDirs ); - for( int i=0; i // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT +#include +using namespace std; +#define CStringArray vector //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/stepmania/src/smpackage/onvertThemeDlg.cpp b/stepmania/src/smpackage/onvertThemeDlg.cpp index 4cf24ec4cb..40abd4ab58 100644 --- a/stepmania/src/smpackage/onvertThemeDlg.cpp +++ b/stepmania/src/smpackage/onvertThemeDlg.cpp @@ -62,7 +62,7 @@ BOOL ConvertThemeDlg::OnInitDialog() CStringArray asThemes; GetDirListing( "Themes\\*.*", asThemes, true, false ); - for( int i=0; ifirst; + const IniFile::key &Key = it->second; + for( IniFile::key::const_iterator val = Key.begin(); val != Key.end(); ++val ) { - CString sName, sValue; - Key.GetNextAssoc( pos, sName, sValue ); + CString sName = val->first, sValue = val->second; mapBaseClassPlusNameToValue[sKey+"-"+sName] = sValue; } } CMapStringToString mapThemeClassPlusNameToValue; - for( i=0; ifirst; + const IniFile::key &Key = it->second; + for( IniFile::key::const_iterator val = Key.begin(); val != Key.end(); ++val ) { - CString sName, sValue; - Key.GetNextAssoc( pos, sName, sValue ); + CString sName = val->first, sValue = val->second; mapThemeClassPlusNameToValue[sKey+"-"+sName] = sValue; } } @@ -476,12 +471,12 @@ void ConvertThemeDlg::OnButtonAnalyzeMetrics() { bFoundMatch = true; if( sThemeValue == sBaseValue ) - asRedundant.Add( sThemeKey ); + asRedundant.push_back( sThemeKey ); break; // skip to next file in asThemeFilePaths } } if( !bFoundMatch ) - asWarning.Add( sThemeKey ); + asWarning.push_back( sThemeKey ); } SortCStringArray( asRedundant ); @@ -493,13 +488,13 @@ void ConvertThemeDlg::OnButtonAnalyzeMetrics() fprintf( fp, "The following metrics are REDUNDANT.\n" " (These metrics are identical to the metrics in the base theme.\n" " They are unnecessary and should be deleted.)\n" ); - for( i=0; i