Merge /AdditionalSongs into /Songs, and /AdditionalCourses into /Courses

Includes a backwards-compatibility mechanism to adapt paths when loading
Stats.xml.
This commit is contained in:
Martin Natano
2022-03-11 22:35:31 +01:00
parent 92ce8c6801
commit 0861ed45c7
24 changed files with 38 additions and 131 deletions
+4
View File
@@ -593,6 +593,10 @@ void CourseID::LoadFromNode( const XNode* pNode )
if( !pNode->GetAttrValue("Path", sPath) )
pNode->GetAttrValue( "FullTitle", sFullTitle );
m_Cache.Unset();
// HACK for backwards compatibility: /AdditionalCourses has been merged into /Courses
if (sPath.Left(18) == "AdditionalCourses/")
sPath.replace(0, 18, "Courses/");
}
RString CourseID::ToString() const
-1
View File
@@ -182,7 +182,6 @@ PrefsManager::PrefsManager() :
m_bDelayedModelDelete ( "DelayedModelDelete", false ),
m_ImageCache ( "ImageCache", IMGCACHE_LOW_RES_PRELOAD ),
m_bFastLoad ( "FastLoad", true ),
m_bFastLoadAdditionalSongs ( "FastLoadAdditionalSongs", true ),
m_NeverCacheList ( "NeverCacheList", ""),
m_bOnlyDedicatedMenuButtons ( "OnlyDedicatedMenuButtons", false ),
-1
View File
@@ -174,7 +174,6 @@ public:
Preference<bool> m_bDelayedModelDelete;
Preference<ImageCacheMode> m_ImageCache;
Preference<bool> m_bFastLoad;
Preference<bool> m_bFastLoadAdditionalSongs;
Preference<RString> m_NeverCacheList;
Preference<bool> m_bOnlyDedicatedMenuButtons;
-1
View File
@@ -780,7 +780,6 @@ static void InitializeConfOptions()
ADD( ConfOption( "AutogenGroupCourses", MovePref<bool>, "Off","On" ) );
ADD( ConfOption( "FastLoad", MovePref<bool>, "Off","On" ) );
ADD( ConfOption( "FastLoadAdditionalSongs", MovePref<bool>, "Off","On" ) );
{
ConfOption c("EditRecordModeLeadIn", EditRecordModeLeadIn);
for(int i= 0; i < 32; ++i)
+14 -70
View File
@@ -39,12 +39,9 @@
SongManager* SONGMAN = nullptr; // global and accessible from anywhere in our program
const RString ADDITIONAL_SONGS_DIR = "/AdditionalSongs/";
const RString ADDITIONAL_COURSES_DIR = "/AdditionalCourses/";
const RString EDIT_SUBDIR = "Edits/";
/** @brief The file that contains various random attacks. */
const RString ATTACK_FILE = "/Data/RandomAttacks.txt";
const RString EDIT_SUBDIR = "Edits/";
static const ThemeMetric<RageColor> EXTRA_COLOR ( "SongManager", "ExtraColor" );
static const ThemeMetric<int> EXTRA_COLOR_METER ( "SongManager", "ExtraColorMeter" );
@@ -116,9 +113,7 @@ static LocalizedString SANITY_CHECKING_GROUPS("SongManager", "Sanity checking gr
void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld )
{
FILEMAN->FlushDirCache( SpecialFiles::SONGS_DIR );
FILEMAN->FlushDirCache( ADDITIONAL_SONGS_DIR );
FILEMAN->FlushDirCache( SpecialFiles::COURSES_DIR );
FILEMAN->FlushDirCache( ADDITIONAL_COURSES_DIR );
FILEMAN->FlushDirCache( EDIT_SUBDIR );
if( ld )
@@ -161,11 +156,6 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld )
SONGINDEX->delay_save_cache = true;
IMAGECACHE->delay_save_cache = true;
LoadStepManiaSongDir( SpecialFiles::SONGS_DIR, ld );
const bool bOldVal = PREFSMAN->m_bFastLoad;
PREFSMAN->m_bFastLoad.Set( PREFSMAN->m_bFastLoadAdditionalSongs );
LoadStepManiaSongDir( ADDITIONAL_SONGS_DIR, ld );
PREFSMAN->m_bFastLoad.Set( bOldVal );
LoadEnabledSongsFromPref();
SONGINDEX->SaveCacheIndex();
SONGINDEX->delay_save_cache= false;
@@ -799,11 +789,6 @@ int SongManager::GetNumSelectableAndUnlockedSongs() const
return std::count_if(m_pSongs.begin(), m_pSongs.end(), [](Song const *s) { return UNLOCKMAN->SongIsLocked(s) & ~(LOCKED_LOCK | LOCKED_SELECTABLE); });
}
int SongManager::GetNumAdditionalSongs() const
{
return std::count_if(m_pSongs.begin(), m_pSongs.end(), [&](Song const *s) { return WasLoadedFromAdditionalSongs(s); });
}
int SongManager::GetNumSongGroups() const
{
return m_sSongGroupNames.size();
@@ -814,11 +799,6 @@ int SongManager::GetNumCourses() const
return m_pCourses.size();
}
int SongManager::GetNumAdditionalCourses() const
{
return std::count_if(m_pCourses.begin(), m_pCourses.end(), [&](Course const *c) { return WasLoadedFromAdditionalCourses(c); });
}
int SongManager::GetNumCourseGroups() const
{
return m_mapCourseGroupToInfo.size();
@@ -841,18 +821,11 @@ void SongManager::InitCoursesFromDisk( LoadingWindow *ld )
RageTimer loading_window_last_update_time;
loading_window_last_update_time.Touch();
vector<RString> vsCourseDirs;
vsCourseDirs.push_back( SpecialFiles::COURSES_DIR );
vsCourseDirs.push_back( ADDITIONAL_COURSES_DIR );
vector<RString> vsCourseGroupNames;
for (RString const &sDir : vsCourseDirs)
{
// Find all group directories in Courses dir
GetDirListing( sDir + "*", vsCourseGroupNames, true, true );
StripCvsAndSvn( vsCourseGroupNames );
StripMacResourceForks( vsCourseGroupNames );
}
// Find all group directories in Courses dir
GetDirListing( SpecialFiles::COURSES_DIR + "*", vsCourseGroupNames, true, true );
StripCvsAndSvn( vsCourseGroupNames );
StripMacResourceForks( vsCourseGroupNames );
// Search for courses both in COURSES_DIR and in subdirectories
vsCourseGroupNames.push_back( SpecialFiles::COURSES_DIR );
@@ -1185,18 +1158,6 @@ void SongManager::DeleteSteps( Steps *pSteps )
pSteps->m_pSong->DeleteSteps( pSteps );
}
bool SongManager::WasLoadedFromAdditionalSongs( const Song *pSong ) const
{
RString sDir = pSong->GetSongDir();
return BeginsWith( sDir, ADDITIONAL_SONGS_DIR );
}
bool SongManager::WasLoadedFromAdditionalCourses( const Course *pCourse ) const
{
RString sDir = pCourse->m_sPath;
return BeginsWith( sDir, ADDITIONAL_COURSES_DIR );
}
void SongManager::GetAllCourses( vector<Course*> &AddTo, bool bIncludeAutogen ) const
{
for( unsigned i=0; i<m_pCourses.size(); i++ )
@@ -1225,14 +1186,6 @@ bool SongManager::GetExtraStageInfoFromCourse( bool bExtra2, RString sPreferredG
const RString sCourseSuffix = sPreferredGroup + (bExtra2 ? "/extra2.crs" : "/extra1.crs");
RString sCoursePath = SpecialFiles::SONGS_DIR + sCourseSuffix;
// Couldn't find course in DWI path or alternative song folders
if( !DoesFileExist(sCoursePath) )
{
sCoursePath = ADDITIONAL_SONGS_DIR + sCourseSuffix;
if( !DoesFileExist(sCoursePath) )
return false;
}
Course course;
CourseLoaderCRS::LoadFromCRSFile( sCoursePath, course );
if( course.GetEstimatedNumStages() <= 0 ) return false;
@@ -2022,11 +1975,12 @@ public:
static int GetNumLockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumLockedSongs() ); return 1; }
static int GetNumUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlockedSongs() ); return 1; }
static int GetNumSelectableAndUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSelectableAndUnlockedSongs() ); return 1; }
static int GetNumAdditionalSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumAdditionalSongs() ); return 1; }
static int GetNumAdditionalSongs( T* p, lua_State *L ) { lua_pushnumber( L, 0 ); return 1; } // deprecated
static int GetNumSongGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongGroups() ); return 1; }
static int GetNumCourses( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourses() ); return 1; }
static int GetNumAdditionalCourses( T* p, lua_State *L ){ lua_pushnumber( L, p->GetNumAdditionalCourses() ); return 1; }
static int GetNumAdditionalCourses( T* p, lua_State *L ){ lua_pushnumber( L, 0 ); return 1; } // deprecated
static int GetNumCourseGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourseGroups() ); return 1; }
/* Note: this could now be implemented as Luna<Steps>::GetSong */
static int GetSongFromSteps( T* p, lua_State *L )
{
@@ -2129,18 +2083,8 @@ public:
lua_pushstring(L, p->SongToPreferredSortSectionName(pSong));
return 1;
}
static int WasLoadedFromAdditionalSongs( T* p, lua_State *L )
{
const Song* pSong = Luna<Song>::check(L,1);
lua_pushboolean(L, p->WasLoadedFromAdditionalSongs(pSong));
return 1;
}
static int WasLoadedFromAdditionalCourses( T* p, lua_State *L )
{
const Course* pCourse = Luna<Course>::check(L,1);
lua_pushboolean(L, p->WasLoadedFromAdditionalCourses(pCourse));
return 1;
}
static int WasLoadedFromAdditionalSongs( T* p, lua_State *L ) { lua_pushboolean(L, false); return 1; } // deprecated
static int WasLoadedFromAdditionalCourses( T* p, lua_State *L ) { lua_pushboolean(L, false); return 1; } // deprecated
LunaSongManager()
{
@@ -2155,10 +2099,10 @@ public:
ADD_METHOD( GetNumLockedSongs );
ADD_METHOD( GetNumUnlockedSongs );
ADD_METHOD( GetNumSelectableAndUnlockedSongs );
ADD_METHOD( GetNumAdditionalSongs );
ADD_METHOD( GetNumAdditionalSongs ); // deprecated
ADD_METHOD( GetNumSongGroups );
ADD_METHOD( GetNumCourses );
ADD_METHOD( GetNumAdditionalCourses );
ADD_METHOD( GetNumAdditionalCourses ); // deprecated
ADD_METHOD( GetNumCourseGroups );
ADD_METHOD( GetSongFromSteps );
ADD_METHOD( GetExtraStageInfo );
@@ -2181,8 +2125,8 @@ public:
ADD_METHOD( GetPopularSongs );
ADD_METHOD( GetPopularCourses );
ADD_METHOD( SongToPreferredSortSectionName );
ADD_METHOD( WasLoadedFromAdditionalSongs );
ADD_METHOD( WasLoadedFromAdditionalCourses );
ADD_METHOD( WasLoadedFromAdditionalSongs ); // deprecated
ADD_METHOD( WasLoadedFromAdditionalCourses ); // deprecated
}
};
-4
View File
@@ -132,13 +132,11 @@ public:
int GetNumLockedSongs() const;
int GetNumUnlockedSongs() const;
int GetNumSelectableAndUnlockedSongs() const;
int GetNumAdditionalSongs() const;
int GetNumSongGroups() const;
/**
* @brief Retrieve the number of courses in the game.
* @return the number of courses. */
int GetNumCourses() const;
int GetNumAdditionalCourses() const;
int GetNumCourseGroups() const;
Song* GetRandomSong();
Course* GetRandomCourse();
@@ -148,8 +146,6 @@ public:
void GetStepsLoadedFromProfile( vector<Steps*> &AddTo, ProfileSlot slot ) const;
void DeleteSteps( Steps *pSteps ); // transfers ownership of pSteps
bool WasLoadedFromAdditionalSongs( const Song *pSong ) const;
bool WasLoadedFromAdditionalCourses( const Course *pCourse ) const;
void GetAllCourses( vector<Course*> &AddTo, bool bIncludeAutogen ) const;
void GetCourses( CourseType ct, vector<Course*> &AddTo, bool bIncludeAutogen ) const;
+4
View File
@@ -1147,6 +1147,10 @@ void SongID::LoadFromNode( const XNode* pNode )
ASSERT( pNode->GetName() == "Song" );
pNode->GetAttrValue("Dir", sDir);
m_Cache.Unset();
// HACK for backwards compatibility: /AdditionalSongs has been merged into /Songs
if (sDir.Left(16) == "AdditionalSongs/")
sDir.replace(0, 16, "Songs/");
}
RString SongID::ToString() const
+2 -2
View File
@@ -1034,14 +1034,14 @@ int sm_main(int argc, char* argv[])
vector<RString> dirs;
split( PREFSMAN->m_sAdditionalSongFolders, ",", dirs, true );
for( unsigned i=0; i < dirs.size(); i++)
FILEMAN->Mount( "dir", dirs[i], "/AdditionalSongs" );
FILEMAN->Mount( "dir", dirs[i], "/Songs" );
}
if( PREFSMAN->m_sAdditionalCourseFolders.Get() != "" )
{
vector<RString> dirs;
split( PREFSMAN->m_sAdditionalCourseFolders, ",", dirs, true );
for( unsigned i=0; i < dirs.size(); i++)
FILEMAN->Mount( "dir", dirs[i], "/AdditionalCourses" );
FILEMAN->Mount( "dir", dirs[i], "/Courses" );
}
MountTreeOfZips( SpecialFiles::PACKAGES_DIR );
-8
View File
@@ -25,7 +25,6 @@ UnlockManager* UNLOCKMAN = nullptr; // global and accessible from anywhere in ou
static ThemeMetric<bool> AUTO_LOCK_CHALLENGE_STEPS( "UnlockManager", "AutoLockChallengeSteps" );
static ThemeMetric<bool> AUTO_LOCK_EDIT_STEPS( "UnlockManager", "AutoLockEditSteps" );
static ThemeMetric<bool> SONGS_NOT_ADDITIONAL( "UnlockManager", "SongsNotAdditional" );
static const char *UnlockRequirementNames[] =
{
@@ -522,9 +521,6 @@ void UnlockManager::Load()
if( SongUtil::GetOneSteps(s, StepsType_Invalid, Difficulty_Challenge) == nullptr )
continue;
if( SONGS_NOT_ADDITIONAL && SONGMAN->WasLoadedFromAdditionalSongs(s) )
continue;
UnlockEntry ue;
ue.m_sEntryID = "_challenge_" + s->GetSongDir();
ue.m_Type = UnlockRewardType_Steps;
@@ -547,10 +543,6 @@ void UnlockManager::Load()
if (SongUtil::GetOneSteps(s, StepsType_Invalid, Difficulty_Edit) == nullptr)
continue;
// don't add additional songs.
if (SONGS_NOT_ADDITIONAL && SONGMAN->WasLoadedFromAdditionalSongs(s))
continue;
UnlockEntry ue;
ue.m_sEntryID = "_edit_" + s->GetSongDir();
ue.m_Type = UnlockRewardType_Steps;