summaryrefslogtreecommitdiff
path: root/src/gamefeaturesproxy.cpp
blob: 1c833a2fe1899bc2a6206296f1b3f883c7d1d7c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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(QStringList(), 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);
}