set default install dir to whatever install dir was used last

prune old non-present installations by checking each for a Programs directory
This commit is contained in:
Chris Danford
2005-10-17 08:15:52 +00:00
parent 944b1dd231
commit c2bc8c3b61
3 changed files with 24 additions and 0 deletions
@@ -259,6 +259,14 @@ void CSMPackageInstallDlg::OnOK()
CString sInstallDir;
m_comboDir.GetWindowText( sInstallDir );
int iSelectedInstallDirIndex = m_comboDir.GetCurSel();
if( iSelectedInstallDirIndex == -1 )
{
MessageBox( "No Installations", "Error", MB_OK|MB_ICONEXCLAMATION );
return;
}
SetDefaultInstallDir( iSelectedInstallDirIndex );
// Show comment (if any)
CString sComment = m_zip.GetGlobalComment();
+15
View File
@@ -42,6 +42,10 @@ void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut )
if( sPath == "" ) // read failed
continue; // skip
CString sProgramDir = sPath+"\\Program";
if( !DoesFileExist(sProgramDir) )
continue; // skip
asInstallDirsOut.push_back( sPath );
}
@@ -70,6 +74,17 @@ void AddStepManiaInstallDir( CString sNewInstallDir )
WriteStepManiaInstallDirs( asInstallDirs );
}
void SetDefaultInstallDir( int iInstallDirIndex )
{
// move the specified index to the top of the list
CStringArray asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs );
ASSERT( iInstallDirIndex > 0 && iInstallDirIndex < asInstallDirs.size() );
CString sDefaultInstallDir = asInstallDirs[iInstallDirIndex];
asInstallDirs.erase( asInstallDirs.begin()+iInstallDirIndex );
asInstallDirs.insert( asInstallDirs.begin(), sDefaultInstallDir );
WriteStepManiaInstallDirs( asInstallDirs );
}
bool GetPref( CString name, bool &val )
{
+1
View File
@@ -6,6 +6,7 @@
void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite );
void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut );
void AddStepManiaInstallDir( CString sNewInstallDir );
void SetDefaultInstallDir( int iInstallDirIndex );
bool GetPref( CString name, bool &val );
bool SetPref( CString name, bool val );