more transparent m_DWIPath

This commit is contained in:
Glenn Maynard
2003-12-05 04:38:22 +00:00
parent a279bd3c15
commit fafa38c62c
3 changed files with 10 additions and 44 deletions
+9 -37
View File
@@ -594,6 +594,12 @@ static bool ImageIsLoadable( const CString &sPath )
/* Songs in BlacklistImages will never be autodetected as song images. */
void Song::TidyUpData()
{
m_sSongDir.Replace( '\\', '/' );
m_sBannerFile.Replace( '\\', '/' );
m_sLyricsFile.Replace( '\\', '/' );
m_sBackgroundFile.Replace( '\\', '/' );
m_sCDTitleFile.Replace( '\\', '/' );
if( !HasMusic() )
{
CStringArray arrayPossibleMusic;
@@ -1530,33 +1536,8 @@ int Song::GetNumTimesPlayed( MemoryCard card ) const
return iTotalNumTimesPlayed;
}
/* Search semantics for all song files:
*
* If the path doesn't have any directory separators, it's a filename in the
* song directory.
*
* If it does, it's relative to the top directory of the tree it was loaded
* from, eg ".\music\stuff\song.ogg". Most of the time, that's the SM tree,
* and that's the PWD, so just return it directly. If the file was originally
* loaded from the DWIPath, it's relative to that, so prepend it.
*
* Some DWI's do have relative paths that don't start with ".\".
*/
/* We only follow this for song files and cdtitles; it's for compatibility
* with DWI. We prefer paths relative to the song directory; only support
* that for all other paths. */
/* Note: Prepending the dwipath is ugly. The first impression might be to
* add a Song::TopFilePath, but don't do that--we have too much stuff in there
* already. We don't really need it; this is the only place it'd be used. What
* we *should* be doing is prepending this path when we first load the song.
* However, dwipaths are usually like "c:\games\dwi", and we can't store colons
* in SM's; they'll get interpreted as delimiters. So:
* XXX: Add some kind of escape character to SM's.
*
* -glenn */
/* Note that supplying a path relative to the top-level directory is only for compatibility
* with DWI. We prefer paths relative to the song directory. */
CString Song::GetMusicPath() const
{
/* If there's no path in the music file, the file is in the same directory
@@ -1564,11 +1545,6 @@ CString Song::GetMusicPath() const
if( m_sMusicFile.Find(SLASH[0]) == -1)
return m_sSongDir+m_sMusicFile;
/* The file has a path. If it was loaded from the m_DWIPath, it's relative
* to that. */
if( PREFSMAN->m_DWIPath!="" && m_sSongDir.Left(PREFSMAN->m_DWIPath.GetLength()) == PREFSMAN->m_DWIPath )
return PREFSMAN->m_DWIPath+SLASH+m_sMusicFile;
/* Otherwise, it's relative to the top of the SM directory (the CWD), so
* return it directly. */
return m_sMusicFile;
@@ -1590,12 +1566,8 @@ CString Song::GetLyricsPath() const
CString Song::GetCDTitlePath() const
{
if( m_sCDTitleFile.Find('/') == -1)
if( m_sCDTitleFile.Find(SLASH[0]) != -1 )
return m_sSongDir+m_sCDTitleFile;
if( PREFSMAN->m_DWIPath!="" && m_sSongDir.Left(PREFSMAN->m_DWIPath.GetLength()) == PREFSMAN->m_DWIPath )
return PREFSMAN->m_DWIPath+SLASH+m_sCDTitleFile;
return m_sCDTitleFile;
}
-7
View File
@@ -146,10 +146,6 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld )
{
RageTimer tm;
LoadStepManiaSongDir( SONGS_DIR, ld );
if( PREFSMAN->m_DWIPath != "" )
LoadStepManiaSongDir( PREFSMAN->m_DWIPath + "/Songs", ld );
LOG->Trace( "Found %d songs in %f seconds.", (int)m_pSongs.size(), tm.GetDeltaTime() );
}
@@ -1145,9 +1141,6 @@ bool SongManager::GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredG
const CString sCourseSuffix = sPreferredGroup + SLASH + (bExtra2 ? "extra2" : "extra1") + ".crs";
CString sCoursePath = SONGS_DIR + sCourseSuffix;
if( !DoesFileExist(sCoursePath) && PREFSMAN->m_DWIPath.size() )
sCoursePath = PREFSMAN->m_DWIPath + SLASH "Songs" SLASH + sCourseSuffix;
/* Couldn't find course in DWI path or alternative song folders */
if( !DoesFileExist(sCoursePath) )
return false;
+1
View File
@@ -828,6 +828,7 @@ int main(int argc, char* argv[])
/* Set up alternative filesystem trees. */
for( unsigned i=0; i<PREFSMAN->m_asAdditionalSongFolders.size(); i++ )
FILEMAN->Mount( "dir", PREFSMAN->m_asAdditionalSongFolders[i], "Songs" );
FILEMAN->Mount( "dir", PREFSMAN->m_DWIPath, "" );
GAMEMAN = new GameManager;
THEME = new ThemeManager;