From 5a2cb943f70b4fbdb6045ea6db0e33e961ae0bc1 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Wed, 23 Aug 2023 17:59:54 +0200 Subject: [PATCH] Add option to open interaction dialog of source --- data/locale/en-US.ini | 1 + src/macro-core/macro-action-source.cpp | 18 ++++++++++++++++++ src/macro-core/macro-action-source.hpp | 1 + 3 files changed, 20 insertions(+) diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 92c2779d..c202101c 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -561,6 +561,7 @@ AdvSceneSwitcher.action.source.type.pressSettingsButton="Press settings button" AdvSceneSwitcher.action.source.type.refreshSettings.tooltip="Can be used to refresh browser, media, etc. sources" AdvSceneSwitcher.action.source.type.deinterlaceMode="Set deinterlace mode" AdvSceneSwitcher.action.source.type.deinterlaceOrder="Set deinterlace field order" +AdvSceneSwitcher.action.source.type.openInteractionDialog="Open interaction dialog" AdvSceneSwitcher.action.source.noSettingsButtons="No buttons found!" AdvSceneSwitcher.action.source.entry="{{actions}}{{sources}}{{settingsButtons}}{{deinterlaceMode}}{{deinterlaceOrder}}" AdvSceneSwitcher.action.source.warning="Warning: Enabling and disabling sources globally cannot be controlled by the OBS UI\nYou might be looking for \"Scene item visibility\"" diff --git a/src/macro-core/macro-action-source.cpp b/src/macro-core/macro-action-source.cpp index a43d3d9c..2b6bc540 100644 --- a/src/macro-core/macro-action-source.cpp +++ b/src/macro-core/macro-action-source.cpp @@ -27,6 +27,8 @@ const static std::map actionTypes = { "AdvSceneSwitcher.action.source.type.deinterlaceMode"}, {MacroActionSource::Action::DEINTERLACE_FIELD_ORDER, "AdvSceneSwitcher.action.source.type.deinterlaceOrder"}, + {MacroActionSource::Action::OPEN_INTERACTION_DIALOG, + "AdvSceneSwitcher.action.source.type.openInteractionDialog"}, }; const static std::map deinterlaceModes = { @@ -110,6 +112,12 @@ static void refreshSourceSettings(obs_source_t *s) } } +static bool isInteractable(obs_source_t *source) +{ + uint32_t flags = obs_source_get_output_flags(source); + return (flags & OBS_SOURCE_INTERACTION) != 0; +} + bool MacroActionSource::PerformAction() { auto s = obs_weak_source_get_source(_source.GetSource()); @@ -135,6 +143,16 @@ bool MacroActionSource::PerformAction() case Action::DEINTERLACE_FIELD_ORDER: obs_source_set_deinterlace_field_order(s, _deinterlaceOrder); break; + case Action::OPEN_INTERACTION_DIALOG: + if (isInteractable(s)) { + obs_frontend_open_source_interaction(s); + } else { + blog(LOG_INFO, + "refusing to open interaction dialog " + "for non intractable source \"%s\"", + _source.ToString().c_str()); + } + break; default: break; } diff --git a/src/macro-core/macro-action-source.hpp b/src/macro-core/macro-action-source.hpp index 89eebd81..54f12891 100644 --- a/src/macro-core/macro-action-source.hpp +++ b/src/macro-core/macro-action-source.hpp @@ -48,6 +48,7 @@ public: SETTINGS_BUTTON, DEINTERLACE_MODE, DEINTERLACE_FIELD_ORDER, + OPEN_INTERACTION_DIALOG, }; Action _action = Action::ENABLE;