S60UIExamplemodel.h
上传用户:laixiong
上传日期:2007-03-11
资源大小:2994k
文件大小:2k
源码类别:

Symbian

开发平台:

C/C++

  1. // Copyright (c) 2006 Nokia Corporation.
  2. #ifndef __S60UIEXAMPLE_MODEL_H__
  3. #define __S60UIEXAMPLE_MODEL_H__
  4. #include <e32base.h>
  5. /**
  6. * THighScore
  7. * class structure to hold high scores and names
  8. */
  9. class THighScore
  10.     {
  11.     public:
  12.         TInt      iScore;
  13.         TBufC<20> iName;
  14.     };
  15. /**
  16. * CS60UIExampleModel model class.
  17. * An instance of class CS60UIExampleModel
  18. */
  19. class CS60UIExampleModel : public CBase
  20.     {
  21.     public: // Constructors and destructor
  22.     
  23.         /**
  24.         * CS60UIExampleModel::NewL()
  25.         * Two-phased constructor.
  26.         */
  27.         static CS60UIExampleModel* CS60UIExampleModel::NewL();
  28.         
  29.         /**
  30.         * CS60UIExampleModel::NewLC()
  31.         * Two-phased constructor.
  32.         */
  33.         static CS60UIExampleModel* CS60UIExampleModel::NewLC();
  34.         
  35.         /**
  36.         * ConstructL.
  37.         * 2nd phase constructor.
  38.         */
  39.         void ConstructL();
  40.         /**
  41.         * Destructor
  42.         */
  43.         virtual ~CS60UIExampleModel();
  44.         
  45.     public:
  46.         /**
  47.         * Access functions
  48.         */
  49.         TBool IsGameStarted() const  { return iGameStarted; }
  50.         TBool IsGamePaused() const   { return iGamePaused; }
  51.             
  52.         void GameStart()    { iGameStarted = ETrue; iLevel = 1; iScore = 0; }
  53.         void GameStop()     { iGameStarted = EFalse; }
  54.         void GamePause()    { iGamePaused = ETrue; }
  55.         void GameContinue() { iGameStarted = ETrue; iGamePaused = EFalse; }
  56.         
  57.         TInt LevelNumber()               { return iLevel; }
  58.         void SetLevelNumber(TInt aLevel) { iLevel = aLevel; }
  59.         
  60.         TInt Score()               { return iScore; }
  61.         void SetScore(TInt aScore) { iScore = aScore; }
  62.         
  63.         RArray<THighScore>* HighScoreArray() { return &iHighScores; }
  64.         void InsertInHighScoresL(TDesC& aName, TInt aScore);
  65.         
  66.     private: // Data
  67.         /**
  68.         * iGameStarted - True if Game is started
  69.         */
  70.         TBool iGameStarted;
  71.         
  72.         /**
  73.         * iGamePaused - True if Game is paused
  74.         */
  75.         TBool iGamePaused;
  76.         
  77.         /**
  78.         * iLevel - The game level
  79.         */
  80.         TInt iLevel;
  81.         
  82.         /**
  83.         * iScore - The game score
  84.         */
  85.         TInt iScore;
  86.         
  87.         /**
  88.         * iHighScores - array of highest scores
  89.         */
  90.         RArray<THighScore>  iHighScores;
  91.     };
  92. #endif // __S60UIEXAMPLE_MODEL_H__
  93. // End of File