2023-10-19 16:19:09 +02:00
|
|
|
/*
|
|
|
|
* CModHandler.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class CModHandler;
|
2024-11-09 22:29:07 +02:00
|
|
|
class ModDescription;
|
2023-10-19 16:19:09 +02:00
|
|
|
class CContentHandler;
|
|
|
|
class ResourcePath;
|
2024-11-09 22:29:07 +02:00
|
|
|
class ModManager;
|
|
|
|
class ISimpleResourceLoader;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
using TModID = std::string;
|
|
|
|
|
2023-11-07 18:32:40 +02:00
|
|
|
class DLL_LINKAGE CModHandler final : boost::noncopyable
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
2024-11-09 22:29:07 +02:00
|
|
|
std::unique_ptr<ModManager> modManager;
|
2024-11-14 17:41:22 +02:00
|
|
|
std::map<std::string, uint32_t> modChecksums;
|
|
|
|
std::set<std::string> validationPassed;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2024-11-09 22:29:07 +02:00
|
|
|
void loadTranslation(const TModID & modName);
|
|
|
|
void checkModFilesystemsConflicts(const std::map<TModID, ISimpleResourceLoader *> & modFilesystems);
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2024-11-14 17:41:22 +02:00
|
|
|
bool isModValidationNeeded(const ModDescription & mod) const;
|
|
|
|
|
2023-10-19 16:19:09 +02:00
|
|
|
public:
|
2024-11-14 17:41:22 +02:00
|
|
|
std::shared_ptr<CContentHandler> content;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
/// receives list of available mods and trying to load mod.json from all of them
|
|
|
|
void initializeConfig();
|
|
|
|
void loadModFilesystems();
|
|
|
|
|
|
|
|
/// returns ID of mod that provides selected file resource
|
2023-11-15 17:57:40 +02:00
|
|
|
TModID findResourceOrigin(const ResourcePath & name) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2024-10-30 13:54:35 +02:00
|
|
|
/// Returns assumed language ID of mod that provides selected file resource
|
|
|
|
std::string findResourceLanguage(const ResourcePath & name) const;
|
|
|
|
|
|
|
|
/// Returns assumed encoding of language of mod that provides selected file resource
|
|
|
|
std::string findResourceEncoding(const ResourcePath & name) const;
|
|
|
|
|
2023-10-19 16:19:09 +02:00
|
|
|
std::string getModLanguage(const TModID & modId) const;
|
|
|
|
|
2024-10-06 17:54:30 +02:00
|
|
|
std::set<TModID> getModDependencies(const TModID & modId) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
std::set<TModID> getModDependencies(const TModID & modId, bool & isModFound) const;
|
2024-10-25 17:21:32 +02:00
|
|
|
std::set<TModID> getModSoftDependencies(const TModID & modId) const;
|
|
|
|
std::set<TModID> getModEnabledSoftDependencies(const TModID & modId) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
/// returns list of all (active) mods
|
2023-11-15 17:57:40 +02:00
|
|
|
std::vector<std::string> getAllMods() const;
|
2024-11-14 17:41:22 +02:00
|
|
|
const std::vector<std::string> & getActiveMods() const;
|
2023-11-15 17:57:40 +02:00
|
|
|
|
2024-11-09 22:29:07 +02:00
|
|
|
const ModDescription & getModInfo(const TModID & modId) const;
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
/// load content from all available mods
|
|
|
|
void load();
|
|
|
|
void afterLoad(bool onlyEssential);
|
|
|
|
|
|
|
|
CModHandler();
|
2023-11-07 18:32:40 +02:00
|
|
|
~CModHandler();
|
2023-10-19 16:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|