Add Group() for USB songs
This commit is contained in:
+13
-5
@@ -41,11 +41,19 @@ Group::~Group()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Group::Group(const RString& sDir, const RString& sGroupDirName) {
|
Group::Group(const RString& sDir, const RString& sGroupDirName, bool bFromProfile) {
|
||||||
RString sPackIniPath = sDir + sGroupDirName + "/" + INI_FILE;
|
RString sPackIniPath;
|
||||||
m_sPath = sDir + sGroupDirName;
|
if (bFromProfile) {
|
||||||
m_sGroupName = Basename(sGroupDirName);
|
sPackIniPath = sDir + "/" + INI_FILE;
|
||||||
m_sDisplayTitle = m_sGroupName;
|
m_sPath = sDir;
|
||||||
|
m_sGroupName = sDir.substr(1, sDir.find('/', 1) - 1);
|
||||||
|
m_sDisplayTitle = sGroupDirName;
|
||||||
|
} else {
|
||||||
|
sPackIniPath = sDir + sGroupDirName + "/" + INI_FILE;
|
||||||
|
m_sPath = sDir + sGroupDirName;
|
||||||
|
m_sGroupName = Basename(sGroupDirName);
|
||||||
|
m_sDisplayTitle = m_sGroupName;
|
||||||
|
}
|
||||||
m_sSortTitle = m_sGroupName;
|
m_sSortTitle = m_sGroupName;
|
||||||
m_sTranslitTitle = m_sGroupName;
|
m_sTranslitTitle = m_sGroupName;
|
||||||
m_sSeries = "";
|
m_sSeries = "";
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ class Group
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Group();
|
Group();
|
||||||
Group( const RString& sDir, const RString& sGroupDirName);
|
Group( const RString& sDir, const RString& sGroupDirName, bool bFromProfile = false);
|
||||||
~Group();
|
~Group();
|
||||||
// Lua
|
// Lua
|
||||||
void PushSelf( lua_State *L );
|
void PushSelf( lua_State *L );
|
||||||
|
|||||||
+16
-1
@@ -6,6 +6,7 @@
|
|||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include "GameManager.h"
|
#include "GameManager.h"
|
||||||
#include "GameState.h"
|
#include "GameState.h"
|
||||||
|
#include "Group.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "Song.h"
|
#include "Song.h"
|
||||||
#include "SongManager.h"
|
#include "SongManager.h"
|
||||||
@@ -96,6 +97,11 @@ void Profile::ClearSongs()
|
|||||||
delete curr_song;
|
delete curr_song;
|
||||||
}
|
}
|
||||||
m_songs.clear();
|
m_songs.clear();
|
||||||
|
|
||||||
|
if (m_group != nullptr)
|
||||||
|
{
|
||||||
|
delete m_group;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Profile::HighScoresForASong::GetNumTimesPlayed() const
|
int Profile::HighScoresForASong::GetNumTimesPlayed() const
|
||||||
@@ -1181,7 +1187,7 @@ ProfileLoadResult Profile::LoadAllFromDir( RString sDir, bool bRequireSignature
|
|||||||
// entire song list to remove custom songs when unloading the profile is
|
// entire song list to remove custom songs when unloading the profile is
|
||||||
// wasteful. -Kyz
|
// wasteful. -Kyz
|
||||||
|
|
||||||
void Profile::LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot)
|
void Profile::LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot, bool isMemoryCard)
|
||||||
{
|
{
|
||||||
if(!PREFSMAN->m_custom_songs_enable)
|
if(!PREFSMAN->m_custom_songs_enable)
|
||||||
{
|
{
|
||||||
@@ -1198,6 +1204,10 @@ void Profile::LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot)
|
|||||||
|
|
||||||
StripCvsAndSvn(song_folders);
|
StripCvsAndSvn(song_folders);
|
||||||
StripMacResourceForks(song_folders);
|
StripMacResourceForks(song_folders);
|
||||||
|
|
||||||
|
Group* group = new Group(songs_folder, GetDisplayNameOrHighScoreName(), true);
|
||||||
|
m_group = group;
|
||||||
|
|
||||||
LOG->Trace("Found %i songs in profile.", int(song_folders.size()));
|
LOG->Trace("Found %i songs in profile.", int(song_folders.size()));
|
||||||
// Only songs that are successfully loaded count towards the limit. -Kyz
|
// Only songs that are successfully loaded count towards the limit. -Kyz
|
||||||
for(size_t song_index= 0; song_index < song_folders.size()
|
for(size_t song_index= 0; song_index < song_folders.size()
|
||||||
@@ -1224,6 +1234,11 @@ void Profile::LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot)
|
|||||||
}
|
}
|
||||||
float load_time= song_load_start_time.Ago();
|
float load_time= song_load_start_time.Ago();
|
||||||
LOG->Trace("Successfully loaded %zu songs in %.6f from profile.", m_songs.size(), load_time);
|
LOG->Trace("Successfully loaded %zu songs in %.6f from profile.", m_songs.size(), load_time);
|
||||||
|
|
||||||
|
if (m_songs.size() <= 0) {
|
||||||
|
delete m_group;
|
||||||
|
m_group = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-1
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
#include "Grade.h"
|
#include "Grade.h"
|
||||||
|
#include "Group.h"
|
||||||
#include "HighScore.h"
|
#include "HighScore.h"
|
||||||
#include "DateTime.h"
|
#include "DateTime.h"
|
||||||
#include "SongUtil.h" // for SongID
|
#include "SongUtil.h" // for SongID
|
||||||
@@ -205,6 +206,7 @@ public:
|
|||||||
std::map<RString,RString> m_sDefaultModifiers;
|
std::map<RString,RString> m_sDefaultModifiers;
|
||||||
SortOrder m_SortOrder;
|
SortOrder m_SortOrder;
|
||||||
std::vector<Song*> m_songs;
|
std::vector<Song*> m_songs;
|
||||||
|
Group* m_group;
|
||||||
Difficulty m_LastDifficulty;
|
Difficulty m_LastDifficulty;
|
||||||
CourseDifficulty m_LastCourseDifficulty;
|
CourseDifficulty m_LastCourseDifficulty;
|
||||||
StepsType m_LastStepsType;
|
StepsType m_LastStepsType;
|
||||||
@@ -403,7 +405,7 @@ public:
|
|||||||
void HandleStatsPrefixChange(RString dir, bool require_signature);
|
void HandleStatsPrefixChange(RString dir, bool require_signature);
|
||||||
ProfileLoadResult LoadAllFromDir( RString sDir, bool bRequireSignature );
|
ProfileLoadResult LoadAllFromDir( RString sDir, bool bRequireSignature );
|
||||||
ProfileLoadResult LoadStatsFromDir(RString dir, bool require_signature);
|
ProfileLoadResult LoadStatsFromDir(RString dir, bool require_signature);
|
||||||
void LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot);
|
void LoadSongsFromDir(RString const& dir, ProfileSlot prof_slot, bool isMemoryCard = true);
|
||||||
void LoadTypeFromDir(RString dir);
|
void LoadTypeFromDir(RString dir);
|
||||||
void LoadCustomFunction(RString sDir, PlayerNumber pn);
|
void LoadCustomFunction(RString sDir, PlayerNumber pn);
|
||||||
bool SaveAllToDir( RString sDir, bool bSignData ) const;
|
bool SaveAllToDir( RString sDir, bool bSignData ) const;
|
||||||
|
|||||||
+1
-1
@@ -311,7 +311,7 @@ bool Song::LoadFromSongDir(RString sDir, bool load_autosave, ProfileSlot from_pr
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_LoadedFromProfile= from_profile;
|
m_LoadedFromProfile= from_profile;
|
||||||
m_sGroupName= PROFILEMAN->GetProfile(from_profile)->m_sDisplayName;
|
m_sGroupName= sDir.substr(1, sDir.find('/', 1) - 1);
|
||||||
use_cache= false;
|
use_cache= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-8
@@ -271,6 +271,13 @@ void SongManager::SanityCheckGroupDir( RString sDir ) const
|
|||||||
|
|
||||||
void SongManager::AddGroup( RString sDir, RString sGroupDirName, Group* group )
|
void SongManager::AddGroup( RString sDir, RString sGroupDirName, Group* group )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if ( group == nullptr ) {
|
||||||
|
// Could not AddGroup 'sGroupDirName'. Group object is null.
|
||||||
|
LOG->Warn( "Could not AddGroup '%s'. Group object is null.", sGroupDirName.c_str() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned j;
|
unsigned j;
|
||||||
for(j = 0; j < m_sSongGroupNames.size(); ++j)
|
for(j = 0; j < m_sSongGroupNames.size(); ++j)
|
||||||
if( sGroupDirName == m_sSongGroupNames[j] )
|
if( sGroupDirName == m_sSongGroupNames[j] )
|
||||||
@@ -279,12 +286,6 @@ void SongManager::AddGroup( RString sDir, RString sGroupDirName, Group* group )
|
|||||||
if( j != m_sSongGroupNames.size() )
|
if( j != m_sSongGroupNames.size() )
|
||||||
return; // the group is already added
|
return; // the group is already added
|
||||||
|
|
||||||
if ( group == nullptr ) {
|
|
||||||
// Could not AddGroup 'sGroupDirName'. Group object is null.
|
|
||||||
LOG->Warn( "Could not AddGroup '%s'. Group object is null.", sGroupDirName.c_str() );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RString sBannerPath;
|
RString sBannerPath;
|
||||||
|
|
||||||
// Look for a group banner in this group folder
|
// Look for a group banner in this group folder
|
||||||
@@ -706,7 +707,7 @@ RageColor SongManager::GetSongGroupColor( const RString &sSongGroup ) const
|
|||||||
Profile* prof= PROFILEMAN->GetProfile(pn);
|
Profile* prof= PROFILEMAN->GetProfile(pn);
|
||||||
if(prof != nullptr)
|
if(prof != nullptr)
|
||||||
{
|
{
|
||||||
if(prof->GetDisplayNameOrHighScoreName() == sSongGroup)
|
if(prof->m_group->GetGroupName() == sSongGroup)
|
||||||
{
|
{
|
||||||
return profile_song_group_colors.GetValue(pn % num_profile_song_group_colors);
|
return profile_song_group_colors.GetValue(pn % num_profile_song_group_colors);
|
||||||
}
|
}
|
||||||
@@ -880,7 +881,7 @@ const std::vector<Song*> &SongManager::GetSongs( const RString &sGroupName ) con
|
|||||||
Profile* prof= PROFILEMAN->GetProfile(pn);
|
Profile* prof= PROFILEMAN->GetProfile(pn);
|
||||||
if(prof != nullptr)
|
if(prof != nullptr)
|
||||||
{
|
{
|
||||||
if(prof->GetDisplayNameOrHighScoreName() == sGroupName)
|
if(prof->m_group->GetGroupName() == sGroupName)
|
||||||
{
|
{
|
||||||
return prof->m_songs;
|
return prof->m_songs;
|
||||||
}
|
}
|
||||||
@@ -938,6 +939,17 @@ Group* SongManager::GetGroupFromName( const RString& sGroupName ) const
|
|||||||
auto iter = m_mapNameToGroup.find( sGroupName );
|
auto iter = m_mapNameToGroup.find( sGroupName );
|
||||||
if( iter != m_mapNameToGroup.end() )
|
if( iter != m_mapNameToGroup.end() )
|
||||||
return iter->second;
|
return iter->second;
|
||||||
|
FOREACH_EnabledPlayer(pn)
|
||||||
|
{
|
||||||
|
Profile* prof= PROFILEMAN->GetProfile(pn);
|
||||||
|
if(prof != nullptr)
|
||||||
|
{
|
||||||
|
if(prof->m_group->GetGroupName() == sGroupName)
|
||||||
|
{
|
||||||
|
return prof->m_group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user