From d00063c067f6d642a9395d383f492f50fc5f0141 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 20 Jan 2006 23:38:17 +0000 Subject: [PATCH] name/tab/string cleanup --- stepmania/Themes/default/Languages/en.ini | 4 ++ stepmania/src/IniFile.cpp | 5 ++- stepmania/src/ProductInfo.h | 4 +- stepmania/src/smpackage/EditInsallations.cpp | 2 +- stepmania/src/smpackage/MainMenuDlg.cpp | 2 +- stepmania/src/smpackage/MainMenuDlg.h | 2 +- .../src/smpackage/SMPackageInstallDlg.cpp | 34 +++++++------- stepmania/src/smpackage/SMPackageUtil.cpp | 45 +++++++++---------- .../src/smpackage/SmpackageExportDlg.cpp | 4 +- stepmania/src/smpackage/smpackage.cpp | 2 +- stepmania/src/smpackage/smpackageUtil.h | 10 ++--- 11 files changed, 60 insertions(+), 54 deletions(-) diff --git a/stepmania/Themes/default/Languages/en.ini b/stepmania/Themes/default/Languages/en.ini index cb8eb7d784..58f06a01bb 100644 --- a/stepmania/Themes/default/Languages/en.ini +++ b/stepmania/Themes/default/Languages/en.ini @@ -8,6 +8,10 @@ Sound Drivers cannot be empty.=Sound Drivers cannot be empty. Couldn't find 'Songs'=Couldn't find 'Songs' [CSMPackageInstallDlg] +You have chosen to install the package:=You have chosen to install the package: +The package will be installed in the following program folder:=The package will be installed in the following program folder: +Installing '%s'. Please wait...=Installing '%s'. Please wait... +This package contains the following files:=This package contains the following files: '%s' is not a valid zip archive.='%s' is not a valid zip archive. Error copying file '%s'=Error copying file '%s' No Installations found. Exiting.=No Installations found. Exiting. diff --git a/stepmania/src/IniFile.cpp b/stepmania/src/IniFile.cpp index c3c94633bd..765e6c8055 100644 --- a/stepmania/src/IniFile.cpp +++ b/stepmania/src/IniFile.cpp @@ -81,8 +81,9 @@ bool IniFile::WriteFile( const RString &sPath ) const } bool bSuccess = IniFile::WriteFile( f ); - f.Close(); - return bSuccess && !f.GetError().empty(); + int iFlush = f.Flush(); + bSuccess &= (iFlush != -1); + return bSuccess; } bool IniFile::WriteFile( RageFileBasic &f ) const diff --git a/stepmania/src/ProductInfo.h b/stepmania/src/ProductInfo.h index e04b744d47..7cad8023e3 100644 --- a/stepmania/src/ProductInfo.h +++ b/stepmania/src/ProductInfo.h @@ -18,9 +18,9 @@ #define PRODUCT_XSTRINGIFY(x) PRODUCT_STRINGIFY(x) #define PRODUCT_NAME PRODUCT_XSTRINGIFY(PRODUCT_NAME_BARE) -#define PRODUCT_VER PRODUCT_XSTRINGIFY(PRODUCT_VER_BARE) +#define PRODUCT_VER PRODUCT_XSTRINGIFY(PRODUCT_VER_BARE) #define PRODUCT_NAME_VER PRODUCT_NAME " " PRODUCT_VER -#define PRODUCT_ID PRODUCT_XSTRINGIFY(PRODUCT_ID_BARE) +#define PRODUCT_ID PRODUCT_XSTRINGIFY(PRODUCT_ID_BARE) #define VIDEO_TROUBLESHOOTING_URL "http://www.stepmania.com/stepmania/mediawiki.php?title=Video_Driver_Troubleshooting" #define REPORT_BUG_URL "http://sourceforge.net/tracker/?func=add&group_id=37892&atid=421366" diff --git a/stepmania/src/smpackage/EditInsallations.cpp b/stepmania/src/smpackage/EditInsallations.cpp index d51053c1a2..5993644dff 100644 --- a/stepmania/src/smpackage/EditInsallations.cpp +++ b/stepmania/src/smpackage/EditInsallations.cpp @@ -60,7 +60,7 @@ BOOL EditInsallations::OnInitDialog() DialogUtil::LocalizeDialogAndContents( *this ); vector vs; - SMPackageUtil::GetStepManiaInstallDirs( vs ); + SMPackageUtil::GetGameInstallDirs( vs ); for( unsigned i=0; iSetWindowText( szCurDir ); - SMPackageUtil::AddStepManiaInstallDir( szCurDir ); + SMPackageUtil::AddGameInstallDir( szCurDir ); SMPackageUtil::SetDefaultInstallDir( szCurDir ); return TRUE; // return TRUE unless you set the focus to a control diff --git a/stepmania/src/smpackage/MainMenuDlg.h b/stepmania/src/smpackage/MainMenuDlg.h index 9e240a8ced..bcf0b55f27 100644 --- a/stepmania/src/smpackage/MainMenuDlg.h +++ b/stepmania/src/smpackage/MainMenuDlg.h @@ -40,7 +40,7 @@ protected: afx_msg void OnChangeApi(); afx_msg void OnCreateSong(); virtual BOOL OnInitDialog(); - afx_msg void OnOpenStepmaniaIni(); + afx_msg void OnOpenPreferencesIni(); afx_msg void OnBnClickedClearKeymaps(); afx_msg void OnBnClickedChangePreferences(); afx_msg void OnBnClickedOpenPreferences(); diff --git a/stepmania/src/smpackage/SMPackageInstallDlg.cpp b/stepmania/src/smpackage/SMPackageInstallDlg.cpp index ea004dbbfe..fef8b68512 100644 --- a/stepmania/src/smpackage/SMPackageInstallDlg.cpp +++ b/stepmania/src/smpackage/SMPackageInstallDlg.cpp @@ -70,7 +70,10 @@ static bool CompareStringNoCase( const RString &s1, const RString &s2 ) return s1.CompareNoCase( s2 ) < 0; } -static LocalizedString IS_NOT_A_VALID_ZIP( "CSMPackageInstallDlg", "'%s' is not a valid zip archive." ); +static LocalizedString IS_NOT_A_VALID_ZIP ( "CSMPackageInstallDlg", "'%s' is not a valid zip archive." ); +static LocalizedString YOU_HAVE_CHOSEN_TO_INSTALL ( "CSMPackageInstallDlg", "You have chosen to install the package:" ); +static LocalizedString THIS_PACKAGE_CONTAINS ( "CSMPackageInstallDlg", "This package contains the following files:" ); +static LocalizedString THE_PACKAGE_WILL_BE_INSTALLED ( "CSMPackageInstallDlg", "The package will be installed in the following program folder:" ); BOOL CSMPackageInstallDlg::OnInitDialog() { CDialog::OnInitDialog(); @@ -95,11 +98,11 @@ BOOL CSMPackageInstallDlg::OnInitDialog() // Set the text of the first Edit box // RString sMessage1 = ssprintf( - "You have chosen to install the Stepmania package:\r\n" + YOU_HAVE_CHOSEN_TO_INSTALL.GetValue()+"\r\n" "\r\n" "\t%s\r\n" - "\r\n" - "This package contains the following files:\r\n", + "\r\n" + + THIS_PACKAGE_CONTAINS.GetValue()+"\r\n", m_sPackagePath ); CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE1); @@ -121,7 +124,7 @@ BOOL CSMPackageInstallDlg::OnInitDialog() // // Set the text of the third Edit box // - RString sMessage3 = "The package will be installed in the following Stepmania program folder:\r\n"; + RString sMessage3 = THE_PACKAGE_WILL_BE_INSTALLED.GetValue()+"\r\n"; // Set the message CEdit* pEdit3 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE3); @@ -241,6 +244,7 @@ bool CSMPackageInstallDlg::CheckPackages() } static LocalizedString NO_INSTALLATIONS ("CSMPackageInstallDlg", "No Installations found. Exiting."); +static LocalizedString INSTALLING_PLEASE_WAIT ("CSMPackageInstallDlg", "Installing '%s'. Please wait..."); static LocalizedString ERROR_COPYING_FILE ("CSMPackageInstallDlg", "Error copying file '%s'"); static LocalizedString PACKAGE_INSTALLED_SUCCESSFULLY ("CSMPackageInstallDlg","Package installed successfully!"); void CSMPackageInstallDlg::OnOK() @@ -291,32 +295,32 @@ void CSMPackageInstallDlg::OnOK() return; // cancelled - // Unzip the SMzip package into the Stepmania installation folder + // Unzip the SMzip package into the installation folder vector vs; GetDirListingRecursive( TEMP_MOUNT_POINT, "*.*", vs ); for( unsigned i=0; iSetWindowText( ssprintf("Installing '%s'. Please wait...", m_sPackagePath) ); + pEdit1->SetWindowText( ssprintf(INSTALLING_PLEASE_WAIT.GetValue(), m_sPackagePath) ); CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2); pEdit2->SetWindowText( "" ); CEdit* pEdit3 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE3); pEdit3->SetWindowText( "" ); CProgressCtrl* pProgress1 = (CProgressCtrl*)GetDlgItem(IDC_PROGRESS1); //Show the hided progress bar - if(!pProgress1->IsWindowVisible()) - { + if(!pProgress1->IsWindowVisible()) + { pProgress1->ShowWindow(SW_SHOWNORMAL); - } + } //Initialize the progress bar and update the window 1 time (it's enough) - if(!ProgressInit) + if(!ProgressInit) { pProgress1->SetRange( 0, (short)vs.size() ); - pProgress1->SetStep(1); + pProgress1->SetStep(1); pProgress1->SetPos(0); SendMessage( WM_PAINT ); - UpdateWindow(); // Force the silly thing to hadle WM_PAINT now! + UpdateWindow(); // Force the silly thing to hadle WM_PAINT now! ProgressInit = 1; } @@ -365,7 +369,7 @@ void CSMPackageInstallDlg::OnButtonEdit() int nResponse = dlg.DoModal(); if( nResponse == IDOK ) { - SMPackageUtil::WriteStepManiaInstallDirs( dlg.m_vsReturnedInstallDirs ); + SMPackageUtil::WriteGameInstallDirs( dlg.m_vsReturnedInstallDirs ); RefreshInstallationList(); } } @@ -376,7 +380,7 @@ void CSMPackageInstallDlg::RefreshInstallationList() m_comboDir.ResetContent(); vector asInstallDirs; - SMPackageUtil::GetStepManiaInstallDirs( asInstallDirs ); + SMPackageUtil::GetGameInstallDirs( asInstallDirs ); for( unsigned i=0; i& asInstallDirsToWrite ) +static const RString SMPACKAGE_KEY = "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage"; +static const RString INSTALLATIONS_KEY = "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage\\Installations"; + +void SMPackageUtil::WriteGameInstallDirs( const vector& asInstallDirsToWrite ) { - RString sKey = "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage\\Installations"; - - unsigned i; - - for( i=0; i<100; i++ ) + for( unsigned i=0; i<100; i++ ) { RString sName = ssprintf("%d",i); // Reg.DeleteKey( sName ); // delete key is broken in this library, so just write over it with "" - RegistryAccess::SetRegValue( sKey, sName, RString() ); + RegistryAccess::SetRegValue( INSTALLATIONS_KEY, sName, RString() ); } - for( i=0; i& asInstallDirsOut ) +void SMPackageUtil::GetGameInstallDirs( vector& asInstallDirsOut ) { asInstallDirsOut.clear(); - RString sKey = "HKEY_LOCAL_MACHINE\\Software\\StepMania\\smpackage\\Installations"; - for( int i=0; i<100; i++ ) { RString sName = ssprintf("%d",i); RString sPath; - if( !RegistryAccess::GetRegValue(sKey, sName, sPath) ) + if( !RegistryAccess::GetRegValue(INSTALLATIONS_KEY, sName, sPath) ) continue; if( sPath == "" ) // read failed @@ -55,13 +52,13 @@ void SMPackageUtil::GetStepManiaInstallDirs( vector& asInstallDirsOut ) } // while we're at it, write to clean up stale entries - WriteStepManiaInstallDirs( asInstallDirsOut ); + WriteGameInstallDirs( asInstallDirsOut ); } -void SMPackageUtil::AddStepManiaInstallDir( RString sNewInstallDir ) +void SMPackageUtil::AddGameInstallDir( RString sNewInstallDir ) { vector asInstallDirs; - GetStepManiaInstallDirs( asInstallDirs ); + GetGameInstallDirs( asInstallDirs ); bool bAlreadyInList = false; for( unsigned i=0; i asInstallDirs; - GetStepManiaInstallDirs( asInstallDirs ); + GetGameInstallDirs( asInstallDirs ); ASSERT( iInstallDirIndex >= 0 && iInstallDirIndex < (int)asInstallDirs.size() ); RString sDefaultInstallDir = asInstallDirs[iInstallDirIndex]; asInstallDirs.erase( asInstallDirs.begin()+iInstallDirIndex ); asInstallDirs.insert( asInstallDirs.begin(), sDefaultInstallDir ); - WriteStepManiaInstallDirs( asInstallDirs ); + WriteGameInstallDirs( asInstallDirs ); } void SMPackageUtil::SetDefaultInstallDir( RString sInstallDir ) { vector asInstallDirs; - GetStepManiaInstallDirs( asInstallDirs ); + GetGameInstallDirs( asInstallDirs ); for( unsigned i=0; i asInstallDirs; - SMPackageUtil::GetStepManiaInstallDirs( asInstallDirs ); + SMPackageUtil::GetGameInstallDirs( asInstallDirs ); for( unsigned i=0; i& asInstallDirsToWrite ); - void GetStepManiaInstallDirs( vector& asInstallDirsOut ); - void AddStepManiaInstallDir( RString sNewInstallDir ); + void WriteGameInstallDirs( const vector& asInstallDirsToWrite ); + void GetGameInstallDirs( vector& asInstallDirsOut ); + void AddGameInstallDir( RString sNewInstallDir ); void SetDefaultInstallDir( int iInstallDirIndex ); void SetDefaultInstallDir( RString sInstallDir ); - bool GetPref( RString name, bool &val ); - bool SetPref( RString name, bool val ); + bool GetPref( const RString &name, bool &val ); + bool SetPref( const RString &name, bool val ); RString GetPackageDirectory(RString path); bool IsValidPackageDirectory(RString path);