mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 09:05:57 -05:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1474509cb9 | ||
|
|
87aa8d3b40 | ||
|
|
d3e8b76fa6 | ||
|
|
99c9b1a4a2 | ||
|
|
8c0aad4c96 |
@@ -457,6 +457,7 @@ AdvSceneSwitcher.videoTab.help="<html><head/><body><p>This tab will allow you to
|
|||||||
|
|
||||||
; Network Tab
|
; Network Tab
|
||||||
AdvSceneSwitcher.networkTab.title="Network"
|
AdvSceneSwitcher.networkTab.title="Network"
|
||||||
|
AdvSceneSwitcher.networkTab.description="This tab will allow you to remotely control the active scene of another OBS instance.\nPlease note that the scene names have to match exactly on all OBS instances."
|
||||||
AdvSceneSwitcher.networkTab.warning="Running the server outside of a local network will allow third parties to read the active scene."
|
AdvSceneSwitcher.networkTab.warning="Running the server outside of a local network will allow third parties to read the active scene."
|
||||||
AdvSceneSwitcher.networkTab.DisabledWarning="This functionality unfortunately had to be disabled on macOS due to library incompatibilities when running the obs-websocket plugin in parallel."
|
AdvSceneSwitcher.networkTab.DisabledWarning="This functionality unfortunately had to be disabled on macOS due to library incompatibilities when running the obs-websocket plugin in parallel."
|
||||||
AdvSceneSwitcher.networkTab.server="Start server (Sends scene switch messages to all connected clients)"
|
AdvSceneSwitcher.networkTab.server="Start server (Sends scene switch messages to all connected clients)"
|
||||||
|
|||||||
@@ -3716,6 +3716,13 @@
|
|||||||
<string>AdvSceneSwitcher.networkTab.title</string>
|
<string>AdvSceneSwitcher.networkTab.title</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_30">
|
<layout class="QVBoxLayout" name="verticalLayout_30">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="networkTabDescription">
|
||||||
|
<property name="text">
|
||||||
|
<string>AdvSceneSwitcher.networkTab.description</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="networkTabWarningLabel">
|
<widget class="QLabel" name="networkTabWarningLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ struct SceneSequenceSwitch : SceneSwitcherEntry {
|
|||||||
bool reduce();
|
bool reduce();
|
||||||
SceneSequenceSwitch *extend();
|
SceneSequenceSwitch *extend();
|
||||||
|
|
||||||
bool checkMatch(OBSWeakSource currentScene, int &linger,
|
bool checkMatch(int &linger, SceneSequenceSwitch *root = nullptr);
|
||||||
SceneSequenceSwitch *root = nullptr);
|
|
||||||
bool checkDurationMatchInterruptible();
|
bool checkDurationMatchInterruptible();
|
||||||
void prepareUninterruptibleMatch(int &linger);
|
void prepareUninterruptibleMatch(int &linger);
|
||||||
void advanceActiveSequence();
|
void advanceActiveSequence();
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ bool MacroConditionCursor::_registered = MacroConditionFactory::Register(
|
|||||||
{MacroConditionCursor::Create, MacroConditionCursorEdit::Create,
|
{MacroConditionCursor::Create, MacroConditionCursorEdit::Create,
|
||||||
"AdvSceneSwitcher.condition.cursor"});
|
"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 = {
|
static std::map<CursorCondition, std::string> cursorConditionTypes = {
|
||||||
{CursorCondition::REGION,
|
{CursorCondition::REGION,
|
||||||
"AdvSceneSwitcher.condition.cursor.type.region"},
|
"AdvSceneSwitcher.condition.cursor.type.region"},
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ bool MacroConditionMacro::_registered = MacroConditionFactory::Register(
|
|||||||
{MacroConditionMacro::Create, MacroConditionMacroEdit::Create,
|
{MacroConditionMacro::Create, MacroConditionMacroEdit::Create,
|
||||||
"AdvSceneSwitcher.condition.macro"});
|
"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 = {
|
static std::map<MacroConditionMacroType, std::string> macroConditionTypes = {
|
||||||
{MacroConditionMacroType::COUNT,
|
{MacroConditionMacroType::COUNT,
|
||||||
"AdvSceneSwitcher.condition.macro.type.count"},
|
"AdvSceneSwitcher.condition.macro.type.count"},
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ bool MacroConditionTimer::_registered = MacroConditionFactory::Register(
|
|||||||
{MacroConditionTimer::Create, MacroConditionTimerEdit::Create,
|
{MacroConditionTimer::Create, MacroConditionTimerEdit::Create,
|
||||||
"AdvSceneSwitcher.condition.timer", false});
|
"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()
|
bool MacroConditionTimer::CheckCondition()
|
||||||
{
|
{
|
||||||
if (_duration.DurationReached()) {
|
if (_duration.DurationReached()) {
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ bool MacroConditionVideo::Save(obs_data_t *obj)
|
|||||||
|
|
||||||
bool MacroConditionVideo::Load(obs_data_t *obj)
|
bool MacroConditionVideo::Load(obs_data_t *obj)
|
||||||
{
|
{
|
||||||
|
MacroCondition::Load(obj);
|
||||||
const char *videoSourceName = obs_data_get_string(obj, "videoSource");
|
const char *videoSourceName = obs_data_get_string(obj, "videoSource");
|
||||||
_videoSource = GetWeakSourceByName(videoSourceName);
|
_videoSource = GetWeakSourceByName(videoSourceName);
|
||||||
_condition =
|
_condition =
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <obs.hpp>
|
#include <obs.hpp>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
bool MacroSegment::Save(obs_data_t *obj)
|
bool MacroSegment::Save(obs_data_t *obj)
|
||||||
{
|
{
|
||||||
@@ -136,6 +137,11 @@ void MacroSegmentEdit::SetFocusPolicyOfWidgets()
|
|||||||
QList<QWidget *> widgets = this->findChildren<QWidget *>();
|
QList<QWidget *> widgets = this->findChildren<QWidget *>();
|
||||||
for (auto w : widgets) {
|
for (auto w : widgets) {
|
||||||
w->setFocusPolicy(Qt::StrongFocus);
|
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));
|
w->installEventFilter(new MouseWheelWidgetAdjustmentGuard(w));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,71 +454,8 @@ void SwitcherData::saveMacros(obs_data_t *obj)
|
|||||||
obs_data_array_release(macroArray);
|
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)
|
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();
|
macros.clear();
|
||||||
|
|
||||||
obs_data_array_t *macroArray = obs_data_get_array(obj, "macros");
|
obs_data_array_t *macroArray = obs_data_get_array(obj, "macros");
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ bool SwitcherData::checkSceneSequence(OBSWeakSource &scene,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matched = s.checkMatch(currentScene, linger);
|
bool matched = s.checkMatch(linger);
|
||||||
|
|
||||||
if (!match && matched) {
|
if (!match && matched) {
|
||||||
match = matched;
|
match = matched;
|
||||||
@@ -395,8 +395,7 @@ SceneSequenceSwitch *SceneSequenceSwitch::extend()
|
|||||||
return extendedSequence.get();
|
return extendedSequence.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SceneSequenceSwitch::checkMatch(OBSWeakSource currentScene, int &linger,
|
bool SceneSequenceSwitch::checkMatch(int &linger, SceneSequenceSwitch *root)
|
||||||
SceneSequenceSwitch *root)
|
|
||||||
{
|
{
|
||||||
if (!initialized()) {
|
if (!initialized()) {
|
||||||
if (root) {
|
if (root) {
|
||||||
@@ -407,8 +406,18 @@ bool SceneSequenceSwitch::checkMatch(OBSWeakSource currentScene, int &linger,
|
|||||||
|
|
||||||
bool match = false;
|
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) {
|
if (activeSequence) {
|
||||||
return activeSequence->checkMatch(currentScene, linger, this);
|
return activeSequence->checkMatch(linger, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startScene == currentScene) {
|
if (startScene == currentScene) {
|
||||||
|
|||||||
Reference in New Issue
Block a user