eliminate duped code in smpackage

This commit is contained in:
Chris Danford
2005-12-10 08:23:10 +00:00
parent 4aa8779c5d
commit 44afa77096
20 changed files with 310 additions and 425 deletions
+15 -14
View File
@@ -1,11 +1,14 @@
// ChangeGameSettings.cpp : implementation file // ChangeGameSettings.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "ChangeGameSettings.h" #include "ChangeGameSettings.h"
#include "IniFile.h" #include "IniFile.h"
#include "SMPackageUtil.h" #include "SMPackageUtil.h"
#include "SpecialFiles.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@@ -51,10 +54,9 @@ BOOL ChangeGameSettings::OnInitDialog()
// Fill the radio buttons // Fill the radio buttons
// //
IniFile ini; IniFile ini;
ini.SetPath( PREFERENCES_INI ); ini.ReadFile( SpecialFiles::PREFERENCES_INI_PATH );
ini.ReadFile();
CString sValue; RString sValue;
sValue = ""; sValue = "";
@@ -102,35 +104,34 @@ void ChangeGameSettings::OnOK()
{ {
// TODO: Add extra validation here // TODO: Add extra validation here
IniFile ini; IniFile ini;
ini.SetPath( PREFERENCES_INI ); ini.ReadFile( SpecialFiles::PREFERENCES_INI_PATH );
ini.ReadFile();
if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_OPENGL) ) if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_OPENGL) )
ini.SetValue( "Options", "VideoRenderers", "opengl" ); ini.SetValue( "Options", "VideoRenderers", (RString)"opengl" );
else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_DIRECT3D) ) else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_DIRECT3D) )
ini.SetValue( "Options", "VideoRenderers", "d3d" ); ini.SetValue( "Options", "VideoRenderers", (RString)"d3d" );
else else
ini.SetValue( "Options", "VideoRenderers", "" ); ini.SetValue( "Options", "VideoRenderers", RString() );
if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE) ) if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE) )
ini.SetValue( "Options", "SoundDrivers", "DirectSound" ); ini.SetValue( "Options", "SoundDrivers", (RString)"DirectSound" );
else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE) ) else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE) )
ini.SetValue( "Options", "SoundDrivers", "DirectSound-sw" ); ini.SetValue( "Options", "SoundDrivers", (RString)"DirectSound-sw" );
else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_WAVEOUT) ) else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_WAVEOUT) )
ini.SetValue( "Options", "SoundDrivers", "WaveOut" ); ini.SetValue( "Options", "SoundDrivers", (RString)"WaveOut" );
else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_NULL) ) else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_NULL) )
ini.SetValue( "Options", "SoundDrivers", "null" ); ini.SetValue( "Options", "SoundDrivers", (RString)"null" );
else else
ini.SetValue( "Options", "SoundDrivers", "" ); ini.SetValue( "Options", "SoundDrivers", RString() );
ini.SetValue( "Options", "LogToDisk", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_LOG_TO_DISK) ); ini.SetValue( "Options", "LogToDisk", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_LOG_TO_DISK) );
ini.SetValue( "Options", "ShowLogWindow", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_SHOW_LOG_WINDOW) ); ini.SetValue( "Options", "ShowLogWindow", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_SHOW_LOG_WINDOW) );
ini.WriteFile(); ini.WriteFile( SpecialFiles::PREFERENCES_INI_PATH );
CDialog::OnOK(); CDialog::OnOK();
} }
+9 -6
View File
@@ -1,6 +1,8 @@
// EditInsallations.cpp : implementation file // EditInsallations.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "EditInsallations.h" #include "EditInsallations.h"
@@ -53,10 +55,10 @@ BOOL EditInsallations::OnInitDialog()
// TODO: Add extra initialization here // TODO: Add extra initialization here
CStringArray asInstallDirs; vector<RString> vs;
GetStepManiaInstallDirs( asInstallDirs ); SMPackageUtil::GetStepManiaInstallDirs( vs );
for( unsigned i=0; i<asInstallDirs.size(); i++ ) for( unsigned i=0; i<vs.size(); i++ )
m_list.AddString( asInstallDirs[i] ); m_list.AddString( vs[i] );
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
@@ -114,13 +116,14 @@ void EditInsallations::OnButtonAdd()
void EditInsallations::OnOK() void EditInsallations::OnOK()
{ {
m_asReturnedInstallDirs.clear(); m_vsReturnedInstallDirs.clear();
for( int i=0; i<m_list.GetCount(); i++ ) for( int i=0; i<m_list.GetCount(); i++ )
{ {
CString sDir; CString sDir;
m_list.GetText( i, sDir ); m_list.GetText( i, sDir );
m_asReturnedInstallDirs.push_back( sDir ); RString s = sDir;
m_vsReturnedInstallDirs.push_back( s );
} }
CDialog::OnOK(); CDialog::OnOK();
+1 -1
View File
@@ -16,7 +16,7 @@ class EditInsallations : public CDialog
public: public:
EditInsallations(CWnd* pParent = NULL); // standard constructor EditInsallations(CWnd* pParent = NULL); // standard constructor
CStringArray m_asReturnedInstallDirs; vector<RString> m_vsReturnedInstallDirs;
// Dialog Data // Dialog Data
//{{AFX_DATA(EditInsallations) //{{AFX_DATA(EditInsallations)
+2
View File
@@ -1,6 +1,8 @@
// EnterComment.cpp : implementation file // EnterComment.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "EnterComment.h" #include "EnterComment.h"
+2
View File
@@ -1,6 +1,8 @@
// EnterName.cpp : implementation file // EnterName.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "EnterName.h" #include "EnterName.h"
+40 -41
View File
@@ -1,16 +1,20 @@
// MainMenuDlg.cpp : implementation file // MainMenuDlg.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "MainMenuDlg.h" #include "MainMenuDlg.h"
#include "EditInsallations.h" #include "EditInsallations.h"
#include "SmpackageExportDlg.h" #include "SmpackageExportDlg.h"
#include "onvertThemeDlg.h"
#include "ChangeGameSettings.h" #include "ChangeGameSettings.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "SMPackageUtil.h" #include "SMPackageUtil.h"
#include ".\mainmenudlg.h" #include "mainmenudlg.h"
#include "archutils/Win32/SpecialDirs.h"
#include "SpecialFiles.h"
#include "ProductInfo.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@@ -44,7 +48,6 @@ BEGIN_MESSAGE_MAP(MainMenuDlg, CDialog)
//{{AFX_MSG_MAP(MainMenuDlg) //{{AFX_MSG_MAP(MainMenuDlg)
ON_BN_CLICKED(IDC_EXPORT_PACKAGES, OnExportPackages) ON_BN_CLICKED(IDC_EXPORT_PACKAGES, OnExportPackages)
ON_BN_CLICKED(IDC_EDIT_INSTALLATIONS, OnEditInstallations) ON_BN_CLICKED(IDC_EDIT_INSTALLATIONS, OnEditInstallations)
ON_BN_CLICKED(IDC_ANALYZE_ELEMENTS, OnAnalyzeElements)
ON_BN_CLICKED(IDC_CREATE_SONG, OnCreateSong) ON_BN_CLICKED(IDC_CREATE_SONG, OnCreateSong)
ON_BN_CLICKED(IDC_CLEAR_KEYMAPS, OnBnClickedClearKeymaps) ON_BN_CLICKED(IDC_CLEAR_KEYMAPS, OnBnClickedClearKeymaps)
ON_BN_CLICKED(IDC_CHANGE_PREFERENCES, OnBnClickedChangePreferences) ON_BN_CLICKED(IDC_CHANGE_PREFERENCES, OnBnClickedChangePreferences)
@@ -52,6 +55,7 @@ BEGIN_MESSAGE_MAP(MainMenuDlg, CDialog)
ON_BN_CLICKED(IDC_CLEAR_PREFERENCES, OnBnClickedClearPreferences) ON_BN_CLICKED(IDC_CLEAR_PREFERENCES, OnBnClickedClearPreferences)
//}}AFX_MSG_MAP //}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON_LAUNCH_GAME, OnBnClickedButtonLaunchGame) ON_BN_CLICKED(IDC_BUTTON_LAUNCH_GAME, OnBnClickedButtonLaunchGame)
ON_BN_CLICKED(IDC_VIEW_STATISTICS, OnBnClickedViewStatistics)
END_MESSAGE_MAP() END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -72,14 +76,7 @@ void MainMenuDlg::OnEditInstallations()
int nResponse = dlg.DoModal(); int nResponse = dlg.DoModal();
} }
void MainMenuDlg::OnAnalyzeElements() RString GetLastErrorString()
{
// TODO: Add your control notification handler code here
ConvertThemeDlg dlg;
int nResponse = dlg.DoModal();
}
CString GetLastErrorString()
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
FormatMessage( FormatMessage(
@@ -96,7 +93,7 @@ CString GetLastErrorString()
// Process any inserts in lpMsgBuf. // Process any inserts in lpMsgBuf.
// ... // ...
// Display the string. // Display the string.
CString s = (LPCTSTR)lpMsgBuf; RString s = (LPCTSTR)lpMsgBuf;
// Free the buffer. // Free the buffer.
LocalFree( lpMsgBuf ); LocalFree( lpMsgBuf );
@@ -114,21 +111,13 @@ void MainMenuDlg::OnCreateSong()
"Music file (*.mp3;*.ogg)|*.mp3;*.ogg|||" "Music file (*.mp3;*.ogg)|*.mp3;*.ogg|||"
); );
int iRet = dialog.DoModal(); int iRet = dialog.DoModal();
CString sMusicFile = dialog.GetPathName(); RString sMusicFile = dialog.GetPathName();
if( iRet != IDOK ) if( iRet != IDOK )
return; return;
CString sFileNameNoExt, sExt, sThrowAway;
splitrelpath(
sMusicFile,
sThrowAway,
sFileNameNoExt,
sExt
);
BOOL bSuccess; BOOL bSuccess;
CString sSongDirectory = "Songs\\My Creations\\"; RString sSongDirectory = "Songs\\My Creations\\";
bSuccess = CreateDirectory( sSongDirectory, NULL ); bSuccess = CreateDirectory( sSongDirectory, NULL );
if( !bSuccess ) if( !bSuccess )
{ {
@@ -144,7 +133,7 @@ void MainMenuDlg::OnCreateSong()
} }
} }
sSongDirectory += sFileNameNoExt; sSongDirectory += Basename( sMusicFile );
bSuccess = CreateDirectory( sSongDirectory, NULL ); // CreateDirectory doesn't like a trailing slash bSuccess = CreateDirectory( sSongDirectory, NULL ); // CreateDirectory doesn't like a trailing slash
if( !bSuccess ) if( !bSuccess )
{ {
@@ -153,7 +142,7 @@ void MainMenuDlg::OnCreateSong()
} }
sSongDirectory += "\\"; sSongDirectory += "\\";
CString sNewMusicFile = sSongDirectory + sFileNameNoExt + "." + sExt; RString sNewMusicFile = sSongDirectory + Basename(sMusicFile);
bSuccess = CopyFile( sMusicFile, sNewMusicFile, TRUE ); bSuccess = CopyFile( sMusicFile, sNewMusicFile, TRUE );
if( !bSuccess ) if( !bSuccess )
{ {
@@ -162,7 +151,8 @@ void MainMenuDlg::OnCreateSong()
} }
// create a blank .sm file // create a blank .sm file
CString sNewSongFile = sSongDirectory + sFileNameNoExt + ".sm"; RString sNewSongFile = sMusicFile;
SetExtension( sNewSongFile, "sm" );
FILE *fp = fopen( sNewSongFile, "w" ); FILE *fp = fopen( sNewSongFile, "w" );
if( fp == NULL ) if( fp == NULL )
{ {
@@ -182,8 +172,8 @@ BOOL MainMenuDlg::OnInitDialog()
TCHAR szCurDir[MAX_PATH]; TCHAR szCurDir[MAX_PATH];
GetCurrentDirectory( ARRAYSIZE(szCurDir), szCurDir ); GetCurrentDirectory( ARRAYSIZE(szCurDir), szCurDir );
GetDlgItem( IDC_EDIT_INSTALLATION )->SetWindowText( szCurDir ); GetDlgItem( IDC_EDIT_INSTALLATION )->SetWindowText( szCurDir );
AddStepManiaInstallDir( szCurDir ); SMPackageUtil::AddStepManiaInstallDir( szCurDir );
SetDefaultInstallDir( szCurDir ); SMPackageUtil::SetDefaultInstallDir( szCurDir );
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE // EXCEPTION: OCX Property Pages should return FALSE
@@ -193,14 +183,14 @@ void MainMenuDlg::OnBnClickedClearKeymaps()
{ {
// TODO: Add your control notification handler code here // TODO: Add your control notification handler code here
if( !DoesFileExist( KEYMAPS_INI ) ) if( !DoesFileExist( SpecialFiles::KEYMAPS_PATH ) )
{ {
MessageBox( KEYMAPS_INI + " is already cleared." ); MessageBox( SpecialFiles::KEYMAPS_PATH + " is already cleared." );
} }
else else
{ {
if( !DeleteFile( KEYMAPS_INI ) ) if( !DeleteFile( SpecialFiles::KEYMAPS_PATH ) )
MessageBox( "Failed to delete file " + KEYMAPS_INI + "." ); MessageBox( "Failed to delete file " + SpecialFiles::KEYMAPS_PATH + "." );
} }
} }
@@ -214,38 +204,47 @@ void MainMenuDlg::OnBnClickedChangePreferences()
void MainMenuDlg::OnBnClickedOpenPreferences() void MainMenuDlg::OnBnClickedOpenPreferences()
{ {
// TODO: Add your control notification handler code here // TODO: Add your control notification handler code here
if( !DoesFileExist( PREFERENCES_INI ) ) if( !DoesFileExist( SpecialFiles::PREFERENCES_INI_PATH ) )
{ {
MessageBox( PREFERENCES_INI + " doesn't exist. It will be created next time you start the game." ); MessageBox( SpecialFiles::PREFERENCES_INI_PATH + " doesn't exist. It will be created next time you start the game." );
} }
else else
{ {
if( NULL == ::ShellExecute( this->m_hWnd, "open", PREFERENCES_INI, "", "", SW_SHOWNORMAL ) ) if( NULL == ::ShellExecute( this->m_hWnd, "open", SpecialFiles::PREFERENCES_INI_PATH, "", "", SW_SHOWNORMAL ) )
MessageBox( "Failed to open " + PREFERENCES_INI + ": " + GetLastErrorString() ); MessageBox( "Failed to open " + SpecialFiles::PREFERENCES_INI_PATH + ": " + GetLastErrorString() );
} }
} }
void MainMenuDlg::OnBnClickedClearPreferences() void MainMenuDlg::OnBnClickedClearPreferences()
{ {
// TODO: Add your control notification handler code here // TODO: Add your control notification handler code here
if( !DoesFileExist( PREFERENCES_INI ) ) if( !DoesFileExist( SpecialFiles::PREFERENCES_INI_PATH ) )
{ {
MessageBox( PREFERENCES_INI + " is already cleared." ); MessageBox( SpecialFiles::PREFERENCES_INI_PATH + " is already cleared." );
return; return;
} }
if( !DeleteFile( PREFERENCES_INI ) ) if( !DeleteFile( SpecialFiles::PREFERENCES_INI_PATH ) )
{ {
MessageBox( "Failed to delete file " + PREFERENCES_INI + "." ); MessageBox( "Failed to delete file " + SpecialFiles::PREFERENCES_INI_PATH + "." );
return; return;
} }
MessageBox( PREFERENCES_INI + " cleared." ); MessageBox( SpecialFiles::PREFERENCES_INI_PATH + " cleared." );
} }
void MainMenuDlg::OnBnClickedButtonLaunchGame() void MainMenuDlg::OnBnClickedButtonLaunchGame()
{ {
// TODO: Add your control notification handler code here // TODO: Add your control notification handler code here
LaunchGame(); SMPackageUtil::LaunchGame();
exit(0); exit(0);
} }
void MainMenuDlg::OnBnClickedViewStatistics()
{
// TODO: Add your control notification handler code here
RString sPersonalDir = GetMyDocumentsDir();
RString sFile = sPersonalDir + PRODUCT_ID +"/Save/MachineProfile/Stats.xml";
if( NULL == ::ShellExecute( this->m_hWnd, "open", sFile, "", "", SW_SHOWNORMAL ) )
MessageBox( "Failed to open '" + sFile + "': " + GetLastErrorString() );
}
+1 -1
View File
@@ -37,7 +37,6 @@ protected:
//{{AFX_MSG(MainMenuDlg) //{{AFX_MSG(MainMenuDlg)
afx_msg void OnExportPackages(); afx_msg void OnExportPackages();
afx_msg void OnEditInstallations(); afx_msg void OnEditInstallations();
afx_msg void OnAnalyzeElements();
afx_msg void OnChangeApi(); afx_msg void OnChangeApi();
afx_msg void OnCreateSong(); afx_msg void OnCreateSong();
virtual BOOL OnInitDialog(); virtual BOOL OnInitDialog();
@@ -50,6 +49,7 @@ protected:
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
public: public:
afx_msg void OnBnClickedButtonLaunchGame(); afx_msg void OnBnClickedButtonLaunchGame();
afx_msg void OnBnClickedViewStatistics();
}; };
//{{AFX_INSERT_LOCATION}} //{{AFX_INSERT_LOCATION}}
+70 -93
View File
@@ -1,6 +1,8 @@
// SMPackageInstallDlg.cpp : implementation file // SMPackageInstallDlg.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "SMPackageInstallDlg.h" #include "SMPackageInstallDlg.h"
@@ -11,6 +13,8 @@
#include "IniFile.h" #include "IniFile.h"
#include "UninstallOld.h" #include "UninstallOld.h"
#include <algorithm> #include <algorithm>
#include "RageFileManager.h"
#include "RageFileDriverZip.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@@ -18,6 +22,8 @@
static char THIS_FILE[] = __FILE__; static char THIS_FILE[] = __FILE__;
#endif #endif
static const RString TEMP_MOUNT_POINT = "/@package/";
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CSMPackageInstallDlg dialog // CSMPackageInstallDlg dialog
@@ -56,7 +62,7 @@ END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CSMPackageInstallDlg message handlers // CSMPackageInstallDlg message handlers
static bool CompareStringNoCase( const CString &s1, const CString &s2 ) static bool CompareStringNoCase( const RString &s1, const RString &s2 )
{ {
return s1.CompareNoCase( s2 ) < 0; return s1.CompareNoCase( s2 ) < 0;
} }
@@ -72,12 +78,17 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
// TODO: Add extra initialization here // TODO: Add extra initialization here
int i; // mount the zip
if( !FILEMAN->Mount( "zip", m_sPackagePath, TEMP_MOUNT_POINT ) )
{
AfxMessageBox( ssprintf("'%s' is not a valid zip archive.", m_sPackagePath), MB_ICONSTOP );
exit( 1 );
}
// //
// Set the text of the first Edit box // Set the text of the first Edit box
// //
CString sMessage1 = ssprintf( RString sMessage1 = ssprintf(
"You have chosen to install the Stepmania package:\r\n" "You have chosen to install the Stepmania package:\r\n"
"\r\n" "\r\n"
"\t%s\r\n" "\t%s\r\n"
@@ -92,35 +103,11 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
// //
// Set the text of the second Edit box // Set the text of the second Edit box
// //
try
{ {
m_zip.Open( m_sPackagePath, CZipArchive::zipOpenReadOnly ); vector<RString> vs;
} GetDirListingRecursive( TEMP_MOUNT_POINT, "*.*", vs );
catch (CException* e)
{
AfxMessageBox( ssprintf("'%s' is not a valid zip archive.", m_sPackagePath), MB_ICONSTOP );
e->Delete();
exit( 1 );
}
{
vector<CString> vs;
for( i=0; i<m_zip.GetCount(); i++ )
{
CZipFileHeader fh;
m_zip.GetFileInfo(fh, (WORD)i);
if( fh.IsDirectory() )
continue;
if( !fh.GetFileName().CompareNoCase( "smzip.ctl" ) )
continue;
vs.push_back( fh.GetFileName() );
}
sort( vs.begin(), vs.end(), CompareStringNoCase );
CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2); CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2);
CString sText = "\t" + join( "\r\n\t", vs ); RString sText = "\t" + join( "\r\n\t", vs );
pEdit2->SetWindowText( sText ); pEdit2->SetWindowText( sText );
} }
@@ -128,7 +115,7 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
// //
// Set the text of the third Edit box // Set the text of the third Edit box
// //
CString sMessage3 = "The package will be installed in the following Stepmania program folder:\r\n"; RString sMessage3 = "The package will be installed in the following Stepmania program folder:\r\n";
// Set the message // Set the message
CEdit* pEdit3 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE3); CEdit* pEdit3 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE3);
@@ -174,42 +161,30 @@ void CSMPackageInstallDlg::OnPaint()
bool CSMPackageInstallDlg::CheckPackages() bool CSMPackageInstallDlg::CheckPackages()
{ {
CZipWordArray ar; IniFile ini;
m_zip.FindMatches("smzip.ctl", ar); if( !ini.ReadFile(TEMP_MOUNT_POINT + "smzip.ctl") )
if( ar.GetSize() != 1 )
return true; return true;
CZipMemFile control;
m_zip.ExtractFile( ar[0], control );
char *buf = new char[control.GetLength()];
control.Seek( 0, CZipAbstractFile::begin );
control.Read(buf, control.GetLength());
IniFile ini;
ini.ReadBuf( CString(buf, control.GetLength()) );
delete[] buf;
int version = 0; int version = 0;
ini.GetValueI( "SMZIP", "Version", version ); ini.GetValue( "SMZIP", "Version", version );
if( version != 1 ) if( version != 1 )
return true; return true;
int cnt = 0; int cnt = 0;
ini.GetValueI( "Packages", "NumPackages", cnt ); ini.GetValue( "Packages", "NumPackages", cnt );
int i; vector<RString> Directories;
CStringArray Directories; for( int i = 0; i < cnt; ++i )
for( i = 0; i < cnt; ++i )
{ {
CString path; RString path;
if( !ini.GetValue( "Packages", ssprintf("%i", i), path) ) if( !ini.GetValue( "Packages", ssprintf("%i", i), path) )
continue; continue;
/* Does this directory exist? */ /* Does this directory exist? */
if( !IsADirectory(path) ) if( !FILEMAN->IsADirectory(path) )
continue; continue;
if( !IsValidPackageDirectory(path) ) if( !SMPackageUtil::IsValidPackageDirectory(path) )
continue; continue;
Directories.push_back(path); Directories.push_back(path);
@@ -230,13 +205,13 @@ bool CSMPackageInstallDlg::CheckPackages()
char cwd_[MAX_PATH]; char cwd_[MAX_PATH];
_getcwd(cwd_, MAX_PATH); _getcwd(cwd_, MAX_PATH);
CString cwd(cwd_); RString cwd(cwd_);
if( cwd[cwd.GetLength()-1] != '\\' ) if( cwd[cwd.GetLength()-1] != '\\' )
cwd += "\\"; cwd += "\\";
for( i = 0; i < (int) Directories.size(); ++i ) for( i = 0; i < (int) Directories.size(); ++i )
{ {
CString path = cwd+Directories[i]; RString path = cwd+Directories[i];
char buf[1024]; char buf[1024];
memcpy(buf, path, path.GetLength()+1); memcpy(buf, path, path.GetLength()+1);
buf[path.GetLength()+1] = 0; buf[path.GetLength()+1] = 0;
@@ -267,8 +242,12 @@ void CSMPackageInstallDlg::OnOK()
m_comboDir.EnableWindow( FALSE ); m_comboDir.EnableWindow( FALSE );
m_buttonEdit.EnableWindow( FALSE ); m_buttonEdit.EnableWindow( FALSE );
CString sInstallDir; RString sInstallDir;
m_comboDir.GetWindowText( sInstallDir ); {
CString s;
m_comboDir.GetWindowText( s );
sInstallDir = s;
}
int iSelectedInstallDirIndex = m_comboDir.GetCurSel(); int iSelectedInstallDirIndex = m_comboDir.GetCurSel();
if( iSelectedInstallDirIndex == -1 ) if( iSelectedInstallDirIndex == -1 )
@@ -277,20 +256,24 @@ void CSMPackageInstallDlg::OnOK()
return; return;
} }
SetDefaultInstallDir( iSelectedInstallDirIndex ); SMPackageUtil::SetDefaultInstallDir( iSelectedInstallDirIndex );
// Show comment (if any) // Show comment (if any)
CString sComment = m_zip.GetGlobalComment();
bool DontShowComment;
if( sComment != "" && (!GetPref("DontShowComment", DontShowComment) || !DontShowComment) )
{ {
ShowComment commentDlg; RageFileDriverZip zip;
commentDlg.m_sComment = sComment; zip.Load( m_sPackagePath );
int nResponse = commentDlg.DoModal(); RString sComment = zip.GetGlobalComment();
if( nResponse != IDOK ) bool DontShowComment;
return; // cancelled if( sComment != "" && (!SMPackageUtil::GetPref("DontShowComment", DontShowComment) || !DontShowComment) )
if( commentDlg.m_bDontShow ) {
SetPref( "DontShowComment", true ); ShowComment commentDlg;
commentDlg.m_sComment = sComment;
int nResponse = commentDlg.DoModal();
if( nResponse != IDOK )
return; // cancelled
if( commentDlg.m_bDontShow )
SMPackageUtil::SetPref( "DontShowComment", true );
}
} }
/* Check for installed packages that should be deleted before installing. */ /* Check for installed packages that should be deleted before installing. */
@@ -299,7 +282,9 @@ void CSMPackageInstallDlg::OnOK()
// Unzip the SMzip package into the Stepmania installation folder // Unzip the SMzip package into the Stepmania installation folder
for( int i=0; i<m_zip.GetCount(); i++ ) vector<RString> vs;
GetDirListingRecursive( TEMP_MOUNT_POINT, "*.*", vs );
for( unsigned i=0; i<vs.size(); i++ )
{ {
// Throw some text up so the user has something to look at during the long pause. // Throw some text up so the user has something to look at during the long pause.
CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE1); CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE1);
@@ -312,12 +297,12 @@ void CSMPackageInstallDlg::OnOK()
//Show the hided progress bar //Show the hided progress bar
if(!pProgress1->IsWindowVisible()) if(!pProgress1->IsWindowVisible())
{ {
pProgress1->ShowWindow(SW_SHOWNORMAL); pProgress1->ShowWindow(SW_SHOWNORMAL);
} }
//Initialize the progress bar and update the window 1 time (it's enough) //Initialize the progress bar and update the window 1 time (it's enough)
if(!ProgressInit) if(!ProgressInit)
{ {
pProgress1->SetRange( 0, m_zip.GetCount()); pProgress1->SetRange( 0, vs.size() );
pProgress1->SetStep(1); pProgress1->SetStep(1);
pProgress1->SetPos(0); pProgress1->SetPos(0);
SendMessage( WM_PAINT ); SendMessage( WM_PAINT );
@@ -328,28 +313,18 @@ void CSMPackageInstallDlg::OnOK()
retry_unzip: retry_unzip:
// Extract the files // Extract the files
try const RString sFile = vs[i];
{ // skip extracting "thumbs.db" files
// skip extracting "thumbs.db" files if( Basename(sFile).CompareNoCase("thumbs.db") == 0 )
CZipFileHeader fhInfo; continue;
if( m_zip.GetFileInfo(fhInfo, (WORD)i) )
{
CString sFileName = fhInfo.GetFileName();
sFileName.MakeLower();
if( sFileName.Find("thumbs.db") != -1 )
continue; // skip to next file
}
m_zip.ExtractFile( (WORD)i, sInstallDir, true ); // extract file to current directory RString sBareFile = sFile;
pProgress1->StepIt(); //increase the progress bar of 1 step sBareFile.erase( sBareFile.begin(), sBareFile.begin()+TEMP_MOUNT_POINT.length() );
} RString sTo = sInstallDir + sTo;
catch (CException* e) if( !FileCopy( sFile, sTo ) )
{ {
char szError[4096]; RString sError = ssprintf( "Error copying file '%s'", sBareFile.c_str() );
e->GetErrorMessage( szError, sizeof(szError) ); switch( MessageBox( sError, "Error Extracting File", MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION ) )
e->Delete();
switch( MessageBox( szError, "Error Extracting File", MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION ) )
{ {
case IDABORT: case IDABORT:
exit(1); exit(1);
@@ -362,6 +337,8 @@ retry_unzip:
break; break;
} }
} }
pProgress1->StepIt(); //increase the progress bar of 1 step
} }
AfxMessageBox( "Package installed successfully!" ); AfxMessageBox( "Package installed successfully!" );
@@ -378,7 +355,7 @@ void CSMPackageInstallDlg::OnButtonEdit()
int nResponse = dlg.DoModal(); int nResponse = dlg.DoModal();
if( nResponse == IDOK ) if( nResponse == IDOK )
{ {
WriteStepManiaInstallDirs( dlg.m_asReturnedInstallDirs ); SMPackageUtil::WriteStepManiaInstallDirs( dlg.m_vsReturnedInstallDirs );
RefreshInstallationList(); RefreshInstallationList();
} }
} }
@@ -388,8 +365,8 @@ void CSMPackageInstallDlg::RefreshInstallationList()
{ {
m_comboDir.ResetContent(); m_comboDir.ResetContent();
CStringArray asInstallDirs; vector<RString> asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs ); SMPackageUtil::GetStepManiaInstallDirs( asInstallDirs );
for( unsigned i=0; i<asInstallDirs.size(); i++ ) for( unsigned i=0; i<asInstallDirs.size(); i++ )
m_comboDir.AddString( asInstallDirs[i] ); m_comboDir.AddString( asInstallDirs[i] );
m_comboDir.SetCurSel( 0 ); // guaranteed to be at least one item m_comboDir.SetCurSel( 0 ); // guaranteed to be at least one item
@@ -10,9 +10,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CSMPackageInstallDlg dialog // CSMPackageInstallDlg dialog
#include "ZipArchive\ZipArchive.h"
class CSMPackageInstallDlg : public CDialog class CSMPackageInstallDlg : public CDialog
{ {
// Construction // Construction
@@ -40,8 +37,7 @@ protected:
bool CheckPackages(); bool CheckPackages();
HICON m_hIcon; HICON m_hIcon;
CString m_sPackagePath; RString m_sPackagePath;
CZipArchive m_zip;
// Generated message map functions // Generated message map functions
//{{AFX_MSG(CSMPackageInstallDlg) //{{AFX_MSG(CSMPackageInstallDlg)
+37 -46
View File
@@ -1,49 +1,50 @@
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "SMPackageUtil.h" #include "SMPackageUtil.h"
#include "Registry.h" #include "archutils/Win32/RegistryAccess.h"
#include "../ProductInfo.h" #include "ProductInfo.h"
#include "RageUtil.h"
void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite ) void SMPackageUtil::WriteStepManiaInstallDirs( const vector<RString>& asInstallDirsToWrite )
{ {
CRegistry Reg; RString sKey = "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage\\Installations";
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
unsigned i; unsigned i;
for( i=0; i<100; i++ ) for( i=0; i<100; i++ )
{ {
CString sName = ssprintf("%d",i); RString sName = ssprintf("%d",i);
// Reg.DeleteKey( sName ); // delete key is broken in this library, so just write over it with "" // Reg.DeleteKey( sName ); // delete key is broken in this library, so just write over it with ""
Reg.WriteString( sName, "" ); RegistryAccess::SetRegValue( sKey, sName, RString() );
} }
for( i=0; i<asInstallDirsToWrite.size(); i++ ) for( i=0; i<asInstallDirsToWrite.size(); i++ )
{ {
CString sName = ssprintf("%d",i); RString sName = ssprintf("%d",i);
Reg.WriteString( sName, asInstallDirsToWrite[i] ); RegistryAccess::SetRegValue( sKey, sName, asInstallDirsToWrite[i] );
} }
} }
void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut ) void SMPackageUtil::GetStepManiaInstallDirs( vector<RString>& asInstallDirsOut )
{ {
asInstallDirsOut.clear(); asInstallDirsOut.clear();
CRegistry Reg; RString sKey = "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage\\Installations";
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
for( int i=0; i<100; i++ ) for( int i=0; i<100; i++ )
{ {
CString sName = ssprintf("%d",i); RString sName = ssprintf("%d",i);
CString sPath = Reg.ReadString( sName, "" ); RString sPath;
if( !RegistryAccess::GetRegValue(sKey, sName, sPath) )
continue;
if( sPath == "" ) // read failed if( sPath == "" ) // read failed
continue; // skip continue; // skip
CString sProgramDir = sPath+"\\Program"; RString sProgramDir = sPath+"\\Program";
if( !DoesFileExist(sProgramDir) ) if( !DoesFileExist(sProgramDir) )
continue; // skip continue; // skip
@@ -54,9 +55,9 @@ void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut )
WriteStepManiaInstallDirs( asInstallDirsOut ); WriteStepManiaInstallDirs( asInstallDirsOut );
} }
void AddStepManiaInstallDir( CString sNewInstallDir ) void SMPackageUtil::AddStepManiaInstallDir( RString sNewInstallDir )
{ {
CStringArray asInstallDirs; vector<RString> asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs ); GetStepManiaInstallDirs( asInstallDirs );
bool bAlreadyInList = false; bool bAlreadyInList = false;
@@ -75,24 +76,23 @@ void AddStepManiaInstallDir( CString sNewInstallDir )
WriteStepManiaInstallDirs( asInstallDirs ); WriteStepManiaInstallDirs( asInstallDirs );
} }
void SetDefaultInstallDir( int iInstallDirIndex ) void SMPackageUtil::SetDefaultInstallDir( int iInstallDirIndex )
{ {
// move the specified index to the top of the list // move the specified index to the top of the list
CStringArray asInstallDirs; vector<RString> asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs ); GetStepManiaInstallDirs( asInstallDirs );
ASSERT( iInstallDirIndex >= 0 && iInstallDirIndex < asInstallDirs.size() ); ASSERT( iInstallDirIndex >= 0 && iInstallDirIndex < (int)asInstallDirs.size() );
CString sDefaultInstallDir = asInstallDirs[iInstallDirIndex]; RString sDefaultInstallDir = asInstallDirs[iInstallDirIndex];
asInstallDirs.erase( asInstallDirs.begin()+iInstallDirIndex ); asInstallDirs.erase( asInstallDirs.begin()+iInstallDirIndex );
asInstallDirs.insert( asInstallDirs.begin(), sDefaultInstallDir ); asInstallDirs.insert( asInstallDirs.begin(), sDefaultInstallDir );
WriteStepManiaInstallDirs( asInstallDirs ); WriteStepManiaInstallDirs( asInstallDirs );
} }
void SetDefaultInstallDir( CString sInstallDir ) void SMPackageUtil::SetDefaultInstallDir( RString sInstallDir )
{ {
CStringArray asInstallDirs; vector<RString> asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs ); GetStepManiaInstallDirs( asInstallDirs );
bool bAlreadyInList = false;
for( unsigned i=0; i<asInstallDirs.size(); i++ ) for( unsigned i=0; i<asInstallDirs.size(); i++ )
{ {
if( asInstallDirs[i].CompareNoCase(sInstallDir) == 0 ) if( asInstallDirs[i].CompareNoCase(sInstallDir) == 0 )
@@ -103,32 +103,24 @@ void SetDefaultInstallDir( CString sInstallDir )
} }
} }
bool GetPref( CString name, bool &val ) bool SMPackageUtil::GetPref( RString name, bool &val )
{ {
CRegistry Reg; return RegistryAccess::GetRegValue( "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage", name, val );
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage", FALSE); // don't create if not already present
return Reg.Read( name, val );
} }
bool SetPref( CString name, bool val ) bool SMPackageUtil::SetPref( RString name, bool val )
{ {
CRegistry Reg; return RegistryAccess::SetRegValue( "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage", name, val );
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage", TRUE); // don't create if not already present
Reg.WriteBool( name, val );
return false;
} }
/* Get a package directory. For most paths, this is the first two components. For /* Get a package directory. For most paths, this is the first two components. For
* songs and note skins, this is the first three. */ * songs and note skins, this is the first three. */
CString GetPackageDirectory(CString path) RString SMPackageUtil::GetPackageDirectory(RString path)
{ {
if( path.Find("CVS") != -1 ) if( path.Find("CVS") != -1 )
return ""; // skip return ""; // skip
CStringArray Parts; vector<RString> Parts;
split( path, "\\", Parts ); split( path, "\\", Parts );
unsigned NumParts = 2; unsigned NumParts = 2;
@@ -139,18 +131,17 @@ CString GetPackageDirectory(CString path)
Parts.erase(Parts.begin() + NumParts, Parts.end()); Parts.erase(Parts.begin() + NumParts, Parts.end());
CString ret = join( "\\", Parts ); RString ret = join( "\\", Parts );
if( !IsADirectory(ret) ) if( !IsADirectory(ret) )
return ""; return "";
return ret; return ret;
} }
bool SMPackageUtil::IsValidPackageDirectory( RString path )
bool IsValidPackageDirectory(CString path)
{ {
/* Make sure the path contains only second-level directories, and doesn't /* Make sure the path contains only second-level directories, and doesn't
* contain any ".", "..", "...", etc. dirs. */ * contain any ".", "..", "...", etc. dirs. */
CStringArray Parts; vector<RString> Parts;
split( path, "\\", Parts, true ); split( path, "\\", Parts, true );
if( Parts.size() == 0 ) if( Parts.size() == 0 )
return false; return false;
@@ -170,13 +161,13 @@ bool IsValidPackageDirectory(CString path)
return true; return true;
} }
void LaunchGame() void SMPackageUtil::LaunchGame()
{ {
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFO si; STARTUPINFO si;
ZeroMemory( &si, sizeof(si) ); ZeroMemory( &si, sizeof(si) );
CString sFile = PRODUCT_NAME ".exe"; RString sFile = PRODUCT_NAME ".exe";
if( !DoesFileExist(sFile) ) if( !DoesFileExist(sFile) )
{ {
sFile = "Program\\" + sFile; sFile = "Program\\" + sFile;
+2
View File
@@ -1,6 +1,8 @@
// ShowComment.cpp : implementation file // ShowComment.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "ShowComment.h" #include "ShowComment.h"
+66 -87
View File
@@ -1,6 +1,8 @@
// SmpackageExportDlg.cpp : implementation file // SmpackageExportDlg.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "SmpackageExportDlg.h" #include "SmpackageExportDlg.h"
@@ -11,6 +13,7 @@
#include "smpackageUtil.h" #include "smpackageUtil.h"
#include "EditInsallations.h" #include "EditInsallations.h"
#include "IniFile.h" #include "IniFile.h"
#include "RageFileDriverMemory.h"
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
@@ -76,9 +79,9 @@ BOOL CSmpackageExportDlg::OnInitDialog()
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
} }
CString ReplaceInvalidFileNameChars( CString sOldFileName ) RString ReplaceInvalidFileNameChars( RString sOldFileName )
{ {
CString sNewFileName = sOldFileName; RString sNewFileName = sOldFileName;
const char charsToReplace[] = { const char charsToReplace[] = {
' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'+', '=', '[', ']', '{', '}', '|', ':', '\"', '\\', '+', '=', '[', ']', '{', '}', '|', ':', '\"', '\\',
@@ -89,38 +92,7 @@ CString ReplaceInvalidFileNameChars( CString sOldFileName )
return sNewFileName; return sNewFileName;
} }
void GetFilePaths( CString sDirOrFile, vector<CString> &asPathToFilesOut ) RString GetDesktopPath()
{
vector<CString> asDirectoriesToExplore;
// HACK:
// Must use backslashes in the path, or else WinZip and WinRAR don't see the files.
// Not sure if this is ZipArchive's fault.
if( IsADirectory(sDirOrFile) && sDirOrFile.Right(1) != "\\" )
{
sDirOrFile += "\\";
sDirOrFile += "*.*";
}
if( IsAFile(sDirOrFile) )
{
asPathToFilesOut.push_back( sDirOrFile );
return;
}
GetDirListing( sDirOrFile, asPathToFilesOut, false, true );
GetDirListing( sDirOrFile, asDirectoriesToExplore, true, true );
while( asDirectoriesToExplore.size() > 0 )
{
GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asPathToFilesOut, false, true );
GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asDirectoriesToExplore, true, true );
asDirectoriesToExplore.erase( asDirectoriesToExplore.begin() );
}
}
CString GetDesktopPath()
{ {
static TCHAR strNull[2] = _T(""); static TCHAR strNull[2] = _T("");
static TCHAR strPath[MAX_PATH]; static TCHAR strPath[MAX_PATH];
@@ -145,14 +117,14 @@ CString GetDesktopPath()
return strPath; return strPath;
} }
bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExport, CString sComment ) static bool ExportPackage( RString sPackageName, const vector<RString>& asDirectoriesToExport, RString sComment )
{ {
CZipArchive zip; CZipArchive zip;
// //
// Create the package zip file // Create the package zip file
// //
const CString sPackagePath = GetDesktopPath() + "\\" + sPackageName; const RString sPackagePath = GetDesktopPath() + "\\" + sPackageName;
try try
{ {
zip.Open( sPackagePath, CZipArchive::zipCreate ); zip.Open( sPackagePath, CZipArchive::zipCreate );
@@ -169,31 +141,35 @@ bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExp
zip.SetGlobalComment( sComment ); zip.SetGlobalComment( sComment );
/* Find files to add to zip. */ /* Find files to add to zip. */
unsigned i; vector<RString> asFilePaths;
vector<CString> asFilePaths; for( unsigned i=0; i<asDirectoriesToExport.size(); i++ )
for( i=0; i<asDirectoriesToExport.size(); i++ ) GetDirListingRecursive( asDirectoriesToExport[i], "*.*", asFilePaths );
GetFilePaths( asDirectoriesToExport[i], asFilePaths );
// Must use backslashes in the path, or else WinZip and WinRAR don't see the files.
// Not sure if this is ZipArchive's fault.
//;XXX
{ {
IniFile ini; IniFile ini;
ini.SetValueI( "SMZIP", "Version", 1 ); ini.SetValue( "SMZIP", "Version", 1 );
set<CString> Directories; set<RString> Directories;
for( i=0; i<asFilePaths.size(); i++ ) for( i=0; i<asFilePaths.size(); i++ )
{ {
const CString name = GetPackageDirectory( asFilePaths[i] ); const RString name = SMPackageUtil::GetPackageDirectory( asFilePaths[i] );
if( name != "" ) if( name != "" )
Directories.insert( name ); Directories.insert( name );
} }
set<CString>::const_iterator it; set<RString>::const_iterator it;
int num = 0; int num = 0;
for( it = Directories.begin(); it != Directories.end(); ++it ) for( it = Directories.begin(); it != Directories.end(); ++it )
ini.SetValue( "Packages", ssprintf("%i", num++), *it ); ini.SetValue( "Packages", ssprintf("%i", num++), *it );
ini.SetValueI( "Packages", "NumPackages", num ); ini.SetValue( "Packages", "NumPackages", num );
CString buf; RageFileObjMem f;
ini.WriteBuf(buf); ini.WriteFile( f );
RString buf = f.GetString();
CZipMemFile control; CZipMemFile control;
control.Write( buf.GetBuffer(0), buf.GetLength() ); control.Write( buf.GetBuffer(0), buf.GetLength() );
@@ -207,7 +183,7 @@ bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExp
// //
for( unsigned j=0; j<asFilePaths.size(); j++ ) for( unsigned j=0; j<asFilePaths.size(); j++ )
{ {
CString sFilePath = asFilePaths[j]; RString sFilePath = asFilePaths[j];
// don't export "thumbs.db" files or "CVS" folders // don't export "thumbs.db" files or "CVS" folders
if( sFilePath.Find("CVS")!=-1 ) if( sFilePath.Find("CVS")!=-1 )
@@ -215,12 +191,12 @@ bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExp
if( sFilePath.Find("Thumbs.db")!=-1 ) if( sFilePath.Find("Thumbs.db")!=-1 )
continue; // skip continue; // skip
CString sDir, sFName, sExt; RString sExt = GetExtension( sFilePath );
splitrelpath( sFilePath, sDir, sFName, sExt );
bool bUseCompression = true; bool bUseCompression = true;
if( sExt.CompareNoCase("avi")==0 || if( sExt.CompareNoCase("avi")==0 ||
sExt.CompareNoCase("mpeg")==0 || sExt.CompareNoCase("mpeg")==0 ||
sExt.CompareNoCase("mpg")==0 || sExt.CompareNoCase("mpg")==0 ||
sExt.CompareNoCase("mp3")==0 ||
sExt.CompareNoCase("ogg")==0 || sExt.CompareNoCase("ogg")==0 ||
sExt.CompareNoCase("gif")==0 || sExt.CompareNoCase("gif")==0 ||
sExt.CompareNoCase("jpg")==0 || sExt.CompareNoCase("jpg")==0 ||
@@ -244,10 +220,10 @@ bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExp
return true; return true;
} }
bool CSmpackageExportDlg::MakeComment( CString &comment ) bool CSmpackageExportDlg::MakeComment( RString &comment )
{ {
bool DontAskForComment; bool DontAskForComment;
if( GetPref("DontAskForComment", DontAskForComment) && DontAskForComment ) if( SMPackageUtil::GetPref("DontAskForComment", DontAskForComment) && DontAskForComment )
{ {
comment = ""; comment = "";
return true; return true;
@@ -260,14 +236,14 @@ bool CSmpackageExportDlg::MakeComment( CString &comment )
comment = commentDlg.m_sEnteredComment; comment = commentDlg.m_sEnteredComment;
if( commentDlg.m_bDontAsk ) if( commentDlg.m_bDontAsk )
SetPref( "DontAskForComment", true ); SMPackageUtil::SetPref( "DontAskForComment", true );
return true; return true;
} }
void CSmpackageExportDlg::OnButtonExportAsOne() void CSmpackageExportDlg::OnButtonExportAsOne()
{ {
CStringArray asPaths; vector<RString> asPaths;
GetCheckedPaths( asPaths ); GetCheckedPaths( asPaths );
if( asPaths.size() == 0 ) if( asPaths.size() == 0 )
@@ -282,7 +258,7 @@ void CSmpackageExportDlg::OnButtonExportAsOne()
} }
// Generate a package name // Generate a package name
CString sPackageName; RString sPackageName;
EnterName nameDlg; EnterName nameDlg;
int nResponse = nameDlg.DoModal(); int nResponse = nameDlg.DoModal();
if( nResponse != IDOK ) if( nResponse != IDOK )
@@ -291,7 +267,7 @@ void CSmpackageExportDlg::OnButtonExportAsOne()
sPackageName = ReplaceInvalidFileNameChars( sPackageName+".smzip" ); sPackageName = ReplaceInvalidFileNameChars( sPackageName+".smzip" );
// Generate a comment // Generate a comment
CString sComment; RString sComment;
if( !MakeComment(sComment) ) if( !MakeComment(sComment) )
return; // cancelled return; // cancelled
@@ -301,7 +277,7 @@ void CSmpackageExportDlg::OnButtonExportAsOne()
void CSmpackageExportDlg::OnButtonExportAsIndividual() void CSmpackageExportDlg::OnButtonExportAsIndividual()
{ {
CStringArray asPaths; vector<RString> asPaths;
GetCheckedPaths( asPaths ); GetCheckedPaths( asPaths );
if( asPaths.size() == 0 ) if( asPaths.size() == 0 )
@@ -311,25 +287,24 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual()
} }
// Generate a comment // Generate a comment
CString sComment; RString sComment;
if( !MakeComment(sComment) ) if( !MakeComment(sComment) )
return; // cancelled return; // cancelled
bool bAllSucceeded = true; vector<RString> asExportedPackages;
CStringArray asExportedPackages; vector<RString> asFailedPackages;
CStringArray asFailedPackages;
for( unsigned i=0; i<asPaths.size(); i++ ) for( unsigned i=0; i<asPaths.size(); i++ )
{ {
// Generate a package name for every path // Generate a package name for every path
CString sPath = asPaths[i]; RString sPath = asPaths[i];
CString sPackageName; RString sPackageName;
CStringArray asPathBits; vector<RString> asPathBits;
split( sPath, "\\", asPathBits, true ); split( sPath, "\\", asPathBits, true );
sPackageName = asPathBits[ asPathBits.size()-1 ] + ".smzip"; sPackageName = asPathBits[ asPathBits.size()-1 ] + ".smzip";
sPackageName = ReplaceInvalidFileNameChars( sPackageName ); sPackageName = ReplaceInvalidFileNameChars( sPackageName );
CStringArray asPathsToExport; vector<RString> asPathsToExport;
asPathsToExport.push_back( sPath ); asPathsToExport.push_back( sPath );
if( ExportPackage( sPackageName, asPathsToExport, sComment ) ) if( ExportPackage( sPackageName, asPathsToExport, sComment ) )
@@ -338,7 +313,7 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual()
asFailedPackages.push_back( sPackageName ); asFailedPackages.push_back( sPackageName );
} }
CString sMessage; RString sMessage;
if( asFailedPackages.size() == 0 ) if( asFailedPackages.size() == 0 )
sMessage = ssprintf("Successfully exported the package%s '%s' to your Desktop.", asFailedPackages.size()>1?"s":"", join("', '",asExportedPackages) ); sMessage = ssprintf("Successfully exported the package%s '%s' to your Desktop.", asFailedPackages.size()>1?"s":"", join("', '",asExportedPackages) );
else else
@@ -349,7 +324,7 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual()
void CSmpackageExportDlg::OnButtonPlay() void CSmpackageExportDlg::OnButtonPlay()
{ {
// TODO: Add your control notification handler code here // TODO: Add your control notification handler code here
LaunchGame(); SMPackageUtil::LaunchGame();
exit(0); exit(0);
} }
@@ -390,7 +365,7 @@ void CSmpackageExportDlg::GetCheckedTreeItems( CArray<HTREEITEM,HTREEITEM>& aChe
aCheckedItemsOut.Add( aItems[i] ); aCheckedItemsOut.Add( aItems[i] );
} }
void CSmpackageExportDlg::GetCheckedPaths( CStringArray& aPathsOut ) void CSmpackageExportDlg::GetCheckedPaths( vector<RString>& aPathsOut )
{ {
CArray<HTREEITEM,HTREEITEM> aItems; CArray<HTREEITEM,HTREEITEM> aItems;
@@ -399,15 +374,15 @@ void CSmpackageExportDlg::GetCheckedPaths( CStringArray& aPathsOut )
{ {
HTREEITEM item = aItems[i]; HTREEITEM item = aItems[i];
CString sPath; RString sPath;
while( item ) while( item )
{ {
sPath = m_tree.GetItemText(item) + '\\' + sPath; sPath = (LPCTSTR)m_tree.GetItemText(item) + '\\' + sPath;
item = m_tree.GetParentItem(item); item = m_tree.GetParentItem(item);
} }
sPath.TrimRight('\\'); // strip off last slash TrimRight( sPath, "\\" ); // strip off last slash
aPathsOut.push_back( sPath ); aPathsOut.push_back( sPath );
} }
@@ -421,7 +396,7 @@ void CSmpackageExportDlg::OnButtonEdit()
int nResponse = dlg.DoModal(); int nResponse = dlg.DoModal();
if( nResponse == IDOK ) if( nResponse == IDOK )
{ {
WriteStepManiaInstallDirs( dlg.m_asReturnedInstallDirs ); SMPackageUtil::WriteStepManiaInstallDirs( dlg.m_vsReturnedInstallDirs );
RefreshInstallationList(); RefreshInstallationList();
RefreshTree(); RefreshTree();
} }
@@ -431,8 +406,8 @@ void CSmpackageExportDlg::RefreshInstallationList()
{ {
m_comboDir.ResetContent(); m_comboDir.ResetContent();
CStringArray asInstallDirs; vector<RString> asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs ); SMPackageUtil::GetStepManiaInstallDirs( asInstallDirs );
for( unsigned i=0; i<asInstallDirs.size(); i++ ) for( unsigned i=0; i<asInstallDirs.size(); i++ )
{ {
m_comboDir.AddString( asInstallDirs[i] ); m_comboDir.AddString( asInstallDirs[i] );
@@ -450,14 +425,18 @@ void CSmpackageExportDlg::RefreshTree()
{ {
m_tree.DeleteAllItems(); m_tree.DeleteAllItems();
CString sDir; RString sDir;
m_comboDir.GetWindowText( sDir ); {
CString s;
m_comboDir.GetWindowText( s );
sDir = s;
}
SetCurrentDirectory( sDir ); SetCurrentDirectory( sDir );
// Add announcers // Add announcers
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "Announcers" ); HTREEITEM item1 = m_tree.InsertItem( "Announcers" );
GetDirListing( "Announcers\\*.*", as1, true, false ); GetDirListing( "Announcers\\*.*", as1, true, false );
for( unsigned i=0; i<as1.size(); i++ ) for( unsigned i=0; i<as1.size(); i++ )
@@ -466,7 +445,7 @@ void CSmpackageExportDlg::RefreshTree()
// Add characters // Add characters
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "Characters" ); HTREEITEM item1 = m_tree.InsertItem( "Characters" );
GetDirListing( "Characters\\*.*", as1, true, false ); GetDirListing( "Characters\\*.*", as1, true, false );
for( unsigned i=0; i<as1.size(); i++ ) for( unsigned i=0; i<as1.size(); i++ )
@@ -475,7 +454,7 @@ void CSmpackageExportDlg::RefreshTree()
// Add themes // Add themes
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "Themes" ); HTREEITEM item1 = m_tree.InsertItem( "Themes" );
GetDirListing( "Themes\\*.*", as1, true, false ); GetDirListing( "Themes\\*.*", as1, true, false );
for( unsigned i=0; i<as1.size(); i++ ) for( unsigned i=0; i<as1.size(); i++ )
@@ -484,7 +463,7 @@ void CSmpackageExportDlg::RefreshTree()
// Add BGAnimations // Add BGAnimations
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "BGAnimations" ); HTREEITEM item1 = m_tree.InsertItem( "BGAnimations" );
GetDirListing( "BGAnimations\\*.*", as1, true, false ); GetDirListing( "BGAnimations\\*.*", as1, true, false );
for( unsigned i=0; i<as1.size(); i++ ) for( unsigned i=0; i<as1.size(); i++ )
@@ -493,7 +472,7 @@ void CSmpackageExportDlg::RefreshTree()
// Add RandomMovies // Add RandomMovies
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "RandomMovies" ); HTREEITEM item1 = m_tree.InsertItem( "RandomMovies" );
GetDirListing( "RandomMovies\\*.avi", as1, false, false ); GetDirListing( "RandomMovies\\*.avi", as1, false, false );
GetDirListing( "RandomMovies\\*.mpg", as1, false, false ); GetDirListing( "RandomMovies\\*.mpg", as1, false, false );
@@ -504,7 +483,7 @@ void CSmpackageExportDlg::RefreshTree()
// Add visualizations // Add visualizations
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "Visualizations" ); HTREEITEM item1 = m_tree.InsertItem( "Visualizations" );
GetDirListing( "Visualizations\\*.avi", as1, false, false ); GetDirListing( "Visualizations\\*.avi", as1, false, false );
GetDirListing( "Visualizations\\*.mpg", as1, false, false ); GetDirListing( "Visualizations\\*.mpg", as1, false, false );
@@ -515,7 +494,7 @@ void CSmpackageExportDlg::RefreshTree()
// Add courses // Add courses
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "Courses" ); HTREEITEM item1 = m_tree.InsertItem( "Courses" );
GetDirListing( "Courses\\*.crs", as1, false, false ); GetDirListing( "Courses\\*.crs", as1, false, false );
for( unsigned i=0; i<as1.size(); i++ ) for( unsigned i=0; i<as1.size(); i++ )
@@ -530,12 +509,12 @@ void CSmpackageExportDlg::RefreshTree()
// Add NoteSkins // Add NoteSkins
// //
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "NoteSkins" ); HTREEITEM item1 = m_tree.InsertItem( "NoteSkins" );
GetDirListing( "NoteSkins\\*.*", as1, true, false ); GetDirListing( "NoteSkins\\*.*", as1, true, false );
for( unsigned i=0; i<as1.size(); i++ ) for( unsigned i=0; i<as1.size(); i++ )
{ {
CStringArray as2; vector<RString> as2;
HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 ); HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 );
GetDirListing( "NoteSkins\\" + as1[i] + "\\*.*", as2, true, false ); GetDirListing( "NoteSkins\\" + as1[i] + "\\*.*", as2, true, false );
for( unsigned j=0; j<as2.size(); j++ ) for( unsigned j=0; j<as2.size(); j++ )
@@ -547,12 +526,12 @@ void CSmpackageExportDlg::RefreshTree()
// Add Songs // Add Songs
// //
{ {
CStringArray as1; vector<RString> as1;
HTREEITEM item1 = m_tree.InsertItem( "Songs" ); HTREEITEM item1 = m_tree.InsertItem( "Songs" );
GetDirListing( "Songs\\*.*", as1, true, false ); GetDirListing( "Songs\\*.*", as1, true, false );
for( unsigned i=0; i<as1.size(); i++ ) for( unsigned i=0; i<as1.size(); i++ )
{ {
CStringArray as2; vector<RString> as2;
HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 ); HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 );
GetDirListing( "Songs\\" + as1[i] + "\\*.*", as2, true, false ); GetDirListing( "Songs\\" + as1[i] + "\\*.*", as2, true, false );
for( unsigned j=0; j<as2.size(); j++ ) for( unsigned j=0; j<as2.size(); j++ )
+2 -2
View File
@@ -42,8 +42,8 @@ protected:
void RefreshTree(); void RefreshTree();
void GetTreeItems( CArray<HTREEITEM,HTREEITEM>& aItemsOut ); void GetTreeItems( CArray<HTREEITEM,HTREEITEM>& aItemsOut );
void GetCheckedTreeItems( CArray<HTREEITEM,HTREEITEM>& aCheckedItemsOut ); void GetCheckedTreeItems( CArray<HTREEITEM,HTREEITEM>& aCheckedItemsOut );
void GetCheckedPaths( CStringArray& aCheckedItemsOut ); void GetCheckedPaths( vector<RString>& aCheckedItemsOut );
bool MakeComment( CString &comment ); bool MakeComment( RString &comment );
// Generated message map functions // Generated message map functions
//{{AFX_MSG(CSmpackageExportDlg) //{{AFX_MSG(CSmpackageExportDlg)
-1
View File
@@ -23,7 +23,6 @@
#include <vector> #include <vector>
using namespace std; using namespace std;
#define CStringArray vector<CString>
//{{AFX_INSERT_LOCATION}} //{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+2
View File
@@ -7,6 +7,8 @@
// http : www.ittiger.net // http : www.ittiger.net
// //
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "TreeCtrlEx.h" #include "TreeCtrlEx.h"
+2
View File
@@ -1,6 +1,8 @@
// UninstallOld.cpp : implementation file // UninstallOld.cpp : implementation file
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "UninstallOld.h" #include "UninstallOld.h"
+1 -5
View File
@@ -13,14 +13,10 @@
#define IDD_EDIT_INSTALLATIONS 138 #define IDD_EDIT_INSTALLATIONS 138
#define IDD_MENU 139 #define IDD_MENU 139
#define MENU 140 #define MENU 140
#define IDD_CONVERT_THEME 142
#define IDD_EDIT_METRICS 145
#define EDIT_METRICS 146
#define IDD_ENTER_COMMENT 146 #define IDD_ENTER_COMMENT 146
#define IDD_SHOW_COMMENT 147 #define IDD_SHOW_COMMENT 147
#define IDD_UNINSTALL_OLD_PACKAGES 148 #define IDD_UNINSTALL_OLD_PACKAGES 148
#define IDD_CHANGE_GAME_SETTINGS 149 #define IDD_CHANGE_GAME_SETTINGS 149
#define CONVERTTHEME 149
#define IDC_LIST_SONGS 1000 #define IDC_LIST_SONGS 1000
#define IDC_LIST 1000 #define IDC_LIST 1000
#define IDC_BUTTON_PLAY 1001 #define IDC_BUTTON_PLAY 1001
@@ -41,7 +37,6 @@
#define IDC_BUTTON_MAKE_DEFAULT 1020 #define IDC_BUTTON_MAKE_DEFAULT 1020
#define IDC_EXPORT_PACKAGES 1022 #define IDC_EXPORT_PACKAGES 1022
#define IDC_LIST_THEMES 1023 #define IDC_LIST_THEMES 1023
#define IDC_ANALYZE_ELEMENTS 1023
#define IDC_EDIT_INSTALLATIONS 1024 #define IDC_EDIT_INSTALLATIONS 1024
#define IDC_BUTTON_CONVERT 1024 #define IDC_BUTTON_CONVERT 1024
#define IDC_BUTTON_ANALYZE 1025 #define IDC_BUTTON_ANALYZE 1025
@@ -56,6 +51,7 @@
#define IDC_CLEAR_PREFERENCES 1028 #define IDC_CLEAR_PREFERENCES 1028
#define IDC_EDIT_DEFAULT 1029 #define IDC_EDIT_DEFAULT 1029
#define IDC_CLEAR_KEYMAPS 1029 #define IDC_CLEAR_KEYMAPS 1029
#define IDC_VIEW_STATISTICS 1030
#define IDC_BUTTON_REFRESH 1035 #define IDC_BUTTON_REFRESH 1035
#define IDC_BUTTON_SAVE 1036 #define IDC_BUTTON_SAVE 1036
#define IDC_BUTTON_OVERRIDE 1037 #define IDC_BUTTON_OVERRIDE 1037
+16 -8
View File
@@ -1,6 +1,8 @@
// smpackage.cpp : Defines the class behaviors for the application. // smpackage.cpp : Defines the class behaviors for the application.
// //
#define CO_EXIST_WITH_MFC
#include "global.h"
#include "stdafx.h" #include "stdafx.h"
#include "smpackage.h" #include "smpackage.h"
#include "smpackageExportDlg.h" #include "smpackageExportDlg.h"
@@ -8,6 +10,7 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "smpackageUtil.h" #include "smpackageUtil.h"
#include "MainMenuDlg.h" #include "MainMenuDlg.h"
#include "RageFileManager.h"
#ifdef _DEBUG #ifdef _DEBUG
@@ -66,32 +69,32 @@ BOOL CSmpackageApp::InitInstance()
// make sure it's in the list of install directories // make sure it's in the list of install directories
TCHAR szCurrentDirectory[MAX_PATH]; TCHAR szCurrentDirectory[MAX_PATH];
GetCurrentDirectory( MAX_PATH, szCurrentDirectory ); GetCurrentDirectory( MAX_PATH, szCurrentDirectory );
AddStepManiaInstallDir( szCurrentDirectory ); SMPackageUtil::AddStepManiaInstallDir( szCurrentDirectory );
} }
// check if there's a .smzip command line argument // check if there's a .smzip command line argument
CStringArray arrayCommandLineBits; vector<RString> arrayCommandLineBits;
split( ::GetCommandLine(), "\"", arrayCommandLineBits ); split( ::GetCommandLine(), "\"", arrayCommandLineBits );
for( unsigned i=0; i<arrayCommandLineBits.size(); i++ ) for( unsigned i=0; i<arrayCommandLineBits.size(); i++ )
{ {
CString sPath = arrayCommandLineBits[i]; RString sPath = arrayCommandLineBits[i];
sPath.TrimLeft(); TrimLeft( sPath );
sPath.TrimRight(); TrimRight( sPath );
CString sPathLower = sPath; RString sPathLower = sPath;
sPathLower.MakeLower(); sPathLower.MakeLower();
// test to see if this is a smzip file // test to see if this is a smzip file
if( sPathLower.Right(3) == "zip" ) if( sPathLower.Right(3) == "zip" )
{ {
if( !DoesFileExist(sPath) ) if( !FILEMAN->DoesFileExist(sPath) )
{ {
AfxMessageBox( ssprintf("The file '%s' does not exist. Aborting installation.",sPath), MB_ICONERROR ); AfxMessageBox( ssprintf("The file '%s' does not exist. Aborting installation.",sPath), MB_ICONERROR );
exit(0); exit(0);
} }
// We found a zip package. Prompt the user to install it! // We found a zip package. Prompt the user to install it!
CSMPackageInstallDlg dlg( sPath ); CSMPackageInstallDlg dlg( CString(sPath.c_str()) );
int nResponse = dlg.DoModal(); int nResponse = dlg.DoModal();
if( nResponse == IDOK ) if( nResponse == IDOK )
{ {
@@ -109,6 +112,8 @@ BOOL CSmpackageApp::InitInstance()
} }
} }
FILEMAN = new RageFileManager( "" );
// Show the Manager Dialog // Show the Manager Dialog
MainMenuDlg dlg; MainMenuDlg dlg;
@@ -116,6 +121,9 @@ BOOL CSmpackageApp::InitInstance()
// if (nResponse == IDOK) // if (nResponse == IDOK)
SAFE_DELETE( FILEMAN );
// Since the dialog has been closed, return FALSE so that we exit the // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump. // application, rather than start the application's message pump.
return FALSE; return FALSE;
+25 -96
View File
@@ -155,91 +155,38 @@ BEGIN
IDC_STATIC,18,144,196,17 IDC_STATIC,18,144,196,17
END END
IDD_MENU DIALOGEX 0, 0, 332, 345 IDD_MENU DIALOGEX 0, 0, 332, 310
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "StepMania Tools Main Menu" CAPTION "StepMania Tools Main Menu"
FONT 8, "MS Sans Serif", 0, 0, 0x1 FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Exit",IDOK,275,324,50,14 DEFPUSHBUTTON "Exit",IDOK,275,289,50,14
CONTROL 140,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38 CONTROL 140,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
GROUPBOX "Installations",IDC_STATIC,7,163,318,39 GROUPBOX "Installation",IDC_STATIC,7,41,318,28
PUSHBUTTON "Edit Installations",IDC_EDIT_INSTALLATIONS,16,178,75,15 PUSHBUTTON "Edit Installations",IDC_EDIT_INSTALLATIONS,241,49,75,15
LTEXT "Choose this option to edit the list of locations where you have StepMania or DWI installed. When you double-click on a .smzip file, you can choose to install the package to any of these locations.", GROUPBOX "Create and Share",IDC_STATIC,7,198,318,86
IDC_STATIC,104,173,215,25 PUSHBUTTON "Export Packages",IDC_EXPORT_PACKAGES,15,213,75,15
GROUPBOX ".smzip Packages",IDC_STATIC,7,203,318,40 LTEXT "Create .smzip package files to share with other users. Packages can contain songs, courses, themes, backgrounds, and more.",
PUSHBUTTON "Export Packages",IDC_EXPORT_PACKAGES,15,218,75,15 IDC_STATIC,104,212,215,18
LTEXT "Choose this option to create .smzip files that you can share with other users. A .smzip package can contain songs, courses, themes, background animations, and more.", PUSHBUTTON "Create Song",IDC_CREATE_SONG,15,260,75,15
IDC_STATIC,104,213,215,25
GROUPBOX "Themes",IDC_STATIC,7,245,318,40
PUSHBUTTON "Theme Tools",IDC_ANALYZE_ELEMENTS,15,260,75,15
LTEXT "Using this feature, you can:\n - Catch redundant and misnamed theme elements\n - Edit theme metrics using a user-friendly interface",
IDC_STATIC,102,255,215,26
GROUPBOX "Songs",IDC_STATIC,7,287,318,34
PUSHBUTTON "Create Song",IDC_CREATE_SONG,16,299,75,15
LTEXT "Choose this option to create a new song in StepMania from your favorite mp3 or ogg music file.", LTEXT "Choose this option to create a new song in StepMania from your favorite mp3 or ogg music file.",
IDC_STATIC,103,298,215,20 IDC_STATIC,103,259,215,20
GROUPBOX "Preferences",IDC_STATIC,7,53,318,69 GROUPBOX "Game Settings",IDC_STATIC,7,109,318,87
PUSHBUTTON "Change Preferences",IDC_CHANGE_PREFERENCES,16,65,75,15 PUSHBUTTON "Change Preferences",IDC_CHANGE_PREFERENCES,16,120,75,15
PUSHBUTTON "Open Preferences",IDC_OPEN_PREFERENCES,16,101,75,15 PUSHBUTTON "Open Preferences",IDC_OPEN_PREFERENCES,16,152,75,15
LTEXT "Using this feature, you can:\n - Change the graphics API that the game will use.\n - Change the sound API that the game will use.\n - Clear all preferences if the game won't start.\n - Open the preferences file to make changes by hand.", LTEXT "Using this feature, you can:\n - Change the graphics API that the game will use.\n - Change the sound API that the game will use.\n - Clear all preferences if the game won't start.\n - Open the preferences file to make changes by hand.",
IDC_STATIC,104,67,215,45 IDC_STATIC,104,123,215,45
PUSHBUTTON "Clear Preferences",IDC_CLEAR_PREFERENCES,16,83,75,15 PUSHBUTTON "Clear Preferences",IDC_CLEAR_PREFERENCES,16,136,75,15
PUSHBUTTON "Clear Mappings",IDC_CLEAR_KEYMAPS,16,138,75,15 PUSHBUTTON "Clear Mappings",IDC_CLEAR_KEYMAPS,16,175,75,15
RTEXT "Installation:",IDC_STATIC,37,42,63,9,0, EDITTEXT IDC_EDIT_INSTALLATION,16,51,219,12,ES_AUTOHSCROLL |
WS_EX_TRANSPARENT
EDITTEXT IDC_EDIT_INSTALLATION,105,40,220,12,ES_AUTOHSCROLL |
ES_READONLY ES_READONLY
GROUPBOX "Keyboard / Joystick Mappings",IDC_STATIC,7,123,318,39 LTEXT "Erase all of your keyboard and joystick mappings if you've made a mistake.",
LTEXT "Erase all of your keyboard and joystick mappings if you've made a mistake mapping keys in the game and can't get back to change them.", IDC_STATIC,104,174,214,18
IDC_STATIC,104,133,214,25 PUSHBUTTON "Launch Game",IDC_BUTTON_LAUNCH_GAME,189,289,70,14
PUSHBUTTON "Launch Game",IDC_BUTTON_LAUNCH_GAME,189,324,70,14 PUSHBUTTON "View Statistics",IDC_VIEW_STATISTICS,16,85,75,15
END LTEXT "View high scores and usage statistics and other saved from your play.",
IDC_STATIC,103,84,215,20
IDD_CONVERT_THEME DIALOGEX 0, 0, 332, 258 GROUPBOX "Statistics",IDC_STATIC,7,72,318,35
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Theme Elements"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "Close",IDOK,275,237,50,14
CONTROL 149,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
LISTBOX IDC_LIST_THEMES,7,44,88,186,LBS_SORT |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Tools",IDC_STATIC,105,41,220,189
LTEXT "Check for redundant or possibly midnamed theme elements.",
IDC_STATIC,110,75,210,11
PUSHBUTTON "Analyze Elements",IDC_BUTTON_ANALYZE,165,55,95,15,
WS_DISABLED
LTEXT "Edit theme metrics with a user-friendly interface.",
IDC_STATIC,110,116,210,10
PUSHBUTTON "Edit Metrics",IDC_BUTTON_EDIT_METRICS,165,96,95,15,
WS_DISABLED
LTEXT "Check for redundant or possibly midnamed theme metrics.",
IDC_STATIC,109,158,210,10
PUSHBUTTON "Analyze Metrics",IDC_BUTTON_ANALYZE_METRICS,165,138,95,
15,WS_DISABLED
END
IDD_EDIT_METRICS DIALOG 0, 0, 332, 234
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Edit Theme Metrics"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "Close",IDC_BUTTON_CLOSE,275,213,50,14
CONTROL 146,IDC_STATIC,"Static",SS_BITMAP,0,0,332,38
EDITTEXT IDC_EDIT_VALUE,217,95,108,50,ES_MULTILINE |
ES_AUTOVSCROLL | WS_DISABLED
LTEXT "Value",IDC_STATIC,218,83,88,9
EDITTEXT IDC_EDIT_DEFAULT,217,161,108,48,ES_MULTILINE |
ES_AUTOVSCROLL | ES_READONLY
LTEXT "Default Value",IDC_STATIC,218,148,88,9
PUSHBUTTON "Override",IDC_BUTTON_OVERRIDE,217,45,60,14,WS_DISABLED
PUSHBUTTON "Remove Override",IDC_BUTTON_REMOVE,217,64,60,14,
WS_DISABLED
CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS |
TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,7,44,203,165
PUSHBUTTON "Save",IDC_BUTTON_SAVE,203,213,56,14
PUSHBUTTON "Explanation",IDC_BUTTON_HELP,65,214,71,13
END END
IDD_ENTER_COMMENT DIALOGEX 0, 0, 312, 202 IDD_ENTER_COMMENT DIALOGEX 0, 0, 312, 202
@@ -405,23 +352,7 @@ BEGIN
LEFTMARGIN, 7 LEFTMARGIN, 7
RIGHTMARGIN, 325 RIGHTMARGIN, 325
TOPMARGIN, 7 TOPMARGIN, 7
BOTTOMMARGIN, 338 BOTTOMMARGIN, 303
END
IDD_CONVERT_THEME, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 325
TOPMARGIN, 7
BOTTOMMARGIN, 251
END
IDD_EDIT_METRICS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 325
TOPMARGIN, 7
BOTTOMMARGIN, 227
END END
IDD_ENTER_COMMENT, DIALOG IDD_ENTER_COMMENT, DIALOG
@@ -467,8 +398,6 @@ END
INSTALL BITMAP "install.bmp" INSTALL BITMAP "install.bmp"
MANAGE BITMAP "manage.bmp" MANAGE BITMAP "manage.bmp"
MENU BITMAP "menu.bmp" MENU BITMAP "menu.bmp"
EDIT_METRICS BITMAP "editmetrics.bmp"
CONVERTTHEME BITMAP "converttheme.bmp"
#endif // English (U.S.) resources #endif // English (U.S.) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
+15 -18
View File
@@ -1,24 +1,21 @@
#ifndef SMPACKAGE_UTIL_H #ifndef SMPackageUtil_H
#define SMPACKAGE_UTIL_H #define SMPackageUtil_H
#include "RageUtil.h" namespace SMPackageUtil
#include "../ProductInfo.h" {
void WriteStepManiaInstallDirs( const vector<RString>& asInstallDirsToWrite );
void GetStepManiaInstallDirs( vector<RString>& asInstallDirsOut );
void AddStepManiaInstallDir( RString sNewInstallDir );
void SetDefaultInstallDir( int iInstallDirIndex );
void SetDefaultInstallDir( RString sInstallDir );
static const CString PREFERENCES_INI = "Save\\Preferences.ini"; bool GetPref( RString name, bool &val );
static const CString KEYMAPS_INI = "Save\\Keymaps.ini"; bool SetPref( RString name, bool val );
void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite ); RString GetPackageDirectory(RString path);
void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut ); bool IsValidPackageDirectory(RString path);
void AddStepManiaInstallDir( CString sNewInstallDir );
void SetDefaultInstallDir( int iInstallDirIndex );
void SetDefaultInstallDir( CString sInstallDir );
bool GetPref( CString name, bool &val ); void LaunchGame();
bool SetPref( CString name, bool val ); }
CString GetPackageDirectory(CString path);
bool IsValidPackageDirectory(CString path);
void LaunchGame();
#endif #endif