diff --git a/stepmania/src/smpackage/ChangeGameSettings.cpp b/stepmania/src/smpackage/ChangeGameSettings.cpp index b021e666a6..816ef7cba8 100644 --- a/stepmania/src/smpackage/ChangeGameSettings.cpp +++ b/stepmania/src/smpackage/ChangeGameSettings.cpp @@ -1,11 +1,14 @@ // ChangeGameSettings.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "ChangeGameSettings.h" #include "IniFile.h" #include "SMPackageUtil.h" +#include "SpecialFiles.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -51,10 +54,9 @@ BOOL ChangeGameSettings::OnInitDialog() // Fill the radio buttons // IniFile ini; - ini.SetPath( PREFERENCES_INI ); - ini.ReadFile(); + ini.ReadFile( SpecialFiles::PREFERENCES_INI_PATH ); - CString sValue; + RString sValue; sValue = ""; @@ -102,35 +104,34 @@ void ChangeGameSettings::OnOK() { // TODO: Add extra validation here IniFile ini; - ini.SetPath( PREFERENCES_INI ); - ini.ReadFile(); - + ini.ReadFile( SpecialFiles::PREFERENCES_INI_PATH ); + 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) ) - ini.SetValue( "Options", "VideoRenderers", "d3d" ); + ini.SetValue( "Options", "VideoRenderers", (RString)"d3d" ); else - ini.SetValue( "Options", "VideoRenderers", "" ); + ini.SetValue( "Options", "VideoRenderers", RString() ); 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) ) - ini.SetValue( "Options", "SoundDrivers", "DirectSound-sw" ); + ini.SetValue( "Options", "SoundDrivers", (RString)"DirectSound-sw" ); 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) ) - ini.SetValue( "Options", "SoundDrivers", "null" ); + ini.SetValue( "Options", "SoundDrivers", (RString)"null" ); 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", "ShowLogWindow", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_SHOW_LOG_WINDOW) ); - ini.WriteFile(); + ini.WriteFile( SpecialFiles::PREFERENCES_INI_PATH ); CDialog::OnOK(); } diff --git a/stepmania/src/smpackage/EditInsallations.cpp b/stepmania/src/smpackage/EditInsallations.cpp index bb081f06e6..38f609200e 100644 --- a/stepmania/src/smpackage/EditInsallations.cpp +++ b/stepmania/src/smpackage/EditInsallations.cpp @@ -1,6 +1,8 @@ // EditInsallations.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "EditInsallations.h" @@ -53,10 +55,10 @@ BOOL EditInsallations::OnInitDialog() // TODO: Add extra initialization here - CStringArray asInstallDirs; - GetStepManiaInstallDirs( asInstallDirs ); - for( unsigned i=0; i vs; + SMPackageUtil::GetStepManiaInstallDirs( vs ); + for( unsigned i=0; i m_vsReturnedInstallDirs; // Dialog Data //{{AFX_DATA(EditInsallations) diff --git a/stepmania/src/smpackage/EnterComment.cpp b/stepmania/src/smpackage/EnterComment.cpp index 2dc91a6ff3..09fe222183 100644 --- a/stepmania/src/smpackage/EnterComment.cpp +++ b/stepmania/src/smpackage/EnterComment.cpp @@ -1,6 +1,8 @@ // EnterComment.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "EnterComment.h" diff --git a/stepmania/src/smpackage/EnterName.cpp b/stepmania/src/smpackage/EnterName.cpp index a7438e0bc8..4041a0f7df 100644 --- a/stepmania/src/smpackage/EnterName.cpp +++ b/stepmania/src/smpackage/EnterName.cpp @@ -1,6 +1,8 @@ // EnterName.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "EnterName.h" diff --git a/stepmania/src/smpackage/MainMenuDlg.cpp b/stepmania/src/smpackage/MainMenuDlg.cpp index 4ecef6bcb0..30315080ce 100644 --- a/stepmania/src/smpackage/MainMenuDlg.cpp +++ b/stepmania/src/smpackage/MainMenuDlg.cpp @@ -1,16 +1,20 @@ // MainMenuDlg.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "MainMenuDlg.h" #include "EditInsallations.h" #include "SmpackageExportDlg.h" -#include "onvertThemeDlg.h" #include "ChangeGameSettings.h" #include "RageUtil.h" #include "SMPackageUtil.h" -#include ".\mainmenudlg.h" +#include "mainmenudlg.h" +#include "archutils/Win32/SpecialDirs.h" +#include "SpecialFiles.h" +#include "ProductInfo.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -44,7 +48,6 @@ BEGIN_MESSAGE_MAP(MainMenuDlg, CDialog) //{{AFX_MSG_MAP(MainMenuDlg) ON_BN_CLICKED(IDC_EXPORT_PACKAGES, OnExportPackages) 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_CLEAR_KEYMAPS, OnBnClickedClearKeymaps) ON_BN_CLICKED(IDC_CHANGE_PREFERENCES, OnBnClickedChangePreferences) @@ -52,6 +55,7 @@ BEGIN_MESSAGE_MAP(MainMenuDlg, CDialog) ON_BN_CLICKED(IDC_CLEAR_PREFERENCES, OnBnClickedClearPreferences) //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON_LAUNCH_GAME, OnBnClickedButtonLaunchGame) + ON_BN_CLICKED(IDC_VIEW_STATISTICS, OnBnClickedViewStatistics) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// @@ -72,14 +76,7 @@ void MainMenuDlg::OnEditInstallations() int nResponse = dlg.DoModal(); } -void MainMenuDlg::OnAnalyzeElements() -{ - // TODO: Add your control notification handler code here - ConvertThemeDlg dlg; - int nResponse = dlg.DoModal(); -} - -CString GetLastErrorString() +RString GetLastErrorString() { LPVOID lpMsgBuf; FormatMessage( @@ -96,7 +93,7 @@ CString GetLastErrorString() // Process any inserts in lpMsgBuf. // ... // Display the string. - CString s = (LPCTSTR)lpMsgBuf; + RString s = (LPCTSTR)lpMsgBuf; // Free the buffer. LocalFree( lpMsgBuf ); @@ -114,21 +111,13 @@ void MainMenuDlg::OnCreateSong() "Music file (*.mp3;*.ogg)|*.mp3;*.ogg|||" ); int iRet = dialog.DoModal(); - CString sMusicFile = dialog.GetPathName(); + RString sMusicFile = dialog.GetPathName(); if( iRet != IDOK ) return; - CString sFileNameNoExt, sExt, sThrowAway; - splitrelpath( - sMusicFile, - sThrowAway, - sFileNameNoExt, - sExt - ); - BOOL bSuccess; - CString sSongDirectory = "Songs\\My Creations\\"; + RString sSongDirectory = "Songs\\My Creations\\"; bSuccess = CreateDirectory( sSongDirectory, NULL ); 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 if( !bSuccess ) { @@ -153,7 +142,7 @@ void MainMenuDlg::OnCreateSong() } sSongDirectory += "\\"; - CString sNewMusicFile = sSongDirectory + sFileNameNoExt + "." + sExt; + RString sNewMusicFile = sSongDirectory + Basename(sMusicFile); bSuccess = CopyFile( sMusicFile, sNewMusicFile, TRUE ); if( !bSuccess ) { @@ -162,7 +151,8 @@ void MainMenuDlg::OnCreateSong() } // create a blank .sm file - CString sNewSongFile = sSongDirectory + sFileNameNoExt + ".sm"; + RString sNewSongFile = sMusicFile; + SetExtension( sNewSongFile, "sm" ); FILE *fp = fopen( sNewSongFile, "w" ); if( fp == NULL ) { @@ -182,8 +172,8 @@ BOOL MainMenuDlg::OnInitDialog() TCHAR szCurDir[MAX_PATH]; GetCurrentDirectory( ARRAYSIZE(szCurDir), szCurDir ); GetDlgItem( IDC_EDIT_INSTALLATION )->SetWindowText( szCurDir ); - AddStepManiaInstallDir( szCurDir ); - SetDefaultInstallDir( szCurDir ); + SMPackageUtil::AddStepManiaInstallDir( szCurDir ); + SMPackageUtil::SetDefaultInstallDir( szCurDir ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE @@ -193,14 +183,14 @@ void MainMenuDlg::OnBnClickedClearKeymaps() { // 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 { - if( !DeleteFile( KEYMAPS_INI ) ) - MessageBox( "Failed to delete file " + KEYMAPS_INI + "." ); + if( !DeleteFile( SpecialFiles::KEYMAPS_PATH ) ) + MessageBox( "Failed to delete file " + SpecialFiles::KEYMAPS_PATH + "." ); } } @@ -214,38 +204,47 @@ void MainMenuDlg::OnBnClickedChangePreferences() void MainMenuDlg::OnBnClickedOpenPreferences() { // 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 { - if( NULL == ::ShellExecute( this->m_hWnd, "open", PREFERENCES_INI, "", "", SW_SHOWNORMAL ) ) - MessageBox( "Failed to open " + PREFERENCES_INI + ": " + GetLastErrorString() ); + if( NULL == ::ShellExecute( this->m_hWnd, "open", SpecialFiles::PREFERENCES_INI_PATH, "", "", SW_SHOWNORMAL ) ) + MessageBox( "Failed to open " + SpecialFiles::PREFERENCES_INI_PATH + ": " + GetLastErrorString() ); } } void MainMenuDlg::OnBnClickedClearPreferences() { // 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; } - 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; } - MessageBox( PREFERENCES_INI + " cleared." ); + MessageBox( SpecialFiles::PREFERENCES_INI_PATH + " cleared." ); } void MainMenuDlg::OnBnClickedButtonLaunchGame() { // TODO: Add your control notification handler code here - LaunchGame(); + SMPackageUtil::LaunchGame(); 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() ); +} diff --git a/stepmania/src/smpackage/MainMenuDlg.h b/stepmania/src/smpackage/MainMenuDlg.h index 511cd2ba42..026b54e976 100644 --- a/stepmania/src/smpackage/MainMenuDlg.h +++ b/stepmania/src/smpackage/MainMenuDlg.h @@ -37,7 +37,6 @@ protected: //{{AFX_MSG(MainMenuDlg) afx_msg void OnExportPackages(); afx_msg void OnEditInstallations(); - afx_msg void OnAnalyzeElements(); afx_msg void OnChangeApi(); afx_msg void OnCreateSong(); virtual BOOL OnInitDialog(); @@ -50,6 +49,7 @@ protected: DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedButtonLaunchGame(); + afx_msg void OnBnClickedViewStatistics(); }; //{{AFX_INSERT_LOCATION}} diff --git a/stepmania/src/smpackage/SMPackageInstallDlg.cpp b/stepmania/src/smpackage/SMPackageInstallDlg.cpp index 9a1dd479c1..afe3e8f0e7 100644 --- a/stepmania/src/smpackage/SMPackageInstallDlg.cpp +++ b/stepmania/src/smpackage/SMPackageInstallDlg.cpp @@ -1,6 +1,8 @@ // SMPackageInstallDlg.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "SMPackageInstallDlg.h" @@ -11,6 +13,8 @@ #include "IniFile.h" #include "UninstallOld.h" #include +#include "RageFileManager.h" +#include "RageFileDriverZip.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -18,6 +22,8 @@ static char THIS_FILE[] = __FILE__; #endif +static const RString TEMP_MOUNT_POINT = "/@package/"; + ///////////////////////////////////////////////////////////////////////////// // CSMPackageInstallDlg dialog @@ -56,7 +62,7 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // 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; } @@ -72,12 +78,17 @@ BOOL CSMPackageInstallDlg::OnInitDialog() // 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 // - CString sMessage1 = ssprintf( + RString sMessage1 = ssprintf( "You have chosen to install the Stepmania package:\r\n" "\r\n" "\t%s\r\n" @@ -92,35 +103,11 @@ BOOL CSMPackageInstallDlg::OnInitDialog() // // Set the text of the second Edit box // - try - { - m_zip.Open( m_sPackagePath, CZipArchive::zipOpenReadOnly ); - } - catch (CException* e) { - AfxMessageBox( ssprintf("'%s' is not a valid zip archive.", m_sPackagePath), MB_ICONSTOP ); - e->Delete(); - exit( 1 ); - } - - { - vector vs; - for( i=0; i vs; + GetDirListingRecursive( TEMP_MOUNT_POINT, "*.*", vs ); 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 ); } @@ -128,7 +115,7 @@ BOOL CSMPackageInstallDlg::OnInitDialog() // // 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 CEdit* pEdit3 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE3); @@ -174,42 +161,30 @@ void CSMPackageInstallDlg::OnPaint() bool CSMPackageInstallDlg::CheckPackages() { - CZipWordArray ar; - m_zip.FindMatches("smzip.ctl", ar); - if( ar.GetSize() != 1 ) + IniFile ini; + if( !ini.ReadFile(TEMP_MOUNT_POINT + "smzip.ctl") ) 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; - ini.GetValueI( "SMZIP", "Version", version ); + ini.GetValue( "SMZIP", "Version", version ); if( version != 1 ) return true; int cnt = 0; - ini.GetValueI( "Packages", "NumPackages", cnt ); + ini.GetValue( "Packages", "NumPackages", cnt ); - int i; - CStringArray Directories; - for( i = 0; i < cnt; ++i ) + vector Directories; + for( int i = 0; i < cnt; ++i ) { - CString path; + RString path; if( !ini.GetValue( "Packages", ssprintf("%i", i), path) ) continue; /* Does this directory exist? */ - if( !IsADirectory(path) ) + if( !FILEMAN->IsADirectory(path) ) continue; - if( !IsValidPackageDirectory(path) ) + if( !SMPackageUtil::IsValidPackageDirectory(path) ) continue; Directories.push_back(path); @@ -230,13 +205,13 @@ bool CSMPackageInstallDlg::CheckPackages() char cwd_[MAX_PATH]; _getcwd(cwd_, MAX_PATH); - CString cwd(cwd_); + RString cwd(cwd_); if( cwd[cwd.GetLength()-1] != '\\' ) cwd += "\\"; for( i = 0; i < (int) Directories.size(); ++i ) { - CString path = cwd+Directories[i]; + RString path = cwd+Directories[i]; char buf[1024]; memcpy(buf, path, path.GetLength()+1); buf[path.GetLength()+1] = 0; @@ -267,8 +242,12 @@ void CSMPackageInstallDlg::OnOK() m_comboDir.EnableWindow( FALSE ); m_buttonEdit.EnableWindow( FALSE ); - CString sInstallDir; - m_comboDir.GetWindowText( sInstallDir ); + RString sInstallDir; + { + CString s; + m_comboDir.GetWindowText( s ); + sInstallDir = s; + } int iSelectedInstallDirIndex = m_comboDir.GetCurSel(); if( iSelectedInstallDirIndex == -1 ) @@ -277,20 +256,24 @@ void CSMPackageInstallDlg::OnOK() return; } - SetDefaultInstallDir( iSelectedInstallDirIndex ); + SMPackageUtil::SetDefaultInstallDir( iSelectedInstallDirIndex ); // Show comment (if any) - CString sComment = m_zip.GetGlobalComment(); - bool DontShowComment; - if( sComment != "" && (!GetPref("DontShowComment", DontShowComment) || !DontShowComment) ) { - ShowComment commentDlg; - commentDlg.m_sComment = sComment; - int nResponse = commentDlg.DoModal(); - if( nResponse != IDOK ) - return; // cancelled - if( commentDlg.m_bDontShow ) - SetPref( "DontShowComment", true ); + RageFileDriverZip zip; + zip.Load( m_sPackagePath ); + RString sComment = zip.GetGlobalComment(); + bool DontShowComment; + if( sComment != "" && (!SMPackageUtil::GetPref("DontShowComment", DontShowComment) || !DontShowComment) ) + { + 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. */ @@ -299,7 +282,9 @@ void CSMPackageInstallDlg::OnOK() // Unzip the SMzip package into the Stepmania installation folder - for( int i=0; i vs; + GetDirListingRecursive( TEMP_MOUNT_POINT, "*.*", vs ); + for( unsigned i=0; iIsWindowVisible()) { - pProgress1->ShowWindow(SW_SHOWNORMAL); + pProgress1->ShowWindow(SW_SHOWNORMAL); } //Initialize the progress bar and update the window 1 time (it's enough) if(!ProgressInit) { - pProgress1->SetRange( 0, m_zip.GetCount()); + pProgress1->SetRange( 0, vs.size() ); pProgress1->SetStep(1); pProgress1->SetPos(0); SendMessage( WM_PAINT ); @@ -328,28 +313,18 @@ void CSMPackageInstallDlg::OnOK() retry_unzip: // Extract the files - try - { - // skip extracting "thumbs.db" files - CZipFileHeader fhInfo; - if( m_zip.GetFileInfo(fhInfo, (WORD)i) ) - { - CString sFileName = fhInfo.GetFileName(); - sFileName.MakeLower(); - if( sFileName.Find("thumbs.db") != -1 ) - continue; // skip to next file - } + const RString sFile = vs[i]; + // skip extracting "thumbs.db" files + if( Basename(sFile).CompareNoCase("thumbs.db") == 0 ) + continue; - m_zip.ExtractFile( (WORD)i, sInstallDir, true ); // extract file to current directory - pProgress1->StepIt(); //increase the progress bar of 1 step - } - catch (CException* e) + RString sBareFile = sFile; + sBareFile.erase( sBareFile.begin(), sBareFile.begin()+TEMP_MOUNT_POINT.length() ); + RString sTo = sInstallDir + sTo; + if( !FileCopy( sFile, sTo ) ) { - char szError[4096]; - e->GetErrorMessage( szError, sizeof(szError) ); - e->Delete(); - - switch( MessageBox( szError, "Error Extracting File", MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION ) ) + RString sError = ssprintf( "Error copying file '%s'", sBareFile.c_str() ); + switch( MessageBox( sError, "Error Extracting File", MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION ) ) { case IDABORT: exit(1); @@ -362,6 +337,8 @@ retry_unzip: break; } } + + pProgress1->StepIt(); //increase the progress bar of 1 step } AfxMessageBox( "Package installed successfully!" ); @@ -378,7 +355,7 @@ void CSMPackageInstallDlg::OnButtonEdit() int nResponse = dlg.DoModal(); if( nResponse == IDOK ) { - WriteStepManiaInstallDirs( dlg.m_asReturnedInstallDirs ); + SMPackageUtil::WriteStepManiaInstallDirs( dlg.m_vsReturnedInstallDirs ); RefreshInstallationList(); } } @@ -388,8 +365,8 @@ void CSMPackageInstallDlg::RefreshInstallationList() { m_comboDir.ResetContent(); - CStringArray asInstallDirs; - GetStepManiaInstallDirs( asInstallDirs ); + vector asInstallDirs; + SMPackageUtil::GetStepManiaInstallDirs( asInstallDirs ); for( unsigned i=0; i& asInstallDirsToWrite ) { - CRegistry Reg; - Reg.SetRootKey(HKEY_LOCAL_MACHINE); - Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present + RString sKey = "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage\\Installations"; unsigned 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.WriteString( sName, "" ); + RegistryAccess::SetRegValue( sKey, sName, RString() ); } for( i=0; i& asInstallDirsOut ) { asInstallDirsOut.clear(); - CRegistry Reg; - Reg.SetRootKey(HKEY_LOCAL_MACHINE); - Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present + RString sKey = "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage\\Installations"; 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 continue; // skip - CString sProgramDir = sPath+"\\Program"; + RString sProgramDir = sPath+"\\Program"; if( !DoesFileExist(sProgramDir) ) continue; // skip @@ -54,9 +55,9 @@ void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut ) WriteStepManiaInstallDirs( asInstallDirsOut ); } -void AddStepManiaInstallDir( CString sNewInstallDir ) +void SMPackageUtil::AddStepManiaInstallDir( RString sNewInstallDir ) { - CStringArray asInstallDirs; + vector asInstallDirs; GetStepManiaInstallDirs( asInstallDirs ); bool bAlreadyInList = false; @@ -75,24 +76,23 @@ void AddStepManiaInstallDir( CString sNewInstallDir ) WriteStepManiaInstallDirs( asInstallDirs ); } -void SetDefaultInstallDir( int iInstallDirIndex ) +void SMPackageUtil::SetDefaultInstallDir( int iInstallDirIndex ) { // move the specified index to the top of the list - CStringArray asInstallDirs; + vector asInstallDirs; GetStepManiaInstallDirs( asInstallDirs ); - ASSERT( iInstallDirIndex >= 0 && iInstallDirIndex < asInstallDirs.size() ); - CString sDefaultInstallDir = asInstallDirs[iInstallDirIndex]; + ASSERT( iInstallDirIndex >= 0 && iInstallDirIndex < (int)asInstallDirs.size() ); + RString sDefaultInstallDir = asInstallDirs[iInstallDirIndex]; asInstallDirs.erase( asInstallDirs.begin()+iInstallDirIndex ); asInstallDirs.insert( asInstallDirs.begin(), sDefaultInstallDir ); WriteStepManiaInstallDirs( asInstallDirs ); } -void SetDefaultInstallDir( CString sInstallDir ) +void SMPackageUtil::SetDefaultInstallDir( RString sInstallDir ) { - CStringArray asInstallDirs; + vector asInstallDirs; GetStepManiaInstallDirs( asInstallDirs ); - bool bAlreadyInList = false; for( unsigned i=0; i Parts; split( path, "\\", Parts ); unsigned NumParts = 2; @@ -139,18 +131,17 @@ CString GetPackageDirectory(CString path) Parts.erase(Parts.begin() + NumParts, Parts.end()); - CString ret = join( "\\", Parts ); + RString ret = join( "\\", Parts ); if( !IsADirectory(ret) ) return ""; return ret; } - -bool IsValidPackageDirectory(CString path) +bool SMPackageUtil::IsValidPackageDirectory( RString path ) { /* Make sure the path contains only second-level directories, and doesn't * contain any ".", "..", "...", etc. dirs. */ - CStringArray Parts; + vector Parts; split( path, "\\", Parts, true ); if( Parts.size() == 0 ) return false; @@ -170,13 +161,13 @@ bool IsValidPackageDirectory(CString path) return true; } -void LaunchGame() +void SMPackageUtil::LaunchGame() { PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory( &si, sizeof(si) ); - CString sFile = PRODUCT_NAME ".exe"; + RString sFile = PRODUCT_NAME ".exe"; if( !DoesFileExist(sFile) ) { sFile = "Program\\" + sFile; diff --git a/stepmania/src/smpackage/ShowComment.cpp b/stepmania/src/smpackage/ShowComment.cpp index 1877bda6f4..343710e23d 100644 --- a/stepmania/src/smpackage/ShowComment.cpp +++ b/stepmania/src/smpackage/ShowComment.cpp @@ -1,6 +1,8 @@ // ShowComment.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "ShowComment.h" diff --git a/stepmania/src/smpackage/SmpackageExportDlg.cpp b/stepmania/src/smpackage/SmpackageExportDlg.cpp index 3b4325b574..c08b66ffc8 100644 --- a/stepmania/src/smpackage/SmpackageExportDlg.cpp +++ b/stepmania/src/smpackage/SmpackageExportDlg.cpp @@ -1,6 +1,8 @@ // SmpackageExportDlg.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "SmpackageExportDlg.h" @@ -11,6 +13,7 @@ #include "smpackageUtil.h" #include "EditInsallations.h" #include "IniFile.h" +#include "RageFileDriverMemory.h" #include #include @@ -76,9 +79,9 @@ BOOL CSmpackageExportDlg::OnInitDialog() 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[] = { ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=', '[', ']', '{', '}', '|', ':', '\"', '\\', @@ -89,38 +92,7 @@ CString ReplaceInvalidFileNameChars( CString sOldFileName ) return sNewFileName; } -void GetFilePaths( CString sDirOrFile, vector &asPathToFilesOut ) -{ - vector 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() +RString GetDesktopPath() { static TCHAR strNull[2] = _T(""); static TCHAR strPath[MAX_PATH]; @@ -145,14 +117,14 @@ CString GetDesktopPath() return strPath; } -bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExport, CString sComment ) +static bool ExportPackage( RString sPackageName, const vector& asDirectoriesToExport, RString sComment ) { CZipArchive zip; // // Create the package zip file // - const CString sPackagePath = GetDesktopPath() + "\\" + sPackageName; + const RString sPackagePath = GetDesktopPath() + "\\" + sPackageName; try { zip.Open( sPackagePath, CZipArchive::zipCreate ); @@ -169,31 +141,35 @@ bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExp zip.SetGlobalComment( sComment ); /* Find files to add to zip. */ - unsigned i; - vector asFilePaths; - for( i=0; i asFilePaths; + for( unsigned i=0; i Directories; + set Directories; for( i=0; i::const_iterator it; + set::const_iterator it; int num = 0; for( it = Directories.begin(); it != Directories.end(); ++it ) ini.SetValue( "Packages", ssprintf("%i", num++), *it ); - ini.SetValueI( "Packages", "NumPackages", num ); + ini.SetValue( "Packages", "NumPackages", num ); - CString buf; - ini.WriteBuf(buf); + RageFileObjMem f; + ini.WriteFile( f ); + RString buf = f.GetString(); CZipMemFile control; control.Write( buf.GetBuffer(0), buf.GetLength() ); @@ -207,7 +183,7 @@ bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExp // for( unsigned j=0; j asPaths; GetCheckedPaths( asPaths ); if( asPaths.size() == 0 ) @@ -282,7 +258,7 @@ void CSmpackageExportDlg::OnButtonExportAsOne() } // Generate a package name - CString sPackageName; + RString sPackageName; EnterName nameDlg; int nResponse = nameDlg.DoModal(); if( nResponse != IDOK ) @@ -291,7 +267,7 @@ void CSmpackageExportDlg::OnButtonExportAsOne() sPackageName = ReplaceInvalidFileNameChars( sPackageName+".smzip" ); // Generate a comment - CString sComment; + RString sComment; if( !MakeComment(sComment) ) return; // cancelled @@ -301,7 +277,7 @@ void CSmpackageExportDlg::OnButtonExportAsOne() void CSmpackageExportDlg::OnButtonExportAsIndividual() { - CStringArray asPaths; + vector asPaths; GetCheckedPaths( asPaths ); if( asPaths.size() == 0 ) @@ -311,25 +287,24 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual() } // Generate a comment - CString sComment; + RString sComment; if( !MakeComment(sComment) ) return; // cancelled - bool bAllSucceeded = true; - CStringArray asExportedPackages; - CStringArray asFailedPackages; + vector asExportedPackages; + vector asFailedPackages; for( unsigned i=0; i asPathBits; split( sPath, "\\", asPathBits, true ); sPackageName = asPathBits[ asPathBits.size()-1 ] + ".smzip"; sPackageName = ReplaceInvalidFileNameChars( sPackageName ); - CStringArray asPathsToExport; + vector asPathsToExport; asPathsToExport.push_back( sPath ); if( ExportPackage( sPackageName, asPathsToExport, sComment ) ) @@ -338,7 +313,7 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual() asFailedPackages.push_back( sPackageName ); } - CString sMessage; + RString sMessage; if( asFailedPackages.size() == 0 ) sMessage = ssprintf("Successfully exported the package%s '%s' to your Desktop.", asFailedPackages.size()>1?"s":"", join("', '",asExportedPackages) ); else @@ -349,7 +324,7 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual() void CSmpackageExportDlg::OnButtonPlay() { // TODO: Add your control notification handler code here - LaunchGame(); + SMPackageUtil::LaunchGame(); exit(0); } @@ -390,7 +365,7 @@ void CSmpackageExportDlg::GetCheckedTreeItems( CArray& aChe aCheckedItemsOut.Add( aItems[i] ); } -void CSmpackageExportDlg::GetCheckedPaths( CStringArray& aPathsOut ) +void CSmpackageExportDlg::GetCheckedPaths( vector& aPathsOut ) { CArray aItems; @@ -399,15 +374,15 @@ void CSmpackageExportDlg::GetCheckedPaths( CStringArray& aPathsOut ) { HTREEITEM item = aItems[i]; - CString sPath; + RString sPath; while( item ) { - sPath = m_tree.GetItemText(item) + '\\' + sPath; + sPath = (LPCTSTR)m_tree.GetItemText(item) + '\\' + sPath; item = m_tree.GetParentItem(item); } - sPath.TrimRight('\\'); // strip off last slash + TrimRight( sPath, "\\" ); // strip off last slash aPathsOut.push_back( sPath ); } @@ -421,7 +396,7 @@ void CSmpackageExportDlg::OnButtonEdit() int nResponse = dlg.DoModal(); if( nResponse == IDOK ) { - WriteStepManiaInstallDirs( dlg.m_asReturnedInstallDirs ); + SMPackageUtil::WriteStepManiaInstallDirs( dlg.m_vsReturnedInstallDirs ); RefreshInstallationList(); RefreshTree(); } @@ -431,8 +406,8 @@ void CSmpackageExportDlg::RefreshInstallationList() { m_comboDir.ResetContent(); - CStringArray asInstallDirs; - GetStepManiaInstallDirs( asInstallDirs ); + vector asInstallDirs; + SMPackageUtil::GetStepManiaInstallDirs( asInstallDirs ); for( unsigned i=0; i as1; HTREEITEM item1 = m_tree.InsertItem( "Announcers" ); GetDirListing( "Announcers\\*.*", as1, true, false ); for( unsigned i=0; i as1; HTREEITEM item1 = m_tree.InsertItem( "Characters" ); GetDirListing( "Characters\\*.*", as1, true, false ); for( unsigned i=0; i as1; HTREEITEM item1 = m_tree.InsertItem( "Themes" ); GetDirListing( "Themes\\*.*", as1, true, false ); for( unsigned i=0; i as1; HTREEITEM item1 = m_tree.InsertItem( "BGAnimations" ); GetDirListing( "BGAnimations\\*.*", as1, true, false ); for( unsigned i=0; i as1; HTREEITEM item1 = m_tree.InsertItem( "RandomMovies" ); GetDirListing( "RandomMovies\\*.avi", as1, false, false ); GetDirListing( "RandomMovies\\*.mpg", as1, false, false ); @@ -504,7 +483,7 @@ void CSmpackageExportDlg::RefreshTree() // Add visualizations { - CStringArray as1; + vector as1; HTREEITEM item1 = m_tree.InsertItem( "Visualizations" ); GetDirListing( "Visualizations\\*.avi", as1, false, false ); GetDirListing( "Visualizations\\*.mpg", as1, false, false ); @@ -515,7 +494,7 @@ void CSmpackageExportDlg::RefreshTree() // Add courses { - CStringArray as1; + vector as1; HTREEITEM item1 = m_tree.InsertItem( "Courses" ); GetDirListing( "Courses\\*.crs", as1, false, false ); for( unsigned i=0; i as1; HTREEITEM item1 = m_tree.InsertItem( "NoteSkins" ); GetDirListing( "NoteSkins\\*.*", as1, true, false ); for( unsigned i=0; i as2; HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 ); GetDirListing( "NoteSkins\\" + as1[i] + "\\*.*", as2, true, false ); for( unsigned j=0; j as1; HTREEITEM item1 = m_tree.InsertItem( "Songs" ); GetDirListing( "Songs\\*.*", as1, true, false ); for( unsigned i=0; i as2; HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 ); GetDirListing( "Songs\\" + as1[i] + "\\*.*", as2, true, false ); for( unsigned j=0; j& aItemsOut ); void GetCheckedTreeItems( CArray& aCheckedItemsOut ); - void GetCheckedPaths( CStringArray& aCheckedItemsOut ); - bool MakeComment( CString &comment ); + void GetCheckedPaths( vector& aCheckedItemsOut ); + bool MakeComment( RString &comment ); // Generated message map functions //{{AFX_MSG(CSmpackageExportDlg) diff --git a/stepmania/src/smpackage/StdAfx.h b/stepmania/src/smpackage/StdAfx.h index 1616785687..0b9a744c6d 100644 --- a/stepmania/src/smpackage/StdAfx.h +++ b/stepmania/src/smpackage/StdAfx.h @@ -23,7 +23,6 @@ #include using namespace std; -#define CStringArray vector //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/stepmania/src/smpackage/TreeCtrlEx.cpp b/stepmania/src/smpackage/TreeCtrlEx.cpp index 0b4ece5ac7..37d0bb45b5 100644 --- a/stepmania/src/smpackage/TreeCtrlEx.cpp +++ b/stepmania/src/smpackage/TreeCtrlEx.cpp @@ -7,6 +7,8 @@ // http : www.ittiger.net // ////////////////////////////////////////////////////////////// +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "TreeCtrlEx.h" diff --git a/stepmania/src/smpackage/UninstallOld.cpp b/stepmania/src/smpackage/UninstallOld.cpp index 9a1c997418..4761f5dc97 100644 --- a/stepmania/src/smpackage/UninstallOld.cpp +++ b/stepmania/src/smpackage/UninstallOld.cpp @@ -1,6 +1,8 @@ // UninstallOld.cpp : implementation file // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "UninstallOld.h" diff --git a/stepmania/src/smpackage/resource.h b/stepmania/src/smpackage/resource.h index 292341a404..88c393cd9f 100644 --- a/stepmania/src/smpackage/resource.h +++ b/stepmania/src/smpackage/resource.h @@ -13,14 +13,10 @@ #define IDD_EDIT_INSTALLATIONS 138 #define IDD_MENU 139 #define MENU 140 -#define IDD_CONVERT_THEME 142 -#define IDD_EDIT_METRICS 145 -#define EDIT_METRICS 146 #define IDD_ENTER_COMMENT 146 #define IDD_SHOW_COMMENT 147 #define IDD_UNINSTALL_OLD_PACKAGES 148 #define IDD_CHANGE_GAME_SETTINGS 149 -#define CONVERTTHEME 149 #define IDC_LIST_SONGS 1000 #define IDC_LIST 1000 #define IDC_BUTTON_PLAY 1001 @@ -41,7 +37,6 @@ #define IDC_BUTTON_MAKE_DEFAULT 1020 #define IDC_EXPORT_PACKAGES 1022 #define IDC_LIST_THEMES 1023 -#define IDC_ANALYZE_ELEMENTS 1023 #define IDC_EDIT_INSTALLATIONS 1024 #define IDC_BUTTON_CONVERT 1024 #define IDC_BUTTON_ANALYZE 1025 @@ -56,6 +51,7 @@ #define IDC_CLEAR_PREFERENCES 1028 #define IDC_EDIT_DEFAULT 1029 #define IDC_CLEAR_KEYMAPS 1029 +#define IDC_VIEW_STATISTICS 1030 #define IDC_BUTTON_REFRESH 1035 #define IDC_BUTTON_SAVE 1036 #define IDC_BUTTON_OVERRIDE 1037 diff --git a/stepmania/src/smpackage/smpackage.cpp b/stepmania/src/smpackage/smpackage.cpp index a3c82c6033..6f4643620c 100644 --- a/stepmania/src/smpackage/smpackage.cpp +++ b/stepmania/src/smpackage/smpackage.cpp @@ -1,6 +1,8 @@ // smpackage.cpp : Defines the class behaviors for the application. // +#define CO_EXIST_WITH_MFC +#include "global.h" #include "stdafx.h" #include "smpackage.h" #include "smpackageExportDlg.h" @@ -8,6 +10,7 @@ #include "RageUtil.h" #include "smpackageUtil.h" #include "MainMenuDlg.h" +#include "RageFileManager.h" #ifdef _DEBUG @@ -66,32 +69,32 @@ BOOL CSmpackageApp::InitInstance() // make sure it's in the list of install directories TCHAR szCurrentDirectory[MAX_PATH]; GetCurrentDirectory( MAX_PATH, szCurrentDirectory ); - AddStepManiaInstallDir( szCurrentDirectory ); + SMPackageUtil::AddStepManiaInstallDir( szCurrentDirectory ); } // check if there's a .smzip command line argument - CStringArray arrayCommandLineBits; + vector arrayCommandLineBits; split( ::GetCommandLine(), "\"", arrayCommandLineBits ); for( unsigned i=0; iDoesFileExist(sPath) ) { AfxMessageBox( ssprintf("The file '%s' does not exist. Aborting installation.",sPath), MB_ICONERROR ); exit(0); } // We found a zip package. Prompt the user to install it! - CSMPackageInstallDlg dlg( sPath ); + CSMPackageInstallDlg dlg( CString(sPath.c_str()) ); int nResponse = dlg.DoModal(); if( nResponse == IDOK ) { @@ -109,6 +112,8 @@ BOOL CSmpackageApp::InitInstance() } } + FILEMAN = new RageFileManager( "" ); + // Show the Manager Dialog MainMenuDlg dlg; @@ -116,6 +121,9 @@ BOOL CSmpackageApp::InitInstance() // if (nResponse == IDOK) + SAFE_DELETE( FILEMAN ); + + // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; diff --git a/stepmania/src/smpackage/smpackage.rc b/stepmania/src/smpackage/smpackage.rc index 6bebdfc433..783e65f926 100644 --- a/stepmania/src/smpackage/smpackage.rc +++ b/stepmania/src/smpackage/smpackage.rc @@ -155,91 +155,38 @@ BEGIN IDC_STATIC,18,144,196,17 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 CAPTION "StepMania Tools Main Menu" FONT 8, "MS Sans Serif", 0, 0, 0x1 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 - GROUPBOX "Installations",IDC_STATIC,7,163,318,39 - PUSHBUTTON "Edit Installations",IDC_EDIT_INSTALLATIONS,16,178,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.", - IDC_STATIC,104,173,215,25 - GROUPBOX ".smzip Packages",IDC_STATIC,7,203,318,40 - PUSHBUTTON "Export Packages",IDC_EXPORT_PACKAGES,15,218,75,15 - 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.", - 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 + GROUPBOX "Installation",IDC_STATIC,7,41,318,28 + PUSHBUTTON "Edit Installations",IDC_EDIT_INSTALLATIONS,241,49,75,15 + GROUPBOX "Create and Share",IDC_STATIC,7,198,318,86 + PUSHBUTTON "Export Packages",IDC_EXPORT_PACKAGES,15,213,75,15 + LTEXT "Create .smzip package files to share with other users. Packages can contain songs, courses, themes, backgrounds, and more.", + IDC_STATIC,104,212,215,18 + PUSHBUTTON "Create Song",IDC_CREATE_SONG,15,260,75,15 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 - GROUPBOX "Preferences",IDC_STATIC,7,53,318,69 - PUSHBUTTON "Change Preferences",IDC_CHANGE_PREFERENCES,16,65,75,15 - PUSHBUTTON "Open Preferences",IDC_OPEN_PREFERENCES,16,101,75,15 + IDC_STATIC,103,259,215,20 + GROUPBOX "Game Settings",IDC_STATIC,7,109,318,87 + PUSHBUTTON "Change Preferences",IDC_CHANGE_PREFERENCES,16,120,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.", - IDC_STATIC,104,67,215,45 - PUSHBUTTON "Clear Preferences",IDC_CLEAR_PREFERENCES,16,83,75,15 - PUSHBUTTON "Clear Mappings",IDC_CLEAR_KEYMAPS,16,138,75,15 - RTEXT "Installation:",IDC_STATIC,37,42,63,9,0, - WS_EX_TRANSPARENT - EDITTEXT IDC_EDIT_INSTALLATION,105,40,220,12,ES_AUTOHSCROLL | + IDC_STATIC,104,123,215,45 + PUSHBUTTON "Clear Preferences",IDC_CLEAR_PREFERENCES,16,136,75,15 + PUSHBUTTON "Clear Mappings",IDC_CLEAR_KEYMAPS,16,175,75,15 + EDITTEXT IDC_EDIT_INSTALLATION,16,51,219,12,ES_AUTOHSCROLL | 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 mapping keys in the game and can't get back to change them.", - IDC_STATIC,104,133,214,25 - PUSHBUTTON "Launch Game",IDC_BUTTON_LAUNCH_GAME,189,324,70,14 -END - -IDD_CONVERT_THEME DIALOGEX 0, 0, 332, 258 -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 + LTEXT "Erase all of your keyboard and joystick mappings if you've made a mistake.", + IDC_STATIC,104,174,214,18 + PUSHBUTTON "Launch Game",IDC_BUTTON_LAUNCH_GAME,189,289,70,14 + PUSHBUTTON "View Statistics",IDC_VIEW_STATISTICS,16,85,75,15 + LTEXT "View high scores and usage statistics and other saved from your play.", + IDC_STATIC,103,84,215,20 + GROUPBOX "Statistics",IDC_STATIC,7,72,318,35 END IDD_ENTER_COMMENT DIALOGEX 0, 0, 312, 202 @@ -405,23 +352,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 325 TOPMARGIN, 7 - BOTTOMMARGIN, 338 - 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 + BOTTOMMARGIN, 303 END IDD_ENTER_COMMENT, DIALOG @@ -467,8 +398,6 @@ END INSTALL BITMAP "install.bmp" MANAGE BITMAP "manage.bmp" MENU BITMAP "menu.bmp" -EDIT_METRICS BITMAP "editmetrics.bmp" -CONVERTTHEME BITMAP "converttheme.bmp" #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/stepmania/src/smpackage/smpackageUtil.h b/stepmania/src/smpackage/smpackageUtil.h index df1b894785..b065f9eda9 100644 --- a/stepmania/src/smpackage/smpackageUtil.h +++ b/stepmania/src/smpackage/smpackageUtil.h @@ -1,24 +1,21 @@ -#ifndef SMPACKAGE_UTIL_H -#define SMPACKAGE_UTIL_H +#ifndef SMPackageUtil_H +#define SMPackageUtil_H -#include "RageUtil.h" -#include "../ProductInfo.h" +namespace SMPackageUtil +{ + void WriteStepManiaInstallDirs( const vector& asInstallDirsToWrite ); + void GetStepManiaInstallDirs( vector& asInstallDirsOut ); + void AddStepManiaInstallDir( RString sNewInstallDir ); + void SetDefaultInstallDir( int iInstallDirIndex ); + void SetDefaultInstallDir( RString sInstallDir ); -static const CString PREFERENCES_INI = "Save\\Preferences.ini"; -static const CString KEYMAPS_INI = "Save\\Keymaps.ini"; + bool GetPref( RString name, bool &val ); + bool SetPref( RString name, bool val ); -void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite ); -void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut ); -void AddStepManiaInstallDir( CString sNewInstallDir ); -void SetDefaultInstallDir( int iInstallDirIndex ); -void SetDefaultInstallDir( CString sInstallDir ); + RString GetPackageDirectory(RString path); + bool IsValidPackageDirectory(RString path); -bool GetPref( CString name, bool &val ); -bool SetPref( CString name, bool val ); - -CString GetPackageDirectory(CString path); -bool IsValidPackageDirectory(CString path); - -void LaunchGame(); + void LaunchGame(); +} #endif