CHighScoreScreen.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 rowEvent(std::function<void(int row, bool currentGameNotInListEntry)> func, const Point & cursorPosition);
  35. void clickPressed(const Point & cursorPosition) override;
  36. void showPopupWindow(const Point & cursorPosition) override;
  37. void showAll(Canvas & to) override;
  38. HighScorePage highscorepage;
  39. std::shared_ptr<CPicture> background;
  40. std::vector<std::shared_ptr<CButton>> buttons;
  41. std::vector<std::shared_ptr<CLabel>> texts;
  42. std::vector<std::shared_ptr<CAnimImage>> images;
  43. const int screenRows = 11;
  44. int highlighted;
  45. public:
  46. CHighScoreScreen(HighScorePage highscorepage, int highlighted = -1);
  47. };
  48. class CHighScoreInput : public CWindowObject
  49. {
  50. std::shared_ptr<CMultiLineLabel> text;
  51. std::shared_ptr<CButton> buttonOk;
  52. std::shared_ptr<CButton> buttonCancel;
  53. std::shared_ptr<CGStatusBar> statusBar;
  54. std::shared_ptr<CTextInput> textInput;
  55. std::function<void(std::string text)> ready;
  56. void okay();
  57. void abort();
  58. public:
  59. CHighScoreInput(std::string playerName, std::function<void(std::string text)> readyCB);
  60. };
  61. class CHighScoreInputScreen : public CWindowObject, public IVideoHolder
  62. {
  63. std::vector<std::shared_ptr<CLabel>> texts;
  64. std::shared_ptr<CHighScoreInput> input;
  65. std::shared_ptr<TransparentFilledRectangle> background;
  66. std::shared_ptr<VideoWidgetBase> videoPlayer;
  67. std::shared_ptr<CButton> statisticButton;
  68. bool won;
  69. HighScoreCalculation calc;
  70. StatisticDataSet stat;
  71. void stopMusicAndClose();
  72. void onVideoPlaybackFinished() override;
  73. public:
  74. CHighScoreInputScreen(bool won, HighScoreCalculation calc, const StatisticDataSet & statistic);
  75. int addEntry(std::string text);
  76. void clickPressed(const Point & cursorPosition) override;
  77. void keyPressed(EShortcut key) override;
  78. void show(Canvas & to) override;
  79. void showAll(Canvas & to) override;
  80. };