[Song] Added Jacket, CD image (a la early DDR), and Disc (PIU-style) support. Added GetJacketPath(), GetCDImagePath(), GetDiscPath(), HasJacket(), HasDisc(), and HasCDImage() Lua bindings.

This commit is contained in:
AJ Kelly
2011-08-21 19:03:19 -05:00
parent 9154a273db
commit 01c6c1679e
3 changed files with 120 additions and 59 deletions
+3 -1
View File
@@ -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 2011/08/21
---------- ----------
* [NotesLoaderSSC] Fix loading pre-split timing files that had blank timing * [NotesLoaderSSC] Fix loading pre-split timing files that had blank timing
tags inside of them. Thanks to Vin.il for the catch. [Wolfman2000] 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 StepMania 5.0 Preview 3 | 20110820
+108 -49
View File
@@ -458,8 +458,9 @@ void Song::TidyUpData( bool fromCache, bool duringCache )
if( !m_sInstrumentTrackFile[i].empty() ) if( !m_sInstrumentTrackFile[i].empty() )
FixupPath( m_sInstrumentTrackFile[i], m_sSongDir ); FixupPath( m_sInstrumentTrackFile[i], m_sSongDir );
FixupPath( m_sBannerFile, m_sSongDir ); FixupPath( m_sBannerFile, m_sSongDir );
//FixupPath( m_sJacketFile, m_sSongDir ); FixupPath( m_sJacketFile, m_sSongDir );
//FixupPath( m_sDiscFile, m_sSongDir ); FixupPath( m_sCDFile, m_sSongDir );
FixupPath( m_sDiscFile, m_sSongDir );
FixupPath( m_sLyricsFile, m_sSongDir ); FixupPath( m_sLyricsFile, m_sSongDir );
FixupPath( m_sBackgroundFile, m_sSongDir ); FixupPath( m_sBackgroundFile, m_sSongDir );
FixupPath( m_sCDTitleFile, m_sSongDir ); FixupPath( m_sCDTitleFile, m_sSongDir );
@@ -618,7 +619,6 @@ void Song::TidyUpData( bool fromCache, bool duringCache )
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.
@@ -629,26 +629,26 @@ void Song::TidyUpData( bool fromCache, bool duringCache )
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;
GetImageDirListing( m_sSongDir + "* Disc", arrayPossibleDiscImages );
GetImageDirListing( m_sSongDir + "* Title", arrayPossibleDiscImages );
if( !arrayPossibleDiscImages.empty() )
m_sDiscFile = arrayPossibleDiscImages[0];
} }
*/
if( !HasCDTitle() ) if( !HasCDTitle() )
{ {
@@ -695,7 +695,14 @@ void Song::TidyUpData( bool fromCache, bool duringCache )
if( HasCDTitle() && m_sCDTitleFile.EqualsNoCase(arrayImages[i]) ) if( HasCDTitle() && m_sCDTitleFile.EqualsNoCase(arrayImages[i]) )
continue; // skip 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]; RString sPath = m_sSongDir + arrayImages[i];
@@ -753,7 +760,27 @@ void Song::TidyUpData( bool fromCache, bool duringCache )
continue; 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. // These will be written to cache, for Song::LoadFromSongDir to use later.
@@ -1230,7 +1257,18 @@ bool Song::HasBGChanges() const
return false; return false;
} }
bool Song::HasAttacks() const {return !m_Attacks.empty(); } 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<BackgroundChange> &Song::GetBackgroundChanges( BackgroundLayer bl ) const const vector<BackgroundChange> &Song::GetBackgroundChanges( BackgroundLayer bl ) const
{ {
@@ -1349,7 +1387,20 @@ RString Song::GetBackgroundPath() const
return GetSongAssetPath( m_sBackgroundFile, m_sSongDir ); 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 RString Song::GetDisplayMainTitle() const
{ {
@@ -1640,6 +1691,33 @@ public:
lua_pushnil(L); lua_pushnil(L);
return 1; 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 ) static int GetCDTitlePath( T* p, lua_State *L )
{ {
RString s = p->GetCDTitlePath(); RString s = p->GetCDTitlePath();
@@ -1719,42 +1797,17 @@ public:
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
} }
static int GetTimingData( T* p, lua_State *L ) static int GetTimingData( T* p, lua_State *L ) { p->m_SongTiming.PushSelf(L); return 1; }
{
p->m_SongTiming.PushSelf(L);
return 1;
}
// has functions // has functions
static int HasMusic( T* p, lua_State *L ) 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; }
lua_pushboolean(L, p->HasMusic()); static int HasBackground( T* p, lua_State *L ) { lua_pushboolean(L, p->HasBackground()); return 1; }
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 HasBanner( T* p, lua_State *L ) 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; }
lua_pushboolean(L, p->HasBanner()); static int HasBGChanges( T* p, lua_State *L ) { lua_pushboolean(L, p->HasBGChanges()); return 1; }
return 1; static int HasLyrics( T* p, lua_State *L ) { lua_pushboolean(L, p->HasLyrics()); 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;
}
// functions that AJ loves // functions that AJ loves
static int HasSignificantBPMChangesOrStops( T* p, lua_State *L ) static int HasSignificantBPMChangesOrStops( T* p, lua_State *L )
{ {
@@ -1863,6 +1916,9 @@ public:
ADD_METHOD( GetMusicPath ); ADD_METHOD( GetMusicPath );
ADD_METHOD( GetBannerPath ); ADD_METHOD( GetBannerPath );
ADD_METHOD( GetBackgroundPath ); ADD_METHOD( GetBackgroundPath );
ADD_METHOD( GetJacketPath );
ADD_METHOD( GetCDImagePath );
ADD_METHOD( GetDiscPath );
ADD_METHOD( GetCDTitlePath ); ADD_METHOD( GetCDTitlePath );
ADD_METHOD( GetLyricsPath ); ADD_METHOD( GetLyricsPath );
ADD_METHOD( GetSongFilePath ); ADD_METHOD( GetSongFilePath );
@@ -1879,6 +1935,9 @@ public:
ADD_METHOD( HasMusic ); ADD_METHOD( HasMusic );
ADD_METHOD( HasBanner ); ADD_METHOD( HasBanner );
ADD_METHOD( HasBackground ); ADD_METHOD( HasBackground );
ADD_METHOD( HasJacket );
ADD_METHOD( HasCDImage );
ADD_METHOD( HasDisc );
ADD_METHOD( HasCDTitle ); ADD_METHOD( HasCDTitle );
ADD_METHOD( HasBGChanges ); ADD_METHOD( HasBGChanges );
ADD_METHOD( HasLyrics ); ADD_METHOD( HasLyrics );
+9 -9
View File
@@ -231,9 +231,9 @@ public:
float m_fSpecifiedBPMMax; // if a range, then Min != Max float m_fSpecifiedBPMMax; // if a range, then Min != Max
RString m_sBannerFile; // typically a 16:5 ratio graphic (e.g. 256x80) RString m_sBannerFile; // typically a 16:5 ratio graphic (e.g. 256x80)
//RString m_sJacketFile; // typically square (e.g. 192x192, 256x256) RString m_sJacketFile; // typically square (e.g. 192x192, 256x256)
//RString m_sCDFile; // square (e.g. 128x128 [DDR 1st-3rd]) RString m_sCDFile; // square (e.g. 128x128 [DDR 1st-3rd])
//RString m_sDiscFile; // rectangular (e.g. 256x192 [Pump], 200x150 [MGD3]) RString m_sDiscFile; // rectangular (e.g. 256x192 [Pump], 200x150 [MGD3])
/** @brief The location of the lyrics file, if it exists. */ /** @brief The location of the lyrics file, if it exists. */
RString m_sLyricsFile; RString m_sLyricsFile;
RString m_sBackgroundFile; RString m_sBackgroundFile;
@@ -245,9 +245,9 @@ public:
RString GetMusicPath() const; RString GetMusicPath() const;
RString GetInstrumentTrackPath( InstrumentTrack it ) const; RString GetInstrumentTrackPath( InstrumentTrack it ) const;
RString GetBannerPath() const; RString GetBannerPath() const;
//RString GetJacketPath() const; RString GetJacketPath() const;
//RString GetCDImagePath() const; RString GetCDImagePath() const;
//RString GetDiscPath() const; RString GetDiscPath() const;
RString GetLyricsPath() const; RString GetLyricsPath() const;
RString GetBackgroundPath() const; RString GetBackgroundPath() const;
RString GetCDTitlePath() const; RString GetCDTitlePath() const;
@@ -265,9 +265,9 @@ public:
* @brief Does this song have a background image? * @brief Does this song have a background image?
* @return true if it does, false otherwise. */ * @return true if it does, false otherwise. */
bool HasBackground() const; bool HasBackground() const;
//bool HasJacket() const; bool HasJacket() const;
//bool HasCDImage() const; bool HasCDImage() const;
//bool HasDisc() const; bool HasDisc() const;
bool HasCDTitle() const; bool HasCDTitle() const;
//bool HasMovieBackground() const; //bool HasMovieBackground() const;
bool HasBGChanges() const; bool HasBGChanges() const;