[Song] add GetDisplayBpms, IsDisplayBpmSecret, IsDisplayBpmConstant Lua bindings

This commit is contained in:
AJ Kelly
2010-05-02 13:00:12 -05:00
parent 105185d5b0
commit 1da7841f28
2 changed files with 50 additions and 20 deletions
+33 -4
View File
@@ -553,9 +553,7 @@ void Song::TidyUpData()
m_sLyricsFile = arrayLyricFiles[0];
}
//
// Now, For the images we still haven't found, look at the image dimensions of the remaining unclassified images.
//
vector<RString> arrayImages;
GetImageDirListing( m_sSongDir + "*", arrayImages );
@@ -1093,7 +1091,7 @@ bool Song::HasInstrumentTrack( InstrumentTrack it ) const
}
bool Song::HasLyrics() const {return m_sLyricsFile != "" && IsAFile(GetLyricsPath()); }
bool Song::HasBackground() const {return m_sBackgroundFile != "" && IsAFile(GetBackgroundPath()); }
bool Song::HasCDTitle() const {return m_sCDTitleFile != "" && IsAFile(GetCDTitlePath()); }
bool Song::HasCDTitle() const {return m_sCDTitleFile != "" && IsAFile(GetCDTitlePath()); }
bool Song::HasBGChanges() const
{
FOREACH_BackgroundLayer( i )
@@ -1103,6 +1101,7 @@ bool Song::HasBGChanges() const
}
return false;
}
bool Song::HasAttacks() const {return !m_Attacks.empty(); }
const vector<BackgroundChange> &Song::GetBackgroundChanges( BackgroundLayer bl ) const
{
@@ -1478,6 +1477,33 @@ public:
static int NormallyDisplayed( T* p, lua_State *L ){ lua_pushboolean(L, p->NormallyDisplayed()); return 1; }
static int GetFirstBeat( T* p, lua_State *L ) { lua_pushnumber(L, p->m_fFirstBeat); return 1; }
static int GetLastBeat( T* p, lua_State *L ) { lua_pushnumber(L, p->m_fLastBeat); return 1; }
static int HasAttacks( T* p, lua_State *L ) { lua_pushboolean(L, p->HasAttacks()); return 1; }
static int GetDisplayBpms( T* p, lua_State *L )
{
DisplayBpms temp;
p->GetDisplayBpms(temp);
float fMin = temp.GetMin();
float fMax = temp.GetMax();
vector<float> fBPMs;
fBPMs.push_back( fMin );
fBPMs.push_back( fMax );
LuaHelpers::CreateTableFromArray(fBPMs, L);
return 1;
}
static int IsDisplayBpmSecret( T* p, lua_State *L )
{
DisplayBpms temp;
p->GetDisplayBpms(temp);
lua_pushboolean( L, temp.IsSecret() );
return 1;
}
static int IsDisplayBpmConstant( T* p, lua_State *L )
{
DisplayBpms temp;
p->GetDisplayBpms(temp);
lua_pushboolean( L, temp.BpmIsConstant() );
return 1;
}
LunaSong()
{
@@ -1515,7 +1541,6 @@ public:
ADD_METHOD( HasCDTitle );
ADD_METHOD( HasBGChanges );
ADD_METHOD( HasLyrics );
// danger will robinson
ADD_METHOD( HasSignificantBPMChangesOrStops );
ADD_METHOD( HasEdits );
ADD_METHOD( IsEasy );
@@ -1523,6 +1548,10 @@ public:
ADD_METHOD( NormallyDisplayed );
ADD_METHOD( GetFirstBeat );
ADD_METHOD( GetLastBeat );
ADD_METHOD( HasAttacks );
ADD_METHOD( GetDisplayBpms );
ADD_METHOD( IsDisplayBpmSecret );
ADD_METHOD( IsDisplayBpmConstant );
}
};
+17 -16
View File
@@ -57,11 +57,11 @@ class Song
public:
void SetSongDir( const RString sDir ) { m_sSongDir = sDir; }
/* Set when this song should be displayed in the music wheel: */
// Set when this song should be displayed in the music wheel:
enum SelectionDisplay
{
SHOW_ALWAYS, /* always */
SHOW_NEVER /* never (unless song hiding is turned off) */
SHOW_ALWAYS, // always
SHOW_NEVER // never (unless song hiding is turned off)
} m_SelectionDisplay;
Song();
@@ -90,42 +90,42 @@ public:
void AutoGen( StepsType ntTo, StepsType ntFrom ); // create Steps of type ntTo from Steps of type ntFrom
void RemoveAutoGenNotes();
/* Directory this song data came from: */
// Directory this song data came from:
const RString &GetSongDir() const { return m_sSongDir; }
/* Filename associated with this file. This will always have
* an .SM extension. If we loaded an .SM, this will point to
/* Filename associated with this file. This will always have
* an .SM extension. If we loaded an .SM, this will point to
* it, but if we loaded any other type, this will point to a
* generated .SM filename. */
RString m_sSongFileName;
RString m_sGroupName;
ProfileSlot m_LoadedFromProfile; // ProfileSlot_Invalid if wasn't loaded from a profile
ProfileSlot m_LoadedFromProfile; // ProfileSlot_Invalid if not loaded from a profile
bool m_bIsSymLink;
bool m_bEnabled;
RString m_sMainTitle, m_sSubTitle, m_sArtist;
RString m_sMainTitleTranslit, m_sSubTitleTranslit, m_sArtistTranslit;
/* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below.
* Otherwise, they return the main titles. */
/* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit*
* below. Otherwise, they return the main titles. */
RString GetDisplayMainTitle() const;
RString GetDisplaySubTitle() const;
RString GetDisplayArtist() const;
/* Returns the transliterated titles, if any; otherwise returns the main titles. */
// Returns the transliterated titles, if any; otherwise returns the main titles.
RString GetTranslitMainTitle() const { return m_sMainTitleTranslit.size()? m_sMainTitleTranslit: m_sMainTitle; }
RString GetTranslitSubTitle() const { return m_sSubTitleTranslit.size()? m_sSubTitleTranslit: m_sSubTitle; }
RString GetTranslitArtist() const { return m_sArtistTranslit.size()? m_sArtistTranslit:m_sArtist; }
/* "title subtitle" */
// "title subtitle"
RString GetDisplayFullTitle() const;
RString GetTranslitFullTitle() const;
RString m_sGenre;
/* This is read and saved, but never actually used. */
// This is read and saved, but never actually used.
RString m_sCredit;
RString m_sMusicFile;
@@ -156,8 +156,7 @@ public:
RString GetBackgroundPath() const;
RString GetCDTitlePath() const;
/* For loading only: */
// For loading only:
bool m_bHasMusic, m_bHasBanner, m_bHasBackground;
bool HasMusic() const;
@@ -168,10 +167,11 @@ public:
bool HasMovieBackground() const;
bool HasBGChanges() const;
bool HasLyrics() const;
bool HasAttacks() const;
bool Matches(RString sGroup, RString sSong) const;
TimingData m_Timing;
TimingData m_Timing;
typedef vector<BackgroundChange> VBackgroundChange;
private:
@@ -188,6 +188,7 @@ public:
void AddBPMSegment( const BPMSegment &seg ) { m_Timing.AddBPMSegment( seg ); }
void AddStopSegment( const StopSegment &seg ) { m_Timing.AddStopSegment( seg ); }
void AddWarpSegment( const WarpSegment &seg ) { m_Timing.AddWarpSegment( seg ); }
void AddBackgroundChange( BackgroundLayer blLayer, BackgroundChange seg );
void AddForegroundChange( BackgroundChange seg );
void AddLyricSegment( LyricSegment seg );
@@ -219,7 +220,7 @@ public:
bool NormallyDisplayed() const;
bool ShowInDemonstrationAndRanking() const;
void AddSteps( Steps* pSteps ); // we are responsible for deleting the memory pointed to by pSteps!
void AddSteps( Steps* pSteps ); // we are responsible for deleting the memory pointed to by pSteps!
void DeleteSteps( const Steps* pSteps, bool bReAutoGen = true );
void FreeAllLoadedFromProfile( ProfileSlot slot = ProfileSlot_Invalid, const set<Steps*> *setInUse = NULL );