CModHandler.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * CModHandler.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. VCMI_LIB_NAMESPACE_BEGIN
  12. class CModHandler;
  13. class ModDescription;
  14. class CContentHandler;
  15. class ResourcePath;
  16. class ModManager;
  17. class ISimpleResourceLoader;
  18. using TModID = std::string;
  19. class DLL_LINKAGE CModHandler final : boost::noncopyable
  20. {
  21. std::unique_ptr<ModManager> modManager;
  22. std::map<std::string, uint32_t> modChecksums;
  23. std::set<std::string> validationPassed;
  24. void loadTranslation(const TModID & modName);
  25. void checkModFilesystemsConflicts(const std::map<TModID, ISimpleResourceLoader *> & modFilesystems);
  26. bool isModValidationNeeded(const ModDescription & mod) const;
  27. public:
  28. std::shared_ptr<CContentHandler> content;
  29. /// receives list of available mods and trying to load mod.json from all of them
  30. void initializeConfig();
  31. void loadModFilesystems();
  32. /// returns ID of mod that provides selected file resource
  33. TModID findResourceOrigin(const ResourcePath & name) const;
  34. /// Returns assumed language ID of mod that provides selected file resource
  35. std::string findResourceLanguage(const ResourcePath & name) const;
  36. /// Returns assumed encoding of language of mod that provides selected file resource
  37. std::string findResourceEncoding(const ResourcePath & name) const;
  38. std::string getModLanguage(const TModID & modId) const;
  39. std::set<TModID> getModDependencies(const TModID & modId) const;
  40. std::set<TModID> getModDependencies(const TModID & modId, bool & isModFound) const;
  41. std::set<TModID> getModSoftDependencies(const TModID & modId) const;
  42. std::set<TModID> getModEnabledSoftDependencies(const TModID & modId) const;
  43. /// returns list of all (active) mods
  44. std::vector<std::string> getAllMods() const;
  45. const std::vector<std::string> & getActiveMods() const;
  46. const ModDescription & getModInfo(const TModID & modId) const;
  47. /// load content from all available mods
  48. void load();
  49. void afterLoad();
  50. CModHandler();
  51. ~CModHandler();
  52. };
  53. VCMI_LIB_NAMESPACE_END