diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2024-06-09 12:18:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-09 12:18:17 +0200 |
| commit | 88c386d74d7d94ec16d4d84ed674eb51e31647ac (patch) | |
| tree | adf0b2537f12d11d8df77f68a84926d15b063554 /src/gamefeaturesproxy.cpp | |
| parent | c43535f5bcf1043c3b9c00c77967267cf1acf60f (diff) | |
Refactoring of game features for better management. (#2043)
Diffstat (limited to 'src/gamefeaturesproxy.cpp')
| -rw-r--r-- | src/gamefeaturesproxy.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/gamefeaturesproxy.cpp b/src/gamefeaturesproxy.cpp new file mode 100644 index 00000000..3adac353 --- /dev/null +++ b/src/gamefeaturesproxy.cpp @@ -0,0 +1,48 @@ +#include "gamefeaturesproxy.h" + +#include "game_features.h" +#include "organizerproxy.h" + +GameFeaturesProxy::GameFeaturesProxy(OrganizerProxy* coreProxy, + GameFeatures& gameFeatures) + : m_CoreProxy(*coreProxy), m_Features(gameFeatures) +{} + +bool GameFeaturesProxy::registerFeature(QStringList const& games, + std::shared_ptr<MOBase::GameFeature> feature, + int priority, bool replace) +{ + if (replace) { + m_Features.unregisterGameFeatures(m_CoreProxy.plugin(), feature->typeInfo()); + } + return m_Features.registerGameFeature(m_CoreProxy.plugin(), games, feature, priority); +} + +bool GameFeaturesProxy::registerFeature(MOBase::IPluginGame* game, + std::shared_ptr<MOBase::GameFeature> feature, + int priority, bool replace) +{ + return registerFeature({game->gameName()}, feature, priority, replace); +} + +bool GameFeaturesProxy::registerFeature(std::shared_ptr<MOBase::GameFeature> feature, + int priority, bool replace) +{ + return registerFeature({}, feature, priority, replace); +} + +bool GameFeaturesProxy::unregisterFeature(std::shared_ptr<MOBase::GameFeature> feature) +{ + return m_Features.unregisterGameFeature(feature); +} + +std::shared_ptr<MOBase::GameFeature> +GameFeaturesProxy::gameFeatureImpl(std::type_info const& info) const +{ + return m_Features.gameFeature(info); +} + +int GameFeaturesProxy::unregisterFeaturesImpl(std::type_info const& info) +{ + return m_Features.unregisterGameFeatures(m_CoreProxy.plugin(), info); +} |
