2003-02-11 09:20:58 +00:00
|
|
|
|
|
|
|
|
#include "Registry.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite )
|
|
|
|
|
{
|
|
|
|
|
CRegistry Reg;
|
|
|
|
|
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
|
2003-02-12 18:03:59 +00:00
|
|
|
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
|
2003-02-11 09:20:58 +00:00
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for( i=0; i<100; i++ )
|
|
|
|
|
{
|
|
|
|
|
CString sName = ssprintf("%d",i);
|
2003-02-11 20:42:42 +00:00
|
|
|
// Reg.DeleteKey( sName ); // delete key is broken in this library, so just write over it with ""
|
|
|
|
|
Reg.WriteString( sName, "" );
|
2003-02-11 09:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( i=0; i<asInstallDirsToWrite.GetSize(); i++ )
|
|
|
|
|
{
|
|
|
|
|
CString sName = ssprintf("%d",i);
|
|
|
|
|
Reg.WriteString( sName, asInstallDirsToWrite[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut )
|
|
|
|
|
{
|
|
|
|
|
asInstallDirsOut.RemoveAll();
|
|
|
|
|
|
|
|
|
|
CRegistry Reg;
|
|
|
|
|
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
|
2003-02-12 18:03:59 +00:00
|
|
|
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
|
2003-02-11 09:20:58 +00:00
|
|
|
|
|
|
|
|
for( int i=0; i<100; i++ )
|
|
|
|
|
{
|
|
|
|
|
CString sName = ssprintf("%d",i);
|
|
|
|
|
|
|
|
|
|
CString sPath = Reg.ReadString( sName, "" );
|
|
|
|
|
|
|
|
|
|
if( sPath == "" ) // read failed
|
|
|
|
|
continue; // skip
|
|
|
|
|
|
|
|
|
|
asInstallDirsOut.Add( sPath );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// while we're at it, write to clean up stale entries
|
|
|
|
|
WriteStepManiaInstallDirs( asInstallDirsOut );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void AddStepManiaInstallDir( CString sNewInstallDir )
|
|
|
|
|
{
|
|
|
|
|
CStringArray asInstallDirs;
|
|
|
|
|
GetStepManiaInstallDirs( asInstallDirs );
|
|
|
|
|
|
|
|
|
|
bool bAlreadyInList = false;
|
|
|
|
|
for( int i=0; i<asInstallDirs.GetSize(); i++ )
|
|
|
|
|
{
|
2003-02-11 20:42:42 +00:00
|
|
|
if( asInstallDirs[i].CompareNoCase(sNewInstallDir) == 0 )
|
2003-02-11 09:20:58 +00:00
|
|
|
{
|
|
|
|
|
bAlreadyInList = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !bAlreadyInList )
|
|
|
|
|
asInstallDirs.Add( sNewInstallDir );
|
|
|
|
|
|
|
|
|
|
WriteStepManiaInstallDirs( asInstallDirs );
|
|
|
|
|
}
|
2003-02-11 20:42:42 +00:00
|
|
|
|