CHighScoreScreen.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * CHighScoreScreen.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../windows/CWindowObject.h"
  12. class CButton;
  13. class CLabel;
  14. class CMultiLineLabel;
  15. class CAnimImage;
  16. class CTextInput;
  17. class TransparentFilledRectangle;
  18. class HighScoreParameter
  19. {
  20. public:
  21. int difficulty;
  22. int day;
  23. int townAmount;
  24. bool usedCheat;
  25. bool hasGrail;
  26. bool allDefeated;
  27. std::string campaignName;
  28. std::string scenarioName;
  29. std::string playerName;
  30. };
  31. class HighScoreCalculation
  32. {
  33. public:
  34. std::vector<HighScoreParameter> parameters = std::vector<HighScoreParameter>();
  35. bool isCampaign = false;
  36. auto calculate();
  37. static CreatureID getCreatureForPoints(int points, bool campaign);
  38. };
  39. class CHighScoreScreen : public CWindowObject
  40. {
  41. public:
  42. enum HighScorePage { SCENARIO, CAMPAIGN };
  43. private:
  44. void addButtons();
  45. void addHighScores();
  46. void buttonCampaignClick();
  47. void buttonScenarioClick();
  48. void buttonResetClick();
  49. void buttonExitClick();
  50. void showPopupWindow(const Point & cursorPosition) override;
  51. HighScorePage highscorepage;
  52. std::shared_ptr<CPicture> background;
  53. std::vector<std::shared_ptr<CButton>> buttons;
  54. std::vector<std::shared_ptr<CLabel>> texts;
  55. std::vector<std::shared_ptr<CAnimImage>> images;
  56. const int screenRows = 11;
  57. int highlighted;
  58. public:
  59. CHighScoreScreen(HighScorePage highscorepage, int highlighted = -1);
  60. };
  61. class CHighScoreInput : public CWindowObject
  62. {
  63. std::shared_ptr<CMultiLineLabel> text;
  64. std::shared_ptr<CButton> buttonOk;
  65. std::shared_ptr<CButton> buttonCancel;
  66. std::shared_ptr<CGStatusBar> statusBar;
  67. std::shared_ptr<CTextInput> textInput;
  68. std::function<void(std::string text)> ready;
  69. void okay();
  70. void abort();
  71. public:
  72. CHighScoreInput(std::string playerName, std::function<void(std::string text)> readyCB);
  73. };
  74. class CHighScoreInputScreen : public CWindowObject
  75. {
  76. std::vector<std::shared_ptr<CMultiLineLabel>> texts;
  77. std::shared_ptr<CHighScoreInput> input;
  78. std::shared_ptr<TransparentFilledRectangle> background;
  79. std::string video;
  80. int sound;
  81. bool won;
  82. HighScoreCalculation calc;
  83. public:
  84. CHighScoreInputScreen(bool won, HighScoreCalculation calc);
  85. int addEntry(std::string text);
  86. void show(Canvas & to) override;
  87. void activate() override;
  88. void deactivate() override;
  89. void clickPressed(const Point & cursorPosition) override;
  90. void keyPressed(EShortcut key) override;
  91. };