Files
itgmania212121/stepmania/src/HighScore.h
T

146 lines
4.1 KiB
C++
Raw Normal View History

2004-05-31 22:42:12 +00:00
/* HighScore - Player scoring data that persists between sessions. */
2006-08-17 19:05:29 +00:00
#ifndef HIGH_SCORE_H
#define HIGH_SCORE_H
2004-02-10 09:42:01 +00:00
#include "Grade.h"
#include "GameConstantsAndTypes.h"
2004-07-19 08:05:14 +00:00
#include "DateTime.h"
2005-08-12 01:05:35 +00:00
#include "RageUtil_AutoPtr.h"
2004-02-10 09:42:01 +00:00
class XNode;
2006-08-17 19:25:36 +00:00
struct RadarValues;
2006-08-09 21:49:06 +00:00
struct lua_State;
2004-07-11 07:21:33 +00:00
2005-08-12 01:05:35 +00:00
struct HighScoreImpl;
2004-02-10 09:42:01 +00:00
struct HighScore
{
2005-08-12 03:14:50 +00:00
HighScore();
2005-08-12 01:52:01 +00:00
2006-01-22 01:00:06 +00:00
RString GetName() const;
2005-08-12 02:37:04 +00:00
Grade GetGrade() const;
int GetScore() const;
2005-08-12 02:46:58 +00:00
float GetPercentDP() const;
float GetSurviveSeconds() const;
float GetSurvivalSeconds() const;
2006-01-22 01:00:06 +00:00
RString GetModifiers() const;
2005-08-12 02:55:48 +00:00
DateTime GetDateTime() const;
2006-01-22 01:00:06 +00:00
RString GetPlayerGuid() const;
RString GetMachineGuid() const;
2005-08-12 03:03:54 +00:00
int GetProductID() const;
int GetTapNoteScore( TapNoteScore tns ) const;
int GetHoldNoteScore( HoldNoteScore tns ) const;
2005-08-12 03:10:53 +00:00
const RadarValues &GetRadarValues() const;
float GetLifeRemainingSeconds() const;
2005-08-12 03:14:50 +00:00
2006-01-22 01:00:06 +00:00
void SetName( const RString &sName );
2005-08-12 03:14:50 +00:00
void SetGrade( Grade g );
void SetScore( int iScore );
void SetPercentDP( float f );
void SetSurviveSeconds( float f );
2006-01-22 01:00:06 +00:00
void SetModifiers( RString s );
2005-08-12 03:14:50 +00:00
void SetDateTime( DateTime d );
2006-01-22 01:00:06 +00:00
void SetPlayerGuid( RString s );
void SetMachineGuid( RString s );
2005-08-12 03:14:50 +00:00
void SetProductID( int i );
void SetTapNoteScore( TapNoteScore tns, int i );
void SetHoldNoteScore( HoldNoteScore tns, int i );
void SetRadarValues( const RadarValues &rv );
2005-08-12 03:10:53 +00:00
void SetLifeRemainingSeconds( float f );
2004-03-08 02:50:46 +00:00
2006-01-22 01:00:06 +00:00
RString *GetNameMutable();
const RString *GetNameMutable() const { return const_cast<RString *> (const_cast<HighScore *>(this)->GetNameMutable()); }
2005-08-12 01:05:35 +00:00
2005-08-12 01:29:40 +00:00
void Unset();
2004-02-10 09:42:01 +00:00
bool operator>=( const HighScore& other ) const;
2005-08-12 01:05:35 +00:00
bool operator==( const HighScore& other ) const;
2004-02-10 09:42:01 +00:00
XNode* CreateNode() const;
2004-02-19 03:19:41 +00:00
void LoadFromNode( const XNode* pNode );
2004-03-08 02:50:46 +00:00
2006-01-22 01:00:06 +00:00
RString GetDisplayName() const;
2006-08-09 21:49:06 +00:00
// Lua
void PushSelf( lua_State *L );
2005-08-12 01:05:35 +00:00
private:
HiddenPtr<HighScoreImpl> m_Impl;
2004-02-10 09:42:01 +00:00
};
struct HighScoreList
{
2005-04-25 22:44:32 +00:00
public:
2004-02-10 09:42:01 +00:00
HighScoreList()
{
Init();
2004-02-10 09:42:01 +00:00
}
void Init();
2005-04-25 22:44:32 +00:00
int GetNumTimesPlayed() const
{
return iNumTimesPlayed;
}
DateTime GetLastPlayed() const
{
ASSERT( iNumTimesPlayed > 0 ); // don't call this unless the song has been played
return dtLastPlayed;
}
const HighScore& GetTopScore() const;
2004-02-10 09:42:01 +00:00
void AddHighScore( HighScore hs, int &iIndexOut, bool bIsMachine );
2005-04-25 22:44:32 +00:00
void IncrementPlayCount( DateTime dtLastPlayed );
void RemoveAllButOneOfEachName();
void ClampSize( bool bIsMachine );
2004-02-10 09:42:01 +00:00
XNode* CreateNode() const;
2004-02-19 03:19:41 +00:00
void LoadFromNode( const XNode* pNode );
2005-04-25 09:03:24 +00:00
2005-04-25 22:44:32 +00:00
vector<HighScore> vHighScores;
Grade HighGrade;
2007-03-14 04:26:32 +00:00
// Lua
void PushSelf( lua_State *L );
2005-04-25 22:44:32 +00:00
private:
int iNumTimesPlayed;
DateTime dtLastPlayed; // meaningless if iNumTimesPlayed == 0
2004-02-10 09:42:01 +00:00
};
2004-06-12 07:01:07 +00:00
struct Screenshot
{
2006-01-22 01:00:06 +00:00
RString sFileName; // no directory part - just the file name
RString sMD5; // MD5 hash of the screenshot file
2004-06-12 07:01:07 +00:00
HighScore highScore;
XNode* CreateNode() const;
void LoadFromNode( const XNode* pNode );
};
2004-02-10 09:42:01 +00:00
#endif
2004-05-31 22:42:12 +00:00
/*
* (c) 2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/