2
0

CModInfo.h 2.0 KB

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