CHighScoreScreen.h 2.4 KB

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