CampaignRegions.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * CampaignRegions.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 "../Point.h"
  12. #include "../filesystem/ResourcePath.h"
  13. #include "../constants/EntityIdentifiers.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class DLL_LINKAGE CampaignRegions
  16. {
  17. // Campaign editor
  18. friend class CampaignEditor;
  19. friend class CampaignProperties;
  20. friend class ScenarioProperties;
  21. /// Shared prefix for all campaign images
  22. std::string campPrefix;
  23. /// Suffix for enabled/selected/completed campaign region maps
  24. std::vector<std::string> campSuffix;
  25. /// Custom background name for campaign
  26. std::string campBackground;
  27. /// Lookup scheme for colored campaign images location
  28. int colorSuffixLength = 0;
  29. struct DLL_LINKAGE RegionDescription
  30. {
  31. std::string infix;
  32. Point pos;
  33. std::optional<Point> labelPos;
  34. template <typename Handler> void serialize(Handler &h)
  35. {
  36. h & infix;
  37. h & pos;
  38. h & labelPos;
  39. }
  40. RegionDescription() = default;
  41. explicit RegionDescription(const JsonNode & node);
  42. JsonNode toJson() const;
  43. };
  44. std::vector<RegionDescription> regions;
  45. ImagePath getNameFor(CampaignScenarioID which, int color, const std::string & type) const;
  46. public:
  47. CampaignRegions() = default;
  48. explicit CampaignRegions(const JsonNode & node);
  49. ImagePath getBackgroundName() const;
  50. Point getPosition(CampaignScenarioID which) const;
  51. std::optional<Point> getLabelPosition(CampaignScenarioID which) const;
  52. ImagePath getAvailableName(CampaignScenarioID which, int color) const;
  53. ImagePath getSelectedName(CampaignScenarioID which, int color) const;
  54. ImagePath getConqueredName(CampaignScenarioID which, int color) const;
  55. int regionsCount() const;
  56. template <typename Handler> void serialize(Handler &h)
  57. {
  58. h & campPrefix;
  59. h & colorSuffixLength;
  60. h & regions;
  61. h & campSuffix;
  62. h & campBackground;
  63. }
  64. JsonNode toJson() const;
  65. };
  66. VCMI_LIB_NAMESPACE_END