CHighScoreScreen.h 2.4 KB

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