CHighScoreScreen.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. void showAll(Canvas & to) override;
  36. HighScorePage highscorepage;
  37. std::shared_ptr<CPicture> background;
  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<CButton> statisticButton;
  66. bool won;
  67. HighScoreCalculation calc;
  68. StatisticDataSet stat;
  69. void stopMusicAndClose();
  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. void showAll(Canvas & to) override;
  78. };