|
From: Lasse Kärkkäi. <tr...@us...> - 2012-02-11 07:01:49
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Feb 11 05:52:08 2012 +0200
Cleanup: determine preview times in song parser rather than in song browser.
---
game/screen_songs.cc | 9 ++-------
game/songparser.cc | 2 ++
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/game/screen_songs.cc b/game/screen_songs.cc
index fc0c86e..bf8fa63 100644
--- a/game/screen_songs.cc
+++ b/game/screen_songs.cc
@@ -178,13 +178,8 @@ void ScreenSongs::stopMultimedia(ScreenSharedInfo& info) {
// Play/stop preview playback (if it is the time)
if (info.music != m_playing && m_playTimer.get() > 0.3) {
m_songbg.reset(); m_video.reset();
- double pstart = 0;
- if (!m_songs.empty() && !m_jukebox) {
- 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
- }
+ double pstart = 0.0; // Playback starting time
+ if (!m_songs.empty() && !m_jukebox) pstart = m_songs.current().preview_start; // In regular mode
if (info.music.empty()) m_audio.fadeout(1.0); else m_audio.playMusic(info.music, true, 2.0, pstart);
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/songparser.cc b/game/songparser.cc
index 7c63d39..d698b15 100644
--- a/game/songparser.cc
+++ b/game/songparser.cc
@@ -85,6 +85,8 @@ SongParser::SongParser(Song& s):
else if (type == INI) iniParseHeader();
else if (type == XML) xmlParseHeader();
else if (type == SM) { smParseHeader(); s.dropNotes(); } // Hack: drop notes here
+ // Default for preview position if none was specified in header
+ if (s.preview_start != s.preview_start) s.preview_start = (type == INI ? 5.0 : 30.0); // 5 s for band mode, 30 s for others
} catch (std::runtime_error& e) {
throw SongParserException(e.what(), m_linenum);
}
|