write Catalog.xml that contains song and course metadata - useful for importing into other tools

This commit is contained in:
Chris Danford
2004-05-20 08:55:26 +00:00
parent 2dc648220c
commit a85f967e69
7 changed files with 147 additions and 41 deletions
+55
View File
@@ -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<Song*> vpSongs = SONGMAN->GetAllSongs();
for( unsigned i=0; i<vpSongs.size(); i++ )
{
Song* pSong = vpSongs[i];
SongID songID;
songID.FromSong( pSong );
XNode* pSongNode = songID.CreateNode();
xml.AppendChild( pSongNode );
vector<Steps*> vpSteps = pSong->GetAllSteps();
for( unsigned j=0; j<vpSteps.size(); j++ )
{
Steps* pSteps = vpSteps[j];
if( pSteps->IsAutogen() )
continue;
StepsID stepsID;
stepsID.FromSteps( pSteps );
pSongNode->AppendChild( stepsID.CreateNode() );
}
}
bool bSaved = xml.SaveToFile(fn);
}
+18
View File
@@ -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
+2 -1
View File
@@ -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 ScreenTitleMenu.cpp ScreenTitleMenu.h ScreenUnlock.cpp ScreenUnlock.h ScreenWithMenuElements.cpp ScreenWithMenuElements.h
DataStructures = \ 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 \ CodeDetector.cpp CodeDetector.h EnumHelper.cpp EnumHelper.h Course.cpp Course.h CourseUtil.cpp CourseUtil.h \
Font.cpp Font.h FontCharAliases.cpp FontCharAliases.h \ Font.cpp Font.h FontCharAliases.cpp FontCharAliases.h \
FontCharmaps.cpp FontCharmaps.h Game.h GameConstantsAndTypes.cpp GameConstantsAndTypes.h GameDef.cpp GameDef.h \ FontCharmaps.cpp FontCharmaps.h Game.h GameConstantsAndTypes.cpp GameConstantsAndTypes.h GameDef.cpp GameDef.h \
+3
View File
@@ -31,6 +31,7 @@
#include "ScoreKeeperMAX2.h" #include "ScoreKeeperMAX2.h"
#include "crypto/CryptRand.h" #include "crypto/CryptRand.h"
#include "UnlockSystem.h" #include "UnlockSystem.h"
#include "CatalogXml.h"
// //
// Old file versions for backward compatibility // Old file versions for backward compatibility
@@ -1656,6 +1657,8 @@ void Profile::SaveStatsWebPageToDir( CString sDir ) const
PROFILEMAN->GetMachineProfile(), PROFILEMAN->GetMachineProfile(),
bThisIsMachineProfile ? HTML_TYPE_MACHINE : HTML_TYPE_PLAYER bThisIsMachineProfile ? HTML_TYPE_MACHINE : HTML_TYPE_PLAYER
); );
if( bThisIsMachineProfile )
SaveCatalogXml( sDir );
} }
void Profile::SaveMachinePublicKeyToDir( CString sDir ) const void Profile::SaveMachinePublicKeyToDir( CString sDir ) const
+30 -34
View File
@@ -947,7 +947,7 @@ bool PrintRecentScores( RageFile &f, const Profile *pProfile, CString sTitle, ve
return true; 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) ) if( pSong->NeverDisplayed() || UNLOCKMAN->SongIsLocked(pSong) )
return false; // skip return false; // skip
@@ -1019,14 +1019,14 @@ bool PrintInventoryForSong( RageFile &f, const Profile *pProfile, Song* pSong )
return true; 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<Song*> &vpSongs, vector<Steps*> &vpAllSteps, vector<StepsType> &vStepsTypesToShow, map<Steps*,Song*> mapStepsToSong, vector<Course*> vpCourses ) void PrintCatalogList( RageFile &f, const Profile *pProfile, CString sTitle, vector<Song*> &vpSongs, vector<Steps*> &vpAllSteps, vector<StepsType> &vStepsTypesToShow, map<Steps*,Song*> mapStepsToSong, vector<Course*> vpCourses )
{ {
PrintGroups( f, pProfile, sTitle, PrintInventoryForGroup ); PrintGroups( f, pProfile, sTitle, PrintCatalogForGroup );
} }
void PrintBookkeeping( RageFile &f, const Profile *pProfile, CString sTitle, vector<Song*> &vpSongs, vector<Steps*> &vpAllSteps, vector<StepsType> &vStepsTypesToShow, map<Steps*,Song*> mapStepsToSong, vector<Course*> vpCourses) void PrintBookkeeping( RageFile &f, const Profile *pProfile, CString sTitle, vector<Song*> &vpSongs, vector<Steps*> &vpAllSteps, vector<StepsType> &vStepsTypesToShow, map<Steps*,Song*> mapStepsToSong, vector<Course*> vpCourses)
@@ -1280,19 +1280,17 @@ void SaveStatsWebPage(
vector<Song*> vpSongs = SONGMAN->GetAllSongs(); vector<Song*> vpSongs = SONGMAN->GetAllSongs();
vector<Steps*> vpAllSteps; vector<Steps*> vpAllSteps;
map<Steps*,Song*> mapStepsToSong; map<Steps*,Song*> mapStepsToSong;
for( unsigned i=0; i<vpSongs.size(); i++ )
{ {
for( unsigned i=0; i<vpSongs.size(); i++ ) Song* pSong = vpSongs[i];
vector<Steps*> vpSteps = pSong->GetAllSteps();
for( unsigned j=0; j<vpSteps.size(); j++ )
{ {
Song* pSong = vpSongs[i]; Steps* pSteps = vpSteps[j];
vector<Steps*> vpSteps = pSong->GetAllSteps(); if( pSteps->IsAutogen() )
for( unsigned j=0; j<vpSteps.size(); j++ ) continue; // skip
{ vpAllSteps.push_back( pSteps );
Steps* pSteps = vpSteps[j]; mapStepsToSong[pSteps] = pSong;
if( pSteps->IsAutogen() )
continue; // skip
vpAllSteps.push_back( pSteps );
mapStepsToSong[pSteps] = pSong;
}
} }
} }
vector<Course*> vpCourses; vector<Course*> vpCourses;
@@ -1302,28 +1300,26 @@ void SaveStatsWebPage(
// Calculate which StepTypes to show // Calculate which StepTypes to show
// //
vector<StepsType> vStepsTypesToShow; vector<StepsType> vStepsTypesToShow;
for( StepsType st=(StepsType)0; st<NUM_STEPS_TYPES; st=(StepsType)(st+1) )
{ {
for( StepsType st=(StepsType)0; st<NUM_STEPS_TYPES; st=(StepsType)(st+1) ) // don't show if there are no Steps of this StepsType
bool bOneSongHasStepsForThisStepsType = false;
for( unsigned i=0; i<vpSongs.size(); i++ )
{ {
// don't show if there are no Steps of this StepsType Song* pSong = vpSongs[i];
bool bOneSongHasStepsForThisStepsType = false; vector<Steps*> vpSteps;
for( unsigned i=0; i<vpSongs.size(); i++ ) pSong->GetSteps( vpSteps, st, DIFFICULTY_INVALID, -1, -1, "", false );
if( !vpSteps.empty() )
{ {
Song* pSong = vpSongs[i]; bOneSongHasStepsForThisStepsType = true;
vector<Steps*> vpSteps; break;
pSong->GetSteps( vpSteps, st, DIFFICULTY_INVALID, -1, -1, "", false );
if( !vpSteps.empty() )
{
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 ); PrintCaloriesBurned( f, pProfile, "Calories Burned", sDir );
PrintPercentComplete( f, pProfile, "Percent Complete", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses ); PrintPercentComplete( f, pProfile, "Percent Complete", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses );
PrintRecentScores( f, pProfile, "Most Scores", 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 ); PrintBookkeeping( f, pProfile, "Bookkeeping", vpSongs, vpAllSteps, vStepsTypesToShow, mapStepsToSong, vpCourses );
break; break;
default: default:
+33 -6
View File
@@ -1,5 +1,5 @@
# Microsoft Developer Studio Project File - Name="StepMania" - Package Owner=<4> # 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 ** # ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101 # TARGTYPE "Win32 (x86) Application" 0x0101
@@ -58,14 +58,14 @@ BSC32=bscmake.exe
LINK32=link.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" # 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 # 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 # SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
# Begin Special Build Tool # Begin Special Build Tool
IntDir=.\../Debug6 IntDir=.\../Debug6
TargetDir=\temp\stepmania\Program TargetDir=\stepmania\itg\itg\Program
TargetName=StepMania-debug TargetName=StepMania-debug
SOURCE="$(InputPath)" 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 PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool # End Special Build Tool
@@ -99,6 +99,10 @@ XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO # ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO # ADD XBCP /NOLOGO
# Begin Special Build Tool # 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 PreLink_Cmds=disasm\verinc cl /Zl /nologo /c PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool # End Special Build Tool
@@ -135,10 +139,10 @@ LINK32=link.exe
# SUBTRACT LINK32 /verbose /pdb:none /debug # SUBTRACT LINK32 /verbose /pdb:none /debug
# Begin Special Build Tool # Begin Special Build Tool
IntDir=.\../Release6 IntDir=.\../Release6
TargetDir=\temp\stepmania\Program TargetDir=\stepmania\stepmania\Program
TargetName=StepMania TargetName=StepMania
SOURCE="$(InputPath)" 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 PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool # End Special Build Tool
@@ -174,6 +178,10 @@ XBCP=xbecopy.exe
# ADD BASE XBCP /NOLOGO # ADD BASE XBCP /NOLOGO
# ADD XBCP /NOLOGO # ADD XBCP /NOLOGO
# Begin Special Build Tool # 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 PreLink_Cmds=disasm\verinc cl /Zl /nologo /c PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool # End Special Build Tool
@@ -1237,6 +1245,25 @@ SOURCE=.\BannerCache.h
# End Source File # End Source File
# Begin 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 SOURCE=.\Character.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug" !IF "$(CFG)" == "StepMania - Win32 Debug"
+6
View File
@@ -578,6 +578,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File <File
RelativePath="BannerCache.h"> RelativePath="BannerCache.h">
</File> </File>
<File
RelativePath="CatalogXml.cpp">
</File>
<File
RelativePath="CatalogXml.h">
</File>
<File <File
RelativePath="Character.cpp"> RelativePath="Character.cpp">
</File> </File>