This commit is contained in:
Glenn Maynard
2003-07-22 02:40:23 +00:00
parent ccba4ffca4
commit d817a6e023
3 changed files with 129 additions and 114 deletions
+73
View File
@@ -0,0 +1,73 @@
#include "stdafx.h"
#include "SMPackageUtil.h"
#include "Registry.h"
void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite )
{
CRegistry Reg;
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
int i;
for( i=0; i<100; i++ )
{
CString sName = ssprintf("%d",i);
// Reg.DeleteKey( sName ); // delete key is broken in this library, so just write over it with ""
Reg.WriteString( sName, "" );
}
for( i=0; i<asInstallDirsToWrite.GetSize(); i++ )
{
CString sName = ssprintf("%d",i);
Reg.WriteString( sName, asInstallDirsToWrite[i] );
}
}
void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut )
{
asInstallDirsOut.RemoveAll();
CRegistry Reg;
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
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 );
}
void AddStepManiaInstallDir( CString sNewInstallDir )
{
CStringArray asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs );
bool bAlreadyInList = false;
for( int i=0; i<asInstallDirs.GetSize(); i++ )
{
if( asInstallDirs[i].CompareNoCase(sNewInstallDir) == 0 )
{
bAlreadyInList = true;
break;
}
}
if( !bAlreadyInList )
asInstallDirs.Add( sNewInstallDir );
WriteStepManiaInstallDirs( asInstallDirs );
}
+50 -45
View File
@@ -1,5 +1,5 @@
# Microsoft Developer Studio Project File - Name="smpackage" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 60000
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
@@ -40,6 +40,7 @@ RSC=rc.exe
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
@@ -52,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 ZipArchive\Release\ZipArchive.lib /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "smpackage - Win32 Debug"
@@ -86,10 +87,9 @@ LINK32=link.exe
# Name "smpackage - Win32 Release"
# Name "smpackage - Win32 Debug"
# Begin Source File
# Begin Group "Source"
SOURCE=.\converttheme.bmp
# End Source File
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\EditInsallations.cpp
@@ -100,10 +100,6 @@ SOURCE=.\EditInsallations.h
# End Source File
# Begin Source File
SOURCE=.\editmetrics.bmp
# End Source File
# Begin Source File
SOURCE=.\EditMetricsDlg.cpp
# End Source File
# Begin Source File
@@ -136,10 +132,6 @@ SOURCE=.\IniFile.h
# End Source File
# Begin Source File
SOURCE=.\install.bmp
# End Source File
# Begin Source File
SOURCE=.\MainMenuDlg.cpp
# End Source File
# Begin Source File
@@ -148,14 +140,6 @@ SOURCE=.\MainMenuDlg.h
# End Source File
# Begin Source File
SOURCE=.\manage.bmp
# End Source File
# Begin Source File
SOURCE=.\menu.bmp
# End Source File
# Begin Source File
SOURCE=.\onvertThemeDlg.cpp
# End Source File
# Begin Source File
@@ -172,10 +156,6 @@ SOURCE=.\RageUtil.h
# End Source File
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# Begin Source File
SOURCE=.\Registry.cpp
# End Source File
# Begin Source File
@@ -204,22 +184,6 @@ SOURCE=.\smpackage.h
# End Source File
# Begin Source File
SOURCE=.\res\smpackage.ico
# End Source File
# Begin Source File
SOURCE=.\smpackage.ICO
# End Source File
# Begin Source File
SOURCE=.\smpackage.rc
# End Source File
# Begin Source File
SOURCE=.\res\smpackage.rc2
# End Source File
# Begin Source File
SOURCE=.\SmpackageExportDlg.cpp
# End Source File
# Begin Source File
@@ -249,15 +213,56 @@ SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\res\StepMania.ICO
# End Source File
# Begin Source File
SOURCE=.\TreeCtrlEx.cpp
# End Source File
# Begin Source File
SOURCE=.\TreeCtrlEx.h
# End Source File
# End Group
# Begin Group "Resources"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\converttheme.bmp
# End Source File
# Begin Source File
SOURCE=.\editmetrics.bmp
# End Source File
# Begin Source File
SOURCE=.\install.bmp
# End Source File
# Begin Source File
SOURCE=.\manage.bmp
# End Source File
# Begin Source File
SOURCE=.\menu.bmp
# End Source File
# Begin Source File
SOURCE=.\res\smpackage.ico
# End Source File
# Begin Source File
SOURCE=.\smpackage.ICO
# End Source File
# Begin Source File
SOURCE=.\smpackage.rc
# End Source File
# Begin Source File
SOURCE=.\res\smpackage.rc2
# End Source File
# Begin Source File
SOURCE=.\res\StepMania.ICO
# End Source File
# End Group
# End Target
# End Project
+6 -69
View File
@@ -1,73 +1,10 @@
#ifndef SMPACKAGE_UTIL_H
#define SMPACKAGE_UTIL_H
#include "Registry.h"
#include "RageUtil.h"
void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite );
void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut );
void AddStepManiaInstallDir( CString sNewInstallDir );
inline void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite )
{
CRegistry Reg;
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
int i;
for( i=0; i<100; i++ )
{
CString sName = ssprintf("%d",i);
// Reg.DeleteKey( sName ); // delete key is broken in this library, so just write over it with ""
Reg.WriteString( sName, "" );
}
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);
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
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++ )
{
if( asInstallDirs[i].CompareNoCase(sNewInstallDir) == 0 )
{
bAlreadyInList = true;
break;
}
}
if( !bAlreadyInList )
asInstallDirs.Add( sNewInstallDir );
WriteStepManiaInstallDirs( asInstallDirs );
}
#endif