mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
Add option to configure macro pause state on startup
This commit is contained in:
parent
a196e56078
commit
c2d2e883c6
|
|
@ -207,6 +207,10 @@ AdvSceneSwitcher.macroTab.currentUseCustomConditionCheckInterval="Check conditio
|
|||
AdvSceneSwitcher.macroTab.currentUseCustomConditionCheckIntervalWarning="⚠️ The selected value is lower than the interval configured on the General tab.\nThe configured value not have any effect!"
|
||||
AdvSceneSwitcher.macroTab.currentSkipExecutionOnStartup="Skip execution of actions of current macro on startup"
|
||||
AdvSceneSwitcher.macroTab.currentStopActionsIfNotDone="Stop and rerun actions of the currently selected macro, if the actions are still running, when a new execution is triggered"
|
||||
AdvSceneSwitcher.macroTab.pauseStateSaveBehavior="On startup set the pause state of the current macro to:"
|
||||
AdvSceneSwitcher.macroTab.pauseStateSaveBehavior.persist="The state the macro was last in"
|
||||
AdvSceneSwitcher.macroTab.pauseStateSaveBehavior.pause="Paused"
|
||||
AdvSceneSwitcher.macroTab.pauseStateSaveBehavior.unpause="Unpaused"
|
||||
AdvSceneSwitcher.macroTab.currentRegisterDock="Register dock widget to control the pause state of selected macro or run it manually"
|
||||
AdvSceneSwitcher.macroTab.currentDockAddRunButton="Add button to run the macro"
|
||||
AdvSceneSwitcher.macroTab.currentDockAddPauseButton="Add button to pause or unpause the macro"
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||
new DurationSelection(this, true, 0.01)),
|
||||
_currentCustomConditionCheckIntervalWarning(new QLabel(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.currentUseCustomConditionCheckIntervalWarning"))),
|
||||
_currentPauseSaveBehavior(new QComboBox(this)),
|
||||
_currentSkipOnStartup(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.currentSkipExecutionOnStartup"))),
|
||||
_currentStopActionsIfNotDone(new QCheckBox(obs_module_text(
|
||||
|
|
@ -113,6 +114,19 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||
_currentUseShortCircuitEvaluation->setToolTip(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.shortCircuit.tooltip"));
|
||||
|
||||
_currentPauseSaveBehavior->addItem(
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.pauseStateSaveBehavior.persist"),
|
||||
static_cast<int>(Macro::PauseStateSaveBehavior::PERSIST));
|
||||
_currentPauseSaveBehavior->addItem(
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.pauseStateSaveBehavior.pause"),
|
||||
static_cast<int>(Macro::PauseStateSaveBehavior::PAUSE));
|
||||
_currentPauseSaveBehavior->addItem(
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.pauseStateSaveBehavior.unpause"),
|
||||
static_cast<int>(Macro::PauseStateSaveBehavior::UNPAUSE));
|
||||
|
||||
auto highlightOptions = new QGroupBox(
|
||||
obs_module_text("AdvSceneSwitcher.macroTab.highlightSettings"));
|
||||
auto highlightLayout = new QVBoxLayout;
|
||||
|
|
@ -145,8 +159,15 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||
customConditionIntervalLayout->addLayout(durationLayout);
|
||||
customConditionIntervalLayout->addWidget(
|
||||
_currentCustomConditionCheckIntervalWarning);
|
||||
|
||||
generalLayout->addLayout(customConditionIntervalLayout);
|
||||
|
||||
auto pauseStateSaveBehavorLayout = new QHBoxLayout();
|
||||
pauseStateSaveBehavorLayout->addWidget(new QLabel(obs_module_text(
|
||||
"AdvSceneSwitcher.macroTab.pauseStateSaveBehavior")));
|
||||
pauseStateSaveBehavorLayout->addWidget(_currentPauseSaveBehavior);
|
||||
pauseStateSaveBehavorLayout->addStretch();
|
||||
generalLayout->addLayout(pauseStateSaveBehavorLayout);
|
||||
|
||||
generalOptions->setLayout(generalLayout);
|
||||
|
||||
auto inputOptions = new QGroupBox(
|
||||
|
|
@ -266,6 +287,7 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||
_currentStopActionsIfNotDone->hide();
|
||||
_currentUseShortCircuitEvaluation->hide();
|
||||
SetLayoutVisible(customConditionIntervalLayout, false);
|
||||
SetLayoutVisible(pauseStateSaveBehavorLayout, false);
|
||||
|
||||
inputOptions->hide();
|
||||
_dockOptions->hide();
|
||||
|
|
@ -282,6 +304,9 @@ MacroSettingsDialog::MacroSettingsDialog(QWidget *parent,
|
|||
_currentCustomConditionCheckInterval->setEnabled(
|
||||
macro->CustomConditionCheckIntervalEnabled());
|
||||
SetCustomConditionIntervalWarningVisibility();
|
||||
_currentPauseSaveBehavior->setCurrentIndex(
|
||||
_currentPauseSaveBehavior->findData(
|
||||
static_cast<int>(macro->GetPauseStateSaveBehavior())));
|
||||
_currentSkipOnStartup->setChecked(macro->SkipExecOnStart());
|
||||
_currentStopActionsIfNotDone->setChecked(macro->StopActionsIfNotDone());
|
||||
_currentInputs->SetInputs(macro->GetInputVariables());
|
||||
|
|
@ -424,6 +449,10 @@ bool MacroSettingsDialog::AskForSettings(QWidget *parent,
|
|||
dialog._currentUseCustomConditionCheckInterval->isChecked());
|
||||
macro->SetCustomConditionCheckInterval(
|
||||
dialog._currentCustomConditionCheckInterval->GetDuration());
|
||||
macro->SetPauseStateSaveBehavior(
|
||||
static_cast<Macro::PauseStateSaveBehavior>(
|
||||
dialog._currentPauseSaveBehavior->currentData()
|
||||
.toInt()));
|
||||
macro->SetSkipExecOnStart(dialog._currentSkipOnStartup->isChecked());
|
||||
macro->SetStopActionsIfNotDone(
|
||||
dialog._currentStopActionsIfNotDone->isChecked());
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ private:
|
|||
QCheckBox *_currentUseCustomConditionCheckInterval;
|
||||
DurationSelection *_currentCustomConditionCheckInterval;
|
||||
QLabel *_currentCustomConditionCheckIntervalWarning;
|
||||
QComboBox *_currentPauseSaveBehavior;
|
||||
QCheckBox *_currentSkipOnStartup;
|
||||
QCheckBox *_currentStopActionsIfNotDone;
|
||||
MacroInputSelection *_currentInputs;
|
||||
|
|
|
|||
|
|
@ -481,6 +481,16 @@ void Macro::AddHelperThread(std::thread &&newThread)
|
|||
_helperThreads.push_back(std::move(newThread));
|
||||
}
|
||||
|
||||
void Macro::SetPauseStateSaveBehavior(PauseStateSaveBehavior behavior)
|
||||
{
|
||||
_pauseSaveBehavior = behavior;
|
||||
}
|
||||
|
||||
Macro::PauseStateSaveBehavior Macro::GetPauseStateSaveBehavior() const
|
||||
{
|
||||
return _pauseSaveBehavior;
|
||||
}
|
||||
|
||||
void Macro::Stop()
|
||||
{
|
||||
_stop = true;
|
||||
|
|
@ -690,6 +700,8 @@ bool Macro::Save(obs_data_t *obj, bool saveForCopy) const
|
|||
return true;
|
||||
}
|
||||
|
||||
obs_data_set_int(obj, "pauseSaveBehavior",
|
||||
static_cast<int>(_pauseSaveBehavior));
|
||||
obs_data_set_bool(obj, "pause", _paused);
|
||||
obs_data_set_bool(obj, "parallel", _runInParallel);
|
||||
obs_data_set_bool(obj, "onChange", _performActionsOnChange);
|
||||
|
|
@ -760,7 +772,22 @@ bool Macro::Load(obs_data_t *obj)
|
|||
return true;
|
||||
}
|
||||
|
||||
_paused = obs_data_get_bool(obj, "pause");
|
||||
_pauseSaveBehavior = static_cast<PauseStateSaveBehavior>(
|
||||
obs_data_get_int(obj, "pauseSaveBehavior"));
|
||||
switch (_pauseSaveBehavior) {
|
||||
case PauseStateSaveBehavior::PERSIST:
|
||||
_paused = obs_data_get_bool(obj, "pause");
|
||||
break;
|
||||
case PauseStateSaveBehavior::PAUSE:
|
||||
_paused = true;
|
||||
break;
|
||||
case PauseStateSaveBehavior::UNPAUSE:
|
||||
_paused = false;
|
||||
break;
|
||||
default:
|
||||
_paused = obs_data_get_bool(obj, "pause");
|
||||
break;
|
||||
}
|
||||
_runInParallel = obs_data_get_bool(obj, "parallel");
|
||||
_performActionsOnChange = obs_data_get_bool(obj, "onChange");
|
||||
_skipExecOnStart = obs_data_get_bool(obj, "skipExecOnStart");
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class Macro {
|
|||
using TimePoint = std::chrono::high_resolution_clock::time_point;
|
||||
|
||||
public:
|
||||
enum class PauseStateSaveBehavior { PERSIST, PAUSE, UNPAUSE };
|
||||
|
||||
Macro(const std::string &name = "", const bool addHotkey = false,
|
||||
const bool shortCircuitEvaluation = false);
|
||||
~Macro();
|
||||
|
|
@ -45,6 +47,9 @@ public:
|
|||
bool Paused() const { return _paused; }
|
||||
bool WasPausedSince(const TimePoint &) const;
|
||||
|
||||
void SetPauseStateSaveBehavior(PauseStateSaveBehavior);
|
||||
PauseStateSaveBehavior GetPauseStateSaveBehavior() const;
|
||||
|
||||
void Stop();
|
||||
bool GetStop() const { return _stop; }
|
||||
void ResetTimers();
|
||||
|
|
@ -211,6 +216,9 @@ private:
|
|||
obs_hotkey_id _unpauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id _togglePauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
|
||||
PauseStateSaveBehavior _pauseSaveBehavior =
|
||||
PauseStateSaveBehavior::PERSIST;
|
||||
|
||||
MacroInputVariables _inputVariables;
|
||||
|
||||
// UI helpers
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user