mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-21 03:52:07 -05:00
Add more plugin state helpers
This commit is contained in:
parent
bcf0a0b7fd
commit
23df42d2d3
|
|
@ -173,8 +173,13 @@ void SwitcherData::SaveVersion(obs_data_t *obj,
|
|||
obs_data_set_string(obj, "version", currentVersion.c_str());
|
||||
}
|
||||
|
||||
void SwitcherData::AddIntervalResetStep(std::function<void()> function)
|
||||
void SwitcherData::AddIntervalResetStep(std::function<void()> function,
|
||||
bool tryLock)
|
||||
{
|
||||
if (!tryLock) {
|
||||
resetIntervalSteps.emplace_back(function);
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
resetIntervalSteps.emplace_back(function);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public:
|
|||
void AddSaveStep(std::function<void(obs_data_t *)>);
|
||||
void AddLoadStep(std::function<void(obs_data_t *)>);
|
||||
void AddPostLoadStep(std::function<void()>);
|
||||
void AddIntervalResetStep(std::function<void()>);
|
||||
void AddIntervalResetStep(std::function<void()>, bool lock = true);
|
||||
bool CheckForMatch(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
int &linger, bool &setPreviousSceneAsMatch,
|
||||
bool ¯oMatch);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "plugin-state-helper.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "switcher-data.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
|
@ -23,9 +23,9 @@ void AddPostLoadStep(std::function<void()> step)
|
|||
GetSwitcher()->AddPostLoadStep(step);
|
||||
}
|
||||
|
||||
void AddIntervalResetStep(std::function<void()> step)
|
||||
void AddIntervalResetStep(std::function<void()> step, bool lock)
|
||||
{
|
||||
GetSwitcher()->AddIntervalResetStep(step);
|
||||
GetSwitcher()->AddIntervalResetStep(step, lock);
|
||||
}
|
||||
|
||||
void StopPlugin()
|
||||
|
|
@ -38,24 +38,70 @@ void StartPlugin()
|
|||
GetSwitcher()->Start();
|
||||
}
|
||||
|
||||
bool PluginIsRunning()
|
||||
{
|
||||
return GetSwitcher() && GetSwitcher()->th &&
|
||||
GetSwitcher()->th->isRunning();
|
||||
}
|
||||
|
||||
int GetIntervalValue()
|
||||
{
|
||||
return GetSwitcher()->interval;
|
||||
}
|
||||
|
||||
void SetPluginNoMatchBehavior(NoMatchBehavior behavior)
|
||||
{
|
||||
GetSwitcher()->switchIfNotMatching = behavior;
|
||||
}
|
||||
|
||||
void SetNoMatchScene(const OBSWeakSource &scene)
|
||||
{
|
||||
GetSwitcher()->nonMatchingScene = scene;
|
||||
}
|
||||
|
||||
NoMatchBehavior GetPluginNoMatchBehavior()
|
||||
{
|
||||
return GetSwitcher()->switchIfNotMatching;
|
||||
}
|
||||
|
||||
void SetNoMatchScene(const OBSWeakSource &scene)
|
||||
{
|
||||
GetSwitcher()->nonMatchingScene = scene;
|
||||
}
|
||||
|
||||
std::string ForegroundWindowTitle()
|
||||
{
|
||||
return GetSwitcher()->currentTitle;
|
||||
}
|
||||
|
||||
std::string PreviousForegroundWindowTitle()
|
||||
{
|
||||
return GetSwitcher()->lastTitle;
|
||||
}
|
||||
|
||||
bool SettingsWindowIsOpened()
|
||||
{
|
||||
return GetSwitcher()->settingsWindowOpened;
|
||||
}
|
||||
|
||||
bool HighlightUIElementsEnabled()
|
||||
{
|
||||
return GetSwitcher() && !GetSwitcher()->disableHints;
|
||||
}
|
||||
|
||||
bool OBSIsShuttingDown()
|
||||
{
|
||||
return GetSwitcher()->obsIsShuttingDown;
|
||||
}
|
||||
|
||||
bool InitialLoadIsComplete()
|
||||
{
|
||||
return GetSwitcher()->startupLoadDone;
|
||||
}
|
||||
|
||||
bool IsFirstInterval()
|
||||
{
|
||||
return GetSwitcher()->firstInterval;
|
||||
}
|
||||
|
||||
bool IsFirstIntervalAfterStop()
|
||||
{
|
||||
return GetSwitcher()->firstIntervalAfterStop;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <functional>
|
||||
#include <obs.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace advss {
|
||||
|
||||
|
|
@ -9,16 +10,27 @@ void LoadPluginSettings(obs_data_t *);
|
|||
void AddSaveStep(std::function<void(obs_data_t *)>);
|
||||
void AddLoadStep(std::function<void(obs_data_t *)>);
|
||||
void AddPostLoadStep(std::function<void()>);
|
||||
void AddIntervalResetStep(std::function<void()>);
|
||||
void AddIntervalResetStep(std::function<void()>, bool lock = true);
|
||||
|
||||
void StopPlugin();
|
||||
void StartPlugin();
|
||||
bool PluginIsRunning();
|
||||
int GetIntervalValue();
|
||||
|
||||
enum class NoMatchBehavior { NO_SWITCH = 0, SWITCH = 1, RANDOM_SWITCH = 2 };
|
||||
void SetPluginNoMatchBehavior(NoMatchBehavior);
|
||||
NoMatchBehavior GetPluginNoMatchBehavior();
|
||||
void SetNoMatchScene(const OBSWeakSource &);
|
||||
|
||||
std::string ForegroundWindowTitle();
|
||||
std::string PreviousForegroundWindowTitle();
|
||||
|
||||
bool SettingsWindowIsOpened();
|
||||
bool HighlightUIElementsEnabled();
|
||||
|
||||
bool OBSIsShuttingDown();
|
||||
bool InitialLoadIsComplete();
|
||||
bool IsFirstInterval();
|
||||
bool IsFirstIntervalAfterStop();
|
||||
|
||||
} // namespace advss
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user