CHighScoreScreen.h 2.6 KB

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