From ac49164f7e9ea29a3482e361f216cb2224bd3ad1 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 9 Jan 2012 12:48:00 -0600 Subject: [PATCH] please use tabs --- src/Song.cpp | 352 +++++++++++++++++++++++++-------------------------- 1 file changed, 176 insertions(+), 176 deletions(-) diff --git a/src/Song.cpp b/src/Song.cpp index 0af6bd2fb6..4f0c47b396 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -590,210 +590,210 @@ void Song::TidyUpData( bool fromCache, bool duringCache ) CHECKPOINT_M( "Looking for images..." ); // 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(); - - if( extension == "dwi" || extension == "ksf" || !fromCache ) - { - // First, check the file name for hints. - if( !HasBanner() ) - { - /* If a nonexistant banner file is specified, and we can't find a - * replacement, don't wipe out the old value. */ - // m_sBannerFile = ""; + if( extension == "dwi" || extension == "ksf" || !fromCache ) + { - // find an image with "banner" in the file name - vector arrayPossibleBanners; - GetImageDirListing( m_sSongDir + "*banner*", arrayPossibleBanners ); + // First, check the file name for hints. + if( !HasBanner() ) + { + /* If a nonexistant banner file is specified, and we can't find a + * replacement, don't wipe out the old value. */ + // m_sBannerFile = ""; - /* Some people do things differently for the sake of being different. - * Don't match eg. abnormal, numbness. */ - GetImageDirListing( m_sSongDir + "* BN", arrayPossibleBanners ); + // find an image with "banner" in the file name + vector arrayPossibleBanners; + GetImageDirListing( m_sSongDir + "*banner*", arrayPossibleBanners ); - if( !arrayPossibleBanners.empty() ) - m_sBannerFile = arrayPossibleBanners[0]; - } + /* Some people do things differently for the sake of being different. + * Don't match eg. abnormal, numbness. */ + GetImageDirListing( m_sSongDir + "* BN", arrayPossibleBanners ); - if( !HasBackground() ) - { - // m_sBackgroundFile = ""; + if( !arrayPossibleBanners.empty() ) + m_sBannerFile = arrayPossibleBanners[0]; + } - // find an image with "bg" or "background" in the file name - vector arrayPossibleBGs; - GetImageDirListing( m_sSongDir + "*background*", arrayPossibleBGs ); - // don't match e.g. "subgroup", "hobgoblin", etc. - GetImageDirListing( m_sSongDir + "*bg", arrayPossibleBGs ); - if( !arrayPossibleBGs.empty() ) - m_sBackgroundFile = arrayPossibleBGs[0]; - } + if( !HasBackground() ) + { + // m_sBackgroundFile = ""; - if( !HasJacket() ) - { - // find an image with "jacket" or "albumart" in the filename. - vector arrayPossibleJackets; - GetImageDirListing( m_sSongDir + "jk_*", arrayPossibleJackets ); - GetImageDirListing( m_sSongDir + "*jacket*", arrayPossibleJackets ); - GetImageDirListing( m_sSongDir + "*albumart*", arrayPossibleJackets ); - if( !arrayPossibleJackets.empty() ) - m_sJacketFile = arrayPossibleJackets[0]; - } + // find an image with "bg" or "background" in the file name + vector arrayPossibleBGs; + GetImageDirListing( m_sSongDir + "*background*", arrayPossibleBGs ); + // don't match e.g. "subgroup", "hobgoblin", etc. + GetImageDirListing( m_sSongDir + "*bg", arrayPossibleBGs ); + if( !arrayPossibleBGs.empty() ) + m_sBackgroundFile = arrayPossibleBGs[0]; + } - if( !HasCDImage() ) - { - // CD image, a la ddr 1st-3rd (not to be confused with CDTitles) - // find an image with "-cd" at the end of the filename. - vector arrayPossibleCDImages; - GetImageDirListing( m_sSongDir + "*-cd", arrayPossibleCDImages ); - if( !arrayPossibleCDImages.empty() ) - m_sCDFile = arrayPossibleCDImages[0]; - } + if( !HasJacket() ) + { + // find an image with "jacket" or "albumart" in the filename. + vector arrayPossibleJackets; + GetImageDirListing( m_sSongDir + "jk_*", arrayPossibleJackets ); + GetImageDirListing( m_sSongDir + "*jacket*", arrayPossibleJackets ); + GetImageDirListing( m_sSongDir + "*albumart*", arrayPossibleJackets ); + if( !arrayPossibleJackets.empty() ) + m_sJacketFile = arrayPossibleJackets[0]; + } - if( !HasDisc() ) - { - // a rectangular graphic, not to be confused with CDImage above. - vector arrayPossibleDiscImages; - GetImageDirListing( m_sSongDir + "* disc", arrayPossibleDiscImages ); - GetImageDirListing( m_sSongDir + "* title", arrayPossibleDiscImages ); - if( !arrayPossibleDiscImages.empty() ) - m_sDiscFile = arrayPossibleDiscImages[0]; - } + if( !HasCDImage() ) + { + // CD image, a la ddr 1st-3rd (not to be confused with CDTitles) + // find an image with "-cd" at the end of the filename. + vector arrayPossibleCDImages; + GetImageDirListing( m_sSongDir + "*-cd", arrayPossibleCDImages ); + if( !arrayPossibleCDImages.empty() ) + m_sCDFile = arrayPossibleCDImages[0]; + } - if( !HasCDTitle() ) - { - // find an image with "cdtitle" in the file name - vector arrayPossibleCDTitles; - GetImageDirListing( m_sSongDir + "*cdtitle*", arrayPossibleCDTitles ); - if( !arrayPossibleCDTitles.empty() ) - m_sCDTitleFile = arrayPossibleCDTitles[0]; - } + if( !HasDisc() ) + { + // a rectangular graphic, not to be confused with CDImage above. + vector arrayPossibleDiscImages; + GetImageDirListing( m_sSongDir + "* disc", arrayPossibleDiscImages ); + GetImageDirListing( m_sSongDir + "* title", arrayPossibleDiscImages ); + if( !arrayPossibleDiscImages.empty() ) + m_sDiscFile = arrayPossibleDiscImages[0]; + } - if( !HasLyrics() ) - { - // Check if there is a lyric file in here - vector arrayLyricFiles; - GetDirListing(m_sSongDir + RString("*.lrc"), arrayLyricFiles ); - if( !arrayLyricFiles.empty() ) - m_sLyricsFile = arrayLyricFiles[0]; - } + if( !HasCDTitle() ) + { + // find an image with "cdtitle" in the file name + vector arrayPossibleCDTitles; + GetImageDirListing( m_sSongDir + "*cdtitle*", arrayPossibleCDTitles ); + if( !arrayPossibleCDTitles.empty() ) + m_sCDTitleFile = arrayPossibleCDTitles[0]; + } - /* Now, For the images we still haven't found, - * look at the image dimensions of the remaining unclassified images. */ - vector arrayImages; - GetImageDirListing( m_sSongDir + "*", arrayImages ); + if( !HasLyrics() ) + { + // Check if there is a lyric file in here + vector arrayLyricFiles; + GetDirListing(m_sSongDir + RString("*.lrc"), arrayLyricFiles ); + if( !arrayLyricFiles.empty() ) + m_sLyricsFile = arrayLyricFiles[0]; + } - for( unsigned i=0; i arrayImages; + GetImageDirListing( m_sSongDir + "*", arrayImages ); - // ignore DWI "-char" graphics - RString sLower = arrayImages[i]; - sLower.MakeLower(); - if( BlacklistedImages.find(sLower) != BlacklistedImages.end() ) - continue; // skip + for( unsigned i=0; iUserLog( "Graphic file", sPath, "couldn't be loaded: %s", error.c_str() ); - continue; - } + RString sPath = m_sSongDir + arrayImages[i]; - const int width = img->w; - const int height = img->h; - delete img; + // We only care about the dimensions. + RString error; + RageSurface *img = RageSurfaceUtils::LoadFile( sPath, error, true ); + if( !img ) + { + LOG->UserLog( "Graphic file", sPath, "couldn't be loaded: %s", error.c_str() ); + continue; + } - if( !HasBackground() && width >= 320 && height >= 240 ) - { - m_sBackgroundFile = arrayImages[i]; - continue; - } + const int width = img->w; + const int height = img->h; + delete img; - if( !HasBanner() && 100<=width && width<=320 && 50<=height && height<=240 ) - { - m_sBannerFile = arrayImages[i]; - continue; - } + if( !HasBackground() && width >= 320 && height >= 240 ) + { + m_sBackgroundFile = arrayImages[i]; + continue; + } - /* Some songs have overlarge banners. Check if the ratio is reasonable - * (over 2:1; usually over 3:1), and large (not a cdtitle). */ - if( !HasBanner() && width > 200 && float(width) / height > 2.0f ) - { - m_sBannerFile = arrayImages[i]; - continue; - } + if( !HasBanner() && 100<=width && width<=320 && 50<=height && height<=240 ) + { + m_sBannerFile = arrayImages[i]; + continue; + } - /* Agh. DWI's inline title images are triggering this, resulting in - * kanji, etc., being used as a CDTitle for songs with none. Some - * sample data from random incarnations: - * 42x50 35x50 50x50 144x49 - * 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 - * the best. -(who? -aj) */ - /* 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 - * -sized CDTitle). This is also subverted in certain designs (beta - * Mungyodance 3 simfiles, for instance, used the CDTitle to hold - * various information about the song in question). As it stands, - * I'm keeping this code until I figure out wtf to do -aj - */ - if( !HasCDTitle() && width<=100 && height<=48 ) - { - m_sCDTitleFile = arrayImages[i]; - continue; - } + /* Some songs have overlarge banners. Check if the ratio is reasonable + * (over 2:1; usually over 3:1), and large (not a cdtitle). */ + if( !HasBanner() && width > 200 && float(width) / height > 2.0f ) + { + m_sBannerFile = arrayImages[i]; + continue; + } - // Jacket files typically have the same width and height. - if( !HasJacket() && width == height ) - { - m_sJacketFile = arrayImages[i]; - continue; - } + /* Agh. DWI's inline title images are triggering this, resulting in + * kanji, etc., being used as a CDTitle for songs with none. Some + * sample data from random incarnations: + * 42x50 35x50 50x50 144x49 + * 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 + * the best. -(who? -aj) */ + /* 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 + * -sized CDTitle). This is also subverted in certain designs (beta + * Mungyodance 3 simfiles, for instance, used the CDTitle to hold + * various information about the song in question). As it stands, + * I'm keeping this code until I figure out wtf to do -aj + */ + if( !HasCDTitle() && width<=100 && height<=48 ) + { + m_sCDTitleFile = arrayImages[i]; + continue; + } - // Disc images are typically rectangular; make sure we have a banner already. - if( !HasDisc() && (width > height) && HasBanner() ) - { - if( arrayImages[i] != m_sBannerFile ) - m_sDiscFile = arrayImages[i]; - continue; - } + // Jacket files typically have the same width and height. + if( !HasJacket() && width == height ) + { + m_sJacketFile = arrayImages[i]; + continue; + } - // CD images are the same as Jackets, typically the same width and height - if( !HasCDImage() && width == height ) - { - m_sCDFile = arrayImages[i]; - continue; - } - } + // Disc images are typically rectangular; make sure we have a banner already. + if( !HasDisc() && (width > height) && HasBanner() ) + { + if( arrayImages[i] != m_sBannerFile ) + m_sDiscFile = arrayImages[i]; + continue; + } - } - + // CD images are the same as Jackets, typically the same width and height + if( !HasCDImage() && width == height ) + { + m_sCDFile = arrayImages[i]; + continue; + } + } + + } + // These will be written to cache, for Song::LoadFromSongDir to use later. m_bHasMusic = HasMusic(); m_bHasBanner = HasBanner(); @@ -831,9 +831,9 @@ void Song::TidyUpData( bool fromCache, bool duringCache ) * for edits). We should be able to use difficulty names as unique * identifiers for steps. */ if( !fromCache ) - { - SongUtil::AdjustDuplicateSteps( this ); - } + { + SongUtil::AdjustDuplicateSteps( this ); + } } void Song::TranslateTitles() @@ -1329,8 +1329,8 @@ vector Song::GetInstrumentTracksToVectorString() const if (this->HasInstrumentTrack(it)) { ret.push_back(InstrumentTrackToString(it) - + "=" - + this->m_sInstrumentTrackFile[it]); + + "=" + + this->m_sInstrumentTrackFile[it]); } } return ret;