mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
Do not check conditions of paused macros
This commit is contained in:
parent
5af206da60
commit
2155a942f3
|
|
@ -77,7 +77,7 @@ public:
|
|||
bool Matched() { return _matched; }
|
||||
std::string Name() { return _name; }
|
||||
void SetName(const std::string &name);
|
||||
void SetPaused(bool pause = true) { _paused = pause; }
|
||||
void SetPaused(bool pause = true);
|
||||
bool Paused() { return _paused; }
|
||||
int GetCount() { return _count; };
|
||||
void ResetCount() { _count = 0; };
|
||||
|
|
@ -102,6 +102,7 @@ private:
|
|||
void SetupHotkeys();
|
||||
void ClearHotkeys();
|
||||
void SetHotkeysDesc();
|
||||
void ResetTimers();
|
||||
|
||||
std::string _name = "";
|
||||
std::deque<std::shared_ptr<MacroCondition>> _conditions;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ bool Macro::CeckMatch()
|
|||
{
|
||||
_matched = false;
|
||||
for (auto &c : _conditions) {
|
||||
if (_paused) {
|
||||
vblog(LOG_INFO, "Macro %s is paused", _name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
auto startTime = std::chrono::high_resolution_clock::now();
|
||||
bool cond = c->CheckCondition();
|
||||
auto endTime = std::chrono::high_resolution_clock::now();
|
||||
|
|
@ -88,18 +93,6 @@ bool Macro::CeckMatch()
|
|||
}
|
||||
|
||||
vblog(LOG_INFO, "Macro %s returned %d", _name.c_str(), _matched);
|
||||
|
||||
// Condition checks shall still be run even if macro is paused.
|
||||
// Otherwise conditions might behave in unexpected ways when resuming.
|
||||
//
|
||||
// For example, audio could immediately match after unpause, when it
|
||||
// matched before it was paused due to timers not being updated.
|
||||
if (_paused) {
|
||||
vblog(LOG_INFO, "Macro %s is paused", _name.c_str());
|
||||
_matched = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return _matched;
|
||||
}
|
||||
|
||||
|
|
@ -125,6 +118,21 @@ void Macro::SetName(const std::string &name)
|
|||
SetHotkeysDesc();
|
||||
}
|
||||
|
||||
void Macro::ResetTimers()
|
||||
{
|
||||
for (auto &c : _conditions) {
|
||||
c->ResetDuration();
|
||||
}
|
||||
}
|
||||
|
||||
void Macro::SetPaused(bool pause)
|
||||
{
|
||||
if (_paused && !pause) {
|
||||
ResetTimers();
|
||||
}
|
||||
_paused = pause;
|
||||
}
|
||||
|
||||
void Macro::UpdateActionIndices()
|
||||
{
|
||||
int idx = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user