From 01c6c1679ef892dc6970bf947e73c30b8142fd36 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 21 Aug 2011 19:03:19 -0500 Subject: [PATCH] [Song] Added Jacket, CD image (a la early DDR), and Disc (PIU-style) support. Added GetJacketPath(), GetCDImagePath(), GetDiscPath(), HasJacket(), HasDisc(), and HasCDImage() Lua bindings. --- Docs/Changelog_sm5.txt | 4 +- src/Song.cpp | 157 ++++++++++++++++++++++++++++------------- src/Song.h | 18 ++--- 3 files changed, 120 insertions(+), 59 deletions(-) diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 2d9954e130..883038a6f6 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -5,13 +5,15 @@ from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt. ________________________________________________________________________________ ================================================================================ -StepMania 5.0 ????????? | 2011???? +StepMania 5.0 $next | 2011???? -------------------------------------------------------------------------------- 2011/08/21 ---------- * [NotesLoaderSSC] Fix loading pre-split timing files that had blank timing tags inside of them. Thanks to Vin.il for the catch. [Wolfman2000] +* [Song] Added Jacket, CD image (a la early DDR), and Disc (PIU-style) support. + Added GetJacketPath(), GetCDImagePath(), GetDiscPath(), [AJ] ================================================================================ StepMania 5.0 Preview 3 | 20110820 diff --git a/src/Song.cpp b/src/Song.cpp index 37de1819eb..675ffa485d 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -458,8 +458,9 @@ void Song::TidyUpData( bool fromCache, bool duringCache ) if( !m_sInstrumentTrackFile[i].empty() ) FixupPath( m_sInstrumentTrackFile[i], m_sSongDir ); FixupPath( m_sBannerFile, m_sSongDir ); - //FixupPath( m_sJacketFile, m_sSongDir ); - //FixupPath( m_sDiscFile, m_sSongDir ); + FixupPath( m_sJacketFile, m_sSongDir ); + FixupPath( m_sCDFile, m_sSongDir ); + FixupPath( m_sDiscFile, m_sSongDir ); FixupPath( m_sLyricsFile, m_sSongDir ); FixupPath( m_sBackgroundFile, m_sSongDir ); FixupPath( m_sCDTitleFile, m_sSongDir ); @@ -618,7 +619,6 @@ void Song::TidyUpData( bool fromCache, bool duringCache ) m_sBackgroundFile = arrayPossibleBGs[0]; } - /* if( !HasJacket() ) { // find an image with "jacket" or "albumart" in the filename. @@ -629,26 +629,26 @@ void Song::TidyUpData( bool fromCache, bool duringCache ) if( !arrayPossibleJackets.empty() ) m_sJacketFile = arrayPossibleJackets[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. + // find an image with "-cd" at the end of the filename. vector arrayPossibleCDImages; - GetImageDirListing( m_sSongDir + "* CD", arrayPossibleCDImages ); + GetImageDirListing( m_sSongDir + "*-cd", arrayPossibleCDImages ); if( !arrayPossibleCDImages.empty() ) m_sCDFile = arrayPossibleCDImages[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( !HasCDTitle() ) { @@ -695,7 +695,14 @@ void Song::TidyUpData( bool fromCache, bool duringCache ) if( HasCDTitle() && m_sCDTitleFile.EqualsNoCase(arrayImages[i]) ) continue; // skip - // todo: add checks for Jacket, Disc, and CDImage -aj + if( HasJacket() && m_sJacketFile.EqualsNoCase(arrayImages[i]) ) + continue; // skip + + if( HasDisc() && m_sDiscFile.EqualsNoCase(arrayImages[i]) ) + continue; // skip + + if( HasCDImage() && m_sCDFile.EqualsNoCase(arrayImages[i]) ) + continue; // skip RString sPath = m_sSongDir + arrayImages[i]; @@ -753,7 +760,27 @@ void Song::TidyUpData( bool fromCache, bool duringCache ) continue; } - // todo: add checks for Jacket, Disc, and CDImage -aj + // Jacket files typically have the same width and height. + if( !HasJacket() && width == height ) + { + m_sJacketFile = 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. @@ -1230,7 +1257,18 @@ bool Song::HasBGChanges() const return false; } bool Song::HasAttacks() const {return !m_Attacks.empty(); } -// todo: add checks for Jacket, Disc, and CDImage -aj +bool Song::HasJacket() const +{ + return m_sJacketFile != "" && IsAFile(GetJacketPath()); +} +bool Song::HasDisc() const +{ + return m_sDiscFile != "" && IsAFile(GetDiscPath()); +} +bool Song::HasCDImage() const +{ + return m_sCDFile != "" && IsAFile(GetCDImagePath()); +} const vector &Song::GetBackgroundChanges( BackgroundLayer bl ) const { @@ -1349,7 +1387,20 @@ RString Song::GetBackgroundPath() const return GetSongAssetPath( m_sBackgroundFile, m_sSongDir ); } -// todo: add checks for Jacket, Disc, and CDImage -aj +RString Song::GetJacketPath() const +{ + return GetSongAssetPath( m_sJacketFile, m_sSongDir ); +} + +RString Song::GetDiscPath() const +{ + return GetSongAssetPath( m_sDiscFile, m_sSongDir ); +} + +RString Song::GetCDImagePath() const +{ + return GetSongAssetPath( m_sCDFile, m_sSongDir ); +} RString Song::GetDisplayMainTitle() const { @@ -1640,6 +1691,33 @@ public: lua_pushnil(L); return 1; } + static int GetJacketPath( T* p, lua_State *L ) + { + RString s = p->GetJacketPath(); + if( !s.empty() ) + lua_pushstring(L, s); + else + lua_pushnil(L); + return 1; + } + static int GetCDImagePath( T* p, lua_State *L ) + { + RString s = p->GetCDImagePath(); + if( !s.empty() ) + lua_pushstring(L, s); + else + lua_pushnil(L); + return 1; + } + static int GetDiscPath( T* p, lua_State *L ) + { + RString s = p->GetDiscPath(); + if( !s.empty() ) + lua_pushstring(L, s); + else + lua_pushnil(L); + return 1; + } static int GetCDTitlePath( T* p, lua_State *L ) { RString s = p->GetCDTitlePath(); @@ -1719,42 +1797,17 @@ public: lua_pushnil(L); return 1; } - static int GetTimingData( T* p, lua_State *L ) - { - p->m_SongTiming.PushSelf(L); - return 1; - } + static int GetTimingData( T* p, lua_State *L ) { p->m_SongTiming.PushSelf(L); return 1; } // has functions - static int HasMusic( T* p, lua_State *L ) - { - lua_pushboolean(L, p->HasMusic()); - return 1; - } - static int HasBanner( T* p, lua_State *L ) - { - lua_pushboolean(L, p->HasBanner()); - return 1; - } - static int HasBackground( T* p, lua_State *L ) - { - lua_pushboolean(L, p->HasBackground()); - return 1; - } - static int HasCDTitle( T* p, lua_State *L ) - { - lua_pushboolean(L, p->HasCDTitle()); - return 1; - } - static int HasBGChanges( T* p, lua_State *L ) - { - lua_pushboolean(L, p->HasBGChanges()); - return 1; - } - static int HasLyrics( T* p, lua_State *L ) - { - lua_pushboolean(L, p->HasLyrics()); - return 1; - } + static int HasMusic( T* p, lua_State *L ) { lua_pushboolean(L, p->HasMusic()); return 1; } + static int HasBanner( T* p, lua_State *L ) { lua_pushboolean(L, p->HasBanner()); return 1; } + static int HasBackground( T* p, lua_State *L ) { lua_pushboolean(L, p->HasBackground()); return 1; } + static int HasJacket( T* p, lua_State *L ) { lua_pushboolean(L, p->HasJacket()); return 1; } + static int HasDisc( T* p, lua_State *L ) { lua_pushboolean(L, p->HasDisc()); return 1; } + static int HasCDImage( T* p, lua_State *L ) { lua_pushboolean(L, p->HasCDImage()); return 1; } + static int HasCDTitle( T* p, lua_State *L ) { lua_pushboolean(L, p->HasCDTitle()); return 1; } + static int HasBGChanges( T* p, lua_State *L ) { lua_pushboolean(L, p->HasBGChanges()); return 1; } + static int HasLyrics( T* p, lua_State *L ) { lua_pushboolean(L, p->HasLyrics()); return 1; } // functions that AJ loves static int HasSignificantBPMChangesOrStops( T* p, lua_State *L ) { @@ -1863,6 +1916,9 @@ public: ADD_METHOD( GetMusicPath ); ADD_METHOD( GetBannerPath ); ADD_METHOD( GetBackgroundPath ); + ADD_METHOD( GetJacketPath ); + ADD_METHOD( GetCDImagePath ); + ADD_METHOD( GetDiscPath ); ADD_METHOD( GetCDTitlePath ); ADD_METHOD( GetLyricsPath ); ADD_METHOD( GetSongFilePath ); @@ -1879,6 +1935,9 @@ public: ADD_METHOD( HasMusic ); ADD_METHOD( HasBanner ); ADD_METHOD( HasBackground ); + ADD_METHOD( HasJacket ); + ADD_METHOD( HasCDImage ); + ADD_METHOD( HasDisc ); ADD_METHOD( HasCDTitle ); ADD_METHOD( HasBGChanges ); ADD_METHOD( HasLyrics ); diff --git a/src/Song.h b/src/Song.h index ccb51649ef..9916f6fe77 100644 --- a/src/Song.h +++ b/src/Song.h @@ -231,9 +231,9 @@ public: float m_fSpecifiedBPMMax; // if a range, then Min != Max RString m_sBannerFile; // typically a 16:5 ratio graphic (e.g. 256x80) - //RString m_sJacketFile; // typically square (e.g. 192x192, 256x256) - //RString m_sCDFile; // square (e.g. 128x128 [DDR 1st-3rd]) - //RString m_sDiscFile; // rectangular (e.g. 256x192 [Pump], 200x150 [MGD3]) + RString m_sJacketFile; // typically square (e.g. 192x192, 256x256) + RString m_sCDFile; // square (e.g. 128x128 [DDR 1st-3rd]) + RString m_sDiscFile; // rectangular (e.g. 256x192 [Pump], 200x150 [MGD3]) /** @brief The location of the lyrics file, if it exists. */ RString m_sLyricsFile; RString m_sBackgroundFile; @@ -245,9 +245,9 @@ public: RString GetMusicPath() const; RString GetInstrumentTrackPath( InstrumentTrack it ) const; RString GetBannerPath() const; - //RString GetJacketPath() const; - //RString GetCDImagePath() const; - //RString GetDiscPath() const; + RString GetJacketPath() const; + RString GetCDImagePath() const; + RString GetDiscPath() const; RString GetLyricsPath() const; RString GetBackgroundPath() const; RString GetCDTitlePath() const; @@ -265,9 +265,9 @@ public: * @brief Does this song have a background image? * @return true if it does, false otherwise. */ bool HasBackground() const; - //bool HasJacket() const; - //bool HasCDImage() const; - //bool HasDisc() const; + bool HasJacket() const; + bool HasCDImage() const; + bool HasDisc() const; bool HasCDTitle() const; //bool HasMovieBackground() const; bool HasBGChanges() const;