EvidenceHuntGame.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #include <qdeclarative.h>
  2. #include <QFile>
  3. #include <QApplication>
  4. #include <QSettings>
  5. #include <QTranslator>
  6. #if defined(Q_EVHUNT_MEEGO)
  7. #include <MDataUri>
  8. #include <maemo-meegotouch-interfaces/shareuiinterface.h>
  9. #endif
  10. #include "TileData.h"
  11. #include "EvidenceType.h"
  12. #include "EvidenceInfo.h"
  13. #include "SuspectData.h"
  14. #include "TopPlayerData.h"
  15. #include "Scoreboard.h"
  16. #ifndef EVIDENHUNTGAME_H
  17. #define EVIDENHUNTGAME_H
  18. class EvidencehuntGame : public QObject {
  19. Q_OBJECT
  20. public:
  21. EvidencehuntGame(QApplication*);
  22. Q_PROPERTY(QDeclarativeListProperty<TileData> tiles READ tiles CONSTANT)
  23. QDeclarativeListProperty<TileData> tiles();
  24. Q_PROPERTY(QDeclarativeListProperty<SuspectData> suspects READ suspects CONSTANT)
  25. QDeclarativeListProperty<SuspectData> suspects();
  26. Q_PROPERTY(QDeclarativeListProperty<TopPlayerData> players READ topPlayers NOTIFY scoreboardLoaded)
  27. QDeclarativeListProperty<TopPlayerData> topPlayers();
  28. Q_PROPERTY(EvidenceInfo* evidenceInfo READ evidenceInfo NOTIFY evidenceInfoChanged)
  29. EvidenceInfo* evidenceInfo() {return _evidenceInfo; }
  30. Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
  31. bool isPlaying() {return playing;}
  32. Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged)
  33. bool hasWon() {return won;}
  34. Q_PROPERTY(int numEvidences READ numEvidences NOTIFY numEvidencesChanged)
  35. int numEvidences() const{return nEvidences;}
  36. Q_PROPERTY(int foundEvidences READ foundEvidences NOTIFY foundEvidencesChanged)
  37. int foundEvidences() const{return fEvidences;}
  38. Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged)
  39. int numFlags() const{return nFlags;}
  40. Q_PROPERTY(int timeRemaining READ timeRemaining NOTIFY timeRemainingChanged)
  41. int timeRemaining() const{return remaining;}
  42. Q_PROPERTY(int streak READ streak NOTIFY wonStreakChanged)
  43. int streak() const {return wonStreak;}
  44. Q_PROPERTY(int currentScore READ currentScore NOTIFY currentScoreChanged)
  45. int currentScore() const {return score;}
  46. Q_PROPERTY(int lastScore READ lastScore NOTIFY lastScoreChanged)
  47. int lastScore() const;
  48. Q_PROPERTY(int totalScore READ totalScore NOTIFY totalScoreChanged)
  49. int totalScore() const;
  50. Q_PROPERTY(int maxScore READ maxScore NOTIFY maxScoreChanged)
  51. int maxScore() const;
  52. Q_PROPERTY(int maxScoreSubmitted READ maxScoreSubmitted NOTIFY maxScoreSubmittedChanged)
  53. int maxScoreSubmitted() const;
  54. Q_PROPERTY(bool solveMode READ solveMode NOTIFY solveModeChanged)
  55. bool solveMode() {return isSolveMode;}
  56. Q_PROPERTY(int killer READ killer NOTIFY killerChanged)
  57. int killer() const{ return killerId; }
  58. Q_PROPERTY(bool isInfoVisible READ isInfoVisible NOTIFY evidenceInfoChanged())
  59. bool isInfoVisible() {return _evidenceInfo->visible();}
  60. Q_PROPERTY(QString emptyString READ getEmptyString NOTIFY languageChanged)
  61. QString getEmptyString () { return ""; }
  62. Q_PROPERTY(int selectedLanguage READ currentLanguage NOTIFY languageChanged)
  63. int currentLanguage () {
  64. QString langString = _settings->value("lang").toString();
  65. int ret = 0;
  66. if (langString=="hu_HU") {
  67. ret = 1;
  68. } else if(langString=="sr_RS") {
  69. ret = 2;
  70. } else if(langString=="it_IT") {
  71. ret = 3;
  72. }
  73. return ret;
  74. }
  75. Q_PROPERTY(QString playerName READ player NOTIFY playerChanged)
  76. QString player();
  77. QList<QString> roleTypes;
  78. public slots:
  79. Q_INVOKABLE bool flip(int row, int col);
  80. Q_INVOKABLE bool flag(int row, int col);
  81. Q_INVOKABLE void shareGame() const;
  82. Q_INVOKABLE bool loadEvidence(int row, int col);
  83. Q_INVOKABLE bool suspectFlip(int id);
  84. Q_INVOKABLE bool suspectExclude(int id);
  85. Q_INVOKABLE bool toggleSolve();
  86. Q_INVOKABLE bool guessMurderer(int id);
  87. Q_INVOKABLE void selectLanguage(int lang);
  88. Q_INVOKABLE void openScoreboard();
  89. Q_INVOKABLE bool submitScore(QString name, int score);
  90. void loadLanguage();
  91. void refreshLanguage(bool loadStartScene = false);
  92. void setBoard();
  93. void reset();
  94. void changeEvidenceInfo() { emit evidenceInfoChanged(); }
  95. void loadScoreboardPlayers(QList< QHash<QString,QString> >);
  96. void boardSubmitSuccess(int);
  97. signals:
  98. void isPlayingChanged();
  99. void hasWonChanged();
  100. void numEvidencesChanged();
  101. void foundEvidencesChanged();
  102. void numFlagsChanged();
  103. void timeRemainingChanged();
  104. void currentScoreChanged();
  105. void lastScoreChanged();
  106. void totalScoreChanged();
  107. void maxScoreChanged();
  108. void maxScoreSubmittedChanged();
  109. void evidenceInfoChanged();
  110. void solveModeChanged();
  111. void killerChanged();
  112. void languageChanged();
  113. void openWelcomeDialog();
  114. void scoreboardLoaded();
  115. void openBoardErrorDialog();
  116. void playerChanged();
  117. void wonStreakChanged();
  118. private:
  119. bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; }
  120. TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; }
  121. SuspectData *suspect( int id ) { return _suspects[id]; }
  122. int getHint(int row, int col);
  123. EvidenceType* getType(int row, int col);
  124. void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();}
  125. QList<QString> loadFromXml(QString);
  126. QList<TileData *> _tiles;
  127. QList<SuspectData *> _suspects;
  128. QList<TopPlayerData *> _players;
  129. QList<EvidenceType *> tileTypes;
  130. QList<QString> suspectProperties;
  131. QList<QString> suspectNegativeProperties;
  132. QList<QString> startScenes;
  133. EvidenceInfo* _evidenceInfo;
  134. Scoreboard* _scoreboard;
  135. int numCols;
  136. int numRows;
  137. int nEvidences;
  138. int fEvidences;
  139. int numSuspects;
  140. bool playing;
  141. bool won;
  142. int remaining;
  143. int score;
  144. int nFlags;
  145. int defaultScore;
  146. int scoreMultiplier;
  147. int wonStreak;
  148. int startScene;
  149. int killerId;
  150. int alibiId;
  151. bool isSolveMode;
  152. QSettings* _settings;
  153. QApplication* _app;
  154. QTranslator* _translator;
  155. };
  156. #endif // EVIDENCEHUNTGAME_H