mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-29 13:25:29 -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.
133 lines
2.2 KiB
C++
133 lines
2.2 KiB
C++
#include "macro-helpers.hpp"
|
|
#include "macro.hpp"
|
|
#include "plugin-state-helpers.hpp"
|
|
|
|
namespace advss {
|
|
|
|
static std::atomic_bool abortMacroWait = {false};
|
|
static std::atomic_bool macroSceneSwitched = {false};
|
|
static std::atomic_int shutdownConditionCount = {0};
|
|
|
|
std::optional<std::deque<std::shared_ptr<MacroAction>>>
|
|
GetMacroActions(Macro *macro)
|
|
{
|
|
if (!macro) {
|
|
return {};
|
|
}
|
|
return macro->Actions();
|
|
}
|
|
|
|
std::optional<std::deque<std::shared_ptr<MacroCondition>>>
|
|
GetMacroConditions(Macro *macro)
|
|
{
|
|
if (!macro) {
|
|
return {};
|
|
}
|
|
return macro->Conditions();
|
|
}
|
|
|
|
std::string_view GetSceneSwitchActionId()
|
|
{
|
|
return MacroAction::GetDefaultID();
|
|
}
|
|
|
|
std::condition_variable &GetMacroWaitCV()
|
|
{
|
|
static std::condition_variable cv;
|
|
return cv;
|
|
}
|
|
|
|
std::condition_variable &GetMacroTransitionCV()
|
|
{
|
|
static std::condition_variable cv;
|
|
return cv;
|
|
}
|
|
|
|
std::atomic_bool &MacroWaitShouldAbort()
|
|
{
|
|
return abortMacroWait;
|
|
}
|
|
|
|
void SetMacroAbortWait(bool value)
|
|
{
|
|
abortMacroWait = value;
|
|
}
|
|
|
|
bool ShutdownCheckIsNecessary()
|
|
{
|
|
return shutdownConditionCount > 0;
|
|
}
|
|
|
|
std::atomic_int &GetShutdownConditionCount()
|
|
{
|
|
return shutdownConditionCount;
|
|
}
|
|
|
|
void SetMacroSwitchedScene(bool value)
|
|
{
|
|
static bool setupDone = false;
|
|
if (!setupDone) {
|
|
// Will always be called with switcher lock already held
|
|
AddIntervalResetStep([]() { macroSceneSwitched = false; },
|
|
false);
|
|
setupDone = true;
|
|
}
|
|
macroSceneSwitched = value;
|
|
}
|
|
|
|
bool MacroSwitchedScene()
|
|
{
|
|
return macroSceneSwitched;
|
|
}
|
|
|
|
std::string GetMacroName(Macro *macro)
|
|
{
|
|
return macro ? macro->Name() : "";
|
|
}
|
|
|
|
int64_t MillisecondsSinceMacroConditionCheck(Macro *macro)
|
|
{
|
|
return macro ? macro->MsSinceLastCheck() : 0;
|
|
}
|
|
|
|
bool MacroIsStopped(Macro *macro)
|
|
{
|
|
return macro ? macro->GetStop() : true;
|
|
}
|
|
|
|
bool MacroIsPaused(Macro *macro)
|
|
{
|
|
return macro ? macro->Paused() : true;
|
|
}
|
|
|
|
void AddMacroHelperThread(Macro *macro, std::thread &&newThread)
|
|
{
|
|
if (!macro) {
|
|
return;
|
|
}
|
|
macro->AddHelperThread(std::move(newThread));
|
|
}
|
|
|
|
bool RunMacroActions(Macro *macro)
|
|
{
|
|
return macro && macro->PerformActions(true);
|
|
}
|
|
|
|
void ResetMacroConditionTimers(Macro *macro)
|
|
{
|
|
if (!macro) {
|
|
return;
|
|
}
|
|
macro->ResetTimers();
|
|
}
|
|
|
|
void ResetMacroRunCount(Macro *macro)
|
|
{
|
|
if (!macro) {
|
|
return;
|
|
}
|
|
macro->ResetRunCount();
|
|
}
|
|
|
|
} // namespace advss
|