CampaignRegions.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. std::string campPrefix;
  22. std::vector<std::string> campSuffix;
  23. std::string campBackground;
  24. int colorSuffixLength = 0;
  25. struct DLL_LINKAGE RegionDescription
  26. {
  27. std::string infix;
  28. Point pos;
  29. std::optional<Point> labelPos;
  30. template <typename Handler> void serialize(Handler &h)
  31. {
  32. h & infix;
  33. h & pos;
  34. h & labelPos;
  35. }
  36. static CampaignRegions::RegionDescription fromJson(const JsonNode & node);
  37. static JsonNode toJson(CampaignRegions::RegionDescription & rd);
  38. };
  39. std::vector<RegionDescription> regions;
  40. ImagePath getNameFor(CampaignScenarioID which, int color, const std::string & type) const;
  41. public:
  42. CampaignRegions() = default;
  43. explicit CampaignRegions(const JsonNode & node);
  44. ImagePath getBackgroundName() const;
  45. Point getPosition(CampaignScenarioID which) const;
  46. std::optional<Point> getLabelPosition(CampaignScenarioID which) const;
  47. ImagePath getAvailableName(CampaignScenarioID which, int color) const;
  48. ImagePath getSelectedName(CampaignScenarioID which, int color) const;
  49. ImagePath getConqueredName(CampaignScenarioID which, int color) const;
  50. int regionsCount() const;
  51. template <typename Handler> void serialize(Handler &h)
  52. {
  53. h & campPrefix;
  54. h & colorSuffixLength;
  55. h & regions;
  56. h & campSuffix;
  57. h & campBackground;
  58. }
  59. static JsonNode toJson(CampaignRegions cr);
  60. static CampaignRegions getLegacy(int campId);
  61. };
  62. VCMI_LIB_NAMESPACE_END