📄 highscores.h
字号:
/*
* ==============================================================================
* Name : HighScores.h
* Part of : RGA Game Example
* Interface :
* Description : high score table, saving and loading
* Version : 1.0
*
* Copyright (c) 2007-2008 Nokia Corporation.
* This material, including documentation and any related
* computer programs, is protected by copyright controlled by
* Nokia Corporation.
* ==============================================================================
*/
#ifndef __HIGHSCORES_H__
#define __HIGHSCORES_H__
#include <e32base.h>
// THighScoreItem
struct THighScoreItem
{
TBuf<12> iName;
TReal64 iScore;
};
class CHighScores : public CBase
{
public:
CHighScores();
virtual ~CHighScores();
/**
* NewL
* 1st phase constructor
* @param aFilename file to save and load from
* @param aMaxItems maximum number of items to store
* @return pointer to initialised high score table
*/
static CHighScores* NewL(const TDesC& aFilename, TInt aMaxItems);
/**
* Load
* load high scores table from file
* @return KErrNone or error code
*/
TInt Load();
/**
* Save
* save high scores table into a file
* @return KErrNone or error code
*/
TInt Save() const;
/**
* Add
* add new high score into the table
* @param aNewHighScore score to add
* @param aInsert if EFalse, score is not inserted to table,
* only possible index is returned. If ETrue score
* is also inserted to high score table
* @return index at highscore table, or -1 if score
* didn't make it to table
*/
TInt Add(const THighScoreItem& aNewScore, TBool aInsert);
/**
* Score
* @aIndex index of the score
* @return reference to high score item at index
*/
THighScoreItem& Score(TInt aIndex);
/**
* MaxItems
* @return maximum number of highscores stored
*/
TInt MaxItems() const;
/**
* MaxNameLength
* @return max number of chars in player name
*/
TInt MaxNameLength() const;
/**
* LatestAddedItemIndex
* @return index of latest added new high score, or KErrNotFound
*/
TInt LatestAddedItemIndex() const;
private:
/**
* ConstructL
* 2nd phase constructor
* @param aFilename file to save and load from
* @param aMaxItems maximum number of items to store
*/
void ConstructL(const TDesC& aFilename, TInt aMaxItems);
private:
HBufC* iFilename;
TInt iMaxItems;
RArray<THighScoreItem> iScores;
TInt iLatestAddedItemIndex;
};
#endif // __HIGHSCORES_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -