CModHandler.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. void loadTranslation(const TModID & modName);
  23. void checkModFilesystemsConflicts(const std::map<TModID, ISimpleResourceLoader *> & modFilesystems);
  24. public:
  25. std::shared_ptr<CContentHandler> content; //FIXME: make private
  26. /// receives list of available mods and trying to load mod.json from all of them
  27. void initializeConfig();
  28. void loadModFilesystems();
  29. /// returns ID of mod that provides selected file resource
  30. TModID findResourceOrigin(const ResourcePath & name) const;
  31. /// Returns assumed language ID of mod that provides selected file resource
  32. std::string findResourceLanguage(const ResourcePath & name) const;
  33. /// Returns assumed encoding of language of mod that provides selected file resource
  34. std::string findResourceEncoding(const ResourcePath & name) const;
  35. std::string getModLanguage(const TModID & modId) const;
  36. std::set<TModID> getModDependencies(const TModID & modId) const;
  37. std::set<TModID> getModDependencies(const TModID & modId, bool & isModFound) const;
  38. std::set<TModID> getModSoftDependencies(const TModID & modId) const;
  39. std::set<TModID> getModEnabledSoftDependencies(const TModID & modId) const;
  40. /// returns list of all (active) mods
  41. std::vector<std::string> getAllMods() const;
  42. std::vector<std::string> getActiveMods() const;
  43. /// Returns human-readable string that describes errors encounter during mod loading, such as missing dependencies
  44. std::string getModLoadErrors() const;
  45. const ModDescription & getModInfo(const TModID & modId) const;
  46. /// load content from all available mods
  47. void load();
  48. void afterLoad(bool onlyEssential);
  49. CModHandler();
  50. ~CModHandler();
  51. };
  52. VCMI_LIB_NAMESPACE_END