Compare commits

...

3 Commits

Author SHA1 Message Date
WarmUpTill
1474509cb9 Fix extended sequence abort when using non-instant transitions 2021-07-30 00:47:40 +02:00
WarmUpTill
87aa8d3b40 Remove code used for backwards compatibility 2021-07-29 15:16:29 -07:00
WarmUpTill
d3e8b76fa6 Do not apply MouseWheelWidgetAdjustmentGuard to QScrollBars
Without this change, it will be annoying to interact with expanded
QComboBoxes and there should be no danger of accidentally modifying
macro settings by interacting with QScrollBars
2021-07-29 15:16:19 -07:00
7 changed files with 20 additions and 87 deletions

View File

@@ -35,8 +35,7 @@ struct SceneSequenceSwitch : SceneSwitcherEntry {
bool reduce();
SceneSequenceSwitch *extend();
bool checkMatch(OBSWeakSource currentScene, int &linger,
SceneSequenceSwitch *root = nullptr);
bool checkMatch(int &linger, SceneSequenceSwitch *root = nullptr);
bool checkDurationMatchInterruptible();
void prepareUninterruptibleMatch(int &linger);
void advanceActiveSequence();

View File

@@ -10,12 +10,6 @@ bool MacroConditionCursor::_registered = MacroConditionFactory::Register(
{MacroConditionCursor::Create, MacroConditionCursorEdit::Create,
"AdvSceneSwitcher.condition.cursor"});
// TODO: Remove in future version - just added for backwards compatibility
static const std::string idOld = "region";
static bool oldRegisterd = MacroConditionFactory::Register(
idOld, {MacroConditionCursor::Create, MacroConditionCursorEdit::Create,
"AdvSceneSwitcher.condition.cursor"});
static std::map<CursorCondition, std::string> cursorConditionTypes = {
{CursorCondition::REGION,
"AdvSceneSwitcher.condition.cursor.type.region"},

View File

@@ -10,12 +10,6 @@ bool MacroConditionMacro::_registered = MacroConditionFactory::Register(
{MacroConditionMacro::Create, MacroConditionMacroEdit::Create,
"AdvSceneSwitcher.condition.macro"});
// TODO: Remove in future version - just added for backward compatibility
static std::string idOld = "counter";
static bool oldRegisterd = MacroConditionFactory::Register(
idOld, {MacroConditionMacro::Create, MacroConditionMacroEdit::Create,
"AdvSceneSwitcher.condition.macro"});
static std::map<MacroConditionMacroType, std::string> macroConditionTypes = {
{MacroConditionMacroType::COUNT,
"AdvSceneSwitcher.condition.macro.type.count"},

View File

@@ -10,12 +10,6 @@ bool MacroConditionTimer::_registered = MacroConditionFactory::Register(
{MacroConditionTimer::Create, MacroConditionTimerEdit::Create,
"AdvSceneSwitcher.condition.timer", false});
// TODO: Remove in future version - just added for backward compatibility
static const std::string idOld = "interval";
static bool oldRegisterd = MacroConditionFactory::Register(
idOld, {MacroConditionTimer::Create, MacroConditionTimerEdit::Create,
"AdvSceneSwitcher.condition.timer", false});
bool MacroConditionTimer::CheckCondition()
{
if (_duration.DurationReached()) {

View File

@@ -5,6 +5,7 @@
#include <obs.hpp>
#include <QEvent>
#include <QLabel>
#include <QScrollBar>
bool MacroSegment::Save(obs_data_t *obj)
{
@@ -136,6 +137,11 @@ void MacroSegmentEdit::SetFocusPolicyOfWidgets()
QList<QWidget *> widgets = this->findChildren<QWidget *>();
for (auto w : widgets) {
w->setFocusPolicy(Qt::StrongFocus);
// Ignore QScrollBar as there is no danger of accidentally modifying anything
// and long expanded QComboBox would be difficult to interact with otherwise.
if (qobject_cast<QScrollBar *>(w)) {
continue;
}
w->installEventFilter(new MouseWheelWidgetAdjustmentGuard(w));
}
}

View File

@@ -454,71 +454,8 @@ void SwitcherData::saveMacros(obs_data_t *obj)
obs_data_array_release(macroArray);
}
// Temporary helper functions to convert old settings format to new one
static std::unordered_map<int, std::string> actionIntToActionString = {
{2, "audio"}, {4, "recording"}, {5, "replay_buffer"}, {6, "run"},
{3, "streaming"}, {0, "scene_switch"}, {1, "wait"},
};
static void replaceActionIds(obs_data_t *obj)
{
obs_data_array_t *actions = obs_data_get_array(obj, "actions");
size_t count = obs_data_array_count(actions);
for (size_t i = 0; i < count; i++) {
obs_data_t *array_obj = obs_data_array_item(actions, i);
auto oldId = obs_data_get_int(array_obj, "id");
obs_data_set_string(array_obj, "id",
actionIntToActionString[oldId].c_str());
obs_data_release(array_obj);
}
obs_data_array_release(actions);
}
static std::unordered_map<int, std::string> conditionIntToConditionString = {
{3, "audio"}, {4, "file"}, {10, "idle"}, {5, "media"},
{11, "plugin_state"}, {9, "process"}, {8, "recording"}, {2, "region"},
{0, "scene"}, {7, "streaming"}, {6, "video"}, {1, "window"},
};
static void replaceConditionIds(obs_data_t *obj)
{
obs_data_array_t *conditions = obs_data_get_array(obj, "conditions");
size_t count = obs_data_array_count(conditions);
for (size_t i = 0; i < count; i++) {
obs_data_t *array_obj = obs_data_array_item(conditions, i);
auto oldId = obs_data_get_int(array_obj, "id");
obs_data_set_string(
array_obj, "id",
conditionIntToConditionString[oldId].c_str());
obs_data_release(array_obj);
}
obs_data_array_release(conditions);
}
static void convertOldMacroIdsToString(obs_data_t *obj)
{
obs_data_array_t *macroArray = obs_data_get_array(obj, "macros");
size_t count = obs_data_array_count(macroArray);
for (size_t i = 0; i < count; i++) {
obs_data_t *array_obj = obs_data_array_item(macroArray, i);
replaceActionIds(array_obj);
replaceConditionIds(array_obj);
obs_data_release(array_obj);
}
obs_data_array_release(macroArray);
}
void SwitcherData::loadMacros(obs_data_t *obj)
{
// TODO: Remove conversion helper in future version
std::string previousVersion = obs_data_get_string(obj, "version");
if (previousVersion == "2ce0b35921be892c987c7dbb5fc90db38f15f0a6") {
convertOldMacroIdsToString(obj);
}
macros.clear();
obs_data_array_t *macroArray = obs_data_get_array(obj, "macros");

View File

@@ -203,7 +203,7 @@ bool SwitcherData::checkSceneSequence(OBSWeakSource &scene,
continue;
}
bool matched = s.checkMatch(currentScene, linger);
bool matched = s.checkMatch(linger);
if (!match && matched) {
match = matched;
@@ -395,8 +395,7 @@ SceneSequenceSwitch *SceneSequenceSwitch::extend()
return extendedSequence.get();
}
bool SceneSequenceSwitch::checkMatch(OBSWeakSource currentScene, int &linger,
SceneSequenceSwitch *root)
bool SceneSequenceSwitch::checkMatch(int &linger, SceneSequenceSwitch *root)
{
if (!initialized()) {
if (root) {
@@ -407,8 +406,18 @@ bool SceneSequenceSwitch::checkMatch(OBSWeakSource currentScene, int &linger,
bool match = false;
// We cannot rely on switcher->currentScene for this information.
// Depending on the transition length the frontend event for the scene
// change of the previous element in the sequence might not yet have
// been received, which would lead to the sequencence being aborted.
// Thus we have to use obs_frontend_get_current_scene() here.
auto sceneSource = obs_frontend_get_current_scene();
auto currentScene = obs_source_get_weak_source(sceneSource);
obs_weak_source_release(currentScene);
obs_source_release(sceneSource);
if (activeSequence) {
return activeSequence->checkMatch(currentScene, linger, this);
return activeSequence->checkMatch(linger, this);
}
if (startScene == currentScene) {