From a85f967e69e814bd57aae3841f8608a6472cf640 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 20 May 2004 08:55:26 +0000 Subject: [PATCH] write Catalog.xml that contains song and course metadata - useful for importing into other tools --- stepmania/src/CatalogXml.cpp | 55 +++++++++++++++++++++++++++++ stepmania/src/CatalogXml.h | 18 ++++++++++ stepmania/src/Makefile.am | 3 +- stepmania/src/Profile.cpp | 3 ++ stepmania/src/ProfileHtml.cpp | 64 ++++++++++++++++------------------ stepmania/src/StepMania.dsp | 39 +++++++++++++++++---- stepmania/src/StepMania.vcproj | 6 ++++ 7 files changed, 147 insertions(+), 41 deletions(-) create mode 100644 stepmania/src/CatalogXml.cpp create mode 100644 stepmania/src/CatalogXml.h diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp new file mode 100644 index 0000000000..7f75b2b98f --- /dev/null +++ b/stepmania/src/CatalogXml.cpp @@ -0,0 +1,55 @@ +#include "global.h" +/* +----------------------------------------------------------------------------- + Class: CatalogXml + + Desc: See header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "CatalogXml.h" +#include "SongManager.h" +#include "song.h" +#include "Steps.h" + +const CString CATALOG_XML = "Catalog.xml"; + +void SaveCatalogXml( CString sDir ) +{ + CString fn = sDir + CATALOG_XML; + + XNode xml; + xml.name = "Catalog"; + + vector vpSongs = SONGMAN->GetAllSongs(); + for( unsigned i=0; i vpSteps = pSong->GetAllSteps(); + for( unsigned j=0; jIsAutogen() ) + continue; + + StepsID stepsID; + stepsID.FromSteps( pSteps ); + + pSongNode->AppendChild( stepsID.CreateNode() ); + } + } + + bool bSaved = xml.SaveToFile(fn); +} diff --git a/stepmania/src/CatalogXml.h b/stepmania/src/CatalogXml.h new file mode 100644 index 0000000000..9ab81ab69e --- /dev/null +++ b/stepmania/src/CatalogXml.h @@ -0,0 +1,18 @@ +#ifndef CatalogXml_H +#define CatalogXml_H +/* +----------------------------------------------------------------------------- + Class: CatalogXml + + Desc: Helpers for generating an HTML web page based on Profile data. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "Profile.h" + +void SaveCatalogXml( CString sDir ); + +#endif diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index c361387ca7..b2e95f2cce 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -48,7 +48,8 @@ ScreenTestLights.cpp ScreenTestLights.h ScreenTestSound.cpp ScreenTestSound.h Sc ScreenTitleMenu.cpp ScreenTitleMenu.h ScreenUnlock.cpp ScreenUnlock.h ScreenWithMenuElements.cpp ScreenWithMenuElements.h DataStructures = \ -Attack.cpp Attack.h BannerCache.cpp BannerCache.h Character.cpp Character.h CharacterHead.cpp CharacterHead.h \ +Attack.cpp Attack.h BannerCache.cpp BannerCache.h CatalogXml.cpp CatalogXml.h \ +Character.cpp Character.h CharacterHead.cpp CharacterHead.h \ CodeDetector.cpp CodeDetector.h EnumHelper.cpp EnumHelper.h Course.cpp Course.h CourseUtil.cpp CourseUtil.h \ Font.cpp Font.h FontCharAliases.cpp FontCharAliases.h \ FontCharmaps.cpp FontCharmaps.h Game.h GameConstantsAndTypes.cpp GameConstantsAndTypes.h GameDef.cpp GameDef.h \ diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index a842421fe0..a7e4bbd8a6 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -31,6 +31,7 @@ #include "ScoreKeeperMAX2.h" #include "crypto/CryptRand.h" #include "UnlockSystem.h" +#include "CatalogXml.h" // // Old file versions for backward compatibility @@ -1656,6 +1657,8 @@ void Profile::SaveStatsWebPageToDir( CString sDir ) const PROFILEMAN->GetMachineProfile(), bThisIsMachineProfile ? HTML_TYPE_MACHINE : HTML_TYPE_PLAYER ); + if( bThisIsMachineProfile ) + SaveCatalogXml( sDir ); } void Profile::SaveMachinePublicKeyToDir( CString sDir ) const diff --git a/stepmania/src/ProfileHtml.cpp b/stepmania/src/ProfileHtml.cpp index 63364df0f4..6bd2316399 100644 --- a/stepmania/src/ProfileHtml.cpp +++ b/stepmania/src/ProfileHtml.cpp @@ -947,7 +947,7 @@ bool PrintRecentScores( RageFile &f, const Profile *pProfile, CString sTitle, ve return true; } -bool PrintInventoryForSong( RageFile &f, const Profile *pProfile, Song* pSong ) +bool PrintCatalogForSong( RageFile &f, const Profile *pProfile, Song* pSong ) { if( pSong->NeverDisplayed() || UNLOCKMAN->SongIsLocked(pSong) ) return false; // skip @@ -1019,14 +1019,14 @@ bool PrintInventoryForSong( RageFile &f, const Profile *pProfile, Song* pSong ) return true; } -bool PrintInventoryForGroup( RageFile &f, const Profile *pProfile, CString sGroup ) +bool PrintCatalogForGroup( RageFile &f, const Profile *pProfile, CString sGroup ) { - return PrintSongsInGroup( f, pProfile, sGroup, PrintInventoryForSong ); + return PrintSongsInGroup( f, pProfile, sGroup, PrintCatalogForSong ); } -void PrintInventoryList( RageFile &f, const Profile *pProfile, CString sTitle, vector &vpSongs, vector &vpAllSteps, vector &vStepsTypesToShow, map mapStepsToSong, vector vpCourses ) +void PrintCatalogList( RageFile &f, const Profile *pProfile, CString sTitle, vector &vpSongs, vector &vpAllSteps, vector &vStepsTypesToShow, map mapStepsToSong, vector vpCourses ) { - PrintGroups( f, pProfile, sTitle, PrintInventoryForGroup ); + PrintGroups( f, pProfile, sTitle, PrintCatalogForGroup ); } void PrintBookkeeping( RageFile &f, const Profile *pProfile, CString sTitle, vector &vpSongs, vector &vpAllSteps, vector &vStepsTypesToShow, map mapStepsToSong, vector vpCourses) @@ -1280,19 +1280,17 @@ void SaveStatsWebPage( vector vpSongs = SONGMAN->GetAllSongs(); vector vpAllSteps; map mapStepsToSong; + for( unsigned i=0; i vpSteps = pSong->GetAllSteps(); + for( unsigned j=0; j vpSteps = pSong->GetAllSteps(); - for( unsigned j=0; jIsAutogen() ) - continue; // skip - vpAllSteps.push_back( pSteps ); - mapStepsToSong[pSteps] = pSong; - } + Steps* pSteps = vpSteps[j]; + if( pSteps->IsAutogen() ) + continue; // skip + vpAllSteps.push_back( pSteps ); + mapStepsToSong[pSteps] = pSong; } } vector vpCourses; @@ -1302,28 +1300,26 @@ void SaveStatsWebPage( // Calculate which StepTypes to show // vector vStepsTypesToShow; + for( StepsType st=(StepsType)0; st vpSteps; + pSong->GetSteps( vpSteps, st, DIFFICULTY_INVALID, -1, -1, "", false ); + if( !vpSteps.empty() ) { - Song* pSong = vpSongs[i]; - vector vpSteps; - pSong->GetSteps( vpSteps, st, DIFFICULTY_INVALID, -1, -1, "", false ); - if( !vpSteps.empty() ) - { - bOneSongHasStepsForThisStepsType = true; - break; - } + bOneSongHasStepsForThisStepsType = true; + break; } - if( !bOneSongHasStepsForThisStepsType ) - continue; - if( !SHOW_STEPS_TYPE(st) ) - continue; - vStepsTypesToShow.push_back( st ); } + if( !bOneSongHasStepsForThisStepsType ) + continue; + if( !SHOW_STEPS_TYPE(st) ) + continue; + vStepsTypesToShow.push_back( st ); } // @@ -1420,7 +1416,7 @@ TITLE.c_str(), STYLE_CSS.c_str() ) ); PrintCaloriesBurned( f, pProfile, "Calories Burned", sDir ); PrintPercentComplete( f, pProfile, "Percent Complete", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); PrintRecentScores( f, pProfile, "Most Scores", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); - PrintInventoryList( f, pProfile, "Song Information", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); + PrintCatalogList( f, pProfile, "Song Information", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); PrintBookkeeping( f, pProfile, "Bookkeeping", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); break; default: diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index a6a9c09b8f..eab111331e 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="StepMania" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# Microsoft Developer Studio Generated Build File, Format Version 60000 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Application" 0x0101 @@ -58,14 +58,14 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 $(intdir)\verstub.obj kernel32.lib shell32.lib user32.lib gdi32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /pdb:"../debug6/StepMania-debug.pdb" /map /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /out:"../StepMania-debug.exe" # SUBTRACT BASE LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib -# ADD LINK32 $(intdir)\verstub.obj kernel32.lib gdi32.lib shell32.lib user32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /out:"../Program/StepMania-debug.exe" +# ADD LINK32 $(intdir)\verstub.obj kernel32.lib gdi32.lib shell32.lib user32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /out:"../../itg/itg/Program/StepMania-debug.exe" # SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib # Begin Special Build Tool IntDir=.\../Debug6 -TargetDir=\temp\stepmania\Program +TargetDir=\stepmania\itg\itg\Program TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -99,6 +99,10 @@ XBCP=xbecopy.exe # ADD BASE XBCP /NOLOGO # ADD XBCP /NOLOGO # Begin Special Build Tool +IntDir=.\../Debug_Xbox +TargetDir=\stepmania\stepmania +TargetName=default +SOURCE="$(InputPath)" PreLink_Cmds=disasm\verinc cl /Zl /nologo /c PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -135,10 +139,10 @@ LINK32=link.exe # SUBTRACT LINK32 /verbose /pdb:none /debug # Begin Special Build Tool IntDir=.\../Release6 -TargetDir=\temp\stepmania\Program +TargetDir=\stepmania\stepmania\Program TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -174,6 +178,10 @@ XBCP=xbecopy.exe # ADD BASE XBCP /NOLOGO # ADD XBCP /NOLOGO # Begin Special Build Tool +IntDir=.\../Release_Xbox +TargetDir=\stepmania\stepmania +TargetName=default +SOURCE="$(InputPath)" PreLink_Cmds=disasm\verinc cl /Zl /nologo /c PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -1237,6 +1245,25 @@ SOURCE=.\BannerCache.h # End Source File # Begin Source File +SOURCE=.\CatalogXml.cpp + +!IF "$(CFG)" == "StepMania - Win32 Debug" + +!ELSEIF "$(CFG)" == "StepMania - Xbox Debug" + +!ELSEIF "$(CFG)" == "StepMania - Win32 Release" + +!ELSEIF "$(CFG)" == "StepMania - Xbox Release" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\CatalogXml.h +# End Source File +# Begin Source File + SOURCE=.\Character.cpp !IF "$(CFG)" == "StepMania - Win32 Debug" diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index 747a083870..478022a712 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -578,6 +578,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + +