mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
The "core" macro conditions and actions have been extracted out to the "base" plugin. The library now mostly contains functionality which is required across all plugins and (e.g. definitions for macro segments). The goal is to reduce the complexity and cross-dependencies and group the source files in a better way. This should relsove the "library limit of 65535 objects exceeded" build issue occuring in some Windows build environments.
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#include "macro-condition-factory.hpp"
|
|
|
|
namespace advss {
|
|
|
|
std::map<std::string, MacroConditionInfo> &MacroConditionFactory::GetMap()
|
|
{
|
|
static std::map<std::string, MacroConditionInfo> _methods;
|
|
return _methods;
|
|
}
|
|
|
|
bool MacroConditionFactory::Register(const std::string &id,
|
|
MacroConditionInfo info)
|
|
{
|
|
if (auto it = GetMap().find(id); it == GetMap().end()) {
|
|
GetMap()[id] = info;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
std::shared_ptr<MacroCondition>
|
|
MacroConditionFactory::Create(const std::string &id, Macro *m)
|
|
{
|
|
if (auto it = GetMap().find(id); it != GetMap().end()) {
|
|
return it->second._create(m);
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
QWidget *
|
|
MacroConditionFactory::CreateWidget(const std::string &id, QWidget *parent,
|
|
std::shared_ptr<MacroCondition> cond)
|
|
{
|
|
if (auto it = GetMap().find(id); it != GetMap().end()) {
|
|
return it->second._createWidget(parent, cond);
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
std::string MacroConditionFactory::GetConditionName(const std::string &id)
|
|
{
|
|
if (auto it = GetMap().find(id); it != GetMap().end()) {
|
|
return it->second._name;
|
|
}
|
|
return "unknown condition";
|
|
}
|
|
|
|
std::string MacroConditionFactory::GetIdByName(const QString &name)
|
|
{
|
|
for (auto it : GetMap()) {
|
|
if (name == obs_module_text(it.second._name.c_str())) {
|
|
return it.first;
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
bool MacroConditionFactory::UsesDurationModifier(const std::string &id)
|
|
{
|
|
if (auto it = GetMap().find(id); it != GetMap().end()) {
|
|
return it->second._useDurationModifier;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace advss
|