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