mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-11 19:58:49 -05:00
Add macro-helpers
Added to reduce dependencies to switcher-data
This commit is contained in:
@@ -237,6 +237,8 @@ target_sources(
|
||||
src/macro-core/macro-condition.hpp
|
||||
src/macro-core/macro-dock.cpp
|
||||
src/macro-core/macro-dock.hpp
|
||||
src/macro-core/macro-helpers.cpp
|
||||
src/macro-core/macro-helpers.hpp
|
||||
src/macro-core/macro-properties.cpp
|
||||
src/macro-core/macro-properties.hpp
|
||||
src/macro-core/macro-ref.cpp
|
||||
|
||||
59
src/macro-core/macro-helpers.cpp
Normal file
59
src/macro-core/macro-helpers.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "macro-helpers.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::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;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
21
src/macro-core/macro-helpers.hpp
Normal file
21
src/macro-core/macro-helpers.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <string_view>
|
||||
|
||||
namespace advss {
|
||||
|
||||
constexpr std::string_view GetSceneSwitchActionId()
|
||||
{
|
||||
return "scene_switch";
|
||||
}
|
||||
std::condition_variable &GetMacroWaitCV();
|
||||
std::condition_variable &GetMacroTransitionCV();
|
||||
std::atomic_bool &MacroWaitShouldAbort();
|
||||
void SetMacroAbortWait(bool);
|
||||
bool ShutdownCheckIsNecessary();
|
||||
std::atomic_int &GetShutdownConditionCount();
|
||||
void SetMacroSwitchedScene(bool value);
|
||||
bool MacroSwitchedScene();
|
||||
|
||||
} // namespace advss
|
||||
Reference in New Issue
Block a user