impr: Further improve interfacing with external plugins

This commit is contained in:
WerWolv
2024-01-22 23:35:00 +01:00
parent 00491c8d90
commit b605c463a1
8 changed files with 39 additions and 12 deletions

View File

@@ -226,6 +226,18 @@ namespace hex {
#endif
}
void PluginManager::addLoadPath(const std::fs::path& path) {
getPluginLoadPaths().emplace_back(path);
}
bool PluginManager::load() {
bool success = true;
for (const auto &loadPath : getPluginLoadPaths())
success = PluginManager::load(loadPath) && success;
return success;
}
bool PluginManager::load(const std::fs::path &pluginFolder) {
@@ -295,6 +307,12 @@ namespace hex {
return pluginPaths;
}
std::vector<std::fs::path> &PluginManager::getPluginLoadPaths() {
static std::vector<std::fs::path> pluginPaths;
return pluginPaths;
}
bool PluginManager::isPluginLoaded(const std::fs::path &path) {
return std::ranges::any_of(getPlugins(), [&path](const Plugin &plugin) {
return plugin.getPath().filename() == path.filename();