Fix issue 2005: incorrect announcer sound files are played on the evaluation screen if the current theme doesn't have exactly 7 grade tiers.

This change maps the new grade tiers evenly to the 7 old grade tiers to trigger the correct sound files.
It also extends that mapping to the grade tiers used for playing cheering for the top few tiers.
This commit is contained in:
Richard Loxley
2020-06-04 16:40:28 +01:00
parent b3bd9a3117
commit 9ab72f4fb5
3 changed files with 13 additions and 2 deletions
+11 -1
View File
@@ -33,7 +33,7 @@ RString GradeToLocalizedString( Grade g )
RString GradeToOldString( Grade g )
{
// string is meant to be human readable
switch( g )
switch( GradeToOldGrade(g) )
{
case Grade_Tier01: return "AAAA";
case Grade_Tier02: return "AAA";
@@ -48,6 +48,16 @@ RString GradeToOldString( Grade g )
}
};
Grade GradeToOldGrade( Grade g )
{
// There used to be 7 grades (plus fail) but grades can now be defined by themes.
// So we need to re-scale the grade bands based on how many actual grades the theme defines.
if( g < NUM_GRADE_TIERS_USED )
g = (Grade)round((double)g * Grade_Tier07 / (NUM_GRADE_TIERS_USED - 1));
return g;
}
Grade StringToGrade( const RString &sGrade )
{
RString s = sGrade;
+1
View File
@@ -67,6 +67,7 @@ static inline RString GradeToString( Grade g )
* @param g the current Grade.
* @return the old styled grade string. */
RString GradeToOldString( Grade g );
Grade GradeToOldGrade( Grade g );
RString GradeToLocalizedString( Grade g );
/**
* @brief Convert the given RString into a proper Grade.
+1 -1
View File
@@ -709,7 +709,7 @@ void ScreenEvaluation::Init()
}
}
switch( best_grade )
switch( GradeToOldGrade(best_grade) )
{
case Grade_Tier01:
case Grade_Tier02: