save HighScore in Screenshot
This commit is contained in:
@@ -189,6 +189,30 @@ void HighScoreList::LoadFromNode( const XNode* pNode )
|
||||
}
|
||||
}
|
||||
|
||||
XNode* Screenshot::CreateNode() const
|
||||
{
|
||||
XNode* pNode = new XNode;
|
||||
pNode->name = "Screenshot";
|
||||
|
||||
// TRICKY: Don't write "name to fill in" markers.
|
||||
pNode->AppendChild( "FileName", sFileName );
|
||||
pNode->AppendChild( "MD5", sMD5 );
|
||||
pNode->AppendChild( highScore.CreateNode() );
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
||||
void Screenshot::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
ASSERT( pNode->name == "Screenshot" );
|
||||
|
||||
pNode->GetChildValue( "FileName", sFileName );
|
||||
pNode->GetChildValue( "MD5", sMD5 );
|
||||
XNode* pHighScore = pNode->GetChild( "HighScore" );
|
||||
if( pHighScore )
|
||||
highScore.LoadFromNode( pHighScore );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
@@ -92,6 +92,16 @@ struct HighScoreList
|
||||
void LoadFromNode( const XNode* pNode );
|
||||
};
|
||||
|
||||
struct Screenshot
|
||||
{
|
||||
CString sFileName; // no directory part - just the file name
|
||||
CString sMD5; // MD5 hash of the screenshot file
|
||||
HighScore highScore;
|
||||
|
||||
XNode* CreateNode() const;
|
||||
void LoadFromNode( const XNode* pNode );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -1263,7 +1263,7 @@ void Profile::SaveMachinePublicKeyToDir( CString sDir ) const
|
||||
FileCopy( CRYPTMAN->GetPublicKeyFileName(), sDir+PUBLIC_KEY_FILE );
|
||||
}
|
||||
|
||||
void Profile::AddScreenshot( Screenshot screenshot )
|
||||
void Profile::AddScreenshot( const Screenshot &screenshot )
|
||||
{
|
||||
m_vScreenshots.push_back( screenshot );
|
||||
}
|
||||
@@ -1273,26 +1273,13 @@ void Profile::LoadScreenshotDataFromNode( const XNode* pNode )
|
||||
CHECKPOINT;
|
||||
|
||||
ASSERT( pNode->name == "ScreenshotData" );
|
||||
for( XNodes::const_iterator screenshot = pNode->childs.begin();
|
||||
screenshot != pNode->childs.end();
|
||||
screenshot++ )
|
||||
FOREACH_CONST( XNode*, pNode->childs, screenshot )
|
||||
{
|
||||
if( (*screenshot)->name != "Screenshot" )
|
||||
WARN_AND_CONTINUE;
|
||||
|
||||
Screenshot ss;
|
||||
|
||||
if( !(*screenshot)->GetChildValue("FileName",ss.sFileName) )
|
||||
WARN;
|
||||
|
||||
if( !(*screenshot)->GetChildValue("MD5",ss.sMD5) )
|
||||
WARN;
|
||||
|
||||
if( !(*screenshot)->GetChildValue("Time",(int&)ss.time) ) // time_t is a signed long on Win32. Is this ok on other platforms?
|
||||
WARN;
|
||||
|
||||
if( !(*screenshot)->GetChildValue("MachineGuid",ss.sMachineGuid) )
|
||||
WARN;
|
||||
ss.LoadFromNode( *screenshot );
|
||||
|
||||
m_vScreenshots.push_back( ss );
|
||||
}
|
||||
@@ -1308,16 +1295,9 @@ XNode* Profile::SaveScreenshotDataCreateNode() const
|
||||
XNode* pNode = new XNode;
|
||||
pNode->name = "ScreenshotData";
|
||||
|
||||
for( unsigned i=0; i<m_vScreenshots.size(); i++ )
|
||||
FOREACH_CONST( Screenshot, m_vScreenshots, ss )
|
||||
{
|
||||
const Screenshot &ss = m_vScreenshots[i];
|
||||
|
||||
XNode* pScreenshotNode = pNode->AppendChild( "Screenshot" );
|
||||
|
||||
pScreenshotNode->AppendChild( "FileName", ss.sFileName );
|
||||
pScreenshotNode->AppendChild( "MD5", ss.sMD5 );
|
||||
pScreenshotNode->AppendChild( "Time", (int) ss.time );
|
||||
pScreenshotNode->AppendChild( "MachineGuid", ss.sMachineGuid );
|
||||
XNode* pScreenshotNode = pNode->AppendChild( ss->CreateNode() );
|
||||
}
|
||||
|
||||
return pNode;
|
||||
@@ -1328,9 +1308,7 @@ void Profile::LoadCalorieDataFromNode( const XNode* pNode )
|
||||
CHECKPOINT;
|
||||
|
||||
ASSERT( pNode->name == "CalorieData" );
|
||||
for( XNodes::const_iterator pDay = pNode->childs.begin();
|
||||
pDay != pNode->childs.end();
|
||||
pDay++ )
|
||||
FOREACH_CONST( XNode*, pNode->childs, pDay )
|
||||
{
|
||||
if( (*pDay)->name != "Day" )
|
||||
WARN_AND_CONTINUE;
|
||||
|
||||
@@ -174,15 +174,8 @@ public:
|
||||
//
|
||||
// Screenshot Data
|
||||
//
|
||||
struct Screenshot
|
||||
{
|
||||
CString sFileName; // no directory part - just the file name
|
||||
CString sMD5; // MD5 hash of the screenshot file
|
||||
time_t time; // return value of time() when screenshot was taken
|
||||
CString sMachineGuid; // where this screenshot was taken
|
||||
};
|
||||
vector<Screenshot> m_vScreenshots;
|
||||
void AddScreenshot( Screenshot screenshot );
|
||||
void AddScreenshot( const Screenshot &screenshot );
|
||||
int GetNextScreenshotIndex() { return m_vScreenshots.size(); }
|
||||
|
||||
|
||||
|
||||
@@ -1138,7 +1138,7 @@ void PrintBookkeeping( RageFile &f, const Profile *pProfile, CString sTitle, vec
|
||||
PRINT_CLOSE(f);
|
||||
}
|
||||
|
||||
void PrintScreenshot( RageFile &f, const Profile::Screenshot &ss )
|
||||
void PrintScreenshot( RageFile &f, const Screenshot &ss )
|
||||
{
|
||||
CString sImagePath = SCREENSHOTS_SUBDIR+ss.sFileName;
|
||||
CString sImgHtml = ssprintf("<a href='%s' target='_new'><img class='screenshot' src='%s' width='160' height='120'></a>", sImagePath.c_str(), sImagePath.c_str() );
|
||||
@@ -1153,8 +1153,7 @@ void PrintScreenshot( RageFile &f, const Profile::Screenshot &ss )
|
||||
|
||||
TABLE_LINE2( "File", ss.sFileName );
|
||||
TABLE_LINE2( "MD5", ss.sMD5 );
|
||||
TABLE_LINE2( "Time", (CString)ctime(&ss.time) );
|
||||
TABLE_LINE2( "Machine", ss.sMachineGuid );
|
||||
TABLE_LINE2( "Results", HighScoreToString(ss.highScore) );
|
||||
|
||||
END_TABLE;
|
||||
|
||||
@@ -1172,9 +1171,9 @@ void PrintScreenshots( RageFile &f, const Profile *pProfile, CString sTitle, CSt
|
||||
|
||||
for( int i = (int)pProfile->m_vScreenshots.size()-1; i >= 0; i-- )
|
||||
{
|
||||
Profile::Screenshot ss = pProfile->m_vScreenshots[i];
|
||||
Screenshot ss = pProfile->m_vScreenshots[i];
|
||||
tm new_time;
|
||||
localtime_r( &ss.time, &new_time );
|
||||
localtime_r( &ss.highScore.time, &new_time );
|
||||
int iYear = new_time.tm_year+1900;
|
||||
int iMonth = new_time.tm_mon+1;
|
||||
CString sNewMonth = ssprintf("%02d/%d", iMonth, iYear );
|
||||
|
||||
@@ -107,11 +107,10 @@ void ScreenAward::Input( const DeviceInput& DeviceI, const InputEventType type,
|
||||
|
||||
if( !sFileName.empty() )
|
||||
{
|
||||
Profile::Screenshot screenshot;
|
||||
Screenshot screenshot;
|
||||
screenshot.sFileName = sFileName;
|
||||
screenshot.sMD5 = CRYPTMAN->GetMD5( sPath );
|
||||
screenshot.time = time(NULL);
|
||||
screenshot.sMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid;
|
||||
// FIXME: save HighScore
|
||||
pProfile->AddScreenshot( screenshot );
|
||||
}
|
||||
|
||||
|
||||
@@ -1392,6 +1392,8 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t
|
||||
if( GameI.IsValid() )
|
||||
{
|
||||
PlayerNumber pn = GAMESTATE->GetCurrentStyleDef()->ControllerToPlayerNumber( GameI.controller );
|
||||
HighScore &hs = m_HighScore[pn];
|
||||
|
||||
|
||||
if( CodeDetector::EnteredCode(GameI.controller, CodeDetector::CODE_SAVE_SCREENSHOT) )
|
||||
{
|
||||
@@ -1406,11 +1408,10 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t
|
||||
|
||||
if( !sFileName.empty() )
|
||||
{
|
||||
Profile::Screenshot screenshot;
|
||||
Screenshot screenshot;
|
||||
screenshot.sFileName = sFileName;
|
||||
screenshot.sMD5 = CRYPTMAN->GetMD5( sPath );
|
||||
screenshot.time = time(NULL);
|
||||
screenshot.sMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid;
|
||||
screenshot.highScore = hs;
|
||||
pProfile->AddScreenshot( screenshot );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user