From 88c386d74d7d94ec16d4d84ed674eb51e31647ac Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sun, 9 Jun 2024 12:18:17 +0200 Subject: Refactoring of game features for better management. (#2043) --- src/gamefeaturesproxy.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/gamefeaturesproxy.cpp (limited to 'src/gamefeaturesproxy.cpp') 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 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 feature, + int priority, bool replace) +{ + return registerFeature({game->gameName()}, feature, priority, replace); +} + +bool GameFeaturesProxy::registerFeature(std::shared_ptr feature, + int priority, bool replace) +{ + return registerFeature({}, feature, priority, replace); +} + +bool GameFeaturesProxy::unregisterFeature(std::shared_ptr feature) +{ + return m_Features.unregisterGameFeature(feature); +} + +std::shared_ptr +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); +} -- cgit v1.3.1