CModInfo.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * CModInfo.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 "../JsonNode.h"
  12. #include "ModVerificationInfo.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class DLL_LINKAGE CModInfo
  15. {
  16. /// cached result of checkModGameplayAffecting() call
  17. /// Do not serialize - depends on local mod version, not server/save mod version
  18. mutable std::optional<bool> modGameplayAffecting;
  19. public:
  20. enum EValidationStatus
  21. {
  22. PENDING,
  23. FAILED,
  24. PASSED
  25. };
  26. /// identifier, identical to name of folder with mod
  27. std::string identifier;
  28. /// detailed mod description
  29. std::string description;
  30. /// Base language of mod, all mod strings are assumed to be in this language
  31. std::string baseLanguage;
  32. /// vcmi versions compatible with the mod
  33. CModVersion vcmiCompatibleMin, vcmiCompatibleMax;
  34. /// list of mods that should be loaded before this one
  35. std::set <TModID> dependencies;
  36. /// list of mods that can't be used in the same time as this one
  37. std::set <TModID> conflicts;
  38. EValidationStatus validation;
  39. JsonNode config;
  40. CModInfo();
  41. CModInfo(const std::string & identifier, const JsonNode & local, const JsonNode & config);
  42. JsonNode saveLocalData() const;
  43. void updateChecksum(ui32 newChecksum);
  44. bool isEnabled() const;
  45. static std::string getModDir(const std::string & name);
  46. static JsonPath getModFile(const std::string & name);
  47. /// return true if this mod can affect gameplay, e.g. adds or modifies any game objects
  48. bool checkModGameplayAffecting() const;
  49. const ModVerificationInfo & getVerificationInfo() const;
  50. private:
  51. /// true if mod is enabled by user, e.g. in Launcher UI
  52. bool explicitlyEnabled;
  53. /// true if mod can be loaded - compatible and has no missing deps
  54. bool implicitlyEnabled;
  55. ModVerificationInfo verificationInfo;
  56. void loadLocalData(const JsonNode & data);
  57. };
  58. VCMI_LIB_NAMESPACE_END