|
From: Tapio V. <aa...@us...> - 2010-01-09 15:02:36
|
Module: performous
Branch: master
Commit: 4b0e6b2fee0c86ab8354fc9b58a54cecb636f8c7
Author: Tapio Vierros <tap...@gm...>
Date: Sat Jan 9 12:42:46 2010 +0200
Seek 30s in previews with only one music file.
---
game/screen_songs.cc | 8 ++++++--
game/song.cc | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/game/screen_songs.cc b/game/screen_songs.cc
index f2e39db..2f4996c 100644
--- a/game/screen_songs.cc
+++ b/game/screen_songs.cc
@@ -151,8 +151,12 @@ void ScreenSongs::stopMultimedia(ScreenSharedInfo& info) {
if (info.music != m_playing && m_playTimer.get() > 0.3) {
m_songbg.reset(); m_video.reset();
double pstart = 0;
- if (!m_songs.empty()) pstart = m_songs.current().preview_start;
- pstart = (pstart == pstart) ? std::min(pstart, 5.0) : 5.0; ///< this line is for performance (don't remove it unless you implement better seeking method in songs)
+ if (!m_songs.empty()) {
+ pstart = m_songs.current().preview_start;
+ if (pstart != pstart) pstart = 100; // true if NaN, 100 is caught in the next min
+ // 5.0s is for performance (don't make it higher unless you implement better seeking method in songs)
+ pstart = std::min(pstart, (info.music.size() == 1 ? 30.0 : 5.0)); // we can seek further in 1-track songs
+ }
if (info.music.empty()) m_audio.fadeout(1.0); else m_audio.playMusic(info.music, true, 2.0, (pstart ? pstart : 5.0));
if (!info.songbg.empty()) try { m_songbg.reset(new Surface(info.songbg)); } catch (std::exception const&) {}
if (!info.video.empty() && config["graphic/video"].b()) m_video.reset(new Video(info.video, info.videoGap));
diff --git a/game/song.cc b/game/song.cc
index 54665d7..c4227b9 100644
--- a/game/song.cc
+++ b/game/song.cc
@@ -28,7 +28,7 @@ void Song::reload(bool errorIgnore) {
noteMax = std::numeric_limits<int>::min();
videoGap = 0.0;
start = 0.0;
- preview_start = 0.0;
+ preview_start = getNaN();
beginTime = endTime = getNaN();
m_scoreFactor = 0.0;
try { SongParser(*this); } catch (...) { if (!errorIgnore) throw; }
|