CCampaignScreen.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * CCampaignScreen.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. VCMI_LIB_NAMESPACE_BEGIN
  13. class JsonNode;
  14. VCMI_LIB_NAMESPACE_END
  15. class CLabel;
  16. class CPicture;
  17. class CButton;
  18. class VideoWidget;
  19. class CCampaignScreen : public CWindowObject
  20. {
  21. public:
  22. enum CampaignStatus {DEFAULT = 0, ENABLED, DISABLED, COMPLETED}; // the status of the campaign
  23. private:
  24. /// A button which plays a video when you move the mouse cursor over it
  25. class CCampaignButton : public CIntObject
  26. {
  27. private:
  28. std::shared_ptr<CLabel> hoverLabel;
  29. std::shared_ptr<CPicture> graphicsImage;
  30. std::shared_ptr<CPicture> graphicsCompleted;
  31. std::shared_ptr<VideoWidget> videoPlayer;
  32. CampaignStatus status;
  33. VideoPath videoPath;
  34. std::string campFile; // the filename/resourcename of the campaign
  35. std::string hoverText;
  36. std::string campaignSet;
  37. void clickReleased(const Point & cursorPosition) override;
  38. void hover(bool on) override;
  39. public:
  40. CCampaignButton(const JsonNode & config, const JsonNode & parentConfig, std::string campaignSet);
  41. };
  42. std::string campaignSet;
  43. std::vector<std::shared_ptr<CCampaignButton>> campButtons;
  44. std::vector<std::shared_ptr<CPicture>> images;
  45. std::shared_ptr<CButton> buttonBack;
  46. std::shared_ptr<CButton> buttonNext;
  47. std::shared_ptr<CButton> buttonPrev;
  48. std::shared_ptr<CLabel> page;
  49. std::shared_ptr<CButton> createExitButton(const JsonNode & button);
  50. int campaignsPerPage = 8;
  51. int currentPage = 0;
  52. int maxPages = 0;
  53. void switchPage(int delta);
  54. void updateCampaignButtons(const JsonNode& parentConfig);
  55. public:
  56. CCampaignScreen(const JsonNode & config, std::string campaignSet);
  57. void activate() override;
  58. };