mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9301ead060 | ||
|
|
bc29ece526 | ||
|
|
4158c7a363 | ||
|
|
944d1059da | ||
|
|
bf18d8e106 | ||
|
|
bf216e0917 | ||
|
|
2405b6dbbf | ||
|
|
e64f2d195e | ||
|
|
f66bec8caf | ||
|
|
3eb79e3adb | ||
|
|
07e2ac3ca0 | ||
|
|
8e2c466c2d | ||
|
|
cc68e2366c | ||
|
|
7a0e08b0d8 | ||
|
|
be8744f0d0 | ||
|
|
d4425df694 | ||
|
|
70e5f6002d | ||
|
|
ff98ec36d6 | ||
|
|
4966802f14 | ||
|
|
b23a90557f | ||
|
|
d6ea815b85 |
|
|
@ -204,6 +204,8 @@ target_sources(
|
|||
lib/utils/file-selection.hpp
|
||||
lib/utils/filter-combo-box.cpp
|
||||
lib/utils/filter-combo-box.hpp
|
||||
lib/utils/first-run-wizard.cpp
|
||||
lib/utils/first-run-wizard.hpp
|
||||
lib/utils/help-icon.hpp
|
||||
lib/utils/help-icon.cpp
|
||||
lib/utils/item-selection-helpers.cpp
|
||||
|
|
@ -454,14 +456,29 @@ else()
|
|||
endif()
|
||||
if(PROCPS2_INCLUDE_DIR)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(libproc2 IMPORTED_TARGET libproc2<4.0.5 QUIET)
|
||||
if(libproc2_FOUND)
|
||||
target_compile_definitions(${LIB_NAME} PRIVATE PROCPS2_USE_INFO)
|
||||
endif()
|
||||
pkg_check_modules(libproc2 REQUIRED IMPORTED_TARGET libproc2)
|
||||
set(PROC_INCLUDE_DIR "${PROCPS2_INCLUDE_DIR}")
|
||||
target_compile_definitions(${LIB_NAME} PRIVATE PROCPS2_AVAILABLE)
|
||||
set(PROCESS_CONDITION_SUPPORTED 1)
|
||||
|
||||
# Check if PIDS_VAL takes 4 arguments (old API, pre-4.0.5) or 3 (new API)
|
||||
include(CheckCSourceCompiles)
|
||||
set(CMAKE_REQUIRED_INCLUDES "${PROCPS2_INCLUDE_DIR}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES proc2)
|
||||
check_c_source_compiles(
|
||||
"
|
||||
#include <libproc2/pids.h>
|
||||
int main(void) {
|
||||
struct pids_stack *s = 0;
|
||||
struct pids_info *i = 0;
|
||||
(void)PIDS_VAL(0, str, s, i);
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
PROCPS2_PIDS_VAL_TAKES_INFO)
|
||||
if(PROCPS2_PIDS_VAL_TAKES_INFO)
|
||||
target_compile_definitions(${LIB_NAME} PRIVATE PROCPS2_USE_INFO)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT DEFINED PROCESS_CONDITION_SUPPORTED)
|
||||
message(
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ function(_git_find_closest_git_dir _start_dir _git_dir_var)
|
|||
while(NOT EXISTS "${git_dir}")
|
||||
# .git dir not found, search parent directories
|
||||
set(git_previous_parent "${cur_dir}")
|
||||
get_filename_component(cur_dir ${cur_dir} DIRECTORY)
|
||||
get_filename_component(cur_dir "${cur_dir}" DIRECTORY)
|
||||
if(cur_dir STREQUAL git_previous_parent)
|
||||
# We have reached the root directory, we are not in git
|
||||
set(${_git_dir_var}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ AdvSceneSwitcher.macroTab.name="Name:"
|
|||
AdvSceneSwitcher.macroTab.run="Makro ausführen"
|
||||
AdvSceneSwitcher.macroTab.runFail="Ausführen von \"%1\" fehlgeschlagen!\nEntweder ist eine der Aktionen fehlgeschlagen oder das Makro wird bereits ausgeführt.\nSoll die aktuelle Ausführung gestoppt werden?"
|
||||
AdvSceneSwitcher.macroTab.runInParallel="Parallel zu anderen Makros ausführen"
|
||||
AdvSceneSwitcher.macroTab.onChange="Nur bei Änderung ausführen"
|
||||
AdvSceneSwitcher.macroTab.defaultname="Makro %1"
|
||||
AdvSceneSwitcher.macroTab.defaultGroupName="Gruppe %1"
|
||||
AdvSceneSwitcher.macroTab.removeGroupPopup.text="Sicher, dass \"%1\" und alle zugehörigen Elemente gelöscht werden?"
|
||||
|
|
@ -835,8 +834,6 @@ AdvSceneSwitcher.status.inactive="Inaktiv"
|
|||
AdvSceneSwitcher.running="Plugin läuft"
|
||||
AdvSceneSwitcher.stopped="Plugin gestoppt"
|
||||
|
||||
AdvSceneSwitcher.firstBootMessage="<html><head/><body><p>Dies scheint das erste Mal zu sein, dass der Erweiterte Szenenwechsler gestartet wurde.<br>Bitte schaue ins <a href=\"https://github.com/WarmUpTill/SceneSwitcher/wiki\"><span style=\" text-decoration: underline; color:#268bd2;\">Wiki</span></a> für eine Liste von Anleitungen und Beispielen.<br>Nicht zögern und Fragen im <a href=\"https://obsproject.com/forum/threads/advanced-scene-switcher.48264\"><span style=\" text-decoration: underline; color:#268bd2;\">Thread</span></a> des Plugins im OBS-Forum stellen!!</p></body></html>"
|
||||
|
||||
AdvSceneSwitcher.deprecatedTabWarning="Die Entwicklung für dieses Tab wurde gestoppt!\nBitte stattdessen zur Verwendung des Makros-Tab übergehen.\nDieser Hinweis kann im Allgemein-Tab deaktiviert werden."
|
||||
|
||||
AdvSceneSwitcher.unit.milliseconds="Millisekunden"
|
||||
|
|
|
|||
|
|
@ -177,7 +177,12 @@ AdvSceneSwitcher.macroTab.run.tooltip="Run all macro actions regardless of condi
|
|||
AdvSceneSwitcher.macroTab.runElse="Run macro (else)"
|
||||
AdvSceneSwitcher.macroTab.runFail="Running \"%1\" failed!\nEither one of the actions failed or the macro is running already.\nDo you want to stop it?"
|
||||
AdvSceneSwitcher.macroTab.runInParallel="Run macro in parallel to other macros"
|
||||
AdvSceneSwitcher.macroTab.onChange="Perform actions only on condition change"
|
||||
AdvSceneSwitcher.macroTab.actionTriggerMode.label="Perform actions:"
|
||||
AdvSceneSwitcher.macroTab.actionTriggerMode.tooltip="Controls when the actions of this macro are performed.\n\n\"Always\" - actions are performed every time the conditions are met.\n\"Macro result changed\" - actions are only performed when the macro transitions between matching and not matching.\n\"Any condition changed\" - actions are only performed when any individual condition changes its result.\n\"Any condition triggered\" - actions are only performed when any individual condition changes from false to true."
|
||||
AdvSceneSwitcher.macroTab.actionTriggerMode.always="always"
|
||||
AdvSceneSwitcher.macroTab.actionTriggerMode.onOverallChange="only when result changes"
|
||||
AdvSceneSwitcher.macroTab.actionTriggerMode.onAnyConditionChange="only when any condition changes"
|
||||
AdvSceneSwitcher.macroTab.actionTriggerMode.onAnyConditionTriggered="only when any condition becomes true"
|
||||
AdvSceneSwitcher.macroTab.defaultname="Macro %1"
|
||||
AdvSceneSwitcher.macroTab.defaultGroupName="Group %1"
|
||||
AdvSceneSwitcher.macroTab.macroNameExists="The name \"%1\" is already used by a macro."
|
||||
|
|
@ -944,6 +949,8 @@ AdvSceneSwitcher.action.source.type.openPropertiesDialog="Open properties dialog
|
|||
AdvSceneSwitcher.action.source.type.closeInteractionDialog="Close interaction dialog"
|
||||
AdvSceneSwitcher.action.source.type.closeFilterDialog="Close filter dialog"
|
||||
AdvSceneSwitcher.action.source.type.closePropertiesDialog="Close properties dialog"
|
||||
AdvSceneSwitcher.action.source.type.getSetting="Get setting value"
|
||||
AdvSceneSwitcher.action.source.type.getSettings="Get settings JSON"
|
||||
AdvSceneSwitcher.action.source.entry="{{actions}}{{sources}}{{settingsButtons}}{{deinterlaceMode}}{{deinterlaceOrder}}{{refresh}}"
|
||||
AdvSceneSwitcher.action.source.entry.settings="{{settings}}{{settingsInputMethod}}{{settingValue}}{{tempVar}}"
|
||||
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\""
|
||||
|
|
@ -1248,23 +1255,52 @@ AdvSceneSwitcher.action.twitch.type.channel.info.category.set="Set stream catego
|
|||
AdvSceneSwitcher.action.twitch.type.channel.info.tags.set="Set stream tags"
|
||||
AdvSceneSwitcher.action.twitch.type.channel.info.language.set="Set stream language"
|
||||
AdvSceneSwitcher.action.twitch.type.raid.start="Start raid"
|
||||
AdvSceneSwitcher.action.twitch.type.raid.end="Cancel raid"
|
||||
AdvSceneSwitcher.action.twitch.type.shoutout.send="Send shoutout"
|
||||
AdvSceneSwitcher.action.twitch.type.shieldMode.start="Enable shield mode"
|
||||
AdvSceneSwitcher.action.twitch.type.shieldMode.end="Disable shield mode"
|
||||
AdvSceneSwitcher.action.twitch.type.commercial.start="Start commercial"
|
||||
AdvSceneSwitcher.action.twitch.type.commercial.snooze="Snooze next ad"
|
||||
AdvSceneSwitcher.action.twitch.type.marker.create="Create stream marker"
|
||||
AdvSceneSwitcher.action.twitch.type.clip.create="Create stream clip"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.announcement.send="Send chat announcement"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.emoteOnly.enable="Enable chat's emote-only mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.emoteOnly.disable="Disable chat's emote-only mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.followerOnly.enable="Enable chat's follower-only mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.followerOnly.disable="Disable chat's follower-only mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.subscriberOnly.enable="Enable chat's subscriber-only mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.subscriberOnly.disable="Disable chat's subscriber-only mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.slowMode.enable="Enable chat's slow mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.slowMode.disable="Disable chat's slow mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.nonModeratorDelay.enable="Enable chat's non-moderator message delay"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.nonModeratorDelay.disable="Disable chat's non-moderator message delay"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.uniqueMode.enable="Enable chat's unique message mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.uniqueMode.disable="Disable chat's unique message mode"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.sendMessage="Send chat message"
|
||||
AdvSceneSwitcher.action.twitch.type.user.getInfo="Get user information"
|
||||
AdvSceneSwitcher.action.twitch.type.user.ban="Ban user"
|
||||
AdvSceneSwitcher.action.twitch.type.user.unban="Unban user"
|
||||
AdvSceneSwitcher.action.twitch.type.user.block="Block user"
|
||||
AdvSceneSwitcher.action.twitch.type.user.unblock="Unblock user"
|
||||
AdvSceneSwitcher.action.twitch.type.user.moderator.add="Add user as moderator"
|
||||
AdvSceneSwitcher.action.twitch.type.user.moderator.delete="Remove user as moderator"
|
||||
AdvSceneSwitcher.action.twitch.type.user.vip.add="Add user as VIP"
|
||||
AdvSceneSwitcher.action.twitch.type.user.vip.delete="Remove user as VIP"
|
||||
AdvSceneSwitcher.action.twitch.type.reward.getInfo="Get channel points reward information"
|
||||
AdvSceneSwitcher.action.twitch.type.channel.getInfo="Get channel information"
|
||||
AdvSceneSwitcher.action.twitch.reward.toggleControl="Toggle reward name / variable selection control"
|
||||
AdvSceneSwitcher.action.twitch.categorySelectionDisabled="Cannot select category without selecting a Twitch account first!"
|
||||
AdvSceneSwitcher.action.twitch.layout.default="On{{account}}{{actions}}{{streamTitle}}{{category}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{channel}}{{pointsReward}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.default="On{{account}}{{actions}}{{streamTitle}}{{category}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{nonModDelayDuration}}{{channel}}{{pointsReward}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.chat="Using account{{account}}{{actions}}on{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.channel.getInfo="Using account{{account}}{{actions}}of{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo="Using account{{account}}{{actions}}for{{userInfoQueryType}}{{userLogin}}{{userId}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo="Using account{{account}}{{actions}}for channel{{channel}}{{pointsReward}}{{rewardVariable}}{{toggleRewardSelection}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo.row1="Using account{{account}}{{actions}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo.row2="for{{userInfoQueryType}}{{userLogin}}{{userId}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.moderation.row1="Using account{{account}}{{actions}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.moderation.row2="on channel{{channel}}for{{userInfoQueryType}}{{userLogin}}{{userId}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.ban.row1="Using account{{account}}{{actions}}timeout{{duration}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.ban.row2="on channel{{channel}}for{{userInfoQueryType}}{{userLogin}}{{userId}}reason{{banReason}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo.row1="Using account{{account}}{{actions}}for channel{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo.row2="{{pointsReward}}{{rewardVariable}}{{toggleRewardSelection}}"
|
||||
AdvSceneSwitcher.action.twitch.title.title="Enter title"
|
||||
AdvSceneSwitcher.action.twitch.marker.description="Describe marker"
|
||||
AdvSceneSwitcher.action.twitch.clip.hasDelay="Add a slight delay before capturing the clip"
|
||||
|
|
@ -1285,6 +1321,8 @@ AdvSceneSwitcher.action.twitch.tags.duplicate.info="This tag is already in the l
|
|||
AdvSceneSwitcher.action.twitch.tags.limit="Tag Limit Reached"
|
||||
AdvSceneSwitcher.action.twitch.tags.limit.info="You can only have up to %1 tags."
|
||||
AdvSceneSwitcher.action.twitch.type.channel.info.contentClassification.set="Set content classification labels"
|
||||
AdvSceneSwitcher.action.twitch.type.channel.info.brandedContent.enable="Enable branded content"
|
||||
AdvSceneSwitcher.action.twitch.type.channel.info.brandedContent.disable="Disable branded content"
|
||||
AdvSceneSwitcher.action.twitch.contentClassification.debatedSocialIssuesAndPolitics="Discussions or debates about politics or sensitive social issues such as elections, civic integrity, military conflict, and civil rights."
|
||||
AdvSceneSwitcher.action.twitch.contentClassification.drugsIntoxication="Excessive tobacco glorification or promotion, any marijuana consumption/use, legal drug and alcohol induced intoxication, discussions of illegal drugs."
|
||||
AdvSceneSwitcher.action.twitch.contentClassification.sexualThemes="Content that focuses on sexualized activities, sexual topics, or experiences."
|
||||
|
|
@ -2196,6 +2234,8 @@ AdvSceneSwitcher.tempVar.recording.durationSeconds.description="Recording durati
|
|||
AdvSceneSwitcher.tempVar.recording.lastSavePath="Last save path"
|
||||
AdvSceneSwitcher.tempVar.recording.lastSavePath.description="The file path of the last saved recording."
|
||||
|
||||
AdvSceneSwitcher.tempVar.video.similarity="Similarity Rating"
|
||||
AdvSceneSwitcher.tempVar.video.similarity.description="Values range from 0 to 1, where 0 means dissimilar and 1 means highly similar."
|
||||
AdvSceneSwitcher.tempVar.video.patternCount="Pattern count"
|
||||
AdvSceneSwitcher.tempVar.video.patternCount.description="The number of times the given pattern has been found in a given video input frame."
|
||||
AdvSceneSwitcher.tempVar.video.objectCount="Object count"
|
||||
|
|
@ -2347,6 +2387,14 @@ AdvSceneSwitcher.tempVar.cursor.y="Cursor position (Y)"
|
|||
AdvSceneSwitcher.tempVar.replay.lastSavePath="Last save path"
|
||||
AdvSceneSwitcher.tempVar.replay.lastSavePath.description="The file path of the last replay buffer saved."
|
||||
|
||||
AdvSceneSwitcher.tempVar.sequence.macro="Macro"
|
||||
AdvSceneSwitcher.tempVar.sequence.macro.description="The name of the macro executed by the \"Sequence\" action.\nIf no macro was executed the returned value is the empty string."
|
||||
AdvSceneSwitcher.tempVar.sequence.nextMacro="Next Macro"
|
||||
AdvSceneSwitcher.tempVar.sequence.nextMacro.description="The name of the macro which will be executed next after the index was set.\nIf no macro will be executed the returned value is the empty string."
|
||||
|
||||
AdvSceneSwitcher.tempVar.random.macro="Macro"
|
||||
AdvSceneSwitcher.tempVar.random.macro.description="The name of the macro executed by the \"Random\" action.\nIf no macro was executed the returned value is the empty string."
|
||||
|
||||
AdvSceneSwitcher.selectScene="--select scene--"
|
||||
AdvSceneSwitcher.selectCanvas="--select canvas--"
|
||||
AdvSceneSwitcher.selectPreviousScene="Previous Scene"
|
||||
|
|
@ -2436,8 +2484,6 @@ AdvSceneSwitcher.status.inactive="Inactive"
|
|||
AdvSceneSwitcher.running="Plugin running"
|
||||
AdvSceneSwitcher.stopped="Plugin stopped"
|
||||
|
||||
AdvSceneSwitcher.firstBootMessage="<html><head/><body><p>This seems to be the first time the Advanced Scene Switcher was started.<br>Please have a look at the <a href=\"https://github.com/WarmUpTill/SceneSwitcher/wiki\"><span style=\" text-decoration: underline; color:#268bd2;\">Wiki</span></a> for a list of guides and examples.<br>Do not hesitate to ask questions in the plugin's <a href=\"https://obsproject.com/forum/threads/advanced-scene-switcher.48264\"><span style=\" text-decoration: underline; color:#268bd2;\">thread</span></a> on the OBS forums!</p></body></html>"
|
||||
|
||||
AdvSceneSwitcher.deprecatedTabWarning="Development for this tab stopped!\nPlease consider transitioning to using Macros instead.\nThis hint can be disabled on the General tab."
|
||||
|
||||
AdvSceneSwitcher.unit.milliseconds="milliseconds"
|
||||
|
|
@ -2477,6 +2523,37 @@ AdvSceneSwitcher.day.sunday="Sunday"
|
|||
AdvSceneSwitcher.day.none="No day"
|
||||
AdvSceneSwitcher.day.any="Any day"
|
||||
|
||||
# First run wizard
|
||||
FirstRunWizard.windowTitle="Advanced Scene Switcher - Setup Wizard"
|
||||
|
||||
FirstRunWizard.welcome.title="Welcome to Advanced Scene Switcher"
|
||||
FirstRunWizard.welcome.subtitle="Let's create your first automation in a few easy steps."
|
||||
FirstRunWizard.welcome.body="<p>Advanced Scene Switcher lets you build <b>Macros</b> - rules of the form:</p><blockquote><i>When [condition] -> perform [action]</i></blockquote><p>This wizard creates a macro that <b>switches to a chosen OBS scene whenever a specific window comes into focus</b>.</p><p>You can skip at any time. Re-open this wizard later from the <b>General</b> tab inside the Advanced Scene Switcher dialog.</p>"
|
||||
|
||||
FirstRunWizard.scene.title="Choose a Target Scene"
|
||||
FirstRunWizard.scene.subtitle="Which OBS scene should become active when your chosen window comes into focus?"
|
||||
FirstRunWizard.scene.label="Switch to scene:"
|
||||
|
||||
FirstRunWizard.window.title="Choose a Trigger Window"
|
||||
FirstRunWizard.window.subtitle="Enter the title of the window that should trigger the scene switch. Partial matches are fine - \"Firefox\" will match any Firefox window."
|
||||
FirstRunWizard.window.label="Window title contains:"
|
||||
FirstRunWizard.window.placeholder="e.g. \"Firefox\", \"Visual Studio Code\""
|
||||
FirstRunWizard.window.autoDetect="Auto-detect focused window"
|
||||
FirstRunWizard.window.autoDetectTooltip="Click, then switch to the target window. The title will be captured automatically after 3 seconds."
|
||||
FirstRunWizard.window.autoDetectCountdown="Detecting in %1 s - focus your window now..."
|
||||
FirstRunWizard.window.hint="<small>Tip: a short partial title is more robust than the full title, which often changes when you switch tabs.</small>"
|
||||
|
||||
FirstRunWizard.review.title="Review Your Macro"
|
||||
FirstRunWizard.review.subtitle="Click Back to make changes, or Finish to create the macro."
|
||||
FirstRunWizard.review.summary="<b>Macro name:</b> Window -> %1<br><br><b>Condition:</b> Focused window title contains <i>\"%2\"</i> (case-insensitive)<br><br><b>Action:</b> Switch to scene <i>\"%1\"</i>"
|
||||
FirstRunWizard.review.errorTitle="Macro Creation Failed"
|
||||
FirstRunWizard.review.errorBody="The macro could not be created automatically.\n\nYou can create it manually on the Macros tab:\n Condition: Window -> contains \"%1\"\n Action: Switch scene -> \"%2\""
|
||||
|
||||
FirstRunWizard.done.title="You're all set!"
|
||||
FirstRunWizard.done.subtitle="Your first macro has been created and is now active."
|
||||
FirstRunWizard.done.body="<p>You can view and edit it on the <b>Macros</b> tab of the Advanced Scene Switcher dialog.</p><p>To learn more:</p><ul><li><a href=\"https://github.com/WarmUpTill/SceneSwitcher/wiki\">Plugin wiki</a></li><li><a href=\"https://obsproject.com/forum/resources/automatic-scene-switching.395/\">OBS forum thread</a></li></ul>"
|
||||
|
||||
FirstRunWizard.openButton="Open Setup Wizard..."
|
||||
# This secion is copied from the OBS locale files
|
||||
|
||||
# OBS commonly shared locale
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ AdvSceneSwitcher.macroTab.add="Agregar nueva macro"
|
|||
AdvSceneSwitcher.macroTab.name="Nombre:"
|
||||
AdvSceneSwitcher.macroTab.run="Ejecutar macro"
|
||||
AdvSceneSwitcher.macroTab.runInParallel="Ejecutar macro en paralelo a otras macros"
|
||||
AdvSceneSwitcher.macroTab.onChange="Realizar acciones solo en el cambio de condición"
|
||||
AdvSceneSwitcher.macroTab.defaultname="Macro %1"
|
||||
AdvSceneSwitcher.macroTab.copy="Crear copia"
|
||||
AdvSceneSwitcher.macroTab.expandAll="Expandir todo"
|
||||
|
|
@ -681,8 +680,6 @@ AdvSceneSwitcher.status.inactive="Inactivo"
|
|||
AdvSceneSwitcher.running="Iniciar complemento"
|
||||
AdvSceneSwitcher.stopped="Complemento de detención"
|
||||
|
||||
AdvSceneSwitcher.firstBootMessage="<html><head/><body><p>Esta parece ser la primera vez que se inicia el conmutador de escena avanzado.<br>Por favor, eche un vistazo a <a href=\"https:/ /github.com/WarmUpTill/SceneSwitcher/wiki\"><span style=\" text-decoration: underline; color:#268bd2;\">Wiki</span></a> para obtener una lista de guías y ejemplos.<br>No dude en hacer preguntas en el complemento <a href=\"https://obsproject.com /forum/threads/advanced-scene-switcher.48264\"><span style=\" text-decoration: underline; color:#268bd2;\">hilo</span></a> en los foros de OBS!</p></body></html>"
|
||||
|
||||
AdvSceneSwitcher.deprecatedTabWarning="¡Se detuvo el desarrollo de esta pestaña!\nConsidere cambiar a macros en su lugar.\nEsta sugerencia se puede desactivar en la pestaña General".
|
||||
|
||||
AdvSceneSwitcher.unit.milliseconds="milisegundos"
|
||||
|
|
|
|||
|
|
@ -78,7 +78,6 @@ AdvSceneSwitcher.macroTab.add="Ajouter une nouvelle macro"
|
|||
AdvSceneSwitcher.macroTab.name="Nom :"
|
||||
AdvSceneSwitcher.macroTab.run="Exécuter la macro"
|
||||
AdvSceneSwitcher.macroTab.runInParallel="Exécuter la macro en parallèle avec d'autres macros"
|
||||
AdvSceneSwitcher.macroTab.onChange="Exécuter des actions uniquement en cas de changement de condition"
|
||||
AdvSceneSwitcher.macroTab.defaultname="Macro %1"
|
||||
AdvSceneSwitcher.macroTab.defaultGroupName="Groupe %1"
|
||||
AdvSceneSwitcher.macroTab.removeSingleMacroPopup.text="Êtes-vous sûr de vouloir supprimer \"%1\" ?"
|
||||
|
|
@ -1123,8 +1122,6 @@ AdvSceneSwitcher.status.inactive="Inactif"
|
|||
AdvSceneSwitcher.running="Plugin en cours d'exécution"
|
||||
AdvSceneSwitcher.stopped="Plugin arrêté"
|
||||
|
||||
AdvSceneSwitcher.firstBootMessage="<html><head/><body><p>Il semble que ce soit la première fois que l'Advanced Scene Switcher est démarré.<br>Veuillez consulter le <a href=\"https://github.com/WarmUpTill/SceneSwitcher/wiki\"><span style=\" text-decoration: underline; color:#268bd2;\">Wiki</span></a> pour obtenir une liste de guides et d'exemples.<br>N'hésitez pas à poser des questions dans le <a href=\"https://obsproject.com/forum/threads/advanced-scene-switcher.48264\"><span style=\" text-decoration: underline; color:#268bd2;\">fil de discussion</span></a> du plugin sur les forums OBS !</p></body></html>"
|
||||
|
||||
AdvSceneSwitcher.deprecatedTabWarning="Le développement de cet onglet est terminé !\nVeuillez envisager de passer à l'utilisation des Macros à la place.\nCette astuce peut être désactivée dans l'onglet Général."
|
||||
|
||||
AdvSceneSwitcher.unit.milliseconds="millisecondes"
|
||||
|
|
|
|||
|
|
@ -164,7 +164,6 @@ AdvSceneSwitcher.macroTab.run.tooltip="条件に関係なくすべてのマク
|
|||
AdvSceneSwitcher.macroTab.runElse="マクロ実行(else)"
|
||||
AdvSceneSwitcher.macroTab.runFail="\"%1\" の実行に失敗しました!\nいずれかのアクションが失敗したか、マクロがすでに実行されています。\n停止しますか?"
|
||||
AdvSceneSwitcher.macroTab.runInParallel="他のマクロと並行してマクロを実行する"
|
||||
AdvSceneSwitcher.macroTab.onChange="条件変更時のみアクションを実行"
|
||||
AdvSceneSwitcher.macroTab.defaultname="マクロ %1"
|
||||
AdvSceneSwitcher.macroTab.defaultGroupName="グループ %1"
|
||||
AdvSceneSwitcher.macroTab.macroNameExists="名前 \"%1\" は既にマクロで使用されています。"
|
||||
|
|
@ -1191,8 +1190,15 @@ AdvSceneSwitcher.action.twitch.reward.toggleControl="リワード名/変数選
|
|||
AdvSceneSwitcher.action.twitch.categorySelectionDisabled="Twitchアカウントを選択しないとカテゴリを選択できません!"
|
||||
; AdvSceneSwitcher.action.twitch.layout.default="On{{account}}{{actions}}{{streamTitle}}{{category}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.chat="{{channel}}でアカウント{{account}}{{actions}}を使用しています"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo="{{userInfoQueryType}}{{userLogin}}{{userId}}でアカウント{{account}}{{actions}}を使用"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo="チャンネル{{channel}}{{pointsReward}}{{rewardVariable}}{{toggleRewardSelection}}でアカウント{{account}}{{actions}}を使用"
|
||||
AdvSceneSwitcher.action.twitch.layout.channel.getInfo="チャンネル{{channel}}でアカウント{{account}}{{actions}}を使用"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo.row1="アカウント{{account}}{{actions}}を使用"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo.row2="{{userInfoQueryType}}{{userLogin}}{{userId}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.moderation.row1="アカウント{{account}}{{actions}}を使用"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.moderation.row2="チャンネル{{channel}}{{userInfoQueryType}}{{userLogin}}{{userId}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.ban.row1="アカウント{{account}}{{actions}}を使用 タイムアウト{{duration}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.ban.row2="チャンネル{{channel}}{{userInfoQueryType}}{{userLogin}}{{userId}} 理由{{banReason}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo.row1="チャンネル{{channel}}でアカウント{{account}}{{actions}}を使用"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo.row2="{{pointsReward}}{{rewardVariable}}{{toggleRewardSelection}}"
|
||||
AdvSceneSwitcher.action.twitch.title.title="タイトルを入力"
|
||||
AdvSceneSwitcher.action.twitch.marker.description="マーカーの説明"
|
||||
AdvSceneSwitcher.action.twitch.clip.hasDelay="クリップをキャプチャする前にわずかな遅延を追加します"
|
||||
|
|
@ -2252,8 +2258,6 @@ AdvSceneSwitcher.status.inactive="停止中"
|
|||
AdvSceneSwitcher.running="プラグイン実行中"
|
||||
AdvSceneSwitcher.stopped="プラグイン停止しました"
|
||||
|
||||
AdvSceneSwitcher.firstBootMessage="<html><head/><body><p>高機能シーンスイッチャーが初めて起動したようです。<br>ガイドと使用例については <a href=\"https://github.com/WarmUpTill/SceneSwitcher/wiki\"><span style=\" text-decoration: underline; color:#268bd2;\">Wiki</span></a> をご覧ください。<br>質問は <a href=\"https://obsproject.com/forum/threads/advanced-scene-switcher.48264\"><span style=\" text-decoration: underline; color:#268bd2;\">OBSフォーラムのプラグインのスレッド</span></a> で遠慮なくどうぞ!</p></body></html>"
|
||||
|
||||
AdvSceneSwitcher.deprecatedTabWarning="このタブの開発は停止しました!\n代わりにマクロの使用に移行することを検討してください。\nこのヒントは [全般] タブで無効にすることができます。"
|
||||
|
||||
AdvSceneSwitcher.unit.milliseconds="ミリ秒"
|
||||
|
|
|
|||
|
|
@ -147,7 +147,6 @@ AdvSceneSwitcher.macroTab.run.tooltip="Execute todas as ações da macro indepen
|
|||
AdvSceneSwitcher.macroTab.runElse="Executar macro (alternativa)"
|
||||
AdvSceneSwitcher.macroTab.runFail="Falha ao executar \"%1\"!\nUma das ações falhou ou a macro já está em execução.\nDeseja interrompê-la?"
|
||||
AdvSceneSwitcher.macroTab.runInParallel="Executar macro em paralelo com outras macros"
|
||||
AdvSceneSwitcher.macroTab.onChange="Executar ações apenas quando houver mudança na condição"
|
||||
AdvSceneSwitcher.macroTab.defaultname="Macro %1"
|
||||
AdvSceneSwitcher.macroTab.defaultGroupName="Grupo %1"
|
||||
AdvSceneSwitcher.macroTab.macroNameExists="O nome \"%1\" já está em uso por uma macro."
|
||||
|
|
@ -1066,7 +1065,7 @@ AdvSceneSwitcher.action.twitch.type.chat.emoteOnly.enable="Habilitar modo apenas
|
|||
AdvSceneSwitcher.action.twitch.type.chat.emoteOnly.disable="Desabilitar modo apenas emotes no chat"
|
||||
AdvSceneSwitcher.action.twitch.type.chat.sendMessage="Enviar mensagem de chat"
|
||||
AdvSceneSwitcher.action.twitch.categorySelectionDisabled="Não é possível selecionar categoria sem selecionar uma conta Twitch primeiro!"
|
||||
AdvSceneSwitcher.action.twitch.layout.default="Em{{account}}{{actions}}{{streamTitle}}{{category}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{channel}}{{pointsReward}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.default="Em{{account}}{{actions}}{{streamTitle}}{{category}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{channel}}{{pointsReward}}{{nonModDelayDuration}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.chat="Usando conta{{account}}{{actions}}em{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.title.title="Digite o título"
|
||||
AdvSceneSwitcher.action.twitch.marker.description="Descreva o marcador"
|
||||
|
|
@ -1872,8 +1871,6 @@ AdvSceneSwitcher.status.inactive="Inativo"
|
|||
AdvSceneSwitcher.running="Plugin em execução"
|
||||
AdvSceneSwitcher.stopped="Plugin parado"
|
||||
|
||||
AdvSceneSwitcher.firstBootMessage="<html><head/><body><p>Parece que esta é a primeira vez que o Advanced Scene Switcher está sendo iniciado.<br>Por favor, consulte o <a href=\"https://github.com/WarmUpTill/SceneSwitcher/wiki\"><span style=\" text-decoration: underline; color:#268bd2;\">Wiki</span></a> para uma lista de guias e exemplos.<br>Não hesite em fazer perguntas no <a href=\"https://obsproject.com/forum/threads/advanced-scene-switcher.48264\"><span style=\" text-decoration: underline; color:#268bd2;\">tópico</span></a> do plugin nos fóruns do OBS!</p></body></html>"
|
||||
|
||||
AdvSceneSwitcher.deprecatedTabWarning="Desenvolvimento para esta aba interrompido!\nPor favor, considere a transição para o uso de Macros em vez disso.\nEsta dica pode ser desativada na aba Geral."
|
||||
|
||||
AdvSceneSwitcher.unit.milliseconds="milissegundos"
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ AdvSceneSwitcher.macroTab.add="Yeni Makro ekle"
|
|||
AdvSceneSwitcher.macroTab.name="İsim:"
|
||||
AdvSceneSwitcher.macroTab.run="Makro Çalıştırma"
|
||||
AdvSceneSwitcher.macroTab.runInParallel="Makroyu diğer makrolara paralel olarak çalıştırın"
|
||||
AdvSceneSwitcher.macroTab.onChange="Eylemleri yalnızca koşul değişikliğinde gerçekleştirin"
|
||||
AdvSceneSwitcher.macroTab.defaultname="Makro %1"
|
||||
AdvSceneSwitcher.macroTab.copy="Kopya oluştur"
|
||||
AdvSceneSwitcher.macroTab.expandAll="Hepsini Genişlet"
|
||||
|
|
@ -587,8 +586,6 @@ AdvSceneSwitcher.status.inactive="İnaktif"
|
|||
AdvSceneSwitcher.running="Eklenti çalışıyor"
|
||||
AdvSceneSwitcher.stopped="Eklenti durdu"
|
||||
|
||||
AdvSceneSwitcher.firstBootMessage="<html><head/><body><p>Gelişmiş Sahne Değiştirici ilk kez başlatılıyor gibi görünüyor.<br>Lütfen <a href=\"https://github.com/ adresine bir göz atın. WarmUpTill/SceneSwitcher/wiki\"><span style=\" text-decoration: underline; color:#268bd2;\">Wiki</span></a> için kılavuzlar ve örnekler listesi.<br>Yapmayın. eklentinin <a href=\"https://obsproject.com/forum/threads/advanced-scene-switcher.48264\"><span style=\" text-decoration: underline; color:# sayfasında soru sormaktan çekinmeyin OBS forumlarında 268bd2;\">konu</span></a>!</p></body></html>"
|
||||
|
||||
AdvSceneSwitcher.unit.milliseconds="millisaniye"
|
||||
AdvSceneSwitcher.unit.seconds="saniye"
|
||||
AdvSceneSwitcher.unit.minutes="dakika"
|
||||
|
|
|
|||
|
|
@ -151,7 +151,6 @@ AdvSceneSwitcher.macroTab.run.tooltip="无论条件如何,都运行所有宏
|
|||
AdvSceneSwitcher.macroTab.runElse="运行宏(不满足条件)"
|
||||
AdvSceneSwitcher.macroTab.runFail="运行 \"%1\" 失败!\n要么其中一个操作失败,要么宏已在运行中.\n你想停止它吗?"
|
||||
AdvSceneSwitcher.macroTab.runInParallel="与其他宏并行运行宏"
|
||||
AdvSceneSwitcher.macroTab.onChange="仅在条件结果发生变化时执行操作(条件结果不变时只执行一次操作)"
|
||||
AdvSceneSwitcher.macroTab.defaultname="宏 %1"
|
||||
AdvSceneSwitcher.macroTab.defaultGroupName="分组 %1"
|
||||
AdvSceneSwitcher.macroTab.macroNameExists="名称 \"%1\" 已被宏使用."
|
||||
|
|
@ -1140,10 +1139,17 @@ AdvSceneSwitcher.action.twitch.type.user.getInfo="获取用户信息"
|
|||
AdvSceneSwitcher.action.twitch.type.reward.getInfo="获取频道积分奖励信息"
|
||||
AdvSceneSwitcher.action.twitch.reward.toggleControl="切换奖励名称/变量选择控制"
|
||||
AdvSceneSwitcher.action.twitch.categorySelectionDisabled="在未选择 Twitch 帐户的情况下无法选择类别!"
|
||||
AdvSceneSwitcher.action.twitch.layout.default="{{account}}{{actions}}{{streamTitle}}{{category}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{channel}}{{pointsReward}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.default="{{account}}{{actions}}{{streamTitle}}{{category}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{channel}}{{pointsReward}}{{nonModDelayDuration}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.chat="使用账户{{account}}{{actions}}{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo="使用账户{{account}}{{actions}}{{userInfoQueryType}}{{userLogin}}{{userId}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo="使用账户{{account}}{{actions}} 频道{{channel}}{{pointsReward}}{{rewardVariable}}{{toggleRewardSelection}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.channel.getInfo="使用账户{{account}}{{actions}}频道{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo.row1="使用账户{{account}}{{actions}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.getInfo.row2="{{userInfoQueryType}}{{userLogin}}{{userId}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.moderation.row1="使用账户{{account}}{{actions}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.moderation.row2="频道{{channel}}{{userInfoQueryType}}{{userLogin}}{{userId}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.ban.row1="使用账户{{account}}{{actions}}超时{{duration}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.user.ban.row2="频道{{channel}}{{userInfoQueryType}}{{userLogin}}{{userId}}原因{{banReason}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo.row1="使用账户{{account}}{{actions}} 频道{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.layout.reward.getInfo.row2="{{pointsReward}}{{rewardVariable}}{{toggleRewardSelection}}"
|
||||
AdvSceneSwitcher.action.twitch.title.title="输入标题"
|
||||
AdvSceneSwitcher.action.twitch.marker.description="标记描述"
|
||||
AdvSceneSwitcher.action.twitch.clip.hasDelay="在捕捉视频片段前稍加延迟"
|
||||
|
|
@ -2116,8 +2122,6 @@ AdvSceneSwitcher.status.inactive="已停止"
|
|||
AdvSceneSwitcher.running="插件正在运行"
|
||||
AdvSceneSwitcher.stopped="插件已停止"
|
||||
|
||||
AdvSceneSwitcher.firstBootMessage="<html><head/><body><p>这似乎是您第一次启动高级场景切换器.<br>请看一下 <a href=\"https://github.com/WarmUpTill/SceneSwitcher/wiki\"><span style=\" text-decoration: underline; color:#268bd2;\">Wiki</span></a> 查看指南和示例列表.<br>如果有问题,在在OBS论坛插件帖子内提问 <a href=\"https://obsproject.com/forum/threads/advanced-scene-switcher.48264\"><span style=\" text-decoration: underline; color:#268bd2;\">thread</span></a></p></body></html>"
|
||||
|
||||
AdvSceneSwitcher.deprecatedTabWarning="此选项卡的开发已停止!请考虑转换为使用宏来代替。\n可以在“常规”选项卡上禁用此提示."
|
||||
|
||||
AdvSceneSwitcher.unit.milliseconds="毫秒"
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>962</width>
|
||||
<height>1160</height>
|
||||
<height>1190</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_19">
|
||||
|
|
@ -565,6 +565,13 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="openSetupWizard">
|
||||
<property name="text">
|
||||
<string>FirstRunWizard.openButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
@ -590,7 +597,7 @@
|
|||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<widget class="QGroupBox" name="macroListBox">
|
||||
<property name="title">
|
||||
<string>AdvSceneSwitcher.macroTab.macros</string>
|
||||
</property>
|
||||
|
|
@ -786,25 +793,19 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="runMacroOnChange">
|
||||
<property name="toolTip">
|
||||
<string>AdvSceneSwitcher.macroTab.onChange</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>AdvSceneSwitcher.macroTab.actionTriggerMode.label</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_18">
|
||||
<widget class="QComboBox" name="actionTriggerMode">
|
||||
<property name="toolTip">
|
||||
<string>AdvSceneSwitcher.macroTab.onChange</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.macroTab.onChange</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
<string>AdvSceneSwitcher.macroTab.actionTriggerMode.tooltip</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -4118,7 +4119,7 @@
|
|||
<tabstop>macroName</tabstop>
|
||||
<tabstop>runMacro</tabstop>
|
||||
<tabstop>runMacroInParallel</tabstop>
|
||||
<tabstop>runMacroOnChange</tabstop>
|
||||
<tabstop>actionTriggerMode</tabstop>
|
||||
<tabstop>macroSettings</tabstop>
|
||||
<tabstop>macroEdit</tabstop>
|
||||
<tabstop>sceneGroups</tabstop>
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public slots:
|
|||
void on_priorityUp_clicked();
|
||||
void on_priorityDown_clicked();
|
||||
void on_threadPriority_currentTextChanged(const QString &text);
|
||||
void on_openSetupWizard_clicked();
|
||||
|
||||
/* --- End of legacy tab section --- */
|
||||
|
||||
|
|
@ -107,7 +108,7 @@ public slots:
|
|||
void on_macroDown_clicked() const;
|
||||
void on_macroName_editingFinished();
|
||||
void on_runMacroInParallel_stateChanged(int value) const;
|
||||
void on_runMacroOnChange_stateChanged(int value) const;
|
||||
void on_actionTriggerMode_currentIndexChanged(int index) const;
|
||||
void MacroSelectionChanged();
|
||||
void ShowMacroContextMenu(const QPoint &);
|
||||
void CopyMacro();
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
#include "advanced-scene-switcher.hpp"
|
||||
#include "file-selection.hpp"
|
||||
#include "filter-combo-box.hpp"
|
||||
#include "first-run-wizard.hpp"
|
||||
#include "layout-helpers.hpp"
|
||||
#include "macro.hpp"
|
||||
#include "macro-search.hpp"
|
||||
#include "macro-settings.hpp"
|
||||
#include "path-helpers.hpp"
|
||||
#include "selection-helpers.hpp"
|
||||
#include "source-helpers.hpp"
|
||||
#include "splitter-helpers.hpp"
|
||||
#include "status-control.hpp"
|
||||
#include "switcher-data.hpp"
|
||||
#include "tab-helpers.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "variable.hpp"
|
||||
#include "version.h"
|
||||
|
||||
|
|
@ -361,14 +360,46 @@ void AdvSceneSwitcher::RestoreWindowGeo()
|
|||
}
|
||||
}
|
||||
|
||||
static void renameMacroIfNecessary(const std::shared_ptr<Macro> ¯o)
|
||||
{
|
||||
if (!GetMacroByName(macro->Name().c_str())) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto name = macro->Name();
|
||||
int i = 2;
|
||||
while (GetMacroByName((name + " " + std::to_string(i)).c_str())) {
|
||||
i++;
|
||||
}
|
||||
|
||||
macro->SetName(name + " " + std::to_string(i));
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::CheckFirstTimeSetup()
|
||||
{
|
||||
if (switcher->firstBoot && !switcher->disableHints) {
|
||||
switcher->firstBoot = false;
|
||||
DisplayMessage(
|
||||
obs_module_text("AdvSceneSwitcher.firstBootMessage"));
|
||||
switcher->Start();
|
||||
if (!IsFirstRun() || !GetTopLevelMacros().empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto macro = FirstRunWizard::ShowWizard(this);
|
||||
if (macro) {
|
||||
renameMacroIfNecessary(macro);
|
||||
QTimer::singleShot(0, this,
|
||||
[this, macro]() { ui->macros->Add(macro); });
|
||||
}
|
||||
switcher->Start();
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_openSetupWizard_clicked()
|
||||
{
|
||||
auto macro = FirstRunWizard::ShowWizard(this);
|
||||
if (!macro) {
|
||||
return;
|
||||
}
|
||||
|
||||
renameMacroIfNecessary(macro);
|
||||
ui->macros->Add(macro);
|
||||
ui->tabWidget->setCurrentWidget(ui->macroTab);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_tabWidget_currentChanged(int)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,17 @@ MacroCondition::MacroCondition(Macro *m, bool supportsVariableValue)
|
|||
{
|
||||
}
|
||||
|
||||
bool MacroCondition::EvaluateCondition()
|
||||
{
|
||||
bool newValue = CheckCondition();
|
||||
_changed = _previousValue.has_value() && (*_previousValue != newValue);
|
||||
const bool negate = _logic.IsNegationType(GetLogicType());
|
||||
_risingEdge = _changed &&
|
||||
((!negate && newValue) || (negate && !newValue));
|
||||
_previousValue = newValue;
|
||||
return newValue;
|
||||
}
|
||||
|
||||
bool MacroCondition::Save(obs_data_t *obj) const
|
||||
{
|
||||
MacroSegment::Save(obj);
|
||||
|
|
|
|||
|
|
@ -4,13 +4,19 @@
|
|||
#include "duration-modifier.hpp"
|
||||
#include "macro-ref.hpp"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace advss {
|
||||
|
||||
class EXPORT MacroCondition : public MacroSegment {
|
||||
public:
|
||||
MacroCondition(Macro *m, bool supportsVariableValue = false);
|
||||
virtual ~MacroCondition() = default;
|
||||
virtual bool CheckCondition() = 0;
|
||||
|
||||
bool EvaluateCondition();
|
||||
bool HasChanged() const { return _changed; }
|
||||
bool IsRisingEdge() const { return _risingEdge; }
|
||||
|
||||
virtual bool Save(obs_data_t *obj) const = 0;
|
||||
virtual bool Load(obs_data_t *obj) = 0;
|
||||
|
||||
|
|
@ -28,9 +34,15 @@ public:
|
|||
|
||||
static std::string_view GetDefaultID();
|
||||
|
||||
protected:
|
||||
virtual bool CheckCondition() = 0;
|
||||
|
||||
private:
|
||||
Logic _logic = Logic(Logic::Type::ROOT_NONE);
|
||||
DurationModifier _durationModifier;
|
||||
std::optional<bool> _previousValue;
|
||||
bool _changed = false;
|
||||
bool _risingEdge = false;
|
||||
};
|
||||
|
||||
class EXPORT MacroRefCondition : virtual public MacroCondition {
|
||||
|
|
|
|||
|
|
@ -1086,6 +1086,11 @@ void MacroEdit::AddMacroAction(Macro *macro, int idx, const std::string &id,
|
|||
HighlightAction(idx);
|
||||
ui->actionsList->SetHelpMsgVisible(false);
|
||||
emit(MacroSegmentOrderChanged());
|
||||
|
||||
QTimer::singleShot(0, this, [this]() {
|
||||
ui->actionsList->ensureWidgetVisible(
|
||||
ui->actionsList->WidgetAt(currentActionIdx));
|
||||
});
|
||||
}
|
||||
|
||||
void MacroEdit::AddMacroAction(int idx)
|
||||
|
|
@ -1389,6 +1394,11 @@ void MacroEdit::AddMacroElseAction(Macro *macro, int idx, const std::string &id,
|
|||
HighlightElseAction(idx);
|
||||
ui->elseActionsList->SetHelpMsgVisible(false);
|
||||
emit(MacroSegmentOrderChanged());
|
||||
|
||||
QTimer::singleShot(0, this, [this]() {
|
||||
ui->elseActionsList->ensureWidgetVisible(
|
||||
ui->elseActionsList->WidgetAt(currentElseActionIdx));
|
||||
});
|
||||
}
|
||||
|
||||
void MacroEdit::AddMacroElseAction(int idx)
|
||||
|
|
@ -1591,6 +1601,11 @@ void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
|
|||
HighlightCondition(idx);
|
||||
ui->conditionsList->SetHelpMsgVisible(false);
|
||||
emit(MacroSegmentOrderChanged());
|
||||
|
||||
QTimer::singleShot(0, this, [this]() {
|
||||
ui->conditionsList->ensureWidgetVisible(
|
||||
ui->conditionsList->WidgetAt(currentConditionIdx));
|
||||
});
|
||||
}
|
||||
|
||||
void MacroEdit::on_conditionAdd_clicked()
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@ namespace advss {
|
|||
class Macro;
|
||||
class MacroSegment;
|
||||
|
||||
/*******************************************************************************
|
||||
* Advanced Scene Switcher window
|
||||
*******************************************************************************/
|
||||
class MacroEdit : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ void MacroSelection::HideSelectedMacro()
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef UNIT_TEST
|
||||
const auto m = ssWindow->ui->macros->GetCurrentMacro();
|
||||
if (!m) {
|
||||
return;
|
||||
|
|
@ -61,6 +62,7 @@ void MacroSelection::HideSelectedMacro()
|
|||
}
|
||||
|
||||
qobject_cast<QListView *>(view())->setRowHidden(idx, true);
|
||||
#endif // !UNIT_TEST
|
||||
}
|
||||
|
||||
void MacroSelection::HideGroups()
|
||||
|
|
|
|||
|
|
@ -474,14 +474,17 @@ void AdvSceneSwitcher::on_runMacroInParallel_stateChanged(int value) const
|
|||
macro->SetRunInParallel(value);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_runMacroOnChange_stateChanged(int value) const
|
||||
void AdvSceneSwitcher::on_actionTriggerMode_currentIndexChanged(int index) const
|
||||
{
|
||||
auto macro = GetSelectedMacro();
|
||||
if (!macro) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto lock = LockContext();
|
||||
macro->SetMatchOnChange(value);
|
||||
const auto mode = static_cast<Macro::ActionTriggerMode>(
|
||||
ui->actionTriggerMode->itemData(index).toInt());
|
||||
macro->SetActionTriggerMode(mode);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::SetMacroEditAreaDisabled(bool disable) const
|
||||
|
|
@ -489,7 +492,7 @@ void AdvSceneSwitcher::SetMacroEditAreaDisabled(bool disable) const
|
|||
ui->macroName->setDisabled(disable);
|
||||
ui->runMacro->setDisabled(disable);
|
||||
ui->runMacroInParallel->setDisabled(disable);
|
||||
ui->runMacroOnChange->setDisabled(disable);
|
||||
ui->actionTriggerMode->setDisabled(disable);
|
||||
ui->macroEdit->SetControlsDisabled(disable);
|
||||
}
|
||||
|
||||
|
|
@ -519,10 +522,12 @@ void AdvSceneSwitcher::MacroSelectionChanged()
|
|||
{
|
||||
const QSignalBlocker b1(ui->macroName);
|
||||
const QSignalBlocker b2(ui->runMacroInParallel);
|
||||
const QSignalBlocker b3(ui->runMacroOnChange);
|
||||
const QSignalBlocker b3(ui->actionTriggerMode);
|
||||
ui->macroName->setText(macro->Name().c_str());
|
||||
ui->runMacroInParallel->setChecked(macro->RunInParallel());
|
||||
ui->runMacroOnChange->setChecked(macro->MatchOnChange());
|
||||
ui->actionTriggerMode->setCurrentIndex(
|
||||
ui->actionTriggerMode->findData(static_cast<int>(
|
||||
macro->GetActionTriggerMode())));
|
||||
}
|
||||
|
||||
macro->ResetUIHelpers();
|
||||
|
|
@ -552,9 +557,9 @@ void AdvSceneSwitcher::HighlightOnChange() const
|
|||
return;
|
||||
}
|
||||
|
||||
if (macro->OnChangePreventedActionsSince(
|
||||
if (macro->ActionTriggerModePreventedActionsSince(
|
||||
lastOnChangeHighlightCheckTime)) {
|
||||
HighlightWidget(ui->runMacroOnChange, Qt::yellow,
|
||||
HighlightWidget(ui->actionTriggerMode, Qt::yellow,
|
||||
Qt::transparent, true);
|
||||
}
|
||||
|
||||
|
|
@ -665,23 +670,49 @@ void AdvSceneSwitcher::SetupMacroTab()
|
|||
SLOT(HighlightOnChange()));
|
||||
onChangeHighlightTimer.start();
|
||||
|
||||
// Reserve more space for macro edit area than for the macro list
|
||||
ui->macroListMacroEditSplitter->setStretchFactor(0, 1);
|
||||
ui->macroListMacroEditSplitter->setStretchFactor(1, 4);
|
||||
|
||||
if (switcher->saveWindowGeo) {
|
||||
if (shouldRestoreSplitter(
|
||||
switcher->macroListMacroEditSplitterPosition)) {
|
||||
ui->macroListMacroEditSplitter->setSizes(
|
||||
switcher->macroListMacroEditSplitterPosition);
|
||||
}
|
||||
}
|
||||
|
||||
SetupMacroSearchWidgets(ui->macroSearchLayout, ui->macroSearchText,
|
||||
ui->macroSearchClear, ui->macroSearchType,
|
||||
ui->macroSearchRegex,
|
||||
ui->macroSearchShowSettings,
|
||||
[this]() { ui->macros->RefreshFilter(); });
|
||||
|
||||
static const std::vector<
|
||||
std::pair<Macro::ActionTriggerMode, const char *>>
|
||||
actionTriggerModes = {
|
||||
{Macro::ActionTriggerMode::ALWAYS,
|
||||
"AdvSceneSwitcher.macroTab.actionTriggerMode.always"},
|
||||
{Macro::ActionTriggerMode::MACRO_RESULT_CHANGED,
|
||||
"AdvSceneSwitcher.macroTab.actionTriggerMode.onOverallChange"},
|
||||
{Macro::ActionTriggerMode::ANY_CONDITION_CHANGED,
|
||||
"AdvSceneSwitcher.macroTab.actionTriggerMode.onAnyConditionChange"},
|
||||
{Macro::ActionTriggerMode::ANY_CONDITION_TRIGGERED,
|
||||
"AdvSceneSwitcher.macroTab.actionTriggerMode.onAnyConditionTriggered"},
|
||||
};
|
||||
|
||||
for (const auto &[mode, name] : actionTriggerModes) {
|
||||
ui->actionTriggerMode->addItem(obs_module_text(name),
|
||||
static_cast<int>(mode));
|
||||
}
|
||||
|
||||
ui->macroListBox->setSizePolicy(QSizePolicy::Ignored,
|
||||
QSizePolicy::Preferred);
|
||||
ui->macroListBox->setMinimumWidth(0);
|
||||
ui->macroEditGroup->setSizePolicy(QSizePolicy::Ignored,
|
||||
QSizePolicy::Preferred);
|
||||
ui->macroEditGroup->setMinimumWidth(0);
|
||||
|
||||
if (shouldRestoreSplitter(
|
||||
switcher->macroListMacroEditSplitterPosition)) {
|
||||
ui->macroListMacroEditSplitter->setSizes(
|
||||
switcher->macroListMacroEditSplitterPosition);
|
||||
} else {
|
||||
QTimer::singleShot(0, this, [this]() {
|
||||
const auto totalWidth =
|
||||
ui->macroListMacroEditSplitter->width();
|
||||
ui->macroListMacroEditSplitter->setSizes(
|
||||
{totalWidth / 5, totalWidth * 4 / 5});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::ShowMacroContextMenu(const QPoint &pos)
|
||||
|
|
|
|||
|
|
@ -224,7 +224,8 @@ void MacroTreeItem::HighlightIfExecuted()
|
|||
|
||||
if (!wasHighlighted &&
|
||||
_lastHighlightCheckTime.time_since_epoch().count() != 0 &&
|
||||
_macro->OnChangePreventedActionsSince(_lastHighlightCheckTime)) {
|
||||
_macro->ActionTriggerModePreventedActionsSince(
|
||||
_lastHighlightCheckTime)) {
|
||||
HighlightWidget(this, Qt::yellow, QColor(0, 0, 0, 0), true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ static bool checkCondition(const std::shared_ptr<MacroCondition> &condition)
|
|||
const auto startTime = std::chrono::high_resolution_clock::now();
|
||||
bool conditionMatched = false;
|
||||
condition->WithLock([&condition, &conditionMatched]() {
|
||||
conditionMatched = condition->CheckCondition();
|
||||
conditionMatched = condition->EvaluateCondition();
|
||||
});
|
||||
const auto endTime = std::chrono::high_resolution_clock::now();
|
||||
const auto timeSpent = endTime - startTime;
|
||||
|
|
@ -241,12 +241,36 @@ bool Macro::CheckConditions(bool ignorePause)
|
|||
|
||||
vblog(LOG_INFO, "Macro %s returned %d", _name.c_str(), _matched);
|
||||
|
||||
_conditionSateChanged = _lastMatched != _matched;
|
||||
_actionModeMatch = false;
|
||||
switch (_actionTriggerMode) {
|
||||
case Macro::ActionTriggerMode::ALWAYS:
|
||||
_actionModeMatch = true;
|
||||
break;
|
||||
case Macro::ActionTriggerMode::MACRO_RESULT_CHANGED:
|
||||
_actionModeMatch = _lastMatched != _matched;
|
||||
break;
|
||||
case Macro::ActionTriggerMode::ANY_CONDITION_CHANGED:
|
||||
for (const auto &condition : _conditions) {
|
||||
if (condition->HasChanged()) {
|
||||
_actionModeMatch = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Macro::ActionTriggerMode::ANY_CONDITION_TRIGGERED:
|
||||
for (const auto &condition : _conditions) {
|
||||
if (condition->IsRisingEdge()) {
|
||||
_actionModeMatch = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const bool hasActionsToExecute = _matched ? (_actions.size() > 0)
|
||||
: (_elseActions.size() > 0);
|
||||
if (!_conditionSateChanged && _performActionsOnChange &&
|
||||
hasActionsToExecute) {
|
||||
_lastOnChangeActionsPreventedTime =
|
||||
if (!_actionModeMatch && hasActionsToExecute) {
|
||||
_lastActionRunModePreventTime =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
|
|
@ -306,9 +330,9 @@ bool Macro::WasExecutedSince(const TimePoint &time) const
|
|||
return _lastExecutionTime > time;
|
||||
}
|
||||
|
||||
bool Macro::OnChangePreventedActionsSince(const TimePoint &time) const
|
||||
bool Macro::ActionTriggerModePreventedActionsSince(const TimePoint &time) const
|
||||
{
|
||||
return _lastOnChangeActionsPreventedTime > time;
|
||||
return _lastActionRunModePreventTime > time;
|
||||
}
|
||||
|
||||
Macro::TimePoint Macro::GetLastExecutionTime() const
|
||||
|
|
@ -342,10 +366,9 @@ bool Macro::ShouldRunActions() const
|
|||
|
||||
const bool hasActionsToExecute =
|
||||
!_paused && (_matched || _elseActions.size() > 0) &&
|
||||
(!_performActionsOnChange || _conditionSateChanged);
|
||||
_actionModeMatch;
|
||||
|
||||
if (VerboseLoggingEnabled() && _performActionsOnChange &&
|
||||
!_conditionSateChanged) {
|
||||
if (VerboseLoggingEnabled() && !_actionModeMatch) {
|
||||
if (_matched && _actions.size() > 0) {
|
||||
blog(LOG_INFO, "skip actions for Macro %s (on change)",
|
||||
_name.c_str());
|
||||
|
|
@ -376,10 +399,24 @@ void Macro::ResetTimers()
|
|||
_lastExecutionTime = {};
|
||||
}
|
||||
|
||||
void Macro::SetActionTriggerMode(ActionTriggerMode mode)
|
||||
{
|
||||
_actionTriggerMode = mode;
|
||||
}
|
||||
|
||||
Macro::ActionTriggerMode Macro::GetActionTriggerMode() const
|
||||
{
|
||||
return _actionTriggerMode;
|
||||
}
|
||||
|
||||
bool Macro::RunActionsHelper(
|
||||
const std::deque<std::shared_ptr<MacroAction>> &actionsToRun,
|
||||
bool ignorePause)
|
||||
{
|
||||
if (_paused && !ignorePause) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create copy of action list as elements might be removed, inserted, or
|
||||
// reordered while actions are currently being executed.
|
||||
auto actions = actionsToRun;
|
||||
|
|
@ -429,11 +466,6 @@ bool Macro::WasPausedSince(const TimePoint &time) const
|
|||
return _lastUnpauseTime > time;
|
||||
}
|
||||
|
||||
void Macro::SetMatchOnChange(bool onChange)
|
||||
{
|
||||
_performActionsOnChange = onChange;
|
||||
}
|
||||
|
||||
void Macro::SetStopActionsIfNotDone(bool stopActionsIfNotDone)
|
||||
{
|
||||
_stopActionsIfNotDone = stopActionsIfNotDone;
|
||||
|
|
@ -754,7 +786,8 @@ bool Macro::Save(obs_data_t *obj, bool saveForCopy) const
|
|||
obs_data_set_bool(obj, "pause", _paused);
|
||||
obs_data_set_bool(obj, "parallel", _runInParallel);
|
||||
obs_data_set_bool(obj, "checkConditionsInParallel", _checkInParallel);
|
||||
obs_data_set_bool(obj, "onChange", _performActionsOnChange);
|
||||
obs_data_set_int(obj, "actionTriggerMode",
|
||||
static_cast<int>(_actionTriggerMode));
|
||||
obs_data_set_bool(obj, "skipExecOnStart", _skipExecOnStart);
|
||||
obs_data_set_bool(obj, "stopActionsIfNotDone", _stopActionsIfNotDone);
|
||||
obs_data_set_bool(obj, "useShortCircuitEvaluation",
|
||||
|
|
@ -840,7 +873,15 @@ bool Macro::Load(obs_data_t *obj)
|
|||
}
|
||||
_runInParallel = obs_data_get_bool(obj, "parallel");
|
||||
_checkInParallel = obs_data_get_bool(obj, "checkConditionsInParallel");
|
||||
_performActionsOnChange = obs_data_get_bool(obj, "onChange");
|
||||
if (obs_data_has_user_value(obj, "onChange")) {
|
||||
const bool onChange = obs_data_get_bool(obj, "onChange");
|
||||
_actionTriggerMode =
|
||||
onChange ? ActionTriggerMode::MACRO_RESULT_CHANGED
|
||||
: ActionTriggerMode::ALWAYS;
|
||||
} else {
|
||||
_actionTriggerMode = static_cast<ActionTriggerMode>(
|
||||
obs_data_get_int(obj, "actionTriggerMode"));
|
||||
}
|
||||
_skipExecOnStart = obs_data_get_bool(obj, "skipExecOnStart");
|
||||
_stopActionsIfNotDone = obs_data_get_bool(obj, "stopActionsIfNotDone");
|
||||
_useShortCircuitEvaluation =
|
||||
|
|
@ -1100,9 +1141,11 @@ void Macro::ClearHotkeys() const
|
|||
void setHotkeyDescriptionHelper(const char *formatModuleText,
|
||||
const std::string name, const obs_hotkey_id id)
|
||||
{
|
||||
#ifndef UNIT_TEST
|
||||
QString format{obs_module_text(formatModuleText)};
|
||||
QString hotkeyDesc = format.arg(QString::fromStdString(name));
|
||||
obs_hotkey_set_description(id, hotkeyDesc.toStdString().c_str());
|
||||
#endif // !UNIT_TEST
|
||||
}
|
||||
|
||||
void Macro::SetHotkeysDesc() const
|
||||
|
|
|
|||
|
|
@ -26,6 +26,16 @@ class Macro {
|
|||
|
||||
public:
|
||||
enum class PauseStateSaveBehavior { PERSIST, PAUSE, UNPAUSE };
|
||||
enum class ActionTriggerMode {
|
||||
// Trigger always
|
||||
ALWAYS,
|
||||
// Trigger when macro match result flips
|
||||
MACRO_RESULT_CHANGED,
|
||||
// Trigger when any individual condition changes
|
||||
ANY_CONDITION_CHANGED,
|
||||
// Trigger when any individual condition evaluates to true
|
||||
ANY_CONDITION_TRIGGERED,
|
||||
};
|
||||
|
||||
Macro(const std::string &name = "");
|
||||
Macro(const std::string &name, const GlobalMacroSettings &settings);
|
||||
|
|
@ -54,8 +64,8 @@ public:
|
|||
bool GetStop() const { return _stop; }
|
||||
void ResetTimers();
|
||||
|
||||
void SetMatchOnChange(bool onChange);
|
||||
bool MatchOnChange() const { return _performActionsOnChange; }
|
||||
void SetActionTriggerMode(ActionTriggerMode);
|
||||
ActionTriggerMode GetActionTriggerMode() const;
|
||||
|
||||
void SetSkipExecOnStart(bool skip) { _skipExecOnStart = skip; }
|
||||
bool SkipExecOnStart() const { return _skipExecOnStart; }
|
||||
|
|
@ -137,7 +147,7 @@ public:
|
|||
const QList<int> &GetElseActionSplitterPosition() const;
|
||||
bool HasValidSplitterPositions() const;
|
||||
bool WasExecutedSince(const TimePoint &) const;
|
||||
bool OnChangePreventedActionsSince(const TimePoint &) const;
|
||||
bool ActionTriggerModePreventedActionsSince(const TimePoint &) const;
|
||||
TimePoint GetLastExecutionTime() const;
|
||||
void ResetUIHelpers();
|
||||
|
||||
|
|
@ -169,7 +179,7 @@ private:
|
|||
TimePoint _lastCheckTime{};
|
||||
TimePoint _lastUnpauseTime{};
|
||||
TimePoint _lastExecutionTime{};
|
||||
TimePoint _lastOnChangeActionsPreventedTime{};
|
||||
TimePoint _lastActionRunModePreventTime{};
|
||||
std::vector<std::thread> _helperThreads;
|
||||
|
||||
std::deque<std::shared_ptr<MacroCondition>> _conditions;
|
||||
|
|
@ -184,14 +194,13 @@ private:
|
|||
bool _useShortCircuitEvaluation = false;
|
||||
bool _useCustomConditionCheckInterval = false;
|
||||
Duration _customConditionCheckInterval = 0.3;
|
||||
bool _conditionSateChanged = false;
|
||||
bool _actionModeMatch = false;
|
||||
|
||||
bool _runInParallel = false;
|
||||
bool _checkInParallel = false;
|
||||
bool _matched = false;
|
||||
std::future<void> _conditionCheckFuture;
|
||||
bool _lastMatched = false;
|
||||
bool _performActionsOnChange = true;
|
||||
bool _skipExecOnStart = false;
|
||||
bool _stopActionsIfNotDone = false;
|
||||
bool _paused = false;
|
||||
|
|
@ -201,6 +210,9 @@ private:
|
|||
obs_hotkey_id _unpauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
obs_hotkey_id _togglePauseHotkey = OBS_INVALID_HOTKEY_ID;
|
||||
|
||||
ActionTriggerMode _actionTriggerMode =
|
||||
ActionTriggerMode::MACRO_RESULT_CHANGED;
|
||||
|
||||
PauseStateSaveBehavior _pauseSaveBehavior =
|
||||
PauseStateSaveBehavior::PERSIST;
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ bool SwitcherData::VersionChanged(obs_data_t *obj, std::string currentVersion)
|
|||
if (!obs_data_has_user_value(obj, "version")) {
|
||||
return false;
|
||||
}
|
||||
switcher->firstBoot = false;
|
||||
|
||||
std::string previousVersion = obs_data_get_string(obj, "version");
|
||||
return previousVersion != currentVersion;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ public:
|
|||
bool stop = false;
|
||||
std::condition_variable cv;
|
||||
|
||||
bool firstBoot = true;
|
||||
bool transitionActive = false;
|
||||
bool sceneCollectionStop = false;
|
||||
bool obsIsShuttingDown = false;
|
||||
|
|
|
|||
|
|
@ -54,31 +54,18 @@ void AskForBackup(obs_data_t *settings)
|
|||
// or crashing.
|
||||
// Therefore, we ask the user whether they want to back up the settings
|
||||
// asynchronously.
|
||||
//
|
||||
// On macOS, an additional QTimer::singleShot wrapper is required for
|
||||
// this to work correctly.
|
||||
|
||||
auto json = obs_data_get_json(settings);
|
||||
static QString jsonQString = json ? json : "";
|
||||
|
||||
static const auto askForBackupWrapper = [](void *) {
|
||||
#ifdef __APPLE__
|
||||
QTimer::singleShot(0,
|
||||
static_cast<QMainWindow *>(
|
||||
obs_frontend_get_main_window()),
|
||||
[]() {
|
||||
#endif
|
||||
showBackupDialogs(jsonQString);
|
||||
#ifdef __APPLE__
|
||||
});
|
||||
#endif
|
||||
showBackupDialogs(jsonQString);
|
||||
};
|
||||
|
||||
std::thread t([]() {
|
||||
AddFinishedLoadingStep([]() {
|
||||
obs_queue_task(OBS_TASK_UI, askForBackupWrapper, nullptr,
|
||||
false);
|
||||
});
|
||||
t.detach();
|
||||
}
|
||||
|
||||
void BackupSettingsOfCurrentVersion()
|
||||
|
|
|
|||
|
|
@ -126,26 +126,13 @@ bool ShouldSkipPluginStartOnUncleanShutdown()
|
|||
// or crashing.
|
||||
// Therefore, we ask the user whether they want to start the plugin
|
||||
// asynchronously.
|
||||
//
|
||||
// On macOS, an additional QTimer::singleShot wrapper is required for
|
||||
// this to work correctly.
|
||||
static const auto showDialogWrapper = [](void *) {
|
||||
#ifdef __APPLE__
|
||||
QTimer::singleShot(0,
|
||||
static_cast<QMainWindow *>(
|
||||
obs_frontend_get_main_window()),
|
||||
[]() {
|
||||
#endif
|
||||
askForStartupSkip();
|
||||
#ifdef __APPLE__
|
||||
});
|
||||
#endif
|
||||
askForStartupSkip();
|
||||
};
|
||||
|
||||
std::thread t([]() {
|
||||
AddFinishedLoadingStep([]() {
|
||||
obs_queue_task(OBS_TASK_UI, showDialogWrapper, nullptr, false);
|
||||
});
|
||||
t.detach();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
|
||||
#define EXPORT
|
||||
#define ADVSS_EXPORT
|
||||
|
||||
#else
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#else
|
||||
|
|
@ -19,5 +12,3 @@
|
|||
#else
|
||||
#define ADVSS_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // UNIT_TEST
|
||||
|
|
|
|||
465
lib/utils/first-run-wizard.cpp
Normal file
465
lib/utils/first-run-wizard.cpp
Normal file
|
|
@ -0,0 +1,465 @@
|
|||
#include "first-run-wizard.hpp"
|
||||
|
||||
#include "log-helper.hpp"
|
||||
#include "macro.hpp"
|
||||
#include "macro-action-factory.hpp"
|
||||
#include "macro-condition-factory.hpp"
|
||||
#include "macro-settings.hpp"
|
||||
#include "platform-funcs.hpp"
|
||||
#include "selection-helpers.hpp"
|
||||
|
||||
#include <obs-frontend-api.h>
|
||||
#include <obs-data.h>
|
||||
#include <util/config-file.h>
|
||||
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace advss {
|
||||
|
||||
static constexpr char kConditionIdWindow[] = "window";
|
||||
static constexpr char kActionIdSceneSwitch[] = "scene_switch";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// OBS global config helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
static constexpr char kConfigSection[] = "AdvancedSceneSwitcher";
|
||||
static constexpr char kFirstRunKey[] = "firstRun";
|
||||
|
||||
bool IsFirstRun()
|
||||
{
|
||||
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(31, 0, 0)
|
||||
config_t *cfg = obs_frontend_get_user_config();
|
||||
#else
|
||||
config_t *cfg = obs_frontend_get_global_config();
|
||||
#endif
|
||||
if (!config_has_user_value(cfg, kConfigSection, kFirstRunKey)) {
|
||||
return true;
|
||||
}
|
||||
return config_get_bool(cfg, kConfigSection, kFirstRunKey);
|
||||
}
|
||||
|
||||
static void WriteFirstRun(bool value)
|
||||
{
|
||||
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(31, 0, 0)
|
||||
config_t *cfg = obs_frontend_get_user_config();
|
||||
#else
|
||||
config_t *cfg = obs_frontend_get_global_config();
|
||||
#endif
|
||||
config_set_bool(cfg, kConfigSection, kFirstRunKey, value);
|
||||
config_save_safe(cfg, "tmp", nullptr);
|
||||
}
|
||||
|
||||
static QString DetectFocusedWindow()
|
||||
{
|
||||
std::string title;
|
||||
GetCurrentWindowTitle(title);
|
||||
return QString::fromStdString(title);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// WelcomePage
|
||||
// ===========================================================================
|
||||
|
||||
WelcomePage::WelcomePage(QWidget *parent) : QWizardPage(parent)
|
||||
{
|
||||
setTitle(obs_module_text("FirstRunWizard.welcome.title"));
|
||||
setSubTitle(obs_module_text("FirstRunWizard.welcome.subtitle"));
|
||||
|
||||
auto body = new QLabel(obs_module_text("FirstRunWizard.welcome.body"),
|
||||
this);
|
||||
body->setWordWrap(true);
|
||||
body->setTextFormat(Qt::RichText);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->addWidget(body);
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// SceneSelectionPage
|
||||
// ===========================================================================
|
||||
|
||||
SceneSelectionPage::SceneSelectionPage(QWidget *parent) : QWizardPage(parent)
|
||||
{
|
||||
setTitle(obs_module_text("FirstRunWizard.scene.title"));
|
||||
setSubTitle(obs_module_text("FirstRunWizard.scene.subtitle"));
|
||||
|
||||
auto label =
|
||||
new QLabel(obs_module_text("FirstRunWizard.scene.label"), this);
|
||||
_sceneCombo = new QComboBox(this);
|
||||
_sceneCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
// registerField with * suffix means the field is mandatory for Next
|
||||
registerField("targetScene*", _sceneCombo, "currentText",
|
||||
SIGNAL(currentTextChanged(QString)));
|
||||
|
||||
connect(_sceneCombo, &QComboBox::currentTextChanged, this,
|
||||
&QWizardPage::completeChanged);
|
||||
|
||||
auto row = new QHBoxLayout;
|
||||
row->addWidget(label);
|
||||
row->addWidget(_sceneCombo, 1);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->addLayout(row);
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
void SceneSelectionPage::initializePage()
|
||||
{
|
||||
_sceneCombo->clear();
|
||||
for (const QString &name : GetSceneNames())
|
||||
_sceneCombo->addItem(name);
|
||||
}
|
||||
|
||||
bool SceneSelectionPage::isComplete() const
|
||||
{
|
||||
return _sceneCombo->count() > 0 &&
|
||||
!_sceneCombo->currentText().isEmpty();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// WindowConditionPage
|
||||
// ===========================================================================
|
||||
|
||||
WindowConditionPage::WindowConditionPage(QWidget *parent)
|
||||
: QWizardPage(parent),
|
||||
_detectTimer(new QTimer(this))
|
||||
{
|
||||
setTitle(obs_module_text("FirstRunWizard.window.title"));
|
||||
setSubTitle(obs_module_text("FirstRunWizard.window.subtitle"));
|
||||
|
||||
auto label = new QLabel(obs_module_text("FirstRunWizard.window.label"),
|
||||
this);
|
||||
_windowEdit = new QLineEdit(this);
|
||||
_windowEdit->setPlaceholderText(
|
||||
obs_module_text("FirstRunWizard.window.placeholder"));
|
||||
|
||||
_autoDetect = new QPushButton(
|
||||
obs_module_text("FirstRunWizard.window.autoDetect"), this);
|
||||
_autoDetect->setToolTip(
|
||||
obs_module_text("FirstRunWizard.window.autoDetectTooltip"));
|
||||
|
||||
registerField("windowTitle*", _windowEdit);
|
||||
|
||||
connect(_windowEdit, &QLineEdit::textChanged, this,
|
||||
&QWizardPage::completeChanged);
|
||||
connect(_autoDetect, &QPushButton::clicked, this,
|
||||
&WindowConditionPage::onAutoDetectClicked);
|
||||
connect(_detectTimer, &QTimer::timeout, this,
|
||||
&WindowConditionPage::onCountdownTick);
|
||||
|
||||
auto row = new QHBoxLayout;
|
||||
row->addWidget(label);
|
||||
row->addWidget(_windowEdit, 1);
|
||||
|
||||
auto hint =
|
||||
new QLabel(obs_module_text("FirstRunWizard.window.hint"), this);
|
||||
hint->setTextFormat(Qt::RichText);
|
||||
hint->setWordWrap(true);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->addLayout(row);
|
||||
layout->addWidget(_autoDetect, 0, Qt::AlignLeft);
|
||||
layout->addWidget(hint);
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
void WindowConditionPage::initializePage()
|
||||
{
|
||||
if (_windowEdit->text().isEmpty()) {
|
||||
QString detected = DetectFocusedWindow();
|
||||
if (!detected.isEmpty()) {
|
||||
_windowEdit->setText(detected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool WindowConditionPage::isComplete() const
|
||||
{
|
||||
return !_windowEdit->text().trimmed().isEmpty();
|
||||
}
|
||||
|
||||
void WindowConditionPage::onAutoDetectClicked()
|
||||
{
|
||||
_countdown = 3;
|
||||
_autoDetect->setEnabled(false);
|
||||
_autoDetect->setText(
|
||||
QString(obs_module_text(
|
||||
"FirstRunWizard.window.autoDetectCountdown"))
|
||||
.arg(_countdown));
|
||||
_detectTimer->start(1000);
|
||||
}
|
||||
|
||||
void WindowConditionPage::onCountdownTick()
|
||||
{
|
||||
--_countdown;
|
||||
if (_countdown > 0) {
|
||||
_autoDetect->setText(
|
||||
QString(obs_module_text(
|
||||
"FirstRunWizard.window.autoDetectCountdown"))
|
||||
.arg(_countdown));
|
||||
return;
|
||||
}
|
||||
|
||||
_detectTimer->stop();
|
||||
QString title = DetectFocusedWindow();
|
||||
if (!title.isEmpty()) {
|
||||
_windowEdit->setText(title);
|
||||
}
|
||||
|
||||
_autoDetect->setEnabled(true);
|
||||
_autoDetect->setText(
|
||||
obs_module_text("FirstRunWizard.window.autoDetect"));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ReviewPage
|
||||
// ===========================================================================
|
||||
|
||||
ReviewPage::ReviewPage(QWidget *parent, std::shared_ptr<Macro> ¯o)
|
||||
: QWizardPage(parent),
|
||||
_macro(macro)
|
||||
{
|
||||
setTitle(obs_module_text("FirstRunWizard.review.title"));
|
||||
setSubTitle(obs_module_text("FirstRunWizard.review.subtitle"));
|
||||
|
||||
_summary = new QLabel(this);
|
||||
_summary->setWordWrap(true);
|
||||
_summary->setTextFormat(Qt::RichText);
|
||||
_summary->setFrameShape(QFrame::StyledPanel);
|
||||
_summary->setContentsMargins(12, 12, 12, 12);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->addWidget(_summary);
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
void ReviewPage::initializePage()
|
||||
{
|
||||
const QString scene = field("targetScene").toString();
|
||||
const QString window = field("windowTitle").toString();
|
||||
|
||||
_summary->setText(
|
||||
QString(obs_module_text("FirstRunWizard.review.summary"))
|
||||
.arg(scene.toHtmlEscaped(), window.toHtmlEscaped()));
|
||||
}
|
||||
|
||||
static QString escapeForRegex(const QString &input)
|
||||
{
|
||||
return QRegularExpression::escape(input);
|
||||
}
|
||||
|
||||
bool ReviewPage::validatePage()
|
||||
{
|
||||
const QString scene = field("targetScene").toString();
|
||||
const QString window = escapeForRegex(field("windowTitle").toString());
|
||||
const std::string name = ("Window -> " + scene).toStdString();
|
||||
|
||||
// Build condition data blob
|
||||
// ---------------------------------------------------------------
|
||||
// Condition blob — mirrors MacroConditionWindow::Save() output:
|
||||
//
|
||||
// {
|
||||
// "segmentSettings": { "enabled": true, "version": 1 },
|
||||
// "id": "window",
|
||||
// "checkTitle": true,
|
||||
// "window": "<user input>",
|
||||
// "windowRegexConfig": {
|
||||
// "enable": true, // use regex-style partial matching
|
||||
// "partial": true, // match anywhere in the title
|
||||
// "options": 3 // case-insensitive (QRegularExpression flags)
|
||||
// },
|
||||
// "focus": true, // only trigger when window is focused
|
||||
// "version": 1
|
||||
// }
|
||||
// ---------------------------------------------------------------
|
||||
OBSDataAutoRelease condSegment = obs_data_create();
|
||||
obs_data_set_bool(condSegment, "enabled", true);
|
||||
obs_data_set_int(condSegment, "version", 1);
|
||||
|
||||
OBSDataAutoRelease condRegex = obs_data_create();
|
||||
obs_data_set_bool(condRegex, "enable", true);
|
||||
obs_data_set_bool(condRegex, "partial", true);
|
||||
obs_data_set_int(condRegex, "options", 3); // CaseInsensitiveOption
|
||||
|
||||
OBSDataAutoRelease condData = obs_data_create();
|
||||
obs_data_set_obj(condData, "segmentSettings", condSegment);
|
||||
obs_data_set_string(condData, "id", "window");
|
||||
obs_data_set_bool(condData, "checkTitle", true);
|
||||
obs_data_set_string(condData, "window", window.toUtf8().constData());
|
||||
obs_data_set_obj(condData, "windowRegexConfig", condRegex);
|
||||
obs_data_set_bool(condData, "focus", true);
|
||||
obs_data_set_int(condData, "version", 1);
|
||||
|
||||
// Build action data blob
|
||||
// ---------------------------------------------------------------
|
||||
// Action blob — mirrors MacroActionSwitchScene::Save() output:
|
||||
//
|
||||
// {
|
||||
// "segmentSettings": { "enabled": true, "version": 1 },
|
||||
// "id": "scene_switch",
|
||||
// "action": 0, // 0 = switch scene
|
||||
// "sceneSelection": {
|
||||
// "type": 0, // 0 = scene by name
|
||||
// "name": "<scene>",
|
||||
// "canvasSelection": "Main"
|
||||
// },
|
||||
// "transitionType": 1, // 1 = use scene's default transition
|
||||
// "blockUntilTransitionDone": false,
|
||||
// "sceneType": 0
|
||||
// }
|
||||
// ---------------------------------------------------------------
|
||||
OBSDataAutoRelease actionSegment = obs_data_create();
|
||||
obs_data_set_bool(actionSegment, "enabled", true);
|
||||
obs_data_set_int(actionSegment, "version", 1);
|
||||
|
||||
OBSDataAutoRelease sceneSelection = obs_data_create();
|
||||
obs_data_set_int(sceneSelection, "type", 0);
|
||||
obs_data_set_string(sceneSelection, "name", scene.toUtf8().constData());
|
||||
obs_data_set_string(sceneSelection, "canvasSelection", "Main");
|
||||
|
||||
OBSDataAutoRelease actionData = obs_data_create();
|
||||
obs_data_set_obj(actionData, "segmentSettings", actionSegment);
|
||||
obs_data_set_string(actionData, "id", "scene_switch");
|
||||
obs_data_set_int(actionData, "action", 0);
|
||||
obs_data_set_obj(actionData, "sceneSelection", sceneSelection);
|
||||
obs_data_set_int(actionData, "transitionType", 1);
|
||||
obs_data_set_bool(actionData, "blockUntilTransitionDone", false);
|
||||
obs_data_set_int(actionData, "sceneType", 0);
|
||||
|
||||
if (!FirstRunWizard::CreateMacro(_macro, name, kConditionIdWindow,
|
||||
condData, kActionIdSceneSwitch,
|
||||
actionData)) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
obs_module_text("FirstRunWizard.review.errorTitle"),
|
||||
QString(obs_module_text(
|
||||
"FirstRunWizard.review.errorBody"))
|
||||
.arg(window, scene));
|
||||
_macro.reset();
|
||||
// Still advance so the user is not stuck.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// DonePage
|
||||
// ===========================================================================
|
||||
|
||||
DonePage::DonePage(QWidget *parent) : QWizardPage(parent)
|
||||
{
|
||||
setTitle(obs_module_text("FirstRunWizard.done.title"));
|
||||
setSubTitle(obs_module_text("FirstRunWizard.done.subtitle"));
|
||||
|
||||
auto body =
|
||||
new QLabel(obs_module_text("FirstRunWizard.done.body"), this);
|
||||
body->setWordWrap(true);
|
||||
body->setTextFormat(Qt::RichText);
|
||||
body->setOpenExternalLinks(true);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->addWidget(body);
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// FirstRunWizard
|
||||
// ===========================================================================
|
||||
|
||||
FirstRunWizard::FirstRunWizard(QWidget *parent) : QWizard(parent)
|
||||
{
|
||||
setWindowTitle(obs_module_text("FirstRunWizard.windowTitle"));
|
||||
setWizardStyle(QWizard::ModernStyle);
|
||||
setMinimumSize(540, 420);
|
||||
|
||||
setPage(PAGE_WELCOME, new WelcomePage(this));
|
||||
setPage(PAGE_SCENE, new SceneSelectionPage(this));
|
||||
setPage(PAGE_WINDOW, new WindowConditionPage(this));
|
||||
setPage(PAGE_REVIEW, new ReviewPage(this, _macro));
|
||||
setPage(PAGE_DONE, new DonePage(this));
|
||||
|
||||
setStartId(PAGE_WELCOME);
|
||||
setOption(QWizard::NoBackButtonOnLastPage, true);
|
||||
setOption(QWizard::NoCancelButtonOnLastPage, true);
|
||||
|
||||
// Mark done on both Accept (Finish) and Reject (Cancel / close)
|
||||
connect(this, &QWizard::accepted, this,
|
||||
&FirstRunWizard::markFirstRunComplete);
|
||||
connect(this, &QWizard::rejected, this,
|
||||
&FirstRunWizard::markFirstRunComplete);
|
||||
}
|
||||
|
||||
void FirstRunWizard::markFirstRunComplete()
|
||||
{
|
||||
WriteFirstRun(false);
|
||||
}
|
||||
|
||||
// static
|
||||
std::shared_ptr<Macro> FirstRunWizard::ShowWizard(QWidget *parent)
|
||||
{
|
||||
auto wizard = new FirstRunWizard(parent);
|
||||
wizard->exec();
|
||||
wizard->deleteLater();
|
||||
return wizard->_macro;
|
||||
}
|
||||
|
||||
// static
|
||||
bool FirstRunWizard::CreateMacro(std::shared_ptr<Macro> ¯o,
|
||||
const std::string ¯oName,
|
||||
const std::string &conditionId,
|
||||
obs_data_t *conditionData,
|
||||
const std::string &actionId,
|
||||
obs_data_t *actionData)
|
||||
{
|
||||
// 1. Create and register the Macro
|
||||
macro = std::make_shared<Macro>(macroName, GetGlobalMacroSettings());
|
||||
if (!macro) {
|
||||
blog(LOG_WARNING, "FirstRunWizard: Macro allocation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2. Instantiate condition via factory, then hydrate via Load()
|
||||
auto condition =
|
||||
MacroConditionFactory::Create(conditionId, macro.get());
|
||||
if (!condition) {
|
||||
blog(LOG_WARNING,
|
||||
"FirstRunWizard: condition factory returned null "
|
||||
"for id '%s' — is the base plugin loaded?",
|
||||
conditionId.c_str());
|
||||
return false;
|
||||
}
|
||||
if (!condition->Load(conditionData)) {
|
||||
blog(LOG_WARNING,
|
||||
"FirstRunWizard: condition Load() failed for id '%s'",
|
||||
conditionId.c_str());
|
||||
return false;
|
||||
}
|
||||
macro->Conditions().emplace_back(condition);
|
||||
|
||||
// 3. Instantiate action via factory, then hydrate via Load()
|
||||
auto action = MacroActionFactory::Create(actionId, macro.get());
|
||||
if (!action) {
|
||||
blog(LOG_WARNING,
|
||||
"FirstRunWizard: action factory returned null "
|
||||
"for id '%s' — is the base plugin loaded?",
|
||||
actionId.c_str());
|
||||
return false;
|
||||
}
|
||||
if (!action->Load(actionData)) {
|
||||
blog(LOG_WARNING,
|
||||
"FirstRunWizard: action Load() failed for id '%s'",
|
||||
actionId.c_str());
|
||||
return false;
|
||||
}
|
||||
macro->Actions().emplace_back(action);
|
||||
|
||||
blog(LOG_INFO, "FirstRunWizard: created macro '%s'", macroName.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
128
lib/utils/first-run-wizard.hpp
Normal file
128
lib/utils/first-run-wizard.hpp
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
#pragma once
|
||||
|
||||
#include <obs-data.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#include <QWizard>
|
||||
#include <QWizardPage>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace advss {
|
||||
|
||||
class Macro;
|
||||
|
||||
bool IsFirstRun();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Page IDs
|
||||
// ---------------------------------------------------------------------------
|
||||
enum WizardPageId {
|
||||
PAGE_WELCOME = 0,
|
||||
PAGE_SCENE,
|
||||
PAGE_WINDOW,
|
||||
PAGE_REVIEW,
|
||||
PAGE_DONE,
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// WelcomePage
|
||||
// ---------------------------------------------------------------------------
|
||||
class WelcomePage : public QWizardPage {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WelcomePage(QWidget *parent = nullptr);
|
||||
int nextId() const override { return PAGE_SCENE; }
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SceneSelectionPage
|
||||
// Registers wizard field "targetScene" (QString).
|
||||
// ---------------------------------------------------------------------------
|
||||
class SceneSelectionPage : public QWizardPage {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SceneSelectionPage(QWidget *parent = nullptr);
|
||||
void initializePage() override;
|
||||
bool isComplete() const override;
|
||||
int nextId() const override { return PAGE_WINDOW; }
|
||||
|
||||
private:
|
||||
QComboBox *_sceneCombo;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// WindowConditionPage
|
||||
// Registers wizard field "windowTitle" (QString).
|
||||
// Auto-detect button samples the focused window after a countdown.
|
||||
// ---------------------------------------------------------------------------
|
||||
class WindowConditionPage : public QWizardPage {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WindowConditionPage(QWidget *parent = nullptr);
|
||||
void initializePage() override;
|
||||
bool isComplete() const override;
|
||||
int nextId() const override { return PAGE_REVIEW; }
|
||||
|
||||
private slots:
|
||||
void onAutoDetectClicked();
|
||||
void onCountdownTick();
|
||||
|
||||
private:
|
||||
QLineEdit *_windowEdit;
|
||||
QPushButton *_autoDetect;
|
||||
QTimer *_detectTimer;
|
||||
int _countdown = 3;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ReviewPage
|
||||
// Displays a summary and calls FirstRunWizard::CreateMacro() on Finish.
|
||||
// ---------------------------------------------------------------------------
|
||||
class ReviewPage : public QWizardPage {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ReviewPage(QWidget *parent, std::shared_ptr<Macro> ¯o);
|
||||
void initializePage() override;
|
||||
bool validatePage() override;
|
||||
int nextId() const override { return PAGE_DONE; }
|
||||
|
||||
private:
|
||||
QLabel *_summary;
|
||||
std::shared_ptr<Macro> &_macro;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DonePage
|
||||
// ---------------------------------------------------------------------------
|
||||
class DonePage : public QWizardPage {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DonePage(QWidget *parent = nullptr);
|
||||
int nextId() const override { return -1; }
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// FirstRunWizard
|
||||
// ---------------------------------------------------------------------------
|
||||
class FirstRunWizard : public QWizard {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FirstRunWizard(QWidget *parent = nullptr);
|
||||
static std::shared_ptr<Macro> ShowWizard(QWidget *parent);
|
||||
static bool
|
||||
CreateMacro(std::shared_ptr<Macro> ¯o, const std::string ¯oName,
|
||||
const std::string &conditionId, obs_data_t *conditionData,
|
||||
const std::string &actionId, obs_data_t *actionData);
|
||||
|
||||
private:
|
||||
void markFirstRunComplete();
|
||||
|
||||
std::shared_ptr<Macro> _macro;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
#ifndef UNIT_TEST
|
||||
#include <util/base.h>
|
||||
#endif
|
||||
|
||||
namespace advss {
|
||||
|
||||
|
|
@ -9,6 +7,7 @@ namespace advss {
|
|||
#define blog(level, msg, ...)
|
||||
#define vblog(level, msg, ...)
|
||||
#define ablog(level, msg, ...)
|
||||
#define mblog(level, msg, ...)
|
||||
#else
|
||||
|
||||
// Print log with "[adv-ss] " prefix
|
||||
|
|
|
|||
|
|
@ -3,12 +3,42 @@
|
|||
#include "macro-signals.hpp"
|
||||
#include "switcher-data.hpp"
|
||||
|
||||
#include "obs-frontend-api.h"
|
||||
|
||||
namespace advss {
|
||||
|
||||
static std::mutex initMutex;
|
||||
static std::mutex postLoadMutex;
|
||||
static std::mutex finishLoadMutex;
|
||||
static std::mutex mutex;
|
||||
|
||||
static bool setup();
|
||||
static bool setupDonw = setup();
|
||||
bool loadingFinished = false;
|
||||
|
||||
static std::vector<std::function<void()>> &getFinishLoadSteps();
|
||||
|
||||
static bool setup()
|
||||
{
|
||||
static auto handleEvent = [](enum obs_frontend_event event, void *) {
|
||||
switch (event) {
|
||||
case OBS_FRONTEND_EVENT_FINISHED_LOADING: {
|
||||
std::lock_guard<std::mutex> lock(finishLoadMutex);
|
||||
for (const auto &step : getFinishLoadSteps()) {
|
||||
step();
|
||||
}
|
||||
getFinishLoadSteps().clear();
|
||||
loadingFinished = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
};
|
||||
};
|
||||
obs_frontend_add_event_callback(handleEvent, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
static std::vector<std::function<void()>> &getPluginInitSteps()
|
||||
{
|
||||
static std::vector<std::function<void()>> steps;
|
||||
|
|
@ -63,6 +93,12 @@ static std::vector<std::function<void()>> &getPostLoadSteps()
|
|||
return steps;
|
||||
}
|
||||
|
||||
static std::vector<std::function<void()>> &getFinishLoadSteps()
|
||||
{
|
||||
static std::vector<std::function<void()>> steps;
|
||||
return steps;
|
||||
}
|
||||
|
||||
void SavePluginSettings(obs_data_t *obj)
|
||||
{
|
||||
GetSwitcher()->SaveSettings(obj);
|
||||
|
|
@ -178,6 +214,16 @@ void RunIntervalResetSteps()
|
|||
}
|
||||
}
|
||||
|
||||
void AddFinishedLoadingStep(std::function<void()> step)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(finishLoadMutex);
|
||||
if (loadingFinished) {
|
||||
return;
|
||||
}
|
||||
|
||||
getFinishLoadSteps().emplace_back(step);
|
||||
}
|
||||
|
||||
void AddStartStep(std::function<void()> step)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ void RunStartSteps();
|
|||
void RunStopSteps();
|
||||
void RunIntervalResetSteps();
|
||||
|
||||
// Steps are executed after OBS_FRONTEND_EVENT_FINISHED_LOADING is fired
|
||||
EXPORT void AddFinishedLoadingStep(std::function<void()>);
|
||||
|
||||
enum class NoMatchBehavior { NO_SWITCH = 0, SWITCH = 1, RANDOM_SWITCH = 2 };
|
||||
EXPORT void SetPluginNoMatchBehavior(NoMatchBehavior);
|
||||
EXPORT NoMatchBehavior GetPluginNoMatchBehavior();
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ void CenterSplitterPosition(QSplitter *splitter)
|
|||
|
||||
void SetSplitterPositionByFraction(QSplitter *splitter, double fraction)
|
||||
{
|
||||
int value1 = (double)QWIDGETSIZE_MAX * fraction;
|
||||
int value2 = (double)QWIDGETSIZE_MAX * (1.0 - fraction);
|
||||
int value1 = (int)((double)QWIDGETSIZE_MAX * fraction);
|
||||
int value2 = (int)((double)QWIDGETSIZE_MAX * (1.0 - fraction));
|
||||
splitter->setSizes(QList<int>() << value1 << value2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,22 @@
|
|||
|
||||
namespace advss {
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
std::mutex *GetSwitcherMutex()
|
||||
{
|
||||
static std::mutex m;
|
||||
return &m;
|
||||
}
|
||||
std::unique_lock<std::mutex> *GetSwitcherLoopLock()
|
||||
{
|
||||
static std::mutex m;
|
||||
static std::unique_lock<std::mutex> lock(m);
|
||||
return &lock;
|
||||
}
|
||||
#else
|
||||
std::mutex *GetSwitcherMutex();
|
||||
std::unique_lock<std::mutex> *GetSwitcherLoopLock();
|
||||
#endif
|
||||
|
||||
std::mutex *GetMutex()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include "export-symbol-helper.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace advss {
|
||||
|
|
|
|||
|
|
@ -81,13 +81,13 @@ void GenericVariableSpinbox::DisableVariableSelection()
|
|||
|
||||
void GenericVariableSpinbox::setMinimum(double value)
|
||||
{
|
||||
_fixedValueInt->setMinimum(value);
|
||||
_fixedValueInt->setMinimum((int)value);
|
||||
_fixedValueDouble->setMinimum(value);
|
||||
}
|
||||
|
||||
void GenericVariableSpinbox::setMaximum(double value)
|
||||
{
|
||||
_fixedValueInt->setMaximum(value);
|
||||
_fixedValueInt->setMaximum((int)value);
|
||||
_fixedValueDouble->setMaximum(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ void MacroActionFileEdit::UpdateEntryData()
|
|||
}
|
||||
|
||||
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
|
||||
_filePath->SetPath(QString::fromStdString(_entryData->_file));
|
||||
_filePath->SetPath(_entryData->_file);
|
||||
_text->setPlainText(_entryData->_text);
|
||||
|
||||
adjustSize();
|
||||
|
|
|
|||
|
|
@ -47,20 +47,28 @@ getNextMacros(std::vector<MacroRef> ¯os, MacroRef &lastRandomMacroRef,
|
|||
bool MacroActionRandom::PerformAction()
|
||||
{
|
||||
if (_macros.size() == 0) {
|
||||
SetTempVarValue("macro", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
auto macros = getNextMacros(_macros, lastRandomMacro, _allowRepeat);
|
||||
if (macros.size() == 0) {
|
||||
SetTempVarValue("macro", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (macros.size() == 1) {
|
||||
lastRandomMacro = macros[0];
|
||||
SetTempVarValue("macro", GetMacroName(macros[0].get()));
|
||||
return RunMacroActions(macros[0].get());
|
||||
}
|
||||
|
||||
srand((unsigned int)time(0));
|
||||
size_t idx = std::rand() % (macros.size());
|
||||
lastRandomMacro = macros[idx];
|
||||
|
||||
SetTempVarValue("macro", GetMacroName(macros[idx].get()));
|
||||
|
||||
return RunMacroActions(macros[idx].get());
|
||||
}
|
||||
|
||||
|
|
@ -85,6 +93,11 @@ bool MacroActionRandom::Load(obs_data_t *obj)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool MacroActionRandom::PostLoad()
|
||||
{
|
||||
return MacroAction::PostLoad() && MultiMacroRefAction::PostLoad();
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionRandom::Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionRandom>(m);
|
||||
|
|
@ -95,6 +108,16 @@ std::shared_ptr<MacroAction> MacroActionRandom::Copy() const
|
|||
return std::make_shared<MacroActionRandom>(*this);
|
||||
}
|
||||
|
||||
void MacroActionRandom::SetupTempVars()
|
||||
{
|
||||
MacroAction::SetupTempVars();
|
||||
AddTempvar(
|
||||
"macro",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.random.macro"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.random.macro.description"));
|
||||
}
|
||||
|
||||
MacroActionRandomEdit::MacroActionRandomEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroActionRandom> entryData)
|
||||
: QWidget(parent),
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public:
|
|||
void LogAction() const;
|
||||
bool Save(obs_data_t *obj) const;
|
||||
bool Load(obs_data_t *obj);
|
||||
bool PostLoad();
|
||||
std::string GetId() const { return id; };
|
||||
static std::shared_ptr<MacroAction> Create(Macro *m);
|
||||
std::shared_ptr<MacroAction> Copy() const;
|
||||
|
|
@ -22,7 +23,10 @@ public:
|
|||
bool _allowRepeat = false;
|
||||
|
||||
private:
|
||||
void SetupTempVars();
|
||||
|
||||
MacroRef lastRandomMacro;
|
||||
|
||||
static bool _registered;
|
||||
static const std::string id;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -82,13 +82,22 @@ void MacroActionSequence::ResolveVariablesToFixedValues()
|
|||
_resetIndex.ResolveVariables();
|
||||
}
|
||||
|
||||
void MacroActionSequence::SetAction(Action action)
|
||||
{
|
||||
_action = action;
|
||||
SetupTempVars();
|
||||
}
|
||||
|
||||
bool MacroActionSequence::RunSequence()
|
||||
{
|
||||
if (_macros.size() == 0) {
|
||||
SetTempVarValue("macro", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
auto macro = GetNextMacro().GetMacro();
|
||||
SetTempVarValue("macro", GetMacroName(macro.get()));
|
||||
|
||||
if (!macro.get()) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -96,18 +105,21 @@ bool MacroActionSequence::RunSequence()
|
|||
return RunMacroActions(macro.get());
|
||||
}
|
||||
|
||||
bool MacroActionSequence::SetSequenceIndex() const
|
||||
bool MacroActionSequence::SetSequenceIndex()
|
||||
{
|
||||
auto macro = _macro.GetMacro();
|
||||
if (!macro) {
|
||||
SetTempVarValue("nextMacro", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
auto actions = GetMacroActions(macro.get());
|
||||
if (!actions) {
|
||||
SetTempVarValue("nextMacro", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string nextMacroName;
|
||||
for (const auto &action : *actions) {
|
||||
if (action->GetId() != id) {
|
||||
continue;
|
||||
|
|
@ -121,10 +133,34 @@ bool MacroActionSequence::SetSequenceIndex() const
|
|||
// -2 is needed since the _lastIndex starts at -1 and the reset
|
||||
// index starts at 1
|
||||
sequenceAction->_lastIdx = _resetIndex - 2;
|
||||
nextMacroName = GetMacroName(
|
||||
sequenceAction->GetNextMacro(false).GetMacro().get());
|
||||
}
|
||||
SetTempVarValue("nextMacro", nextMacroName);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MacroActionSequence::SetupTempVars()
|
||||
{
|
||||
MacroAction::SetupTempVars();
|
||||
|
||||
if (_action == Action::RUN_SEQUENCE) {
|
||||
AddTempvar(
|
||||
"macro",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.sequence.macro"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.sequence.macro.description"));
|
||||
} else if (_action == Action::SET_INDEX) {
|
||||
AddTempvar(
|
||||
"nextMacro",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.sequence.nextMacro"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.sequence.nextMacro.description"));
|
||||
}
|
||||
}
|
||||
|
||||
bool MacroActionSequence::PerformAction()
|
||||
{
|
||||
if (_action == Action::RUN_SEQUENCE) {
|
||||
|
|
@ -162,7 +198,7 @@ bool MacroActionSequence::Load(obs_data_t *obj)
|
|||
LoadMacroList(obj, _macros);
|
||||
_restart = obs_data_get_bool(obj, "restart");
|
||||
_macro.Load(obj);
|
||||
_action = static_cast<Action>(obs_data_get_int(obj, "action"));
|
||||
SetAction(static_cast<Action>(obs_data_get_int(obj, "action")));
|
||||
_resetIndex.Load(obj, "resetIndex");
|
||||
return true;
|
||||
}
|
||||
|
|
@ -256,7 +292,7 @@ void MacroActionSequenceEdit::UpdateEntryData()
|
|||
_macroList->SetContent(_entryData->_macros);
|
||||
_restart->setChecked(_entryData->_restart);
|
||||
_resetIndex->SetValue(_entryData->_resetIndex);
|
||||
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
|
||||
_actions->setCurrentIndex(static_cast<int>(_entryData->GetAction()));
|
||||
_macros->SetCurrentMacro(_entryData->_macro);
|
||||
SetWidgetVisibility();
|
||||
adjustSize();
|
||||
|
|
@ -361,7 +397,7 @@ void MacroActionSequenceEdit::UpdateStatusLine()
|
|||
void MacroActionSequenceEdit::ActionChanged(int value)
|
||||
{
|
||||
GUARD_LOADING_AND_LOCK();
|
||||
_entryData->_action = static_cast<MacroActionSequence::Action>(value);
|
||||
_entryData->SetAction(static_cast<MacroActionSequence::Action>(value));
|
||||
SetWidgetVisibility();
|
||||
}
|
||||
|
||||
|
|
@ -385,10 +421,10 @@ void MacroActionSequenceEdit::SetWidgetVisibility()
|
|||
|
||||
ClearLayout(_layout);
|
||||
|
||||
const auto action = _entryData->GetAction();
|
||||
PlaceWidgets(
|
||||
obs_module_text(
|
||||
_entryData->_action ==
|
||||
MacroActionSequence::Action::RUN_SEQUENCE
|
||||
action == MacroActionSequence::Action::RUN_SEQUENCE
|
||||
? "AdvSceneSwitcher.action.sequence.entry.run"
|
||||
: "AdvSceneSwitcher.action.sequence.entry.setIndex"),
|
||||
_layout,
|
||||
|
|
@ -396,15 +432,14 @@ void MacroActionSequenceEdit::SetWidgetVisibility()
|
|||
{"{{macros}}", _macros},
|
||||
{"{{index}}", _resetIndex}});
|
||||
|
||||
_macroList->setVisible(_entryData->_action ==
|
||||
_macroList->setVisible(action ==
|
||||
MacroActionSequence::Action::RUN_SEQUENCE);
|
||||
_restart->setVisible(_entryData->_action ==
|
||||
_restart->setVisible(action ==
|
||||
MacroActionSequence::Action::RUN_SEQUENCE);
|
||||
_statusLine->setVisible(_entryData->_action ==
|
||||
_statusLine->setVisible(action ==
|
||||
MacroActionSequence::Action::RUN_SEQUENCE);
|
||||
_macros->setVisible(_entryData->_action ==
|
||||
MacroActionSequence::Action::SET_INDEX);
|
||||
_resetIndex->setVisible(_entryData->_action ==
|
||||
_macros->setVisible(action == MacroActionSequence::Action::SET_INDEX);
|
||||
_resetIndex->setVisible(action ==
|
||||
MacroActionSequence::Action::SET_INDEX);
|
||||
|
||||
adjustSize();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,10 @@ public:
|
|||
RUN_SEQUENCE,
|
||||
SET_INDEX,
|
||||
};
|
||||
Action _action = Action::RUN_SEQUENCE;
|
||||
|
||||
Action GetAction() const { return _action; }
|
||||
void SetAction(Action);
|
||||
|
||||
bool _restart = true;
|
||||
IntVariable _resetIndex = 1;
|
||||
|
||||
|
|
@ -43,7 +46,11 @@ public:
|
|||
|
||||
private:
|
||||
bool RunSequence();
|
||||
bool SetSequenceIndex() const;
|
||||
bool SetSequenceIndex();
|
||||
|
||||
void SetupTempVars();
|
||||
|
||||
Action _action = Action::RUN_SEQUENCE;
|
||||
|
||||
static bool _registered;
|
||||
static const std::string id;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ const static std::map<MacroActionSource::Action, std::string> actionTypes = {
|
|||
"AdvSceneSwitcher.action.source.type.closeFilterDialog"},
|
||||
{MacroActionSource::Action::CLOSE_PROPERTIES_DIALOG,
|
||||
"AdvSceneSwitcher.action.source.type.closePropertiesDialog"},
|
||||
{MacroActionSource::Action::GET_SETTING,
|
||||
"AdvSceneSwitcher.action.source.type.getSetting"},
|
||||
{MacroActionSource::Action::GET_SETTINGS,
|
||||
"AdvSceneSwitcher.action.source.type.getSettings"},
|
||||
};
|
||||
|
||||
const static std::map<obs_deinterlace_mode, std::string> deinterlaceModes = {
|
||||
|
|
@ -273,6 +277,22 @@ bool MacroActionSource::PerformAction()
|
|||
"OBSBasicProperties");
|
||||
});
|
||||
break;
|
||||
case Action::GET_SETTING: {
|
||||
const auto value =
|
||||
GetSourceSettingValue(_source.GetSource(), _setting);
|
||||
if (value) {
|
||||
SetTempVarValue("setting", *value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Action::GET_SETTINGS: {
|
||||
const auto settings =
|
||||
GetSourceSettings(_source.GetSource(), true);
|
||||
if (settings) {
|
||||
SetTempVarValue("settings", *settings);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -360,6 +380,31 @@ void MacroActionSource::ResolveVariablesToFixedValues()
|
|||
_manualSettingValue.ResolveVariables();
|
||||
}
|
||||
|
||||
void MacroActionSource::SetupTempVars()
|
||||
{
|
||||
MacroAction::SetupTempVars();
|
||||
switch (_action) {
|
||||
case Action::GET_SETTING:
|
||||
AddTempvar("setting",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.source.setting"));
|
||||
break;
|
||||
case Action::GET_SETTINGS:
|
||||
AddTempvar("settings",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.source.settings"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MacroActionSource::SetAction(Action action)
|
||||
{
|
||||
_action = action;
|
||||
SetupTempVars();
|
||||
}
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
{
|
||||
for (auto &[actionType, name] : actionTypes) {
|
||||
|
|
@ -502,7 +547,7 @@ void MacroActionSourceEdit::UpdateEntryData()
|
|||
|
||||
const auto weakSource = _entryData->_source.GetSource();
|
||||
_settingsButtons->SetSelection(weakSource, _entryData->_button);
|
||||
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
|
||||
_actions->setCurrentIndex(static_cast<int>(_entryData->GetAction()));
|
||||
_sources->SetSource(_entryData->_source);
|
||||
_sourceSettings->SetSelection(weakSource, _entryData->_setting);
|
||||
_settingsString->setPlainText(_entryData->_settingsString);
|
||||
|
|
@ -537,7 +582,7 @@ void MacroActionSourceEdit::SourceChanged(const SourceSelection &source)
|
|||
void MacroActionSourceEdit::ActionChanged(int value)
|
||||
{
|
||||
GUARD_LOADING_AND_LOCK();
|
||||
_entryData->_action = static_cast<MacroActionSource::Action>(value);
|
||||
_entryData->SetAction(static_cast<MacroActionSource::Action>(value));
|
||||
SetWidgetVisibility();
|
||||
}
|
||||
|
||||
|
|
@ -664,19 +709,29 @@ static QString GetIndividualListEntryName()
|
|||
|
||||
void MacroActionSourceEdit::SetWidgetVisibility()
|
||||
{
|
||||
const auto action = _entryData->GetAction();
|
||||
|
||||
const bool isSetSettings = action ==
|
||||
MacroActionSource::Action::SETTINGS;
|
||||
const bool isGetSetting = action ==
|
||||
MacroActionSource::Action::GET_SETTING;
|
||||
const bool isGetSettings = action ==
|
||||
MacroActionSource::Action::GET_SETTINGS;
|
||||
|
||||
SetLayoutVisible(_settingsLayout,
|
||||
_entryData->_action ==
|
||||
MacroActionSource::Action::SETTINGS);
|
||||
isSetSettings || isGetSetting || isGetSettings);
|
||||
_settingsInputMethods->setVisible(isSetSettings);
|
||||
_sourceSettings->setVisible(
|
||||
_entryData->_action == MacroActionSource::Action::SETTINGS &&
|
||||
_entryData->_settingsInputMethod !=
|
||||
MacroActionSource::SettingsInputMethod::JSON_STRING);
|
||||
(isSetSettings &&
|
||||
_entryData->_settingsInputMethod !=
|
||||
MacroActionSource::SettingsInputMethod::JSON_STRING) ||
|
||||
isGetSetting);
|
||||
_settingsString->setVisible(
|
||||
_entryData->_action == MacroActionSource::Action::SETTINGS &&
|
||||
isSetSettings &&
|
||||
_entryData->_settingsInputMethod ==
|
||||
MacroActionSource::SettingsInputMethod::JSON_STRING);
|
||||
_getSettings->setVisible(
|
||||
_entryData->_action == MacroActionSource::Action::SETTINGS &&
|
||||
isSetSettings &&
|
||||
_entryData->_settingsInputMethod !=
|
||||
MacroActionSource::SettingsInputMethod::
|
||||
INDIVIDUAL_TEMPVAR);
|
||||
|
|
@ -685,13 +740,12 @@ void MacroActionSourceEdit::SetWidgetVisibility()
|
|||
GetIndividualListEntryName(),
|
||||
_entryData->_setting.IsList());
|
||||
|
||||
_tempVars->setVisible(_entryData->_action ==
|
||||
MacroActionSource::Action::SETTINGS &&
|
||||
_tempVars->setVisible(isSetSettings &&
|
||||
_entryData->_settingsInputMethod ==
|
||||
MacroActionSource::SettingsInputMethod::
|
||||
INDIVIDUAL_TEMPVAR);
|
||||
|
||||
if (_entryData->_action == MacroActionSource::Action::SETTINGS &&
|
||||
if (isSetSettings &&
|
||||
(_entryData->_settingsInputMethod ==
|
||||
MacroActionSource::SettingsInputMethod::INDIVIDUAL_MANUAL ||
|
||||
_entryData->_settingsInputMethod ==
|
||||
|
|
@ -704,35 +758,31 @@ void MacroActionSourceEdit::SetWidgetVisibility()
|
|||
_manualSettingValue->hide();
|
||||
}
|
||||
|
||||
const bool showWarning =
|
||||
_entryData->_action == MacroActionSource::Action::ENABLE ||
|
||||
_entryData->_action == MacroActionSource::Action::DISABLE;
|
||||
const bool showWarning = action == MacroActionSource::Action::ENABLE ||
|
||||
action == MacroActionSource::Action::DISABLE;
|
||||
_warning->setVisible(showWarning);
|
||||
_settingsButtons->setVisible(
|
||||
_entryData->_action ==
|
||||
MacroActionSource::Action::SETTINGS_BUTTON);
|
||||
action == MacroActionSource::Action::SETTINGS_BUTTON);
|
||||
_deinterlaceMode->setVisible(
|
||||
_entryData->_action ==
|
||||
MacroActionSource::Action::DEINTERLACE_MODE);
|
||||
action == MacroActionSource::Action::DEINTERLACE_MODE);
|
||||
_deinterlaceOrder->setVisible(
|
||||
_entryData->_action ==
|
||||
MacroActionSource::Action::DEINTERLACE_FIELD_ORDER);
|
||||
action == MacroActionSource::Action::DEINTERLACE_FIELD_ORDER);
|
||||
|
||||
_refreshSettingSelection->setVisible(
|
||||
(_entryData->_settingsInputMethod ==
|
||||
MacroActionSource::SettingsInputMethod::
|
||||
INDIVIDUAL_MANUAL ||
|
||||
_entryData->_settingsInputMethod ==
|
||||
MacroActionSource::SettingsInputMethod::
|
||||
INDIVIDUAL_LIST_ENTRY) &&
|
||||
((isSetSettings &&
|
||||
(_entryData->_settingsInputMethod ==
|
||||
MacroActionSource::SettingsInputMethod::
|
||||
INDIVIDUAL_MANUAL ||
|
||||
_entryData->_settingsInputMethod ==
|
||||
MacroActionSource::SettingsInputMethod::
|
||||
INDIVIDUAL_LIST_ENTRY)) ||
|
||||
isGetSetting) &&
|
||||
_entryData->_source.GetType() ==
|
||||
SourceSelection::Type::VARIABLE);
|
||||
|
||||
_acceptDialog->setVisible(
|
||||
_entryData->_action ==
|
||||
MacroActionSource::Action::CLOSE_FILTER_DIALOG ||
|
||||
_entryData->_action ==
|
||||
MacroActionSource::Action::CLOSE_PROPERTIES_DIALOG);
|
||||
action == MacroActionSource::Action::CLOSE_FILTER_DIALOG ||
|
||||
action == MacroActionSource::Action::CLOSE_PROPERTIES_DIALOG);
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
|
|
|
|||
|
|
@ -24,17 +24,7 @@ public:
|
|||
static std::shared_ptr<MacroAction> Create(Macro *m);
|
||||
std::shared_ptr<MacroAction> Copy() const;
|
||||
void ResolveVariablesToFixedValues();
|
||||
|
||||
SourceSelection _source;
|
||||
SourceSettingButton _button;
|
||||
StringVariable _settingsString = "";
|
||||
StringVariable _manualSettingValue = "";
|
||||
obs_deinterlace_mode _deinterlaceMode = OBS_DEINTERLACE_MODE_DISABLE;
|
||||
obs_deinterlace_field_order _deinterlaceOrder =
|
||||
OBS_DEINTERLACE_FIELD_ORDER_TOP;
|
||||
TempVariableRef _tempVar;
|
||||
SourceSetting _setting;
|
||||
bool _acceptDialog = false;
|
||||
void SetupTempVars();
|
||||
|
||||
enum class Action {
|
||||
ENABLE,
|
||||
|
|
@ -50,8 +40,23 @@ public:
|
|||
CLOSE_INTERACTION_DIALOG,
|
||||
CLOSE_FILTER_DIALOG,
|
||||
CLOSE_PROPERTIES_DIALOG,
|
||||
GET_SETTING,
|
||||
GET_SETTINGS,
|
||||
};
|
||||
Action _action = Action::SETTINGS;
|
||||
|
||||
void SetAction(Action);
|
||||
Action GetAction() const { return _action; }
|
||||
|
||||
SourceSelection _source;
|
||||
SourceSettingButton _button;
|
||||
StringVariable _settingsString = "";
|
||||
StringVariable _manualSettingValue = "";
|
||||
obs_deinterlace_mode _deinterlaceMode = OBS_DEINTERLACE_MODE_DISABLE;
|
||||
obs_deinterlace_field_order _deinterlaceOrder =
|
||||
OBS_DEINTERLACE_FIELD_ORDER_TOP;
|
||||
TempVariableRef _tempVar;
|
||||
SourceSetting _setting;
|
||||
bool _acceptDialog = false;
|
||||
|
||||
enum class SettingsInputMethod {
|
||||
INDIVIDUAL_MANUAL,
|
||||
|
|
@ -63,6 +68,8 @@ public:
|
|||
SettingsInputMethod::INDIVIDUAL_MANUAL;
|
||||
|
||||
private:
|
||||
Action _action = Action::SETTINGS;
|
||||
|
||||
static bool _registered;
|
||||
static const std::string id;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
#include "text-helpers.hpp"
|
||||
|
||||
#include <regex>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace advss {
|
||||
|
||||
QString EscapeForRegex(const QString &s)
|
||||
QString EscapeForRegex(const QString &input)
|
||||
{
|
||||
static std::regex specialChars{R"([-[\]{}()*+?.,\^$|#\s])"};
|
||||
std::string input = s.toStdString();
|
||||
return QString::fromStdString(
|
||||
std::regex_replace(input, specialChars, R"(\$&)"));
|
||||
return QRegularExpression::escape(input);
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
|
|
|||
|
|
@ -68,10 +68,15 @@ void ContentClassification::SetContentClassification(
|
|||
data = obs_data_create();
|
||||
obs_data_set_array(data, "content_classification_labels", ccls);
|
||||
|
||||
const auto id = token.GetUserID();
|
||||
if (!id) {
|
||||
vblog(LOG_INFO, "%s skip - invalid user id", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = SendPatchRequest(token, "https://api.twitch.tv",
|
||||
"/helix/channels",
|
||||
{{"broadcaster_id", token.GetUserID()}},
|
||||
data.Get());
|
||||
{{"broadcaster_id", *id}}, data.Get());
|
||||
|
||||
if (result.status != 204) {
|
||||
blog(LOG_INFO,
|
||||
|
|
|
|||
|
|
@ -207,6 +207,26 @@ static obs_data_t *copyData(const OBSData &data)
|
|||
return obs_data_create_from_json(json);
|
||||
}
|
||||
|
||||
void EventSub::LogActiveSubscriptions() const
|
||||
{
|
||||
if (!VerboseLoggingEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_activeSubscriptions.empty()) {
|
||||
blog(LOG_INFO, "Twitch EventSub active subscriptions: none");
|
||||
return;
|
||||
}
|
||||
|
||||
blog(LOG_INFO, "Twitch EventSub active subscriptions: %zu",
|
||||
_activeSubscriptions.size());
|
||||
for (const auto &sub : _activeSubscriptions) {
|
||||
const char *type = obs_data_get_string(sub.data, "type");
|
||||
blog(LOG_INFO, " id=%s type=%s", sub.id.c_str(),
|
||||
type ? type : "");
|
||||
}
|
||||
}
|
||||
|
||||
std::string EventSub::AddEventSubscription(std::shared_ptr<TwitchToken> token,
|
||||
Subscription subscription)
|
||||
{
|
||||
|
|
@ -218,7 +238,12 @@ std::string EventSub::AddEventSubscription(std::shared_ptr<TwitchToken> token,
|
|||
|
||||
std::unique_lock<std::mutex> lock(eventSub->_subscriptionMtx);
|
||||
if (!eventSub->_connected) {
|
||||
vblog(LOG_INFO, "Twitch EventSub connect started for %s",
|
||||
if (eventSub->_reconnecting) {
|
||||
return "";
|
||||
}
|
||||
|
||||
vblog(LOG_INFO,
|
||||
"new Twitch EventSub connect attempt started for %s",
|
||||
token->GetName().c_str());
|
||||
lock.unlock();
|
||||
eventSub->Connect();
|
||||
|
|
@ -226,9 +251,17 @@ std::string EventSub::AddEventSubscription(std::shared_ptr<TwitchToken> token,
|
|||
}
|
||||
|
||||
if (isAlreadySubscribed(eventSub->_activeSubscriptions, subscription)) {
|
||||
eventSub->LogActiveSubscriptions();
|
||||
return eventSub->_activeSubscriptions.find(subscription)->id;
|
||||
}
|
||||
|
||||
if (!eventSub->IsValidID(eventSub->_sessionID)) {
|
||||
vblog(LOG_INFO,
|
||||
"session ID of Twitch event sub invalid - skip %s",
|
||||
__func__);
|
||||
return "";
|
||||
}
|
||||
|
||||
OBSDataAutoRelease postData = copyData(subscription.data);
|
||||
setTransportData(postData.Get(), eventSub->_sessionID);
|
||||
auto result = SendPostRequest(*token, registerSubscriptionURL.data(),
|
||||
|
|
@ -236,8 +269,14 @@ std::string EventSub::AddEventSubscription(std::shared_ptr<TwitchToken> token,
|
|||
postData.Get());
|
||||
|
||||
if (result.status != 202) {
|
||||
vblog(LOG_INFO, "failed to register Twitch EventSub (%d)",
|
||||
result.status);
|
||||
const char *error = obs_data_get_string(result.data, "error");
|
||||
const char *message =
|
||||
obs_data_get_string(result.data, "message");
|
||||
vblog(LOG_INFO,
|
||||
"failed to register Twitch EventSub (%d): %s - %s",
|
||||
result.status, error ? error : "no error",
|
||||
message ? message : "no message");
|
||||
eventSub->LogActiveSubscriptions();
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
@ -246,6 +285,7 @@ std::string EventSub::AddEventSubscription(std::shared_ptr<TwitchToken> token,
|
|||
OBSDataAutoRelease replyData = obs_data_array_item(replyArray, 0);
|
||||
subscription.id = obs_data_get_string(replyData, "id");
|
||||
eventSub->_activeSubscriptions.emplace(subscription);
|
||||
eventSub->LogActiveSubscriptions();
|
||||
return subscription.id;
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +442,9 @@ void EventSub::HandleWelcome(obs_data_t *data)
|
|||
{
|
||||
OBSDataAutoRelease session = obs_data_get_obj(data, "session");
|
||||
_sessionID = obs_data_get_string(session, "id");
|
||||
ClearActiveSubscriptions();
|
||||
blog(LOG_INFO, "Twitch EventSub connected");
|
||||
vblog(LOG_INFO, "Twitch EventSub session id: %s", _sessionID.c_str());
|
||||
}
|
||||
|
||||
void EventSub::HandleKeepAlive() const
|
||||
|
|
@ -430,11 +472,14 @@ void EventSub::OnServerMigrationWelcome(
|
|||
// Disable reconnect handling for old connection which will be closed
|
||||
_client->set_close_handler([](connection_hdl) {});
|
||||
_client->set_fail_handler([](connection_hdl) {});
|
||||
auto connection = _client->get_con_from_hdl(_connection);
|
||||
connection->set_close_handler([](connection_hdl) {
|
||||
vblog(LOG_INFO, "previous Twitch EventSub connection closed");
|
||||
});
|
||||
connection->set_fail_handler([](connection_hdl) {});
|
||||
if (!_connection.expired()) {
|
||||
auto connection = _client->get_con_from_hdl(_connection);
|
||||
connection->set_close_handler([](connection_hdl) {
|
||||
vblog(LOG_INFO,
|
||||
"previous Twitch EventSub connection closed");
|
||||
});
|
||||
connection->set_fail_handler([](connection_hdl) {});
|
||||
}
|
||||
|
||||
websocketpp::lib::error_code ec;
|
||||
_client->close(_connection, websocketpp::close::status::normal,
|
||||
|
|
@ -442,6 +487,7 @@ void EventSub::OnServerMigrationWelcome(
|
|||
|
||||
_client.swap(newClient);
|
||||
_sessionID = _migrationSessionID;
|
||||
vblog(LOG_INFO, "Twitch EventSub session id: %s", _sessionID.c_str());
|
||||
_connection = newHdl;
|
||||
|
||||
_client->set_open_handler(bind(&EventSub::OnOpen, this, _1));
|
||||
|
|
@ -461,17 +507,16 @@ void EventSub::OnServerMigrationWelcome(
|
|||
|
||||
void EventSub::StartServerMigrationClient(const std::string &url)
|
||||
{
|
||||
auto client = std::make_unique<EventSubWSClient>();
|
||||
SetupClient(*client);
|
||||
_migrationClient = std::make_unique<EventSubWSClient>();
|
||||
SetupClient(*_migrationClient);
|
||||
|
||||
client->set_open_handler([this](connection_hdl) {
|
||||
_migrationClient->set_open_handler([this](connection_hdl) {
|
||||
vblog(LOG_INFO, "Twitch EventSub migration client opened");
|
||||
});
|
||||
|
||||
client->set_message_handler([this,
|
||||
&client](connection_hdl hdl,
|
||||
EventSubWSClient::message_ptr
|
||||
message) {
|
||||
_migrationClient->set_message_handler([this](connection_hdl hdl,
|
||||
EventSubWSClient::message_ptr
|
||||
message) {
|
||||
const auto msg = ParseWebSocketMessage(message);
|
||||
if (!msg) {
|
||||
return;
|
||||
|
|
@ -487,14 +532,14 @@ void EventSub::StartServerMigrationClient(const std::string &url)
|
|||
obs_data_get_obj(data, "session");
|
||||
_migrationSessionID =
|
||||
obs_data_get_string(session, "id");
|
||||
OnServerMigrationWelcome(hdl, client);
|
||||
OnServerMigrationWelcome(hdl, _migrationClient);
|
||||
} else {
|
||||
OnMessage(hdl, message);
|
||||
}
|
||||
});
|
||||
|
||||
websocketpp::lib::error_code ec;
|
||||
auto con = client->get_connection(url, ec);
|
||||
auto con = _migrationClient->get_connection(url, ec);
|
||||
if (ec) {
|
||||
blog(LOG_ERROR,
|
||||
"Twitch EventSub migration connection failed: %s",
|
||||
|
|
@ -504,8 +549,8 @@ void EventSub::StartServerMigrationClient(const std::string &url)
|
|||
}
|
||||
|
||||
_migrationConnection = con;
|
||||
client->connect(con);
|
||||
client->run();
|
||||
_migrationClient->connect(con);
|
||||
_migrationClient->run();
|
||||
}
|
||||
|
||||
void EventSub::HandleServerMigration(obs_data_t *data)
|
||||
|
|
@ -563,7 +608,7 @@ void EventSub::HandleRevocation(obs_data_t *data)
|
|||
|
||||
std::lock_guard<std::mutex> lock(_subscriptionMtx);
|
||||
for (auto it = _activeSubscriptions.begin();
|
||||
it != _activeSubscriptions.begin();) {
|
||||
it != _activeSubscriptions.end();) {
|
||||
if (it->id == id) {
|
||||
it = _activeSubscriptions.erase(it);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ private:
|
|||
void HandleServerMigration(obs_data_t *);
|
||||
void HandleRevocation(obs_data_t *);
|
||||
|
||||
void LogActiveSubscriptions() const;
|
||||
|
||||
void RegisterInstance();
|
||||
void UnregisterInstance();
|
||||
|
||||
|
|
|
|||
|
|
@ -189,12 +189,17 @@ void LanguageSelection::Save(obs_data_t *obj) const
|
|||
|
||||
void LanguageSelection::SetStreamLanguage(const TwitchToken &token) const
|
||||
{
|
||||
const auto id = token.GetUserID();
|
||||
if (!id) {
|
||||
vblog(LOG_INFO, "%s skip - invalid user id", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "broadcaster_language", _language.c_str());
|
||||
auto result = SendPatchRequest(token, "https://api.twitch.tv",
|
||||
"/helix/channels",
|
||||
{{"broadcaster_id", token.GetUserID()}},
|
||||
data.Get());
|
||||
{{"broadcaster_id", *id}}, data.Get());
|
||||
|
||||
if (result.status != 204) {
|
||||
blog(LOG_INFO, "Failed to set stream language! (%d)",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -12,6 +12,7 @@
|
|||
#include <variable-line-edit.hpp>
|
||||
#include <variable-text-edit.hpp>
|
||||
#include <duration-control.hpp>
|
||||
#include <duration.hpp>
|
||||
|
||||
namespace advss {
|
||||
|
||||
|
|
@ -182,11 +183,13 @@ public:
|
|||
StringVariable _announcementMessage = obs_module_text(
|
||||
"AdvSceneSwitcher.action.twitch.announcement.message");
|
||||
AnnouncementColor _announcementColor = AnnouncementColor::PRIMARY;
|
||||
int _nonModDelayDuration = 2;
|
||||
TwitchChannel _channel;
|
||||
StringVariable _chatMessage;
|
||||
UserInfoQueryType _userInfoQueryType = UserInfoQueryType::LOGIN;
|
||||
StringVariable _userLogin = "user login";
|
||||
DoubleVariable _userId = 0;
|
||||
StringVariable _banReason = "";
|
||||
TwitchPointsReward _pointsReward;
|
||||
std::weak_ptr<Variable> _rewardVariable;
|
||||
bool _useVariableForRewardSelection = false;
|
||||
|
|
@ -198,14 +201,14 @@ private:
|
|||
void CreateStreamClip(const std::shared_ptr<TwitchToken> &) const;
|
||||
void StartCommercial(const std::shared_ptr<TwitchToken> &) const;
|
||||
void SendChatAnnouncement(const std::shared_ptr<TwitchToken> &) const;
|
||||
void SetChatEmoteOnlyMode(const std::shared_ptr<TwitchToken> &,
|
||||
bool enable) const;
|
||||
void StartRaid(const std::shared_ptr<TwitchToken> &);
|
||||
void SendChatMessage(const std::shared_ptr<TwitchToken> &);
|
||||
void GetUserInfo(const std::shared_ptr<TwitchToken> &);
|
||||
void GetRewardInfo(const std::shared_ptr<TwitchToken> &);
|
||||
void GetChannelInfo(const std::shared_ptr<TwitchToken> &token);
|
||||
|
||||
std::optional<std::string>
|
||||
GetTargetUserID(const std::shared_ptr<TwitchToken> &) const;
|
||||
bool ResolveVariableSelectionToRewardId(
|
||||
const std::shared_ptr<TwitchToken> &);
|
||||
|
||||
|
|
@ -251,11 +254,13 @@ private slots:
|
|||
void DurationChanged(const Duration &);
|
||||
void AnnouncementMessageChanged();
|
||||
void AnnouncementColorChanged(int index);
|
||||
void NonModDelayDurationChanged(int index);
|
||||
void ChannelChanged(const TwitchChannel &);
|
||||
void ChatMessageChanged();
|
||||
void UserInfoQueryTypeChanged(int);
|
||||
void UserLoginChanged();
|
||||
void UserIdChanged(const NumberVariable<double> &);
|
||||
void BanReasonChanged();
|
||||
void PointsRewardChanged(const TwitchPointsReward &);
|
||||
void RewardVariableChanged(const QString &);
|
||||
void ToggleRewardSelection(bool);
|
||||
|
|
@ -274,6 +279,8 @@ private:
|
|||
void SetTokenWarning(bool visible, const QString &text = "");
|
||||
|
||||
QHBoxLayout *_layout;
|
||||
QWidget *_userModerationRow;
|
||||
QHBoxLayout *_layout2;
|
||||
FilterComboBox *_actions;
|
||||
TwitchConnectionSelection *_tokens;
|
||||
QLabel *_tokenWarning;
|
||||
|
|
@ -288,6 +295,7 @@ private:
|
|||
DurationSelection *_duration;
|
||||
VariableTextEdit *_announcementMessage;
|
||||
QComboBox *_announcementColor;
|
||||
QComboBox *_nonModDelayDuration;
|
||||
TwitchChannelSelection *_channel;
|
||||
VariableTextEdit *_chatMessage;
|
||||
QComboBox *_userInfoQueryType;
|
||||
|
|
@ -295,6 +303,7 @@ private:
|
|||
// QSpinBox uses int internally, which is too small for Twitch IDs, so
|
||||
// we use QDoubleSpinBox instead
|
||||
VariableDoubleSpinBox *_userId;
|
||||
VariableLineEdit *_banReason;
|
||||
TwitchPointsRewardWidget *_pointsReward;
|
||||
VariableSelection *_rewardVariable;
|
||||
QPushButton *_toggleRewardSelection;
|
||||
|
|
|
|||
|
|
@ -1096,6 +1096,12 @@ void MacroConditionTwitch::AddChannelGenericEventSubscription(
|
|||
return;
|
||||
}
|
||||
|
||||
const auto id = token->GetUserID();
|
||||
if (!id) {
|
||||
vblog(LOG_INFO, "%s skip - invalid user id", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto channelID = _channel.GetUserID(*token);
|
||||
if (!TwitchChannel::IsValid(channelID)) {
|
||||
vblog(LOG_INFO, "skip %s because of invalid channel selection",
|
||||
|
|
@ -1114,7 +1120,7 @@ void MacroConditionTwitch::AddChannelGenericEventSubscription(
|
|||
|
||||
if (includeModeratorId) {
|
||||
obs_data_set_string(condition, "moderator_user_id",
|
||||
token->GetUserID().c_str());
|
||||
id->c_str());
|
||||
}
|
||||
|
||||
obs_data_apply(condition, extraConditions);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,12 @@ void TwitchTagList::Save(obs_data_t *obj) const
|
|||
|
||||
void TwitchTagList::SetStreamTags(const TwitchToken &token) const
|
||||
{
|
||||
const auto id = token.GetUserID();
|
||||
if (!id) {
|
||||
vblog(LOG_INFO, "%s skip - invalid user id", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
nlohmann::json j;
|
||||
j["tags"] = toVector();
|
||||
|
||||
|
|
@ -47,8 +53,7 @@ void TwitchTagList::SetStreamTags(const TwitchToken &token) const
|
|||
|
||||
auto result = SendPatchRequest(token, "https://api.twitch.tv",
|
||||
"/helix/channels",
|
||||
{{"broadcaster_id", token.GetUserID()}},
|
||||
j.dump());
|
||||
{{"broadcaster_id", *id}}, j.dump());
|
||||
|
||||
if (result.status != 204) {
|
||||
blog(LOG_INFO, "Failed to set stream tags! (%d)",
|
||||
|
|
|
|||
|
|
@ -206,7 +206,9 @@ void TwitchToken::Save(obs_data_t *obj) const
|
|||
{
|
||||
Item::Save(obj);
|
||||
obs_data_set_string(obj, "token", _token.c_str());
|
||||
obs_data_set_string(obj, "userID", _userID.c_str());
|
||||
if (_userID) {
|
||||
obs_data_set_string(obj, "userID", _userID->c_str());
|
||||
}
|
||||
obs_data_set_bool(obj, "validateEventSubTimestamps",
|
||||
_validateEventSubTimestamps);
|
||||
obs_data_set_bool(obj, "warnIfInvalid", _warnIfInvalid);
|
||||
|
|
@ -266,7 +268,7 @@ void TwitchToken::SetToken(const std::string &value)
|
|||
SendGetRequest(*this, "https://api.twitch.tv", "/helix/users");
|
||||
if (res.status != 200) {
|
||||
blog(LOG_WARNING, "failed to get Twitch user id from token!");
|
||||
_userID = -1;
|
||||
_userID = {};
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -318,12 +320,35 @@ bool TwitchToken::IsValid(bool forceUpdate) const
|
|||
cli.Get("/oauth2/validate", httplib::Params{}, headers);
|
||||
_lastValidityCheckTime = std::chrono::system_clock::now();
|
||||
_lastValidityCheckValue = _token;
|
||||
_lastValidityCheckResult = response && response->status == 200;
|
||||
if (!_lastValidityCheckResult) {
|
||||
|
||||
if (!response || response->status != 200) {
|
||||
blog(LOG_INFO, "Twitch token %s is not valid!",
|
||||
_name.c_str());
|
||||
_lastValidityCheckResult = false;
|
||||
return false;
|
||||
}
|
||||
return _lastValidityCheckResult;
|
||||
|
||||
OBSDataAutoRelease replyData =
|
||||
obs_data_create_from_json(response->body.c_str());
|
||||
const char *id = obs_data_get_string(replyData, "user_id");
|
||||
if (!id) {
|
||||
blog(LOG_INFO,
|
||||
"Twitch token %s does validity check did not report user_id! Assume invalid!",
|
||||
_name.c_str());
|
||||
_lastValidityCheckResult = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_userID && _userID != id) {
|
||||
blog(LOG_INFO,
|
||||
"Twitch token %s does not match expected user (got %s, expected %s)!",
|
||||
_name.c_str(), id, _userID->c_str());
|
||||
_lastValidityCheckResult = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
_lastValidityCheckResult = true;
|
||||
return true;
|
||||
};
|
||||
|
||||
const bool tokenChanged = _lastValidityCheckValue != _token;
|
||||
|
|
@ -729,6 +754,7 @@ void TwitchTokenSettingsDialog::RequestToken()
|
|||
|
||||
auto scope = QString::fromStdString(
|
||||
generateScopeString(GetEnabledOptions()));
|
||||
_validationTimer.stop();
|
||||
_tokenGrabber.SetTokenScope(scope);
|
||||
_tokenGrabber.start();
|
||||
_tokenStatus->setText(obs_module_text(
|
||||
|
|
@ -766,6 +792,7 @@ void TwitchTokenSettingsDialog::GotToken(const std::optional<QString> &value)
|
|||
Q_ARG(const QString &, name));
|
||||
SetTokenInfoVisible(true);
|
||||
_requestToken->setEnabled(true);
|
||||
_validationTimer.start();
|
||||
}
|
||||
|
||||
std::set<TokenOption> TwitchTokenSettingsDialog::GetEnabledOptions()
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public:
|
|||
void SetToken(const std::string &);
|
||||
bool IsEmpty() const { return _token.empty(); }
|
||||
std::optional<std::string> GetToken() const;
|
||||
std::string GetUserID() const { return _userID; }
|
||||
std::optional<std::string> GetUserID() const { return _userID; }
|
||||
std::shared_ptr<EventSub> GetEventSub();
|
||||
bool ValidateTimestamps() const { return _validateEventSubTimestamps; }
|
||||
bool IsValid(bool forceUpdate = false) const;
|
||||
|
|
@ -65,7 +65,7 @@ private:
|
|||
mutable std::string _lastValidityCheckValue;
|
||||
mutable bool _lastValidityCheckResult = false;
|
||||
mutable std::chrono::system_clock::time_point _lastValidityCheckTime;
|
||||
std::string _userID;
|
||||
std::optional<std::string> _userID;
|
||||
std::set<TokenOption> _tokenOptions = TokenOption::GetAllTokenOptions();
|
||||
std::shared_ptr<EventSub> _eventSub;
|
||||
bool _validateEventSubTimestamps = false;
|
||||
|
|
|
|||
|
|
@ -185,6 +185,11 @@ static RequestResult processResult(const httplib::Result &response,
|
|||
return result;
|
||||
}
|
||||
|
||||
if (response->status < 200 || response->status >= 300) {
|
||||
vblog(LOG_INFO, "Twitch API error response: %s",
|
||||
response->body.c_str());
|
||||
}
|
||||
|
||||
OBSDataAutoRelease replyData =
|
||||
obs_data_create_from_json(response->body.c_str());
|
||||
result.data = replyData;
|
||||
|
|
@ -518,6 +523,13 @@ static RequestResult sendDeleteRequest(const TwitchToken &token,
|
|||
return processResult(response, __func__);
|
||||
}
|
||||
|
||||
RequestResult SendDeleteRequest(const TwitchToken &token,
|
||||
const std::string &uri, const std::string &path,
|
||||
const httplib::Params ¶ms)
|
||||
{
|
||||
return sendDeleteRequest(token, uri, path, params);
|
||||
}
|
||||
|
||||
void SetJsonTempVars(const std::string &jsonStr,
|
||||
std::function<void(const char *, const char *)> setVarFunc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ RequestResult SendPatchRequest(const TwitchToken &token, const std::string &uri,
|
|||
const httplib::Params ¶ms = {},
|
||||
const std::string &data = "",
|
||||
bool useCache = false);
|
||||
RequestResult SendDeleteRequest(const TwitchToken &token,
|
||||
const std::string &uri, const std::string &path,
|
||||
const httplib::Params ¶ms = {});
|
||||
|
||||
// Helper functions to set temp var values
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ static bool setup()
|
|||
AddSetupTabCallback("twitchConnectionTab",
|
||||
TwitchConnectionsTable::Create, setupTab);
|
||||
|
||||
static const auto showInvalidWarnings = []() {
|
||||
static const auto showInvalidWarnings = [](void *) {
|
||||
const auto invalidTokens = getInvalidTokens();
|
||||
for (const auto &token : invalidTokens) {
|
||||
QueueUITask(
|
||||
|
|
@ -47,24 +47,9 @@ static bool setup()
|
|||
// or crashing.
|
||||
// Therefore, we ask the user whether they want to update their Twitch
|
||||
// connections asynchronously.
|
||||
//
|
||||
// On macOS, an additional QTimer::singleShot wrapper is required for
|
||||
// this to work correctly.
|
||||
AddLoadStep([](obs_data_t *) {
|
||||
AddPostLoadStep([]() {
|
||||
#ifdef __APPLE__
|
||||
QTimer::singleShot(
|
||||
0,
|
||||
static_cast<QMainWindow *>(
|
||||
obs_frontend_get_main_window()),
|
||||
[]() {
|
||||
#endif
|
||||
showInvalidWarnings();
|
||||
|
||||
#ifdef __APPLE__
|
||||
});
|
||||
#endif
|
||||
});
|
||||
AddFinishedLoadingStep([]() {
|
||||
obs_queue_task(OBS_TASK_UI, showInvalidWarnings, nullptr,
|
||||
false);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
@ -168,6 +153,25 @@ static QStringList getCellLabels(TwitchToken *token, bool addName = true)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void updateConnectionStatus(QTableWidget *table)
|
||||
{
|
||||
for (int row = 0; row < table->rowCount(); row++) {
|
||||
auto item = table->item(row, 0);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto weakToken = GetWeakTwitchTokenByQString(item->text());
|
||||
auto token = weakToken.lock();
|
||||
if (!token) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UpdateItemTableRow(table, row,
|
||||
getCellLabels(token.get(), false));
|
||||
}
|
||||
}
|
||||
|
||||
static void openSettingsDialog()
|
||||
{
|
||||
auto selectedRows =
|
||||
|
|
@ -189,6 +193,7 @@ static void openSettingsDialog()
|
|||
|
||||
TwitchTokenSettingsDialog::AskForSettings(GetSettingsWindow(),
|
||||
*token.get());
|
||||
updateConnectionStatus(tabWidget->Table());
|
||||
}
|
||||
|
||||
static const QStringList headers =
|
||||
|
|
@ -217,25 +222,6 @@ TwitchConnectionsTable::TwitchConnectionsTable(QTabWidget *parent)
|
|||
SetHelpVisible(GetTwitchTokens().empty());
|
||||
}
|
||||
|
||||
static void updateConnectionStatus(QTableWidget *table)
|
||||
{
|
||||
for (int row = 0; row < table->rowCount(); row++) {
|
||||
auto item = table->item(row, 0);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto weakToken = GetWeakTwitchTokenByQString(item->text());
|
||||
auto token = weakToken.lock();
|
||||
if (!token) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UpdateItemTableRow(table, row,
|
||||
getCellLabels(token.get(), false));
|
||||
}
|
||||
}
|
||||
|
||||
static QStringList getInvalidTokens()
|
||||
{
|
||||
QStringList tokens;
|
||||
|
|
|
|||
|
|
@ -273,15 +273,18 @@ void MacroConditionVideo::SetCondition(VideoCondition condition)
|
|||
bool MacroConditionVideo::ScreenshotContainsPattern()
|
||||
{
|
||||
cv::Mat result;
|
||||
MatchPattern(_screenshotData.GetImage(), _patternImageData,
|
||||
_patternMatchParameters.threshold, result, nullptr,
|
||||
_patternMatchParameters.useAlphaAsMask,
|
||||
_patternMatchParameters.matchMode);
|
||||
double bestMatchValue =
|
||||
MatchPattern(_screenshotData.GetImage(), _patternImageData,
|
||||
_patternMatchParameters.threshold, result,
|
||||
_patternMatchParameters.useAlphaAsMask,
|
||||
_patternMatchParameters.matchMode);
|
||||
if (result.total() == 0) {
|
||||
SetTempVarValue("similarity", std::to_string(bestMatchValue));
|
||||
SetTempVarValue("patternCount", "0");
|
||||
return false;
|
||||
}
|
||||
const auto count = countNonZero(result);
|
||||
SetTempVarValue("similarity", std::to_string(bestMatchValue));
|
||||
SetTempVarValue("patternCount", std::to_string(count));
|
||||
return count > 0;
|
||||
}
|
||||
|
|
@ -304,10 +307,12 @@ bool MacroConditionVideo::OutputChanged()
|
|||
|
||||
cv::Mat result;
|
||||
_patternImageData = CreatePatternData(_matchImage);
|
||||
MatchPattern(_screenshotData.GetImage(), _patternImageData,
|
||||
_patternMatchParameters.threshold, result, nullptr,
|
||||
_patternMatchParameters.useAlphaAsMask,
|
||||
_patternMatchParameters.matchMode);
|
||||
double bestMatchValue =
|
||||
MatchPattern(_screenshotData.GetImage(), _patternImageData,
|
||||
_patternMatchParameters.threshold, result,
|
||||
_patternMatchParameters.useAlphaAsMask,
|
||||
_patternMatchParameters.matchMode);
|
||||
SetTempVarValue("similarity", std::to_string(bestMatchValue));
|
||||
if (result.total() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -411,7 +416,25 @@ void MacroConditionVideo::SetupTempVars()
|
|||
{
|
||||
MacroCondition::SetupTempVars();
|
||||
switch (_condition) {
|
||||
case VideoCondition::HAS_CHANGED:
|
||||
case VideoCondition::HAS_NOT_CHANGED:
|
||||
if (!_patternMatchParameters.useForChangedCheck) {
|
||||
break;
|
||||
}
|
||||
AddTempvar(
|
||||
"similarity",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.video.similarity"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.video.similarity.description"));
|
||||
break;
|
||||
case VideoCondition::PATTERN:
|
||||
AddTempvar(
|
||||
"similarity",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.video.similarity"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.video.similarity.description"));
|
||||
AddTempvar(
|
||||
"patternCount",
|
||||
obs_module_text(
|
||||
|
|
@ -451,8 +474,6 @@ void MacroConditionVideo::SetupTempVars()
|
|||
break;
|
||||
case VideoCondition::MATCH:
|
||||
case VideoCondition::DIFFER:
|
||||
case VideoCondition::HAS_NOT_CHANGED:
|
||||
case VideoCondition::HAS_CHANGED:
|
||||
case VideoCondition::NO_IMAGE:
|
||||
default:
|
||||
break;
|
||||
|
|
@ -1477,6 +1498,7 @@ void MacroConditionVideoEdit::UsePatternForChangedCheckChanged(int value)
|
|||
{
|
||||
GUARD_LOADING_AND_LOCK();
|
||||
_entryData->_patternMatchParameters.useForChangedCheck = value;
|
||||
_entryData->SetupTempVars();
|
||||
SetWidgetVisibility();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public:
|
|||
|
||||
void SetCondition(VideoCondition);
|
||||
VideoCondition GetCondition() const { return _condition; }
|
||||
void SetupTempVars();
|
||||
|
||||
VideoInput _video;
|
||||
std::string _file = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
|
|
@ -89,8 +90,6 @@ private:
|
|||
bool Compare();
|
||||
bool CheckShouldBeSkipped();
|
||||
|
||||
void SetupTempVars();
|
||||
|
||||
VideoCondition _condition = VideoCondition::MATCH;
|
||||
|
||||
bool _getNextScreenshot = true;
|
||||
|
|
|
|||
|
|
@ -48,20 +48,18 @@ static void preprocessPatternMatchResult(cv::Mat &mat, bool invert)
|
|||
}
|
||||
}
|
||||
|
||||
void MatchPattern(QImage &img, const PatternImageData &patternData,
|
||||
double threshold, cv::Mat &result, double *pBestFitValue,
|
||||
bool useAlphaAsMask, cv::TemplateMatchModes matchMode)
|
||||
double MatchPattern(QImage &img, const PatternImageData &patternData,
|
||||
double threshold, cv::Mat &result, bool useAlphaAsMask,
|
||||
cv::TemplateMatchModes matchMode)
|
||||
{
|
||||
double bestFitValue = std::numeric_limits<double>::signaling_NaN();
|
||||
result = cv::Mat(0, 0, CV_32F);
|
||||
if (pBestFitValue) {
|
||||
*pBestFitValue = std::numeric_limits<double>::signaling_NaN();
|
||||
}
|
||||
if (img.isNull() || patternData.rgbaPattern.empty()) {
|
||||
return;
|
||||
return bestFitValue;
|
||||
}
|
||||
if (img.height() < patternData.rgbaPattern.rows ||
|
||||
img.width() < patternData.rgbaPattern.cols) {
|
||||
return;
|
||||
return bestFitValue;
|
||||
}
|
||||
|
||||
auto input = QImageToMat(img);
|
||||
|
|
@ -94,20 +92,18 @@ void MatchPattern(QImage &img, const PatternImageData &patternData,
|
|||
// -> Invert TM_SQDIFF_NORMED in the preprocess step
|
||||
preprocessPatternMatchResult(result, matchMode == cv::TM_SQDIFF_NORMED);
|
||||
|
||||
if (pBestFitValue) {
|
||||
cv::minMaxLoc(result, nullptr, pBestFitValue);
|
||||
}
|
||||
|
||||
cv::minMaxLoc(result, nullptr, &bestFitValue);
|
||||
cv::threshold(result, result, threshold, 0.0, cv::THRESH_TOZERO);
|
||||
return bestFitValue;
|
||||
}
|
||||
|
||||
void MatchPattern(QImage &img, QImage &pattern, double threshold,
|
||||
cv::Mat &result, double *pBestFitValue, bool useAlphaAsMask,
|
||||
cv::TemplateMatchModes matchColor)
|
||||
double MatchPattern(QImage &img, QImage &pattern, double threshold,
|
||||
cv::Mat &result, bool useAlphaAsMask,
|
||||
cv::TemplateMatchModes matchColor)
|
||||
{
|
||||
auto data = CreatePatternData(pattern);
|
||||
MatchPattern(img, data, threshold, result, pBestFitValue,
|
||||
useAlphaAsMask, matchColor);
|
||||
return MatchPattern(img, data, threshold, result, useAlphaAsMask,
|
||||
matchColor);
|
||||
}
|
||||
|
||||
std::vector<cv::Rect> MatchObject(QImage &img, cv::CascadeClassifier &cascade,
|
||||
|
|
|
|||
|
|
@ -62,12 +62,12 @@ struct PatternImageData {
|
|||
};
|
||||
|
||||
PatternImageData CreatePatternData(const QImage &pattern);
|
||||
void MatchPattern(QImage &img, const PatternImageData &patternData,
|
||||
double threshold, cv::Mat &result, double *pBestFitValue,
|
||||
bool useAlphaAsMask, cv::TemplateMatchModes matchMode);
|
||||
void MatchPattern(QImage &img, QImage &pattern, double threshold,
|
||||
cv::Mat &result, double *pBestFitValue, bool useAlphaAsMask,
|
||||
cv::TemplateMatchModes matchMode);
|
||||
double MatchPattern(QImage &img, const PatternImageData &patternData,
|
||||
double threshold, cv::Mat &result, bool useAlphaAsMask,
|
||||
cv::TemplateMatchModes matchMode);
|
||||
double MatchPattern(QImage &img, QImage &pattern, double threshold,
|
||||
cv::Mat &result, bool useAlphaAsMask,
|
||||
cv::TemplateMatchModes matchMode);
|
||||
std::vector<cv::Rect> MatchObject(QImage &img, cv::CascadeClassifier &cascade,
|
||||
double scaleFactor, int minNeighbors,
|
||||
const cv::Size &minSize,
|
||||
|
|
|
|||
|
|
@ -329,10 +329,10 @@ void PreviewImage::MarkPatternMatch(
|
|||
const PatternImageData &patternImageData)
|
||||
{
|
||||
cv::Mat result;
|
||||
double matchValue = std::numeric_limits<double>::signaling_NaN();
|
||||
MatchPattern(screenshot, patternImageData, patternMatchParams.threshold,
|
||||
result, &matchValue, patternMatchParams.useAlphaAsMask,
|
||||
patternMatchParams.matchMode);
|
||||
double matchValue = MatchPattern(screenshot, patternImageData,
|
||||
patternMatchParams.threshold, result,
|
||||
patternMatchParams.useAlphaAsMask,
|
||||
patternMatchParams.matchMode);
|
||||
emit ValueUpdate(matchValue);
|
||||
if (result.total() == 0 || countNonZero(result) == 0) {
|
||||
emit StatusUpdate(obs_module_text(
|
||||
|
|
|
|||
|
|
@ -1,22 +1,27 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
project(advanced-scene-switcher-tests)
|
||||
|
||||
get_target_property(ADVSS_SOURCE_DIR advanced-scene-switcher-lib SOURCE_DIR)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE UNIT_TEST)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE UNIT_TEST
|
||||
ADVSS_EXPORT_SYMBOLS=1)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
|
||||
|
||||
target_sources(
|
||||
${PROJECT_NAME} PRIVATE test-main.cpp mocks/obs-data.cpp
|
||||
mocks/path-helpers.cpp mocks/ui-helpers.cpp)
|
||||
target_sources(${PROJECT_NAME} PRIVATE test-main.cpp)
|
||||
|
||||
get_target_property(ADVSS_SOURCE_DIR advanced-scene-switcher-lib SOURCE_DIR)
|
||||
get_target_property(ADVSS_BINARY_DIR advanced-scene-switcher-lib BINARY_DIR)
|
||||
|
||||
target_include_directories(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE mocks ${ADVSS_SOURCE_DIR}/lib/utils ${ADVSS_SOURCE_DIR}/lib/variables
|
||||
PRIVATE ${ADVSS_SOURCE_DIR}/lib ${ADVSS_SOURCE_DIR}/lib/macro
|
||||
${ADVSS_SOURCE_DIR}/lib/utils ${ADVSS_SOURCE_DIR}/lib/variables
|
||||
${ADVSS_SOURCE_DIR}/plugins/base/utils)
|
||||
|
||||
# --- Qt --- #
|
||||
setup_obs_lib_dependency(${PROJECT_NAME})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Qt::Core Qt::Widgets)
|
||||
# --- Qt --- #
|
||||
|
||||
if(TARGET Qt6::Core)
|
||||
set(_QT_VERSION
|
||||
|
|
@ -28,25 +33,26 @@ elseif(TARGET Qt5::Core)
|
|||
CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
macro(add_qt_lib lib_name)
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_FILE:Qt${_QT_VERSION}::${lib_name}>
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
|
||||
endmacro()
|
||||
# Include autogen headers so that generated ui_*.h files are found
|
||||
target_include_directories(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE "${ADVSS_BINARY_DIR}/advanced-scene-switcher-lib_autogen/include")
|
||||
foreach(_conf Release RelWithDebInfo Debug MinSizeRe)
|
||||
target_include_directories(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
"${ADVSS_BINARY_DIR}/advanced-scene-switcher-lib_autogen/include_${_conf}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
add_qt_lib(Core)
|
||||
add_qt_lib(Gui)
|
||||
add_qt_lib(Widgets)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Qt::Core Qt::Widgets)
|
||||
|
||||
set_target_properties(
|
||||
${PROJECT_NAME}
|
||||
PROPERTIES AUTOMOC ON
|
||||
AUTOUIC ON
|
||||
AUTORCC ON)
|
||||
AUTORCC ON
|
||||
AUTOUIC_SEARCH_PATHS "${ADVSS_SOURCE_DIR}/forms")
|
||||
|
||||
# --- condition-logic --- #
|
||||
|
||||
|
|
@ -83,12 +89,11 @@ target_include_directories(${PROJECT_NAME}
|
|||
PRIVATE ${ADVSS_SOURCE_DIR}/deps/exprtk)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC /MP /d2FH4- /wd4267 /wd4267
|
||||
/bigobj)
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC /MP /d2FH4- /wd4267 /bigobj)
|
||||
else()
|
||||
target_compile_options(
|
||||
${PROJECT_NAME} PUBLIC -Wno-error=unused-parameter -Wno-error=conversion
|
||||
-Wno-error=unused-value)
|
||||
-Wno-error=unused-value -Wno-error=unused-variable)
|
||||
endif()
|
||||
|
||||
# --- regex --- #
|
||||
|
|
@ -122,6 +127,107 @@ target_sources(
|
|||
${ADVSS_SOURCE_DIR}/lib/utils/resizing-text-edit.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/variables/variable.cpp)
|
||||
|
||||
# --- #
|
||||
# --- macro / macro-condition --- #
|
||||
|
||||
target_sources(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE test-macro.cpp
|
||||
test-macro-condition.cpp
|
||||
stubs/path-helpers.cpp
|
||||
stubs/ui-helpers.cpp
|
||||
stubs/plugin-state-helpers.cpp
|
||||
stubs/macro-action-macro.cpp
|
||||
stubs/macro-edit.cpp
|
||||
stubs/macro-dock-settings.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/temp-variable.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/sync-helpers.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/help-icon.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/auto-update-tooltip-label.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/duration-control.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/duration-control.hpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/duration-modifier.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/duration-modifier.hpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/duration.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/duration.hpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/list-controls.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/list-editor.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/layout-helpers.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/log-helper.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/mouse-wheel-guard.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/section.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/splitter-helpers.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/resizable-widget.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/string-list.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-action.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-action-macro.hpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-action-factory.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-condition.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-condition-factory.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-edit.hpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-helpers.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-input.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-ref.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-segment.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-selection.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro-signals.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/macro/macro.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/variables/variable-line-edit.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/variables/variable-spinbox.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/variables/variable-string.cpp)
|
||||
|
||||
# --- Testing --- #
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
|
||||
|
||||
if(WIN32)
|
||||
# Copy all CMake-known transitive DLLs (Qt, OBS, etc.) next to the binary.
|
||||
# This makes the test executable runnable directly without PATH changes.
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
COMMAND_EXPAND_LISTS)
|
||||
|
||||
# Copy remaining OBS deps (zlib, srt, librist, ffmpeg, etc.) that are not
|
||||
# CMake targets but are required at runtime. Derive the path from ZLIB::ZLIB
|
||||
# which lives in the same deps directory.
|
||||
get_target_property(_zlib_lib ZLIB::ZLIB IMPORTED_LOCATION_RELWITHDEBINFO)
|
||||
if(NOT _zlib_lib)
|
||||
get_target_property(_zlib_lib ZLIB::ZLIB IMPORTED_LOCATION_RELEASE)
|
||||
endif()
|
||||
if(_zlib_lib)
|
||||
get_filename_component(_obs_deps_bin "${_zlib_lib}" DIRECTORY)
|
||||
get_filename_component(_obs_deps_bin "${_obs_deps_bin}/../bin" ABSOLUTE)
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${_obs_deps_bin}"
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
|
||||
else()
|
||||
message(
|
||||
WARNING "Could not determine OBS deps bin directory from ZLIB::ZLIB - "
|
||||
"some DLLs may be missing at runtime")
|
||||
endif()
|
||||
|
||||
elseif(APPLE)
|
||||
# On macOS, binaries use RPATH so copying is usually not needed. Fall back to
|
||||
# DYLD_LIBRARY_PATH in case RPATH is not set correctly.
|
||||
set_tests_properties(
|
||||
${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
ENVIRONMENT
|
||||
"DYLD_LIBRARY_PATH=$<TARGET_FILE_DIR:OBS::libobs>:$<TARGET_FILE_DIR:Qt${_QT_VERSION}::Core>"
|
||||
)
|
||||
|
||||
else()
|
||||
# On Linux, same approach using LD_LIBRARY_PATH.
|
||||
set_tests_properties(
|
||||
${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
ENVIRONMENT
|
||||
"LD_LIBRARY_PATH=$<TARGET_FILE_DIR:OBS::libobs>:$<TARGET_FILE_DIR:Qt${_QT_VERSION}::Core>"
|
||||
)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1,502 +0,0 @@
|
|||
#include "obs-data.h"
|
||||
|
||||
struct obs_data_item {};
|
||||
|
||||
struct obs_data {};
|
||||
|
||||
struct obs_data_array {};
|
||||
|
||||
struct obs_data_number {};
|
||||
|
||||
obs_data_t *obs_data_create()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_create_from_json(const char *json_string)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_create_from_json_file(const char *json_file)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_create_from_json_file_safe(const char *json_file,
|
||||
const char *backup_ext)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void obs_data_addref(obs_data_t *data) {}
|
||||
|
||||
void obs_data_release(obs_data_t *data) {}
|
||||
|
||||
const char *obs_data_get_json(obs_data_t *data)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *obs_data_get_json_pretty(obs_data_t *data)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *obs_data_get_last_json(obs_data_t *data)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
bool obs_data_save_json(obs_data_t *data, const char *file)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool obs_data_save_json_safe(obs_data_t *data, const char *file,
|
||||
const char *temp_ext, const char *backup_ext)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool obs_data_save_json_pretty_safe(obs_data_t *data, const char *file,
|
||||
const char *temp_ext,
|
||||
const char *backup_ext)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_get_defaults(obs_data_t *data)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void obs_data_apply(obs_data_t *target, obs_data_t *apply_data) {}
|
||||
|
||||
void obs_data_erase(obs_data_t *data, const char *name) {}
|
||||
|
||||
void obs_data_clear(obs_data_t *target) {}
|
||||
|
||||
void obs_data_set_string(obs_data_t *data, const char *name, const char *val) {}
|
||||
|
||||
void obs_data_set_int(obs_data_t *data, const char *name, long long val) {}
|
||||
|
||||
void obs_data_set_double(obs_data_t *data, const char *name, double val) {}
|
||||
|
||||
void obs_data_set_bool(obs_data_t *data, const char *name, bool val) {}
|
||||
|
||||
void obs_data_set_obj(obs_data_t *data, const char *name, obs_data_t *obj) {}
|
||||
|
||||
void obs_data_set_array(obs_data_t *data, const char *name,
|
||||
obs_data_array_t *array)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_default_string(obs_data_t *data, const char *name,
|
||||
const char *val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_default_int(obs_data_t *data, const char *name, long long val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_default_double(obs_data_t *data, const char *name, double val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_default_bool(obs_data_t *data, const char *name, bool val) {}
|
||||
|
||||
void obs_data_set_default_obj(obs_data_t *data, const char *name,
|
||||
obs_data_t *obj)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_default_array(obs_data_t *data, const char *name,
|
||||
obs_data_array_t *arr)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_autoselect_string(obs_data_t *data, const char *name,
|
||||
const char *val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_autoselect_int(obs_data_t *data, const char *name,
|
||||
long long val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_autoselect_double(obs_data_t *data, const char *name,
|
||||
double val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_autoselect_bool(obs_data_t *data, const char *name, bool val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_autoselect_obj(obs_data_t *data, const char *name,
|
||||
obs_data_t *obj)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_set_autoselect_array(obs_data_t *data, const char *name,
|
||||
obs_data_array_t *arr)
|
||||
{
|
||||
}
|
||||
|
||||
const char *obs_data_get_string(obs_data_t *data, const char *name)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
long long obs_data_get_int(obs_data_t *data, const char *name)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double obs_data_get_double(obs_data_t *data, const char *name)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool obs_data_get_bool(obs_data_t *data, const char *name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_get_obj(obs_data_t *data, const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_array_t *obs_data_get_array(obs_data_t *data, const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *obs_data_get_default_string(obs_data_t *data, const char *name)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
long long obs_data_get_default_int(obs_data_t *data, const char *name)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double obs_data_get_default_double(obs_data_t *data, const char *name)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool obs_data_get_default_bool(obs_data_t *data, const char *name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_get_default_obj(obs_data_t *data, const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_array_t *obs_data_get_default_array(obs_data_t *data, const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *obs_data_get_autoselect_string(obs_data_t *data, const char *name)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
long long obs_data_get_autoselect_int(obs_data_t *data, const char *name)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double obs_data_get_autoselect_double(obs_data_t *data, const char *name)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool obs_data_get_autoselect_bool(obs_data_t *data, const char *name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_get_autoselect_obj(obs_data_t *data, const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_array_t *obs_data_get_autoselect_array(obs_data_t *data,
|
||||
const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_array_t *obs_data_array_create()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void obs_data_array_addref(obs_data_array_t *array) {}
|
||||
|
||||
void obs_data_array_release(obs_data_array_t *array) {}
|
||||
|
||||
size_t obs_data_array_count(obs_data_array_t *array)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_array_item(obs_data_array_t *array, size_t idx)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t obs_data_array_push_back(obs_data_array_t *array, obs_data_t *obj)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void obs_data_array_insert(obs_data_array_t *array, size_t idx, obs_data_t *obj)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_array_push_back_array(obs_data_array_t *array,
|
||||
obs_data_array_t *array2)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_array_erase(obs_data_array_t *array, size_t idx) {}
|
||||
|
||||
void obs_data_array_enum(obs_data_array_t *array,
|
||||
void (*cb)(obs_data_t *data, void *param), void *param)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Item status inspection */
|
||||
|
||||
bool obs_data_has_user_value(obs_data_t *data, const char *name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool obs_data_has_default_value(obs_data_t *data, const char *name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool obs_data_has_autoselect_value(obs_data_t *data, const char *name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool obs_data_item_has_user_value(obs_data_item_t *item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool obs_data_item_has_default_value(obs_data_item_t *item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool obs_data_item_has_autoselect_value(obs_data_item_t *item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Clearing data values */
|
||||
|
||||
void obs_data_unset_user_value(obs_data_t *data, const char *name) {}
|
||||
|
||||
void obs_data_unset_default_value(obs_data_t *data, const char *name) {}
|
||||
|
||||
void obs_data_unset_autoselect_value(obs_data_t *data, const char *name) {}
|
||||
|
||||
void obs_data_item_unset_user_value(obs_data_item_t *item) {}
|
||||
|
||||
void obs_data_item_unset_default_value(obs_data_item_t *item) {}
|
||||
|
||||
void obs_data_item_unset_autoselect_value(obs_data_item_t *item) {}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Item iteration */
|
||||
|
||||
obs_data_item_t *obs_data_first(obs_data_t *data)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_item_t *obs_data_item_byname(obs_data_t *data, const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool obs_data_item_next(obs_data_item_t **item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void obs_data_item_release(obs_data_item_t **item) {}
|
||||
|
||||
void obs_data_item_remove(obs_data_item_t **item) {}
|
||||
|
||||
enum obs_data_type obs_data_item_gettype(obs_data_item_t *item)
|
||||
{
|
||||
return OBS_DATA_NULL;
|
||||
}
|
||||
|
||||
enum obs_data_number_type obs_data_item_numtype(obs_data_item_t *item)
|
||||
{
|
||||
return OBS_DATA_NUM_INVALID;
|
||||
}
|
||||
|
||||
const char *obs_data_item_get_name(obs_data_item_t *item)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void obs_data_item_set_string(obs_data_item_t **item, const char *val) {}
|
||||
|
||||
void obs_data_item_set_int(obs_data_item_t **item, long long val) {}
|
||||
|
||||
void obs_data_item_set_double(obs_data_item_t **item, double val) {}
|
||||
|
||||
void obs_data_item_set_bool(obs_data_item_t **item, bool val) {}
|
||||
|
||||
void obs_data_item_set_obj(obs_data_item_t **item, obs_data_t *val) {}
|
||||
|
||||
void obs_data_item_set_array(obs_data_item_t **item, obs_data_array_t *val) {}
|
||||
|
||||
void obs_data_item_set_default_string(obs_data_item_t **item, const char *val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_item_set_default_int(obs_data_item_t **item, long long val) {}
|
||||
|
||||
void obs_data_item_set_default_double(obs_data_item_t **item, double val) {}
|
||||
|
||||
void obs_data_item_set_default_bool(obs_data_item_t **item, bool val) {}
|
||||
|
||||
void obs_data_item_set_default_obj(obs_data_item_t **item, obs_data_t *val) {}
|
||||
|
||||
void obs_data_item_set_default_array(obs_data_item_t **item,
|
||||
obs_data_array_t *val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_item_set_autoselect_string(obs_data_item_t **item,
|
||||
const char *val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_item_set_autoselect_int(obs_data_item_t **item, long long val) {}
|
||||
|
||||
void obs_data_item_set_autoselect_double(obs_data_item_t **item, double val) {}
|
||||
|
||||
void obs_data_item_set_autoselect_bool(obs_data_item_t **item, bool val) {}
|
||||
|
||||
void obs_data_item_set_autoselect_obj(obs_data_item_t **item, obs_data_t *val)
|
||||
{
|
||||
}
|
||||
|
||||
void obs_data_item_set_autoselect_array(obs_data_item_t **item,
|
||||
obs_data_array_t *val)
|
||||
{
|
||||
}
|
||||
|
||||
const char *obs_data_item_get_string(obs_data_item_t *item)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
long long obs_data_item_get_int(obs_data_item_t *item)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double obs_data_item_get_double(obs_data_item_t *item)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool obs_data_item_get_bool(obs_data_item_t *item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_item_get_obj(obs_data_item_t *item)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_array_t *obs_data_item_get_array(obs_data_item_t *item)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *obs_data_item_get_default_string(obs_data_item_t *item)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
long long obs_data_item_get_default_int(obs_data_item_t *item)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double obs_data_item_get_default_double(obs_data_item_t *item)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool obs_data_item_get_default_bool(obs_data_item_t *item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_item_get_default_obj(obs_data_item_t *item)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_array_t *obs_data_item_get_default_array(obs_data_item_t *item)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *obs_data_item_get_autoselect_string(obs_data_item_t *item)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
long long obs_data_item_get_autoselect_int(obs_data_item_t *item)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double obs_data_item_get_autoselect_double(obs_data_item_t *item)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool obs_data_item_get_autoselect_bool(obs_data_item_t *item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_data_t *obs_data_item_get_autoselect_obj(obs_data_item_t *item)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_array_t *obs_data_item_get_autoselect_array(obs_data_item_t *item)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -1,253 +0,0 @@
|
|||
#pragma once
|
||||
#include "export-symbol-helper.hpp"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct obs_data;
|
||||
struct obs_data_item;
|
||||
struct obs_data_array;
|
||||
typedef struct obs_data obs_data_t;
|
||||
typedef struct obs_data_item obs_data_item_t;
|
||||
typedef struct obs_data_array obs_data_array_t;
|
||||
|
||||
enum obs_data_type {
|
||||
OBS_DATA_NULL,
|
||||
OBS_DATA_STRING,
|
||||
OBS_DATA_NUMBER,
|
||||
OBS_DATA_BOOLEAN,
|
||||
OBS_DATA_OBJECT,
|
||||
OBS_DATA_ARRAY
|
||||
};
|
||||
|
||||
enum obs_data_number_type {
|
||||
OBS_DATA_NUM_INVALID,
|
||||
OBS_DATA_NUM_INT,
|
||||
OBS_DATA_NUM_DOUBLE
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Main usage functions */
|
||||
|
||||
EXPORT obs_data_t *obs_data_create();
|
||||
EXPORT obs_data_t *obs_data_create_from_json(const char *json_string);
|
||||
EXPORT obs_data_t *obs_data_create_from_json_file(const char *json_file);
|
||||
EXPORT obs_data_t *obs_data_create_from_json_file_safe(const char *json_file,
|
||||
const char *backup_ext);
|
||||
EXPORT void obs_data_addref(obs_data_t *data);
|
||||
EXPORT void obs_data_release(obs_data_t *data);
|
||||
|
||||
EXPORT const char *obs_data_get_json(obs_data_t *data);
|
||||
EXPORT const char *obs_data_get_json_pretty(obs_data_t *data);
|
||||
EXPORT const char *obs_data_get_last_json(obs_data_t *data);
|
||||
EXPORT bool obs_data_save_json(obs_data_t *data, const char *file);
|
||||
EXPORT bool obs_data_save_json_safe(obs_data_t *data, const char *file,
|
||||
const char *temp_ext,
|
||||
const char *backup_ext);
|
||||
EXPORT bool obs_data_save_json_pretty_safe(obs_data_t *data, const char *file,
|
||||
const char *temp_ext,
|
||||
const char *backup_ext);
|
||||
|
||||
EXPORT void obs_data_apply(obs_data_t *target, obs_data_t *apply_data);
|
||||
|
||||
EXPORT void obs_data_erase(obs_data_t *data, const char *name);
|
||||
EXPORT void obs_data_clear(obs_data_t *data);
|
||||
|
||||
/* Set functions */
|
||||
EXPORT void obs_data_set_string(obs_data_t *data, const char *name,
|
||||
const char *val);
|
||||
EXPORT void obs_data_set_int(obs_data_t *data, const char *name, long long val);
|
||||
EXPORT void obs_data_set_double(obs_data_t *data, const char *name, double val);
|
||||
EXPORT void obs_data_set_bool(obs_data_t *data, const char *name, bool val);
|
||||
EXPORT void obs_data_set_obj(obs_data_t *data, const char *name,
|
||||
obs_data_t *obj);
|
||||
EXPORT void obs_data_set_array(obs_data_t *data, const char *name,
|
||||
obs_data_array_t *array);
|
||||
|
||||
/*
|
||||
* Creates an obs_data_t * filled with all default values.
|
||||
*/
|
||||
EXPORT obs_data_t *obs_data_get_defaults(obs_data_t *data);
|
||||
|
||||
/*
|
||||
* Default value functions.
|
||||
*/
|
||||
EXPORT void obs_data_set_default_string(obs_data_t *data, const char *name,
|
||||
const char *val);
|
||||
EXPORT void obs_data_set_default_int(obs_data_t *data, const char *name,
|
||||
long long val);
|
||||
EXPORT void obs_data_set_default_double(obs_data_t *data, const char *name,
|
||||
double val);
|
||||
EXPORT void obs_data_set_default_bool(obs_data_t *data, const char *name,
|
||||
bool val);
|
||||
EXPORT void obs_data_set_default_obj(obs_data_t *data, const char *name,
|
||||
obs_data_t *obj);
|
||||
EXPORT void obs_data_set_default_array(obs_data_t *data, const char *name,
|
||||
obs_data_array_t *arr);
|
||||
|
||||
/*
|
||||
* Application overrides
|
||||
* Use these to communicate the actual values of settings in case the user
|
||||
* settings aren't appropriate
|
||||
*/
|
||||
EXPORT void obs_data_set_autoselect_string(obs_data_t *data, const char *name,
|
||||
const char *val);
|
||||
EXPORT void obs_data_set_autoselect_int(obs_data_t *data, const char *name,
|
||||
long long val);
|
||||
EXPORT void obs_data_set_autoselect_double(obs_data_t *data, const char *name,
|
||||
double val);
|
||||
EXPORT void obs_data_set_autoselect_bool(obs_data_t *data, const char *name,
|
||||
bool val);
|
||||
EXPORT void obs_data_set_autoselect_obj(obs_data_t *data, const char *name,
|
||||
obs_data_t *obj);
|
||||
EXPORT void obs_data_set_autoselect_array(obs_data_t *data, const char *name,
|
||||
obs_data_array_t *arr);
|
||||
|
||||
/*
|
||||
* Get functions
|
||||
*/
|
||||
EXPORT const char *obs_data_get_string(obs_data_t *data, const char *name);
|
||||
EXPORT long long obs_data_get_int(obs_data_t *data, const char *name);
|
||||
EXPORT double obs_data_get_double(obs_data_t *data, const char *name);
|
||||
EXPORT bool obs_data_get_bool(obs_data_t *data, const char *name);
|
||||
EXPORT obs_data_t *obs_data_get_obj(obs_data_t *data, const char *name);
|
||||
EXPORT obs_data_array_t *obs_data_get_array(obs_data_t *data, const char *name);
|
||||
|
||||
EXPORT const char *obs_data_get_default_string(obs_data_t *data,
|
||||
const char *name);
|
||||
EXPORT long long obs_data_get_default_int(obs_data_t *data, const char *name);
|
||||
EXPORT double obs_data_get_default_double(obs_data_t *data, const char *name);
|
||||
EXPORT bool obs_data_get_default_bool(obs_data_t *data, const char *name);
|
||||
EXPORT obs_data_t *obs_data_get_default_obj(obs_data_t *data, const char *name);
|
||||
EXPORT obs_data_array_t *obs_data_get_default_array(obs_data_t *data,
|
||||
const char *name);
|
||||
|
||||
EXPORT const char *obs_data_get_autoselect_string(obs_data_t *data,
|
||||
const char *name);
|
||||
EXPORT long long obs_data_get_autoselect_int(obs_data_t *data,
|
||||
const char *name);
|
||||
EXPORT double obs_data_get_autoselect_double(obs_data_t *data,
|
||||
const char *name);
|
||||
EXPORT bool obs_data_get_autoselect_bool(obs_data_t *data, const char *name);
|
||||
EXPORT obs_data_t *obs_data_get_autoselect_obj(obs_data_t *data,
|
||||
const char *name);
|
||||
EXPORT obs_data_array_t *obs_data_get_autoselect_array(obs_data_t *data,
|
||||
const char *name);
|
||||
|
||||
/* Array functions */
|
||||
EXPORT obs_data_array_t *obs_data_array_create();
|
||||
EXPORT void obs_data_array_addref(obs_data_array_t *array);
|
||||
EXPORT void obs_data_array_release(obs_data_array_t *array);
|
||||
|
||||
EXPORT size_t obs_data_array_count(obs_data_array_t *array);
|
||||
EXPORT obs_data_t *obs_data_array_item(obs_data_array_t *array, size_t idx);
|
||||
EXPORT size_t obs_data_array_push_back(obs_data_array_t *array,
|
||||
obs_data_t *obj);
|
||||
EXPORT void obs_data_array_insert(obs_data_array_t *array, size_t idx,
|
||||
obs_data_t *obj);
|
||||
EXPORT void obs_data_array_push_back_array(obs_data_array_t *array,
|
||||
obs_data_array_t *array2);
|
||||
EXPORT void obs_data_array_erase(obs_data_array_t *array, size_t idx);
|
||||
EXPORT void obs_data_array_enum(obs_data_array_t *array,
|
||||
void (*cb)(obs_data_t *data, void *param),
|
||||
void *param);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Item status inspection */
|
||||
|
||||
EXPORT bool obs_data_has_user_value(obs_data_t *data, const char *name);
|
||||
EXPORT bool obs_data_has_default_value(obs_data_t *data, const char *name);
|
||||
EXPORT bool obs_data_has_autoselect_value(obs_data_t *data, const char *name);
|
||||
|
||||
EXPORT bool obs_data_item_has_user_value(obs_data_item_t *data);
|
||||
EXPORT bool obs_data_item_has_default_value(obs_data_item_t *data);
|
||||
EXPORT bool obs_data_item_has_autoselect_value(obs_data_item_t *data);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Clearing data values */
|
||||
|
||||
EXPORT void obs_data_unset_user_value(obs_data_t *data, const char *name);
|
||||
EXPORT void obs_data_unset_default_value(obs_data_t *data, const char *name);
|
||||
EXPORT void obs_data_unset_autoselect_value(obs_data_t *data, const char *name);
|
||||
|
||||
EXPORT void obs_data_item_unset_user_value(obs_data_item_t *data);
|
||||
EXPORT void obs_data_item_unset_default_value(obs_data_item_t *data);
|
||||
EXPORT void obs_data_item_unset_autoselect_value(obs_data_item_t *data);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Item iteration */
|
||||
|
||||
EXPORT obs_data_item_t *obs_data_first(obs_data_t *data);
|
||||
EXPORT obs_data_item_t *obs_data_item_byname(obs_data_t *data,
|
||||
const char *name);
|
||||
EXPORT bool obs_data_item_next(obs_data_item_t **item);
|
||||
EXPORT void obs_data_item_release(obs_data_item_t **item);
|
||||
EXPORT void obs_data_item_remove(obs_data_item_t **item);
|
||||
|
||||
/* Gets Item type */
|
||||
EXPORT enum obs_data_type obs_data_item_gettype(obs_data_item_t *item);
|
||||
EXPORT enum obs_data_number_type obs_data_item_numtype(obs_data_item_t *item);
|
||||
EXPORT const char *obs_data_item_get_name(obs_data_item_t *item);
|
||||
|
||||
/* Item set functions */
|
||||
EXPORT void obs_data_item_set_string(obs_data_item_t **item, const char *val);
|
||||
EXPORT void obs_data_item_set_int(obs_data_item_t **item, long long val);
|
||||
EXPORT void obs_data_item_set_double(obs_data_item_t **item, double val);
|
||||
EXPORT void obs_data_item_set_bool(obs_data_item_t **item, bool val);
|
||||
EXPORT void obs_data_item_set_obj(obs_data_item_t **item, obs_data_t *val);
|
||||
EXPORT void obs_data_item_set_array(obs_data_item_t **item,
|
||||
obs_data_array_t *val);
|
||||
|
||||
EXPORT void obs_data_item_set_default_string(obs_data_item_t **item,
|
||||
const char *val);
|
||||
EXPORT void obs_data_item_set_default_int(obs_data_item_t **item,
|
||||
long long val);
|
||||
EXPORT void obs_data_item_set_default_double(obs_data_item_t **item,
|
||||
double val);
|
||||
EXPORT void obs_data_item_set_default_bool(obs_data_item_t **item, bool val);
|
||||
EXPORT void obs_data_item_set_default_obj(obs_data_item_t **item,
|
||||
obs_data_t *val);
|
||||
EXPORT void obs_data_item_set_default_array(obs_data_item_t **item,
|
||||
obs_data_array_t *val);
|
||||
|
||||
EXPORT void obs_data_item_set_autoselect_string(obs_data_item_t **item,
|
||||
const char *val);
|
||||
EXPORT void obs_data_item_set_autoselect_int(obs_data_item_t **item,
|
||||
long long val);
|
||||
EXPORT void obs_data_item_set_autoselect_double(obs_data_item_t **item,
|
||||
double val);
|
||||
EXPORT void obs_data_item_set_autoselect_bool(obs_data_item_t **item, bool val);
|
||||
EXPORT void obs_data_item_set_autoselect_obj(obs_data_item_t **item,
|
||||
obs_data_t *val);
|
||||
EXPORT void obs_data_item_set_autoselect_array(obs_data_item_t **item,
|
||||
obs_data_array_t *val);
|
||||
|
||||
/* Item get functions */
|
||||
EXPORT const char *obs_data_item_get_string(obs_data_item_t *item);
|
||||
EXPORT long long obs_data_item_get_int(obs_data_item_t *item);
|
||||
EXPORT double obs_data_item_get_double(obs_data_item_t *item);
|
||||
EXPORT bool obs_data_item_get_bool(obs_data_item_t *item);
|
||||
EXPORT obs_data_t *obs_data_item_get_obj(obs_data_item_t *item);
|
||||
EXPORT obs_data_array_t *obs_data_item_get_array(obs_data_item_t *item);
|
||||
|
||||
EXPORT const char *obs_data_item_get_default_string(obs_data_item_t *item);
|
||||
EXPORT long long obs_data_item_get_default_int(obs_data_item_t *item);
|
||||
EXPORT double obs_data_item_get_default_double(obs_data_item_t *item);
|
||||
EXPORT bool obs_data_item_get_default_bool(obs_data_item_t *item);
|
||||
EXPORT obs_data_t *obs_data_item_get_default_obj(obs_data_item_t *item);
|
||||
EXPORT obs_data_array_t *obs_data_item_get_default_array(obs_data_item_t *item);
|
||||
|
||||
EXPORT const char *obs_data_item_get_autoselect_string(obs_data_item_t *item);
|
||||
EXPORT long long obs_data_item_get_autoselect_int(obs_data_item_t *item);
|
||||
EXPORT double obs_data_item_get_autoselect_double(obs_data_item_t *item);
|
||||
EXPORT bool obs_data_item_get_autoselect_bool(obs_data_item_t *item);
|
||||
EXPORT obs_data_t *obs_data_item_get_autoselect_obj(obs_data_item_t *item);
|
||||
EXPORT obs_data_array_t *
|
||||
obs_data_item_get_autoselect_array(obs_data_item_t *item);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
123
tests/stubs/macro-action-macro.cpp
Normal file
123
tests/stubs/macro-action-macro.cpp
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#include "macro-action-macro.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
bool MacroActionMacro::_registered = false;
|
||||
const std::string MacroActionMacro::id = "macro";
|
||||
|
||||
bool MacroActionMacro::PerformAction()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void MacroActionMacro::LogAction() const {}
|
||||
|
||||
bool MacroActionMacro::Save(obs_data_t *obj) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MacroActionMacro::Load(obs_data_t *obj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MacroActionMacro::PostLoad()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string MacroActionMacro::GetShortDesc() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionMacro::Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionMacro>(m);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionMacro::Copy() const
|
||||
{
|
||||
return std::make_shared<MacroActionMacro>(*this);
|
||||
}
|
||||
|
||||
void MacroActionMacro::ResolveVariablesToFixedValues() {}
|
||||
|
||||
void MacroActionMacro::RunOptions::Save(obs_data_t *obj) const {}
|
||||
|
||||
void MacroActionMacro::RunOptions::Load(obs_data_t *obj) {}
|
||||
|
||||
void MacroActionMacro::RunActions(Macro *actionMacro) const {}
|
||||
|
||||
void MacroActionMacro::AdjustActionState(Macro *macro) const {}
|
||||
|
||||
MacroActionMacroEdit::MacroActionMacroEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroActionMacro> entryData)
|
||||
: ResizableWidget(parent),
|
||||
_actions(new QComboBox(this)),
|
||||
_macros(new MacroSelection(this)),
|
||||
_actionSelectionType(new QComboBox(this)),
|
||||
_label(new VariableLineEdit(this)),
|
||||
_actionTypes(new FilterComboBox(this)),
|
||||
_regex(new RegexConfigWidget(this)),
|
||||
_conditionMacros(new MacroSelection(this)),
|
||||
_conditionBehaviors(new QComboBox(this)),
|
||||
_reevaluateConditionState(new QCheckBox(this)),
|
||||
_actionSections(new QComboBox(this)),
|
||||
_skipWhenPaused(new QCheckBox(this)),
|
||||
_setInputs(new QCheckBox(this)),
|
||||
_inputs(new MacroInputEdit(this)),
|
||||
_entryLayout(new QHBoxLayout()),
|
||||
_conditionLayout(new QHBoxLayout()),
|
||||
_reevaluateConditionStateLayout(new QHBoxLayout()),
|
||||
_setInputsLayout(new QHBoxLayout()),
|
||||
_nestedMacro(new MacroEdit(this)),
|
||||
_entryData(entryData)
|
||||
{
|
||||
}
|
||||
|
||||
MacroActionMacroEdit::~MacroActionMacroEdit() {}
|
||||
|
||||
void MacroActionMacroEdit::UpdateEntryData() {}
|
||||
|
||||
QWidget *MacroActionMacroEdit::Create(QWidget *parent,
|
||||
std::shared_ptr<MacroAction> action)
|
||||
{
|
||||
return new MacroActionMacroEdit(
|
||||
parent, std::dynamic_pointer_cast<MacroActionMacro>(action));
|
||||
}
|
||||
|
||||
void MacroActionMacroEdit::MacroChanged(const QString &text) {}
|
||||
|
||||
void MacroActionMacroEdit::ActionChanged(int value) {}
|
||||
|
||||
void MacroActionMacroEdit::ActionSelectionTypeChanged(int value) {}
|
||||
|
||||
void MacroActionMacroEdit::ActionIndexChanged(const IntVariable &value) {}
|
||||
|
||||
void MacroActionMacroEdit::LabelChanged() {}
|
||||
|
||||
void MacroActionMacroEdit::ActionTypeChanged(int value) {}
|
||||
|
||||
void MacroActionMacroEdit::RegexChanged(const RegexConfig &config) {}
|
||||
|
||||
void MacroActionMacroEdit::ConditionMacroChanged(const QString &text) {}
|
||||
|
||||
void MacroActionMacroEdit::ConditionBehaviorChanged(int value) {}
|
||||
|
||||
void MacroActionMacroEdit::ReevaluateConditionStateChanged(int value) {}
|
||||
|
||||
void MacroActionMacroEdit::ActionSectionChanged(int value) {}
|
||||
|
||||
void MacroActionMacroEdit::SkipWhenPausedChanged(int value) {}
|
||||
|
||||
void MacroActionMacroEdit::SetInputsChanged(int value) {}
|
||||
|
||||
void MacroActionMacroEdit::InputsChanged(const StringList &inputs) {}
|
||||
|
||||
void MacroActionMacroEdit::SetWidgetVisibility() {}
|
||||
|
||||
void MacroActionMacroEdit::SetupMacroInput(Macro *macro) const {}
|
||||
|
||||
} // namespace advss
|
||||
77
tests/stubs/macro-dock-settings.cpp
Normal file
77
tests/stubs/macro-dock-settings.cpp
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#include "macro-dock-settings.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
MacroDockSettings::MacroDockSettings(Macro *macro) : _macro(macro) {}
|
||||
MacroDockSettings::~MacroDockSettings() {}
|
||||
|
||||
void MacroDockSettings::Save(obs_data_t *, bool) const {}
|
||||
void MacroDockSettings::Load(obs_data_t *) {}
|
||||
void MacroDockSettings::EnableDock(bool value)
|
||||
{
|
||||
_registerDock = value;
|
||||
}
|
||||
void MacroDockSettings::SetIsStandaloneDock(bool value)
|
||||
{
|
||||
_standaloneDock = value;
|
||||
}
|
||||
void MacroDockSettings::SetDockWindowName(const std::string &name)
|
||||
{
|
||||
_dockWindow = name;
|
||||
}
|
||||
void MacroDockSettings::SetHasRunButton(bool value)
|
||||
{
|
||||
_hasRunButton = value;
|
||||
}
|
||||
void MacroDockSettings::SetHasPauseButton(bool value)
|
||||
{
|
||||
_hasPauseButton = value;
|
||||
}
|
||||
void MacroDockSettings::SetHasStatusLabel(bool value)
|
||||
{
|
||||
_hasStatusLabel = value;
|
||||
}
|
||||
void MacroDockSettings::SetHighlightEnable(bool value)
|
||||
{
|
||||
_highlight = value;
|
||||
}
|
||||
void MacroDockSettings::SetRunButtonText(const std::string &text)
|
||||
{
|
||||
_runButtonText = text;
|
||||
}
|
||||
void MacroDockSettings::SetPauseButtonText(const std::string &text)
|
||||
{
|
||||
_pauseButtonText = text;
|
||||
}
|
||||
void MacroDockSettings::SetUnpauseButtonText(const std::string &text)
|
||||
{
|
||||
_unpauseButtonText = text;
|
||||
}
|
||||
void MacroDockSettings::SetConditionsTrueStatusText(const std::string &text)
|
||||
{
|
||||
_conditionsTrueStatusText = text;
|
||||
}
|
||||
void MacroDockSettings::SetConditionsFalseStatusText(const std::string &text)
|
||||
{
|
||||
_conditionsFalseStatusText = text;
|
||||
}
|
||||
|
||||
StringVariable MacroDockSettings::ConditionsTrueStatusText() const
|
||||
{
|
||||
return _conditionsTrueStatusText;
|
||||
}
|
||||
StringVariable MacroDockSettings::ConditionsFalseStatusText() const
|
||||
{
|
||||
return _conditionsFalseStatusText;
|
||||
}
|
||||
|
||||
void MacroDockSettings::HandleMacroNameChange() {}
|
||||
void MacroDockSettings::ResetDockIfEnabled() {}
|
||||
void MacroDockSettings::RemoveDock() {}
|
||||
|
||||
std::string MacroDockSettings::GenerateId()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
134
tests/stubs/macro-edit.cpp
Normal file
134
tests/stubs/macro-edit.cpp
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
#include "macro-edit.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
MacroEdit::MacroEdit(QWidget *parent, QStringList)
|
||||
: QWidget(parent),
|
||||
ui(std::make_unique<Ui_MacroEdit>())
|
||||
{
|
||||
}
|
||||
|
||||
void MacroEdit::SetMacro(const std::shared_ptr<Macro> &m)
|
||||
{
|
||||
_currentMacro = m;
|
||||
}
|
||||
std::shared_ptr<Macro> MacroEdit::GetMacro() const
|
||||
{
|
||||
return _currentMacro;
|
||||
}
|
||||
void MacroEdit::ClearSegmentWidgetCacheFor(Macro *) const {}
|
||||
void MacroEdit::SetControlsDisabled(bool) const {}
|
||||
void MacroEdit::HighlightAction(int, QColor) const {}
|
||||
void MacroEdit::HighlightElseAction(int, QColor) const {}
|
||||
void MacroEdit::HighlightCondition(int, QColor) const {}
|
||||
void MacroEdit::ResetConditionHighlights() {}
|
||||
void MacroEdit::ResetActionHighlights() {}
|
||||
void MacroEdit::SetActionData(Macro &) const {}
|
||||
void MacroEdit::SetElseActionData(Macro &) const {}
|
||||
void MacroEdit::SetConditionData(Macro &) const {}
|
||||
void MacroEdit::SwapActions(Macro *, int, int) {}
|
||||
void MacroEdit::SwapElseActions(Macro *, int, int) {}
|
||||
void MacroEdit::SwapConditions(Macro *, int, int) {}
|
||||
void MacroEdit::CopyMacroSegment() {}
|
||||
void MacroEdit::PasteMacroSegment() {}
|
||||
bool MacroEdit::IsEmpty() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void MacroEdit::ShowAllMacroSections() {}
|
||||
|
||||
void MacroEdit::on_conditionAdd_clicked() {}
|
||||
void MacroEdit::on_conditionRemove_clicked() {}
|
||||
void MacroEdit::on_conditionTop_clicked() {}
|
||||
void MacroEdit::on_conditionUp_clicked() {}
|
||||
void MacroEdit::on_conditionDown_clicked() {}
|
||||
void MacroEdit::on_conditionBottom_clicked() {}
|
||||
void MacroEdit::on_actionAdd_clicked() {}
|
||||
void MacroEdit::on_actionRemove_clicked() {}
|
||||
void MacroEdit::on_actionTop_clicked() {}
|
||||
void MacroEdit::on_actionUp_clicked() {}
|
||||
void MacroEdit::on_actionDown_clicked() {}
|
||||
void MacroEdit::on_actionBottom_clicked() {}
|
||||
void MacroEdit::on_toggleElseActions_clicked() const {}
|
||||
void MacroEdit::on_elseActionAdd_clicked() {}
|
||||
void MacroEdit::on_elseActionRemove_clicked() {}
|
||||
void MacroEdit::on_elseActionTop_clicked() {}
|
||||
void MacroEdit::on_elseActionUp_clicked() {}
|
||||
void MacroEdit::on_elseActionDown_clicked() {}
|
||||
void MacroEdit::on_elseActionBottom_clicked() {}
|
||||
void MacroEdit::UpMacroSegmentHotkey() {}
|
||||
void MacroEdit::DownMacroSegmentHotkey() {}
|
||||
void MacroEdit::DeleteMacroSegmentHotkey() {}
|
||||
void MacroEdit::ShowMacroActionsContextMenu(const QPoint &) {}
|
||||
void MacroEdit::ShowMacroElseActionsContextMenu(const QPoint &) {}
|
||||
void MacroEdit::ShowMacroConditionsContextMenu(const QPoint &) {}
|
||||
void MacroEdit::ExpandAllActions() const {}
|
||||
void MacroEdit::ExpandAllElseActions() const {}
|
||||
void MacroEdit::ExpandAllConditions() const {}
|
||||
void MacroEdit::CollapseAllActions() const {}
|
||||
void MacroEdit::CollapseAllElseActions() const {}
|
||||
void MacroEdit::CollapseAllConditions() const {}
|
||||
void MacroEdit::MinimizeActions() const {}
|
||||
void MacroEdit::MaximizeActions() const {}
|
||||
void MacroEdit::MinimizeElseActions() const {}
|
||||
void MacroEdit::MaximizeElseActions() const {}
|
||||
void MacroEdit::MinimizeConditions() const {}
|
||||
void MacroEdit::MaximizeConditions() const {}
|
||||
void MacroEdit::SetElseActionsStateToHidden() const {}
|
||||
void MacroEdit::SetElseActionsStateToVisible() const {}
|
||||
void MacroEdit::MacroActionSelectionChanged(int) {}
|
||||
void MacroEdit::MacroActionReorder(int, int) {}
|
||||
void MacroEdit::AddMacroAction(Macro *, int, const std::string &, obs_data_t *)
|
||||
{
|
||||
}
|
||||
void MacroEdit::AddMacroAction(int) {}
|
||||
void MacroEdit::RemoveMacroAction(int) {}
|
||||
void MacroEdit::MoveMacroActionUp(int) {}
|
||||
void MacroEdit::MoveMacroActionDown(int) {}
|
||||
void MacroEdit::MacroElseActionSelectionChanged(int) {}
|
||||
void MacroEdit::MacroElseActionReorder(int, int) {}
|
||||
void MacroEdit::AddMacroElseAction(Macro *, int, const std::string &,
|
||||
obs_data_t *)
|
||||
{
|
||||
}
|
||||
void MacroEdit::AddMacroElseAction(int) {}
|
||||
void MacroEdit::RemoveMacroElseAction(int) {}
|
||||
void MacroEdit::MoveMacroElseActionUp(int) {}
|
||||
void MacroEdit::MoveMacroElseActionDown(int) {}
|
||||
void MacroEdit::MacroConditionSelectionChanged(int) {}
|
||||
void MacroEdit::MacroConditionReorder(int, int) {}
|
||||
void MacroEdit::AddMacroCondition(int) {}
|
||||
void MacroEdit::AddMacroCondition(Macro *, int, const std::string &,
|
||||
obs_data_t *, Logic::Type)
|
||||
{
|
||||
}
|
||||
void MacroEdit::RemoveMacroCondition(int) {}
|
||||
void MacroEdit::MoveMacroConditionUp(int) {}
|
||||
void MacroEdit::MoveMacroConditionDown(int) {}
|
||||
void MacroEdit::HighlightControls() const {}
|
||||
|
||||
void MacroEdit::PopulateMacroActions(Macro &, uint32_t) {}
|
||||
void MacroEdit::PopulateMacroElseActions(Macro &, uint32_t) {}
|
||||
void MacroEdit::PopulateMacroConditions(Macro &, uint32_t) {}
|
||||
void MacroEdit::SetupMacroSegmentSelection(MacroSection, int) {}
|
||||
void MacroEdit::SetupContextMenu(const QPoint &,
|
||||
const std::function<void(MacroEdit *, int)> &,
|
||||
const std::function<void(MacroEdit *)> &,
|
||||
const std::function<void(MacroEdit *)> &,
|
||||
const std::function<void(MacroEdit *)> &,
|
||||
const std::function<void(MacroEdit *)> &,
|
||||
MacroSegmentList *)
|
||||
{
|
||||
}
|
||||
void MacroEdit::RunSegmentHighlightChecks() {}
|
||||
bool MacroEdit::ElseSectionIsVisible() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MacroEdit::eventFilter(QObject *, QEvent *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
86
tests/stubs/plugin-state-helpers.cpp
Normal file
86
tests/stubs/plugin-state-helpers.cpp
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#include "plugin-state-helpers.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
void SavePluginSettings(obs_data_t *) {}
|
||||
void LoadPluginSettings(obs_data_t *) {}
|
||||
void AddSaveStep(std::function<void(obs_data_t *)>) {}
|
||||
void AddLoadStep(std::function<void(obs_data_t *)>) {}
|
||||
void AddPostLoadStep(std::function<void()>) {}
|
||||
void AddIntervalResetStep(std::function<void()>) {}
|
||||
void RunSaveSteps(obs_data_t *) {}
|
||||
void RunLoadSteps(obs_data_t *) {}
|
||||
void RunAndClearPostLoadSteps() {}
|
||||
void ClearPostLoadSteps() {}
|
||||
|
||||
void AddPluginInitStep(std::function<void()>) {}
|
||||
void AddPluginPostLoadStep(std::function<void()>) {}
|
||||
void AddPluginCleanupStep(std::function<void()>) {}
|
||||
void RunPluginInitSteps() {}
|
||||
void RunPluginPostLoadSteps() {}
|
||||
void RunPluginCleanupSteps() {}
|
||||
|
||||
void StopPlugin() {}
|
||||
void StartPlugin() {}
|
||||
bool PluginIsRunning()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int GetIntervalValue()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void AddStartStep(std::function<void()>) {}
|
||||
void AddStopStep(std::function<void()>) {}
|
||||
void RunStartSteps() {}
|
||||
void RunStopSteps() {}
|
||||
void RunIntervalResetSteps() {}
|
||||
|
||||
void SetPluginNoMatchBehavior(NoMatchBehavior) {}
|
||||
NoMatchBehavior GetPluginNoMatchBehavior()
|
||||
{
|
||||
return NoMatchBehavior::NO_SWITCH;
|
||||
}
|
||||
void SetNoMatchScene(const OBSWeakSource &) {}
|
||||
|
||||
std::string ForegroundWindowTitle()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
std::string PreviousForegroundWindowTitle()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
bool SettingsWindowIsOpened()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool HighlightUIElementsEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OBSIsShuttingDown()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool InitialLoadIsComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool IsFirstInterval()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool IsFirstIntervalAfterStop()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetMacroHighlightingEnabled(bool) {}
|
||||
bool IsMacroHighlightingEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
|
@ -47,4 +47,9 @@ QWidget *GetSettingsWindow()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool IsCursorInWidgetArea(QWidget *widget)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
351
tests/test-macro-condition.cpp
Normal file
351
tests/test-macro-condition.cpp
Normal file
|
|
@ -0,0 +1,351 @@
|
|||
#include "catch.hpp"
|
||||
|
||||
#include <macro-condition.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
class StubCondition : public advss::MacroCondition {
|
||||
public:
|
||||
StubCondition(bool initialValue = false)
|
||||
: MacroCondition(nullptr),
|
||||
_value(initialValue)
|
||||
{
|
||||
}
|
||||
|
||||
void SetValue(bool value) { _value = value; }
|
||||
bool CheckCondition() override { return _value; }
|
||||
bool Save(obs_data_t *) const override { return true; }
|
||||
bool Load(obs_data_t *) override { return true; }
|
||||
std::string GetId() const override { return "stub"; }
|
||||
|
||||
private:
|
||||
bool _value;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// HasChanged
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("HasChanged is false on first evaluation", "[macro-condition]")
|
||||
{
|
||||
StubCondition cond;
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE_FALSE(cond.HasChanged());
|
||||
}
|
||||
|
||||
TEST_CASE("HasChanged is false when value stays false", "[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
cond.EvaluateCondition();
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE_FALSE(cond.HasChanged());
|
||||
}
|
||||
|
||||
TEST_CASE("HasChanged is false when value stays true", "[macro-condition]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.EvaluateCondition();
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE_FALSE(cond.HasChanged());
|
||||
}
|
||||
|
||||
TEST_CASE("HasChanged is true on rising edge (false to true)",
|
||||
"[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
cond.EvaluateCondition();
|
||||
cond.SetValue(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.HasChanged());
|
||||
}
|
||||
|
||||
TEST_CASE("HasChanged is true on falling edge (true to false)",
|
||||
"[macro-condition]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.EvaluateCondition();
|
||||
cond.SetValue(false);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.HasChanged());
|
||||
}
|
||||
|
||||
TEST_CASE("HasChanged resets to false after stable evaluation",
|
||||
"[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
cond.EvaluateCondition();
|
||||
|
||||
cond.SetValue(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.HasChanged());
|
||||
|
||||
cond.EvaluateCondition(); // value unchanged
|
||||
REQUIRE_FALSE(cond.HasChanged());
|
||||
}
|
||||
|
||||
TEST_CASE("EvaluateCondition returns the current condition value",
|
||||
"[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
REQUIRE_FALSE(cond.EvaluateCondition());
|
||||
|
||||
cond.SetValue(true);
|
||||
REQUIRE(cond.EvaluateCondition());
|
||||
|
||||
cond.SetValue(false);
|
||||
REQUIRE_FALSE(cond.EvaluateCondition());
|
||||
}
|
||||
|
||||
TEST_CASE("Multiple alternating changes are each detected", "[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
cond.EvaluateCondition(); // baseline
|
||||
|
||||
cond.SetValue(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.HasChanged()); // false -> true
|
||||
|
||||
cond.SetValue(false);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.HasChanged()); // true -> false
|
||||
|
||||
cond.SetValue(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.HasChanged()); // false -> true again
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// IsRisingEdge
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("IsRisingEdge is false on first evaluation", "[macro-condition]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE_FALSE(cond.IsRisingEdge());
|
||||
}
|
||||
|
||||
TEST_CASE("IsRisingEdge is true on false-to-true transition",
|
||||
"[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
cond.EvaluateCondition();
|
||||
cond.SetValue(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.IsRisingEdge());
|
||||
}
|
||||
|
||||
TEST_CASE("IsRisingEdge is false on true-to-false transition",
|
||||
"[macro-condition]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.EvaluateCondition();
|
||||
cond.SetValue(false);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE_FALSE(cond.IsRisingEdge());
|
||||
}
|
||||
|
||||
TEST_CASE("IsRisingEdge is false when value stays true", "[macro-condition]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.EvaluateCondition();
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE_FALSE(cond.IsRisingEdge());
|
||||
}
|
||||
|
||||
TEST_CASE("IsRisingEdge is false when value stays false", "[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
cond.EvaluateCondition();
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE_FALSE(cond.IsRisingEdge());
|
||||
}
|
||||
|
||||
TEST_CASE("IsRisingEdge resets to false after stable evaluation",
|
||||
"[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
cond.EvaluateCondition();
|
||||
|
||||
cond.SetValue(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.IsRisingEdge());
|
||||
|
||||
cond.EvaluateCondition(); // value unchanged
|
||||
REQUIRE_FALSE(cond.IsRisingEdge());
|
||||
}
|
||||
|
||||
TEST_CASE("IsRisingEdge fires again after falling then rising",
|
||||
"[macro-condition]")
|
||||
{
|
||||
StubCondition cond(false);
|
||||
cond.EvaluateCondition();
|
||||
|
||||
cond.SetValue(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.IsRisingEdge());
|
||||
|
||||
cond.SetValue(false);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE_FALSE(cond.IsRisingEdge());
|
||||
|
||||
cond.SetValue(true);
|
||||
cond.EvaluateCondition();
|
||||
REQUIRE(cond.IsRisingEdge()); // second rising edge is detected
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CheckDurationModifier - NONE (default, no time constraint)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("DurationModifier NONE passes through condition value",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
// Default modifier type is NONE
|
||||
REQUIRE(cond.CheckDurationModifier(true));
|
||||
REQUIRE_FALSE(cond.CheckDurationModifier(false));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CheckDurationModifier - MORE (true only after duration has elapsed)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("DurationModifier MORE returns false before duration elapses",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::MORE);
|
||||
cond.SetDuration(advss::Duration(10.0)); // 10 seconds — won't elapse
|
||||
|
||||
REQUIRE_FALSE(cond.CheckDurationModifier(true));
|
||||
}
|
||||
|
||||
TEST_CASE("DurationModifier MORE returns true after duration elapses",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::MORE);
|
||||
cond.SetDuration(
|
||||
advss::Duration(0.0)); // 0 seconds — elapses immediately
|
||||
|
||||
// First call starts the timer; with 0s duration it should already pass
|
||||
REQUIRE(cond.CheckDurationModifier(true));
|
||||
}
|
||||
|
||||
TEST_CASE("DurationModifier MORE resets when condition becomes false",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond;
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::MORE);
|
||||
cond.SetDuration(advss::Duration(0.0));
|
||||
|
||||
cond.CheckDurationModifier(true); // start timer
|
||||
cond.CheckDurationModifier(false); // reset
|
||||
// After reset a fresh call with true must re-start the timer and still pass
|
||||
// (duration is 0 so it should pass immediately again)
|
||||
REQUIRE(cond.CheckDurationModifier(true));
|
||||
}
|
||||
|
||||
TEST_CASE("DurationModifier MORE returns false when condition is false",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond;
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::MORE);
|
||||
cond.SetDuration(advss::Duration(0.0));
|
||||
|
||||
REQUIRE_FALSE(cond.CheckDurationModifier(false));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CheckDurationModifier - LESS (true only before duration elapses)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("DurationModifier LESS returns true before duration elapses",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::LESS);
|
||||
cond.SetDuration(advss::Duration(10.0)); // won't elapse during test
|
||||
|
||||
REQUIRE(cond.CheckDurationModifier(true));
|
||||
}
|
||||
|
||||
TEST_CASE("DurationModifier LESS returns false after duration elapses",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::LESS);
|
||||
cond.SetDuration(advss::Duration(0.0)); // elapses immediately
|
||||
|
||||
// First call starts timer; with 0s it is already past
|
||||
REQUIRE_FALSE(cond.CheckDurationModifier(true));
|
||||
}
|
||||
|
||||
TEST_CASE("DurationModifier LESS returns false when condition is false",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond;
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::LESS);
|
||||
cond.SetDuration(advss::Duration(10.0));
|
||||
|
||||
REQUIRE_FALSE(cond.CheckDurationModifier(false));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CheckDurationModifier - WITHIN (true while within window after going false)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("DurationModifier WITHIN returns true while condition is true",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::WITHIN);
|
||||
cond.SetDuration(advss::Duration(10.0));
|
||||
|
||||
REQUIRE(cond.CheckDurationModifier(true));
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"DurationModifier WITHIN returns true immediately after condition goes false",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond;
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::WITHIN);
|
||||
cond.SetDuration(advss::Duration(10.0));
|
||||
|
||||
cond.CheckDurationModifier(
|
||||
true); // condition was true — sets time remaining
|
||||
REQUIRE(cond.CheckDurationModifier(false)); // still within window
|
||||
}
|
||||
|
||||
TEST_CASE("DurationModifier WITHIN returns false before condition was ever true",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond;
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::WITHIN);
|
||||
cond.SetDuration(advss::Duration(10.0));
|
||||
|
||||
// Timer was never started (condition never went true->false)
|
||||
REQUIRE_FALSE(cond.CheckDurationModifier(false));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ResetDuration
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("ResetDuration causes MORE modifier to restart its timer",
|
||||
"[duration-modifier]")
|
||||
{
|
||||
StubCondition cond(true);
|
||||
cond.SetDurationModifier(advss::DurationModifier::Type::MORE);
|
||||
cond.SetDuration(advss::Duration(10.0));
|
||||
|
||||
cond.CheckDurationModifier(true); // starts timer
|
||||
cond.ResetDuration(); // reset
|
||||
|
||||
// After reset the timer restarts — 10s duration won't have elapsed
|
||||
REQUIRE_FALSE(cond.CheckDurationModifier(true));
|
||||
}
|
||||
416
tests/test-macro.cpp
Normal file
416
tests/test-macro.cpp
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
#include "catch.hpp"
|
||||
|
||||
#include <macro.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Stubs
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class StubCondition : public advss::MacroCondition {
|
||||
public:
|
||||
StubCondition(advss::Macro *m, bool initialValue = false)
|
||||
: MacroCondition(m),
|
||||
_value(initialValue)
|
||||
{
|
||||
}
|
||||
|
||||
void SetValue(bool value) { _value = value; }
|
||||
bool CheckCondition() override { return _value; }
|
||||
bool Save(obs_data_t *) const override { return true; }
|
||||
bool Load(obs_data_t *) override { return true; }
|
||||
std::string GetId() const override { return "stub"; }
|
||||
|
||||
private:
|
||||
bool _value;
|
||||
};
|
||||
|
||||
class StubAction : public advss::MacroAction {
|
||||
public:
|
||||
StubAction(advss::Macro *m) : MacroAction(m) {}
|
||||
|
||||
bool PerformAction() override
|
||||
{
|
||||
_performCount++;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> Copy() const override
|
||||
{
|
||||
return std::make_shared<StubAction>(*this);
|
||||
}
|
||||
|
||||
bool Save(obs_data_t *) const override { return true; }
|
||||
bool Load(obs_data_t *) override { return true; }
|
||||
std::string GetId() const override { return "stub"; }
|
||||
|
||||
int PerformCount() const { return _performCount; }
|
||||
|
||||
private:
|
||||
int _performCount = 0;
|
||||
};
|
||||
|
||||
// Helpers to wire up conditions and actions onto a macro
|
||||
std::shared_ptr<StubCondition> AddCondition(advss::Macro &m,
|
||||
bool initialValue = false)
|
||||
{
|
||||
auto cond = std::make_shared<StubCondition>(&m, initialValue);
|
||||
cond->SetLogicType(advss::Logic::Type::ROOT_NONE);
|
||||
m.Conditions().push_back(cond);
|
||||
return cond;
|
||||
}
|
||||
|
||||
std::shared_ptr<StubAction> AddAction(advss::Macro &m)
|
||||
{
|
||||
auto action = std::make_shared<StubAction>(&m);
|
||||
m.Actions().push_back(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
std::shared_ptr<StubAction> AddElseAction(advss::Macro &m)
|
||||
{
|
||||
auto action = std::make_shared<StubAction>(&m);
|
||||
m.ElseActions().push_back(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CheckConditions - basic matching
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("CheckConditions returns false with no conditions", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
REQUIRE_FALSE(m.CheckConditions());
|
||||
}
|
||||
|
||||
TEST_CASE("CheckConditions returns true when condition is true", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
REQUIRE(m.CheckConditions());
|
||||
}
|
||||
|
||||
TEST_CASE("CheckConditions returns false when condition is false", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, false);
|
||||
REQUIRE_FALSE(m.CheckConditions());
|
||||
}
|
||||
|
||||
TEST_CASE("ConditionsMatched reflects last CheckConditions result", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
auto cond = AddCondition(m, false);
|
||||
|
||||
m.CheckConditions();
|
||||
REQUIRE_FALSE(m.ConditionsMatched());
|
||||
|
||||
cond->SetValue(true);
|
||||
m.CheckConditions();
|
||||
REQUIRE(m.ConditionsMatched());
|
||||
}
|
||||
|
||||
TEST_CASE("CheckConditions returns false for group macros", "[macro]")
|
||||
{
|
||||
std::vector<std::shared_ptr<advss::Macro>> children;
|
||||
auto group = advss::Macro::CreateGroup("group", children);
|
||||
REQUIRE_FALSE(group->CheckConditions());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pause
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("CheckConditions respects pause", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
auto cond = AddCondition(m, true);
|
||||
|
||||
m.SetPaused(true);
|
||||
// When paused, conditions are not evaluated — _matched stays false
|
||||
REQUIRE_FALSE(m.CheckConditions());
|
||||
}
|
||||
|
||||
TEST_CASE("CheckConditions runs when ignorePause is true while paused",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
|
||||
m.SetPaused(true);
|
||||
REQUIRE(m.CheckConditions(/*ignorePause=*/true));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ShouldRunActions - ActionTriggerMode::MACRO_RESULT_CHANGED (default)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("ShouldRunActions is false before first CheckConditions", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
AddAction(m);
|
||||
// _actionModeMatch starts false, _matched starts false
|
||||
REQUIRE_FALSE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
TEST_CASE("ShouldRunActions MACRO_RESULT_CHANGED: true on first match",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
AddAction(m);
|
||||
|
||||
// Default mode is MACRO_RESULT_CHANGED.
|
||||
// _lastMatched starts false, first check sets _matched=true -> changed
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::MACRO_RESULT_CHANGED);
|
||||
m.CheckConditions();
|
||||
REQUIRE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
TEST_CASE("ShouldRunActions MACRO_RESULT_CHANGED: false when result unchanged",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
AddAction(m);
|
||||
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::MACRO_RESULT_CHANGED);
|
||||
m.CheckConditions(); // false -> true: changed
|
||||
m.CheckConditions(); // true -> true: unchanged
|
||||
REQUIRE_FALSE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"ShouldRunActions MACRO_RESULT_CHANGED: true again when result flips back",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
auto cond = AddCondition(m, true);
|
||||
AddAction(m);
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::MACRO_RESULT_CHANGED);
|
||||
m.CheckConditions(); // false -> true
|
||||
REQUIRE(m.ShouldRunActions());
|
||||
m.CheckConditions(); // true -> true
|
||||
REQUIRE_FALSE(m.ShouldRunActions());
|
||||
cond->SetValue(false);
|
||||
m.CheckConditions(); // true -> false: changed
|
||||
cond->SetValue(true);
|
||||
m.CheckConditions(); // true -> false: changed
|
||||
REQUIRE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ShouldRunActions - ActionTriggerMode::ALWAYS
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("ShouldRunActions ALWAYS: true every time conditions match",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
AddAction(m);
|
||||
|
||||
m.SetActionTriggerMode(advss::Macro::ActionTriggerMode::ALWAYS);
|
||||
m.CheckConditions();
|
||||
REQUIRE(m.ShouldRunActions());
|
||||
|
||||
m.CheckConditions();
|
||||
REQUIRE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
TEST_CASE("ShouldRunActions ALWAYS: false when conditions do not match",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, false);
|
||||
// No else actions, so nothing to run
|
||||
m.SetActionTriggerMode(advss::Macro::ActionTriggerMode::ALWAYS);
|
||||
m.CheckConditions();
|
||||
REQUIRE_FALSE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ShouldRunActions - ActionTriggerMode::ANY_CONDITION_CHANGED
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("ShouldRunActions ANY_CONDITION_CHANGED: true when condition changes",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
auto cond = AddCondition(m, false);
|
||||
AddAction(m);
|
||||
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::ANY_CONDITION_CHANGED);
|
||||
m.CheckConditions(); // baseline — no change yet
|
||||
|
||||
cond->SetValue(true);
|
||||
m.CheckConditions(); // changed: false -> true
|
||||
REQUIRE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
TEST_CASE("ShouldRunActions ANY_CONDITION_CHANGED: false when condition stable",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
AddAction(m);
|
||||
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::ANY_CONDITION_CHANGED);
|
||||
m.CheckConditions(); // baseline
|
||||
m.CheckConditions(); // stable
|
||||
REQUIRE_FALSE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ShouldRunActions - ActionTriggerMode::ANY_CONDITION_TRIGGERED
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("ShouldRunActions ANY_CONDITION_TRIGGERED: true on rising edge",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
auto cond = AddCondition(m, false);
|
||||
AddAction(m);
|
||||
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::ANY_CONDITION_TRIGGERED);
|
||||
m.CheckConditions(); // baseline
|
||||
|
||||
cond->SetValue(true);
|
||||
m.CheckConditions(); // rising edge
|
||||
REQUIRE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
TEST_CASE("ShouldRunActions ANY_CONDITION_TRIGGERED: false on falling edge",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
auto cond = AddCondition(m, true);
|
||||
AddElseAction(m); // need else actions so ShouldRunActions can be true
|
||||
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::ANY_CONDITION_TRIGGERED);
|
||||
m.CheckConditions(); // baseline (first eval, no rising edge)
|
||||
|
||||
cond->SetValue(false);
|
||||
m.CheckConditions(); // falling edge — not a rising edge
|
||||
REQUIRE_FALSE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
TEST_CASE("ShouldRunActions ANY_CONDITION_TRIGGERED: false when stable true",
|
||||
"[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
AddAction(m);
|
||||
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::ANY_CONDITION_TRIGGERED);
|
||||
m.CheckConditions(); // baseline
|
||||
m.CheckConditions(); // stable true — no rising edge
|
||||
REQUIRE_FALSE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// RunCount
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("RunCount increments after PerformActions", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
AddAction(m);
|
||||
|
||||
m.SetActionTriggerMode(advss::Macro::ActionTriggerMode::ALWAYS);
|
||||
m.CheckConditions();
|
||||
REQUIRE(m.RunCount() == 0);
|
||||
|
||||
m.PerformActions(true);
|
||||
REQUIRE(m.RunCount() == 1);
|
||||
|
||||
m.PerformActions(true);
|
||||
REQUIRE(m.RunCount() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("ResetRunCount resets to zero", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddAction(m);
|
||||
|
||||
m.PerformActions(true);
|
||||
m.PerformActions(true);
|
||||
REQUIRE(m.RunCount() == 2);
|
||||
|
||||
m.ResetRunCount();
|
||||
REQUIRE(m.RunCount() == 0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pause state
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("Paused is false by default", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
REQUIRE_FALSE(m.Paused());
|
||||
}
|
||||
|
||||
TEST_CASE("SetPaused toggles pause state", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
m.SetPaused(true);
|
||||
REQUIRE(m.Paused());
|
||||
m.SetPaused(false);
|
||||
REQUIRE_FALSE(m.Paused());
|
||||
}
|
||||
|
||||
TEST_CASE("Paused macros don't run actions", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
m.SetPaused(true);
|
||||
REQUIRE(m.Paused());
|
||||
auto action = AddAction(m);
|
||||
m.PerformActions(true);
|
||||
REQUIRE(action->PerformCount() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("ShouldRunActions is false while paused", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
AddCondition(m, true);
|
||||
AddAction(m);
|
||||
|
||||
m.SetActionTriggerMode(advss::Macro::ActionTriggerMode::ALWAYS);
|
||||
m.CheckConditions(/*ignorePause=*/true);
|
||||
m.SetPaused(true);
|
||||
REQUIRE_FALSE(m.ShouldRunActions());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ActionTriggerMode getter/setter
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("GetActionTriggerMode returns the set mode", "[macro]")
|
||||
{
|
||||
advss::Macro m("test");
|
||||
m.SetActionTriggerMode(advss::Macro::ActionTriggerMode::ALWAYS);
|
||||
REQUIRE(m.GetActionTriggerMode() ==
|
||||
advss::Macro::ActionTriggerMode::ALWAYS);
|
||||
|
||||
m.SetActionTriggerMode(
|
||||
advss::Macro::ActionTriggerMode::ANY_CONDITION_TRIGGERED);
|
||||
REQUIRE(m.GetActionTriggerMode() ==
|
||||
advss::Macro::ActionTriggerMode::ANY_CONDITION_TRIGGERED);
|
||||
}
|
||||
|
|
@ -80,11 +80,3 @@ TEST_CASE("Matches (PartialMatchRegexConfig)", "[regex-config]")
|
|||
result = regex.Matches(std::string("abc"), "a");
|
||||
REQUIRE(result == true);
|
||||
}
|
||||
|
||||
TEST_CASE("EscapeForRegex , [text-helpers]")
|
||||
{
|
||||
REQUIRE(advss::EscapeForRegex("") == "");
|
||||
REQUIRE(advss::EscapeForRegex("abcdefg") == "abcdefg");
|
||||
REQUIRE(advss::EscapeForRegex("(abcdefg)") == "\\(abcdefg\\)");
|
||||
REQUIRE(advss::EscapeForRegex("\\(abcdefg)") == "\\\\(abcdefg\\)");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user