S60UIExamplemodel.cpp
上传用户:laixiong
上传日期:2007-03-11
资源大小:2994k
文件大小:2k
- // Copyright (c) 2006 Nokia Corporation.
- #include <e32std.h>
- #include "S60UIExampleModel.h"
- const TInt KMaxHighScores = 5;
- // -----------------------------------------------------------------------------
- // CS60UIExampleModel::NewL()
- // Two-phased constructor.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleModel* CS60UIExampleModel::NewL()
- {
- CS60UIExampleModel* self = CS60UIExampleModel::NewLC();
- CleanupStack::Pop(self);
- return self;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleModel::NewLC()
- // Two-phased constructor.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleModel* CS60UIExampleModel::NewLC()
- {
- CS60UIExampleModel* self = new (ELeave) CS60UIExampleModel();
- CleanupStack::PushL(self);
- self->ConstructL();
- return self;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleModel::ConstructL()
- // Symbian 2nd phase constructor can leave.
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleModel::ConstructL()
- {
- // Initialise Model
- iGameStarted = EFalse;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleModel::~CS60UIExampleModel
- // Destructor.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleModel::~CS60UIExampleModel()
- {
- iHighScores.Close();
- }
-
- // -----------------------------------------------------------------------------
- // CS60UIExampleModel::InsertInHighScoresL
- // Inserts a name and score into highscores.
- // Ordered by score
- // Rejected if not in top set (KmaxHighScores)
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleModel::InsertInHighScoresL(TDesC& aName, TInt aScore)
- {
- THighScore highScore;
- highScore.iScore = aScore;
- highScore.iName = aName.Left(20);
- iHighScores.InsertInSignedKeyOrderAllowRepeatsL(highScore);
- if (iHighScores.Count() > KMaxHighScores)
- {
- iHighScores.Remove(0);
- }
- }
- // End of File