mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-08 09:36:07 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
465f55d3f3 | ||
|
|
9758c14c33 |
@@ -173,8 +173,6 @@ target_sources(
|
|||||||
lib/macro/macro-signals.hpp
|
lib/macro/macro-signals.hpp
|
||||||
lib/macro/macro-tab.cpp
|
lib/macro/macro-tab.cpp
|
||||||
lib/macro/macro-tree.cpp
|
lib/macro/macro-tree.cpp
|
||||||
lib/macro/macro-undo-redo.cpp
|
|
||||||
lib/macro/macro-undo-redo.hpp
|
|
||||||
lib/macro/macro-tree.hpp
|
lib/macro/macro-tree.hpp
|
||||||
lib/macro/macro-websocket-trigger.cpp
|
lib/macro/macro-websocket-trigger.cpp
|
||||||
lib/macro/macro.cpp
|
lib/macro/macro.cpp
|
||||||
|
|||||||
@@ -198,20 +198,6 @@ AdvSceneSwitcher.macroTab.groupNameExists="The name \"%1\" is already used by a
|
|||||||
AdvSceneSwitcher.macroTab.removeSingleMacroPopup.text="Are you sure you want to remove \"%1\"?"
|
AdvSceneSwitcher.macroTab.removeSingleMacroPopup.text="Are you sure you want to remove \"%1\"?"
|
||||||
AdvSceneSwitcher.macroTab.removeMultipleMacrosPopup.text="Are you sure you want to remove %1 macros/groups?"
|
AdvSceneSwitcher.macroTab.removeMultipleMacrosPopup.text="Are you sure you want to remove %1 macros/groups?"
|
||||||
AdvSceneSwitcher.macroTab.removeGroupPopup.text="Are you sure you want to remove \"%1\" group and all its elements?"
|
AdvSceneSwitcher.macroTab.removeGroupPopup.text="Are you sure you want to remove \"%1\" group and all its elements?"
|
||||||
AdvSceneSwitcher.undo.renameMacro="Rename Macro '%1'"
|
|
||||||
AdvSceneSwitcher.undo.modifyMacro="Modify Macro '%1'"
|
|
||||||
AdvSceneSwitcher.undo.addMacro="Add Macro '%1'"
|
|
||||||
AdvSceneSwitcher.undo.removeMacro="Remove Macro '%1'"
|
|
||||||
AdvSceneSwitcher.undo.importMacros="Import Macros"
|
|
||||||
AdvSceneSwitcher.undo.addSegment="Add %1 in '%2'"
|
|
||||||
AdvSceneSwitcher.undo.removeSegment="Remove %1 in '%2'"
|
|
||||||
AdvSceneSwitcher.undo.changeSegmentType="Change %1 Type in '%2'"
|
|
||||||
AdvSceneSwitcher.undo.groupMacros="Group Macros '%1'"
|
|
||||||
AdvSceneSwitcher.undo.ungroupMacros="Ungroup Macros '%1'"
|
|
||||||
AdvSceneSwitcher.undo.removeMacroGroup="Remove Macro Group '%1'"
|
|
||||||
AdvSceneSwitcher.undo.segment.action="Action"
|
|
||||||
AdvSceneSwitcher.undo.segment.elseAction="Else Action"
|
|
||||||
AdvSceneSwitcher.undo.segment.condition="Condition"
|
|
||||||
AdvSceneSwitcher.macroTab.contextMenuAdd="Add"
|
AdvSceneSwitcher.macroTab.contextMenuAdd="Add"
|
||||||
AdvSceneSwitcher.macroTab.copy="Duplicate Macro"
|
AdvSceneSwitcher.macroTab.copy="Duplicate Macro"
|
||||||
AdvSceneSwitcher.macroTab.group="Group Selected Macros"
|
AdvSceneSwitcher.macroTab.group="Group Selected Macros"
|
||||||
@@ -356,9 +342,7 @@ AdvSceneSwitcher.condition.audio.type.volume="Configured volume level"
|
|||||||
AdvSceneSwitcher.condition.audio.type.syncOffset="Sync offset"
|
AdvSceneSwitcher.condition.audio.type.syncOffset="Sync offset"
|
||||||
AdvSceneSwitcher.condition.audio.type.monitor="Audio monitoring"
|
AdvSceneSwitcher.condition.audio.type.monitor="Audio monitoring"
|
||||||
AdvSceneSwitcher.condition.audio.type.balance="Audio balance"
|
AdvSceneSwitcher.condition.audio.type.balance="Audio balance"
|
||||||
AdvSceneSwitcher.condition.audio.type.track="Audio track"
|
|
||||||
AdvSceneSwitcher.condition.audio.entry="{{checkType}}of{{audioSources}}is{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
|
AdvSceneSwitcher.condition.audio.entry="{{checkType}}of{{audioSources}}is{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
|
||||||
AdvSceneSwitcher.condition.audio.layout.track="{{audioSources}}is enabled on{{checkType}}{{track}}"
|
|
||||||
AdvSceneSwitcher.condition.cursor="Cursor"
|
AdvSceneSwitcher.condition.cursor="Cursor"
|
||||||
AdvSceneSwitcher.condition.cursor.type.region="is in region"
|
AdvSceneSwitcher.condition.cursor.type.region="is in region"
|
||||||
AdvSceneSwitcher.condition.cursor.type.moving="is moving"
|
AdvSceneSwitcher.condition.cursor.type.moving="is moving"
|
||||||
@@ -920,19 +904,9 @@ AdvSceneSwitcher.condition.streamDeck.stopListen="Stop listening"
|
|||||||
AdvSceneSwitcher.condition.streamDeck.pluginDownload="<html><head/><body><p>The Stream Deck plugin can be found <a href=\"https://github.com/WarmUpTill/advanced-scene-switcher-streamdeck-plugin/releases\"><span style=\" text-decoration: underline; color:#268bd2;\">here on GitHub</span></a>.</p></body></html>"
|
AdvSceneSwitcher.condition.streamDeck.pluginDownload="<html><head/><body><p>The Stream Deck plugin can be found <a href=\"https://github.com/WarmUpTill/advanced-scene-switcher-streamdeck-plugin/releases\"><span style=\" text-decoration: underline; color:#268bd2;\">here on GitHub</span></a>.</p></body></html>"
|
||||||
AdvSceneSwitcher.condition.gameCapture="Game capture"
|
AdvSceneSwitcher.condition.gameCapture="Game capture"
|
||||||
AdvSceneSwitcher.condition.gameCapture.entry="{{sources}}hooked a game."
|
AdvSceneSwitcher.condition.gameCapture.entry="{{sources}}hooked a game."
|
||||||
|
|
||||||
AdvSceneSwitcher.condition.screenshot="Screenshot"
|
AdvSceneSwitcher.condition.screenshot="Screenshot"
|
||||||
AdvSceneSwitcher.condition.screenshot.entry="A screenshot was taken"
|
AdvSceneSwitcher.condition.screenshot.entry="A screenshot was taken"
|
||||||
AdvSceneSwitcher.condition.nowPlaying="Now Playing"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.checkType.playbackState="Playback state"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.checkType.title="Title"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.checkType.artist="Artist"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.checkType.album="Album"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.checkType.appName="App name"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.playbackState.playing="Playing"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.playbackState.paused="Paused"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.playbackState.stopped="Stopped"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.playbackState.opening="Opening"
|
|
||||||
AdvSceneSwitcher.condition.nowPlaying.playbackState.changing="Changing"
|
|
||||||
AdvSceneSwitcher.condition.mqtt="MQTT"
|
AdvSceneSwitcher.condition.mqtt="MQTT"
|
||||||
AdvSceneSwitcher.condition.mqtt.layout.match="Message was received from{{connection}} which matches{{regex}}:"
|
AdvSceneSwitcher.condition.mqtt.layout.match="Message was received from{{connection}} which matches{{regex}}:"
|
||||||
AdvSceneSwitcher.condition.mqtt.layout.listen="Set message selection to incoming message:{{listenButton}}"
|
AdvSceneSwitcher.condition.mqtt.layout.listen="Set message selection to incoming message:{{listenButton}}"
|
||||||
@@ -999,6 +973,7 @@ AdvSceneSwitcher.action.playAudio.monitorUnavailable="Audio monitoring not avail
|
|||||||
AdvSceneSwitcher.action.playAudio.tracks="Tracks"
|
AdvSceneSwitcher.action.playAudio.tracks="Tracks"
|
||||||
AdvSceneSwitcher.action.playAudio.layout.startOffset="{{useStartOffset}}Start at{{startOffset}}"
|
AdvSceneSwitcher.action.playAudio.layout.startOffset="{{useStartOffset}}Start at{{startOffset}}"
|
||||||
AdvSceneSwitcher.action.playAudio.layout.playbackDuration="{{useDuration}}Play for{{playbackDuration}}(0 = until end)"
|
AdvSceneSwitcher.action.playAudio.layout.playbackDuration="{{useDuration}}Play for{{playbackDuration}}(0 = until end)"
|
||||||
|
AdvSceneSwitcher.action.playAudio.mono="Mono"
|
||||||
AdvSceneSwitcher.action.recording="Recording"
|
AdvSceneSwitcher.action.recording="Recording"
|
||||||
AdvSceneSwitcher.action.recording.type.stop="Stop recording"
|
AdvSceneSwitcher.action.recording.type.stop="Stop recording"
|
||||||
AdvSceneSwitcher.action.recording.type.start="Start recording"
|
AdvSceneSwitcher.action.recording.type.start="Start recording"
|
||||||
@@ -2390,7 +2365,6 @@ AdvSceneSwitcher.tempVar.audio.muted="Source muted"
|
|||||||
AdvSceneSwitcher.tempVar.audio.sync_offset="Source audio sync offset"
|
AdvSceneSwitcher.tempVar.audio.sync_offset="Source audio sync offset"
|
||||||
AdvSceneSwitcher.tempVar.audio.monitor="Source audio monitor type"
|
AdvSceneSwitcher.tempVar.audio.monitor="Source audio monitor type"
|
||||||
AdvSceneSwitcher.tempVar.audio.balance="Source audio balance"
|
AdvSceneSwitcher.tempVar.audio.balance="Source audio balance"
|
||||||
AdvSceneSwitcher.tempVar.audio.trackEnabled="Audio track enabled"
|
|
||||||
|
|
||||||
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary="Primary clipboard item MIME type"
|
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary="Primary clipboard item MIME type"
|
||||||
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary.description="Highest priority MIME type of the current item stored in clipboard, if available."
|
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary.description="Highest priority MIME type of the current item stored in clipboard, if available."
|
||||||
@@ -2626,12 +2600,6 @@ AdvSceneSwitcher.tempVar.gameCapture.class.description="Window class of the appl
|
|||||||
AdvSceneSwitcher.tempVar.gameCapture.executable="Executable"
|
AdvSceneSwitcher.tempVar.gameCapture.executable="Executable"
|
||||||
AdvSceneSwitcher.tempVar.gameCapture.executable.description="Executable name of the application captured by the source."
|
AdvSceneSwitcher.tempVar.gameCapture.executable.description="Executable name of the application captured by the source."
|
||||||
|
|
||||||
AdvSceneSwitcher.tempVar.nowPlaying.title="Title"
|
|
||||||
AdvSceneSwitcher.tempVar.nowPlaying.artist="Artist"
|
|
||||||
AdvSceneSwitcher.tempVar.nowPlaying.album="Album"
|
|
||||||
AdvSceneSwitcher.tempVar.nowPlaying.appName="App name"
|
|
||||||
AdvSceneSwitcher.tempVar.nowPlaying.playbackStatus="Playback status"
|
|
||||||
|
|
||||||
AdvSceneSwitcher.tempVar.http.status="Status code"
|
AdvSceneSwitcher.tempVar.http.status="Status code"
|
||||||
AdvSceneSwitcher.tempVar.http.error="Error"
|
AdvSceneSwitcher.tempVar.http.error="Error"
|
||||||
AdvSceneSwitcher.tempVar.http.error.description="Empty when no error occurred.\nOther possible values:\n\n * Could not establish connection\n * Failed to bind IP address\n * Failed to read connection\n * Failed to write connection\n * Maximum redirect count exceeded\n * Connection handling canceled\n * SSL connection failed\n * SSL certificate loading failed\n * SSL server verification failed\n * Unsupported HTTP multipart boundary characters\n * Compression failed\n * Connection timed out\n * Proxy connection failed\n * Unknown"
|
AdvSceneSwitcher.tempVar.http.error.description="Empty when no error occurred.\nOther possible values:\n\n * Could not establish connection\n * Failed to bind IP address\n * Failed to read connection\n * Failed to write connection\n * Maximum redirect count exceeded\n * Connection handling canceled\n * SSL connection failed\n * SSL certificate loading failed\n * SSL server verification failed\n * Unsupported HTTP multipart boundary characters\n * Compression failed\n * Connection timed out\n * Proxy connection failed\n * Unknown"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "macro-action-edit.hpp"
|
#include "macro-action-edit.hpp"
|
||||||
#include "macro-undo-redo.hpp"
|
|
||||||
#include "advanced-scene-switcher.hpp"
|
#include "advanced-scene-switcher.hpp"
|
||||||
#include "macro-helpers.hpp"
|
#include "macro-helpers.hpp"
|
||||||
#include "macro-settings.hpp"
|
#include "macro-settings.hpp"
|
||||||
@@ -112,32 +111,9 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *const parentMacro =
|
|
||||||
(*_entryData)->GetMacro()->GetNestedParentMacro();
|
|
||||||
OBSDataAutoRelease parentBeforeData;
|
|
||||||
if (parentMacro) {
|
|
||||||
parentBeforeData = obs_data_create();
|
|
||||||
parentMacro->Save(parentBeforeData);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string oldId = (*_entryData)->GetId();
|
|
||||||
OBSDataAutoRelease oldData = obs_data_create();
|
|
||||||
(*_entryData)->Save(oldData);
|
|
||||||
|
|
||||||
HeaderInfoChanged("");
|
HeaderInfoChanged("");
|
||||||
auto idx = _entryData->get()->GetIndex();
|
auto idx = _entryData->get()->GetIndex();
|
||||||
auto macro = _entryData->get()->GetMacro();
|
auto macro = _entryData->get()->GetMacro();
|
||||||
|
|
||||||
// Determine whether this is an action or else-action before resetting.
|
|
||||||
const auto *rawPtr = (*_entryData).get();
|
|
||||||
const auto &elseActions = macro->ElseActions();
|
|
||||||
const bool isElse = std::any_of(elseActions.begin(), elseActions.end(),
|
|
||||||
[rawPtr](const auto &a) {
|
|
||||||
return a.get() == rawPtr;
|
|
||||||
});
|
|
||||||
const auto segmentType = isElse ? MacroEdit::SegmentType::ELSE_ACTION
|
|
||||||
: MacroEdit::SegmentType::ACTION;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
_entryData->reset();
|
_entryData->reset();
|
||||||
@@ -146,16 +122,6 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
|
|||||||
(*_entryData)->PostLoad();
|
(*_entryData)->PostLoad();
|
||||||
RunAndClearPostLoadSteps();
|
RunAndClearPostLoadSteps();
|
||||||
}
|
}
|
||||||
|
|
||||||
OBSDataAutoRelease newData = obs_data_create();
|
|
||||||
(*_entryData)->Save(newData);
|
|
||||||
if (parentMacro) {
|
|
||||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
|
||||||
} else {
|
|
||||||
RegisterSegmentTypeChangeUndoRedo(macro, segmentType, idx,
|
|
||||||
oldId, oldData, 0, id,
|
|
||||||
newData, 0);
|
|
||||||
}
|
|
||||||
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
|
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
|
||||||
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
|
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
|
||||||
this, SLOT(HeaderInfoChanged(const QString &)));
|
this, SLOT(HeaderInfoChanged(const QString &)));
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ bool MacroActionLoop::PostLoad()
|
|||||||
MacroAction::PostLoad();
|
MacroAction::PostLoad();
|
||||||
_loopMacro->PostLoad();
|
_loopMacro->PostLoad();
|
||||||
_loopMacro->SetActionTriggerMode(Macro::ActionTriggerMode::ALWAYS);
|
_loopMacro->SetActionTriggerMode(Macro::ActionTriggerMode::ALWAYS);
|
||||||
_loopMacro->SetNestedParentMacro(GetMacro());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -281,7 +281,6 @@ bool MacroActionMacro::PostLoad()
|
|||||||
MacroAction::PostLoad();
|
MacroAction::PostLoad();
|
||||||
_runOptions.macro.PostLoad();
|
_runOptions.macro.PostLoad();
|
||||||
_nestedMacro->PostLoad();
|
_nestedMacro->PostLoad();
|
||||||
_nestedMacro->SetNestedParentMacro(GetMacro());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "macro-condition-edit.hpp"
|
#include "macro-condition-edit.hpp"
|
||||||
#include "macro-undo-redo.hpp"
|
|
||||||
|
|
||||||
#include "advanced-scene-switcher.hpp"
|
#include "advanced-scene-switcher.hpp"
|
||||||
#include "condition-logic.hpp"
|
#include "condition-logic.hpp"
|
||||||
@@ -251,19 +250,6 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *const parentMacro =
|
|
||||||
(*_entryData)->GetMacro()->GetNestedParentMacro();
|
|
||||||
OBSDataAutoRelease parentBeforeData;
|
|
||||||
if (parentMacro) {
|
|
||||||
parentBeforeData = obs_data_create();
|
|
||||||
parentMacro->Save(parentBeforeData);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string oldId = (*_entryData)->GetId();
|
|
||||||
const int oldLogic = (int)(*_entryData)->GetLogicType();
|
|
||||||
OBSDataAutoRelease oldData = obs_data_create();
|
|
||||||
(*_entryData)->Save(oldData);
|
|
||||||
|
|
||||||
auto temp = DurationModifier();
|
auto temp = DurationModifier();
|
||||||
_dur->SetValue(temp);
|
_dur->SetValue(temp);
|
||||||
HeaderInfoChanged("");
|
HeaderInfoChanged("");
|
||||||
@@ -281,17 +267,6 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
|
|||||||
(*_entryData)->PostLoad();
|
(*_entryData)->PostLoad();
|
||||||
RunAndClearPostLoadSteps();
|
RunAndClearPostLoadSteps();
|
||||||
}
|
}
|
||||||
|
|
||||||
OBSDataAutoRelease newData = obs_data_create();
|
|
||||||
(*_entryData)->Save(newData);
|
|
||||||
if (parentMacro) {
|
|
||||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
|
||||||
} else {
|
|
||||||
RegisterSegmentTypeChangeUndoRedo(
|
|
||||||
macro, MacroEdit::SegmentType::CONDITION, idx, oldId,
|
|
||||||
oldData, oldLogic, id, newData,
|
|
||||||
(int)(*_entryData)->GetLogicType());
|
|
||||||
}
|
|
||||||
auto widget =
|
auto widget =
|
||||||
MacroConditionFactory::CreateWidget(id, this, *_entryData);
|
MacroConditionFactory::CreateWidget(id, this, *_entryData);
|
||||||
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
|
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "macro-edit.hpp"
|
#include "macro-edit.hpp"
|
||||||
|
|
||||||
#include "condition-logic.hpp"
|
#include "condition-logic.hpp"
|
||||||
#include "macro-undo-redo.hpp"
|
|
||||||
#include "cursor-shape-changer.hpp"
|
#include "cursor-shape-changer.hpp"
|
||||||
#include "macro-action-edit.hpp"
|
#include "macro-action-edit.hpp"
|
||||||
#include "macro-action-macro.hpp"
|
#include "macro-action-macro.hpp"
|
||||||
@@ -258,92 +257,6 @@ std::shared_ptr<Macro> MacroEdit::GetMacro() const
|
|||||||
return _currentMacro;
|
return _currentMacro;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroEdit::InsertSegmentWidget(SegmentType type, int idx)
|
|
||||||
{
|
|
||||||
auto macro = _currentMacro;
|
|
||||||
if (!macro) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case SegmentType::ACTION: {
|
|
||||||
if (idx < 0 || idx > (int)macro->Actions().size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ui->actionsList->Insert(
|
|
||||||
idx, new MacroActionEdit(this, ¯o->Actions()[idx]));
|
|
||||||
SetActionData(*macro);
|
|
||||||
ui->actionsList->SetHelpMsgVisible(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SegmentType::ELSE_ACTION: {
|
|
||||||
if (idx < 0 || idx > (int)macro->ElseActions().size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ui->elseActionsList->Insert(
|
|
||||||
idx,
|
|
||||||
new MacroActionEdit(this, ¯o->ElseActions()[idx]));
|
|
||||||
SetElseActionData(*macro);
|
|
||||||
ui->elseActionsList->SetHelpMsgVisible(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SegmentType::CONDITION: {
|
|
||||||
if (idx < 0 || idx > (int)macro->Conditions().size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ui->conditionsList->Insert(
|
|
||||||
idx,
|
|
||||||
new MacroConditionEdit(this, ¯o->Conditions()[idx],
|
|
||||||
idx == 0));
|
|
||||||
if (idx == 0 && macro->Conditions().size() > 1) {
|
|
||||||
static_cast<MacroConditionEdit *>(
|
|
||||||
ui->conditionsList->WidgetAt(1))
|
|
||||||
->SetRootNode(false);
|
|
||||||
}
|
|
||||||
SetConditionData(*macro);
|
|
||||||
ui->conditionsList->SetHelpMsgVisible(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroEdit::RemoveSegmentWidget(SegmentType type, int idx)
|
|
||||||
{
|
|
||||||
auto macro = _currentMacro;
|
|
||||||
if (!macro) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case SegmentType::ACTION:
|
|
||||||
if (idx >= 0 &&
|
|
||||||
idx < ui->actionsList->ContentLayout()->count()) {
|
|
||||||
ui->actionsList->Remove(idx);
|
|
||||||
SetActionData(*macro);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SegmentType::ELSE_ACTION:
|
|
||||||
if (idx >= 0 &&
|
|
||||||
idx < ui->elseActionsList->ContentLayout()->count()) {
|
|
||||||
ui->elseActionsList->Remove(idx);
|
|
||||||
SetElseActionData(*macro);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SegmentType::CONDITION:
|
|
||||||
if (idx >= 0 &&
|
|
||||||
idx < ui->conditionsList->ContentLayout()->count()) {
|
|
||||||
ui->conditionsList->Remove(idx);
|
|
||||||
if (idx == 0 && !macro->Conditions().empty()) {
|
|
||||||
static_cast<MacroConditionEdit *>(
|
|
||||||
ui->conditionsList->WidgetAt(0))
|
|
||||||
->SetRootNode(true);
|
|
||||||
}
|
|
||||||
SetConditionData(*macro);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroEdit::ClearSegmentWidgetCacheFor(Macro *macro) const
|
void MacroEdit::ClearSegmentWidgetCacheFor(Macro *macro) const
|
||||||
{
|
{
|
||||||
ui->conditionsList->ClearWidgetsFromCacheFor(macro);
|
ui->conditionsList->ClearWidgetsFromCacheFor(macro);
|
||||||
@@ -382,7 +295,7 @@ isValidMacroSegmentIdx(const std::deque<std::shared_ptr<MacroSegment>> &list,
|
|||||||
return (idx > 0 || (unsigned)idx < list.size());
|
return (idx > 0 || (unsigned)idx < list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroEdit::SetupMacroSegmentSelection(SegmentType type, int idx)
|
void MacroEdit::SetupMacroSegmentSelection(MacroSection type, int idx)
|
||||||
{
|
{
|
||||||
auto macro = _currentMacro;
|
auto macro = _currentMacro;
|
||||||
if (!macro) {
|
if (!macro) {
|
||||||
@@ -395,7 +308,7 @@ void MacroEdit::SetupMacroSegmentSelection(SegmentType type, int idx)
|
|||||||
std::deque<std::shared_ptr<MacroSegment>> segments;
|
std::deque<std::shared_ptr<MacroSegment>> segments;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MacroEdit::SegmentType::CONDITION:
|
case MacroEdit::MacroSection::CONDITIONS:
|
||||||
setList = ui->conditionsList;
|
setList = ui->conditionsList;
|
||||||
setIdx = ¤tConditionIdx;
|
setIdx = ¤tConditionIdx;
|
||||||
segments = {macro->Conditions().begin(),
|
segments = {macro->Conditions().begin(),
|
||||||
@@ -406,7 +319,7 @@ void MacroEdit::SetupMacroSegmentSelection(SegmentType type, int idx)
|
|||||||
resetIdx1 = ¤tActionIdx;
|
resetIdx1 = ¤tActionIdx;
|
||||||
resetIdx2 = ¤tElseActionIdx;
|
resetIdx2 = ¤tElseActionIdx;
|
||||||
break;
|
break;
|
||||||
case MacroEdit::SegmentType::ACTION:
|
case MacroEdit::MacroSection::ACTIONS:
|
||||||
setList = ui->actionsList;
|
setList = ui->actionsList;
|
||||||
setIdx = ¤tActionIdx;
|
setIdx = ¤tActionIdx;
|
||||||
segments = {macro->Actions().begin(), macro->Actions().end()};
|
segments = {macro->Actions().begin(), macro->Actions().end()};
|
||||||
@@ -416,7 +329,7 @@ void MacroEdit::SetupMacroSegmentSelection(SegmentType type, int idx)
|
|||||||
resetIdx1 = ¤tConditionIdx;
|
resetIdx1 = ¤tConditionIdx;
|
||||||
resetIdx2 = ¤tElseActionIdx;
|
resetIdx2 = ¤tElseActionIdx;
|
||||||
break;
|
break;
|
||||||
case MacroEdit::SegmentType::ELSE_ACTION:
|
case MacroEdit::MacroSection::ELSE_ACTIONS:
|
||||||
setList = ui->elseActionsList;
|
setList = ui->elseActionsList;
|
||||||
setIdx = ¤tElseActionIdx;
|
setIdx = ¤tElseActionIdx;
|
||||||
segments = {macro->ElseActions().begin(),
|
segments = {macro->ElseActions().begin(),
|
||||||
@@ -1052,7 +965,7 @@ void MacroEdit::UpMacroSegmentHotkey()
|
|||||||
int conditionSize = macro->Conditions().size();
|
int conditionSize = macro->Conditions().size();
|
||||||
|
|
||||||
if (currentActionIdx == -1 && currentConditionIdx == -1) {
|
if (currentActionIdx == -1 && currentConditionIdx == -1) {
|
||||||
if (lastInteracted == SegmentType::CONDITION) {
|
if (lastInteracted == MacroSection::CONDITIONS) {
|
||||||
if (conditionSize == 0) {
|
if (conditionSize == 0) {
|
||||||
MacroActionSelectionChanged(0);
|
MacroActionSelectionChanged(0);
|
||||||
} else {
|
} else {
|
||||||
@@ -1108,7 +1021,7 @@ void MacroEdit::DownMacroSegmentHotkey()
|
|||||||
int conditionSize = macro->Conditions().size();
|
int conditionSize = macro->Conditions().size();
|
||||||
|
|
||||||
if (currentActionIdx == -1 && currentConditionIdx == -1) {
|
if (currentActionIdx == -1 && currentConditionIdx == -1) {
|
||||||
if (lastInteracted == SegmentType::CONDITION) {
|
if (lastInteracted == MacroSection::CONDITIONS) {
|
||||||
if (conditionSize == 0) {
|
if (conditionSize == 0) {
|
||||||
MacroActionSelectionChanged(0);
|
MacroActionSelectionChanged(0);
|
||||||
} else {
|
} else {
|
||||||
@@ -1171,13 +1084,6 @@ void MacroEdit::AddMacroAction(Macro *macro, int idx, const std::string &id,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
|
||||||
OBSDataAutoRelease parentBeforeData;
|
|
||||||
if (parentMacro) {
|
|
||||||
parentBeforeData = obs_data_create();
|
|
||||||
parentMacro->Save(parentBeforeData);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
macro->Actions().emplace(macro->Actions().begin() + idx,
|
macro->Actions().emplace(macro->Actions().begin() + idx,
|
||||||
@@ -1192,11 +1098,6 @@ void MacroEdit::AddMacroAction(Macro *macro, int idx, const std::string &id,
|
|||||||
idx, new MacroActionEdit(this, ¯o->Actions()[idx]));
|
idx, new MacroActionEdit(this, ¯o->Actions()[idx]));
|
||||||
SetActionData(*macro);
|
SetActionData(*macro);
|
||||||
}
|
}
|
||||||
if (parentMacro) {
|
|
||||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
|
||||||
} else {
|
|
||||||
RegisterSegmentAddUndoRedo(macro, SegmentType::ACTION, idx);
|
|
||||||
}
|
|
||||||
HighlightAction(idx);
|
HighlightAction(idx);
|
||||||
ui->actionsList->SetHelpMsgVisible(false);
|
ui->actionsList->SetHelpMsgVisible(false);
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
@@ -1262,24 +1163,6 @@ void MacroEdit::RemoveMacroAction(int idx)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
|
||||||
OBSDataAutoRelease parentBeforeData;
|
|
||||||
if (parentMacro) {
|
|
||||||
parentBeforeData = obs_data_create();
|
|
||||||
parentMacro->Save(parentBeforeData);
|
|
||||||
} else {
|
|
||||||
OBSDataAutoRelease segData = obs_data_create();
|
|
||||||
std::string segId;
|
|
||||||
{
|
|
||||||
auto lock = LockContext();
|
|
||||||
macro->Actions().at(idx)->Save(segData);
|
|
||||||
segId = macro->Actions().at(idx)->GetId();
|
|
||||||
}
|
|
||||||
RegisterSegmentRemoveUndoRedo(macro.get(), SegmentType::ACTION,
|
|
||||||
idx, segId, segData,
|
|
||||||
(int)Logic::Type::ROOT_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
ui->actionsList->Remove(idx);
|
ui->actionsList->Remove(idx);
|
||||||
@@ -1289,11 +1172,8 @@ void MacroEdit::RemoveMacroAction(int idx)
|
|||||||
macro->UpdateActionIndices();
|
macro->UpdateActionIndices();
|
||||||
SetActionData(*macro);
|
SetActionData(*macro);
|
||||||
}
|
}
|
||||||
if (parentMacro) {
|
|
||||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
|
||||||
}
|
|
||||||
MacroActionSelectionChanged(-1);
|
MacroActionSelectionChanged(-1);
|
||||||
lastInteracted = SegmentType::ACTION;
|
lastInteracted = MacroSection::ACTIONS;
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1473,7 +1353,7 @@ void MacroEdit::MoveMacroActionDown(int idx)
|
|||||||
|
|
||||||
void MacroEdit::MacroElseActionSelectionChanged(int idx)
|
void MacroEdit::MacroElseActionSelectionChanged(int idx)
|
||||||
{
|
{
|
||||||
SetupMacroSegmentSelection(SegmentType::ELSE_ACTION, idx);
|
SetupMacroSegmentSelection(MacroSection::ELSE_ACTIONS, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroEdit::MacroElseActionReorder(int to, int from)
|
void MacroEdit::MacroElseActionReorder(int to, int from)
|
||||||
@@ -1510,13 +1390,6 @@ void MacroEdit::AddMacroElseAction(Macro *macro, int idx, const std::string &id,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
|
||||||
OBSDataAutoRelease parentBeforeData;
|
|
||||||
if (parentMacro) {
|
|
||||||
parentBeforeData = obs_data_create();
|
|
||||||
parentMacro->Save(parentBeforeData);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
macro->ElseActions().emplace(macro->ElseActions().begin() + idx,
|
macro->ElseActions().emplace(macro->ElseActions().begin() + idx,
|
||||||
@@ -1533,12 +1406,6 @@ void MacroEdit::AddMacroElseAction(Macro *macro, int idx, const std::string &id,
|
|||||||
new MacroActionEdit(this, ¯o->ElseActions()[idx]));
|
new MacroActionEdit(this, ¯o->ElseActions()[idx]));
|
||||||
SetElseActionData(*macro);
|
SetElseActionData(*macro);
|
||||||
}
|
}
|
||||||
if (parentMacro) {
|
|
||||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
|
||||||
} else {
|
|
||||||
RegisterSegmentAddUndoRedo(macro, SegmentType::ELSE_ACTION,
|
|
||||||
idx);
|
|
||||||
}
|
|
||||||
HighlightElseAction(idx);
|
HighlightElseAction(idx);
|
||||||
ui->elseActionsList->SetHelpMsgVisible(false);
|
ui->elseActionsList->SetHelpMsgVisible(false);
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
@@ -1588,25 +1455,6 @@ void MacroEdit::RemoveMacroElseAction(int idx)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
|
||||||
OBSDataAutoRelease parentBeforeData;
|
|
||||||
if (parentMacro) {
|
|
||||||
parentBeforeData = obs_data_create();
|
|
||||||
parentMacro->Save(parentBeforeData);
|
|
||||||
} else {
|
|
||||||
OBSDataAutoRelease segData = obs_data_create();
|
|
||||||
std::string segId;
|
|
||||||
{
|
|
||||||
auto lock = LockContext();
|
|
||||||
macro->ElseActions().at(idx)->Save(segData);
|
|
||||||
segId = macro->ElseActions().at(idx)->GetId();
|
|
||||||
}
|
|
||||||
RegisterSegmentRemoveUndoRedo(macro.get(),
|
|
||||||
SegmentType::ELSE_ACTION, idx,
|
|
||||||
segId, segData,
|
|
||||||
(int)Logic::Type::ROOT_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
ui->elseActionsList->Remove(idx);
|
ui->elseActionsList->Remove(idx);
|
||||||
@@ -1616,11 +1464,8 @@ void MacroEdit::RemoveMacroElseAction(int idx)
|
|||||||
macro->UpdateElseActionIndices();
|
macro->UpdateElseActionIndices();
|
||||||
SetElseActionData(*macro);
|
SetElseActionData(*macro);
|
||||||
}
|
}
|
||||||
if (parentMacro) {
|
|
||||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
|
||||||
}
|
|
||||||
MacroElseActionSelectionChanged(-1);
|
MacroElseActionSelectionChanged(-1);
|
||||||
lastInteracted = SegmentType::ELSE_ACTION;
|
lastInteracted = MacroSection::ELSE_ACTIONS;
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1681,7 +1526,7 @@ void MacroEdit::MoveMacroElseActionDown(int idx)
|
|||||||
|
|
||||||
void MacroEdit::MacroActionSelectionChanged(int idx)
|
void MacroEdit::MacroActionSelectionChanged(int idx)
|
||||||
{
|
{
|
||||||
SetupMacroSegmentSelection(SegmentType::ACTION, idx);
|
SetupMacroSegmentSelection(MacroSection::ACTIONS, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroEdit::MacroActionReorder(int to, int from)
|
void MacroEdit::MacroActionReorder(int to, int from)
|
||||||
@@ -1754,13 +1599,6 @@ void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
|
||||||
OBSDataAutoRelease parentBeforeData;
|
|
||||||
if (parentMacro) {
|
|
||||||
parentBeforeData = obs_data_create();
|
|
||||||
parentMacro->Save(parentBeforeData);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
auto cond = macro->Conditions().emplace(
|
auto cond = macro->Conditions().emplace(
|
||||||
@@ -1779,11 +1617,6 @@ void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
|
|||||||
idx == 0));
|
idx == 0));
|
||||||
SetConditionData(*macro);
|
SetConditionData(*macro);
|
||||||
}
|
}
|
||||||
if (parentMacro) {
|
|
||||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
|
||||||
} else {
|
|
||||||
RegisterSegmentAddUndoRedo(macro, SegmentType::CONDITION, idx);
|
|
||||||
}
|
|
||||||
HighlightCondition(idx);
|
HighlightCondition(idx);
|
||||||
ui->conditionsList->SetHelpMsgVisible(false);
|
ui->conditionsList->SetHelpMsgVisible(false);
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
@@ -1819,26 +1652,6 @@ void MacroEdit::RemoveMacroCondition(int idx)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
|
||||||
OBSDataAutoRelease parentBeforeData;
|
|
||||||
if (parentMacro) {
|
|
||||||
parentBeforeData = obs_data_create();
|
|
||||||
parentMacro->Save(parentBeforeData);
|
|
||||||
} else {
|
|
||||||
OBSDataAutoRelease segData = obs_data_create();
|
|
||||||
std::string segId;
|
|
||||||
int logic;
|
|
||||||
{
|
|
||||||
auto lock = LockContext();
|
|
||||||
macro->Conditions().at(idx)->Save(segData);
|
|
||||||
segId = macro->Conditions().at(idx)->GetId();
|
|
||||||
logic = (int)macro->Conditions().at(idx)->GetLogicType();
|
|
||||||
}
|
|
||||||
RegisterSegmentRemoveUndoRedo(macro.get(),
|
|
||||||
SegmentType::CONDITION, idx,
|
|
||||||
segId, segData, logic);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
ui->conditionsList->Remove(idx);
|
ui->conditionsList->Remove(idx);
|
||||||
@@ -1853,11 +1666,8 @@ void MacroEdit::RemoveMacroCondition(int idx)
|
|||||||
}
|
}
|
||||||
SetConditionData(*macro);
|
SetConditionData(*macro);
|
||||||
}
|
}
|
||||||
if (parentMacro) {
|
|
||||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
|
||||||
}
|
|
||||||
MacroConditionSelectionChanged(-1);
|
MacroConditionSelectionChanged(-1);
|
||||||
lastInteracted = SegmentType::CONDITION;
|
lastInteracted = MacroSection::CONDITIONS;
|
||||||
emit(MacroSegmentOrderChanged());
|
emit(MacroSegmentOrderChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1982,7 +1792,7 @@ void MacroEdit::MoveMacroConditionDown(int idx)
|
|||||||
|
|
||||||
void MacroEdit::MacroConditionSelectionChanged(int idx)
|
void MacroEdit::MacroConditionSelectionChanged(int idx)
|
||||||
{
|
{
|
||||||
SetupMacroSegmentSelection(SegmentType::CONDITION, idx);
|
SetupMacroSegmentSelection(MacroSection::CONDITIONS, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroEdit::MacroConditionReorder(int to, int from)
|
void MacroEdit::MacroConditionReorder(int to, int from)
|
||||||
|
|||||||
@@ -12,15 +12,11 @@ class MacroEdit : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class SegmentType { CONDITION, ACTION, ELSE_ACTION };
|
|
||||||
|
|
||||||
MacroEdit(QWidget *parent, QStringList helpMsg = {});
|
MacroEdit(QWidget *parent, QStringList helpMsg = {});
|
||||||
void SetMacro(const std::shared_ptr<Macro> &);
|
void SetMacro(const std::shared_ptr<Macro> &);
|
||||||
std::shared_ptr<Macro> GetMacro() const;
|
std::shared_ptr<Macro> GetMacro() const;
|
||||||
void ClearSegmentWidgetCacheFor(Macro *) const;
|
void ClearSegmentWidgetCacheFor(Macro *) const;
|
||||||
void SetControlsDisabled(bool disable) const;
|
void SetControlsDisabled(bool disable) const;
|
||||||
void InsertSegmentWidget(SegmentType type, int idx);
|
|
||||||
void RemoveSegmentWidget(SegmentType type, int idx);
|
|
||||||
void HighlightAction(int idx, QColor color = QColor(Qt::green)) const;
|
void HighlightAction(int idx, QColor color = QColor(Qt::green)) const;
|
||||||
void HighlightElseAction(int idx,
|
void HighlightElseAction(int idx,
|
||||||
QColor color = QColor(Qt::green)) const;
|
QColor color = QColor(Qt::green)) const;
|
||||||
@@ -116,12 +112,14 @@ protected:
|
|||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum class MacroSection { CONDITIONS, ACTIONS, ELSE_ACTIONS };
|
||||||
|
|
||||||
void PopulateMacroActions(Macro &m, uint32_t afterIdx = 0);
|
void PopulateMacroActions(Macro &m, uint32_t afterIdx = 0);
|
||||||
void PopulateMacroElseActions(Macro &m, uint32_t afterIdx = 0);
|
void PopulateMacroElseActions(Macro &m, uint32_t afterIdx = 0);
|
||||||
void PopulateMacroConditions(Macro &m, uint32_t afterIdx = 0);
|
void PopulateMacroConditions(Macro &m, uint32_t afterIdx = 0);
|
||||||
void ScrollAndFocusNewSegment(MacroSegmentList *list, int newIdx,
|
void ScrollAndFocusNewSegment(MacroSegmentList *list, int newIdx,
|
||||||
int *currentIdx);
|
int *currentIdx);
|
||||||
void SetupMacroSegmentSelection(SegmentType type, int idx);
|
void SetupMacroSegmentSelection(MacroSection type, int idx);
|
||||||
void
|
void
|
||||||
SetupContextMenu(const QPoint &pos,
|
SetupContextMenu(const QPoint &pos,
|
||||||
const std::function<void(MacroEdit *, int)> &remove,
|
const std::function<void(MacroEdit *, int)> &remove,
|
||||||
@@ -133,7 +131,7 @@ private:
|
|||||||
void RunSegmentHighlightChecks();
|
void RunSegmentHighlightChecks();
|
||||||
bool ElseSectionIsVisible() const;
|
bool ElseSectionIsVisible() const;
|
||||||
|
|
||||||
SegmentType lastInteracted = SegmentType::CONDITION;
|
MacroSection lastInteracted = MacroSection::CONDITIONS;
|
||||||
int currentConditionIdx = -1;
|
int currentConditionIdx = -1;
|
||||||
int currentActionIdx = -1;
|
int currentActionIdx = -1;
|
||||||
int currentElseActionIdx = -1;
|
int currentElseActionIdx = -1;
|
||||||
|
|||||||
@@ -201,8 +201,6 @@ bool MacroSegmentList::PopulateWidgetsFromCache(const Macro *macro)
|
|||||||
_contentLayout->addWidget(widget);
|
_contentLayout->addWidget(widget);
|
||||||
widget->show();
|
widget->show();
|
||||||
}
|
}
|
||||||
// Widgets are now owned by the layout again, so the cache entry is stale.
|
|
||||||
_widgetCache.erase(it);
|
|
||||||
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
@@ -465,17 +463,7 @@ void MacroSegmentList::SetupVisibleMacroSegmentWidgets()
|
|||||||
|
|
||||||
const auto viewportRect = viewport()->rect();
|
const auto viewportRect = viewport()->rect();
|
||||||
|
|
||||||
for (int i = 0; i < _contentLayout->count(); ++i) {
|
for (auto segment : widget()->findChildren<MacroSegmentEdit *>()) {
|
||||||
auto item = _contentLayout->itemAt(i);
|
|
||||||
if (!item) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto segment = dynamic_cast<MacroSegmentEdit *>(item->widget());
|
|
||||||
if (!segment) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto pos = segment->mapTo(viewport(), QPoint(0, 0));
|
const auto pos = segment->mapTo(viewport(), QPoint(0, 0));
|
||||||
const QRect rect(pos, segment->size());
|
const QRect rect(pos, segment->size());
|
||||||
if (!viewportRect.intersects(rect)) {
|
if (!viewportRect.intersects(rect)) {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "macro-settings.hpp"
|
#include "macro-settings.hpp"
|
||||||
#include "macro-signals.hpp"
|
#include "macro-signals.hpp"
|
||||||
#include "macro-tree.hpp"
|
#include "macro-tree.hpp"
|
||||||
#include "macro-undo-redo.hpp"
|
|
||||||
#include "macro.hpp"
|
#include "macro.hpp"
|
||||||
#include "math-helpers.hpp"
|
#include "math-helpers.hpp"
|
||||||
#include "name-dialog.hpp"
|
#include "name-dialog.hpp"
|
||||||
@@ -123,7 +122,6 @@ void AdvSceneSwitcher::on_macroAdd_clicked()
|
|||||||
ui->macros->Add(newMacro);
|
ui->macros->Add(newMacro);
|
||||||
MacroSignalManager::Instance()->Add(
|
MacroSignalManager::Instance()->Add(
|
||||||
QString::fromStdString(name));
|
QString::fromStdString(name));
|
||||||
RegisterMacroAddUndoRedo(name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +131,6 @@ void AdvSceneSwitcher::on_macroAdd_clicked()
|
|||||||
ui->macros->AddToGroup(newMacro, selectedMacro);
|
ui->macros->AddToGroup(newMacro, selectedMacro);
|
||||||
MacroSignalManager::Instance()->Add(
|
MacroSignalManager::Instance()->Add(
|
||||||
QString::fromStdString(name));
|
QString::fromStdString(name));
|
||||||
RegisterMacroAddUndoRedo(name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,14 +139,12 @@ void AdvSceneSwitcher::on_macroAdd_clicked()
|
|||||||
ui->macros->Add(newMacro, selectedMacro);
|
ui->macros->Add(newMacro, selectedMacro);
|
||||||
MacroSignalManager::Instance()->Add(
|
MacroSignalManager::Instance()->Add(
|
||||||
QString::fromStdString(name));
|
QString::fromStdString(name));
|
||||||
RegisterMacroAddUndoRedo(name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro::PrepareMoveToGroup(selectedMacroGroup, newMacro);
|
Macro::PrepareMoveToGroup(selectedMacroGroup, newMacro);
|
||||||
ui->macros->Add(newMacro, selectedMacro);
|
ui->macros->Add(newMacro, selectedMacro);
|
||||||
MacroSignalManager::Instance()->Add(QString::fromStdString(name));
|
MacroSignalManager::Instance()->Add(QString::fromStdString(name));
|
||||||
RegisterMacroAddUndoRedo(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addGroupSubitems(std::vector<std::shared_ptr<Macro>> ¯os,
|
static void addGroupSubitems(std::vector<std::shared_ptr<Macro>> ¯os,
|
||||||
@@ -190,12 +185,6 @@ void AdvSceneSwitcher::RemoveMacro(std::shared_ptr<Macro> ¯o)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (macro->IsGroup()) {
|
|
||||||
RegisterGroupDeleteUndoRedo(macro.get());
|
|
||||||
} else {
|
|
||||||
RegisterMacroRemoveUndoRedo(macro.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (macro->IsGroup()) {
|
if (macro->IsGroup()) {
|
||||||
std::vector<std::shared_ptr<Macro>> macros = {macro};
|
std::vector<std::shared_ptr<Macro>> macros = {macro};
|
||||||
addGroupSubitems(macros, macro);
|
addGroupSubitems(macros, macro);
|
||||||
@@ -252,16 +241,13 @@ void AdvSceneSwitcher::RemoveSelectedMacros()
|
|||||||
void AdvSceneSwitcher::RenameMacro(std::shared_ptr<Macro> ¯o,
|
void AdvSceneSwitcher::RenameMacro(std::shared_ptr<Macro> ¯o,
|
||||||
const QString &name)
|
const QString &name)
|
||||||
{
|
{
|
||||||
const std::string oldName = macro->Name();
|
auto oldName = QString::fromStdString(macro->Name());
|
||||||
const std::string newName = name.toStdString();
|
|
||||||
{
|
{
|
||||||
auto lock = LockContext();
|
auto lock = LockContext();
|
||||||
macro->SetName(newName);
|
macro->SetName(name.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterMacroRenameUndoRedo(oldName, newName);
|
MacroSignalManager::Instance()->Rename(oldName, name);
|
||||||
MacroSignalManager::Instance()->Rename(QString::fromStdString(oldName),
|
|
||||||
name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_macroRemove_clicked()
|
void AdvSceneSwitcher::on_macroRemove_clicked()
|
||||||
@@ -457,7 +443,6 @@ void AdvSceneSwitcher::ImportMacros()
|
|||||||
ui->macros->Reset(GetTopLevelMacros(),
|
ui->macros->Reset(GetTopLevelMacros(),
|
||||||
GetGlobalMacroSettings()._highlightExecuted);
|
GetGlobalMacroSettings()._highlightExecuted);
|
||||||
disableAddButtonHighlight();
|
disableAddButtonHighlight();
|
||||||
RegisterMacrosImportUndoRedo(importedMacros);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::on_macroName_editingFinished()
|
void AdvSceneSwitcher::on_macroName_editingFinished()
|
||||||
@@ -829,7 +814,6 @@ void AdvSceneSwitcher::CopyMacro()
|
|||||||
ui->macros->Add(newMacro, macro);
|
ui->macros->Add(newMacro, macro);
|
||||||
disableAddButtonHighlight();
|
disableAddButtonHighlight();
|
||||||
MacroSignalManager::Instance()->Add(QString::fromStdString(name));
|
MacroSignalManager::Instance()->Add(QString::fromStdString(name));
|
||||||
RegisterMacroAddUndoRedo(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::PauseSelectedMacros()
|
void AdvSceneSwitcher::PauseSelectedMacros()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "macro-tree.hpp"
|
#include "macro-tree.hpp"
|
||||||
#include "macro-undo-redo.hpp"
|
|
||||||
|
|
||||||
#include "macro-helpers.hpp"
|
#include "macro-helpers.hpp"
|
||||||
#include "macro-search.hpp"
|
#include "macro-search.hpp"
|
||||||
@@ -825,8 +824,6 @@ void MacroTreeModel::GroupSelectedItems(QModelIndexList &indices)
|
|||||||
|
|
||||||
Reset(_macros);
|
Reset(_macros);
|
||||||
assert(IsInValidState());
|
assert(IsInValidState());
|
||||||
|
|
||||||
RegisterGroupCreateUndoRedo(name.toStdString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroTreeModel::UngroupSelectedGroups(QModelIndexList &indices)
|
void MacroTreeModel::UngroupSelectedGroups(QModelIndexList &indices)
|
||||||
@@ -840,7 +837,6 @@ void MacroTreeModel::UngroupSelectedGroups(QModelIndexList &indices)
|
|||||||
std::shared_ptr<Macro> item = _macros[ModelIndexToMacroIndex(
|
std::shared_ptr<Macro> item = _macros[ModelIndexToMacroIndex(
|
||||||
indices[i].row(), _macros)];
|
indices[i].row(), _macros)];
|
||||||
if (item->IsGroup()) {
|
if (item->IsGroup()) {
|
||||||
RegisterGroupRemoveUndoRedo(item->Name());
|
|
||||||
Macro::RemoveGroup(item);
|
Macro::RemoveGroup(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,35 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "macro-edit.hpp"
|
|
||||||
|
|
||||||
#include <obs-data.h>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
class Macro;
|
|
||||||
|
|
||||||
void RegisterMacroAddUndoRedo(const std::string ¯oName);
|
|
||||||
bool RegisterMacroRemoveUndoRedo(Macro *macro);
|
|
||||||
void RegisterSegmentAddUndoRedo(Macro *macro, MacroEdit::SegmentType type,
|
|
||||||
int index);
|
|
||||||
void RegisterSegmentTypeChangeUndoRedo(Macro *macro,
|
|
||||||
MacroEdit::SegmentType type, int index,
|
|
||||||
const std::string &oldId,
|
|
||||||
obs_data_t *oldData, int oldLogic,
|
|
||||||
const std::string &newId,
|
|
||||||
obs_data_t *newData, int newLogic);
|
|
||||||
void RegisterSegmentRemoveUndoRedo(Macro *macro, MacroEdit::SegmentType type,
|
|
||||||
int index, const std::string &segmentId,
|
|
||||||
obs_data_t *segmentData, int logic);
|
|
||||||
void RegisterMacroRenameUndoRedo(const std::string &oldName,
|
|
||||||
const std::string &newName);
|
|
||||||
void RegisterGroupCreateUndoRedo(const std::string &groupName);
|
|
||||||
void RegisterGroupRemoveUndoRedo(const std::string &groupName);
|
|
||||||
void RegisterGroupDeleteUndoRedo(Macro *macro);
|
|
||||||
void RegisterMacroModifyUndoRedo(Macro *parentMacro, obs_data_t *beforeData);
|
|
||||||
void RegisterMacrosImportUndoRedo(
|
|
||||||
const std::vector<std::shared_ptr<Macro>> &importedMacros);
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -130,13 +130,6 @@ public:
|
|||||||
void SetParent(std::shared_ptr<Macro> m) { _parent = m; }
|
void SetParent(std::shared_ptr<Macro> m) { _parent = m; }
|
||||||
std::shared_ptr<Macro> Parent() const;
|
std::shared_ptr<Macro> Parent() const;
|
||||||
|
|
||||||
// For nested macros embedded in actions (e.g. loop, nested-macro action)
|
|
||||||
void SetNestedParentMacro(Macro *parent)
|
|
||||||
{
|
|
||||||
_nestedParentMacro = parent;
|
|
||||||
}
|
|
||||||
Macro *GetNestedParentMacro() const { return _nestedParentMacro; }
|
|
||||||
|
|
||||||
// Saving and loading
|
// Saving and loading
|
||||||
bool Save(obs_data_t *obj, bool saveForCopy = false) const;
|
bool Save(obs_data_t *obj, bool saveForCopy = false) const;
|
||||||
bool Load(obs_data_t *obj);
|
bool Load(obs_data_t *obj);
|
||||||
@@ -194,7 +187,6 @@ private:
|
|||||||
std::deque<std::shared_ptr<MacroAction>> _elseActions;
|
std::deque<std::shared_ptr<MacroAction>> _elseActions;
|
||||||
|
|
||||||
std::weak_ptr<Macro> _parent;
|
std::weak_ptr<Macro> _parent;
|
||||||
Macro *_nestedParentMacro = nullptr;
|
|
||||||
uint32_t _groupSize = 0;
|
uint32_t _groupSize = 0;
|
||||||
bool _isGroup = false;
|
bool _isGroup = false;
|
||||||
bool _isCollapsed = false;
|
bool _isCollapsed = false;
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ add_plugin(twitch)
|
|||||||
add_plugin(usb)
|
add_plugin(usb)
|
||||||
add_plugin(video)
|
add_plugin(video)
|
||||||
add_plugin(speech)
|
add_plugin(speech)
|
||||||
add_plugin(now-playing)
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,64 @@
|
|||||||
#include "audio-helpers.hpp"
|
#include "audio-helpers.hpp"
|
||||||
#include "layout-helpers.hpp"
|
#include "layout-helpers.hpp"
|
||||||
#include "macro-helpers.hpp"
|
#include "macro-helpers.hpp"
|
||||||
|
#include "plugin-state-helpers.hpp"
|
||||||
#include "sync-helpers.hpp"
|
#include "sync-helpers.hpp"
|
||||||
|
|
||||||
|
#include <obs-frontend-api.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <mutex>
|
||||||
|
#include <set>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
// Use a high output channel index that is unlikely to be claimed by OBS or
|
|
||||||
// other plugins. OBS supports channels 0-63; channel 0 is the main scene.
|
|
||||||
static constexpr uint32_t kPlaybackOutputChannel = 63;
|
static constexpr uint32_t kPlaybackOutputChannel = 63;
|
||||||
|
|
||||||
|
// Tracks rawSource handles held by background cleanup threads so they can be
|
||||||
|
// stopped early when OBS begins shutdown, before audio is freed.
|
||||||
|
static std::mutex g_activeSourcesMutex;
|
||||||
|
static std::set<obs_source_t *> g_activeSources;
|
||||||
|
|
||||||
|
static void registerActiveSource(obs_source_t *source)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(g_activeSourcesMutex);
|
||||||
|
g_activeSources.insert(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unregisterActiveSource(obs_source_t *source)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(g_activeSourcesMutex);
|
||||||
|
g_activeSources.erase(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void stopAllActiveSources()
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(g_activeSourcesMutex);
|
||||||
|
for (auto *source : g_activeSources) {
|
||||||
|
obs_source_media_stop(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleObsEvent(enum obs_frontend_event event, void *)
|
||||||
|
{
|
||||||
|
if (event == OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN ||
|
||||||
|
event == OBS_FRONTEND_EVENT_EXIT) {
|
||||||
|
stopAllActiveSources();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool setup()
|
||||||
|
{
|
||||||
|
AddPluginPostLoadStep([]() {
|
||||||
|
obs_frontend_add_event_callback(handleObsEvent, nullptr);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool setupDone = setup();
|
||||||
|
|
||||||
const std::string MacroActionPlayAudio::id = "play_audio";
|
const std::string MacroActionPlayAudio::id = "play_audio";
|
||||||
|
|
||||||
bool MacroActionPlayAudio::_registered = MacroActionFactory::Register(
|
bool MacroActionPlayAudio::_registered = MacroActionFactory::Register(
|
||||||
@@ -23,6 +69,7 @@ bool MacroActionPlayAudio::_registered = MacroActionFactory::Register(
|
|||||||
|
|
||||||
static void deactivatePlayback(obs_source_t *source, bool wantsOutput)
|
static void deactivatePlayback(obs_source_t *source, bool wantsOutput)
|
||||||
{
|
{
|
||||||
|
obs_source_media_stop(source);
|
||||||
if (wantsOutput) {
|
if (wantsOutput) {
|
||||||
obs_set_output_source(kPlaybackOutputChannel, nullptr);
|
obs_set_output_source(kPlaybackOutputChannel, nullptr);
|
||||||
} else {
|
} else {
|
||||||
@@ -38,8 +85,7 @@ static void waitForPlaybackToEnd(Macro *macro, obs_source_t *source,
|
|||||||
std::unique_lock<std::mutex> lock(*GetMutex());
|
std::unique_lock<std::mutex> lock(*GetMutex());
|
||||||
SetMacroAbortWait(false);
|
SetMacroAbortWait(false);
|
||||||
|
|
||||||
// The media source needs time to open and decode before reaching
|
// Poll until the source starts playing or the macro is stopped.
|
||||||
// PLAYING state. Poll until it starts (or the macro is stopped).
|
|
||||||
while (!MacroWaitShouldAbort() && !MacroIsStopped(macro)) {
|
while (!MacroWaitShouldAbort() && !MacroIsStopped(macro)) {
|
||||||
if (obs_source_media_get_state(source) ==
|
if (obs_source_media_get_state(source) ==
|
||||||
OBS_MEDIA_STATE_PLAYING) {
|
OBS_MEDIA_STATE_PLAYING) {
|
||||||
@@ -48,9 +94,8 @@ static void waitForPlaybackToEnd(Macro *macro, obs_source_t *source,
|
|||||||
GetMacroWaitCV().wait_for(lock, 10ms);
|
GetMacroWaitCV().wait_for(lock, 10ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now wait for playback to end. Require two consecutive non-playing
|
// Wait for playback to end. Two consecutive non-playing samples are
|
||||||
// samples to avoid false positives on brief state transitions.
|
// required to avoid false positives on brief state transitions.
|
||||||
// If maxMs > 0, also stop once that many milliseconds have elapsed.
|
|
||||||
const auto playbackStart = std::chrono::steady_clock::now();
|
const auto playbackStart = std::chrono::steady_clock::now();
|
||||||
static const int kStopThreshold = 2;
|
static const int kStopThreshold = 2;
|
||||||
int stoppedCount = 0;
|
int stoppedCount = 0;
|
||||||
@@ -95,7 +140,6 @@ bool MacroActionPlayAudio::PerformAction()
|
|||||||
obs_data_set_string(settings, "local_file", path.c_str());
|
obs_data_set_string(settings, "local_file", path.c_str());
|
||||||
obs_data_set_bool(settings, "is_local_file", true);
|
obs_data_set_bool(settings, "is_local_file", true);
|
||||||
obs_data_set_bool(settings, "looping", false);
|
obs_data_set_bool(settings, "looping", false);
|
||||||
// Disable automatic restart on activate so we control start explicitly.
|
|
||||||
obs_data_set_bool(settings, "restart_on_activate", false);
|
obs_data_set_bool(settings, "restart_on_activate", false);
|
||||||
obs_data_set_bool(settings, "close_when_inactive", true);
|
obs_data_set_bool(settings, "close_when_inactive", true);
|
||||||
|
|
||||||
@@ -113,10 +157,11 @@ bool MacroActionPlayAudio::PerformAction()
|
|||||||
DecibelToPercent(static_cast<float>(_volumeDB.GetValue()));
|
DecibelToPercent(static_cast<float>(_volumeDB.GetValue()));
|
||||||
obs_source_set_volume(source, vol);
|
obs_source_set_volume(source, vol);
|
||||||
obs_source_set_monitoring_type(source, _monitorType);
|
obs_source_set_monitoring_type(source, _monitorType);
|
||||||
|
if (_mono) {
|
||||||
|
obs_source_set_flags(source, OBS_SOURCE_FLAG_FORCE_MONO);
|
||||||
|
}
|
||||||
|
|
||||||
// Fall back to monitor-only if all output tracks are deselected —
|
// Fall back to monitor-only if all output tracks are deselected.
|
||||||
// there is no point routing through the output channel if the mixer
|
|
||||||
// mask would silence every track.
|
|
||||||
const bool wantsOutput =
|
const bool wantsOutput =
|
||||||
(_monitorType != OBS_MONITORING_TYPE_MONITOR_ONLY) &&
|
(_monitorType != OBS_MONITORING_TYPE_MONITOR_ONLY) &&
|
||||||
(_audioMixers != 0);
|
(_audioMixers != 0);
|
||||||
@@ -128,10 +173,8 @@ bool MacroActionPlayAudio::PerformAction()
|
|||||||
|
|
||||||
if (wantsOutput) {
|
if (wantsOutput) {
|
||||||
obs_source_set_audio_mixers(source, _audioMixers);
|
obs_source_set_audio_mixers(source, _audioMixers);
|
||||||
// Route through a private scene so we can position the scene
|
// Route through a private scene positioned off-screen so the
|
||||||
// item far off-screen. This keeps the item "visible" (so audio
|
// audio mixes into the output without video appearing on screen.
|
||||||
// is still mixed) while ensuring its video never intersects the
|
|
||||||
// output frame.
|
|
||||||
OBSSceneAutoRelease audioScene =
|
OBSSceneAutoRelease audioScene =
|
||||||
obs_scene_create_private("advss_audio_scene");
|
obs_scene_create_private("advss_audio_scene");
|
||||||
obs_sceneitem_t *item = obs_scene_add(audioScene, source);
|
obs_sceneitem_t *item = obs_scene_add(audioScene, source);
|
||||||
@@ -141,8 +184,7 @@ bool MacroActionPlayAudio::PerformAction()
|
|||||||
}
|
}
|
||||||
obs_set_output_source(kPlaybackOutputChannel,
|
obs_set_output_source(kPlaybackOutputChannel,
|
||||||
obs_scene_get_source(audioScene));
|
obs_scene_get_source(audioScene));
|
||||||
// audioScene released here; the output channel holds the
|
// audioScene is released here; the output channel keeps the scene alive.
|
||||||
// remaining reference and keeps the scene alive.
|
|
||||||
} else {
|
} else {
|
||||||
obs_source_set_audio_mixers(source, 0);
|
obs_source_set_audio_mixers(source, 0);
|
||||||
obs_source_inc_active(source);
|
obs_source_inc_active(source);
|
||||||
@@ -167,15 +209,15 @@ bool MacroActionPlayAudio::PerformAction()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep the source alive in a background thread that cleans up
|
// Keep the source alive until playback ends via a background thread.
|
||||||
// once playback finishes. Grab an extra strong reference so the
|
|
||||||
// source survives beyond this stack frame.
|
|
||||||
auto rawSource = obs_source_get_ref(source);
|
auto rawSource = obs_source_get_ref(source);
|
||||||
|
registerActiveSource(rawSource);
|
||||||
auto macro = GetMacro();
|
auto macro = GetMacro();
|
||||||
|
|
||||||
std::thread cleanupThread([rawSource, wantsOutput, macro, maxMs]() {
|
std::thread cleanupThread([rawSource, wantsOutput, macro, maxMs]() {
|
||||||
waitForPlaybackToEnd(macro, rawSource, maxMs);
|
waitForPlaybackToEnd(macro, rawSource, maxMs);
|
||||||
deactivatePlayback(rawSource, wantsOutput);
|
deactivatePlayback(rawSource, wantsOutput);
|
||||||
|
unregisterActiveSource(rawSource);
|
||||||
obs_source_release(rawSource);
|
obs_source_release(rawSource);
|
||||||
});
|
});
|
||||||
AddMacroHelperThread(macro, std::move(cleanupThread));
|
AddMacroHelperThread(macro, std::move(cleanupThread));
|
||||||
@@ -204,6 +246,7 @@ bool MacroActionPlayAudio::Save(obs_data_t *obj) const
|
|||||||
obs_data_set_bool(obj, "useDuration", _useDuration);
|
obs_data_set_bool(obj, "useDuration", _useDuration);
|
||||||
_playbackDuration.Save(obj, "playbackDuration");
|
_playbackDuration.Save(obj, "playbackDuration");
|
||||||
obs_data_set_bool(obj, "waitForCompletion", _waitForCompletion);
|
obs_data_set_bool(obj, "waitForCompletion", _waitForCompletion);
|
||||||
|
obs_data_set_bool(obj, "mono", _mono);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +264,7 @@ bool MacroActionPlayAudio::Load(obs_data_t *obj)
|
|||||||
_useDuration = obs_data_get_bool(obj, "useDuration");
|
_useDuration = obs_data_get_bool(obj, "useDuration");
|
||||||
_playbackDuration.Load(obj, "playbackDuration");
|
_playbackDuration.Load(obj, "playbackDuration");
|
||||||
_waitForCompletion = obs_data_get_bool(obj, "waitForCompletion");
|
_waitForCompletion = obs_data_get_bool(obj, "waitForCompletion");
|
||||||
|
_mono = obs_data_get_bool(obj, "mono");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +306,9 @@ MacroActionPlayAudioEdit::MacroActionPlayAudioEdit(
|
|||||||
_useDuration(new QCheckBox(this)),
|
_useDuration(new QCheckBox(this)),
|
||||||
_playbackDuration(new DurationSelection(this, true, 0.0)),
|
_playbackDuration(new DurationSelection(this, true, 0.0)),
|
||||||
_waitForCompletion(new QCheckBox(
|
_waitForCompletion(new QCheckBox(
|
||||||
obs_module_text("AdvSceneSwitcher.action.playAudio.wait")))
|
obs_module_text("AdvSceneSwitcher.action.playAudio.wait"))),
|
||||||
|
_mono(new QCheckBox(
|
||||||
|
obs_module_text("AdvSceneSwitcher.action.playAudio.mono")))
|
||||||
{
|
{
|
||||||
_volumeDB->setMinimum(-100.0);
|
_volumeDB->setMinimum(-100.0);
|
||||||
_volumeDB->setMaximum(0.0);
|
_volumeDB->setMaximum(0.0);
|
||||||
@@ -303,6 +349,8 @@ MacroActionPlayAudioEdit::MacroActionPlayAudioEdit(
|
|||||||
SLOT(PlaybackDurationChanged(const Duration &)));
|
SLOT(PlaybackDurationChanged(const Duration &)));
|
||||||
QWidget::connect(_waitForCompletion, SIGNAL(stateChanged(int)), this,
|
QWidget::connect(_waitForCompletion, SIGNAL(stateChanged(int)), this,
|
||||||
SLOT(WaitChanged(int)));
|
SLOT(WaitChanged(int)));
|
||||||
|
QWidget::connect(_mono, SIGNAL(stateChanged(int)), this,
|
||||||
|
SLOT(MonoChanged(int)));
|
||||||
|
|
||||||
auto tracksLayout = new QHBoxLayout;
|
auto tracksLayout = new QHBoxLayout;
|
||||||
tracksLayout->setContentsMargins(0, 0, 0, 0);
|
tracksLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
@@ -346,6 +394,7 @@ MacroActionPlayAudioEdit::MacroActionPlayAudioEdit(
|
|||||||
mainLayout->addLayout(startOffsetLayout);
|
mainLayout->addLayout(startOffsetLayout);
|
||||||
mainLayout->addLayout(playbackDurationLayout);
|
mainLayout->addLayout(playbackDurationLayout);
|
||||||
mainLayout->addWidget(_waitForCompletion);
|
mainLayout->addWidget(_waitForCompletion);
|
||||||
|
mainLayout->addWidget(_mono);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
_entryData = entryData;
|
_entryData = entryData;
|
||||||
@@ -375,6 +424,7 @@ void MacroActionPlayAudioEdit::UpdateEntryData()
|
|||||||
_playbackDuration->SetDuration(_entryData->_playbackDuration);
|
_playbackDuration->SetDuration(_entryData->_playbackDuration);
|
||||||
_playbackDuration->setEnabled(_entryData->_useDuration);
|
_playbackDuration->setEnabled(_entryData->_useDuration);
|
||||||
_waitForCompletion->setChecked(_entryData->_waitForCompletion);
|
_waitForCompletion->setChecked(_entryData->_waitForCompletion);
|
||||||
|
_mono->setChecked(_entryData->_mono);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroActionPlayAudioEdit::FilePathChanged(const QString &path)
|
void MacroActionPlayAudioEdit::FilePathChanged(const QString &path)
|
||||||
@@ -443,4 +493,10 @@ void MacroActionPlayAudioEdit::WaitChanged(int value)
|
|||||||
_entryData->_waitForCompletion = value;
|
_entryData->_waitForCompletion = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacroActionPlayAudioEdit::MonoChanged(int value)
|
||||||
|
{
|
||||||
|
GUARD_LOADING_AND_LOCK();
|
||||||
|
_entryData->_mono = value;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public:
|
|||||||
bool _useDuration = false;
|
bool _useDuration = false;
|
||||||
Duration _playbackDuration;
|
Duration _playbackDuration;
|
||||||
bool _waitForCompletion = false;
|
bool _waitForCompletion = false;
|
||||||
|
bool _mono = false;
|
||||||
|
|
||||||
static bool _registered;
|
static bool _registered;
|
||||||
static const std::string id;
|
static const std::string id;
|
||||||
@@ -68,6 +69,7 @@ private slots:
|
|||||||
void UseDurationChanged(int);
|
void UseDurationChanged(int);
|
||||||
void PlaybackDurationChanged(const Duration &);
|
void PlaybackDurationChanged(const Duration &);
|
||||||
void WaitChanged(int value);
|
void WaitChanged(int value);
|
||||||
|
void MonoChanged(int value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void HeaderInfoChanged(const QString &);
|
void HeaderInfoChanged(const QString &);
|
||||||
@@ -83,6 +85,7 @@ private:
|
|||||||
QCheckBox *_useDuration;
|
QCheckBox *_useDuration;
|
||||||
DurationSelection *_playbackDuration;
|
DurationSelection *_playbackDuration;
|
||||||
QCheckBox *_waitForCompletion;
|
QCheckBox *_waitForCompletion;
|
||||||
|
QCheckBox *_mono;
|
||||||
|
|
||||||
std::shared_ptr<MacroActionPlayAudio> _entryData;
|
std::shared_ptr<MacroActionPlayAudio> _entryData;
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#include "macro-action-scene-collection.hpp"
|
#include "macro-action-scene-collection.hpp"
|
||||||
|
|
||||||
#include "layout-helpers.hpp"
|
#include "layout-helpers.hpp"
|
||||||
#include "plugin-state-helpers.hpp"
|
#include "plugin-state-helpers.hpp"
|
||||||
#include "selection-helpers.hpp"
|
#include "selection-helpers.hpp"
|
||||||
#include "ui-helpers.hpp"
|
|
||||||
|
|
||||||
#include <obs-frontend-api.h>
|
#include <obs-frontend-api.h>
|
||||||
|
|
||||||
@@ -17,20 +15,6 @@ bool MacroActionSceneCollection::_registered = MacroActionFactory::Register(
|
|||||||
MacroActionSceneCollectionEdit::Create,
|
MacroActionSceneCollectionEdit::Create,
|
||||||
"AdvSceneSwitcher.action.sceneCollection"});
|
"AdvSceneSwitcher.action.sceneCollection"});
|
||||||
|
|
||||||
template<typename F> void QueueUITaskLambda(F &&func)
|
|
||||||
{
|
|
||||||
using FnType = std::decay_t<F>;
|
|
||||||
auto *heapFunc = new FnType(std::forward<F>(func));
|
|
||||||
|
|
||||||
QueueUITask(
|
|
||||||
[](void *param) {
|
|
||||||
std::unique_ptr<FnType> fn(
|
|
||||||
static_cast<FnType *>(param));
|
|
||||||
(*fn)();
|
|
||||||
},
|
|
||||||
heapFunc);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroActionSceneCollection::PerformAction()
|
bool MacroActionSceneCollection::PerformAction()
|
||||||
{
|
{
|
||||||
// Changing the scene collection will also reload the settings of the
|
// Changing the scene collection will also reload the settings of the
|
||||||
@@ -39,13 +23,7 @@ bool MacroActionSceneCollection::PerformAction()
|
|||||||
if (SettingsWindowIsOpened()) {
|
if (SettingsWindowIsOpened()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
obs_frontend_set_current_scene_collection(_sceneCollection.c_str());
|
||||||
const auto collectionName = _sceneCollection;
|
|
||||||
QueueUITaskLambda([collectionName]() {
|
|
||||||
obs_frontend_set_current_scene_collection(
|
|
||||||
collectionName.c_str());
|
|
||||||
});
|
|
||||||
|
|
||||||
// It does not make sense to continue as the current settings will be
|
// It does not make sense to continue as the current settings will be
|
||||||
// invalid after switching scene collection.
|
// invalid after switching scene collection.
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ const static std::map<MacroConditionAudio::Type, std::string> checkTypes = {
|
|||||||
"AdvSceneSwitcher.condition.audio.type.monitor"},
|
"AdvSceneSwitcher.condition.audio.type.monitor"},
|
||||||
{MacroConditionAudio::Type::BALANCE,
|
{MacroConditionAudio::Type::BALANCE,
|
||||||
"AdvSceneSwitcher.condition.audio.type.balance"},
|
"AdvSceneSwitcher.condition.audio.type.balance"},
|
||||||
{MacroConditionAudio::Type::TRACK,
|
|
||||||
"AdvSceneSwitcher.condition.audio.type.track"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const static std::map<MacroConditionAudio::OutputCondition, std::string>
|
const static std::map<MacroConditionAudio::OutputCondition, std::string>
|
||||||
@@ -247,20 +245,6 @@ bool MacroConditionAudio::CheckBalance()
|
|||||||
return ret && source;
|
return ret && source;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacroConditionAudio::CheckTrack()
|
|
||||||
{
|
|
||||||
if (!_audioSource.GetSource()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OBSSourceAutoRelease source =
|
|
||||||
obs_weak_source_get_source(_audioSource.GetSource());
|
|
||||||
uint32_t mixers = obs_source_get_audio_mixers(source);
|
|
||||||
bool enabled = (mixers >> (uint32_t)(_track - 1)) & 1u;
|
|
||||||
SetTempVarValue("track_enabled", enabled ? "true" : "false");
|
|
||||||
return enabled && source;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroConditionAudio::CheckCondition()
|
bool MacroConditionAudio::CheckCondition()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@@ -280,9 +264,6 @@ bool MacroConditionAudio::CheckCondition()
|
|||||||
case Type::BALANCE:
|
case Type::BALANCE:
|
||||||
ret = CheckBalance();
|
ret = CheckBalance();
|
||||||
break;
|
break;
|
||||||
case Type::TRACK:
|
|
||||||
ret = CheckTrack();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetVariableValue().empty()) {
|
if (GetVariableValue().empty()) {
|
||||||
@@ -300,7 +281,6 @@ bool MacroConditionAudio::Save(obs_data_t *obj) const
|
|||||||
_volumePercent.Save(obj, "volume");
|
_volumePercent.Save(obj, "volume");
|
||||||
_syncOffset.Save(obj, "syncOffset");
|
_syncOffset.Save(obj, "syncOffset");
|
||||||
_balance.Save(obj, "balance");
|
_balance.Save(obj, "balance");
|
||||||
_track.Save(obj, "track");
|
|
||||||
obs_data_set_int(obj, "checkType", static_cast<int>(_checkType));
|
obs_data_set_int(obj, "checkType", static_cast<int>(_checkType));
|
||||||
obs_data_set_int(obj, "outputCondition",
|
obs_data_set_int(obj, "outputCondition",
|
||||||
static_cast<int>(_outputCondition));
|
static_cast<int>(_outputCondition));
|
||||||
@@ -366,7 +346,6 @@ bool MacroConditionAudio::Load(obs_data_t *obj)
|
|||||||
_useDb = obs_data_get_bool(obj, "useDb");
|
_useDb = obs_data_get_bool(obj, "useDb");
|
||||||
_volumeDB.Load(obj, "volumeDB");
|
_volumeDB.Load(obj, "volumeDB");
|
||||||
}
|
}
|
||||||
_track.Load(obj, "track");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,12 +421,6 @@ void MacroConditionAudio::SetupTempVars()
|
|||||||
obs_module_text(
|
obs_module_text(
|
||||||
"AdvSceneSwitcher.tempVar.audio.balance"));
|
"AdvSceneSwitcher.tempVar.audio.balance"));
|
||||||
break;
|
break;
|
||||||
case Type::TRACK:
|
|
||||||
AddTempvar(
|
|
||||||
"track_enabled",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.audio.trackEnabled"));
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -495,7 +468,6 @@ static QStringList getAudioSourcesList()
|
|||||||
MacroConditionAudioEdit::MacroConditionAudioEdit(
|
MacroConditionAudioEdit::MacroConditionAudioEdit(
|
||||||
QWidget *parent, std::shared_ptr<MacroConditionAudio> entryData)
|
QWidget *parent, std::shared_ptr<MacroConditionAudio> entryData)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
_layout(new QHBoxLayout),
|
|
||||||
_checkTypes(new QComboBox()),
|
_checkTypes(new QComboBox()),
|
||||||
_sources(new SourceSelectionWidget(this, getAudioSourcesList, true)),
|
_sources(new SourceSelectionWidget(this, getAudioSourcesList, true)),
|
||||||
_condition(new QComboBox()),
|
_condition(new QComboBox()),
|
||||||
@@ -504,8 +476,7 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
|||||||
_percentDBToggle(new QPushButton),
|
_percentDBToggle(new QPushButton),
|
||||||
_syncOffset(new VariableSpinBox()),
|
_syncOffset(new VariableSpinBox()),
|
||||||
_monitorTypes(new QComboBox),
|
_monitorTypes(new QComboBox),
|
||||||
_balance(new SliderSpinBox(0., 1., "")),
|
_balance(new SliderSpinBox(0., 1., ""))
|
||||||
_track(new VariableSpinBox())
|
|
||||||
{
|
{
|
||||||
_volumePercent->setSuffix("%");
|
_volumePercent->setSuffix("%");
|
||||||
_volumePercent->setMaximum(100);
|
_volumePercent->setMaximum(100);
|
||||||
@@ -520,9 +491,6 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
|||||||
_syncOffset->setMaximum(20000);
|
_syncOffset->setMaximum(20000);
|
||||||
_syncOffset->setSuffix("ms");
|
_syncOffset->setSuffix("ms");
|
||||||
|
|
||||||
_track->setMinimum(1);
|
|
||||||
_track->setMaximum(32);
|
|
||||||
|
|
||||||
QWidget::connect(_checkTypes, SIGNAL(currentIndexChanged(int)), this,
|
QWidget::connect(_checkTypes, SIGNAL(currentIndexChanged(int)), this,
|
||||||
SLOT(CheckTypeChanged(int)));
|
SLOT(CheckTypeChanged(int)));
|
||||||
QWidget::connect(
|
QWidget::connect(
|
||||||
@@ -551,16 +519,27 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
|||||||
this, SLOT(VolumeDBChanged(const NumberVariable<double> &)));
|
this, SLOT(VolumeDBChanged(const NumberVariable<double> &)));
|
||||||
QWidget::connect(_percentDBToggle, SIGNAL(clicked()), this,
|
QWidget::connect(_percentDBToggle, SIGNAL(clicked()), this,
|
||||||
SLOT(PercentDBClicked()));
|
SLOT(PercentDBClicked()));
|
||||||
QWidget::connect(
|
|
||||||
_track,
|
|
||||||
SIGNAL(NumberVariableChanged(const NumberVariable<int> &)),
|
|
||||||
this, SLOT(TrackChanged(const NumberVariable<int> &)));
|
|
||||||
|
|
||||||
populateCheckTypes(_checkTypes);
|
populateCheckTypes(_checkTypes);
|
||||||
PopulateMonitorTypeSelection(_monitorTypes);
|
PopulateMonitorTypeSelection(_monitorTypes);
|
||||||
|
|
||||||
|
QHBoxLayout *switchLayout = new QHBoxLayout;
|
||||||
|
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||||
|
{"{{checkType}}", _checkTypes},
|
||||||
|
{"{{audioSources}}", _sources},
|
||||||
|
{"{{volume}}", _volumePercent},
|
||||||
|
{"{{syncOffset}}", _syncOffset},
|
||||||
|
{"{{monitorTypes}}", _monitorTypes},
|
||||||
|
{"{{balance}}", _balance},
|
||||||
|
{"{{condition}}", _condition},
|
||||||
|
{"{{volumeDB}}", _volumeDB},
|
||||||
|
{"{{percentDBToggle}}", _percentDBToggle},
|
||||||
|
};
|
||||||
|
PlaceWidgets(obs_module_text("AdvSceneSwitcher.condition.audio.entry"),
|
||||||
|
switchLayout, widgetPlaceholders);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(_layout);
|
mainLayout->addLayout(switchLayout);
|
||||||
mainLayout->addWidget(_balance);
|
mainLayout->addWidget(_balance);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
@@ -629,12 +608,6 @@ void MacroConditionAudioEdit::BalanceChanged(const NumberVariable<double> &value
|
|||||||
_entryData->_balance = value;
|
_entryData->_balance = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroConditionAudioEdit::TrackChanged(const NumberVariable<int> &value)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_track = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionAudioEdit::VolumeDBChanged(
|
void MacroConditionAudioEdit::VolumeDBChanged(
|
||||||
const NumberVariable<double> &value)
|
const NumberVariable<double> &value)
|
||||||
{
|
{
|
||||||
@@ -719,8 +692,6 @@ void MacroConditionAudioEdit::CheckTypeChanged(int idx)
|
|||||||
} else if (_entryData->GetType() ==
|
} else if (_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::CONFIGURED_VOLUME) {
|
MacroConditionAudio::Type::CONFIGURED_VOLUME) {
|
||||||
populateVolumeConditionSelection(_condition);
|
populateVolumeConditionSelection(_condition);
|
||||||
} else if (_entryData->GetType() == MacroConditionAudio::Type::TRACK) {
|
|
||||||
_condition->clear();
|
|
||||||
}
|
}
|
||||||
SetWidgetVisibility();
|
SetWidgetVisibility();
|
||||||
}
|
}
|
||||||
@@ -737,7 +708,6 @@ void MacroConditionAudioEdit::UpdateEntryData()
|
|||||||
_syncOffset->SetValue(_entryData->_syncOffset);
|
_syncOffset->SetValue(_entryData->_syncOffset);
|
||||||
_monitorTypes->setCurrentIndex(_entryData->_monitorType);
|
_monitorTypes->setCurrentIndex(_entryData->_monitorType);
|
||||||
_balance->SetDoubleValue(_entryData->_balance);
|
_balance->SetDoubleValue(_entryData->_balance);
|
||||||
_track->SetValue(_entryData->_track);
|
|
||||||
_checkTypes->setCurrentIndex(
|
_checkTypes->setCurrentIndex(
|
||||||
_checkTypes->findData(static_cast<int>(_entryData->GetType())));
|
_checkTypes->findData(static_cast<int>(_entryData->GetType())));
|
||||||
|
|
||||||
@@ -778,63 +748,26 @@ void MacroConditionAudioEdit::SetWidgetVisibility()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_layout->removeWidget(_checkTypes);
|
|
||||||
_layout->removeWidget(_sources);
|
|
||||||
_layout->removeWidget(_condition);
|
|
||||||
_layout->removeWidget(_volumePercent);
|
|
||||||
_layout->removeWidget(_volumeDB);
|
|
||||||
_layout->removeWidget(_percentDBToggle);
|
|
||||||
_layout->removeWidget(_syncOffset);
|
|
||||||
_layout->removeWidget(_monitorTypes);
|
|
||||||
_layout->removeWidget(_track);
|
|
||||||
ClearLayout(_layout);
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, QWidget *> placeholders = {
|
|
||||||
{"{{checkType}}", _checkTypes},
|
|
||||||
{"{{audioSources}}", _sources},
|
|
||||||
{"{{condition}}", _condition},
|
|
||||||
{"{{volume}}", _volumePercent},
|
|
||||||
{"{{volumeDB}}", _volumeDB},
|
|
||||||
{"{{percentDBToggle}}", _percentDBToggle},
|
|
||||||
{"{{syncOffset}}", _syncOffset},
|
|
||||||
{"{{monitorTypes}}", _monitorTypes},
|
|
||||||
{"{{track}}", _track},
|
|
||||||
};
|
|
||||||
|
|
||||||
const bool isTrack = _entryData->GetType() ==
|
|
||||||
MacroConditionAudio::Type::TRACK;
|
|
||||||
PlaceWidgets(
|
|
||||||
obs_module_text(
|
|
||||||
isTrack ? "AdvSceneSwitcher.condition.audio.layout.track"
|
|
||||||
: "AdvSceneSwitcher.condition.audio.entry"),
|
|
||||||
_layout, placeholders);
|
|
||||||
|
|
||||||
_condition->setVisible(
|
_condition->setVisible(
|
||||||
!isTrack &&
|
_entryData->GetType() ==
|
||||||
(_entryData->GetType() ==
|
MacroConditionAudio::Type::OUTPUT_VOLUME ||
|
||||||
MacroConditionAudio::Type::OUTPUT_VOLUME ||
|
_entryData->GetType() ==
|
||||||
_entryData->GetType() ==
|
MacroConditionAudio::Type::CONFIGURED_VOLUME ||
|
||||||
MacroConditionAudio::Type::CONFIGURED_VOLUME ||
|
_entryData->GetType() == MacroConditionAudio::Type::BALANCE ||
|
||||||
_entryData->GetType() == MacroConditionAudio::Type::BALANCE ||
|
_entryData->GetType() ==
|
||||||
_entryData->GetType() ==
|
MacroConditionAudio::Type::SYNC_OFFSET);
|
||||||
MacroConditionAudio::Type::SYNC_OFFSET));
|
_syncOffset->setVisible(_entryData->GetType() ==
|
||||||
_syncOffset->setVisible(!isTrack &&
|
MacroConditionAudio::Type::SYNC_OFFSET);
|
||||||
_entryData->GetType() ==
|
_monitorTypes->setVisible(_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::SYNC_OFFSET);
|
MacroConditionAudio::Type::MONITOR);
|
||||||
_monitorTypes->setVisible(!isTrack &&
|
|
||||||
_entryData->GetType() ==
|
|
||||||
MacroConditionAudio::Type::MONITOR);
|
|
||||||
_track->setVisible(isTrack);
|
|
||||||
_volumePercent->setVisible(!isTrack && HasVolumeControl() &&
|
|
||||||
!_entryData->_useDb);
|
|
||||||
_volumeDB->setVisible(!isTrack && HasVolumeControl() &&
|
|
||||||
_entryData->_useDb);
|
|
||||||
_percentDBToggle->setText(_entryData->_useDb ? "dB" : "%");
|
|
||||||
_percentDBToggle->setVisible(!isTrack && HasVolumeControl());
|
|
||||||
_balance->setVisible(_entryData->GetType() ==
|
_balance->setVisible(_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::BALANCE);
|
MacroConditionAudio::Type::BALANCE);
|
||||||
_volMeter->setVisible(_entryData->GetType() ==
|
_volMeter->setVisible(_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::OUTPUT_VOLUME);
|
MacroConditionAudio::Type::OUTPUT_VOLUME);
|
||||||
|
_volumePercent->setVisible(HasVolumeControl() && !_entryData->_useDb);
|
||||||
|
_volumeDB->setVisible(HasVolumeControl() && _entryData->_useDb);
|
||||||
|
_percentDBToggle->setText(_entryData->_useDb ? "dB" : "%");
|
||||||
|
_percentDBToggle->setVisible(HasVolumeControl());
|
||||||
adjustSize();
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "source-selection.hpp"
|
#include "source-selection.hpp"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -37,7 +36,6 @@ public:
|
|||||||
SYNC_OFFSET,
|
SYNC_OFFSET,
|
||||||
MONITOR,
|
MONITOR,
|
||||||
BALANCE,
|
BALANCE,
|
||||||
TRACK,
|
|
||||||
};
|
};
|
||||||
void SetType(const Type &);
|
void SetType(const Type &);
|
||||||
Type GetType() const { return _checkType; }
|
Type GetType() const { return _checkType; }
|
||||||
@@ -62,7 +60,6 @@ public:
|
|||||||
IntVariable _syncOffset = 0;
|
IntVariable _syncOffset = 0;
|
||||||
obs_monitoring_type _monitorType = OBS_MONITORING_TYPE_NONE;
|
obs_monitoring_type _monitorType = OBS_MONITORING_TYPE_NONE;
|
||||||
DoubleVariable _balance = 0.5;
|
DoubleVariable _balance = 0.5;
|
||||||
IntVariable _track = 1;
|
|
||||||
OutputCondition _outputCondition = OutputCondition::ABOVE;
|
OutputCondition _outputCondition = OutputCondition::ABOVE;
|
||||||
VolumeCondition _volumeCondition = VolumeCondition::ABOVE;
|
VolumeCondition _volumeCondition = VolumeCondition::ABOVE;
|
||||||
obs_volmeter_t *_volmeter = nullptr;
|
obs_volmeter_t *_volmeter = nullptr;
|
||||||
@@ -73,7 +70,6 @@ private:
|
|||||||
bool CheckSyncOffset();
|
bool CheckSyncOffset();
|
||||||
bool CheckMonitor();
|
bool CheckMonitor();
|
||||||
bool CheckBalance();
|
bool CheckBalance();
|
||||||
bool CheckTrack();
|
|
||||||
void SetupTempVars();
|
void SetupTempVars();
|
||||||
float GetVolumePeak();
|
float GetVolumePeak();
|
||||||
|
|
||||||
@@ -115,7 +111,6 @@ private slots:
|
|||||||
void VolumeDBChanged(const NumberVariable<double> &value);
|
void VolumeDBChanged(const NumberVariable<double> &value);
|
||||||
void PercentDBClicked();
|
void PercentDBClicked();
|
||||||
void SyncSliderAndValueSelection(bool sliderMoved);
|
void SyncSliderAndValueSelection(bool sliderMoved);
|
||||||
void TrackChanged(const NumberVariable<int> &value);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void HeaderInfoChanged(const QString &);
|
void HeaderInfoChanged(const QString &);
|
||||||
@@ -124,7 +119,6 @@ private:
|
|||||||
void SetWidgetVisibility();
|
void SetWidgetVisibility();
|
||||||
bool HasVolumeControl() const;
|
bool HasVolumeControl() const;
|
||||||
|
|
||||||
QHBoxLayout *_layout;
|
|
||||||
QComboBox *_checkTypes;
|
QComboBox *_checkTypes;
|
||||||
SourceSelectionWidget *_sources;
|
SourceSelectionWidget *_sources;
|
||||||
QComboBox *_condition;
|
QComboBox *_condition;
|
||||||
@@ -134,7 +128,6 @@ private:
|
|||||||
VariableSpinBox *_syncOffset;
|
VariableSpinBox *_syncOffset;
|
||||||
QComboBox *_monitorTypes;
|
QComboBox *_monitorTypes;
|
||||||
SliderSpinBox *_balance;
|
SliderSpinBox *_balance;
|
||||||
VariableSpinBox *_track;
|
|
||||||
VolControl *_volMeter = nullptr;
|
VolControl *_volMeter = nullptr;
|
||||||
|
|
||||||
std::shared_ptr<MacroConditionAudio> _entryData;
|
std::shared_ptr<MacroConditionAudio> _entryData;
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
|
||||||
project(advanced-scene-switcher-now-playing)
|
|
||||||
|
|
||||||
if(NOT WIN32)
|
|
||||||
message(WARNING "Now playing condition is only supported on Windows.")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} MODULE)
|
|
||||||
target_sources(${PROJECT_NAME} PRIVATE macro-condition-now-playing.cpp
|
|
||||||
macro-condition-now-playing.hpp)
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE windowsapp)
|
|
||||||
|
|
||||||
setup_advss_plugin(${PROJECT_NAME})
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
|
|
||||||
install_advss_plugin(${PROJECT_NAME})
|
|
||||||
@@ -1,338 +0,0 @@
|
|||||||
#include "macro-condition-now-playing.hpp"
|
|
||||||
#include "layout-helpers.hpp"
|
|
||||||
#include "sync-helpers.hpp"
|
|
||||||
|
|
||||||
#include <util/base.h>
|
|
||||||
|
|
||||||
#include <roapi.h>
|
|
||||||
#include <winrt/Windows.Foundation.h>
|
|
||||||
#include <winrt/Windows.Media.Control.h>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
using namespace winrt::Windows::Media::Control;
|
|
||||||
|
|
||||||
const std::string MacroConditionNowPlaying::id = "now_playing";
|
|
||||||
|
|
||||||
bool MacroConditionNowPlaying::_registered = MacroConditionFactory::Register(
|
|
||||||
MacroConditionNowPlaying::id,
|
|
||||||
{MacroConditionNowPlaying::Create, MacroConditionNowPlayingEdit::Create,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying"});
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
struct SessionInfo {
|
|
||||||
bool hasSession = false;
|
|
||||||
std::string title;
|
|
||||||
std::string artist;
|
|
||||||
std::string album;
|
|
||||||
std::string appName;
|
|
||||||
GlobalSystemMediaTransportControlsSessionPlaybackStatus playbackStatus =
|
|
||||||
GlobalSystemMediaTransportControlsSessionPlaybackStatus::Closed;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool initWinRT()
|
|
||||||
{
|
|
||||||
HRESULT hr = RoInitialize(RO_INIT_MULTITHREADED);
|
|
||||||
// S_OK: initialized, S_FALSE: already initialized with same type,
|
|
||||||
// RPC_E_CHANGED_MODE: thread is STA (OBS UI thread) - WinRT still usable
|
|
||||||
return SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SessionInfo getCurrentSessionInfo()
|
|
||||||
{
|
|
||||||
thread_local bool initialized = initWinRT();
|
|
||||||
(void)initialized;
|
|
||||||
|
|
||||||
SessionInfo info;
|
|
||||||
|
|
||||||
try {
|
|
||||||
auto manager =
|
|
||||||
GlobalSystemMediaTransportControlsSessionManager::
|
|
||||||
RequestAsync()
|
|
||||||
.get();
|
|
||||||
auto session = manager.GetCurrentSession();
|
|
||||||
if (!session) {
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
info.hasSession = true;
|
|
||||||
info.appName = winrt::to_string(session.SourceAppUserModelId());
|
|
||||||
|
|
||||||
auto playbackInfo = session.GetPlaybackInfo();
|
|
||||||
info.playbackStatus = playbackInfo.PlaybackStatus();
|
|
||||||
|
|
||||||
auto props = session.TryGetMediaPropertiesAsync().get();
|
|
||||||
if (props) {
|
|
||||||
info.title = winrt::to_string(props.Title());
|
|
||||||
info.artist = winrt::to_string(props.Artist());
|
|
||||||
info.album = winrt::to_string(props.AlbumTitle());
|
|
||||||
}
|
|
||||||
} catch (const winrt::hresult_error &e) {
|
|
||||||
blog(LOG_WARNING, "now playing: WinRT error 0x%08X",
|
|
||||||
static_cast<uint32_t>(e.code()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string PlaybackStatusToString(
|
|
||||||
GlobalSystemMediaTransportControlsSessionPlaybackStatus status)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Playing:
|
|
||||||
return "Playing";
|
|
||||||
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Paused:
|
|
||||||
return "Paused";
|
|
||||||
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Stopped:
|
|
||||||
return "Stopped";
|
|
||||||
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Opened:
|
|
||||||
return "Opening";
|
|
||||||
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Changing:
|
|
||||||
return "Changing";
|
|
||||||
default:
|
|
||||||
return "Closed";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool MacroConditionNowPlaying::CheckCondition()
|
|
||||||
{
|
|
||||||
const auto info = getCurrentSessionInfo();
|
|
||||||
|
|
||||||
SetTempVarValue("title", info.title);
|
|
||||||
SetTempVarValue("artist", info.artist);
|
|
||||||
SetTempVarValue("album", info.album);
|
|
||||||
SetTempVarValue("appName", info.appName);
|
|
||||||
SetTempVarValue("playbackStatus",
|
|
||||||
PlaybackStatusToString(info.playbackStatus));
|
|
||||||
|
|
||||||
if (!info.hasSession) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto textMatches = [this](const std::string &field) -> bool {
|
|
||||||
const QString pattern = QString::fromStdString(_matchText);
|
|
||||||
const QString value = QString::fromStdString(field);
|
|
||||||
if (_regex.Enabled()) {
|
|
||||||
return _regex.Matches(value, pattern);
|
|
||||||
}
|
|
||||||
return value == pattern;
|
|
||||||
};
|
|
||||||
|
|
||||||
switch (_checkType) {
|
|
||||||
case CheckType::PLAYBACK_STATE: {
|
|
||||||
using S =
|
|
||||||
GlobalSystemMediaTransportControlsSessionPlaybackStatus;
|
|
||||||
switch (_playbackState) {
|
|
||||||
case PlaybackState::PLAYING:
|
|
||||||
return info.playbackStatus == S::Playing;
|
|
||||||
case PlaybackState::PAUSED:
|
|
||||||
return info.playbackStatus == S::Paused;
|
|
||||||
case PlaybackState::STOPPED:
|
|
||||||
return info.playbackStatus == S::Stopped;
|
|
||||||
case PlaybackState::OPENING:
|
|
||||||
return info.playbackStatus == S::Opened;
|
|
||||||
case PlaybackState::CHANGING:
|
|
||||||
return info.playbackStatus == S::Changing;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CheckType::TITLE:
|
|
||||||
return textMatches(info.title);
|
|
||||||
case CheckType::ARTIST:
|
|
||||||
return textMatches(info.artist);
|
|
||||||
case CheckType::ALBUM:
|
|
||||||
return textMatches(info.album);
|
|
||||||
case CheckType::APP_NAME:
|
|
||||||
return textMatches(info.appName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroConditionNowPlaying::Save(obs_data_t *obj) const
|
|
||||||
{
|
|
||||||
MacroCondition::Save(obj);
|
|
||||||
obs_data_set_int(obj, "checkType", static_cast<int>(_checkType));
|
|
||||||
obs_data_set_int(obj, "playbackState",
|
|
||||||
static_cast<int>(_playbackState));
|
|
||||||
_matchText.Save(obj, "matchText");
|
|
||||||
_regex.Save(obj);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacroConditionNowPlaying::Load(obs_data_t *obj)
|
|
||||||
{
|
|
||||||
MacroCondition::Load(obj);
|
|
||||||
_checkType = static_cast<CheckType>(obs_data_get_int(obj, "checkType"));
|
|
||||||
_playbackState = static_cast<PlaybackState>(
|
|
||||||
obs_data_get_int(obj, "playbackState"));
|
|
||||||
_matchText.Load(obj, "matchText");
|
|
||||||
_regex.Load(obj);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionNowPlaying::SetupTempVars()
|
|
||||||
{
|
|
||||||
AddTempvar(
|
|
||||||
"title",
|
|
||||||
obs_module_text("AdvSceneSwitcher.tempVar.nowPlaying.title"));
|
|
||||||
AddTempvar(
|
|
||||||
"artist",
|
|
||||||
obs_module_text("AdvSceneSwitcher.tempVar.nowPlaying.artist"));
|
|
||||||
AddTempvar(
|
|
||||||
"album",
|
|
||||||
obs_module_text("AdvSceneSwitcher.tempVar.nowPlaying.album"));
|
|
||||||
AddTempvar(
|
|
||||||
"appName",
|
|
||||||
obs_module_text("AdvSceneSwitcher.tempVar.nowPlaying.appName"));
|
|
||||||
AddTempvar(
|
|
||||||
"playbackStatus",
|
|
||||||
obs_module_text(
|
|
||||||
"AdvSceneSwitcher.tempVar.nowPlaying.playbackStatus"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static void populateCheckTypeSelection(QComboBox *list)
|
|
||||||
{
|
|
||||||
static const std::map<MacroConditionNowPlaying::CheckType, std::string> checkTypes = {
|
|
||||||
{MacroConditionNowPlaying::CheckType::PLAYBACK_STATE,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.checkType.playbackState"},
|
|
||||||
{MacroConditionNowPlaying::CheckType::TITLE,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.checkType.title"},
|
|
||||||
{MacroConditionNowPlaying::CheckType::ARTIST,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.checkType.artist"},
|
|
||||||
{MacroConditionNowPlaying::CheckType::ALBUM,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.checkType.album"},
|
|
||||||
{MacroConditionNowPlaying::CheckType::APP_NAME,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.checkType.appName"},
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto &[type, name] : checkTypes) {
|
|
||||||
list->addItem(obs_module_text(name.c_str()),
|
|
||||||
static_cast<int>(type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void populatePlaybackStateSelection(QComboBox *list)
|
|
||||||
{
|
|
||||||
static const std::map<MacroConditionNowPlaying::PlaybackState, std::string> playbackStates = {
|
|
||||||
{MacroConditionNowPlaying::PlaybackState::PLAYING,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.playbackState.playing"},
|
|
||||||
{MacroConditionNowPlaying::PlaybackState::PAUSED,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.playbackState.paused"},
|
|
||||||
{MacroConditionNowPlaying::PlaybackState::STOPPED,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.playbackState.stopped"},
|
|
||||||
{MacroConditionNowPlaying::PlaybackState::OPENING,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.playbackState.opening"},
|
|
||||||
{MacroConditionNowPlaying::PlaybackState::CHANGING,
|
|
||||||
"AdvSceneSwitcher.condition.nowPlaying.playbackState.changing"},
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto &[state, name] : playbackStates) {
|
|
||||||
list->addItem(obs_module_text(name.c_str()),
|
|
||||||
static_cast<int>(state));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MacroConditionNowPlayingEdit::MacroConditionNowPlayingEdit(
|
|
||||||
QWidget *parent, std::shared_ptr<MacroConditionNowPlaying> entryData)
|
|
||||||
: QWidget(parent),
|
|
||||||
_checkType(new QComboBox(this)),
|
|
||||||
_playbackState(new QComboBox(this)),
|
|
||||||
_matchText(new VariableLineEdit(this)),
|
|
||||||
_regex(new RegexConfigWidget(this))
|
|
||||||
{
|
|
||||||
populateCheckTypeSelection(_checkType);
|
|
||||||
populatePlaybackStateSelection(_playbackState);
|
|
||||||
|
|
||||||
connect(_checkType, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
||||||
this, &MacroConditionNowPlayingEdit::CheckTypeChanged);
|
|
||||||
connect(_playbackState,
|
|
||||||
QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
|
||||||
&MacroConditionNowPlayingEdit::PlaybackStateChanged);
|
|
||||||
connect(_matchText, &VariableLineEdit::textEdited, this,
|
|
||||||
&MacroConditionNowPlayingEdit::MatchTextChanged);
|
|
||||||
connect(_regex, &RegexConfigWidget::RegexConfigChanged, this,
|
|
||||||
&MacroConditionNowPlayingEdit::RegexChanged);
|
|
||||||
|
|
||||||
_layout = new QHBoxLayout();
|
|
||||||
_layout->addWidget(_checkType);
|
|
||||||
_layout->addWidget(_playbackState);
|
|
||||||
_layout->addWidget(_matchText);
|
|
||||||
_layout->addWidget(_regex);
|
|
||||||
setLayout(_layout);
|
|
||||||
|
|
||||||
_entryData = entryData;
|
|
||||||
UpdateEntryData();
|
|
||||||
_loading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionNowPlayingEdit::UpdateEntryData()
|
|
||||||
{
|
|
||||||
if (!_entryData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_checkType->setCurrentIndex(
|
|
||||||
_checkType->findData(static_cast<int>(_entryData->_checkType)));
|
|
||||||
_playbackState->setCurrentIndex(_playbackState->findData(
|
|
||||||
static_cast<int>(_entryData->_playbackState)));
|
|
||||||
_matchText->setText(QString::fromStdString(_entryData->_matchText));
|
|
||||||
_regex->SetRegexConfig(_entryData->_regex);
|
|
||||||
|
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionNowPlayingEdit::CheckTypeChanged(int)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_checkType =
|
|
||||||
static_cast<MacroConditionNowPlaying::CheckType>(
|
|
||||||
_checkType->currentData().toInt());
|
|
||||||
SetWidgetVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionNowPlayingEdit::PlaybackStateChanged(int)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_playbackState =
|
|
||||||
static_cast<MacroConditionNowPlaying::PlaybackState>(
|
|
||||||
_playbackState->currentData().toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionNowPlayingEdit::MatchTextChanged(const QString &text)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_matchText = text.toStdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionNowPlayingEdit::RegexChanged(const RegexConfig ®ex)
|
|
||||||
{
|
|
||||||
GUARD_LOADING_AND_LOCK();
|
|
||||||
_entryData->_regex = regex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MacroConditionNowPlayingEdit::SetWidgetVisibility()
|
|
||||||
{
|
|
||||||
const bool isStateCheck =
|
|
||||||
_entryData->_checkType ==
|
|
||||||
MacroConditionNowPlaying::CheckType::PLAYBACK_STATE;
|
|
||||||
_playbackState->setVisible(isStateCheck);
|
|
||||||
_matchText->setVisible(!isStateCheck);
|
|
||||||
_regex->setVisible(!isStateCheck);
|
|
||||||
|
|
||||||
if (isStateCheck) {
|
|
||||||
AddStretchIfNecessary(_layout);
|
|
||||||
} else {
|
|
||||||
RemoveStretchIfPresent(_layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
adjustSize();
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "macro-condition-edit.hpp"
|
|
||||||
#include "regex-config.hpp"
|
|
||||||
#include "variable-line-edit.hpp"
|
|
||||||
|
|
||||||
#include <QComboBox>
|
|
||||||
|
|
||||||
namespace advss {
|
|
||||||
|
|
||||||
class MacroConditionNowPlaying : public MacroCondition {
|
|
||||||
public:
|
|
||||||
enum class CheckType {
|
|
||||||
PLAYBACK_STATE,
|
|
||||||
TITLE,
|
|
||||||
ARTIST,
|
|
||||||
ALBUM,
|
|
||||||
APP_NAME,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class PlaybackState {
|
|
||||||
PLAYING,
|
|
||||||
PAUSED,
|
|
||||||
STOPPED,
|
|
||||||
OPENING,
|
|
||||||
CHANGING,
|
|
||||||
};
|
|
||||||
|
|
||||||
MacroConditionNowPlaying(Macro *m) : MacroCondition(m) {}
|
|
||||||
bool CheckCondition();
|
|
||||||
bool Save(obs_data_t *obj) const;
|
|
||||||
bool Load(obs_data_t *obj);
|
|
||||||
std::string GetId() const { return id; }
|
|
||||||
static std::shared_ptr<MacroCondition> Create(Macro *m)
|
|
||||||
{
|
|
||||||
return std::make_shared<MacroConditionNowPlaying>(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckType _checkType = CheckType::PLAYBACK_STATE;
|
|
||||||
PlaybackState _playbackState = PlaybackState::PLAYING;
|
|
||||||
StringVariable _matchText;
|
|
||||||
RegexConfig _regex;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SetupTempVars();
|
|
||||||
|
|
||||||
static bool _registered;
|
|
||||||
static const std::string id;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MacroConditionNowPlayingEdit : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MacroConditionNowPlayingEdit(
|
|
||||||
QWidget *parent,
|
|
||||||
std::shared_ptr<MacroConditionNowPlaying> cond = nullptr);
|
|
||||||
void UpdateEntryData();
|
|
||||||
static QWidget *Create(QWidget *parent,
|
|
||||||
std::shared_ptr<MacroCondition> cond)
|
|
||||||
{
|
|
||||||
return new MacroConditionNowPlayingEdit(
|
|
||||||
parent,
|
|
||||||
std::dynamic_pointer_cast<MacroConditionNowPlaying>(
|
|
||||||
cond));
|
|
||||||
}
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void CheckTypeChanged(int);
|
|
||||||
void PlaybackStateChanged(int);
|
|
||||||
void MatchTextChanged(const QString &);
|
|
||||||
void RegexChanged(const RegexConfig &);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SetWidgetVisibility();
|
|
||||||
|
|
||||||
QHBoxLayout *_layout;
|
|
||||||
QComboBox *_checkType;
|
|
||||||
QComboBox *_playbackState;
|
|
||||||
VariableLineEdit *_matchText;
|
|
||||||
RegexConfigWidget *_regex;
|
|
||||||
|
|
||||||
std::shared_ptr<MacroConditionNowPlaying> _entryData;
|
|
||||||
bool _loading = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace advss
|
|
||||||
@@ -110,9 +110,7 @@ void MacroEdit::HighlightControls() const {}
|
|||||||
void MacroEdit::PopulateMacroActions(Macro &, uint32_t) {}
|
void MacroEdit::PopulateMacroActions(Macro &, uint32_t) {}
|
||||||
void MacroEdit::PopulateMacroElseActions(Macro &, uint32_t) {}
|
void MacroEdit::PopulateMacroElseActions(Macro &, uint32_t) {}
|
||||||
void MacroEdit::PopulateMacroConditions(Macro &, uint32_t) {}
|
void MacroEdit::PopulateMacroConditions(Macro &, uint32_t) {}
|
||||||
void MacroEdit::InsertSegmentWidget(SegmentType, int) {}
|
void MacroEdit::SetupMacroSegmentSelection(MacroSection, int) {}
|
||||||
void MacroEdit::RemoveSegmentWidget(SegmentType, int) {}
|
|
||||||
void MacroEdit::SetupMacroSegmentSelection(SegmentType, int) {}
|
|
||||||
void MacroEdit::SetupContextMenu(const QPoint &,
|
void MacroEdit::SetupContextMenu(const QPoint &,
|
||||||
const std::function<void(MacroEdit *, int)> &,
|
const std::function<void(MacroEdit *, int)> &,
|
||||||
const std::function<void(MacroEdit *)> &,
|
const std::function<void(MacroEdit *)> &,
|
||||||
|
|||||||
Reference in New Issue
Block a user