[loading window] Merge with default

This commit is contained in:
Henrik Andersson
2011-06-04 14:27:19 +02:00
7 changed files with 38 additions and 18 deletions
+1 -1
View File
@@ -832,7 +832,7 @@ void NoteField::DrawPrimitives()
//LOG->Trace( "start = %f.1, end = %f.1", fFirstBeatToDraw-fSongBeat, fLastBeatToDraw-fSongBeat ); //LOG->Trace( "start = %f.1, end = %f.1", fFirstBeatToDraw-fSongBeat, fLastBeatToDraw-fSongBeat );
//LOG->Trace( "Drawing elements %d through %d", iFirstRowToDraw, iLastRowToDraw ); //LOG->Trace( "Drawing elements %d through %d", iFirstRowToDraw, iLastRowToDraw );
#define IS_ON_SCREEN( fBeat ) IsOnScreen( fBeat, 0, iDrawDistanceAfterTargetsPixels, iDrawDistanceBeforeTargetsPixels ) #define IS_ON_SCREEN( fBeat ) ( fFirstBeatToDraw <= (fBeat) && (fBeat) <= fLastBeatToDraw && IsOnScreen( fBeat, 0, iDrawDistanceAfterTargetsPixels, iDrawDistanceBeforeTargetsPixels ) )
// Draw board // Draw board
if( SHOW_BOARD ) if( SHOW_BOARD )
+1 -1
View File
@@ -932,7 +932,7 @@ void SMLoader::TidyUpData( Song &song, bool bFromCache )
bg.push_back( BackgroundChange(song.m_fLastBeat,song.m_sBackgroundFile) ); bg.push_back( BackgroundChange(song.m_fLastBeat,song.m_sBackgroundFile) );
} while(0); } while(0);
} }
song.TidyUpData(); song.TidyUpData( bFromCache );
} }
/* /*
+12 -6
View File
@@ -236,9 +236,7 @@ bool Song::LoadFromSongDir( RString sDir )
{ {
// LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.c_str(), GetCacheFilePath().c_str() ); // LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.c_str(), GetCacheFilePath().c_str() );
bool bLoadedFromSSC = SSCLoader::LoadFromSSCFile( sCacheFilePath, *this, true ); bool bLoadedFromSSC = SSCLoader::LoadFromSSCFile( sCacheFilePath, *this, true );
if( bLoadedFromSSC ) if( !bLoadedFromSSC )
SSCLoader::TidyUpData( *this, true );
else
{ {
// load from .sm // load from .sm
SMLoader::LoadFromSMFile( sCacheFilePath, *this, true ); SMLoader::LoadFromSMFile( sCacheFilePath, *this, true );
@@ -390,7 +388,7 @@ void FixupPath( RString &path, const RString &sSongPath )
} }
// Songs in BlacklistImages will never be autodetected as song images. // Songs in BlacklistImages will never be autodetected as song images.
void Song::TidyUpData() void Song::TidyUpData( bool bFromCache )
{ {
// We need to do this before calling any of HasMusic, HasHasCDTitle, etc. // We need to do this before calling any of HasMusic, HasHasCDTitle, etc.
ASSERT_M( m_sSongDir.Left(3) != "../", m_sSongDir ); // meaningless ASSERT_M( m_sSongDir.Left(3) != "../", m_sSongDir ); // meaningless
@@ -481,7 +479,7 @@ void Song::TidyUpData()
/* Generate these before we autogen notes, so the new notes can inherit /* Generate these before we autogen notes, so the new notes can inherit
* their source's values. */ * their source's values. */
ReCalculateRadarValuesAndLastBeat(); ReCalculateRadarValuesAndLastBeat( bFromCache );
Trim( m_sMainTitle ); Trim( m_sMainTitle );
Trim( m_sSubTitle ); Trim( m_sSubTitle );
@@ -791,8 +789,16 @@ void Song::TranslateTitles()
title.SaveToStrings( m_sMainTitle, m_sSubTitle, m_sArtist, m_sMainTitleTranslit, m_sSubTitleTranslit, m_sArtistTranslit ); title.SaveToStrings( m_sMainTitle, m_sSubTitle, m_sArtist, m_sMainTitleTranslit, m_sSubTitleTranslit, m_sArtistTranslit );
} }
void Song::ReCalculateRadarValuesAndLastBeat() void Song::ReCalculateRadarValuesAndLastBeat( bool bFromCache )
{ {
if( bFromCache && m_fFirstBeat >= 0 && m_fLastBeat > 0 )
{
// this is loaded from cache, then we just have to calculate the radar values.
for( unsigned i=0; i<m_vpSteps.size(); i++ )
m_vpSteps[i]->CalculateRadarValues( m_fMusicLengthSeconds );
return;
}
float fFirstBeat = FLT_MAX; // inf float fFirstBeat = FLT_MAX; // inf
float fLastBeat = m_fSpecifiedLastBeat; // Make sure we're at least as long as the specified amount. float fLastBeat = m_fSpecifiedLastBeat; // Make sure we're at least as long as the specified amount.
+2 -2
View File
@@ -97,13 +97,13 @@ public:
bool ReloadFromSongDir( RString sDir ); bool ReloadFromSongDir( RString sDir );
/** @brief Call this after loading a song to clean up invalid data. */ /** @brief Call this after loading a song to clean up invalid data. */
void TidyUpData(); void TidyUpData( bool bFromCache = false );
/** /**
* @brief Get the new radar values, and determine the last beat at the same time. * @brief Get the new radar values, and determine the last beat at the same time.
* *
* This is called by TidyUpData, after saving the Song. */ * This is called by TidyUpData, after saving the Song. */
void ReCalculateRadarValuesAndLastBeat(); void ReCalculateRadarValuesAndLastBeat( bool bFromCache = false );
/** /**
* @brief Translate any titles that aren't in english. * @brief Translate any titles that aren't in english.
* *
+9 -1
View File
@@ -31,7 +31,8 @@ Steps::Steps(): m_StepsType(StepsType_Invalid),
m_sNoteDataCompressed(""), m_sFilename(""), m_bSavedToDisk(false), m_sNoteDataCompressed(""), m_sFilename(""), m_bSavedToDisk(false),
m_LoadedFromProfile(ProfileSlot_Invalid), m_iHash(0), m_LoadedFromProfile(ProfileSlot_Invalid), m_iHash(0),
m_sDescription(""), m_sChartStyle(""), m_sDescription(""), m_sChartStyle(""),
m_Difficulty(Difficulty_Invalid), m_iMeter(0), m_sCredit("") {} m_Difficulty(Difficulty_Invalid), m_iMeter(0), m_sCredit(""),
m_bAreCachedRadarValuesJustLoaded(false) {}
Steps::~Steps() Steps::~Steps()
{ {
@@ -171,6 +172,12 @@ void Steps::CalculateRadarValues( float fMusicLengthSeconds )
if( parent != NULL ) if( parent != NULL )
return; return;
if( m_bAreCachedRadarValuesJustLoaded )
{
m_bAreCachedRadarValuesJustLoaded = false;
return;
}
// Do write radar values, and leave it up to the reading app whether they want to trust // Do write radar values, and leave it up to the reading app whether they want to trust
// the cached values without recalculating them. // the cached values without recalculating them.
/* /*
@@ -422,6 +429,7 @@ void Steps::SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] )
{ {
DeAutogen(); DeAutogen();
copy( v, v + NUM_PLAYERS, m_CachedRadarValues ); copy( v, v + NUM_PLAYERS, m_CachedRadarValues );
m_bAreCachedRadarValuesJustLoaded = true;
} }
bool Steps::UsesSplitTiming() const bool Steps::UsesSplitTiming() const
+1
View File
@@ -180,6 +180,7 @@ private:
int m_iMeter; int m_iMeter;
/** @brief The radar values used for each player. */ /** @brief The radar values used for each player. */
RadarValues m_CachedRadarValues[NUM_PLAYERS]; RadarValues m_CachedRadarValues[NUM_PLAYERS];
bool m_bAreCachedRadarValuesJustLoaded;
/** @brief The name of the person who created the Steps. */ /** @brief The name of the person who created the Steps. */
RString m_sCredit; RString m_sCredit;
}; };
+12 -7
View File
@@ -1003,14 +1003,19 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
float TimingData::GetDisplayedBeat( float fBeat ) const float TimingData::GetDisplayedBeat( float fBeat ) const
{ {
unsigned index = GetScrollSegmentIndexAtBeat(fBeat); vector<ScrollSegment>::const_iterator it = m_ScrollSegments.begin(), end = m_ScrollSegments.end();
const ScrollSegment &s = m_ScrollSegments[index]; float fOutBeat = 0.0;
float fOutBeat = ( fBeat - s.GetBeat() ) * s.GetRatio(); for( ; it != end; it++ )
for( unsigned i = 0; i < index; i ++ )
{ {
const ScrollSegment &future = m_ScrollSegments[i+1]; if( it+1 == end || fBeat <= (it+1)->GetBeat() )
const ScrollSegment &current = m_ScrollSegments[i]; {
fOutBeat += ( future.GetBeat() - current.GetBeat() ) * current.GetRatio(); fOutBeat += ( fBeat - (it)->GetBeat() ) * (it)->GetRatio();
break;
}
else
{
fOutBeat += ( (it+1)->GetBeat() - (it)->GetBeat() ) * (it)->GetRatio();
}
} }
return fOutBeat; return fOutBeat;
} }