Further Group enhancements.
- Adjust the variable scope of group attributes - Remove the now redundant GroupBannerPaths vector and replace its usage. - Migrate ini loading logic to Group class - Better clarity on comments for Group - Remove GetTotalSongs in favor of GetSongs. - Add Year as a value to Group.ini - Ensure new group and song maps are cleared properly when freeing songs
This commit is contained in:
+71
-9
@@ -1,12 +1,18 @@
|
||||
#include "global.h"
|
||||
#include "Song.h"
|
||||
#include "Group.h"
|
||||
#include "Style.h"
|
||||
#include "SongManager.h"
|
||||
#include "RageFile.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageFileManager.h"
|
||||
#include "RageSurface.h"
|
||||
#include <vector>
|
||||
#include "RageLog.h"
|
||||
#include "Song.h"
|
||||
#include "SongCacheIndex.h"
|
||||
#include "SongUtil.h"
|
||||
#include "TitleSubstitution.h"
|
||||
#include "Group.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
Group::Group() {
|
||||
m_sDisplayTitle = "";
|
||||
@@ -17,12 +23,60 @@ Group::Group() {
|
||||
m_sSeries = "";
|
||||
m_iSyncOffset = 0;
|
||||
m_bHasGroupIni = false;
|
||||
iTotalSongs = 0;
|
||||
m_iYearReleased = 0;
|
||||
m_sBannerPath = "";
|
||||
m_sCredits.clear();
|
||||
m_sAuthorsNotes = "";
|
||||
}
|
||||
|
||||
Group::Group(const RString &sPath) {
|
||||
RString sGroupIniPath = sPath + "/Group.ini";
|
||||
RString credits = "";
|
||||
if (FILEMAN->DoesFileExist(sGroupIniPath)) {
|
||||
IniFile ini;
|
||||
ini.ReadFile(sGroupIniPath);
|
||||
ini.GetValue("Group", "DisplayTitle", m_sDisplayTitle);
|
||||
if (m_sDisplayTitle.empty()) {
|
||||
m_sDisplayTitle = m_sGroupName;
|
||||
}
|
||||
ini.GetValue("Group", "Banner", m_sBannerPath);
|
||||
ini.GetValue("Group", "SortTitle", m_sSortTitle);
|
||||
if (m_sSortTitle.empty()) {
|
||||
m_sSortTitle = m_sDisplayTitle;
|
||||
}
|
||||
ini.GetValue("Group", "TranslitTitle", m_sTranslitTitle);
|
||||
if (m_sTranslitTitle.empty()) {
|
||||
m_sTranslitTitle = m_sDisplayTitle;
|
||||
}
|
||||
ini.GetValue("Group", "Series", m_sSeries);
|
||||
RString sValue = "";
|
||||
ini.GetValue("Group", "SyncOffset", sValue);
|
||||
if (sValue.CompareNoCase("null") == 0) {
|
||||
m_iSyncOffset = 0;
|
||||
} else if (sValue.CompareNoCase("itg") == 0) {
|
||||
m_iSyncOffset = 0.009f;
|
||||
} else {
|
||||
m_iSyncOffset = StringToFloat(sValue);
|
||||
}
|
||||
ini.GetValue("Group", "Year", m_iYearReleased);
|
||||
ini.GetValue("Group", "AuthorsNotes", m_sAuthorsNotes);
|
||||
|
||||
std::vector<RString> credits_vector;
|
||||
ini.GetValue("Group", "Credits", credits);
|
||||
split(credits, ";", credits_vector);
|
||||
m_sCredits = credits_vector;
|
||||
m_bHasGroupIni = true;
|
||||
} else {
|
||||
m_bHasGroupIni = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const std::vector<Song *> &Group::GetSongs() const
|
||||
{
|
||||
return SONGMAN->GetSongs(m_sGroupName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "LuaBinding.h"
|
||||
@@ -71,9 +125,10 @@ public:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetTotalSongs( T* p, lua_State *L )
|
||||
static int GetSongs( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushnumber(L, p->iTotalSongs);
|
||||
const std::vector<Song*> &v = p->GetSongs();
|
||||
LuaHelpers::CreateTableFromArray<Song*>( v, L );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -96,6 +151,12 @@ public:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int GetYearReleased( T* p, lua_State *L )
|
||||
{
|
||||
lua_pushnumber(L, p->GetYearReleased());
|
||||
return 1;
|
||||
}
|
||||
|
||||
LunaGroup()
|
||||
{
|
||||
ADD_METHOD( GetGroupName );
|
||||
@@ -105,10 +166,11 @@ public:
|
||||
ADD_METHOD( GetSeries );
|
||||
ADD_METHOD( GetSyncOffset );
|
||||
ADD_METHOD( HasGroupIni );
|
||||
ADD_METHOD( GetTotalSongs );
|
||||
ADD_METHOD( GetSongs );
|
||||
ADD_METHOD( GetBannerPath );
|
||||
ADD_METHOD( GetStepArtistCredits );
|
||||
ADD_METHOD( GetAuthorsNotes );
|
||||
ADD_METHOD( GetYearReleased );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user