From 2b54f34c39bd3affeeb87d45d9cf62cb9a1b58a8 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 1 Mar 2005 15:22:15 +0000 Subject: [PATCH] cleanup --- stepmania/src/ScreenSystemLayer.cpp | 72 +++++++++++++++-------------- stepmania/src/ScreenSystemLayer.h | 2 +- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/stepmania/src/ScreenSystemLayer.cpp b/stepmania/src/ScreenSystemLayer.cpp index 4508c0b114..8256ad2da2 100644 --- a/stepmania/src/ScreenSystemLayer.cpp +++ b/stepmania/src/ScreenSystemLayer.cpp @@ -243,50 +243,51 @@ void ScreenSystemLayer::AddTimestampLine( const CString &txt, const RageColor &c m_LastSkip %= NUM_SKIPS_TO_SHOW; } -void ScreenSystemLayer::UpdateTimestampAndSkips() +void ScreenSystemLayer::UpdateSkips() { + if( !PREFSMAN->m_bTimestamping && !PREFSMAN->m_bLogSkips ) + return; + /* Use our own timer, so we ignore `/tab. */ const float UpdateTime = SkipTimer.GetDeltaTime(); /* FPS is 0 for a little while after we load a screen; don't report * during this time. Do clear the timer, though, so we don't report * a big "skip" after this period passes. */ - if(DISPLAY->GetFPS()) + if( !DISPLAY->GetFPS() ) + return; + + /* We want to display skips. We expect to get updates of about 1.0/FPS ms. */ + const float ExpectedUpdate = 1.0f / DISPLAY->GetFPS(); + + /* These are thresholds for severity of skips. The smallest + * is slightly above expected, to tolerate normal jitter. */ + const float Thresholds[] = { - /* We want to display skips. We expect to get updates of about 1.0/FPS ms. */ - const float ExpectedUpdate = 1.0f / DISPLAY->GetFPS(); - - /* These are thresholds for severity of skips. The smallest - * is slightly above expected, to tolerate normal jitter. */ - const float Thresholds[] = { - ExpectedUpdate * 2.0f, ExpectedUpdate * 4.0f, 0.1f, -1 + ExpectedUpdate * 2.0f, ExpectedUpdate * 4.0f, 0.1f, -1 + }; + + int skip = 0; + while( Thresholds[skip] != -1 && UpdateTime > Thresholds[skip] ) + skip++; + + if( skip ) + { + CString time(SecondsToMMSSMsMs(RageTimer::GetTimeSinceStart())); + + static const RageColor colors[] = + { + RageColor(0,0,0,0), /* unused */ + RageColor(0.2f,0.2f,1,1), /* light blue */ + RageColor(1,1,0,1), /* yellow */ + RageColor(1,0.2f,0.2f,1) /* light red */ }; - int skip = 0; - while(Thresholds[skip] != -1 && UpdateTime > Thresholds[skip]) - skip++; - - if(skip) - { - CString time(SecondsToMMSSMsMs(RageTimer::GetTimeSinceStart())); - - static const RageColor colors[] = { - RageColor(0,0,0,0), /* unused */ - RageColor(0.2f,0.2f,1,1), /* light blue */ - RageColor(1,1,0,1), /* yellow */ - RageColor(1,0.2f,0.2f,1) /* light red */ - }; - - if( PREFSMAN->m_bTimestamping ) - AddTimestampLine( ssprintf("%s: %.0fms (%.0f)", time.c_str(), 1000*UpdateTime, UpdateTime/ExpectedUpdate), - colors[skip] ); - if( PREFSMAN->m_bLogSkips ) - LOG->Trace( "Frame skip: %.0fms (%.0f)", 1000*UpdateTime, UpdateTime/ExpectedUpdate ); - } + if( PREFSMAN->m_bTimestamping ) + AddTimestampLine( ssprintf("%s: %.0fms (%.0f)", time.c_str(), 1000*UpdateTime, UpdateTime/ExpectedUpdate), colors[skip] ); + if( PREFSMAN->m_bLogSkips ) + LOG->Trace( "Frame skip: %.0fms (%.0f)", 1000*UpdateTime, UpdateTime/ExpectedUpdate ); } - - if( PREFSMAN->m_bTimestamping ) - m_textTime.SetText( SecondsToMMSSMsMs(RageTimer::GetTimeSinceStart()) ); } void ScreenSystemLayer::Update( float fDeltaTime ) @@ -303,7 +304,10 @@ void ScreenSystemLayer::Update( float fDeltaTime ) m_textStats.SetDiffuse( RageColor(1,1,1,0) ); /* hide */ } - UpdateTimestampAndSkips(); + UpdateSkips(); + + if( PREFSMAN->m_bTimestamping ) + m_textTime.SetText( SecondsToMMSSMsMs(RageTimer::GetTimeSinceStart()) ); } /* diff --git a/stepmania/src/ScreenSystemLayer.h b/stepmania/src/ScreenSystemLayer.h index e484b23510..7172a9fe2c 100644 --- a/stepmania/src/ScreenSystemLayer.h +++ b/stepmania/src/ScreenSystemLayer.h @@ -32,7 +32,7 @@ private: RageTimer SkipTimer; void AddTimestampLine( const CString &txt, const RageColor &color ); - void UpdateTimestampAndSkips(); + void UpdateSkips(); CString GetCreditsMessage( PlayerNumber pn ) const; ThemeMetric CREDITS_PRESS_START;