experimental: save NoteData to XML for recording played games
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
#include "NoteData.h"
|
#include "NoteData.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
|
#include "XmlFile.h"
|
||||||
|
#include "Foreach.h"
|
||||||
|
|
||||||
#include "RageUtil_AutoPtr.h"
|
#include "RageUtil_AutoPtr.h"
|
||||||
REGISTER_CLASS_TRAITS( NoteData, new NoteData(*pCopy) )
|
REGISTER_CLASS_TRAITS( NoteData, new NoteData(*pCopy) )
|
||||||
@@ -877,6 +879,34 @@ bool NoteData::GetPrevTapNoteRowForAllTracks( int &rowInOut ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XNode* NoteData::CreateNode() const
|
||||||
|
{
|
||||||
|
XNode *p = new XNode;
|
||||||
|
p->m_sName = "NoteData";
|
||||||
|
|
||||||
|
FOREACH_NONEMPTY_ROW_ALL_TRACKS( *this, row )
|
||||||
|
{
|
||||||
|
set<int> s;
|
||||||
|
GetTapNonEmptyTracks( row, s );
|
||||||
|
FOREACHS_CONST( int, s, t )
|
||||||
|
{
|
||||||
|
TapNote tn = this->GetTapNote(*t, row);
|
||||||
|
XNode *p2 = tn.CreateNode();
|
||||||
|
p2->AppendAttr( "Track", *t );
|
||||||
|
p2->AppendAttr( "Row", row );
|
||||||
|
p->AppendChild( p2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteData::LoadFromNode( const XNode* pNode )
|
||||||
|
{
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -150,6 +150,10 @@ public:
|
|||||||
|
|
||||||
// Transformations
|
// Transformations
|
||||||
void LoadTransformed( const NoteData& original, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track
|
void LoadTransformed( const NoteData& original, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track
|
||||||
|
|
||||||
|
// XML
|
||||||
|
XNode* CreateNode() const;
|
||||||
|
void LoadFromNode( const XNode* pNode );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "LuaManager.h"
|
#include "LuaManager.h"
|
||||||
#include "LuaFunctions.h"
|
#include "LuaFunctions.h"
|
||||||
|
#include "XmlFile.h"
|
||||||
|
|
||||||
TapNote TAP_EMPTY ( TapNote::empty, TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 );
|
TapNote TAP_EMPTY ( TapNote::empty, TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 );
|
||||||
TapNote TAP_ORIGINAL_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 );
|
TapNote TAP_ORIGINAL_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::original, "", 0, false, 0 );
|
||||||
@@ -75,6 +76,52 @@ bool IsNoteOfType( int row, NoteType t )
|
|||||||
return GetNoteType(row) == t;
|
return GetNoteType(row) == t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XNode* TapNoteResult::CreateNode() const
|
||||||
|
{
|
||||||
|
XNode *p = new XNode;
|
||||||
|
p->m_sName = "TapNoteResult";
|
||||||
|
|
||||||
|
p->AppendAttr( "TapNoteScore", TapNoteScoreToString(tns) );
|
||||||
|
p->AppendAttr( "TapNoteOffset", fTapNoteOffset );
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TapNoteResult::LoadFromNode( const XNode* pNode )
|
||||||
|
{
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
XNode* HoldNoteResult::CreateNode() const
|
||||||
|
{
|
||||||
|
XNode *p = new XNode;
|
||||||
|
p->m_sName = "HoldNoteResult";
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HoldNoteResult::LoadFromNode( const XNode* pNode )
|
||||||
|
{
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
XNode* TapNote::CreateNode() const
|
||||||
|
{
|
||||||
|
XNode *p = new XNode;
|
||||||
|
p->m_sName = "TapNote";
|
||||||
|
|
||||||
|
p->AppendChild( result.CreateNode() );
|
||||||
|
p->AppendChild( HoldResult.CreateNode() );
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TapNote::LoadFromNode( const XNode* pNode )
|
||||||
|
{
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
float HoldNoteResult::GetLastHeldBeat() const
|
float HoldNoteResult::GetLastHeldBeat() const
|
||||||
{
|
{
|
||||||
return NoteRowToBeat(iLastHeldRow);
|
return NoteRowToBeat(iLastHeldRow);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#define NOTE_TYPES_H
|
#define NOTE_TYPES_H
|
||||||
|
|
||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
|
struct XNode;
|
||||||
|
|
||||||
struct TapNoteResult
|
struct TapNoteResult
|
||||||
{
|
{
|
||||||
@@ -21,6 +22,10 @@ struct TapNoteResult
|
|||||||
|
|
||||||
/* If the whole row has been judged, all taps on the row will be set to hidden. */
|
/* If the whole row has been judged, all taps on the row will be set to hidden. */
|
||||||
bool bHidden;
|
bool bHidden;
|
||||||
|
|
||||||
|
// XML
|
||||||
|
XNode* CreateNode() const;
|
||||||
|
void LoadFromNode( const XNode* pNode );
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HoldNoteResult
|
struct HoldNoteResult
|
||||||
@@ -49,6 +54,10 @@ struct HoldNoteResult
|
|||||||
|
|
||||||
bool bHeld;
|
bool bHeld;
|
||||||
bool bActive;
|
bool bActive;
|
||||||
|
|
||||||
|
// XML
|
||||||
|
XNode* CreateNode() const;
|
||||||
|
void LoadFromNode( const XNode* pNode );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +112,11 @@ struct TapNote
|
|||||||
HoldNoteResult HoldResult;
|
HoldNoteResult HoldResult;
|
||||||
|
|
||||||
|
|
||||||
|
// XML
|
||||||
|
XNode* CreateNode() const;
|
||||||
|
void LoadFromNode( const XNode* pNode );
|
||||||
|
|
||||||
|
|
||||||
TapNote() {}
|
TapNote() {}
|
||||||
TapNote(
|
TapNote(
|
||||||
Type type_,
|
Type type_,
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
#include "DifficultyMeter.h"
|
#include "DifficultyMeter.h"
|
||||||
#include "PlayerScoreList.h"
|
#include "PlayerScoreList.h"
|
||||||
#include "InputEventPlus.h"
|
#include "InputEventPlus.h"
|
||||||
|
#include "XmlFile.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Defines
|
// Defines
|
||||||
@@ -2533,6 +2534,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
{
|
{
|
||||||
SongFinished();
|
SongFinished();
|
||||||
StageFinished( false );
|
StageFinished( false );
|
||||||
|
//SaveRecordedResults();
|
||||||
}
|
}
|
||||||
else if( SM == SM_GainFocus )
|
else if( SM == SM_GainFocus )
|
||||||
{
|
{
|
||||||
@@ -2686,6 +2688,22 @@ Song *ScreenGameplay::GetNextCourseSong() const
|
|||||||
return m_apSongsQueue[iPlaySongIndex];
|
return m_apSongsQueue[iPlaySongIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenGameplay::SaveRecordedResults()
|
||||||
|
{
|
||||||
|
FOREACH_HumanPlayer( pn )
|
||||||
|
{
|
||||||
|
FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi )
|
||||||
|
{
|
||||||
|
XNode *p = pi->m_pPlayer->m_NoteData.CreateNode();
|
||||||
|
DISP_OPT opt;
|
||||||
|
p->SaveToFile( "Save/LastSongRecording.xml", opt );
|
||||||
|
SAFE_DELETE( p );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// lua start
|
// lua start
|
||||||
#include "LuaBinding.h"
|
#include "LuaBinding.h"
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ protected:
|
|||||||
void UpdateLyrics( float fDeltaTime );
|
void UpdateLyrics( float fDeltaTime );
|
||||||
void SongFinished();
|
void SongFinished();
|
||||||
void StageFinished( bool bBackedOut );
|
void StageFinished( bool bBackedOut );
|
||||||
|
void SaveRecordedResults();
|
||||||
|
|
||||||
virtual void InitSongQueues();
|
virtual void InitSongQueues();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user