From 9cd3b4d4ba160425f4a665e79e75a535d865c5b9 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 20 Dec 2005 02:45:25 +0000 Subject: [PATCH] theme some common exception strings --- stepmania/src/RageSoundManager.cpp | 5 ++- stepmania/src/SongManager.cpp | 12 +++---- stepmania/src/StepMania.cpp | 32 +++++++++++++------ stepmania/src/Steps.cpp | 1 - .../src/arch/ArchHooks/ArchHooks_Unix.cpp | 3 +- .../LowLevelWindow/LowLevelWindow_X11.cpp | 3 +- stepmania/src/arch/arch.cpp | 13 +++++--- 7 files changed, 44 insertions(+), 25 deletions(-) diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index f58d63220b..1d3c6612e5 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -10,6 +10,7 @@ #include "RageTimer.h" #include "RageSoundReader_Preload.h" #include "Foreach.h" +#include "ThemeMetric.h" #include "arch/Sound/RageSoundDriver.h" @@ -35,11 +36,13 @@ RageSoundManager::RageSoundManager() m_bPlayOnlyCriticalSounds = false; } +static ThemeMetric COULDNT_FIND_SOUND_DRIVER( "RageSoundManager", "Couldn't find a sound driver that works" ); + void RageSoundManager::Init( CString sDrivers ) { m_pDriver = MakeRageSoundDriver( sDrivers ); if( m_pDriver == NULL ) - RageException::Throw( "Couldn't find a sound driver that works" ); + RageException::Throw( COULDNT_FIND_SOUND_DRIVER.GetValue() ); } RageSoundManager::~RageSoundManager() diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index a8e351ca15..e996fe1556 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -102,6 +102,9 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld ) LOG->Trace( "Found %d songs in %f seconds.", (int)m_pSongs.size(), tm.GetDeltaTime() ); } + +static ThemeMetric FOLDER_CONTAINS_MUSIC_FILES( "SongManager", "The folder '%s' appears to be a song folder. All song folders must reside in a group folder. For example, 'Songs/Originals/My Song'." ); + void SongManager::SanityCheckGroupDir( CString sDir ) const { // Check to see if they put a song directly inside the group folder. @@ -110,14 +113,7 @@ void SongManager::SanityCheckGroupDir( CString sDir ) const GetDirListing( sDir + "/*.ogg", arrayFiles ); GetDirListing( sDir + "/*.wav", arrayFiles ); if( !arrayFiles.empty() ) - RageException::Throw( - "The folder '%s' contains music files.\n\n" - "This means that you have a music outside of a song folder.\n" - "All song folders must reside in a group folder. For example, 'Songs/Originals/MySong'.\n" - "See the StepMania readme for more info.", - sDir.c_str() - ); - + RageException::Throw( FOLDER_CONTAINS_MUSIC_FILES.GetValue(), sDir.c_str() ); } void SongManager::AddGroup( CString sDir, CString sGroupDirName ) diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index b761504ee7..11b4b8e0c3 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -664,6 +664,13 @@ found_defaults: LOG->Info( "Video renderers: '%s'", PREFSMAN->m_sVideoRenderers.Get().c_str() ); } +static ThemeMetric ERROR_INITIALIZING_CARD ( "StepMania", "There was an error while initializing your video card." ); +static ThemeMetric ERROR_DONT_FILE_BUG ( "StepMania", "Please do not file this error as a bug! Use the web page below to troubleshoot this problem." ); +static ThemeMetric ERROR_VIDEO_DRIVER ( "StepMania", "Video Driver: %s" ); +static ThemeMetric ERROR_NO_VIDEO_RENDERERS ( "StepMania", "No video renderers attempted." ); +static ThemeMetric ERROR_INITIALIZING ( "StepMania", "Initializing %s..." ); +static ThemeMetric ERROR_UNKNOWN_VIDEO_RENDERER ( "StepMania", "Unknown video renderer value: %s" ); + RageDisplay *CreateDisplay() { /* We never want to bother users with having to decide which API to use. @@ -694,16 +701,16 @@ RageDisplay *CreateDisplay() VideoModeParams params; StepMania::GetPreferredVideoModeParams( params ); - CString error = "There was an error while initializing your video card.\n\n" - "Please do not file this error as a bug! Use the web page below to troubleshoot this problem.\n\n" - VIDEO_TROUBLESHOOTING_URL "\n\n" - "Video Driver: "+GetVideoDriverName()+"\n\n"; + CString error = ERROR_INITIALIZING_CARD.GetValue()+"\n\n"+ + ERROR_DONT_FILE_BUG.GetValue()+"\n\n" + VIDEO_TROUBLESHOOTING_URL "\n\n"+ + ssprintf(ERROR_VIDEO_DRIVER.GetValue(), GetVideoDriverName().c_str())+"\n\n"; vector asRenderers; split( PREFSMAN->m_sVideoRenderers, ",", asRenderers, true ); if( asRenderers.empty() ) - RageException::Throw("No video renderers attempted."); + RageException::Throw( ERROR_NO_VIDEO_RENDERERS.GetValue() ); for( unsigned i=0; iInit( params, PREFSMAN->m_bAllowUnacceleratedRenderer ); if( sError == "" ) return pRet; - error += "Initializing OpenGL...\n" + sError; + error += ssprintf(ERROR_INITIALIZING.GetValue(),"OpenGL")+"\n" + sError; delete pRet; #endif } @@ -727,14 +734,18 @@ RageDisplay *CreateDisplay() CString sError = pRet->Init( params ); if( sError == "" ) return pRet; - error += "Initializing Direct3D...\n" + sError; + error += ssprintf(ERROR_INITIALIZING.GetValue(),"Direct3D")+"\n" + sError; delete pRet; #endif } else if( sRenderer.CompareNoCase("null")==0 ) + { return new RageDisplay_Null( params ); + } else - RageException::Throw("Unknown video renderer value: %s", sRenderer.c_str() ); + { + RageException::Throw( ERROR_UNKNOWN_VIDEO_RENDERER.GetValue(), sRenderer.c_str() ); + } error += "\n\n\n"; } @@ -893,6 +904,9 @@ static void ApplyLogPreferences() Checkpoints::LogCheckpoints( PREFSMAN->m_bLogCheckpoints ); } +static ThemeMetric COULDNT_OPEN_LOADING_WINDOW( "StepMania", "Couldn't open any loading windows." ); + + #ifdef _XBOX void __cdecl main() #else @@ -997,7 +1011,7 @@ int main(int argc, char* argv[]) /* This requires PREFSMAN, for PREFSMAN->m_bShowLoadingWindow. */ LoadingWindow *loading_window = MakeLoadingWindow(); if( loading_window == NULL ) - RageException::Throw( "Couldn't open any loading windows." ); + RageException::Throw( COULDNT_OPEN_LOADING_WINDOW.GetValue() ); srand( time(NULL) ); // seed number generator diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index 20eed784da..4738130f99 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -20,7 +20,6 @@ #include "RageUtil.h" #include "RageLog.h" #include "NoteData.h" -#include "RageException.h" #include "GameManager.h" #include "NoteDataUtil.h" #include "NotesLoaderSM.h" diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp index ae7e3b282f..1a757b1d12 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Unix.cpp @@ -218,6 +218,7 @@ void ArchHooks_Unix::SetTime( tm newtime ) #include "RageFileManager.h" #include +static ThemeMetric COULDNT_FIND_SONGS( "ArchHooks_Unix", "Couldn't find 'Songs'" ); void ArchHooks_Unix::MountInitialFilesystems( const CString &sDirOfExecutable ) { #if defined(LINUX) @@ -258,7 +259,7 @@ void ArchHooks_Unix::MountInitialFilesystems( const CString &sDirOfExecutable ) if( Root == "" && !stat( RageFileManagerUtil::sInitialWorkingDirectory + "/Songs", &st ) && st.st_mode&S_IFDIR ) Root = RageFileManagerUtil::sInitialWorkingDirectory; if( Root == "" ) - RageException::Throw( "Couldn't find \"Songs\"" ); + RageException::Throw( COULDNT_FIND_SONGS ); FILEMAN->Mount( "dir", Root, "/" ); #else diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp index 03fcf5d87b..d2b4f9857c 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp @@ -19,11 +19,12 @@ #include #endif +static ThemeMetric FAILED_CONNECTION_XSERVER( "LowLevelWindow_X11", "Failed to establish a connection with the X server'" ); LowLevelWindow_X11::LowLevelWindow_X11() { m_bWindowIsOpen = false; if( !X11Helper::Go() ) - RageException::Throw( "Failed to establish a connection with the X server." ); + RageException::Throw( FAILED_CONNECTION_XSERVER ); const int iScreen = DefaultScreen( X11Helper::Dpy ); diff --git a/stepmania/src/arch/arch.cpp b/stepmania/src/arch/arch.cpp index 159b9fbe29..18f8d12aa7 100644 --- a/stepmania/src/arch/arch.cpp +++ b/stepmania/src/arch/arch.cpp @@ -9,15 +9,17 @@ #include "arch.h" #include "arch_platform.h" #include "Foreach.h" +#include "ThemeMetric.h" #include "InputHandler/Selector_InputHandler.h" +static ThemeMetric INPUT_HANDLERS_EMPTY( "Arch", "Input Handlers cannot be empty." ); void MakeInputHandlers(CString drivers, vector &Add) { vector DriversToTry; split(drivers, ",", DriversToTry, true); if( DriversToTry.empty() ) - RageException::Throw( "Input Handlers cannot be empty." ); + RageException::Throw( INPUT_HANDLERS_EMPTY.GetValue() ); CString Driver; @@ -177,6 +179,8 @@ MemoryCardDriver *MakeMemoryCardDriver() #include "MovieTexture/Selector_MovieTexture.h" static void DumpAVIDebugInfo( const CString& fn ); /* Try drivers in order of preference until we find one that works. */ +static ThemeMetric MOVIE_DRIVERS_EMPTY ( "Arch", "Movie Drivers cannot be empty." ); +static ThemeMetric COULDNT_CREATE_MOVIE_DRIVER( "Arch", "Couldn't create a movie driver." ); RageMovieTexture *MakeRageMovieTexture( RageTextureID ID ) { DumpAVIDebugInfo( ID.filename ); @@ -185,7 +189,7 @@ RageMovieTexture *MakeRageMovieTexture( RageTextureID ID ) split( PREFSMAN->GetMovieDrivers(), ",", DriversToTry, true ); if( DriversToTry.empty() ) - RageException::Throw( "Movie Drivers cannot be empty." ); + RageException::Throw( MOVIE_DRIVERS_EMPTY.GetValue() ); CString Driver; RageMovieTexture *ret = NULL; @@ -220,7 +224,7 @@ RageMovieTexture *MakeRageMovieTexture( RageTextureID ID ) } } if (!ret) - RageException::Throw("Couldn't create a movie texture"); + RageException::Throw( COULDNT_CREATE_MOVIE_DRIVER.GetValue() ); LOG->Trace("Created movie texture \"%s\" with driver \"%s\"", ID.filename.c_str(), Driver.c_str() ); @@ -228,13 +232,14 @@ RageMovieTexture *MakeRageMovieTexture( RageTextureID ID ) } #include "Sound/Selector_RageSoundDriver.h" +static ThemeMetric SOUND_DRIVERS_CANNOT_EMPTY( "Arch", "Sound Drivers cannot be empty." ); RageSoundDriver *MakeRageSoundDriver(CString drivers) { vector DriversToTry; split(drivers, ",", DriversToTry, true); if( DriversToTry.empty() ) - RageException::Throw( "Sound Drivers cannot be empty." ); + RageException::Throw( SOUND_DRIVERS_CANNOT_EMPTY.GetValue() ); CString Driver; RageSoundDriver *ret = NULL;