please use tabs

This commit is contained in:
AJ Kelly
2012-01-09 12:48:00 -06:00
parent cb25966cf5
commit ac49164f7e
+174 -174
View File
@@ -590,209 +590,209 @@ void Song::TidyUpData( bool fromCache, bool duringCache )
CHECKPOINT_M( "Looking for images..." ); CHECKPOINT_M( "Looking for images..." );
// HACK: DWI/KSF files require searching the file system for this info. // HACK: DWI/KSF files require searching the file system for this info.
RString extension = GetExtension(this->m_sSongFileName); RString extension = GetExtension(this->m_sSongFileName);
extension.MakeLower(); extension.MakeLower();
if( extension == "dwi" || extension == "ksf" || !fromCache ) if( extension == "dwi" || extension == "ksf" || !fromCache )
{ {
// First, check the file name for hints. // First, check the file name for hints.
if( !HasBanner() ) if( !HasBanner() )
{ {
/* If a nonexistant banner file is specified, and we can't find a /* If a nonexistant banner file is specified, and we can't find a
* replacement, don't wipe out the old value. */ * replacement, don't wipe out the old value. */
// m_sBannerFile = ""; // m_sBannerFile = "";
// find an image with "banner" in the file name // find an image with "banner" in the file name
vector<RString> arrayPossibleBanners; vector<RString> arrayPossibleBanners;
GetImageDirListing( m_sSongDir + "*banner*", arrayPossibleBanners ); GetImageDirListing( m_sSongDir + "*banner*", arrayPossibleBanners );
/* Some people do things differently for the sake of being different. /* Some people do things differently for the sake of being different.
* Don't match eg. abnormal, numbness. */ * Don't match eg. abnormal, numbness. */
GetImageDirListing( m_sSongDir + "* BN", arrayPossibleBanners ); GetImageDirListing( m_sSongDir + "* BN", arrayPossibleBanners );
if( !arrayPossibleBanners.empty() ) if( !arrayPossibleBanners.empty() )
m_sBannerFile = arrayPossibleBanners[0]; m_sBannerFile = arrayPossibleBanners[0];
} }
if( !HasBackground() ) if( !HasBackground() )
{ {
// m_sBackgroundFile = ""; // m_sBackgroundFile = "";
// find an image with "bg" or "background" in the file name // find an image with "bg" or "background" in the file name
vector<RString> arrayPossibleBGs; vector<RString> arrayPossibleBGs;
GetImageDirListing( m_sSongDir + "*background*", arrayPossibleBGs ); GetImageDirListing( m_sSongDir + "*background*", arrayPossibleBGs );
// don't match e.g. "subgroup", "hobgoblin", etc. // don't match e.g. "subgroup", "hobgoblin", etc.
GetImageDirListing( m_sSongDir + "*bg", arrayPossibleBGs ); GetImageDirListing( m_sSongDir + "*bg", arrayPossibleBGs );
if( !arrayPossibleBGs.empty() ) if( !arrayPossibleBGs.empty() )
m_sBackgroundFile = arrayPossibleBGs[0]; m_sBackgroundFile = arrayPossibleBGs[0];
} }
if( !HasJacket() ) if( !HasJacket() )
{ {
// find an image with "jacket" or "albumart" in the filename. // find an image with "jacket" or "albumart" in the filename.
vector<RString> arrayPossibleJackets; vector<RString> arrayPossibleJackets;
GetImageDirListing( m_sSongDir + "jk_*", arrayPossibleJackets ); GetImageDirListing( m_sSongDir + "jk_*", arrayPossibleJackets );
GetImageDirListing( m_sSongDir + "*jacket*", arrayPossibleJackets ); GetImageDirListing( m_sSongDir + "*jacket*", arrayPossibleJackets );
GetImageDirListing( m_sSongDir + "*albumart*", arrayPossibleJackets ); GetImageDirListing( m_sSongDir + "*albumart*", arrayPossibleJackets );
if( !arrayPossibleJackets.empty() ) if( !arrayPossibleJackets.empty() )
m_sJacketFile = arrayPossibleJackets[0]; m_sJacketFile = arrayPossibleJackets[0];
} }
if( !HasCDImage() ) if( !HasCDImage() )
{ {
// CD image, a la ddr 1st-3rd (not to be confused with CDTitles) // CD image, a la ddr 1st-3rd (not to be confused with CDTitles)
// find an image with "-cd" at the end of the filename. // find an image with "-cd" at the end of the filename.
vector<RString> arrayPossibleCDImages; vector<RString> arrayPossibleCDImages;
GetImageDirListing( m_sSongDir + "*-cd", arrayPossibleCDImages ); GetImageDirListing( m_sSongDir + "*-cd", arrayPossibleCDImages );
if( !arrayPossibleCDImages.empty() ) if( !arrayPossibleCDImages.empty() )
m_sCDFile = arrayPossibleCDImages[0]; m_sCDFile = arrayPossibleCDImages[0];
} }
if( !HasDisc() ) if( !HasDisc() )
{ {
// a rectangular graphic, not to be confused with CDImage above. // a rectangular graphic, not to be confused with CDImage above.
vector<RString> arrayPossibleDiscImages; vector<RString> arrayPossibleDiscImages;
GetImageDirListing( m_sSongDir + "* disc", arrayPossibleDiscImages ); GetImageDirListing( m_sSongDir + "* disc", arrayPossibleDiscImages );
GetImageDirListing( m_sSongDir + "* title", arrayPossibleDiscImages ); GetImageDirListing( m_sSongDir + "* title", arrayPossibleDiscImages );
if( !arrayPossibleDiscImages.empty() ) if( !arrayPossibleDiscImages.empty() )
m_sDiscFile = arrayPossibleDiscImages[0]; m_sDiscFile = arrayPossibleDiscImages[0];
} }
if( !HasCDTitle() ) if( !HasCDTitle() )
{ {
// find an image with "cdtitle" in the file name // find an image with "cdtitle" in the file name
vector<RString> arrayPossibleCDTitles; vector<RString> arrayPossibleCDTitles;
GetImageDirListing( m_sSongDir + "*cdtitle*", arrayPossibleCDTitles ); GetImageDirListing( m_sSongDir + "*cdtitle*", arrayPossibleCDTitles );
if( !arrayPossibleCDTitles.empty() ) if( !arrayPossibleCDTitles.empty() )
m_sCDTitleFile = arrayPossibleCDTitles[0]; m_sCDTitleFile = arrayPossibleCDTitles[0];
} }
if( !HasLyrics() ) if( !HasLyrics() )
{ {
// Check if there is a lyric file in here // Check if there is a lyric file in here
vector<RString> arrayLyricFiles; vector<RString> arrayLyricFiles;
GetDirListing(m_sSongDir + RString("*.lrc"), arrayLyricFiles ); GetDirListing(m_sSongDir + RString("*.lrc"), arrayLyricFiles );
if( !arrayLyricFiles.empty() ) if( !arrayLyricFiles.empty() )
m_sLyricsFile = arrayLyricFiles[0]; m_sLyricsFile = arrayLyricFiles[0];
} }
/* Now, For the images we still haven't found, /* Now, For the images we still haven't found,
* look at the image dimensions of the remaining unclassified images. */ * look at the image dimensions of the remaining unclassified images. */
vector<RString> arrayImages; vector<RString> arrayImages;
GetImageDirListing( m_sSongDir + "*", arrayImages ); GetImageDirListing( m_sSongDir + "*", arrayImages );
for( unsigned i=0; i<arrayImages.size(); i++ ) // foreach image for( unsigned i=0; i<arrayImages.size(); i++ ) // foreach image
{ {
if( HasBanner() && HasCDTitle() && HasBackground() ) if( HasBanner() && HasCDTitle() && HasBackground() )
break; // done break; // done
// ignore DWI "-char" graphics // ignore DWI "-char" graphics
RString sLower = arrayImages[i]; RString sLower = arrayImages[i];
sLower.MakeLower(); sLower.MakeLower();
if( BlacklistedImages.find(sLower) != BlacklistedImages.end() ) if( BlacklistedImages.find(sLower) != BlacklistedImages.end() )
continue; // skip continue; // skip
// Skip any image that we've already classified // Skip any image that we've already classified
if( HasBanner() && m_sBannerFile.EqualsNoCase(arrayImages[i]) ) if( HasBanner() && m_sBannerFile.EqualsNoCase(arrayImages[i]) )
continue; // skip continue; // skip
if( HasBackground() && m_sBackgroundFile.EqualsNoCase(arrayImages[i]) ) if( HasBackground() && m_sBackgroundFile.EqualsNoCase(arrayImages[i]) )
continue; // skip continue; // skip
if( HasCDTitle() && m_sCDTitleFile.EqualsNoCase(arrayImages[i]) ) if( HasCDTitle() && m_sCDTitleFile.EqualsNoCase(arrayImages[i]) )
continue; // skip continue; // skip
if( HasJacket() && m_sJacketFile.EqualsNoCase(arrayImages[i]) ) if( HasJacket() && m_sJacketFile.EqualsNoCase(arrayImages[i]) )
continue; // skip continue; // skip
if( HasDisc() && m_sDiscFile.EqualsNoCase(arrayImages[i]) ) if( HasDisc() && m_sDiscFile.EqualsNoCase(arrayImages[i]) )
continue; // skip continue; // skip
if( HasCDImage() && m_sCDFile.EqualsNoCase(arrayImages[i]) ) if( HasCDImage() && m_sCDFile.EqualsNoCase(arrayImages[i]) )
continue; // skip continue; // skip
RString sPath = m_sSongDir + arrayImages[i]; RString sPath = m_sSongDir + arrayImages[i];
// We only care about the dimensions. // We only care about the dimensions.
RString error; RString error;
RageSurface *img = RageSurfaceUtils::LoadFile( sPath, error, true ); RageSurface *img = RageSurfaceUtils::LoadFile( sPath, error, true );
if( !img ) if( !img )
{ {
LOG->UserLog( "Graphic file", sPath, "couldn't be loaded: %s", error.c_str() ); LOG->UserLog( "Graphic file", sPath, "couldn't be loaded: %s", error.c_str() );
continue; continue;
} }
const int width = img->w; const int width = img->w;
const int height = img->h; const int height = img->h;
delete img; delete img;
if( !HasBackground() && width >= 320 && height >= 240 ) if( !HasBackground() && width >= 320 && height >= 240 )
{ {
m_sBackgroundFile = arrayImages[i]; m_sBackgroundFile = arrayImages[i];
continue; continue;
} }
if( !HasBanner() && 100<=width && width<=320 && 50<=height && height<=240 ) if( !HasBanner() && 100<=width && width<=320 && 50<=height && height<=240 )
{ {
m_sBannerFile = arrayImages[i]; m_sBannerFile = arrayImages[i];
continue; continue;
} }
/* Some songs have overlarge banners. Check if the ratio is reasonable /* Some songs have overlarge banners. Check if the ratio is reasonable
* (over 2:1; usually over 3:1), and large (not a cdtitle). */ * (over 2:1; usually over 3:1), and large (not a cdtitle). */
if( !HasBanner() && width > 200 && float(width) / height > 2.0f ) if( !HasBanner() && width > 200 && float(width) / height > 2.0f )
{ {
m_sBannerFile = arrayImages[i]; m_sBannerFile = arrayImages[i];
continue; continue;
} }
/* Agh. DWI's inline title images are triggering this, resulting in /* Agh. DWI's inline title images are triggering this, resulting in
* kanji, etc., being used as a CDTitle for songs with none. Some * kanji, etc., being used as a CDTitle for songs with none. Some
* sample data from random incarnations: * sample data from random incarnations:
* 42x50 35x50 50x50 144x49 * 42x50 35x50 50x50 144x49
* It looks like ~50 height is what people use to align to DWI's font. * It looks like ~50 height is what people use to align to DWI's font.
* *
* My tallest CDTitle is 44. Let's cut off in the middle and hope for * My tallest CDTitle is 44. Let's cut off in the middle and hope for
* the best. -(who? -aj) */ * the best. -(who? -aj) */
/* The proper size of a CDTitle is 64x48 or sometihng. Simfile artists /* The proper size of a CDTitle is 64x48 or sometihng. Simfile artists
* typically don't give a shit about this (see Cetaka's fucking banner * typically don't give a shit about this (see Cetaka's fucking banner
* -sized CDTitle). This is also subverted in certain designs (beta * -sized CDTitle). This is also subverted in certain designs (beta
* Mungyodance 3 simfiles, for instance, used the CDTitle to hold * Mungyodance 3 simfiles, for instance, used the CDTitle to hold
* various information about the song in question). As it stands, * various information about the song in question). As it stands,
* I'm keeping this code until I figure out wtf to do -aj * I'm keeping this code until I figure out wtf to do -aj
*/ */
if( !HasCDTitle() && width<=100 && height<=48 ) if( !HasCDTitle() && width<=100 && height<=48 )
{ {
m_sCDTitleFile = arrayImages[i]; m_sCDTitleFile = arrayImages[i];
continue; continue;
} }
// Jacket files typically have the same width and height. // Jacket files typically have the same width and height.
if( !HasJacket() && width == height ) if( !HasJacket() && width == height )
{ {
m_sJacketFile = arrayImages[i]; m_sJacketFile = arrayImages[i];
continue; continue;
} }
// Disc images are typically rectangular; make sure we have a banner already. // Disc images are typically rectangular; make sure we have a banner already.
if( !HasDisc() && (width > height) && HasBanner() ) if( !HasDisc() && (width > height) && HasBanner() )
{ {
if( arrayImages[i] != m_sBannerFile ) if( arrayImages[i] != m_sBannerFile )
m_sDiscFile = arrayImages[i]; m_sDiscFile = arrayImages[i];
continue; continue;
} }
// CD images are the same as Jackets, typically the same width and height // CD images are the same as Jackets, typically the same width and height
if( !HasCDImage() && width == height ) if( !HasCDImage() && width == height )
{ {
m_sCDFile = arrayImages[i]; m_sCDFile = arrayImages[i];
continue; continue;
} }
} }
} }
// These will be written to cache, for Song::LoadFromSongDir to use later. // These will be written to cache, for Song::LoadFromSongDir to use later.
m_bHasMusic = HasMusic(); m_bHasMusic = HasMusic();
@@ -831,9 +831,9 @@ void Song::TidyUpData( bool fromCache, bool duringCache )
* for edits). We should be able to use difficulty names as unique * for edits). We should be able to use difficulty names as unique
* identifiers for steps. */ * identifiers for steps. */
if( !fromCache ) if( !fromCache )
{ {
SongUtil::AdjustDuplicateSteps( this ); SongUtil::AdjustDuplicateSteps( this );
} }
} }
void Song::TranslateTitles() void Song::TranslateTitles()
@@ -1329,8 +1329,8 @@ vector<RString> Song::GetInstrumentTracksToVectorString() const
if (this->HasInstrumentTrack(it)) if (this->HasInstrumentTrack(it))
{ {
ret.push_back(InstrumentTrackToString(it) ret.push_back(InstrumentTrackToString(it)
+ "=" + "="
+ this->m_sInstrumentTrackFile[it]); + this->m_sInstrumentTrackFile[it]);
} }
} }
return ret; return ret;