From 8f70dcf99bfb464523f308e6d0a11c5d94c96c9a Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 15 May 2011 03:18:34 -0500 Subject: [PATCH] move DwiCompatibleStringToDifficulty from Difficulty to NotesLoaderDWI; make .sm and .sm-derived formats use DifficultyToString since NotesWriterSM/SMA/SSC should be writing normalized strings --- src/Difficulty.cpp | 29 ----------------------------- src/Difficulty.h | 2 -- src/NotesLoaderDWI.cpp | 28 ++++++++++++++++++++++++++++ src/NotesLoaderSM.cpp | 2 +- src/NotesLoaderSMA.cpp | 2 +- src/NotesLoaderSSC.cpp | 4 ++-- 6 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/Difficulty.cpp b/src/Difficulty.cpp index 9e64fe665b..e37c5a4745 100644 --- a/src/Difficulty.cpp +++ b/src/Difficulty.cpp @@ -21,35 +21,6 @@ XToString( Difficulty ); StringToX( Difficulty ); LuaXType( Difficulty ); -/* We prefer the above names; recognize a number of others, too. (They'll get - * normalized when written to SMs, etc.) TODO: Format specific hacks should be - * moved into the file loader for that format. We don't want to carry these - * hacks forward to file formats that don't need them. */ -Difficulty DwiCompatibleStringToDifficulty( const RString& sDC ) -{ - RString s2 = sDC; - s2.MakeLower(); - if( s2 == "beginner" ) return Difficulty_Beginner; - else if( s2 == "easy" ) return Difficulty_Easy; - else if( s2 == "basic" ) return Difficulty_Easy; - else if( s2 == "light" ) return Difficulty_Easy; - else if( s2 == "medium" ) return Difficulty_Medium; - else if( s2 == "another" ) return Difficulty_Medium; - else if( s2 == "trick" ) return Difficulty_Medium; - else if( s2 == "standard" ) return Difficulty_Medium; - else if( s2 == "difficult") return Difficulty_Medium; - else if( s2 == "hard" ) return Difficulty_Hard; - else if( s2 == "ssr" ) return Difficulty_Hard; - else if( s2 == "maniac" ) return Difficulty_Hard; - else if( s2 == "heavy" ) return Difficulty_Hard; - else if( s2 == "smaniac" ) return Difficulty_Challenge; - else if( s2 == "challenge" ) return Difficulty_Challenge; - else if( s2 == "expert" ) return Difficulty_Challenge; - else if( s2 == "oni" ) return Difficulty_Challenge; - else if( s2 == "edit" ) return Difficulty_Edit; - else return Difficulty_Invalid; -} - const RString &CourseDifficultyToLocalizedString( CourseDifficulty x ) { static auto_ptr g_CourseDifficultyName[NUM_Difficulty]; diff --git a/src/Difficulty.h b/src/Difficulty.h index 48b97a6006..3c7896efd3 100644 --- a/src/Difficulty.h +++ b/src/Difficulty.h @@ -22,8 +22,6 @@ const RString& DifficultyToString( Difficulty dc ); Difficulty StringToDifficulty( const RString& sDC ); LuaDeclareType( Difficulty ); -Difficulty DwiCompatibleStringToDifficulty( const RString& sDC ); - typedef Difficulty CourseDifficulty; const int NUM_CourseDifficulty = NUM_Difficulty; /** @brief Loop through the shown course difficulties. */ diff --git a/src/NotesLoaderDWI.cpp b/src/NotesLoaderDWI.cpp index a822f50259..3bc992d1c5 100644 --- a/src/NotesLoaderDWI.cpp +++ b/src/NotesLoaderDWI.cpp @@ -10,6 +10,7 @@ #include "GameInput.h" #include "NotesLoader.h" #include "PrefsManager.h" +#include "Difficulty.h" #include @@ -140,6 +141,33 @@ static bool Is192( const RString &sStepData, size_t pos ) /** @brief All DWI files use 4 beats per measure. */ const int BEATS_PER_MEASURE = 4; +/* We prefer the normal names; recognize a number of others, too. (They'll get + * normalized when written to SMs, etc.) */ +Difficulty DwiCompatibleStringToDifficulty( const RString& sDC ) +{ + RString s2 = sDC; + s2.MakeLower(); + if( s2 == "beginner" ) return Difficulty_Beginner; + else if( s2 == "easy" ) return Difficulty_Easy; + else if( s2 == "basic" ) return Difficulty_Easy; + else if( s2 == "light" ) return Difficulty_Easy; + else if( s2 == "medium" ) return Difficulty_Medium; + else if( s2 == "another" ) return Difficulty_Medium; + else if( s2 == "trick" ) return Difficulty_Medium; + else if( s2 == "standard" ) return Difficulty_Medium; + else if( s2 == "difficult") return Difficulty_Medium; + else if( s2 == "hard" ) return Difficulty_Hard; + else if( s2 == "ssr" ) return Difficulty_Hard; + else if( s2 == "maniac" ) return Difficulty_Hard; + else if( s2 == "heavy" ) return Difficulty_Hard; + else if( s2 == "smaniac" ) return Difficulty_Challenge; + else if( s2 == "challenge" ) return Difficulty_Challenge; + else if( s2 == "expert" ) return Difficulty_Challenge; + else if( s2 == "oni" ) return Difficulty_Challenge; + else if( s2 == "edit" ) return Difficulty_Edit; + else return Difficulty_Invalid; +} + /** * @brief Look through the notes tag to extract the data. * @param sMode the steps type. diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index b8099a1e01..0369f60a0e 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -45,7 +45,7 @@ void SMLoader::LoadFromSMTokens( out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType ); out.SetDescription( sDescription ); out.SetCredit( sDescription ); // this is often used for both. - out.SetDifficulty( DwiCompatibleStringToDifficulty(sDifficulty) ); + out.SetDifficulty( StringToDifficulty(sDifficulty) ); // Handle hacks that originated back when StepMania didn't have // Difficulty_Challenge. (At least v1.64, possibly v3.0 final...) diff --git a/src/NotesLoaderSMA.cpp b/src/NotesLoaderSMA.cpp index dbb0089494..089e0705bb 100644 --- a/src/NotesLoaderSMA.cpp +++ b/src/NotesLoaderSMA.cpp @@ -42,7 +42,7 @@ void SMALoader::LoadFromSMATokens( out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType ); out.SetDescription( sDescription ); out.SetCredit( sDescription ); // this is often used for both. - out.SetDifficulty( DwiCompatibleStringToDifficulty(sDifficulty) ); + out.SetDifficulty( StringToDifficulty(sDifficulty) ); sDescription.MakeLower(); diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index 4e511c844a..217b31507a 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -709,7 +709,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach else if( sValueName=="DIFFICULTY" ) { - pNewNotes->SetDifficulty( DwiCompatibleStringToDifficulty( sParams[1] ) ); + pNewNotes->SetDifficulty( StringToDifficulty( sParams[1] ) ); } else if( sValueName=="METER" ) @@ -980,7 +980,7 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat else if( sValueName=="DIFFICULTY" ) { - pNewNotes->SetDifficulty( DwiCompatibleStringToDifficulty( sParams[1] ) ); + pNewNotes->SetDifficulty( StringToDifficulty( sParams[1] ) ); bSSCFormat = true; }