Move GetGroup to SONGMAN, rename variables consistently, move "pack.ini" to constant var, flip sync bias sign
This commit is contained in:
+29
-21
@@ -14,6 +14,14 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief The file that contains the group information.
|
||||||
|
* We name this Pack.ini over Group.ini to avoid conflict
|
||||||
|
* with the Waiei Group.ini-lua project still actively
|
||||||
|
* being developed.
|
||||||
|
*/
|
||||||
|
const RString INI_FILE = "Pack.ini";
|
||||||
|
|
||||||
Group::Group() {
|
Group::Group() {
|
||||||
m_sDisplayTitle = "";
|
m_sDisplayTitle = "";
|
||||||
m_sSortTitle = "";
|
m_sSortTitle = "";
|
||||||
@@ -32,12 +40,12 @@ Group::~Group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Group::Group(const RString& sDir, const RString& sGroupDirName) {
|
Group::Group(const RString& sDir, const RString& sGroupDirName) {
|
||||||
RString sPackIniPath = sDir + sGroupDirName + "/pack.ini";
|
RString sPackIniPath = sDir + sGroupDirName + "/" + INI_FILE;
|
||||||
RString sDisplayTitle = sGroupDirName;
|
RString sDisplayTitle = sGroupDirName;
|
||||||
RString SortTitle = sGroupDirName;
|
RString sSortTitle = sGroupDirName;
|
||||||
RString TranslitTitle = "";
|
RString sTranslitTitle = "";
|
||||||
RString Series = "";
|
RString sSeries = "";
|
||||||
RString bannerPath = "";
|
RString sBannerPath = "";
|
||||||
float fOffset = PREFSMAN->m_fMachineSyncBias;
|
float fOffset = PREFSMAN->m_fMachineSyncBias;
|
||||||
|
|
||||||
if (FILEMAN->DoesFileExist(sPackIniPath)) {
|
if (FILEMAN->DoesFileExist(sPackIniPath)) {
|
||||||
@@ -48,18 +56,18 @@ Group::Group(const RString& sDir, const RString& sGroupDirName) {
|
|||||||
if (sDisplayTitle.empty()) {
|
if (sDisplayTitle.empty()) {
|
||||||
sDisplayTitle = Basename(sGroupDirName);
|
sDisplayTitle = Basename(sGroupDirName);
|
||||||
}
|
}
|
||||||
ini.GetValue("Group", "Banner", bannerPath);
|
ini.GetValue("Group", "Banner", sBannerPath);
|
||||||
ini.GetValue("Group", "SortTitle", SortTitle);
|
ini.GetValue("Group", "SortTitle", sSortTitle);
|
||||||
Trim(SortTitle);
|
Trim(sSortTitle);
|
||||||
if (SortTitle.empty()) {
|
if (sSortTitle.empty()) {
|
||||||
SortTitle = sDisplayTitle;
|
sSortTitle = sDisplayTitle;
|
||||||
}
|
}
|
||||||
ini.GetValue("Group", "TranslitTitle", TranslitTitle);
|
ini.GetValue("Group", "TranslitTitle", sTranslitTitle);
|
||||||
Trim(TranslitTitle);
|
Trim(sTranslitTitle);
|
||||||
if (TranslitTitle.empty()) {
|
if (sTranslitTitle.empty()) {
|
||||||
TranslitTitle = sDisplayTitle;
|
sTranslitTitle = sDisplayTitle;
|
||||||
}
|
}
|
||||||
ini.GetValue("Group", "Series", Series);
|
ini.GetValue("Group", "Series", sSeries);
|
||||||
RString sValue = "";
|
RString sValue = "";
|
||||||
|
|
||||||
ini.GetValue("Group", "SyncOffset", sValue);
|
ini.GetValue("Group", "SyncOffset", sValue);
|
||||||
@@ -68,7 +76,7 @@ Group::Group(const RString& sDir, const RString& sGroupDirName) {
|
|||||||
if (sValue.CompareNoCase("null") == 0) {
|
if (sValue.CompareNoCase("null") == 0) {
|
||||||
fOffset = 0.0f;
|
fOffset = 0.0f;
|
||||||
} else if (sValue.CompareNoCase("itg") == 0) {
|
} else if (sValue.CompareNoCase("itg") == 0) {
|
||||||
fOffset = 0.009f;
|
fOffset = -0.009f;
|
||||||
} else {
|
} else {
|
||||||
fOffset = StringToFloat(sValue);
|
fOffset = StringToFloat(sValue);
|
||||||
}
|
}
|
||||||
@@ -84,9 +92,9 @@ Group::Group(const RString& sDir, const RString& sGroupDirName) {
|
|||||||
std::vector<RString> arrayGroupBanners;
|
std::vector<RString> arrayGroupBanners;
|
||||||
|
|
||||||
// First check if there is a banner provided in pack.ini
|
// First check if there is a banner provided in pack.ini
|
||||||
if(!bannerPath.empty())
|
if(!sBannerPath.empty())
|
||||||
{
|
{
|
||||||
GetDirListing(sDir + sGroupDirName + "/" + bannerPath, arrayGroupBanners);
|
GetDirListing(sDir + sGroupDirName + "/" + sBannerPath, arrayGroupBanners);
|
||||||
}
|
}
|
||||||
GetDirListing(sDir + sGroupDirName + "/*.png", arrayGroupBanners);
|
GetDirListing(sDir + sGroupDirName + "/*.png", arrayGroupBanners);
|
||||||
GetDirListing(sDir + sGroupDirName + "/*.jpg", arrayGroupBanners);
|
GetDirListing(sDir + sGroupDirName + "/*.jpg", arrayGroupBanners);
|
||||||
@@ -140,9 +148,9 @@ Group::Group(const RString& sDir, const RString& sGroupDirName) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
m_sDisplayTitle = sDisplayTitle;
|
m_sDisplayTitle = sDisplayTitle;
|
||||||
m_sSortTitle = SortTitle;
|
m_sSortTitle = sSortTitle;
|
||||||
m_sTranslitTitle = TranslitTitle;
|
m_sTranslitTitle = sTranslitTitle;
|
||||||
m_sSeries = Series;
|
m_sSeries = sSeries;
|
||||||
m_sPath = sDir + sGroupDirName;
|
m_sPath = sDir + sGroupDirName;
|
||||||
m_sGroupName = sGroupDirName;
|
m_sGroupName = sGroupDirName;
|
||||||
m_fSyncOffset = fOffset;
|
m_fSyncOffset = fOffset;
|
||||||
|
|||||||
+2
-2
@@ -755,7 +755,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
|||||||
for( unsigned i=0; i< arraySongs.size(); i++ )
|
for( unsigned i=0; i< arraySongs.size(); i++ )
|
||||||
{
|
{
|
||||||
Song* pSong = arraySongs[i];
|
Song* pSong = arraySongs[i];
|
||||||
Group* pGroup = pSong->GetGroup();
|
Group* pGroup = SONGMAN->GetGroup(pSong);
|
||||||
if( bUseSections )
|
if( bUseSections )
|
||||||
{
|
{
|
||||||
RString sThisSection = pGroup->GetGroupName();
|
RString sThisSection = pGroup->GetGroupName();
|
||||||
@@ -812,7 +812,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
|||||||
sLastSection = sThisSection;
|
sLastSection = sThisSection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, nullptr, pSong->GetGroup(), SONGMAN->GetSongColor(pSong), 0) );
|
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, nullptr, SONGMAN->GetGroup(pSong), SONGMAN->GetSongColor(pSong), 0) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-13
@@ -277,10 +277,6 @@ const RString &Song::GetSongFilePath() const
|
|||||||
* <set> into Song.h, which is heavily used. */
|
* <set> into Song.h, which is heavily used. */
|
||||||
static std::set<RString> BlacklistedImages;
|
static std::set<RString> BlacklistedImages;
|
||||||
|
|
||||||
Group* Song::GetGroup() const
|
|
||||||
{
|
|
||||||
return SONGMAN->GetGroupFromName(m_sGroupName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If PREFSMAN->m_bFastLoad is true, always load from cache if possible.
|
/* If PREFSMAN->m_bFastLoad is true, always load from cache if possible.
|
||||||
* Don't read the contents of sDir if we can avoid it. That means we can't call
|
* Don't read the contents of sDir if we can avoid it. That means we can't call
|
||||||
@@ -481,7 +477,7 @@ bool Song::ReloadFromSongDir( RString sDir )
|
|||||||
return false;
|
return false;
|
||||||
copy.RemoveAutoGenNotes();
|
copy.RemoveAutoGenNotes();
|
||||||
*this = copy;
|
*this = copy;
|
||||||
m_SongTiming.m_fBeat0GroupOffsetInSeconds = GetGroup()->GetSyncOffset();
|
m_SongTiming.m_fBeat0GroupOffsetInSeconds = SONGMAN->GetGroupFromName(m_sGroupName)->GetSyncOffset();
|
||||||
|
|
||||||
/* Go through the steps, first setting their Song pointer to this song
|
/* Go through the steps, first setting their Song pointer to this song
|
||||||
* (instead of the copy used above), and constructing a map to let us
|
* (instead of the copy used above), and constructing a map to let us
|
||||||
@@ -497,7 +493,7 @@ bool Song::ReloadFromSongDir( RString sDir )
|
|||||||
// Reapply the Group Offset if the steps have their own timing data.
|
// Reapply the Group Offset if the steps have their own timing data.
|
||||||
if( mNewSteps[id]->m_Timing.empty() )
|
if( mNewSteps[id]->m_Timing.empty() )
|
||||||
continue;
|
continue;
|
||||||
mNewSteps[id]->m_Timing.m_fBeat0GroupOffsetInSeconds = GetGroup()->GetSyncOffset();
|
mNewSteps[id]->m_Timing.m_fBeat0GroupOffsetInSeconds = SONGMAN->GetGroupFromName(m_sGroupName)->GetSyncOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we wipe out the new pointers, which were shallow copied and not deep copied...
|
// Now we wipe out the new pointers, which were shallow copied and not deep copied...
|
||||||
@@ -2281,12 +2277,6 @@ public:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetGroup( T* p, lua_State *L )
|
|
||||||
{
|
|
||||||
p->GetGroup()->PushSelf(L);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int MusicLengthSeconds( T* p, lua_State *L )
|
static int MusicLengthSeconds( T* p, lua_State *L )
|
||||||
{
|
{
|
||||||
lua_pushnumber(L, p->m_fMusicLengthSeconds);
|
lua_pushnumber(L, p->m_fMusicLengthSeconds);
|
||||||
@@ -2506,7 +2496,6 @@ public:
|
|||||||
ADD_METHOD( IsEnabled );
|
ADD_METHOD( IsEnabled );
|
||||||
ADD_METHOD(IsCustomSong);
|
ADD_METHOD(IsCustomSong);
|
||||||
ADD_METHOD( GetGroupName );
|
ADD_METHOD( GetGroupName );
|
||||||
ADD_METHOD( GetGroup );
|
|
||||||
ADD_METHOD( MusicLengthSeconds );
|
ADD_METHOD( MusicLengthSeconds );
|
||||||
ADD_METHOD( GetSampleStart );
|
ADD_METHOD( GetSampleStart );
|
||||||
ADD_METHOD( GetSampleLength );
|
ADD_METHOD( GetSampleLength );
|
||||||
|
|||||||
@@ -209,8 +209,6 @@ public:
|
|||||||
RString GetDisplayArtist() const;
|
RString GetDisplayArtist() const;
|
||||||
RString GetMainTitle() const;
|
RString GetMainTitle() const;
|
||||||
|
|
||||||
Group* GetGroup() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Retrieve the transliterated title, or the main title if there is no translit.
|
* @brief Retrieve the transliterated title, or the main title if there is no translit.
|
||||||
* @return the proper title. */
|
* @return the proper title. */
|
||||||
|
|||||||
@@ -595,6 +595,7 @@ RString SongManager::GetSongGroupBackgroundPath( RString sSongGroup ) const
|
|||||||
return RString();
|
return RString();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void SongManager::GetSongGroupNames( std::vector<RString> &AddTo ) const
|
void SongManager::GetSongGroupNames( std::vector<RString> &AddTo ) const
|
||||||
{
|
{
|
||||||
AddTo.insert(AddTo.end(), m_sSongGroupNames.begin(), m_sSongGroupNames.end() );
|
AddTo.insert(AddTo.end(), m_sSongGroupNames.begin(), m_sSongGroupNames.end() );
|
||||||
@@ -851,6 +852,11 @@ std::vector<Song*> SongManager::GetPreferredSortSongsBySectionName( const RStrin
|
|||||||
return AddTo;
|
return AddTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Group* SongManager::GetGroup( const Song* pSong ) const
|
||||||
|
{
|
||||||
|
return GetGroupFromName( pSong->m_sGroupName );
|
||||||
|
}
|
||||||
|
|
||||||
Group* SongManager::GetGroupFromName( const RString& sGroupName ) const
|
Group* SongManager::GetGroupFromName( const RString& sGroupName ) const
|
||||||
{
|
{
|
||||||
auto iter = m_mapGroupsByName.find( sGroupName );
|
auto iter = m_mapGroupsByName.find( sGroupName );
|
||||||
@@ -2236,6 +2242,17 @@ public:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int GetGroup( T* p, lua_State *L )
|
||||||
|
{
|
||||||
|
Song *pSong = Luna<Song>::check(L,1);
|
||||||
|
Group *pGroup = p->GetGroup(pSong);
|
||||||
|
if( pGroup != nullptr )
|
||||||
|
pGroup->PushSelf(L);
|
||||||
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int GetSongsInGroup( T* p, lua_State *L )
|
static int GetSongsInGroup( T* p, lua_State *L )
|
||||||
{
|
{
|
||||||
std::vector<Song*> v = p->GetSongs(SArg(1));
|
std::vector<Song*> v = p->GetSongs(SArg(1));
|
||||||
@@ -2321,6 +2338,7 @@ public:
|
|||||||
ADD_METHOD( GetCourseColor );
|
ADD_METHOD( GetCourseColor );
|
||||||
ADD_METHOD( GetSongRank );
|
ADD_METHOD( GetSongRank );
|
||||||
ADD_METHOD( GetSongGroupNames );
|
ADD_METHOD( GetSongGroupNames );
|
||||||
|
ADD_METHOD( GetGroup );
|
||||||
ADD_METHOD( GetSongsInGroup );
|
ADD_METHOD( GetSongsInGroup );
|
||||||
ADD_METHOD( GetCoursesInGroup );
|
ADD_METHOD( GetCoursesInGroup );
|
||||||
ADD_METHOD( ShortenGroupName );
|
ADD_METHOD( ShortenGroupName );
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ public:
|
|||||||
std::map<RString, Group*> GetGroupGroupMap() const { return m_mapGroupsByName;};
|
std::map<RString, Group*> GetGroupGroupMap() const { return m_mapGroupsByName;};
|
||||||
std::map<RString, std::vector<Group*>> GetSeriesGroupMap() const { return m_mapSeries;};
|
std::map<RString, std::vector<Group*>> GetSeriesGroupMap() const { return m_mapSeries;};
|
||||||
Group* GetGroupFromName( const RString &sGroupName ) const;
|
Group* GetGroupFromName( const RString &sGroupName ) const;
|
||||||
|
Group* GetGroup( const Song *pSong ) const;
|
||||||
std::vector<RString> GetPreferredSortSectionNames() const;
|
std::vector<RString> GetPreferredSortSectionNames() const;
|
||||||
std::vector<Song*> GetPreferredSortSongsBySectionName( const RString &sSectionName ) const;
|
std::vector<Song*> GetPreferredSortSongsBySectionName( const RString &sSectionName ) const;
|
||||||
void GetPreferredSortSongsBySectionName( const RString &sSectionName, std::vector<Song*> &AddTo ) const;
|
void GetPreferredSortSongsBySectionName( const RString &sSectionName, std::vector<Song*> &AddTo ) const;
|
||||||
|
|||||||
+5
-5
@@ -596,12 +596,12 @@ void SongUtil::SortSongPointerArrayByGenre( std::vector<Song*> &vpSongsInOut )
|
|||||||
int SongUtil::CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2)
|
int SongUtil::CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2)
|
||||||
{
|
{
|
||||||
// Check if the sort title exists
|
// Check if the sort title exists
|
||||||
if( pSong1->GetGroup()->GetSortTitle().empty() || pSong2->GetGroup()->GetSortTitle().empty() ) {
|
if( SONGMAN->GetGroup(pSong1)->GetSortTitle().empty() || SONGMAN->GetGroup(pSong2)->GetSortTitle().empty() ) {
|
||||||
// LOG the DEETS
|
// LOG the DEETS
|
||||||
LOG->Warn("SongUtil::CompareSongPointersByGroup: Song %s or %s has an empty group name. Using group name instead.", pSong1->m_sSongName.c_str(), pSong2->m_sSongName.c_str());
|
LOG->Warn("SongUtil::CompareSongPointersByGroup: Song %s or %s has an empty group name. Using group name instead.", pSong1->m_sSongName.c_str(), pSong2->m_sSongName.c_str());
|
||||||
return pSong1->m_sGroupName < pSong2->m_sGroupName;
|
return pSong1->m_sGroupName < pSong2->m_sGroupName;
|
||||||
} else {
|
} else {
|
||||||
return pSong1->GetGroup()->GetSortTitle() < pSong2->GetGroup()->GetSortTitle();
|
return SONGMAN->GetGroup(pSong1)->GetSortTitle() < SONGMAN->GetGroup(pSong2)->GetSortTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,8 +609,8 @@ static int CompareSongPointersByGroupAndTitle( const Song *pSong1, const Song *p
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Check if the sort title exists
|
// Check if the sort title exists
|
||||||
const RString &sGroup1 = pSong1->GetGroup()->GetSortTitle();
|
const RString &sGroup1 = SONGMAN->GetGroup(pSong1)->GetSortTitle();
|
||||||
const RString &sGroup2 = pSong2->GetGroup()->GetSortTitle();
|
const RString &sGroup2 = SONGMAN->GetGroup(pSong2)->GetSortTitle();
|
||||||
|
|
||||||
if( sGroup1 < sGroup2 )
|
if( sGroup1 < sGroup2 )
|
||||||
return true;
|
return true;
|
||||||
@@ -655,7 +655,7 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
|
|||||||
return SONGMAN->SongToPreferredSortSectionName( pSong );
|
return SONGMAN->SongToPreferredSortSectionName( pSong );
|
||||||
case SORT_GROUP:
|
case SORT_GROUP:
|
||||||
// guaranteed not empty
|
// guaranteed not empty
|
||||||
return pSong->GetGroup()->GetSortTitle();
|
return SONGMAN->GetGroup(pSong)->GetSortTitle();
|
||||||
case SORT_TITLE:
|
case SORT_TITLE:
|
||||||
case SORT_ARTIST:
|
case SORT_ARTIST:
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user