From df0f224ae06d4a89e73346dbd53fda1e537ac296 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 28 Apr 2005 21:20:20 +0000 Subject: [PATCH] show totals and unlock totals in Catalog.xml don't show locked in Catalog.xml --- stepmania/src/CatalogXml.cpp | 82 ++++++++++++++++++++++++++++++++++- stepmania/src/CatalogXml.h | 3 +- stepmania/src/SongManager.cpp | 7 --- stepmania/src/StepMania.cpp | 7 ++- 4 files changed, 89 insertions(+), 10 deletions(-) diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp index 1d05dc3730..efa0af9ee6 100644 --- a/stepmania/src/CatalogXml.cpp +++ b/stepmania/src/CatalogXml.cpp @@ -19,6 +19,8 @@ #include "PrefsManager.h" #include "Style.h" #include "CommonMetrics.h" +#include "UnlockManager.h" +#include "arch/LoadingWindow/LoadingWindow.h" #define SHOW_PLAY_MODE(pm) THEME->GetMetricB("CatalogXml",ssprintf("ShowPlayMode%s",PlayModeToString(pm).c_str())) #define SHOW_STYLE(ps) THEME->GetMetricB("CatalogXml",ssprintf("ShowStyle%s",Capitalize((ps)->m_szName).c_str())) @@ -29,8 +31,14 @@ #define FOOTER_TEXT THEME->GetMetric ("CatalogXml","FooterText") #define FOOTER_LINK THEME->GetMetric ("CatalogXml","FooterLink") -void SaveCatalogXml() +void SaveCatalogXml( LoadingWindow *loading_window ) { + ASSERT( SONGMAN ); + ASSERT( UNLOCKMAN ); + + if( loading_window ) + loading_window->SetText( "Saving Catalog.xml ..." ); + CString fn = CATALOG_XML_FILE; LOG->Trace( "Writing %s ...", fn.c_str() ); @@ -40,6 +48,72 @@ void SaveCatalogXml() const vector &vStepsTypesToShow = STEPS_TYPES_TO_SHOW.GetValue(); + { + XNode* pNode = xml.AppendChild( "Totals" ); + + int iTotalSongs = 0; + int iTotalSteps = 0; + FOREACH_CONST( Song*, SONGMAN->GetAllSongs(), i ) + { + Song *pSong = *i; + if( pSong->IsTutorial() ) + continue; // skip + if( UNLOCKMAN->SongIsLocked(pSong) ) + continue; // skip + iTotalSongs++; + + FOREACH_CONST( StepsType, vStepsTypesToShow, st ) + { + FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), dc ) + { + Steps* pSteps = pSong->GetStepsByDifficulty( *st, *dc, false ); // no autogen + if( pSteps == NULL ) + continue; // skip + if( UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) + continue; // skip + iTotalSteps++; + } + } + } + + int iTotalCourses = 0; + vector vpCourses; + SONGMAN->GetAllCourses( vpCourses, false ); + for( unsigned i=0; iIsFixed() ) + continue; + if( UNLOCKMAN->CourseIsLocked(pCourse) ) + continue; + iTotalCourses++; + } + + int iNumUnlockedSongs = 0; + int iNumUnlockedSteps = 0; + int iNumUnlockedCourses = 0; + FOREACH_CONST( UnlockEntry, UNLOCKMAN->m_UnlockEntries, e ) + { + if( e->IsLocked() ) + continue; + switch( e->m_Type ) + { + case UnlockEntry::TYPE_SONG: iNumUnlockedSongs++; break; + case UnlockEntry::TYPE_STEPS: iNumUnlockedSteps++; break; + case UnlockEntry::TYPE_COURSE: iNumUnlockedCourses++; break; + } + } + + pNode->AppendChild( "TotalSongs", iTotalSongs ); + pNode->AppendChild( "TotalSteps", iTotalSteps ); + pNode->AppendChild( "TotalCourses", iTotalCourses ); + pNode->AppendChild( "NumUnlockedSongs", iNumUnlockedSongs ); + pNode->AppendChild( "NumUnlockedSteps", iNumUnlockedSteps ); + pNode->AppendChild( "NumUnlockedCourses", iNumUnlockedCourses ); + } + { XNode* pNode = xml.AppendChild( "Songs" ); @@ -50,6 +124,8 @@ void SaveCatalogXml() if( pSong->IsTutorial() ) continue; // skip + if( UNLOCKMAN->SongIsLocked(pSong) ) + continue; // skip SongID songID; songID.FromSong( pSong ); @@ -68,6 +144,8 @@ void SaveCatalogXml() Steps* pSteps = pSong->GetStepsByDifficulty( *st, *dc, false ); // no autogen if( pSteps == NULL ) continue; // skip + if( UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) + continue; // skip StepsID stepsID; stepsID.FromSteps( pSteps ); @@ -96,6 +174,8 @@ void SaveCatalogXml() // the title. if( !pCourse->IsFixed() ) continue; + if( UNLOCKMAN->CourseIsLocked(pCourse) ) + continue; CourseID courseID; courseID.FromCourse( pCourse ); diff --git a/stepmania/src/CatalogXml.h b/stepmania/src/CatalogXml.h index 64e17c2ee7..92cbd19655 100644 --- a/stepmania/src/CatalogXml.h +++ b/stepmania/src/CatalogXml.h @@ -4,12 +4,13 @@ #define CATALOG_XML_H #include "GameConstantsAndTypes.h" +class LoadingWindow; const CString CATALOG_XML = "Catalog.xml"; const CString CATALOG_XSL = "Catalog.xsl"; const CString CATALOG_XML_FILE = DATA_DIR + "Catalog.xml"; -void SaveCatalogXml(); +void SaveCatalogXml( LoadingWindow *ld ); #endif diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 5bf4e71f83..fe93c7cf58 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -26,7 +26,6 @@ #include "CourseUtil.h" #include "RageFileManager.h" #include "UnlockManager.h" -#include "CatalogXml.h" #include "Foreach.h" #include "StatsManager.h" #include "Style.h" @@ -84,12 +83,6 @@ void SongManager::InitAll( LoadingWindow *ld ) InitSongsFromDisk( ld ); InitCoursesFromDisk( ld ); InitAutogenCourses(); - - /* This shouldn't need to be here; if it's taking long enough that this is - * even visible, we should be fixing it, not showing a progress display. */ - if( ld ) - ld->SetText( "Saving Catalog.xml ..." ); - SaveCatalogXml(); } void SongManager::Reload( LoadingWindow *ld ) diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 85ab1bbb95..f0a53ead27 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -34,8 +34,8 @@ #include "Game.h" #include "RageSurface.h" #include "RageSurface_Load.h" - #include "arch/arch.h" +#include "CatalogXml.h" // // StepMania global classes @@ -1125,6 +1125,11 @@ int main(int argc, char* argv[]) PROFILEMAN = new ProfileManager; PROFILEMAN->Init(); // must load after SONGMAN UNLOCKMAN = new UnlockManager; + + /* This shouldn't need to be here; if it's taking long enough that this is + * even visible, we should be fixing it, not showing a progress display. */ + SaveCatalogXml( loading_window ); + NSMAN = new NetworkSyncManager( loading_window ); MESSAGEMAN = new MessageManager; STATSMAN = new StatsManager;