CHighScoreScreen.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 HighScoreParameter
  18. {
  19. public:
  20. int difficulty;
  21. int day;
  22. int townAmount;
  23. bool usedCheat;
  24. bool hasGrail;
  25. bool allDefeated;
  26. std::string campaign;
  27. std::string land;
  28. };
  29. class HighScoreCalculation
  30. {
  31. public:
  32. std::vector<HighScoreParameter> parameters = std::vector<HighScoreParameter>();
  33. bool isCampaign = false;
  34. auto calculate();
  35. static CreatureID getCreatureForPoints(int points, bool campaign);
  36. };
  37. class CHighScoreScreen : public CWindowObject
  38. {
  39. public:
  40. enum HighScorePage { SCENARIO, CAMPAIGN };
  41. private:
  42. void addButtons();
  43. void addHighScores();
  44. void buttonCampaginClick();
  45. void buttonStandardClick();
  46. void buttonResetClick();
  47. void buttonExitClick();
  48. void showPopupWindow(const Point & cursorPosition) override;
  49. HighScorePage highscorepage;
  50. std::shared_ptr<CPicture> background;
  51. std::vector<std::shared_ptr<CButton>> buttons;
  52. std::vector<std::shared_ptr<CLabel>> texts;
  53. std::vector<std::shared_ptr<CAnimImage>> images;
  54. int highlighted;
  55. public:
  56. CHighScoreScreen(HighScorePage highscorepage = HighScorePage::SCENARIO, int highlighted = -1);
  57. };
  58. class CHighScoreInput : public CWindowObject
  59. {
  60. std::shared_ptr<CPicture> background;
  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::string video;
  77. bool won;
  78. HighScoreCalculation calc;
  79. public:
  80. CHighScoreInputScreen(bool won, HighScoreCalculation calc);
  81. int addEntry(std::string text);
  82. void show(Canvas & to) override;
  83. void activate() override;
  84. void deactivate() override;
  85. void clickPressed(const Point & cursorPosition) override;
  86. };