Added support for multiple installation dirs to smpackage.

This commit is contained in:
Chris Danford
2003-02-11 09:20:58 +00:00
parent a7d1e33b31
commit 7c027cfcf6
11 changed files with 1276 additions and 24 deletions
@@ -0,0 +1,129 @@
// EditInsallations.cpp : implementation file
//
#include "stdafx.h"
#include "smpackage.h"
#include "EditInsallations.h"
#include "smpackageUtil.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// EditInsallations dialog
EditInsallations::EditInsallations(CWnd* pParent /*=NULL*/)
: CDialog(EditInsallations::IDD, pParent)
{
//{{AFX_DATA_INIT(EditInsallations)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void EditInsallations::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(EditInsallations)
DDX_Control(pDX, IDC_LIST, m_list);
DDX_Control(pDX, IDC_EDIT, m_edit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(EditInsallations, CDialog)
//{{AFX_MSG_MAP(EditInsallations)
ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove)
ON_BN_CLICKED(IDC_BUTTON_MAKE_DEFAULT, OnButtonMakeDefault)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// EditInsallations message handlers
BOOL EditInsallations::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CStringArray asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs );
for( int i=0; i<asInstallDirs.GetSize(); i++ )
m_list.AddString( asInstallDirs[i] );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void EditInsallations::OnButtonRemove()
{
// TODO: Add your control notification handler code here
if( m_list.GetCount() == 1 )
{
AfxMessageBox( "You cannot remove the list item in the list." );
return;
}
if( m_list.GetCurSel() == LB_ERR )
{
AfxMessageBox( "You must select an item from the list first." );
return;
}
m_list.DeleteString( m_list.GetCurSel() );
}
void EditInsallations::OnButtonMakeDefault()
{
// TODO: Add your control notification handler code here
if( m_list.GetCurSel() == LB_ERR )
{
AfxMessageBox( "You must select an item from the list first." );
return;
}
CString sText;
m_list.GetText( m_list.GetCurSel(), sText );
m_list.DeleteString( m_list.GetCurSel() );
m_list.InsertString( 0, sText );
}
void EditInsallations::OnButtonAdd()
{
// TODO: Add your control notification handler code here
CString sText;
m_edit.GetWindowText( sText );
if( sText == "" )
{
AfxMessageBox( "You must type a SM or DWI program directory before clicking add." );
return;
}
m_list.AddString( sText );
}
void EditInsallations::OnOK()
{
// TODO: Add extra validation here
m_asReturnedInstallDirs.RemoveAll();
for( int i=0; i<m_list.GetCount(); i++ )
{
CString sDir;
m_list.GetText( i, sDir );
m_asReturnedInstallDirs.Add( sDir );
}
CDialog::OnOK();
}
@@ -0,0 +1,53 @@
#if !defined(AFX_EDITINSALLATIONS_H__CD328CB4_8E35_4B12_BCD1_ADF5CE7EABC7__INCLUDED_)
#define AFX_EDITINSALLATIONS_H__CD328CB4_8E35_4B12_BCD1_ADF5CE7EABC7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// EditInsallations.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// EditInsallations dialog
class EditInsallations : public CDialog
{
// Construction
public:
EditInsallations(CWnd* pParent = NULL); // standard constructor
CStringArray m_asReturnedInstallDirs;
// Dialog Data
//{{AFX_DATA(EditInsallations)
enum { IDD = IDD_EDIT_INSTALLATIONS };
CListBox m_list;
CEdit m_edit;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(EditInsallations)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(EditInsallations)
virtual BOOL OnInitDialog();
afx_msg void OnButtonRemove();
afx_msg void OnButtonMakeDefault();
afx_msg void OnButtonAdd();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_EDITINSALLATIONS_H__CD328CB4_8E35_4B12_BCD1_ADF5CE7EABC7__INCLUDED_)
+798
View File
@@ -0,0 +1,798 @@
#include "stdafx.h"
#include <winreg.h>
#include "Registry.h"
#define CLASS_NAME_LENGTH 255
/* IMPORTANT NOTES ABOUT CREGISTRY:
CRegistry never keeps a key open past the end of a function call.
This is incase the application crashes before the next call to close
the registry
INCLUDE FILES
"winreg.h" and "afxdisp.h" must be included in "stdafx.h"
KEY NAMES:
Key names must not begin with a \ and only absolute strings are accepted
*/
CRegistry::CRegistry()
{
m_hRootKey = HKEY_CURRENT_USER;
m_bLazyWrite = TRUE;
m_nLastError = ERROR_SUCCESS;
}
CRegistry::~CRegistry()
{
ClearKey();
}
BOOL CRegistry::ClearKey()
{
/* Call CloseKey to write the current key to the registry and close the
key. An application should not keep keys open any longer than necessary.
Calling CloseKey when there is no current key has no effect.*/
m_strCurrentPath.Empty();
m_hRootKey = HKEY_CURRENT_USER;
m_bLazyWrite = TRUE;
return TRUE;
}
BOOL CRegistry::SetRootKey(HKEY hRootKey)
{
// sets the root key
// make sure to set it to a valid key
if (hRootKey != HKEY_CLASSES_ROOT &&
hRootKey != HKEY_CURRENT_USER &&
hRootKey != HKEY_LOCAL_MACHINE &&
hRootKey != HKEY_USERS) return FALSE;
m_hRootKey = hRootKey;
return TRUE;
}
BOOL CRegistry::CreateKey(CString strKey)
{
/* Use CreateKey to add a new key to the registry.
Key is the name of the key to create. Key must be
an absolute name. An absolute key
begins with a backslash (\) and is a subkey of
the root key. */
ASSERT(strKey[0] != '\\');
HKEY hKey;
DWORD dwDisposition = 0;
if (::RegCreateKeyEx(m_hRootKey, LPCTSTR(strKey), 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,
&dwDisposition) != ERROR_SUCCESS) return FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
m_strCurrentPath = strKey;
return TRUE;
}
BOOL CRegistry::DeleteKey(CString strKey)
{
/* Call DeleteKey to remove a specified key and its associated data,
if any, from the registry. Returns FALSE is there are subkeys
Subkeys must be explicitly deleted by separate calls to DeleteKey.
DeleteKey returns True if key deletion is successful. On error,
DeleteKey returns False. */
// need to open the key first with RegOpenKeyEx
// ASSERT(FALSE); // not yet implemented
// ASSERT(strKey[0] != '\\');
if (!KeyExists(strKey)) return TRUE;
if (::RegDeleteKey(m_hRootKey, strKey) != ERROR_SUCCESS) return FALSE;
return TRUE;
}
BOOL CRegistry::DeleteValue(CString strName)
{
/* Call DeleteValue to remove a specific data value
associated with the current key. Name is string
containing the name of the value to delete. Keys can contain
multiple data values, and every value associated with a key
has a unique name. */
ASSERT(m_strCurrentPath.GetLength() > 0);
HKEY hKey;
LONG lResult;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_SET_VALUE, &hKey) != ERROR_SUCCESS) return FALSE;
lResult = ::RegDeleteValue(hKey, LPCTSTR(strName));
::RegCloseKey(hKey);
if (lResult == ERROR_SUCCESS) return TRUE;
return FALSE;
}
int CRegistry::GetDataSize(CString strValueName)
{
/* Call GetDataSize to determine the size, in bytes, of
a data value associated with the current key. ValueName
is a string containing the name of the data value to query.
On success, GetDataSize returns the size of the data value.
On failure, GetDataSize returns -1. */
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
LONG lResult;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) return -1;
DWORD dwSize = 1;
lResult = ::RegQueryValueEx(hKey, LPCTSTR(strValueName),
NULL, NULL, NULL, &dwSize);
::RegCloseKey(hKey);
if (lResult != ERROR_SUCCESS) return -1;
return (int)dwSize;
}
DWORD CRegistry::GetDataType(CString strValueName)
{
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
m_nLastError = ::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_QUERY_VALUE, &hKey);
if (m_nLastError != ERROR_SUCCESS) return 0;
DWORD dwType = 1;
m_nLastError = ::RegQueryValueEx(hKey, LPCTSTR(strValueName),
NULL, &dwType, NULL, NULL);
::RegCloseKey(hKey);
if (m_nLastError == ERROR_SUCCESS) return dwType;
return 0;
}
int CRegistry::GetSubKeyCount()
{
/* Call this function to determine the number of subkeys.
the function returns -1 on error */
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) return -1;
LONG lResult;
DWORD dwSubKeyCount, dwValueCount, dwClassNameLength,
dwMaxSubKeyName, dwMaxValueName, dwMaxValueLength;
FILETIME ftLastWritten;
_TCHAR szClassBuffer[CLASS_NAME_LENGTH];
dwClassNameLength = CLASS_NAME_LENGTH;
lResult = ::RegQueryInfoKey(hKey, szClassBuffer, &dwClassNameLength,
NULL, &dwSubKeyCount, &dwMaxSubKeyName, NULL, &dwValueCount,
&dwMaxValueName, &dwMaxValueLength, NULL, &ftLastWritten);
::RegCloseKey(hKey);
if (lResult != ERROR_SUCCESS) return -1;
return (int)dwSubKeyCount;
}
int CRegistry::GetValueCount()
{
/* Call this function to determine the number of subkeys.
the function returns -1 on error */
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) return -1;
LONG lResult;
DWORD dwSubKeyCount, dwValueCount, dwClassNameLength,
dwMaxSubKeyName, dwMaxValueName, dwMaxValueLength;
FILETIME ftLastWritten;
_TCHAR szClassBuffer[CLASS_NAME_LENGTH];
dwClassNameLength = CLASS_NAME_LENGTH;
lResult = ::RegQueryInfoKey(hKey, szClassBuffer, &dwClassNameLength,
NULL, &dwSubKeyCount, &dwMaxSubKeyName, NULL, &dwValueCount,
&dwMaxValueName, &dwMaxValueLength, NULL, &ftLastWritten);
::RegCloseKey(hKey);
if (lResult != ERROR_SUCCESS) return -1;
return (int)dwValueCount;
}
BOOL CRegistry::KeyExists(CString strKey, HKEY hRootKey)
{
/* Call KeyExists to determine if a key of a specified name exists.
Key is the name of the key for which to search. */
ASSERT(strKey[0] != '\\');
HKEY hKey;
if (hRootKey == NULL) hRootKey = m_hRootKey;
LONG lResult = ::RegOpenKeyEx(hRootKey, LPCTSTR(strKey), 0,
KEY_ALL_ACCESS, &hKey);
::RegCloseKey(hKey);
if (lResult == ERROR_SUCCESS) return TRUE;
return FALSE;
}
BOOL CRegistry::SetKey(CString strKey, BOOL bCanCreate)
{
/* Call SetKey to make a specified key the current key. Key is the
name of the key to open. If Key is null, the CurrentKey property
is set to the key specified by the RootKey property.
CanCreate specifies whether to create the specified key if it does
not exist. If CanCreate is True, the key is created if necessary.
Key is opened or created with the security access value KEY_ALL_ACCESS.
OpenKey only creates non-volatile keys, A non-volatile key is stored in
the registry and is preserved when the system is restarted.
OpenKey returns True if the key is successfully opened or created */
ASSERT(strKey[0] != '\\');
HKEY hKey;
// close the current key if it is open
if (strKey.GetLength() == 0)
{
m_strCurrentPath.Empty();
return TRUE;
}
DWORD dwDisposition;
if (bCanCreate) // open the key with RegCreateKeyEx
{
if (::RegCreateKeyEx(m_hRootKey, LPCTSTR(strKey), 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,
&dwDisposition) != ERROR_SUCCESS) return FALSE;
m_strCurrentPath = strKey;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return TRUE;
}
// otherwise, open the key without creating
// open key requires no initial slash
m_nLastError = ::RegOpenKeyEx(m_hRootKey, LPCTSTR(strKey), 0,
KEY_ALL_ACCESS, &hKey);
if (m_nLastError != ERROR_SUCCESS) return FALSE;
m_strCurrentPath = strKey;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return TRUE;
}
BOOL CRegistry::ValueExists(CString strName)
{
/* Call ValueExists to determine if a particular key exists in
the registry. Calling Value Exists is especially useful before
calling other TRegistry methods that operate only on existing keys.
Name is the name of the data value for which to check.
ValueExists returns True if a match if found, False otherwise. */
HKEY hKey;
LONG lResult;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) return FALSE;
lResult = ::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
NULL, NULL, NULL);
::RegCloseKey(hKey);
if (lResult == ERROR_SUCCESS) return TRUE;
return FALSE;
}
void CRegistry::RenameValue(CString strOldName, CString strNewName)
{
/* Call RenameValue to change the name of a data value associated
with the current key. OldName is a string containing the current
name of the data value. NewName is a string containing the replacement
name for the data value.
If OldName is the name of an existing data value for the current key,
and NewName is not the name of an existing data value for the current
key, RenameValue changes the data value name as specified. Otherwise
the current name remains unchanged.
*/
ASSERT(FALSE); // functionality not yet implemented
}
COleDateTime CRegistry::ReadDateTime(CString strName, COleDateTime dtDefault)
{
/* Call ReadDate to read a date value from a specified data value
associated with the current key. Name is the name of the data value to read.
If successful, ReadDate returns a Delphi TDateTime value. The integral part
of a TDateTime value is the number of days that have passed since 12/30/1899.
The fractional part of a TDateTime value is the time of day.
On error, an exception is raised, and the value returned by this function
should be discarded. */
DWORD dwType = REG_BINARY;
COleDateTime dt;
DWORD dwSize = sizeof(dt);
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return dtDefault;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)&dt, &dwSize) != ERROR_SUCCESS) dt = dtDefault;
::RegCloseKey(hKey);
return dt;
}
double CRegistry::ReadFloat(CString strName, double fDefault)
{
/* Call ReadFloat to read a float value from a specified
data value associated with the current key. Name is the name
of the data value to read.
If successful, ReadFloat returns a double value.
On error, an exception is raised, and the value returned by
this function should be discarded. */
DWORD dwType = REG_BINARY;
double d;
DWORD dwSize = sizeof(d);
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return fDefault;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)&d, &dwSize) != ERROR_SUCCESS) d = fDefault;
::RegCloseKey(hKey);
return d;
}
CString CRegistry::ReadString(CString strName, CString strDefault)
{
DWORD dwType = REG_SZ;
DWORD dwSize = 255;
BOOL bSuccess = TRUE;
_TCHAR sz[255];
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
// make sure it is the proper type
dwType = GetDataType(strName);
if (dwType != REG_SZ && dwType != REG_EXPAND_SZ)
{
return strDefault;
}
m_nLastError = ::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey);
if (m_nLastError != ERROR_SUCCESS) return strDefault;
m_nLastError = ::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)sz, &dwSize);
if (m_nLastError != ERROR_SUCCESS) bSuccess = FALSE;
::RegCloseKey(hKey);
if (!bSuccess) return strDefault;
return CString((LPCTSTR)sz);
}
DWORD CRegistry::ReadDword(CString strName, DWORD dwDefault)
{
DWORD dwType = REG_DWORD;
DWORD dw;
DWORD dwSize = sizeof(dw);
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return dwDefault;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)&dw, &dwSize) != ERROR_SUCCESS) dw = dwDefault;
::RegCloseKey(hKey);
return dw;
}
int CRegistry::ReadInt(CString strName, int nDefault)
{
DWORD dwType = REG_BINARY;
int n;
DWORD dwSize = sizeof(n);
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return nDefault;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)&n, &dwSize) != ERROR_SUCCESS) n = nDefault;
::RegCloseKey(hKey);
return n;
}
BOOL CRegistry::ReadBool(CString strName, BOOL bDefault)
{
DWORD dwType = REG_BINARY;
BOOL b;
DWORD dwSize = sizeof(b);
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return bDefault;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)&b, &dwSize) != ERROR_SUCCESS) b = bDefault;
::RegCloseKey(hKey);
return b;
}
COLORREF CRegistry::ReadColor(CString strName, COLORREF rgbDefault)
{
DWORD dwType = REG_BINARY;
COLORREF rgb;
DWORD dwSize = sizeof(rgb);
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return rgbDefault;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)&rgb, &dwSize) != ERROR_SUCCESS) rgb = rgbDefault;
::RegCloseKey(hKey);
return rgb;
}
BOOL CRegistry::ReadFont(CString strName, CFont* pFont)
{
DWORD dwType = REG_BINARY;
DWORD dwSize = sizeof(LOGFONT);
BOOL bSuccess = TRUE;
HKEY hKey;
LOGFONT lf;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)&lf, &dwSize) != ERROR_SUCCESS) bSuccess = FALSE;
::RegCloseKey(hKey);
if (bSuccess)
{
pFont->Detach();
pFont->CreateFontIndirect(&lf);
}
return bSuccess;
}
BOOL CRegistry::ReadPoint(CString strName, CPoint* pPoint)
{
DWORD dwType = REG_BINARY;
DWORD dwSize = sizeof(CPoint);
BOOL bSuccess = TRUE;
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)pPoint, &dwSize) != ERROR_SUCCESS) bSuccess = FALSE;
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::ReadSize(CString strName, CSize* pSize)
{
DWORD dwType = REG_BINARY;
DWORD dwSize = sizeof(CSize);
BOOL bSuccess = TRUE;
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)pSize, &dwSize) != ERROR_SUCCESS) bSuccess = FALSE;
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::ReadRect(CString strName, CRect* pRect)
{
DWORD dwType = REG_BINARY;
DWORD dwSize = sizeof(CRect);
BOOL bSuccess = TRUE;
HKEY hKey;
ASSERT(m_strCurrentPath.GetLength() > 0);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
&dwType, (LPBYTE)pRect, &dwSize) != ERROR_SUCCESS) bSuccess = FALSE;
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteBool(CString strName, BOOL bValue)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)&bValue, sizeof(bValue))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteDateTime(CString strName, COleDateTime dtValue)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)&dtValue, sizeof(dtValue))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteString(CString strName, CString strValue)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
_TCHAR sz[255];
if (strValue.GetLength() > 254) return FALSE;
#ifdef _UNICODE
wstrcpy(sz, LPCTSTR(strValue));
#else
strcpy(sz, LPCTSTR(strValue));
#endif
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
#ifdef _UNICODE
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_SZ, (LPBYTE)sz, wstrlen(sz) + 1)
!= ERROR_SUCCESS) bSuccess = FALSE;
#else
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_SZ, (LPBYTE)sz, strlen(sz) + 1)
!= ERROR_SUCCESS) bSuccess = FALSE;
#endif
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteFloat(CString strName, double fValue)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)&fValue, sizeof(fValue))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteInt(CString strName, int nValue)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)&nValue, sizeof(nValue))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteDword(CString strName, DWORD dwValue)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)&dwValue, sizeof(dwValue))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteColor(CString strName, COLORREF rgbValue)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)&rgbValue, sizeof(rgbValue))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteFont(CString strName, CFont* pFont)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
LOGFONT lf;
pFont->GetLogFont(&lf);
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)&lf, sizeof(lf))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WritePoint(CString strName, CPoint* pPoint)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)pPoint, sizeof(CPoint))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteSize(CString strName, CSize* pSize)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)pSize, sizeof(CSize))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
BOOL CRegistry::WriteRect(CString strName, CRect* pRect)
{
ASSERT(m_strCurrentPath.GetLength() > 0);
BOOL bSuccess = TRUE;
HKEY hKey;
if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
KEY_WRITE, &hKey) != ERROR_SUCCESS) return FALSE;
if (::RegSetValueEx(hKey, LPCTSTR(strName), 0,
REG_BINARY, (LPBYTE)pRect, sizeof(CRect))
!= ERROR_SUCCESS) bSuccess = FALSE;
if (!m_bLazyWrite) ::RegFlushKey(hKey);
::RegCloseKey(hKey);
return bSuccess;
}
+74
View File
@@ -0,0 +1,74 @@
#ifndef __REGISTRY_H__
#define __REGISTRY_H__
class CRegistry
{
public:
CRegistry();
~CRegistry();
int m_nLastError;
// CRegistry properties
protected:
HKEY m_hRootKey;
BOOL m_bLazyWrite;
CString m_strCurrentPath;
public:
inline BOOL PathIsValid() {
return (m_strCurrentPath.GetLength() > 0); }
inline CString GetCurrentPath() {
return m_strCurrentPath; }
inline HKEY GetRootKey() {
return m_hRootKey; }
//CRegistry methods
public:
BOOL ClearKey();
BOOL SetRootKey(HKEY hRootKey);
BOOL CreateKey(CString strKey);
BOOL DeleteKey(CString strKey);
BOOL DeleteValue(CString strName);
int GetDataSize(CString strValueName);
DWORD GetDataType(CString strValueName);
int GetSubKeyCount();
int GetValueCount();
BOOL KeyExists(CString strKey, HKEY hRootKey = NULL);
BOOL SetKey(CString strKey, BOOL bCanCreate);
BOOL ValueExists(CString strName);
void RenameValue(CString strOldName, CString strNewName);
// data reading functions
COleDateTime ReadDateTime(CString strName, COleDateTime dtDefault);
double ReadFloat(CString strName, double fDefault);
CString ReadString(CString strName, CString strDefault);
int ReadInt(CString strName, int nDefault);
BOOL ReadBool(CString strName, BOOL bDefault);
COLORREF ReadColor(CString strName, COLORREF rgbDefault);
BOOL ReadFont(CString strName, CFont* pFont);
BOOL ReadPoint(CString strName, CPoint* pPoint);
BOOL ReadSize(CString strName, CSize* pSize);
BOOL ReadRect(CString strName, CRect* pRect);
DWORD ReadDword(CString strName, DWORD dwDefault);
// data writing functions
BOOL WriteBool(CString strName, BOOL bValue);
BOOL WriteDateTime(CString strName, COleDateTime dtValue);
BOOL WriteString(CString strName, CString strValue);
BOOL WriteFloat(CString strName, double fValue);
BOOL WriteInt(CString strName, int nValue);
BOOL WriteColor(CString strName, COLORREF rgbValue);
BOOL WriteFont(CString strName, CFont* pFont);
BOOL WritePoint(CString strName, CPoint* pPoint);
BOOL WriteSize(CString strName, CSize* pSize);
BOOL WriteRect(CString strName, CRect* pRect);
BOOL WriteDword(CString strName, DWORD dwValue);
};// end of CRegistry class definition
#endif
+51 -13
View File
@@ -5,6 +5,8 @@
#include "smpackage.h"
#include "SMPackageInstallDlg.h"
#include "RageUtil.h"
#include "smpackageUtil.h"
#include "EditInsallations.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -33,7 +35,8 @@ void CSMPackageInstallDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSMPackageInstallDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX, IDC_BUTTON_EDIT, m_buttonEdit);
DDX_Control(pDX, IDC_COMBO_DIR, m_comboDir);
//}}AFX_DATA_MAP
}
@@ -41,9 +44,11 @@ void CSMPackageInstallDlg::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(CSMPackageInstallDlg, CDialog)
//{{AFX_MSG_MAP(CSMPackageInstallDlg)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSMPackageInstallDlg message handlers
@@ -58,6 +63,7 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
// TODO: Add extra initialization here
int i;
//
// Set the text of the first Edit box
@@ -89,7 +95,7 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
exit( 1 );
}
for( int i=0; i<m_zip.GetCount(); i++ )
for( i=0; i<m_zip.GetCount(); i++ )
{
CZipFileHeader fh;
m_zip.GetFileInfo(fh, (WORD)i);
@@ -106,20 +112,21 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
//
// Set the text of the third Edit box
//
TCHAR szCurrentDirectory[MAX_PATH];
GetCurrentDirectory( MAX_PATH, szCurrentDirectory );
CString sMessage3 = ssprintf(
"The package will be installed in the Stepmania program folder:\r\n"
"\r\n"
"\t%s",
szCurrentDirectory
);
CString sMessage3 = "The package will be installed in the following Stepmania program folder:\r\n";
// Set the message
CEdit* pEdit3 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE3);
pEdit3->SetWindowText( sMessage3 );
TCHAR szCurrentDirectory[MAX_PATH];
GetCurrentDirectory( MAX_PATH, szCurrentDirectory );
AddStepManiaInstallDir( szCurrentDirectory );
RefreshInstallationList();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
@@ -160,9 +167,12 @@ void CSMPackageInstallDlg::OnOK()
{
// TODO: Add extra validation here
TCHAR szCurrentDirectory[MAX_PATH];
GetCurrentDirectory( MAX_PATH, szCurrentDirectory );
m_comboDir.EnableWindow( FALSE );
m_buttonEdit.EnableWindow( FALSE );
CString sInstallDir;
m_comboDir.GetWindowText( sInstallDir );
// Unzip the SMzip package into the Stepmania installation folder
for( int i=0; i<m_zip.GetCount(); i++ )
{
@@ -180,7 +190,7 @@ void CSMPackageInstallDlg::OnOK()
// Extract the files
try
{
m_zip.ExtractFile( (WORD)i, szCurrentDirectory, true ); // extract file to current directory
m_zip.ExtractFile( (WORD)i, sInstallDir, true ); // extract file to current directory
}
catch (CException* e)
{
@@ -195,3 +205,31 @@ void CSMPackageInstallDlg::OnOK()
// close the dialog
CDialog::OnOK();
}
void CSMPackageInstallDlg::OnButtonEdit()
{
// TODO: Add your control notification handler code here
EditInsallations dlg;
int nResponse = dlg.DoModal();
if( nResponse == IDOK )
{
WriteStepManiaInstallDirs( dlg.m_asReturnedInstallDirs );
RefreshInstallationList();
}
}
void CSMPackageInstallDlg::RefreshInstallationList()
{
m_comboDir.ResetContent();
CStringArray asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs );
for( int i=0; i<asInstallDirs.GetSize(); i++ )
{
m_comboDir.AddString( asInstallDirs[i] );
}
m_comboDir.SetCurSel( 0 ); // guaranteed to be at least one item
}
@@ -22,7 +22,8 @@ public:
// Dialog Data
//{{AFX_DATA(CSMPackageInstallDlg)
enum { IDD = IDD_INSTALL };
// NOTE: the ClassWizard will add data members here
CButton m_buttonEdit;
CComboBox m_comboDir;
//}}AFX_DATA
@@ -35,6 +36,8 @@ public:
// Implementation
protected:
void RefreshInstallationList();
HICON m_hIcon;
CString m_sPackagePath;
CZipArchive m_zip;
@@ -44,6 +47,7 @@ protected:
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnPaint();
afx_msg void OnButtonEdit();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
+8 -2
View File
@@ -10,6 +10,7 @@
#define INSTALL 133
#define MANAGE 135
#define IDD_DIALOG_NAME 137
#define IDD_EDIT_INSTALLATIONS 138
#define IDC_LIST_SONGS 1000
#define IDC_LIST 1000
#define IDC_BUTTON_PLAY 1001
@@ -22,14 +23,19 @@
#define IDC_EDIT_MESSAGE2 1007
#define IDC_TREE 1011
#define IDC_EDIT 1012
#define IDC_COMBO_DIR 1013
#define IDC_BUTTON_EDIT 1014
#define IDC_BUTTON_ADD 1018
#define IDC_BUTTON_REMOVE 1019
#define IDC_BUTTON_MAKE_DEFAULT 1020
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 138
#define _APS_NEXT_RESOURCE_VALUE 139
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1013
#define _APS_NEXT_CONTROL_VALUE 1022
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
+35 -7
View File
@@ -2,23 +2,25 @@
[General Info]
Version=1
LastClass=EnterName
LastClass=EditInsallations
LastTemplate=CDialog
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "smpackage.h"
ClassCount=5
ClassCount=6
Class1=CSmpackageApp
Class2=CSmpackageDlg
ResourceCount=4
ResourceCount=5
Resource1=IDR_MAINFRAME
Resource2=IDD_INSTALL
Resource2=IDD_DIALOG_NAME
Class3=CSMPackageInstallDlg
Class4=CSmpackageExportDlg
Resource3=IDD_EXPORTER
Class5=EnterName
Resource4=IDD_DIALOG_NAME
Resource4=IDD_INSTALL
Class6=EditInsallations
Resource5=IDD_EDIT_INSTALLATIONS
[CLS:CSmpackageApp]
Type=0
@@ -43,7 +45,7 @@ VirtualFilter=dWC
[DLG:IDD_INSTALL]
Type=1
Class=CSMPackageInstallDlg
ControlCount=7
ControlCount=9
Control1=IDC_EDIT_MESSAGE1,edit,1342179460
Control2=IDOK,button,1342242817
Control3=IDCANCEL,button,1342242816
@@ -51,6 +53,8 @@ Control4=IDC_BUTTON_BACK,button,1476460544
Control5=IDC_STATIC,static,1342177294
Control6=IDC_EDIT_MESSAGE3,edit,1342179460
Control7=IDC_EDIT_MESSAGE2,edit,1352665220
Control8=IDC_COMBO_DIR,combobox,1344339971
Control9=IDC_BUTTON_EDIT,button,1342242816
[CLS:CSMPackageInstallDlg]
Type=0
@@ -58,7 +62,7 @@ HeaderFile=SMPackageInstallDlg.h
ImplementationFile=SMPackageInstallDlg.cpp
BaseClass=CDialog
Filter=D
LastObject=CSMPackageInstallDlg
LastObject=IDC_COMBO_DIR
VirtualFilter=dWC
[DLG:IDD_EXPORTER]
@@ -100,3 +104,27 @@ Filter=D
VirtualFilter=dWC
LastObject=IDC_EDIT
[DLG:IDD_EDIT_INSTALLATIONS]
Type=1
Class=EditInsallations
ControlCount=10
Control1=IDOK,button,1342242817
Control2=IDCANCEL,button,1342242816
Control3=IDC_LIST,listbox,1352728833
Control4=IDC_EDIT,edit,1350631552
Control5=IDC_BUTTON_ADD,button,1342242816
Control6=IDC_BUTTON_REMOVE,button,1342242816
Control7=IDC_BUTTON_MAKE_DEFAULT,button,1342242816
Control8=IDC_STATIC,button,1342177287
Control9=IDC_STATIC,button,1342177287
Control10=IDC_STATIC,static,1342308352
[CLS:EditInsallations]
Type=0
HeaderFile=EditInsallations.h
ImplementationFile=EditInsallations.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=EditInsallations
+20
View File
@@ -88,6 +88,14 @@ LINK32=link.exe
# Name "smpackage - Win32 Debug"
# Begin Source File
SOURCE=.\EditInsallations.cpp
# End Source File
# Begin Source File
SOURCE=.\EditInsallations.h
# End Source File
# Begin Source File
SOURCE=.\EnterName.cpp
# End Source File
# Begin Source File
@@ -116,6 +124,14 @@ SOURCE=.\ReadMe.txt
# End Source File
# Begin Source File
SOURCE=.\Registry.cpp
# End Source File
# Begin Source File
SOURCE=.\Registry.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
@@ -160,6 +176,10 @@ SOURCE=.\SMPackageInstallDlg.h
# End Source File
# Begin Source File
SOURCE=.\smpackageUtil.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
+32 -1
View File
@@ -85,12 +85,15 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,275,215,50,15
PUSHBUTTON "< Back",IDC_BUTTON_BACK,145,215,55,15,WS_DISABLED
CONTROL 133,IDC_STATIC,"Static",SS_BITMAP,0,0,258,37
EDITTEXT IDC_EDIT_MESSAGE3,5,180,320,30,ES_MULTILINE |
EDITTEXT IDC_EDIT_MESSAGE3,5,180,320,13,ES_MULTILINE |
ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT
WS_TABSTOP
EDITTEXT IDC_EDIT_MESSAGE2,5,90,320,87,ES_MULTILINE |
ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT
WS_TABSTOP
COMBOBOX IDC_COMBO_DIR,22,195,204,105,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Edit Installations",IDC_BUTTON_EDIT,233,194,59,14
END
IDD_EXPORTER DIALOGEX 0, 0, 332, 234
@@ -125,6 +128,26 @@ BEGIN
18,38,179,12
END
IDD_EDIT_INSTALLATIONS DIALOG DISCARDABLE 0, 0, 233, 220
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Edit Installations"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,117,198,50,14
PUSHBUTTON "Cancel",IDCANCEL,175,198,50,14
LISTBOX IDC_LIST,17,21,136,89,LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_TABSTOP
EDITTEXT IDC_EDIT,19,168,136,13,ES_AUTOHSCROLL
PUSHBUTTON "Add",IDC_BUTTON_ADD,165,168,50,14
PUSHBUTTON "Remove",IDC_BUTTON_REMOVE,164,42,50,15
PUSHBUTTON "Make Default",IDC_BUTTON_MAKE_DEFAULT,164,72,50,15
GROUPBOX "Add New Installation",IDC_STATIC,7,130,218,59
GROUPBOX "Current Installations (the top installation is the default)",
IDC_STATIC,7,7,218,114
LTEXT "Enter the complete path to a StepMania or DWI installation\r\ne.g. ""C:\\Program Files\\StepMania""",
IDC_STATIC,18,144,196,17
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
@@ -200,6 +223,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 51
END
IDD_EDIT_INSTALLATIONS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 225
TOPMARGIN, 7
BOTTOMMARGIN, 212
END
END
#endif // APSTUDIO_INVOKED
+71
View File
@@ -0,0 +1,71 @@
#include "Registry.h"
#include "RageUtil.h"
inline void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite )
{
CRegistry Reg;
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage", TRUE); // create if not already present
int i;
for( i=0; i<100; i++ )
{
CString sName = ssprintf("%d",i);
Reg.DeleteKey( 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", 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] == sNewInstallDir )
{
bAlreadyInList = true;
break;
}
}
if( !bAlreadyInList )
asInstallDirs.Add( sNewInstallDir );
WriteStepManiaInstallDirs( asInstallDirs );
}