CHighScoreScreen.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 campaign;
  28. std::string land;
  29. };
  30. class HighScoreCalculation
  31. {
  32. public:
  33. std::vector<HighScoreParameter> parameters = std::vector<HighScoreParameter>();
  34. bool isCampaign = false;
  35. auto calculate();
  36. static CreatureID getCreatureForPoints(int points, bool campaign);
  37. };
  38. class CHighScoreScreen : public CWindowObject
  39. {
  40. public:
  41. enum HighScorePage { SCENARIO, CAMPAIGN };
  42. private:
  43. void addButtons();
  44. void addHighScores();
  45. void buttonCampaignClick();
  46. void buttonScenarioClick();
  47. void buttonResetClick();
  48. void buttonExitClick();
  49. void showPopupWindow(const Point & cursorPosition) override;
  50. HighScorePage highscorepage;
  51. std::shared_ptr<CPicture> background;
  52. std::vector<std::shared_ptr<CButton>> buttons;
  53. std::vector<std::shared_ptr<CLabel>> texts;
  54. std::vector<std::shared_ptr<CAnimImage>> images;
  55. int highlighted;
  56. public:
  57. CHighScoreScreen(HighScorePage highscorepage = HighScorePage::SCENARIO, int highlighted = -1);
  58. };
  59. class CHighScoreInput : public CWindowObject
  60. {
  61. std::shared_ptr<CMultiLineLabel> text;
  62. std::shared_ptr<CButton> buttonOk;
  63. std::shared_ptr<CButton> buttonCancel;
  64. std::shared_ptr<CGStatusBar> statusBar;
  65. std::shared_ptr<CTextInput> textInput;
  66. std::function<void(std::string text)> ready;
  67. void okay();
  68. void abort();
  69. public:
  70. CHighScoreInput(std::function<void(std::string text)> readyCB);
  71. };
  72. class CHighScoreInputScreen : public CWindowObject
  73. {
  74. std::vector<std::shared_ptr<CMultiLineLabel>> texts;
  75. std::shared_ptr<CHighScoreInput> input;
  76. std::shared_ptr<TransparentFilledRectangle> background;
  77. std::string video;
  78. bool won;
  79. HighScoreCalculation calc;
  80. public:
  81. CHighScoreInputScreen(bool won, HighScoreCalculation calc);
  82. int addEntry(std::string text);
  83. void show(Canvas & to) override;
  84. void activate() override;
  85. void deactivate() override;
  86. void clickPressed(const Point & cursorPosition) override;
  87. void keyPressed(EShortcut key) override;
  88. };