Move group into its own class, add Credit and AuthorsNotes fields, Begin exposing methods to lua
This commit is contained in:
+119
@@ -0,0 +1,119 @@
|
||||
#include "global.h"
|
||||
#include "Song.h"
|
||||
#include "Group.h"
|
||||
#include "Style.h"
|
||||
#include "RageFile.h"
|
||||
#include "RageFileManager.h"
|
||||
#include "RageSurface.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
Group::Group() {
|
||||
m_sDisplayTitle = "";
|
||||
m_sSortTitle = "";
|
||||
m_sPath = "";
|
||||
m_sGroupName = "";
|
||||
m_sTranslitTitle = "";
|
||||
m_sSeries = "";
|
||||
m_iSyncOffset = 0;
|
||||
m_bHasGroupIni = false;
|
||||
iTotalSongs = 0;
|
||||
m_sBannerPath = "";
|
||||
m_sCredits.clear();
|
||||
m_sAuthorsNotes = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "LuaBinding.h"
|
||||
|
||||
class LunaGroup: public Luna<Group>
|
||||
{
|
||||
public:
|
||||
static int GetGroupName( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushstring(L, p->GetGroupName());
|
||||
return 1;
|
||||
}
|
||||
static int GetSortTitle( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushstring(L, p->GetSortTitle());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetDisplayTitle( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushstring(L, p->GetDisplayTitle());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetTranslitTitle( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushstring(L, p->GetTranslitTitle());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetSeries( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushstring(L, p->GetSeries());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetSyncOffset( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushnumber(L, p->GetSyncOffset());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int HasGroupIni( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushboolean(L, p->HasGroupIni());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetTotalSongs( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushnumber(L, p->iTotalSongs);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetBannerPath( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushstring(L, p->GetBannerPath());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetStepArtistCredits( T* p, lua_State *L )
|
||||
{
|
||||
std::vector<RString> v = p->GetStepArtistCredits();
|
||||
LuaHelpers::CreateTableFromArray<RString>( v, L );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetAuthorsNotes( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushstring(L, p->GetAuthorsNotes());
|
||||
return 1;
|
||||
}
|
||||
|
||||
LunaGroup()
|
||||
{
|
||||
ADD_METHOD( GetGroupName );
|
||||
ADD_METHOD( GetSortTitle );
|
||||
ADD_METHOD( GetDisplayTitle );
|
||||
ADD_METHOD( GetTranslitTitle );
|
||||
ADD_METHOD( GetSeries );
|
||||
ADD_METHOD( GetSyncOffset );
|
||||
ADD_METHOD( HasGroupIni );
|
||||
ADD_METHOD( GetTotalSongs );
|
||||
ADD_METHOD( GetBannerPath );
|
||||
ADD_METHOD( GetStepArtistCredits );
|
||||
ADD_METHOD( GetAuthorsNotes );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
LUA_REGISTER_CLASS( Group )
|
||||
|
||||
|
||||
// lua end
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
#ifndef GROUP_H
|
||||
#define GROUP_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "ActorFrame.h"
|
||||
#include "GameplayAssist.h"
|
||||
#include "Player.h"
|
||||
#include "NoteData.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
struct lua_State;
|
||||
class Group
|
||||
{
|
||||
public:
|
||||
Group();
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
RString m_sDisplayTitle;
|
||||
RString m_sSortTitle;
|
||||
RString m_sPath;
|
||||
RString m_sGroupName;
|
||||
RString m_sTranslitTitle;
|
||||
RString m_sSeries;
|
||||
float m_iSyncOffset;
|
||||
bool m_bHasGroupIni;
|
||||
RString m_sBannerPath;
|
||||
std::vector<RString> m_sCredits;
|
||||
RString m_sAuthorsNotes;
|
||||
// Get the display title of the group.
|
||||
const RString GetDisplayTitle() const { return m_sDisplayTitle; };
|
||||
|
||||
// Set the display title of the group.
|
||||
void SetDisplayTitle(const RString sDisplayTitle) { m_sDisplayTitle = sDisplayTitle; };
|
||||
|
||||
// Get the sort title of the group.
|
||||
const RString GetSortTitle() const { return m_sSortTitle; };
|
||||
|
||||
// Set the sort title of the group.
|
||||
void SetSortTitle(const RString sSortTitle) { m_sSortTitle = sSortTitle; };
|
||||
|
||||
// Get the path of the group.
|
||||
const RString GetPath() const { return m_sPath; };
|
||||
|
||||
// Set the path of the group.
|
||||
void SetPath(const RString sPath) { m_sPath = sPath; };
|
||||
|
||||
// Get the group name.
|
||||
const RString GetGroupName() const { return m_sGroupName; };
|
||||
|
||||
// Set the group name.
|
||||
void SetGroupName(const RString sGroupName) { m_sGroupName = sGroupName; };
|
||||
|
||||
// Get the transliterated title of the group.
|
||||
const RString GetTranslitTitle() const { return m_sTranslitTitle; };
|
||||
|
||||
// Set the transliterated title of the group.
|
||||
void SetTranslitTitle(const RString sTranslitTitle) { m_sTranslitTitle = sTranslitTitle; };
|
||||
|
||||
// Get the series of the group.
|
||||
const RString GetSeries() const { return m_sSeries; };
|
||||
|
||||
// Set the series of the group.
|
||||
void SetSeries(const RString sSeries) { m_sSeries = sSeries; };
|
||||
|
||||
// Get the sync offset of the group.
|
||||
float GetSyncOffset() const { return m_iSyncOffset; };
|
||||
|
||||
// Set the sync offset of the group.
|
||||
void SetSyncOffset(const float fSyncOffset) { m_iSyncOffset = fSyncOffset; };
|
||||
|
||||
// Determine if the group has a Group.ini file.
|
||||
|
||||
bool HasGroupIni() const { return m_bHasGroupIni; };
|
||||
|
||||
// Set if the group has a Group.ini file.
|
||||
void SetGroupIni(const bool bHasGroupIni) { m_bHasGroupIni = bHasGroupIni; };
|
||||
|
||||
// Get the banner path of the group.
|
||||
const RString GetBannerPath() const { return m_sBannerPath; };
|
||||
|
||||
// Set the banner path of the group.
|
||||
void SetBannerPath(const RString sBannerPath) { m_sBannerPath = sBannerPath; };
|
||||
|
||||
// Get the credits of the group.
|
||||
const std::vector<RString> GetStepArtistCredits() const { return m_sCredits; };
|
||||
|
||||
// Set the credits of the group.
|
||||
void SetStepArtistCredits(const std::vector<RString> sCredits) { m_sCredits = sCredits; };
|
||||
|
||||
// Get the authors notes of the group.
|
||||
const RString GetAuthorsNotes() const { return m_sAuthorsNotes; };
|
||||
|
||||
// Set the authors notes of the group.
|
||||
void SetAuthorsNotes(const RString sAuthorsNotes) { m_sAuthorsNotes = sAuthorsNotes; };
|
||||
|
||||
int iTotalSongs;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
class Course;
|
||||
class Song;
|
||||
struct Group;
|
||||
|
||||
struct MusicWheelItemData;
|
||||
|
||||
|
||||
@@ -1195,14 +1195,6 @@ void Profile::LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot)
|
||||
RageTimer song_load_start_time;
|
||||
song_load_start_time.Touch();
|
||||
FILEMAN->GetDirListing(songs_folder + "/*", song_folders, true, true);
|
||||
Group group;
|
||||
group.m_sDisplayTitle = m_sDisplayName;
|
||||
group.m_sSortTitle = m_sDisplayName;
|
||||
group.m_sTranslitTitle = m_sDisplayName;
|
||||
group.m_sSeries = "";
|
||||
group.m_iSyncOffset = 0;
|
||||
group.m_sPath = songs_folder;
|
||||
group.m_sGroupName = m_sDisplayName;
|
||||
|
||||
StripCvsAndSvn(song_folders);
|
||||
StripMacResourceForks(song_folders);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "Song.h"
|
||||
#include "Group.h"
|
||||
#include "Steps.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
@@ -2274,6 +2275,13 @@ public:
|
||||
lua_pushstring(L, p->m_sGroupName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetGroup( T* p, lua_State *L )
|
||||
{
|
||||
p->GetGroup()->PushSelf(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int MusicLengthSeconds( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushnumber(L, p->m_fMusicLengthSeconds);
|
||||
@@ -2493,6 +2501,7 @@ public:
|
||||
ADD_METHOD( IsEnabled );
|
||||
ADD_METHOD(IsCustomSong);
|
||||
ADD_METHOD( GetGroupName );
|
||||
ADD_METHOD( GetGroup );
|
||||
ADD_METHOD( MusicLengthSeconds );
|
||||
ADD_METHOD( GetSampleStart );
|
||||
ADD_METHOD( GetSampleLength );
|
||||
@@ -2536,6 +2545,8 @@ public:
|
||||
};
|
||||
|
||||
LUA_REGISTER_CLASS( Song )
|
||||
|
||||
|
||||
// lua end
|
||||
|
||||
|
||||
|
||||
+1
-14
@@ -8,6 +8,7 @@
|
||||
#include "RageUtil_AutoPtr.h"
|
||||
#include "RageTypes.h"
|
||||
#include "Steps.h"
|
||||
#include "Group.h"
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
@@ -65,20 +66,6 @@ struct LyricSegment
|
||||
};
|
||||
|
||||
|
||||
struct Group
|
||||
{
|
||||
RString m_sDisplayTitle;
|
||||
RString m_sSortTitle;
|
||||
RString m_sPath;
|
||||
RString m_sGroupName;
|
||||
RString m_sTranslitTitle;
|
||||
RString m_sSeries;
|
||||
float m_iSyncOffset;
|
||||
bool m_bHasGroupIni;
|
||||
int iTotalSongs;
|
||||
RString m_sBannerPath;
|
||||
};
|
||||
|
||||
/** @brief Holds all music metadata and steps for one song. */
|
||||
class Song
|
||||
{
|
||||
|
||||
+44
-25
@@ -22,6 +22,7 @@
|
||||
#include "Profile.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "RageFile.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageFileManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "Song.h"
|
||||
@@ -37,6 +38,7 @@
|
||||
#include "TrailUtil.h"
|
||||
#include "UnlockManager.h"
|
||||
#include "SpecialFiles.h"
|
||||
#include "Group.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
@@ -282,9 +284,9 @@ void SongManager::AddGroup( RString sDir, RString sGroupDirName, Group group )
|
||||
std::vector<RString> arrayGroupBanners;
|
||||
|
||||
// First check if there is a banner provided in group.ini
|
||||
if( group.m_sBannerPath != "" )
|
||||
if( group.GetBannerPath() != "" )
|
||||
{
|
||||
GetDirListing( sDir+sGroupDirName+"/"+group.m_sBannerPath, arrayGroupBanners );
|
||||
GetDirListing( sDir+sGroupDirName+"/"+group.GetBannerPath(), arrayGroupBanners );
|
||||
}
|
||||
GetDirListing( sDir+sGroupDirName+"/*.png", arrayGroupBanners );
|
||||
GetDirListing( sDir+sGroupDirName+"/*.jpg", arrayGroupBanners );
|
||||
@@ -345,16 +347,12 @@ void SongManager::AddGroup( RString sDir, RString sGroupDirName, Group group )
|
||||
if (m_mapGroupsByName.find(sGroupDirName) == m_mapGroupsByName.end())
|
||||
{
|
||||
m_mapGroupsByName[sGroupDirName] = group;
|
||||
} else {
|
||||
LOG->Trace("SongManager::AddGroup: Group %s already has a group. Ignoring group %s.", sGroupDirName.c_str(), group.m_sDisplayTitle.c_str());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Add the group to its series if the group has one and if the series exists
|
||||
if( group.m_sSeries != "" )
|
||||
if( group.GetSeries() != "" )
|
||||
{
|
||||
std::vector<Group*>& series = m_mapSeries[group.m_sSeries];
|
||||
std::vector<Group*>& series = m_mapSeries[group.GetSeries()];
|
||||
if( std::find(series.begin(), series.end(), &group) == series.end() )
|
||||
series.push_back(&group);
|
||||
}
|
||||
@@ -446,9 +444,12 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
|
||||
RString TranslitTitle = sGroupDirName;
|
||||
RString Series = "";
|
||||
RString bannerPath = "";
|
||||
RString credits = "";
|
||||
RString authorsNotes = "";
|
||||
// Use our new Group class
|
||||
Group group;
|
||||
float fOffset = 0;
|
||||
|
||||
Group group;
|
||||
if( FILEMAN->DoesFileExist( sGroupIniPath ) && arraySongDirs.size() > 0 )
|
||||
{
|
||||
IniFile ini;
|
||||
@@ -477,21 +478,39 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
|
||||
} else {
|
||||
fOffset = StringToFloat( sValue );
|
||||
}
|
||||
ini.GetValue( "Group", "Credits", credits );
|
||||
ini.GetValue( "Group", "AuthorsNotes", authorsNotes );
|
||||
|
||||
LOG->Trace("Loaded group.ini for \"%s\"", (sDir+sGroupDirName).c_str() );
|
||||
|
||||
group.m_bHasGroupIni = true;
|
||||
group.SetGroupIni(true);
|
||||
} else {
|
||||
group.m_bHasGroupIni = false;
|
||||
group.SetGroupIni(false);
|
||||
}
|
||||
group.m_sDisplayTitle = sDisplayTitle;
|
||||
group.m_sSortTitle = SortTitle;
|
||||
group.m_sTranslitTitle = TranslitTitle;
|
||||
group.m_sSeries = Series;
|
||||
group.m_iSyncOffset = fOffset;
|
||||
group.m_sBannerPath = bannerPath;
|
||||
group.m_sPath = sDir + sGroupDirName;
|
||||
group.m_sGroupName = group_base_name;
|
||||
|
||||
// group.m_sDisplayTitle = sDisplayTitle;
|
||||
// group.m_sSortTitle = SortTitle;
|
||||
// group.m_sTranslitTitle = TranslitTitle;
|
||||
// group.m_sSeries = Series;
|
||||
// group.m_iSyncOffset = fOffset;
|
||||
// group.m_sBannerPath = bannerPath;
|
||||
// group.m_sPath = sDir + sGroupDirName;
|
||||
// group.m_sGroupName = group_base_name;
|
||||
// split(credits, ";", group.m_sCredits);
|
||||
// group.m_sAuthorsNotes = authorsNotes;
|
||||
|
||||
group.SetDisplayTitle(sDisplayTitle);
|
||||
group.SetSortTitle(SortTitle);
|
||||
group.SetTranslitTitle(TranslitTitle);
|
||||
group.SetSeries(Series);
|
||||
group.SetSyncOffset(fOffset);
|
||||
group.SetBannerPath(bannerPath);
|
||||
group.SetPath(sDir + sGroupDirName);
|
||||
group.SetGroupName(group_base_name);
|
||||
std::vector<RString> credits_vector;
|
||||
split(credits, ";", credits_vector);
|
||||
group.SetStepArtistCredits(credits_vector);
|
||||
group.SetAuthorsNotes(authorsNotes);
|
||||
|
||||
|
||||
for( unsigned j=0; j< arraySongDirs.size(); ++j ) // for each song dir
|
||||
{
|
||||
@@ -527,10 +546,10 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
|
||||
continue;
|
||||
}
|
||||
// Apply Group Offset if applicable
|
||||
if( group.m_iSyncOffset != 0 )
|
||||
if( group.GetSyncOffset() != 0 )
|
||||
{
|
||||
LOG->Trace("Applying group offset of %i ms to \"%s\"", group.m_iSyncOffset, pNewSong->GetSongDir().c_str() );
|
||||
pNewSong->m_SongTiming.m_fBeat0GroupOffsetInSeconds = group.m_iSyncOffset;
|
||||
LOG->Trace("Applying group offset of %i ms to \"%s\"", group.GetSyncOffset(), pNewSong->GetSongDir().c_str() );
|
||||
pNewSong->m_SongTiming.m_fBeat0GroupOffsetInSeconds = group.GetSyncOffset();
|
||||
const std::vector<Steps*>& vpSteps = pNewSong->GetAllSteps();
|
||||
for (Steps* s : vpSteps)
|
||||
{
|
||||
@@ -538,7 +557,7 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
|
||||
// from the song and is already changed.
|
||||
if( s->m_Timing.empty() )
|
||||
continue;
|
||||
s->m_Timing.m_fBeat0GroupOffsetInSeconds = group.m_iSyncOffset;
|
||||
s->m_Timing.m_fBeat0GroupOffsetInSeconds = group.GetSyncOffset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user