| 250 | } |
| 251 | |
| 252 | bool GameFeatures::registerGameFeature(MOBase::IPlugin* plugin, |
| 253 | QStringList const& games, |
| 254 | std::shared_ptr<MOBase::GameFeature> feature, |
| 255 | int priority) |
| 256 | { |
| 257 | auto& features = m_allFeatures[feature->typeInfo()]; |
| 258 | |
| 259 | if (std::find_if(features.begin(), features.end(), [&feature](const auto& data) { |
| 260 | return data.feature() == feature; |
| 261 | }) != features.end()) { |
| 262 | log::error("cannot register feature multiple time"); |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | std::decay_t<decltype(features)>::iterator it; |
| 267 | if (dynamic_cast<IPluginGame*>(plugin)) { |
| 268 | it = features.end(); |
| 269 | } else { |
| 270 | it = std::lower_bound(features.begin(), features.end(), priority, |
| 271 | [](const auto& feature, int priority) { |
| 272 | return feature.priority() > priority; |
| 273 | }); |
| 274 | } |
| 275 | |
| 276 | features.emplace(it, feature, plugin, games, std::numeric_limits<int>::min()); |
| 277 | |
| 278 | // TODO: only update if relevant |
| 279 | updateCurrentFeatures(feature->typeInfo()); |
| 280 | |
| 281 | return true; |
| 282 | } |
| 283 | |
| 284 | // unregister game features |
| 285 | // |
no test coverage detected