CHighScoreScreen.h 2.5 KB

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