Compare commits

..

50 Commits

Author SHA1 Message Date
WarmUpTill
af188b55df Move plugins to separate folder (#400) 2022-01-29 15:47:16 +01:00
WarmUpTill
f287a1041d Add option to also check for configured volume level 2022-01-25 12:46:16 -08:00
WarmUpTill
fda9b1c3ea Fix dock location and size not saving correctly
OBS will handle the docking position / window size and position as long
as an object name is set
2022-01-25 10:33:41 -08:00
WarmUpTill
9eb7f58525 CI: Save debian build result 2022-01-25 10:33:02 -08:00
WarmUpTill
abd6fd6b7e Add sequence action (#395) 2022-01-22 18:07:26 +01:00
WarmUpTill
2909b1300e Fix empty statusControl of general tab blocking mouse input 2022-01-22 06:14:03 -08:00
WarmUpTill
d1331a60b9 Fix crash on exit caused by status dock 2022-01-22 06:14:03 -08:00
WarmUpTill
d5fc3befb8 Remove QtConcurrent dependency 2022-01-22 06:14:03 -08:00
WarmUpTill
80f9c79907 CI: Bump windows QT version to 5.15.2 2022-01-22 06:14:03 -08:00
WarmUpTill
e4bd1fc180 Reduce amount of signals emitted on repopulate 2022-01-22 06:14:03 -08:00
WarmUpTill
59c87ca027 Emphasize that a duration of 0s means using default duration 2022-01-21 09:51:00 -08:00
WarmUpTill
eda161de39 Sort condition and action selection alphabetically 2022-01-21 09:51:00 -08:00
WarmUpTill
6033426a6e Enable word wrap for macro priority warning 2022-01-21 09:51:00 -08:00
WarmUpTill
caea16c6ad Hide selected macro for run or stop action
Running a macro from within itself is not supported and stopping it from
withint itself does not seem useful either.
2022-01-21 09:51:00 -08:00
WarmUpTill
e3a39a5df7 Add label clarifying the condition's intent 2022-01-21 09:51:00 -08:00
WarmUpTill
38b7e08711 Add macro action to stop other macros 2022-01-21 09:51:00 -08:00
WarmUpTill
7349841758 Fix unexpectedly returning true for hotkey condition
The condition would return true after unpause, if a configured hotkey was pressed
during the time the macro was paused.
2022-01-21 09:50:19 -08:00
WarmUpTill
5d58269b02 Add function to access parent macro from condition or action 2022-01-21 09:50:19 -08:00
WarmUpTill
8a4aef0f50 Update bug_report.md 2022-01-19 20:22:26 +01:00
WarmUpTill
4b877d865c Add issue templates 2022-01-16 19:43:51 +01:00
WarmUpTill
82503286ea Use the same widget for main settings window and status dock 2022-01-14 09:11:36 -08:00
WarmUpTill
16ee789c82 Add option to perform macro actions only on condition change 2022-01-06 08:41:18 -08:00
WarmUpTill
d040a01016 Reintroduce checkbox to change current scene check transition behaviour 2022-01-06 08:41:18 -08:00
WarmUpTill
eb952afe58 Enable time constraints for transition condition 2022-01-06 08:41:18 -08:00
WarmUpTill
34cff925fc CI: No longer query for 32 bit OBS install path 2022-01-05 20:21:03 +01:00
WarmUpTill
016d963598 Fix volume not changing when selecting fade with a duration of 0s 2022-01-04 19:32:53 -08:00
WarmUpTill
d31ae77176 Run macros even if they are paused when pressing "Run Macro" 2022-01-04 19:32:53 -08:00
WarmUpTill
2c1b97e5cd Abort macro early if it was paused 2022-01-05 03:39:37 +01:00
WarmUpTill
c498d1509a Adjust locale 2022-01-05 02:54:39 +01:00
WarmUpTill
2d61189655 Display message on first boot 2022-01-04 17:16:38 -08:00
WarmUpTill
82c20b871b Don't ask to backup settings if there is nothing to backup 2022-01-04 17:16:38 -08:00
WarmUpTill
bd52ef8e84 Don't abort build if OpenVR cannot be found 2022-01-04 15:50:26 -08:00
WarmUpTill
59e1ddd31e Add openvr condition 2022-01-04 15:50:26 -08:00
WarmUpTill
a320d78a08 Separate OpenCV dependency into its own lib
This should avoid issues of the whole plugin not loading if OpenCV is
not available.
This approach should also work for possible future external
dependencies.
2022-01-03 18:22:02 -08:00
WarmUpTill
ce5730428c Remove unnecessary uses of UNUSED_PARAMETER macro 2022-01-03 13:48:21 -08:00
WarmUpTill
f7b9795014 Add option to check if source is muted 2022-01-03 13:48:21 -08:00
WarmUpTill
3417fc5407 Add status dock 2022-01-03 11:32:22 -08:00
WarmUpTill
2649efe8b3 Adjust to SceneItemSelection and SceneItemSelectionWidget 2022-01-03 08:52:32 -08:00
WarmUpTill
3af5897427 Rename function 2022-01-03 08:52:32 -08:00
WarmUpTill
92877a6b30 Add SceneItemSelection and SceneItemSelectionWidget
Allows selecting individual scene items if there are duplicate entries
for the same source.
2022-01-03 08:52:32 -08:00
WarmUpTill
fbdaffcbf6 Clean up formatJsonString() 2022-01-03 08:52:32 -08:00
WarmUpTill
ba111c6caa Add action to import settings from file 2022-01-01 18:26:40 -08:00
WarmUpTill
5c8760ac0a Add action to switch scene collection 2022-01-01 18:26:40 -08:00
WarmUpTill
e0cca2a0d4 Add action to switch profile 2022-01-01 18:26:40 -08:00
WarmUpTill
d69aba8ab7 Remove dependency to SceneSwitcherEntry and SwitchWidget 2021-12-28 05:07:37 -08:00
WarmUpTill
a2ba7adc56 Add option to wait for transition to complete 2021-12-28 05:07:37 -08:00
WarmUpTill
0881146a25 Fix startup behavior not loading correctly 2021-12-22 13:12:41 -08:00
WarmUpTill
5224d6589e Reduce log output when running macro in background 2021-12-22 13:12:27 -08:00
WarmUpTill
15eeec8ebf Add condition "Studio Mode"
Can be used to check whether or not studio mode is active or to check
the current preview scene
2021-12-22 13:12:27 -08:00
WarmUpTill
ed7f375d64 Fix crash when reordering macros 2021-12-22 13:12:27 -08:00
117 changed files with 4173 additions and 1323 deletions

35
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Logs**
Please provide a log of your issue with verbose logging enabled (See General tab of the plugin).
See [here](https://obsproject.com/forum/threads/please-post-a-log-with-your-issue-heres-how.23074/) for a description where to find the log files and how to share them.
Please share the currently used plugin settings by exporting them them to a file (See General tab of the plugin).
If applicable, add screenshots to help explain your problem.
**Version information**
- OS: [e.g. Windows 10]
- OBS Version [e.g. 27.1.3]
- Plugin Version [e.g. 1.17.1]
**Additional context**
Add any other context about the problem here.

View File

@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -4,46 +4,52 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: check_libobs_revision
run: |
sudo apt update
sudo apt install libobs-dev
mkdir source
cd source
dpkg -l libobs-dev | tr -s " "| grep libobs | cut -d" " -f3 > libobs.rev
- name: install_frontend_header
run: |
[ -e /usr/include/obs/obs-frontend-api.h ] && { echo "ERROR: obs-frontend-api.h already in system. Maybe the package libobs-dev is installing it."; exit 1; }
cd source
LIBOBSREV=$(cat libobs.rev)
sudo apt update
sudo apt install devscripts
dget -u http://archive.ubuntu.com/ubuntu/pool/universe/o/obs-studio/obs-studio_$LIBOBSREV.dsc
cd ..
sudo find -name obs-frontend-api.h -exec cp {} /usr/include/obs/ \;
egrep '#include <obs.h>' /usr/include/obs/obs-frontend-api.h || { echo "ERROR: check if the sed commands are needed from now."; exit 1; }
sudo sed -i 's/#include <obs.h>/#include <obs\/obs.h>/' /usr/include/obs/obs-frontend-api.h
sudo sed -i 's/#include <util\/darray.h>/#include <obs\/util\/darray.h>/' /usr/include/obs/obs-frontend-api.h
- name: create_tarball
run: |
cd ..
tar --exclude=.git -cvzf obs-scene-switcher_0.1+testonly.orig.tar.gz SceneSwitcher
- name: create_debian_dir
run: |
cp -a CI/linux/debian .
- name: install_dependencies
run: |
# devscripts and libobs-dev are needed but they were already installed
# from check_libobs_revision and install_frontend_header sections.
sudo apt update
sudo apt install cmake debhelper libcurl4-openssl-dev libxss-dev libxtst-dev qtbase5-dev libopencv-dev libprocps-dev
- name: build
run: |
debuild --no-lintian --no-sign
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: check_libobs_revision
run: |
sudo apt update
sudo apt install libobs-dev
mkdir source
cd source
dpkg -l libobs-dev | tr -s " "| grep libobs | cut -d" " -f3 > libobs.rev
- name: install_frontend_header
run: |
[ -e /usr/include/obs/obs-frontend-api.h ] && { echo "ERROR: obs-frontend-api.h already in system. Maybe the package libobs-dev is installing it."; exit 1; }
cd source
LIBOBSREV=$(cat libobs.rev)
sudo apt update
sudo apt install devscripts
dget -u http://archive.ubuntu.com/ubuntu/pool/universe/o/obs-studio/obs-studio_$LIBOBSREV.dsc
cd ..
sudo find -name obs-frontend-api.h -exec cp {} /usr/include/obs/ \;
egrep '#include <obs.h>' /usr/include/obs/obs-frontend-api.h || { echo "ERROR: check if the sed commands are needed from now."; exit 1; }
sudo sed -i 's/#include <obs.h>/#include <obs\/obs.h>/' /usr/include/obs/obs-frontend-api.h
sudo sed -i 's/#include <util\/darray.h>/#include <obs\/util\/darray.h>/' /usr/include/obs/obs-frontend-api.h
- name: create_tarball
run: |
cd ..
tar --exclude=.git -cvzf obs-scene-switcher_0.1+testonly.orig.tar.gz SceneSwitcher
- name: create_debian_dir
run: |
cp -a CI/linux/debian .
- name: install_dependencies
run: |
# devscripts and libobs-dev are needed but they were already installed
# from check_libobs_revision and install_frontend_header sections.
sudo apt update
sudo apt install cmake debhelper libcurl4-openssl-dev libxss-dev libxtst-dev qtbase5-dev libopencv-dev libprocps-dev
- name: build
run: |
debuild --no-lintian --no-sign
mv ../*.deb .
- name: Publish
if: success()
uses: actions/upload-artifact@v2.2.1
with:
name: "obs-scene-switcher.deb"
path: ${{ github.workspace }}/*.deb

View File

@@ -12,25 +12,25 @@ jobs:
name: "macOS 64-bit"
runs-on: [macos-latest]
env:
QT_VERSION: '5.15.2'
MACOS_DEPS_VERSION: '2020-12-11'
QT_VERSION: "5.15.2"
MACOS_DEPS_VERSION: "2020-12-11"
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
with:
repository: obsproject/obs-studio
submodules: 'recursive'
ref: 'refs/tags/${{ env.OBS_TAG }}'
submodules: "recursive"
ref: "refs/tags/${{ env.OBS_TAG }}"
- name: "Checkout plugin"
uses: actions/checkout@v2.3.4
with:
path: UI/frontend-plugins/${{ env.PLUGIN_NAME }}
submodules: 'recursive'
submodules: "recursive"
- name: Fetch Git Tags
run: |
cd UI/frontend-plugins/${{ env.PLUGIN_NAME }}
git fetch --prune --tags --unshallow
- name: 'Install prerequisites (Homebrew)'
- name: "Install prerequisites (Homebrew)"
shell: bash
run: |
if [ -d /usr/local/opt/openssl@1.0.2t ]; then
@@ -42,20 +42,20 @@ jobs:
brew untap local/python2
fi
brew bundle --file ./CI/scripts/macos/Brewfile
- name: 'Install prerequisite: Pre-built dependencies'
- name: "Install prerequisite: Pre-built dependencies"
if: steps.deps-cache.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L -O https://github.com/obsproject/obs-deps/releases/download/${{ env.MACOS_DEPS_VERSION }}/macos-deps-${{ env.MACOS_DEPS_VERSION }}.tar.gz
tar -xf ./macos-deps-${{ env.MACOS_DEPS_VERSION }}.tar.gz -C "/tmp"
- name: 'Install prerequisite: Pre-built dependency Qt'
- name: "Install prerequisite: Pre-built dependency Qt"
if: steps.deps-qt-cache.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L -O https://github.com/obsproject/obs-deps/releases/download/${{ env.MACOS_DEPS_VERSION }}/macos-qt-${{ env.QT_VERSION }}-${{ env.MACOS_DEPS_VERSION }}.tar.gz
tar -xf ./macos-qt-${{ env.QT_VERSION }}-${{ env.MACOS_DEPS_VERSION }}.tar.gz -C "/tmp"
xattr -r -d com.apple.quarantine /tmp/obsdeps
- name: 'Build prerequisite: OpenCV'
- name: "Build prerequisite: OpenCV"
shell: bash
run: |
cd UI/frontend-plugins/${{ env.PLUGIN_NAME }}/deps/opencv
@@ -79,7 +79,7 @@ jobs:
cd ./build
make -j4
cd -
- name: 'Install prerequisite: Packages app'
- name: "Install prerequisite: Packages app"
if: success()
shell: bash
run: |
@@ -90,12 +90,16 @@ jobs:
if: success()
shell: bash
run: |
fix_linker_paths() {
install_name_tool -change @rpath/libobs-frontend-api.dylib @executable_path/../Frameworks/libobs-frontend-api.dylib $1
install_name_tool -change @rpath/libobs.0.dylib @executable_path/../Frameworks/libobs.0.dylib $1
install_name_tool -change /tmp/obsdeps/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets $1
install_name_tool -change /tmp/obsdeps/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui $1
install_name_tool -change /tmp/obsdeps/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore $1
}
cd UI/frontend-plugins/${{ env.PLUGIN_NAME }}
install_name_tool -change @rpath/libobs-frontend-api.dylib @executable_path/../Frameworks/libobs-frontend-api.dylib ../../../build/UI/frontend-plugins/SceneSwitcher/advanced-scene-switcher.so
install_name_tool -change @rpath/libobs.0.dylib @executable_path/../Frameworks/libobs.0.dylib ../../../build/UI/frontend-plugins/SceneSwitcher/advanced-scene-switcher.so
install_name_tool -change /tmp/obsdeps/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets ../../../build/UI/frontend-plugins/SceneSwitcher/advanced-scene-switcher.so
install_name_tool -change /tmp/obsdeps/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui ../../../build/UI/frontend-plugins/SceneSwitcher/advanced-scene-switcher.so
install_name_tool -change /tmp/obsdeps/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore ../../../build/UI/frontend-plugins/SceneSwitcher/advanced-scene-switcher.so
fix_linker_paths ../../../build/UI/frontend-plugins/SceneSwitcher/advanced-scene-switcher.so
fix_linker_paths ../../../build/UI/frontend-plugins/SceneSwitcher/src/external-macro-modules/opencv/advanced-scene-switcher-opencv.so
FILE_DATE=$(date +%Y-%m-%d)
FILE_NAME=${{ env.PLUGIN_NAME }}-$FILE_DATE-${{ github.sha }}-macos.pkg
echo "FILE_NAME=${FILE_NAME}" >> $GITHUB_ENV
@@ -107,23 +111,23 @@ jobs:
if: success()
uses: actions/upload-artifact@v2.2.1
with:
name: '${{ env.FILE_NAME }}'
name: "${{ env.FILE_NAME }}"
path: ./nightly/*.pkg
ubuntu64:
name: 'Linux/Ubuntu 64-bit'
name: "Linux/Ubuntu 64-bit"
runs-on: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
with:
repository: obsproject/obs-studio
submodules: 'recursive'
ref: 'refs/tags/${{ env.OBS_TAG }}'
submodules: "recursive"
ref: "refs/tags/${{ env.OBS_TAG }}"
- name: "Checkout plugin"
uses: actions/checkout@v2.3.4
with:
path: UI/frontend-plugins/${{ env.PLUGIN_NAME }}
submodules: 'recursive'
submodules: "recursive"
- name: Add plugin to obs cmake
shell: bash
run: echo "add_subdirectory(${{ env.PLUGIN_NAME }})" >> UI/frontend-plugins/CMakeLists.txt
@@ -181,17 +185,17 @@ jobs:
libxcb-xfixes0-dev \
libopencv-dev \
libprocps-dev
- name: 'Configure'
- name: "Configure"
shell: bash
run: |
mkdir ./build
cd ./build
cmake -DENABLE_PIPEWIRE=OFF -DUNIX_STRUCTURE=0 -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/obs-studio-portable" -DWITH_RTMPS=OFF -DBUILD_BROWSER=OFF ..
- name: 'Build'
- name: "Build"
shell: bash
working-directory: ${{ github.workspace }}/build
run: make -j4
- name: 'Package'
- name: "Package"
shell: bash
run: |
FILE_DATE=$(date +%Y-%m-%d)
@@ -201,12 +205,16 @@ jobs:
strip -d ./build/UI/frontend-plugins/${{ env.PLUGIN_NAME }}/${{ env.LIB_NAME }}.so
mv ./build/UI/frontend-plugins/${{ env.PLUGIN_NAME }}/${{ env.LIB_NAME }}.so ./${{ env.LIB_NAME }}/bin/64bit/${{ env.LIB_NAME }}.so
mv ./UI/frontend-plugins/${{ env.PLUGIN_NAME }}/data ./${{ env.LIB_NAME }}/data
# Macro modules
mkdir -p ./${{ env.LIB_NAME }}/bin/64bit/adv-ss-plugins
strip -d ./build/UI/frontend-plugins/${{ env.PLUGIN_NAME }}/src/external-macro-modules/opencv/advanced-scene-switcher-opencv.so
mv ./build/UI/frontend-plugins/${{ env.PLUGIN_NAME }}/src/external-macro-modules/opencv/advanced-scene-switcher-opencv.so ./${{ env.LIB_NAME }}/bin/64bit/adv-ss-plugins
tar -cvzf "${FILE_NAME}" ${{ env.LIB_NAME }}
- name: 'Publish'
- name: "Publish"
uses: actions/upload-artifact@v2.2.1
with:
name: '${{ env.FILE_NAME }}'
path: '*.tar.gz'
name: "${{ env.FILE_NAME }}"
path: "*.tar.gz"
windows:
name: Windows
runs-on: [windows-latest]
@@ -214,10 +222,10 @@ jobs:
matrix:
arch: [32, 64]
env:
QT_VERSION: 5.10.1
QT_VERSION: 5.15.2
CMAKE_GENERATOR: "Visual Studio 16 2019"
CMAKE_SYSTEM_VERSION: "10.0.18363.657"
WINDOWS_DEPS_VERSION: '2019'
WINDOWS_DEPS_VERSION: "2019"
steps:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
@@ -225,27 +233,27 @@ jobs:
uses: actions/checkout@v2.3.4
with:
repository: obsproject/obs-studio
submodules: 'recursive'
ref: 'refs/tags/${{ env.OBS_TAG }}'
submodules: "recursive"
ref: "refs/tags/${{ env.OBS_TAG }}"
- name: Checkout plugin
uses: actions/checkout@v2.3.4
with:
path: UI/frontend-plugins/${{ env.PLUGIN_NAME}}
submodules: 'recursive'
submodules: "recursive"
- name: Add plugin to obs cmake
shell: cmd
run: echo add_subdirectory(${{ env.PLUGIN_NAME }}) >> UI/frontend-plugins/CMakeLists.txt
- name: Fetch Git Tags
run: git fetch --prune --tags --unshallow
- name: 'Install prerequisite: QT'
- name: "Install prerequisite: QT"
run: |
curl -kLO https://cdn-fastly.obsproject.com/downloads/Qt_${{ env.QT_VERSION }}.7z -f --retry 5 -C -
7z x Qt_${{ env.QT_VERSION }}.7z -o"${{ github.workspace }}/cmbuild/QT"
- name: 'Install prerequisite: Pre-built dependencies'
- name: "Install prerequisite: Pre-built dependencies"
run: |
curl -kLO https://cdn-fastly.obsproject.com/downloads/dependencies${{ env.WINDOWS_DEPS_VERSION }}.zip -f --retry 5 -C -
7z x dependencies${{ env.WINDOWS_DEPS_VERSION }}.zip -o"${{ github.workspace }}/cmbuild/deps"
- name: 'Build prerequisite: OpenCV'
- name: "Build prerequisite: OpenCV"
run: |
cd UI/frontend-plugins/${{ env.PLUGIN_NAME }}/deps/opencv
mkdir build
@@ -268,11 +276,11 @@ jobs:
Get-Location
if ( ${{ matrix.arch }} -eq 32 )
{
cmake -G"${{ env.CMAKE_GENERATOR }}" -A"Win32" -DOpenCV_DIR="${{ github.workspace }}/UI/frontend-plugins/SceneSwitcher/deps/opencv/build/" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DBUILD_CAPTIONS=false -DCOMPILE_D3D12_HOOK=false -DDepsPath="${{ github.workspace }}/cmbuild/deps/win32" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2017" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE ..
cmake -G"${{ env.CMAKE_GENERATOR }}" -A"Win32" -DOpenCV_DIR="${{ github.workspace }}/UI/frontend-plugins/SceneSwitcher/deps/opencv/build/" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DBUILD_CAPTIONS=false -DCOMPILE_D3D12_HOOK=false -DDepsPath="${{ github.workspace }}/cmbuild/deps/win32" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2019" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE ..
}
else
{
cmake -G"${{ env.CMAKE_GENERATOR }}" -A"x64" -DOpenCV_DIR="${{ github.workspace }}/UI/frontend-plugins/SceneSwitcher/deps/opencv/build/" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DBUILD_CAPTIONS=false -DCOMPILE_D3D12_HOOK=false -DDepsPath="${{ github.workspace }}/cmbuild/deps/win64" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2017_64" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE ..
cmake -G"${{ env.CMAKE_GENERATOR }}" -A"x64" -DOpenCV_DIR="${{ github.workspace }}/UI/frontend-plugins/SceneSwitcher/deps/opencv/build/" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DBUILD_CAPTIONS=false -DCOMPILE_D3D12_HOOK=false -DDepsPath="${{ github.workspace }}/cmbuild/deps/win64" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2019_64" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE ..
}
- name: Build
run: |
@@ -283,19 +291,21 @@ jobs:
$env:FILE_DATE=(Get-Date -UFormat "%F")
$env:FILE_NAME="${{ env.PLUGIN_NAME }}-${env:FILE_DATE}-${{ github.sha }}-windows"
echo "FILE_NAME=${env:FILE_NAME}" >> ${env:GITHUB_ENV}
robocopy .\build${{ matrix.arch }}\rundir\RelWithDebInfo\obs-plugins\${{ matrix.arch }}bit\ .\package\obs-plugins\${{ matrix.arch }}bit ${{ env.LIB_NAME }}.* /E /XF .gitignore
robocopy .\build${{ matrix.arch }}\rundir\RelWithDebInfo\obs-plugins\${{ matrix.arch }}bit\ .\package\obs-plugins\${{ matrix.arch }}bit ${{ env.LIB_NAME }}* /E /XF .gitignore
robocopy .\build${{ matrix.arch }}\rundir\RelWithDebInfo\obs-plugins\${{ matrix.arch }}bit\ .\package\obs-plugins\${{ matrix.arch }}bit adv-ss-plugins /E /XF .gitignore
robocopy .\build${{ matrix.arch }}\rundir\RelWithDebInfo\data\obs-plugins\${{ env.LIB_NAME }}\ .\package\data\obs-plugins\${{ env.LIB_NAME }}\ /E /XF .gitignore
cp UI/frontend-plugins/${{ env.PLUGIN_NAME }}/deps/opencv/build/bin/Release/*dll package/obs-plugins/${{ matrix.arch }}bit
cp UI/frontend-plugins/${{ env.PLUGIN_NAME }}/deps/opencv/build/bin/Release/*dll package/obs-plugins/${{ matrix.arch }}bit/adv-ss-plugins
cp UI/frontend-plugins/${{ env.PLUGIN_NAME }}/deps/openvr/bin/win${{ matrix.arch }}/*dll package/obs-plugins/${{ matrix.arch }}bit/adv-ss-plugins
exit 0
- name: Publish zip
if: success()
uses: actions/upload-artifact@v2.2.1
with:
name: '${{ env.FILE_NAME }}-${{ matrix.arch }}bit'
name: "${{ env.FILE_NAME }}-${{ matrix.arch }}bit"
path: package/*
windows-installer:
needs: [windows]
name: 'Create Windows Installer'
name: "Create Windows Installer"
runs-on: [windows-latest]
steps:
- name: "Checkout plugin"
@@ -332,12 +342,12 @@ jobs:
if: success()
uses: actions/upload-artifact@v2.2.0
with:
name: '${{ env.FILE_NAME }}-installer'
name: "${{ env.FILE_NAME }}-installer"
path: build/CI/windows/Output/*.exe
release:
needs: [macos64, ubuntu64, windows, windows-installer]
name: 'Create Release'
runs-on: [ubuntu-18.04]
name: "Create Release"
runs-on: [ubuntu-latest]
steps:
- name: "Checkout plugin"
uses: actions/checkout@v2.3.4
@@ -347,7 +357,7 @@ jobs:
uses: actions/download-artifact@v2
with:
path: artifacts
- name: 'Package'
- name: "Package"
shell: bash
run: |
mkdir -p ${{ env.PLUGIN_NAME }}/Linux ${{ env.PLUGIN_NAME }}/MacOs ${{ env.PLUGIN_NAME }}/Windows
@@ -366,4 +376,4 @@ jobs:
uses: actions/upload-artifact@v2.2.1
with:
name: "Release"
path: '*.zip'
path: "*.zip"

3
.gitmodules vendored
View File

@@ -7,3 +7,6 @@
[submodule "deps/opencv"]
path = deps/opencv
url = https://github.com/opencv/opencv.git
[submodule "deps/openvr"]
path = deps/openvr
url = https://github.com/ValveSoftware/openvr.git

View File

@@ -30,6 +30,327 @@
<dict>
<key>CHILDREN</key>
<array>
<dict>
<key>CHILDREN</key>
<array>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../../../../build/UI/frontend-plugins/SceneSwitcher/src/external-macro-modules/opencv/advanced-scene-switcher-opencv.so</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_objdetect.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_features2d.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_core.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_calib3d.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_calib3d.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_imgproc.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_features2d.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_core.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_flann.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_calib3d.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_objdetect.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_imgproc.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_flann.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_imgproc.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_flann.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_features2d.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_core.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_objdetect.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
</array>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>adv-ss-plugins</string>
<key>PATH_TYPE</key>
<integer>0</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>2</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
@@ -46,294 +367,6 @@
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_objdetect.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_features2d.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_core.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_calib3d.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_calib3d.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_imgproc.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_features2d.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_core.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_flann.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_calib3d.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_objdetect.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_imgproc.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_flann.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_imgproc.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_flann.4.5.3.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_features2d.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_core.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../deps/opencv/build/lib/libopencv_objdetect.4.5.dylib</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
<integer>3</integer>
<key>UID</key>
<integer>0</integer>
</dict>
</array>
<key>GID</key>
<integer>80</integer>

View File

@@ -14,7 +14,7 @@ AppVersion={#MyAppVersion}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={code:GetDirName}
DefaultDirName={code:GetDefaultDirectory}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
@@ -38,18 +38,18 @@ Source: "@ISS_PLUGIN_FILES_DIR@\*"; DestDir: "{app}"; Flags: ignoreversion recur
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Code]
// credit where it's due:
// following function comes from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45
function GetDirName(Value: string): string;
function GetDefaultDirectory(Value: String): String;
var
InstallPath: string;
sInstallPath: String;
begin
// initialize default path, which will be returned when the following registry
// key queries fail due to missing keys or for some different reason
Result := ExpandConstant('{pf}\obs-studio');
// query the first registry value; if this succeeds, return the obtained value
if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then
Result := InstallPath
sInstallPath := Value;
if (sInstallPath = '') then
RegQueryStringValue(HKLM64, 'SOFTWARE\OBS Studio', '', sInstallPath);
if (sInstallPath = '') then
RegQueryStringValue(HKCU64, 'SOFTWARE\OBS Studio', '', sInstallPath);
if (sInstallPath = '') then
sInstallPath := ExpandConstant('{commonpf}\obs-studio');
Result := sInstallPath
end;
procedure CurStepChanged(CurStep: TSetupStep);

View File

@@ -8,6 +8,7 @@ endif()
# Compiler settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(CMAKE_COMPILER_IS_GNUCC
OR CMAKE_COMPILER_IS_GNUCXX
@@ -110,6 +111,7 @@ endif()
# Platform specific settings
if(APPLE)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
find_library(COCOA Cocoa)
if(BUILD_OUT_OF_TREE)
find_package(Qt5MacExtras REQUIRED)
@@ -197,16 +199,19 @@ set(advanced-scene-switcher_HEADERS
src/headers/macro-action-media.hpp
src/headers/macro-action-plugin-state.hpp
src/headers/macro-action-preview-scene.hpp
src/headers/macro-action-profile.hpp
src/headers/macro-action-random.hpp
src/headers/macro-action-recording.hpp
src/headers/macro-action-replay-buffer.hpp
src/headers/macro-action-run.hpp
src/headers/macro-action-scene-collection.hpp
src/headers/macro-action-scene-order.hpp
src/headers/macro-action-scene-swap.hpp
src/headers/macro-action-scene-switch.hpp
src/headers/macro-action-scene-transform.hpp
src/headers/macro-action-scene-visibility.hpp
src/headers/macro-action-screenshot.hpp
src/headers/macro-action-sequence.hpp
src/headers/macro-action-source.hpp
src/headers/macro-action-streaming.hpp
src/headers/macro-action-systray.hpp
@@ -234,9 +239,9 @@ set(advanced-scene-switcher_HEADERS
src/headers/macro-condition-scene.hpp
src/headers/macro-condition-source.hpp
src/headers/macro-condition-streaming.hpp
src/headers/macro-condition-studio-mode.hpp
src/headers/macro-condition-timer.hpp
src/headers/macro-condition-transition.hpp
src/headers/macro-condition-video.hpp
src/headers/macro-condition-virtual-cam.hpp
src/headers/macro-condition-window.hpp
src/headers/macro.hpp
@@ -245,6 +250,7 @@ set(advanced-scene-switcher_HEADERS
src/headers/macro-selection.hpp
src/headers/curl-helper.hpp
src/headers/hotkey.hpp
src/headers/scene-item-selection.hpp
src/headers/scene-selection.hpp
src/headers/screenshot-helper.hpp
src/headers/transition-selection.hpp
@@ -252,6 +258,7 @@ set(advanced-scene-switcher_HEADERS
src/headers/duration-control.hpp
src/headers/file-selection.hpp
src/headers/section.hpp
src/headers/status-control.hpp
src/headers/platform-funcs.hpp
src/headers/utility.hpp
src/headers/volume-control.hpp
@@ -292,16 +299,19 @@ set(advanced-scene-switcher_SOURCES
src/macro-action-media.cpp
src/macro-action-plugin-state.cpp
src/macro-action-preview-scene.cpp
src/macro-action-profile.cpp
src/macro-action-random.cpp
src/macro-action-recording.cpp
src/macro-action-replay-buffer.cpp
src/macro-action-run.cpp
src/macro-action-scene-collection.cpp
src/macro-action-scene-order.cpp
src/macro-action-scene-swap.cpp
src/macro-action-scene-switch.cpp
src/macro-action-scene-transform.cpp
src/macro-action-scene-visibility.cpp
src/macro-action-screenshot.cpp
src/macro-action-sequence.cpp
src/macro-action-source.cpp
src/macro-action-streaming.cpp
src/macro-action-systray.cpp
@@ -329,9 +339,9 @@ set(advanced-scene-switcher_SOURCES
src/macro-condition-scene.cpp
src/macro-condition-source.cpp
src/macro-condition-streaming.cpp
src/macro-condition-studio-mode.cpp
src/macro-condition-timer.cpp
src/macro-condition-transition.cpp
src/macro-condition-video.cpp
src/macro-condition-virtual-cam.cpp
src/macro-condition-window.cpp
src/macro.cpp
@@ -340,32 +350,18 @@ set(advanced-scene-switcher_SOURCES
src/macro-selection.cpp
src/macro-tab.cpp
src/curl-helper.cpp
src/scene-item-selection.cpp
src/scene-selection.cpp
src/screenshot-helper.cpp
src/transition-selection.cpp
src/name-dialog.cpp
src/duration-control.cpp
src/status-control.cpp
src/section.cpp
src/utility.cpp
src/volume-control.cpp
src/version.cpp)
# opencv
find_package(OpenCV)
if(OpenCV_FOUND)
include_directories("${OpenCV_INCLUDE_DIRS}")
else()
set(OpenCV_LIBRARIES "")
message(
WARNING
"OpenCV not found! Functionality relying on OpenCV will be disabled!\nOpenCV sources are available under: ${CMAKE_CURRENT_SOURCE_DIR}/deps/opencv"
)
list(REMOVE_ITEM advanced-scene-switcher_SOURCES
src/macro-condition-video.cpp)
list(REMOVE_ITEM advanced-scene-switcher_HEADERS
src/headers/macro-condition-video.hpp)
endif()
# Backwards compatability checks with older OBS versions
if(DEFINED LibObs_VERSION_MAJOR)
if(LibObs_VERSION_MAJOR GREATER_EQUAL 27)
@@ -391,7 +387,7 @@ if(DEFINED LibObs_VERSION_MAJOR)
endif()
add_library(
advanced-scene-switcher MODULE
advanced-scene-switcher SHARED
${advanced-scene-switcher_HEADERS}
${advanced-scene-switcher_SOURCES}
${advanced-scene-switcher_UI_HEADERS}
@@ -401,13 +397,8 @@ add_library(
# Out of tree build
if(BUILD_OUT_OF_TREE)
target_link_libraries(
advanced-scene-switcher
${advanced-scene-switcher_PLATFORM_LIBS}
${OpenCV_LIBRARIES}
${LIBOBS_LIB}
${LIBOBS_FRONTEND_API_LIB}
Qt5::Core
Qt5::Widgets)
advanced-scene-switcher ${advanced-scene-switcher_PLATFORM_LIBS}
${LIBOBS_LIB} ${LIBOBS_FRONTEND_API_LIB} Qt5::Core Qt5::Widgets)
# Additional commands to install the module in the correct place. Find all the
# translation files so we can copy them to the correct place later on.
@@ -438,6 +429,8 @@ else()
# In tree build
target_link_libraries(
advanced-scene-switcher ${advanced-scene-switcher_PLATFORM_LIBS}
${OpenCV_LIBRARIES} obs-frontend-api Qt5::Widgets libobs)
obs-frontend-api Qt5::Widgets libobs)
install_obs_plugin_with_data(advanced-scene-switcher data)
endif()
add_subdirectory(src/external-macro-modules)

View File

@@ -70,6 +70,7 @@ AdvSceneSwitcher.macroTab.name="Name:"
AdvSceneSwitcher.macroTab.run="Run macro"
AdvSceneSwitcher.macroTab.runFail="Running \"%1\" failed!\nEither one of the actions failed or the macro is running already."
AdvSceneSwitcher.macroTab.runInParallel="Run macro in parallel to other macros"
AdvSceneSwitcher.macroTab.onChange="Perform actions only on condition change"
AdvSceneSwitcher.macroTab.defaultname="Macro %1"
AdvSceneSwitcher.macroTab.exists="Macro name exists already"
AdvSceneSwitcher.macroTab.copy="Create copy"
@@ -87,9 +88,14 @@ AdvSceneSwitcher.logic.not="If not"
; Macro Conditions
AdvSceneSwitcher.condition.audio="Audio"
AdvSceneSwitcher.condition.audio.state.below="Below"
AdvSceneSwitcher.condition.audio.state.above="Above"
AdvSceneSwitcher.condition.audio.entry="Volume of {{audioSources}} is {{condition}} {{volume}}"
AdvSceneSwitcher.condition.audio.state.below="below"
AdvSceneSwitcher.condition.audio.state.exact="exactly"
AdvSceneSwitcher.condition.audio.state.above="above"
AdvSceneSwitcher.condition.audio.state.mute="muted"
AdvSceneSwitcher.condition.audio.state.unmute="unmuted"
AdvSceneSwitcher.condition.audio.type.output="Output volume"
AdvSceneSwitcher.condition.audio.type.volume="Configured volume level"
AdvSceneSwitcher.condition.audio.entry="{{checkType}} of {{audioSources}} is {{condition}} {{volume}}"
AdvSceneSwitcher.condition.cursor="Cursor"
AdvSceneSwitcher.condition.cursor.type.region="is in region"
AdvSceneSwitcher.condition.cursor.type.moving="is moving"
@@ -102,8 +108,9 @@ AdvSceneSwitcher.condition.scene.type.current="Current scene is"
AdvSceneSwitcher.condition.scene.type.previous="Previous scene is"
AdvSceneSwitcher.condition.scene.type.changed="Scene changed"
AdvSceneSwitcher.condition.scene.type.notChanged="Scene has not changed"
AdvSceneSwitcher.condition.scene.waitForTransition="Wait for transition to complete"
AdvSceneSwitcher.condition.scene.entry="{{sceneType}} {{scenes}} {{waitForTransition}}"
AdvSceneSwitcher.condition.scene.currentSceneTransitionBehaviour="During transition check for transition target scene"
AdvSceneSwitcher.condition.scene.entry.line1="{{sceneType}} {{scenes}}"
AdvSceneSwitcher.condition.scene.entry.line2="{{useTransitionTargetScene}}"
AdvSceneSwitcher.condition.window="Window"
AdvSceneSwitcher.condition.window.entry.line1="{{windows}} exist and ..."
AdvSceneSwitcher.condition.window.entry.line2="... is {{fullscreen}} fullscreen {{maximized}} maximized {{focused}} focused {{windowFocusChanged}} foreground window changed"
@@ -214,11 +221,12 @@ AdvSceneSwitcher.condition.sceneOrder.type.above="Is above"
AdvSceneSwitcher.condition.sceneOrder.type.below="Is below"
AdvSceneSwitcher.condition.sceneOrder.type.position="Is at position"
AdvSceneSwitcher.condition.sceneOrder.positionInfo="The position value starts at the bottom with 0 and increases by one for each scene item including the ones in scene groups"
AdvSceneSwitcher.condition.sceneOrder.entry="On {{scenes}} {{sources}} {{conditions}} {{sources2}} {{position}}"
AdvSceneSwitcher.condition.sceneOrder.entry="On{{scenes}}{{sources}}{{conditions}}{{sources2}}{{position}}"
AdvSceneSwitcher.condition.hotkey="Hotkey"
AdvSceneSwitcher.condition.hotkey.name="Macro trigger hotkey"
AdvSceneSwitcher.condition.hotkey.tip="Note: You can configure the keybindings for this hotkey in the OBS settings window"
AdvSceneSwitcher.condition.hotkey.entry="Name: {{name}}"
AdvSceneSwitcher.condition.hotkey.entry.line1="Hotkey is pressed"
AdvSceneSwitcher.condition.hotkey.entry.line2="Name: {{name}}"
AdvSceneSwitcher.condition.replay="Replay buffer"
AdvSceneSwitcher.condition.replay.state.stopped="Replay buffer stopped"
AdvSceneSwitcher.condition.replay.state.started="Replay buffer started"
@@ -234,7 +242,7 @@ AdvSceneSwitcher.condition.date.entry.line2="{{repeat}} Repeat every {{duration}
AdvSceneSwitcher.condition.sceneTransform="Scene item transform"
AdvSceneSwitcher.condition.sceneTransform.getTransform="Get transform"
AdvSceneSwitcher.condition.sceneTransform.regex="Use regular expressions"
AdvSceneSwitcher.condition.sceneTransform.entry.line1="On {{scenes}} {{sources}} matches transform"
AdvSceneSwitcher.condition.sceneTransform.entry.line1="On{{scenes}}{{sources}}matches transform"
AdvSceneSwitcher.condition.sceneTransform.entry.line2="{{settings}}"
AdvSceneSwitcher.condition.sceneTransform.entry.line3="{{regex}} {{getSettings}}"
AdvSceneSwitcher.condition.transition="Transition"
@@ -249,11 +257,22 @@ AdvSceneSwitcher.condition.transition.entry="{{conditions}}{{transitions}}{{scen
AdvSceneSwitcher.condition.sceneVisibility="Scene item visibility"
AdvSceneSwitcher.condition.sceneVisibility.type.shown="Shown"
AdvSceneSwitcher.condition.sceneVisibility.type.hidden="Hidden"
AdvSceneSwitcher.condition.sceneVisibility.entry="On {{scenes}} {{sources}} is {{conditions}} "
AdvSceneSwitcher.condition.sceneVisibility.entry="On{{scenes}}{{sources}}is{{conditions}}"
AdvSceneSwitcher.condition.studioMode="Studio mode"
AdvSceneSwitcher.condition.studioMode.state.active="Studio mode is active"
AdvSceneSwitcher.condition.studioMode.state.notActive="Studio mode is not active"
AdvSceneSwitcher.condition.studioMode.state.previewScene="Preview scene is"
AdvSceneSwitcher.condition.studioMode.entry="{{conditions}}{{scenes}}"
AdvSceneSwitcher.condition.openvr="OpenVR"
AdvSceneSwitcher.condition.errorStatus="OpenVR error: "
AdvSceneSwitcher.condition.openvr.entry.line1="HMD is in ..."
AdvSceneSwitcher.condition.openvr.entry.line2="{{controls}}"
AdvSceneSwitcher.condition.openvr.entry.line3="HMD is currently at {{xPos}} x {{yPos}} x {{zPos}}"
; Macro Actions
AdvSceneSwitcher.action.switchScene="Switch scene"
AdvSceneSwitcher.action.scene.entry="Switch to scene {{scenes}} using {{transitions}} with a duration of {{duration}} seconds"
AdvSceneSwitcher.action.scene.blockUntilTransitionDone="Wait until transition to target scene is complete"
AdvSceneSwitcher.action.wait="Wait"
AdvSceneSwitcher.action.wait.type.fixed="fixed"
AdvSceneSwitcher.action.wait.type.random="random"
@@ -292,7 +311,7 @@ AdvSceneSwitcher.action.sceneVisibility.type.show="Show"
AdvSceneSwitcher.action.sceneVisibility.type.hide="Hide"
AdvSceneSwitcher.action.sceneVisibility.type.source="Source"
AdvSceneSwitcher.action.sceneVisibility.type.sourceGroup="Any"
AdvSceneSwitcher.action.sceneVisibility.entry="On {{scenes}} {{actions}} {{sourceTypes}} {{sources}}"
AdvSceneSwitcher.action.sceneVisibility.entry="On{{scenes}}{{actions}}{{sourceTypes}}{{sources}}{{sourceGroups}}"
AdvSceneSwitcher.action.filter="Filter"
AdvSceneSwitcher.action.filter.type.enable="Enable"
AdvSceneSwitcher.action.filter.type.disable="Disable"
@@ -319,11 +338,14 @@ AdvSceneSwitcher.action.macro.type.pause="Pause"
AdvSceneSwitcher.action.macro.type.unpause="Unpause"
AdvSceneSwitcher.action.macro.type.resetCounter="Reset counter"
AdvSceneSwitcher.action.macro.type.run="Run"
AdvSceneSwitcher.action.macro.type.stop="Stop"
AdvSceneSwitcher.action.macro.entry="{{actions}} {{macros}}"
AdvSceneSwitcher.action.pluginState="Plugin state"
AdvSceneSwitcher.action.pluginState.type.stop="Stop the Advanced Scene Switcher plugin"
AdvSceneSwitcher.action.pluginState.type.noMatch="Change the no-match behaviour:"
AdvSceneSwitcher.action.pluginState.entry="{{actions}} {{values}} {{scenes}}"
AdvSceneSwitcher.action.pluginState.type.import="Import settings from"
AdvSceneSwitcher.action.pluginState.importWarning="Note: Action will be ignored while settings window is opened."
AdvSceneSwitcher.action.pluginState.entry="{{actions}}{{values}}{{scenes}}{{settings}}{{settingsWarning}}"
AdvSceneSwitcher.action.virtualCamera="Virtual camera"
AdvSceneSwitcher.action.virtualCamera.type.stop="Stop virtual camera"
AdvSceneSwitcher.action.virtualCamera.type.start="Start virtual camera"
@@ -346,10 +368,10 @@ AdvSceneSwitcher.action.sceneOrder.type.moveDown="Move down"
AdvSceneSwitcher.action.sceneOrder.type.moveTop="Move to top"
AdvSceneSwitcher.action.sceneOrder.type.moveBottom="Move to bottom"
AdvSceneSwitcher.action.sceneOrder.type.movePosition="Move to position"
AdvSceneSwitcher.action.sceneOrder.entry="On {{scenes}} {{actions}} {{sources}} {{position}}"
AdvSceneSwitcher.action.sceneOrder.entry="On{{scenes}}{{actions}}{{sources}}{{position}}"
AdvSceneSwitcher.action.sceneTransform="Scene item transform"
AdvSceneSwitcher.action.sceneTransform.getTransform="Get transform"
AdvSceneSwitcher.action.sceneTransform.entry="On {{scenes}} transform {{sources}}"
AdvSceneSwitcher.action.sceneTransform.entry="On{{scenes}}transform{{sources}}"
AdvSceneSwitcher.action.file="File"
AdvSceneSwitcher.action.file.type.write="Write"
AdvSceneSwitcher.action.file.type.append="Append"
@@ -374,6 +396,17 @@ AdvSceneSwitcher.action.systray.entry="Show notification: {{message}}"
AdvSceneSwitcher.action.screenshot="Screenshot"
AdvSceneSwitcher.action.screenshot.mainOutput="OBS's main output"
AdvSceneSwitcher.action.screenshot.entry="Screenshot {{sources}}"
AdvSceneSwitcher.action.profile="Profile"
AdvSceneSwitcher.action.profile.entry="Switch active profile to {{profiles}}"
AdvSceneSwitcher.action.sceneCollection="Scene collection"
AdvSceneSwitcher.action.sceneCollection.entry="Switch active scene collection to {{sceneCollections}}"
AdvSceneSwitcher.action.sceneCollection.warning="Note: Any actions following after this will not be executed as the changing scene collection will also reload the scene switcher settings.\nThe scene collection action will be ignored while the settings window is opened."
AdvSceneSwitcher.action.sequence="Sequence"
AdvSceneSwitcher.action.sequence.entry="Each time this action is performed run the next macro in the list (paused macros are ignored)"
AdvSceneSwitcher.action.sequence.status="Last executed macro: %1 - Next macro to be executed: %2"
AdvSceneSwitcher.action.sequence.status.none="none"
AdvSceneSwitcher.action.sequence.restart="Restart from beginning once end of list is reached"
AdvSceneSwitcher.action.sequence.continueFrom="Continue with selected item"
; Transition Tab
AdvSceneSwitcher.transitionTab.title="Transition"
@@ -643,16 +676,22 @@ AdvSceneSwitcher.selectProcess="--select process--"
AdvSceneSwitcher.selectFilter="--select filter--"
AdvSceneSwitcher.selectMacro="--select macro--"
AdvSceneSwitcher.selectItem="--select item--"
AdvSceneSwitcher.selectProfile="--select profile--"
AdvSceneSwitcher.selectSceneCollection="--select scene collection--"
AdvSceneSwitcher.enterPath="--enter path--"
AdvSceneSwitcher.enterText="--enter text--"
AdvSceneSwitcher.invaildEntriesWillNotBeSaved="invalid entries will not be saved"
AdvSceneSwitcher.selectWindowTip="Use \"OBS\" to specify OBS window\nUse \"Task Switching\"to specify ALT + TAB"
AdvSceneSwitcher.sceneItemSelection.all="All"
AdvSceneSwitcher.sceneItemSelection.any="Any"
AdvSceneSwitcher.status.active="Active"
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.unit.milliseconds="milliseconds"
AdvSceneSwitcher.unit.secends="seconds"
AdvSceneSwitcher.unit.minutes="minutes"

1
deps/openvr vendored Submodule

Submodule deps/openvr added at 4c85abcb7f

View File

@@ -56,10 +56,30 @@
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="statusLayout">
<item row="4" column="1">
<widget class="QComboBox" name="autoStartEvent"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_64">
<property name="text">
<string>AdvSceneSwitcher.generalTab.status.onStartup</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="startupBehavior"/>
</item>
<item row="1" column="0">
<widget class="QWidget" name="placeholder" native="true"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>AdvSceneSwitcher.generalTab.status.autoStart</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="checkInterval">
<property name="minimumSize">
@@ -82,6 +102,13 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>AdvSceneSwitcher.generalTab.status.hotkeytips</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
@@ -90,66 +117,10 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="toggleStartButton">
<property name="text">
<string>AdvSceneSwitcher.generalTab.status.start</string>
</property>
</widget>
<widget class="QWidget" name="placeholder2" native="true"/>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_47">
<item>
<widget class="QLabel" name="pluginRunningText">
<property name="text">
<string>AdvSceneSwitcher.status.inactive</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>AdvSceneSwitcher.generalTab.status.hotkeytips</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_64">
<property name="text">
<string>AdvSceneSwitcher.generalTab.status.onStartup</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>AdvSceneSwitcher.generalTab.status.currentStatus</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>AdvSceneSwitcher.generalTab.status.autoStart</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="autoStartEvent"/>
<widget class="QWidget" name="placeholder3" native="true"/>
</item>
</layout>
</item>
@@ -550,6 +521,9 @@
<property name="text">
<string>AdvSceneSwitcher.macroTab.priorityWarning</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@@ -729,7 +703,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_34">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18" stretch="0,0,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout_18" stretch="0,0,0,0,0,0">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
@@ -754,6 +728,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="runMacroOnChange">
<property name="text">
<string>AdvSceneSwitcher.macroTab.onChange</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
@@ -783,7 +764,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>767</width>
<width>792</width>
<height>218</height>
</rect>
</property>
@@ -882,7 +863,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>767</width>
<width>792</width>
<height>218</height>
</rect>
</property>

View File

@@ -1,6 +1,7 @@
#include <QMainWindow>
#include <QAction>
#include <QFileDialog>
#include <QDirIterator>
#include <regex>
#include <filesystem>
@@ -8,11 +9,16 @@
#include <obs-frontend-api.h>
#include "headers/advanced-scene-switcher.hpp"
#include "headers/status-control.hpp"
#include "headers/curl-helper.hpp"
#include "headers/utility.hpp"
#include "headers/version.h"
SwitcherData *switcher = nullptr;
SwitcherData *GetSwitcher()
{
return switcher;
}
/******************************************************************************
* Create the Advanced Scene Switcher settings window
@@ -81,6 +87,7 @@ void AdvSceneSwitcher::loadUI()
setTabOrder();
restoreWindowGeo();
checkFirstTimeSetup();
loading = false;
}
@@ -100,7 +107,6 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
} else {
// Stop the scene switcher at least once to
// avoid scene duplication issues with scene collection changes
bool start = !switcher->stop;
switcher->Stop();
switcher->m.lock();
@@ -116,7 +122,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
obs_data_release(obj);
switcher->m.unlock();
if (start) {
if (!switcher->stop) {
switcher->Start();
}
}
@@ -414,6 +420,7 @@ void SwitcherData::Stop()
cv.notify_all();
abortMacroWait = true;
macroWaitCv.notify_all();
macroTransitionCv.notify_all();
th->wait();
delete th;
th = nullptr;
@@ -552,6 +559,7 @@ void setTranstionEnd()
{
switcher->lastTransitionEndTime =
std::chrono::high_resolution_clock::now();
switcher->macroTransitionCv.notify_all();
}
void setStreamStarting()
@@ -616,6 +624,34 @@ static void OBSEvent(enum obs_frontend_event event, void *switcher)
}
}
void LoadPlugins()
{
QFileInfo libPath(
QString(obs_get_module_binary_path(obs_current_module())));
QString pluginDir(libPath.absolutePath() + "/adv-ss-plugins");
#ifdef _WIN32
QString libPattern = "*.dll";
SetDllDirectory(pluginDir.toStdWString().c_str());
#else
QString libPattern = "*.so";
#endif
QDirIterator it(pluginDir, QStringList() << libPattern, QDir::Files);
while (it.hasNext()) {
auto file = it.next();
blog(LOG_INFO, "attempting to load \"%s\"",
file.toStdString().c_str());
auto lib = new QLibrary(file, nullptr);
if (lib->load()) {
blog(LOG_INFO, "successfully loaded \"%s\"",
file.toStdString().c_str());
} else {
blog(LOG_WARNING, "failed to load \"%s\": %s",
file.toStdString().c_str(),
lib->errorString().toStdString().c_str());
}
}
}
AdvSceneSwitcher *ssWindow;
extern "C" void InitSceneSwitcher()
@@ -623,9 +659,6 @@ extern "C" void InitSceneSwitcher()
blog(LOG_INFO, "version: %s", g_GIT_TAG);
blog(LOG_INFO, "version: %s", g_GIT_SHA1);
QAction *action = (QAction *)obs_frontend_add_tools_menu_qaction(
obs_module_text("AdvSceneSwitcher.pluginName"));
switcher = new SwitcherData;
if (loadCurl() && f_curl_init) {
@@ -633,6 +666,8 @@ extern "C" void InitSceneSwitcher()
}
PlatformInit();
LoadPlugins();
SetupDock();
auto cb = []() {
if (switcher->settingsWindowOpened) {
@@ -640,8 +675,9 @@ extern "C" void InitSceneSwitcher()
ssWindow->raise();
ssWindow->activateWindow();
} else {
ssWindow = new AdvSceneSwitcher(
(QMainWindow *)obs_frontend_get_main_window());
ssWindow =
new AdvSceneSwitcher(static_cast<QMainWindow *>(
obs_frontend_get_main_window()));
ssWindow->setAttribute(Qt::WA_DeleteOnClose);
ssWindow->show();
}
@@ -650,5 +686,7 @@ extern "C" void InitSceneSwitcher()
obs_frontend_add_save_callback(SaveSceneSwitcher, nullptr);
obs_frontend_add_event_callback(OBSEvent, switcher);
QAction *action = (QAction *)obs_frontend_add_tools_menu_qaction(
obs_module_text("AdvSceneSwitcher.pluginName"));
action->connect(action, &QAction::triggered, cb);
}

View File

@@ -0,0 +1,59 @@
# Helper function to install plugins to correct location
function(install_advss_plugin target)
set(plugin_folder "adv-ss-plugins")
if(APPLE)
set(_bit_suffix "")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_bit_suffix "64bit/")
else()
set(_bit_suffix "32bit/")
endif()
set_target_properties(${target} PROPERTIES PREFIX "")
install(
TARGETS ${target}
LIBRARY DESTINATION "${OBS_PLUGIN_DESTINATION}/${plugin_folder}"
RUNTIME DESTINATION "${OBS_PLUGIN_DESTINATION}/${plugin_folder}")
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND
"${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${target}>"
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/obs-plugins/${_bit_suffix}/${plugin_folder}/$<TARGET_FILE_NAME:${target}>"
VERBATIM)
if(DEFINED ENV{obsInstallerTempDir})
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND
"${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${target}>"
"$ENV{obsInstallerTempDir}/${OBS_PLUGIN_DESTINATION}/${plugin_folder}/$<TARGET_FILE_NAME:${target}>"
VERBATIM)
endif()
if(MSVC)
obs_debug_copy_helper(
${target}
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/obs-plugins/${_bit_suffix}/${plugin_folder}"
)
if(DEFINED ENV{obsInstallerTempDir})
obs_debug_copy_helper(
${target}
"$ENV{obsInstallerTempDir}/${OBS_PLUGIN_DESTINATION}/${plugin_folder}")
endif()
install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pdbs/"
DESTINATION "${OBS_PLUGIN_DESTINATION}/${plugin_folder}"
CONFIGURATIONS Debug RelWithDebInfo)
endif()
endfunction()
# Add macro conditions or actions which have dependencies to external libraries
# or other components which might potentially not be fulfilled by the user and
# thus cause issues.
add_subdirectory(opencv)
add_subdirectory(openvr)

View File

@@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 3.14)
project(advanced-scene-switcher-opencv)
add_definitions(-DADVSS_MODULE)
find_package(OpenCV)
if(OpenCV_FOUND)
include_directories("${OpenCV_INCLUDE_DIRS}")
else()
set(OpenCV_LIBRARIES "")
message(
WARNING
"OpenCV not found! Functionality relying on OpenCV will be disabled!\nOpenCV sources are available under: ${CMAKE_CURRENT_SOURCE_DIR}/deps/opencv"
)
return()
endif()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../headers")
set(module_SOURCES macro-condition-video.cpp macro-condition-video.hpp)
add_library(advanced-scene-switcher-opencv MODULE ${module_SOURCES})
if(BUILD_OUT_OF_TREE)
target_link_libraries(
advanced-scene-switcher-opencv
advanced-scene-switcher
${LIBOBS_LIB}
${LIBOBS_FRONTEND_API_LIB}
${OpenCV_LIBRARIES}
Qt5::Core
Qt5::Widgets)
if(UNIX AND NOT APPLE)
if(NOT LIB_OUT_DIR)
set(LIB_OUT_DIR "/lib/obs-plugins")
endif()
set_target_properties(advanced-scene-switcher-opencv PROPERTIES PREFIX "")
install(
TARGETS advanced-scene-switcher-opencv
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_OUT_DIR}/adv-ss-plugins)
endif()
else()
target_link_libraries(
advanced-scene-switcher-opencv
advanced-scene-switcher
obs-frontend-api
${OpenCV_LIBRARIES}
Qt5::Core
Qt5::Widgets
libobs)
install_advss_plugin(advanced-scene-switcher-opencv)
endif()

View File

@@ -1,7 +1,9 @@
#include "headers/macro-condition-edit.hpp"
#include "headers/macro-condition-video.hpp"
#include "headers/utility.hpp"
#include "headers/advanced-scene-switcher.hpp"
#include "macro-condition-video.hpp"
#include <advanced-scene-switcher.hpp>
#include <macro-condition-edit.hpp>
#include <switcher-data-structs.hpp>
#include <utility.hpp>
#include <QFileDialog>
#include <QBuffer>
@@ -450,9 +452,9 @@ MacroConditionVideoEdit::MacroConditionVideoEdit(
_throttleEnable = new QCheckBox();
_throttleCount = new QSpinBox();
_throttleCount->setMinimum(1 * switcher->interval);
_throttleCount->setMaximum(10 * switcher->interval);
_throttleCount->setSingleStep(switcher->interval);
_throttleCount->setMinimum(1 * GetSwitcher()->interval);
_throttleCount->setMaximum(10 * GetSwitcher()->interval);
_throttleCount->setSingleStep(GetSwitcher()->interval);
_showMatch = new QPushButton(
obs_module_text("AdvSceneSwitcher.condition.video.showMatch"));
@@ -595,7 +597,7 @@ void MacroConditionVideoEdit::SourceChanged(const QString &text)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_videoSource = GetWeakSourceByQString(text);
_entryData->ResetLastMatch();
emit HeaderInfoChanged(
@@ -608,7 +610,7 @@ void MacroConditionVideoEdit::ConditionChanged(int cond)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_condition = static_cast<VideoCondition>(cond);
_entryData->ResetLastMatch();
SetWidgetVisibility();
@@ -634,7 +636,7 @@ void MacroConditionVideoEdit::ImagePathChanged(const QString &text)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_file = text.toUtf8().constData();
_entryData->ResetLastMatch();
if (_entryData->LoadImageFromFile()) {
@@ -712,7 +714,7 @@ void MacroConditionVideoEdit::UsePatternForChangedCheckChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_usePatternForChangedCheck = value;
_patternThreshold->setVisible(value);
adjustSize();
@@ -724,7 +726,7 @@ void MacroConditionVideoEdit::PatternThresholdChanged(double value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_patternThreshold = value;
}
@@ -734,7 +736,7 @@ void MacroConditionVideoEdit::UseAlphaAsMaskChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_useAlphaAsMask = value;
_entryData->LoadImageFromFile();
}
@@ -745,7 +747,7 @@ void MacroConditionVideoEdit::ObjectScaleThresholdChanged(double value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_scaleFactor = value;
}
@@ -755,7 +757,7 @@ void MacroConditionVideoEdit::MinNeighborsChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_minNeighbors = value;
}
@@ -765,7 +767,7 @@ void MacroConditionVideoEdit::MinSizeXChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_minSizeX = value;
}
@@ -775,7 +777,7 @@ void MacroConditionVideoEdit::MinSizeYChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_minSizeY = value;
}
@@ -785,7 +787,7 @@ void MacroConditionVideoEdit::MaxSizeXChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_maxSizeX = value;
}
@@ -795,7 +797,7 @@ void MacroConditionVideoEdit::MaxSizeYChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_maxSizeY = value;
}
@@ -805,7 +807,7 @@ void MacroConditionVideoEdit::ThrottleEnableChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_throttleEnabled = value;
_throttleCount->setEnabled(value);
}
@@ -816,8 +818,8 @@ void MacroConditionVideoEdit::ThrottleCountChanged(int value)
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_throttleCount = value / switcher->interval;
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_throttleCount = value / GetSwitcher()->interval;
}
QImage markPatterns(cv::Mat &matchResult, QImage &image, QImage &pattern)
@@ -907,7 +909,7 @@ void MacroConditionVideoEdit::ModelPathChanged(const QString &text)
bool dataLoaded = false;
{
std::lock_guard<std::mutex> lock(switcher->m);
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
std::string path = text.toStdString();
dataLoaded = _entryData->LoadModelData(path);
}
@@ -1003,6 +1005,6 @@ void MacroConditionVideoEdit::UpdateEntryData()
_maxSizeY->setValue(_entryData->_maxSizeY);
_throttleEnable->setChecked(_entryData->_throttleEnabled);
_throttleCount->setValue(_entryData->_throttleCount *
switcher->interval);
GetSwitcher()->interval);
SetWidgetVisibility();
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include "macro.hpp"
#include "screenshot-helper.hpp"
#include "file-selection.hpp"
#include <macro.hpp>
#include <screenshot-helper.hpp>
#include <file-selection.hpp>
#include <QWidget>
#include <QComboBox>
@@ -32,15 +32,16 @@ constexpr int maxMinNeighbors = 6;
class MacroConditionVideo : public MacroCondition {
public:
MacroConditionVideo(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
QImage GetMatchImage() { return _matchImage; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionVideo>();
return std::make_shared<MacroConditionVideo>(m);
}
void GetScreenshot();
bool LoadImageFromFile();

View File

@@ -0,0 +1,90 @@
cmake_minimum_required(VERSION 3.14)
project(advanced-scene-switcher-openvr)
if(NOT WIN32)
message(
WARNING "OpenVR condition is only supported on Windows builds for now.")
return()
endif(NOT WIN32)
add_definitions(-DADVSS_MODULE)
# openvr
if(NOT OpenVR_DIR)
set(OpenVR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../deps/openvr)
endif()
if(EXISTS ${OpenVR_DIR})
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
if((NOT APPLE) AND (CMAKE_SIZEOF_VOID_P EQUAL 8))
set(PROCESSOR_ARCH "64")
else()
set(PROCESSOR_ARCH "32")
endif()
if(WIN32)
set(PLATFORM_NAME "win")
elseif(UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(PLATFORM_NAME "linux")
endif()
elseif(APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*" OR CMAKE_SYSTEM_NAME MATCHES
".*MacOS.*")
set(PLATFORM_NAME "osx")
endif()
endif()
set(OpenVR_INCLUDE_DIRS ${OpenVR_DIR}/headers)
set(OpenVR_BINARIES
${OpenVR_DIR}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}/${CMAKE_SHARED_LIBRARY_PREFIX}openvr_api${CMAKE_SHARED_LIBRARY_SUFFIX}
)
set(OpenVR_LIBRARIES
${OpenVR_DIR}/lib/${PLATFORM_NAME}${PROCESSOR_ARCH}/${CMAKE_SHARED_LIBRARY_PREFIX}openvr_api${CMAKE_IMPORT_LIBRARY_SUFFIX}
)
set(OpenVR_FOUND TRUE)
endif()
if(OpenVR_FOUND)
include_directories("${OpenVR_INCLUDE_DIRS}")
else()
set(OpenVR_LIBRARIES "")
message(
WARNING
"OpenVR not found! Functionality relying on OpenVR will be disabled!\nOpenVR sources are available under: ${CMAKE_CURRENT_SOURCE_DIR}/deps/openvr"
return
())
endif()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../headers")
set(module_SOURCES macro-condition-openvr.cpp macro-condition-openvr.hpp)
add_library(advanced-scene-switcher-openvr MODULE ${module_SOURCES})
if(BUILD_OUT_OF_TREE)
target_link_libraries(
advanced-scene-switcher-openvr
advanced-scene-switcher
${LIBOBS_LIB}
${LIBOBS_FRONTEND_API_LIB}
${OpenVR_LIBRARIES}
Qt5::Core
Qt5::Widgets)
if(UNIX AND NOT APPLE)
if(NOT LIB_OUT_DIR)
set(LIB_OUT_DIR "/lib/obs-plugins")
endif()
set_target_properties(advanced-scene-switcher-openvr PROPERTIES PREFIX "")
install(
TARGETS advanced-scene-switcher-openvr
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_OUT_DIR}/adv-ss-plugins)
endif()
else()
target_link_libraries(
advanced-scene-switcher-openvr
advanced-scene-switcher
obs-frontend-api
${OpenVR_LIBRARIES}
Qt5::Core
Qt5::Widgets
libobs)
install_advss_plugin(advanced-scene-switcher-openvr)
endif()

View File

@@ -0,0 +1,297 @@
#include "macro-condition-openvr.hpp"
#include <macro-condition-edit.hpp>
#include <utility.hpp>
#include <advanced-scene-switcher.hpp>
#include <openvr.h>
const std::string MacroConditionOpenVR::id = "openvr";
bool MacroConditionOpenVR::_registered = MacroConditionFactory::Register(
MacroConditionOpenVR::id,
{MacroConditionOpenVR::Create, MacroConditionOpenVREdit::Create,
"AdvSceneSwitcher.condition.openvr"});
static vr::IVRSystem *openvrSystem;
std::mutex openvrMutex;
std::condition_variable openvrCV;
void processOpenVREvents()
{
std::unique_lock<std::mutex> lock(openvrMutex);
vr::VREvent_t event;
while (true) {
if (openvrSystem->PollNextEvent(&event, sizeof(event)) &&
event.eventType == vr::VREvent_Quit) {
openvrSystem->AcknowledgeQuit_Exiting();
vr::VR_Shutdown();
openvrSystem = nullptr;
break;
}
openvrCV.wait_for(lock, std::chrono::milliseconds(100));
}
blog(LOG_INFO, "stop handling openVR events");
}
void initOpenVR(vr::EVRInitError &err)
{
openvrSystem = vr::VR_Init(&err, vr::VRApplication_Background);
if (openvrSystem) {
// Don't kill OBS if SteamVR is exiting
std::thread t(processOpenVREvents);
t.detach();
}
}
struct TrackingData {
float x, y, z;
bool valid = false;
};
TrackingData getOpenVRPos(vr::EVRInitError &err)
{
TrackingData data;
std::unique_lock<std::mutex> lock(openvrMutex);
if (!openvrSystem) {
initOpenVR(err);
}
if (openvrSystem && vr::VRCompositor() &&
openvrSystem->IsTrackedDeviceConnected(0)) {
vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount];
openvrSystem->GetDeviceToAbsoluteTrackingPose(
vr::TrackingUniverseStanding, 0.0, poses,
vr::k_unMaxTrackedDeviceCount);
auto hmdPose = poses[vr::k_unTrackedDeviceIndex_Hmd];
auto mat = hmdPose.mDeviceToAbsoluteTracking.m;
data.x = mat[0][3];
data.y = mat[1][3];
data.z = mat[2][3];
data.valid = true;
}
return data;
}
bool MacroConditionOpenVR::CheckCondition()
{
vr::EVRInitError err;
TrackingData data = getOpenVRPos(err);
if (!data.valid) {
return false;
}
return data.x >= _minX && data.y >= _minY && data.z >= _minZ &&
data.x <= _maxX && data.y <= _maxY && data.z <= _maxZ;
}
bool MacroConditionOpenVR::Save(obs_data_t *obj)
{
MacroCondition::Save(obj);
obs_data_set_double(obj, "minX", _minX);
obs_data_set_double(obj, "minY", _minY);
obs_data_set_double(obj, "minZ", _minZ);
obs_data_set_double(obj, "maxX", _maxX);
obs_data_set_double(obj, "maxY", _maxY);
obs_data_set_double(obj, "maxZ", _maxZ);
return true;
}
bool MacroConditionOpenVR::Load(obs_data_t *obj)
{
MacroCondition::Load(obj);
_minX = obs_data_get_double(obj, "minX");
_minY = obs_data_get_double(obj, "minY");
_minZ = obs_data_get_double(obj, "minZ");
_maxX = obs_data_get_double(obj, "maxX");
_maxY = obs_data_get_double(obj, "maxY");
_maxZ = obs_data_get_double(obj, "maxZ");
return true;
}
MacroConditionOpenVREdit::MacroConditionOpenVREdit(
QWidget *parent, std::shared_ptr<MacroConditionOpenVR> entryData)
: QWidget(parent)
{
_minX = new QDoubleSpinBox();
_minY = new QDoubleSpinBox();
_minZ = new QDoubleSpinBox();
_maxX = new QDoubleSpinBox();
_maxY = new QDoubleSpinBox();
_maxZ = new QDoubleSpinBox();
_xPos = new QLabel("-");
_yPos = new QLabel("-");
_zPos = new QLabel("-");
_errLabel = new QLabel();
_errLabel->setVisible(false);
_minX->setPrefix("Min X: ");
_minY->setPrefix("Min Y: ");
_minZ->setPrefix("Min Z: ");
_maxX->setPrefix("Max X: ");
_maxY->setPrefix("Max Y: ");
_maxZ->setPrefix("Max Z: ");
_minX->setMinimum(-99);
_minY->setMinimum(-99);
_minZ->setMinimum(-99);
_maxX->setMinimum(-99);
_maxY->setMinimum(-99);
_maxZ->setMinimum(-99);
_minX->setMaximum(99);
_minY->setMaximum(99);
_minZ->setMaximum(99);
_maxX->setMaximum(99);
_maxY->setMaximum(99);
_maxZ->setMaximum(99);
QWidget::connect(_minX, SIGNAL(valueChanged(double)), this,
SLOT(MinXChanged(double)));
QWidget::connect(_minY, SIGNAL(valueChanged(double)), this,
SLOT(MinYChanged(double)));
QWidget::connect(_minZ, SIGNAL(valueChanged(double)), this,
SLOT(MinZChanged(double)));
QWidget::connect(_maxX, SIGNAL(valueChanged(double)), this,
SLOT(MaxXChanged(double)));
QWidget::connect(_maxY, SIGNAL(valueChanged(double)), this,
SLOT(MaxYChanged(double)));
QWidget::connect(_maxZ, SIGNAL(valueChanged(double)), this,
SLOT(MaxZChanged(double)));
QGridLayout *controlsLayout = new QGridLayout;
controlsLayout->addWidget(_minX, 0, 0);
controlsLayout->addWidget(_minY, 0, 1);
controlsLayout->addWidget(_minZ, 0, 2);
controlsLayout->addWidget(_maxX, 1, 0);
controlsLayout->addWidget(_maxY, 1, 1);
controlsLayout->addWidget(_maxZ, 1, 2);
QWidget *controls = new QWidget;
controls->setLayout(controlsLayout);
controls->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{controls}}", controls},
{"{{xPos}}", _xPos},
{"{{yPos}}", _yPos},
{"{{zPos}}", _zPos},
};
QHBoxLayout *line1 = new QHBoxLayout;
placeWidgets(obs_module_text(
"AdvSceneSwitcher.condition.openvr.entry.line1"),
line1, widgetPlaceholders);
QHBoxLayout *line2 = new QHBoxLayout;
placeWidgets(obs_module_text(
"AdvSceneSwitcher.condition.openvr.entry.line2"),
line2, widgetPlaceholders);
QHBoxLayout *line3 = new QHBoxLayout;
placeWidgets(obs_module_text(
"AdvSceneSwitcher.condition.openvr.entry.line3"),
line3, widgetPlaceholders);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(line1);
mainLayout->addLayout(line2);
mainLayout->addLayout(line3);
mainLayout->addWidget(_errLabel);
setLayout(mainLayout);
connect(&_timer, &QTimer::timeout, this,
&MacroConditionOpenVREdit::UpdateOpenVRPos);
_timer.start(1000);
_entryData = entryData;
UpdateEntryData();
_loading = false;
}
void MacroConditionOpenVREdit::MinXChanged(double pos)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_minX = pos;
}
void MacroConditionOpenVREdit::MinYChanged(double pos)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_minY = pos;
}
void MacroConditionOpenVREdit::MinZChanged(double pos)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_minZ = pos;
}
void MacroConditionOpenVREdit::MaxXChanged(double pos)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_maxX = pos;
}
void MacroConditionOpenVREdit::MaxYChanged(double pos)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_maxY = pos;
}
void MacroConditionOpenVREdit::MaxZChanged(double pos)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(GetSwitcher()->m);
_entryData->_maxZ = pos;
}
void MacroConditionOpenVREdit::UpdateOpenVRPos()
{
vr::EVRInitError err;
TrackingData data = getOpenVRPos(err);
if (data.valid) {
_xPos->setText(QString::number(data.x));
_yPos->setText(QString::number(data.y));
_zPos->setText(QString::number(data.z));
} else {
_xPos->setText("-");
_yPos->setText("-");
_zPos->setText("-");
_errLabel->setText(
QString(obs_module_text(
"AdvSceneSwitcher.condition.errorStatus")) +
QString(vr::VR_GetVRInitErrorAsEnglishDescription(err)));
}
_errLabel->setVisible(!data.valid);
adjustSize();
}
void MacroConditionOpenVREdit::UpdateEntryData()
{
if (!_entryData) {
return;
}
_minX->setValue(_entryData->_minX);
_minY->setValue(_entryData->_minY);
_maxX->setValue(_entryData->_maxX);
_maxY->setValue(_entryData->_maxY);
}

View File

@@ -0,0 +1,69 @@
#pragma once
#include <macro.hpp>
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QPushButton>
#include <QTimer>
class MacroConditionOpenVR : public MacroCondition {
public:
MacroConditionOpenVR(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionOpenVR>(m);
}
double _minX = 0, _minY = 0, _minZ = 0, _maxX = 0, _maxY = 0, _maxZ = 0;
private:
static bool _registered;
static const std::string id;
};
class MacroConditionOpenVREdit : public QWidget {
Q_OBJECT
public:
MacroConditionOpenVREdit(
QWidget *parent,
std::shared_ptr<MacroConditionOpenVR> cond = nullptr);
void UpdateEntryData();
static QWidget *Create(QWidget *parent,
std::shared_ptr<MacroCondition> cond)
{
return new MacroConditionOpenVREdit(
parent,
std::dynamic_pointer_cast<MacroConditionOpenVR>(cond));
}
private slots:
void MinXChanged(double pos);
void MinYChanged(double pos);
void MinZChanged(double pos);
void MaxXChanged(double pos);
void MaxYChanged(double pos);
void MaxZChanged(double pos);
void UpdateOpenVRPos();
protected:
QDoubleSpinBox *_minX;
QDoubleSpinBox *_minY;
QDoubleSpinBox *_minZ;
QDoubleSpinBox *_maxX;
QDoubleSpinBox *_maxY;
QDoubleSpinBox *_maxZ;
QLabel *_xPos;
QLabel *_yPos;
QLabel *_zPos;
QLabel *_errLabel;
std::shared_ptr<MacroConditionOpenVR> _entryData;
private:
QTimer _timer;
bool _loading = true;
};

View File

@@ -1,13 +1,11 @@
#include "headers/advanced-scene-switcher.hpp"
#include "headers/status-control.hpp"
#include "headers/utility.hpp"
#include "headers/version.h"
#include <QFileDialog>
#include <QGuiApplication>
#include <QStandardPaths>
QMetaObject::Connection inactivePluse;
void AdvSceneSwitcher::on_close_clicked()
{
close();
@@ -147,41 +145,6 @@ void AdvSceneSwitcher::on_checkInterval_valueChanged(int value)
switcher->interval = value;
}
void AdvSceneSwitcher::SetStarted()
{
ui->toggleStartButton->setText(
obs_module_text("AdvSceneSwitcher.generalTab.status.stop"));
ui->pluginRunningText->setText(
obs_module_text("AdvSceneSwitcher.status.active"));
ui->pluginRunningText->disconnect(inactivePluse);
currentStatusActive = true;
}
void AdvSceneSwitcher::SetStopped()
{
ui->toggleStartButton->setText(
obs_module_text("AdvSceneSwitcher.generalTab.status.start"));
ui->pluginRunningText->setText(
obs_module_text("AdvSceneSwitcher.status.inactive"));
if (!switcher->disableHints) {
inactivePluse = PulseWidget(ui->pluginRunningText,
QColor(Qt::red), QColor(0, 0, 0, 0),
"QLabel ");
}
currentStatusActive = false;
}
void AdvSceneSwitcher::on_toggleStartButton_clicked()
{
if (switcher->th && switcher->th->isRunning()) {
switcher->Stop();
SetStopped();
} else {
switcher->Start();
SetStarted();
}
}
void AdvSceneSwitcher::closeEvent(QCloseEvent *)
{
if (!switcher) {
@@ -436,11 +399,6 @@ void AdvSceneSwitcher::setTabOrder()
connect(bar, &QTabBar::tabMoved, this, &AdvSceneSwitcher::on_tabMoved);
}
bool windowPosValid(QPoint pos)
{
return !!QGuiApplication::screenAt(pos);
}
void AdvSceneSwitcher::restoreWindowGeo()
{
if (switcher->saveWindowGeo && windowPosValid(switcher->windowPos)) {
@@ -449,6 +407,14 @@ void AdvSceneSwitcher::restoreWindowGeo()
}
}
void AdvSceneSwitcher::checkFirstTimeSetup()
{
if (switcher->firstBoot && !switcher->disableHints) {
DisplayMessage(
obs_module_text("AdvSceneSwitcher.firstBootMessage"));
}
}
void AdvSceneSwitcher::on_tabMoved(int from, int to)
{
if (loading) {
@@ -458,10 +424,8 @@ void AdvSceneSwitcher::on_tabMoved(int from, int to)
std::swap(switcher->tabOrder[from], switcher->tabOrder[to]);
}
void AdvSceneSwitcher::on_tabWidget_currentChanged(int index)
void AdvSceneSwitcher::on_tabWidget_currentChanged(int)
{
UNUSED_PARAMETER(index);
switcher->showFrame = false;
clearFrames(ui->screenRegionSwitches);
SetShowFrames();
@@ -788,21 +752,6 @@ void populateAutoStartEventSelection(QComboBox *cb)
"AdvSceneSwitcher.generalTab.status.autoStart.recordingAndStreaming"));
}
void AdvSceneSwitcher::updateStatus()
{
if (switcher->th && switcher->th->isRunning()) {
if (currentStatusActive) {
return;
}
SetStarted();
} else {
if (!currentStatusActive) {
return;
}
SetStopped();
}
}
void AdvSceneSwitcher::setupGeneralTab()
{
populateSceneSelection(ui->noMatchSwitchScene, false);
@@ -923,17 +872,17 @@ void AdvSceneSwitcher::setupGeneralTab()
ui->autoStartEvent->setCurrentIndex(
static_cast<int>(switcher->autoStartEvent));
if (switcher->th && switcher->th->isRunning()) {
SetStarted();
} else {
SetStopped();
}
// Updates the UI status element if the status changed externally
// (e.g. via hotkeys)
QTimer *statusTimer = new QTimer(this);
connect(statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
statusTimer->start(1000);
// Set up status control
auto statusControl = new StatusControl(this, true);
ui->statusLayout->addWidget(statusControl->StatusPrefixLabel(), 1, 0);
auto tmp = new QHBoxLayout;
tmp->addWidget(statusControl->StatusLabel());
tmp->addStretch();
ui->statusLayout->addLayout(tmp, 1, 1);
ui->statusLayout->addWidget(statusControl->Button(), 2, 1);
// Hide the now empty invisible shell of the statusControl widget
// as otherwise it could block user input
statusControl->hide();
setWindowTitle(windowTitle() + " - " + g_GIT_TAG);
}

View File

@@ -1,6 +1,8 @@
#pragma once
#ifdef BUILD_OUT_OF_TREE
#include "../../forms/ui_advanced-scene-switcher.h"
#elif defined ADVSS_MODULE
#include "../../../ui_advanced-scene-switcher.h"
#else
#include "ui_advanced-scene-switcher.h"
#endif
@@ -26,7 +28,6 @@ class AdvSceneSwitcher : public QDialog {
public:
std::unique_ptr<Ui_AdvSceneSwitcher> ui;
bool loading = true;
bool currentStatusActive = false;
AdvSceneSwitcher(QWidget *parent);
~AdvSceneSwitcher();
@@ -34,9 +35,6 @@ public:
void reject() override;
void closeEvent(QCloseEvent *event) override;
void SetStarted();
void SetStopped();
void SetShowFrames();
void SetHideFrames();
void clearFrames(QListWidget *list);
@@ -81,6 +79,7 @@ public:
void setupMacroTab();
void setTabOrder();
void restoreWindowGeo();
void checkFirstTimeSetup();
signals:
void MacroAdded(const QString &name);
@@ -106,7 +105,6 @@ public slots:
void on_autoStartEvent_currentIndexChanged(int index);
void on_noMatchSwitchScene_currentTextChanged(const QString &text);
void on_checkInterval_valueChanged(int value);
void on_toggleStartButton_clicked();
void on_tabMoved(int from, int to);
void on_tabWidget_currentChanged(int index);
@@ -117,6 +115,7 @@ public slots:
void on_macroName_editingFinished();
void on_runMacro_clicked();
void on_runMacroInParallel_stateChanged(int value);
void on_runMacroOnChange_stateChanged(int value);
void on_macros_currentRowChanged(int idx);
void on_macros_itemChanged(QListWidgetItem *);
void on_conditionAdd_clicked();
@@ -268,7 +267,6 @@ public slots:
void on_threadPriority_currentTextChanged(const QString &text);
void updateScreenRegionCursorPos();
void updateStatus();
void on_close_clicked();
@@ -297,3 +295,4 @@ void AskForBackup(obs_data_t *obj);
******************************************************************************/
struct SwitcherData;
extern SwitcherData *switcher;
SwitcherData *GetSwitcher();

View File

@@ -42,6 +42,7 @@ public:
void SetValue(double value);
void SetUnit(DurationUnit u);
void SetDuration(Duration d);
QDoubleSpinBox *SpinBox() { return _duration; }
private slots:
void _DurationChanged(double value);

View File

@@ -15,15 +15,16 @@ enum class AudioAction {
class MacroActionAudio : public MacroAction {
public:
MacroActionAudio(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionAudio>();
return std::make_shared<MacroActionAudio>(m);
}
OBSWeakSource _audioSource;

View File

@@ -2,7 +2,7 @@
#include "macro.hpp"
struct MacroActionInfo {
using TCreateMethod = std::shared_ptr<MacroAction> (*)();
using TCreateMethod = std::shared_ptr<MacroAction> (*)(Macro *m);
using TCreateWidgetMethod = QWidget *(*)(QWidget *parent,
std::shared_ptr<MacroAction>);
TCreateMethod _createFunc = nullptr;
@@ -14,7 +14,8 @@ class MacroActionFactory {
public:
MacroActionFactory() = delete;
static bool Register(const std::string &id, MacroActionInfo);
static std::shared_ptr<MacroAction> Create(const std::string &id);
static std::shared_ptr<MacroAction> Create(const std::string &id,
Macro *m);
static QWidget *CreateWidget(const std::string &id, QWidget *parent,
std::shared_ptr<MacroAction> action);
static auto GetActionTypes() { return _methods; }

View File

@@ -11,15 +11,16 @@ enum class FileAction {
class MacroActionFile : public MacroAction {
public:
MacroActionFile(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionFile>();
return std::make_shared<MacroActionFile>(m);
}
std::string _file = obs_module_text("AdvSceneSwitcher.enterPath");

View File

@@ -11,15 +11,16 @@ enum class FilterAction {
class MacroActionFilter : public MacroAction {
public:
MacroActionFilter(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionFilter>();
return std::make_shared<MacroActionFilter>(m);
}
OBSWeakSource _source;

View File

@@ -8,14 +8,15 @@
class MacroActionHotkey : public MacroAction {
public:
MacroActionHotkey(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionHotkey>();
return std::make_shared<MacroActionHotkey>(m);
}
OBSWeakSource _HotkeySource;

View File

@@ -9,19 +9,21 @@ enum class PerformMacroAction {
UNPAUSE,
RESET_COUNTER,
RUN,
STOP,
};
class MacroActionMacro : public MacroRefAction {
public:
MacroActionMacro(Macro *m) : MacroRefAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionMacro>();
return std::make_shared<MacroActionMacro>(m);
}
PerformMacroAction _action = PerformMacroAction::PAUSE;

View File

@@ -15,15 +15,16 @@ enum class MediaAction {
class MacroActionMedia : public MacroAction {
public:
MacroActionMedia(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionMedia>();
return std::make_shared<MacroActionMedia>(m);
}
OBSWeakSource _mediaSource;

View File

@@ -1,28 +1,32 @@
#pragma once
#include "macro-action-edit.hpp"
#include "file-selection.hpp"
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QLabel>
enum class PluginStateAction {
STOP,
NO_MATCH_BEHAVIOUR,
IMPORT_SETTINGS,
};
class MacroActionPluginState : public MacroAction {
public:
MacroActionPluginState(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionPluginState>();
return std::make_shared<MacroActionPluginState>(m);
}
PluginStateAction _action = PluginStateAction::STOP;
int _value = 0;
std::string _settingsPath;
OBSWeakSource _scene;
private:
@@ -51,15 +55,17 @@ private slots:
void ActionChanged(int value);
void ValueChanged(int value);
void SceneChanged(const QString &text);
void PathChanged(const QString &text);
protected:
QComboBox *_actions;
QComboBox *_values;
QComboBox *_scenes;
FileSelection *_settings;
QLabel *_settingsWarning;
std::shared_ptr<MacroActionPluginState> _entryData;
private:
void SetWidgetVisibility(PluginStateAction, int);
QHBoxLayout *_mainLayout;
void SetWidgetVisibility();
bool _loading = true;
};

View File

@@ -4,15 +4,16 @@
class MacroActionPreviewScene : public MacroAction {
public:
MacroActionPreviewScene(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionPreviewScene>();
return std::make_shared<MacroActionPreviewScene>(m);
}
SceneSelection _scene;

View File

@@ -0,0 +1,52 @@
#pragma once
#include "macro-action-edit.hpp"
class MacroActionProfile : public MacroAction {
public:
MacroActionProfile(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionProfile>(m);
}
std::string _profile;
private:
static bool _registered;
static const std::string id;
};
class MacroActionProfileEdit : public QWidget {
Q_OBJECT
public:
MacroActionProfileEdit(
QWidget *parent,
std::shared_ptr<MacroActionProfile> entryData = nullptr);
void UpdateEntryData();
static QWidget *Create(QWidget *parent,
std::shared_ptr<MacroAction> action)
{
return new MacroActionProfileEdit(
parent,
std::dynamic_pointer_cast<MacroActionProfile>(action));
}
private slots:
void ProfileChanged(const QString &text);
signals:
void HeaderInfoChanged(const QString &);
protected:
QComboBox *_profiles;
std::shared_ptr<MacroActionProfile> _entryData;
private:
bool _loading = true;
};

View File

@@ -4,19 +4,19 @@
#include <QPushButton>
#include <QListWidget>
#include <QDialog>
#include <unordered_map>
class MacroActionRandom : public MultiMacroRefAction {
public:
MacroActionRandom(Macro *m) : MultiMacroRefAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionRandom>();
return std::make_shared<MacroActionRandom>(m);
}
// TODO: add weights to each macro ...
@@ -28,17 +28,6 @@ private:
static const std::string id;
};
class MacroDialog : public QDialog {
Q_OBJECT
public:
MacroDialog(QWidget *parent);
static bool AskForMacro(QWidget *parent, std::string &macroName);
private:
MacroSelection *_macroSelection;
};
class MacroActionRandomEdit : public QWidget {
Q_OBJECT

View File

@@ -13,14 +13,15 @@ enum class RecordAction {
class MacroActionRecord : public MacroAction {
public:
MacroActionRecord(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionRecord>();
return std::make_shared<MacroActionRecord>(m);
}
RecordAction _action = RecordAction::STOP;

View File

@@ -14,14 +14,15 @@ enum class ReplayBufferAction {
class MacroActionReplayBuffer : public MacroAction {
public:
MacroActionReplayBuffer(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionReplayBuffer>();
return std::make_shared<MacroActionReplayBuffer>(m);
}
ReplayBufferAction _action = ReplayBufferAction::STOP;

View File

@@ -9,15 +9,16 @@
class MacroActionRun : public MacroAction {
public:
MacroActionRun(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionRun>();
return std::make_shared<MacroActionRun>(m);
}
std::string _path = obs_module_text("AdvSceneSwitcher.enterPath");

View File

@@ -0,0 +1,53 @@
#pragma once
#include "macro-action-edit.hpp"
class MacroActionSceneCollection : public MacroAction {
public:
MacroActionSceneCollection(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSceneCollection>(m);
}
std::string _sceneCollection;
private:
static bool _registered;
static const std::string id;
};
class MacroActionSceneCollectionEdit : public QWidget {
Q_OBJECT
public:
MacroActionSceneCollectionEdit(
QWidget *parent,
std::shared_ptr<MacroActionSceneCollection> entryData = nullptr);
void UpdateEntryData();
static QWidget *Create(QWidget *parent,
std::shared_ptr<MacroAction> action)
{
return new MacroActionSceneCollectionEdit(
parent,
std::dynamic_pointer_cast<MacroActionSceneCollection>(
action));
}
private slots:
void SceneCollectionChanged(const QString &text);
signals:
void HeaderInfoChanged(const QString &);
protected:
QComboBox *_sceneCollections;
std::shared_ptr<MacroActionSceneCollection> _entryData;
private:
bool _loading = true;
};

View File

@@ -1,7 +1,9 @@
#pragma once
#include <QSpinBox>
#include "macro-action-edit.hpp"
#include "scene-selection.hpp"
#include "scene-item-selection.hpp"
#include <QSpinBox>
enum class SceneOrderAction {
MOVE_UP,
@@ -13,19 +15,20 @@ enum class SceneOrderAction {
class MacroActionSceneOrder : public MacroAction {
public:
MacroActionSceneOrder(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSceneOrder>();
return std::make_shared<MacroActionSceneOrder>(m);
}
SceneSelection _scene;
OBSWeakSource _source;
SceneItemSelection _source;
SceneOrderAction _action = SceneOrderAction::MOVE_UP;
int _position = 0;
@@ -53,7 +56,7 @@ public:
private slots:
void SceneChanged(const SceneSelection &);
void SourceChanged(const QString &text);
void SourceChanged(const SceneItemSelection &);
void ActionChanged(int value);
void PositionChanged(int value);
signals:
@@ -61,7 +64,7 @@ signals:
protected:
SceneSelectionWidget *_scenes;
QComboBox *_sources;
SceneItemSelectionWidget *_sources;
QComboBox *_actions;
QSpinBox *_position;
std::shared_ptr<MacroActionSceneOrder> _entryData;

View File

@@ -3,14 +3,15 @@
class MacroActionSceneSwap : public MacroAction {
public:
MacroActionSceneSwap(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSceneSwap>();
return std::make_shared<MacroActionSceneSwap>(m);
}
private:

View File

@@ -1,12 +1,14 @@
#pragma once
#include "macro-action-edit.hpp"
#include "switch-generic.hpp"
#include "scene-selection.hpp"
#include "transition-selection.hpp"
#include "duration-control.hpp"
// TODO: Switch to using SceneSelection class and widget instead
#include <QCheckBox>
class MacroActionSwitchScene : public MacroAction, public SceneSwitcherEntry {
class MacroActionSwitchScene : public MacroAction {
public:
MacroActionSwitchScene(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
@@ -14,11 +16,14 @@ public:
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSwitchScene>();
return std::make_shared<MacroActionSwitchScene>(m);
}
SceneSelection _scene;
TransitionSelection _transition;
Duration _duration;
bool _blockUntilTransitionDone = true;
private:
const char *getType() { return "MacroActionSwitchScene"; }
@@ -27,7 +32,7 @@ private:
static const std::string id;
};
class MacroActionSwitchSceneEdit : public SwitchWidget {
class MacroActionSwitchSceneEdit : public QWidget {
Q_OBJECT
public:
@@ -44,12 +49,21 @@ public:
}
private slots:
void SceneChanged(const SceneSelection &);
void TransitionChanged(const TransitionSelection &);
void DurationChanged(double seconds);
void ChangeHeaderInfo(const QString &);
void BlockUntilTransitionDoneChanged(int state);
signals:
void HeaderInfoChanged(const QString &);
protected:
SceneSelectionWidget *_scenes;
TransitionSelectionWidget *_transitions;
DurationSelection *_duration;
QCheckBox *_blockUntilTransitionDone;
std::shared_ptr<MacroActionSwitchScene> _entryData;
private:
bool _loading = true;
};

View File

@@ -1,26 +1,29 @@
#pragma once
#include <QSpinBox>
#include <QPlainTextEdit>
#include "macro-action-edit.hpp"
#include "scene-selection.hpp"
#include "scene-item-selection.hpp"
#include <QSpinBox>
#include <QPlainTextEdit>
class MacroActionSceneTransform : public MacroAction {
public:
MacroActionSceneTransform(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSceneTransform>();
return std::make_shared<MacroActionSceneTransform>(m);
}
std::string GetSettings();
void SetSettings(std::string &);
SceneSelection _scene;
OBSWeakSource _source;
SceneItemSelection _source;
struct obs_transform_info _info = {};
struct obs_sceneitem_crop _crop = {};
@@ -48,7 +51,7 @@ public:
private slots:
void SceneChanged(const SceneSelection &);
void SourceChanged(const QString &text);
void SourceChanged(const SceneItemSelection &);
void GetSettingsClicked();
void SettingsChanged();
signals:
@@ -56,7 +59,7 @@ signals:
protected:
SceneSelectionWidget *_scenes;
QComboBox *_sources;
SceneItemSelectionWidget *_sources;
QPushButton *_getSettings;
QPlainTextEdit *_settings;
std::shared_ptr<MacroActionSceneTransform> _entryData;

View File

@@ -1,7 +1,9 @@
#pragma once
#include <QSpinBox>
#include "macro-action-edit.hpp"
#include "scene-selection.hpp"
#include "scene-item-selection.hpp"
#include <QSpinBox>
enum class SceneVisibilityAction {
SHOW,
@@ -15,20 +17,21 @@ enum class SceneItemSourceType {
class MacroActionSceneVisibility : public MacroAction {
public:
MacroActionSceneVisibility(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSceneVisibility>();
return std::make_shared<MacroActionSceneVisibility>(m);
}
SceneSelection _scene;
SceneItemSourceType _sourceType = SceneItemSourceType::SOURCE;
OBSWeakSource _source;
SceneItemSelection _source;
std::string _sourceGroup = "";
SceneVisibilityAction _action = SceneVisibilityAction::SHOW;
@@ -57,7 +60,8 @@ public:
private slots:
void SceneChanged(const SceneSelection &);
void SourceTypeChanged(int value);
void SourceChanged(const QString &text);
void SourceChanged(const SceneItemSelection &);
void SourceGroupChanged(const QString &text);
void ActionChanged(int value);
signals:
void HeaderInfoChanged(const QString &);
@@ -65,11 +69,14 @@ signals:
protected:
SceneSelectionWidget *_scenes;
QComboBox *_sourceTypes;
QComboBox *_sources;
SceneItemSelectionWidget *_sources;
QComboBox *_sourceGroups;
QComboBox *_actions;
std::shared_ptr<MacroActionSceneVisibility> _entryData;
private:
void SetWidgetVisibility();
QHBoxLayout *_mainLayout;
bool _loading = true;
};

View File

@@ -3,15 +3,16 @@
class MacroActionScreenshot : public MacroAction {
public:
MacroActionScreenshot(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionScreenshot>();
return std::make_shared<MacroActionScreenshot>(m);
}
OBSWeakSource _source;

View File

@@ -0,0 +1,77 @@
#pragma once
#include "macro-action-edit.hpp"
#include "macro-selection.hpp"
#include <QPushButton>
#include <QListWidget>
#include <QCheckBox>
#include <QTimer>
class MacroActionSequence : public MultiMacroRefAction {
public:
MacroActionSequence(Macro *m) : MultiMacroRefAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
MacroRef GetNextMacro(bool advance = true);
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSequence>(m);
}
bool _restart = true;
MacroRef _lastSequenceMacro;
int _lastIdx = -1;
private:
static bool _registered;
static const std::string id;
};
class MacroActionSequenceEdit : public QWidget {
Q_OBJECT
public:
MacroActionSequenceEdit(
QWidget *parent,
std::shared_ptr<MacroActionSequence> entryData = nullptr);
void UpdateEntryData();
static QWidget *Create(QWidget *parent,
std::shared_ptr<MacroAction> action)
{
return new MacroActionSequenceEdit(
parent,
std::dynamic_pointer_cast<MacroActionSequence>(action));
}
private slots:
void MacroRemove(const QString &name);
void MacroRename(const QString &oldName, const QString &newName);
void Add();
void Remove();
void Up();
void Down();
void ContinueFromClicked();
void RestartChanged(int state);
void UpdateStatusLine();
protected:
std::shared_ptr<MacroActionSequence> _entryData;
private:
int FindEntry(const std::string &macro);
void SetMacroListSize();
QListWidget *_macroList;
QPushButton *_add;
QPushButton *_remove;
QPushButton *_up;
QPushButton *_down;
QPushButton *_continueFrom;
QCheckBox *_restart;
QLabel *_statusLine;
QTimer _statusTimer;
bool _loading = true;
};

View File

@@ -14,15 +14,16 @@ enum class SourceAction {
class MacroActionSource : public MacroAction {
public:
MacroActionSource(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSource>();
return std::make_shared<MacroActionSource>(m);
}
OBSWeakSource _source;

View File

@@ -13,14 +13,15 @@ enum class StreamAction {
class MacroActionStream : public MacroAction {
public:
MacroActionStream(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionStream>();
return std::make_shared<MacroActionStream>(m);
}
StreamAction _action = StreamAction::STOP;

View File

@@ -5,14 +5,15 @@
class MacroActionSystray : public MacroAction {
public:
MacroActionSystray(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionSystray>();
return std::make_shared<MacroActionSystray>(m);
}
std::string _msg = "";

View File

@@ -15,15 +15,16 @@ enum class TimerAction {
class MacroActionTimer : public MacroRefAction {
public:
MacroActionTimer(Macro *m) : MacroRefAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionTimer>();
return std::make_shared<MacroActionTimer>(m);
}
Duration _duration;
TimerAction _actionType = TimerAction::PAUSE;

View File

@@ -8,15 +8,16 @@
class MacroActionTransition : public MacroAction {
public:
MacroActionTransition(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionTransition>();
return std::make_shared<MacroActionTransition>(m);
}
bool _setDuration = true;

View File

@@ -13,14 +13,15 @@ enum class VCamAction {
class MacroActionVCam : public MacroAction {
public:
MacroActionVCam(Macro *m) : MacroAction(m) {}
bool PerformAction();
void LogAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionVCam>();
return std::make_shared<MacroActionVCam>(m);
}
VCamAction _action = VCamAction::STOP;

View File

@@ -12,13 +12,14 @@ enum class WaitType {
class MacroActionWait : public MacroAction {
public:
MacroActionWait(Macro *m) : MacroAction(m) {}
bool PerformAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroAction> Create()
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionWait>();
return std::make_shared<MacroActionWait>(m);
}
Duration _duration;
Duration _duration2;

View File

@@ -6,22 +6,39 @@
#include <QComboBox>
#include <chrono>
enum class AudioCondition {
enum class AudioConditionCheckType {
OUTPUT_VOLUME,
CONFIGURED_VOLUME,
};
enum class AudioOutputCondition {
ABOVE,
BELOW,
// TODO: To be removed
MUTE,
UNMUTE,
};
enum class AudioVolumeCondition {
ABOVE,
EXACT,
BELOW,
MUTE,
UNMUTE,
};
class MacroConditionAudio : public MacroCondition {
public:
MacroConditionAudio(Macro *m) : MacroCondition(m) {}
~MacroConditionAudio();
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionAudio>();
return std::make_shared<MacroConditionAudio>(m);
}
static void SetVolumeLevel(void *data,
const float magnitude[MAX_AUDIO_CHANNELS],
@@ -31,10 +48,16 @@ public:
OBSWeakSource _audioSource;
int _volume = 0;
AudioCondition _condition = AudioCondition::ABOVE;
AudioConditionCheckType _checkType =
AudioConditionCheckType::OUTPUT_VOLUME;
AudioOutputCondition _outputCondition = AudioOutputCondition::ABOVE;
AudioVolumeCondition _volumeCondition = AudioVolumeCondition::ABOVE;
obs_volmeter_t *_volmeter = nullptr;
private:
bool CheckOutputCondition();
bool CheckVolumeCondition();
float _peak = -std::numeric_limits<float>::infinity();
static bool _registered;
static const std::string id;
@@ -61,10 +84,13 @@ private slots:
void SourceChanged(const QString &text);
void VolumeThresholdChanged(int vol);
void ConditionChanged(int cond);
void CheckTypeChanged(int cond);
signals:
void HeaderInfoChanged(const QString &);
protected:
QComboBox *_checkTypes;
QComboBox *_audioSources;
QComboBox *_condition;
QSpinBox *_volume;
@@ -72,5 +98,7 @@ protected:
std::shared_ptr<MacroConditionAudio> _entryData;
private:
void SetWidgetVisibility();
bool _loading = true;
};

View File

@@ -14,13 +14,14 @@ enum class CursorCondition {
class MacroConditionCursor : public MacroCondition {
public:
MacroConditionCursor(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionCursor>();
return std::make_shared<MacroConditionCursor>(m);
}
CursorCondition _condition = CursorCondition::REGION;

View File

@@ -15,14 +15,15 @@ enum class DateCondition {
class MacroConditionDate : public MacroCondition {
public:
MacroConditionDate(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionDate>();
return std::make_shared<MacroConditionDate>(m);
}
QDateTime _dateTime;

View File

@@ -2,7 +2,7 @@
#include "macro.hpp"
struct MacroConditionInfo {
using TCreateMethod = std::shared_ptr<MacroCondition> (*)();
using TCreateMethod = std::shared_ptr<MacroCondition> (*)(Macro *m);
using TCreateWidgetMethod =
QWidget *(*)(QWidget *parent, std::shared_ptr<MacroCondition>);
TCreateMethod _createFunc = nullptr;
@@ -15,7 +15,8 @@ class MacroConditionFactory {
public:
MacroConditionFactory() = delete;
static bool Register(const std::string &, MacroConditionInfo);
static std::shared_ptr<MacroCondition> Create(const std::string &);
static std::shared_ptr<MacroCondition> Create(const std::string &,
Macro *m);
static QWidget *CreateWidget(const std::string &id, QWidget *parent,
std::shared_ptr<MacroCondition>);
static auto GetConditionTypes() { return _methods; }

View File

@@ -17,14 +17,15 @@ enum class FileType {
class MacroConditionFile : public MacroCondition {
public:
MacroConditionFile(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionFile>();
return std::make_shared<MacroConditionFile>(m);
}
std::string _file = obs_module_text("AdvSceneSwitcher.enterPath");

View File

@@ -14,14 +14,15 @@ enum class FilterCondition {
class MacroConditionFilter : public MacroCondition {
public:
MacroConditionFilter(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionFilter>();
return std::make_shared<MacroConditionFilter>(m);
}
OBSWeakSource _source;

View File

@@ -5,15 +5,15 @@
class MacroConditionHotkey : public MacroCondition {
public:
MacroConditionHotkey();
MacroConditionHotkey(Macro *m);
~MacroConditionHotkey();
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionHotkey>();
return std::make_shared<MacroConditionHotkey>(m);
}
void SetPressed() { _pressed = true; }

View File

@@ -7,13 +7,14 @@
class MacroConditionIdle : public MacroCondition {
public:
MacroConditionIdle(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionIdle>();
return std::make_shared<MacroConditionIdle>(m);
}
Duration _duration;

View File

@@ -21,14 +21,15 @@ enum class CounterCondition {
class MacroConditionMacro : public MacroRefCondition {
public:
MacroConditionMacro(Macro *m) : MacroRefCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionMacro>();
return std::make_shared<MacroConditionMacro>(m);
}
MacroConditionMacroType _type = MacroConditionMacroType::STATE;

View File

@@ -43,15 +43,16 @@ enum class MediaSourceType {
class MacroConditionMedia : public MacroCondition {
public:
MacroConditionMedia(Macro *m) : MacroCondition(m) {}
~MacroConditionMedia();
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionMedia>();
return std::make_shared<MacroConditionMedia>(m);
}
void ClearSignalHandler();
void ResetSignalHandler();

View File

@@ -10,13 +10,14 @@ enum class PluginStateCondition {
class MacroConditionPluginState : public MacroCondition {
public:
MacroConditionPluginState(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionPluginState>();
return std::make_shared<MacroConditionPluginState>(m);
}
PluginStateCondition _condition = PluginStateCondition::SCENESWITCHED;

View File

@@ -6,14 +6,15 @@
class MacroConditionProcess : public MacroCondition {
public:
MacroConditionProcess(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionProcess>();
return std::make_shared<MacroConditionProcess>(m);
}
std::string _process;

View File

@@ -11,13 +11,14 @@ enum class RecordState {
class MacroConditionRecord : public MacroCondition {
public:
MacroConditionRecord(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionRecord>();
return std::make_shared<MacroConditionRecord>(m);
}
RecordState _recordState = RecordState::STOP;

View File

@@ -13,13 +13,14 @@ enum class ReplayBufferState {
class MacroConditionReplayBuffer : public MacroCondition {
public:
MacroConditionReplayBuffer(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionReplayBuffer>();
return std::make_shared<MacroConditionReplayBuffer>(m);
}
ReplayBufferState _state = ReplayBufferState::STOP;

View File

@@ -1,6 +1,7 @@
#pragma once
#include "macro.hpp"
#include "scene-selection.hpp"
#include "scene-item-selection.hpp"
#include <QWidget>
#include <QComboBox>
@@ -13,19 +14,20 @@ enum class SceneOrderCondition {
class MacroConditionSceneOrder : public MacroCondition {
public:
MacroConditionSceneOrder(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionSceneOrder>();
return std::make_shared<MacroConditionSceneOrder>(m);
}
SceneSelection _scene;
OBSWeakSource _source;
OBSWeakSource _source2;
SceneItemSelection _source;
SceneItemSelection _source2;
int _position = 0;
SceneOrderCondition _condition = SceneOrderCondition::ABOVE;
@@ -53,8 +55,8 @@ public:
private slots:
void SceneChanged(const SceneSelection &);
void SourceChanged(const QString &text);
void Source2Changed(const QString &text);
void SourceChanged(const SceneItemSelection &);
void Source2Changed(const SceneItemSelection &);
void ConditionChanged(int cond);
void PositionChanged(int cond);
signals:
@@ -63,8 +65,8 @@ signals:
protected:
SceneSelectionWidget *_scenes;
QComboBox *_conditions;
QComboBox *_sources;
QComboBox *_sources2;
SceneItemSelectionWidget *_sources;
SceneItemSelectionWidget *_sources2;
QSpinBox *_position;
QLabel *_posInfo;

View File

@@ -1,6 +1,7 @@
#pragma once
#include "macro.hpp"
#include "scene-selection.hpp"
#include "scene-item-selection.hpp"
#include <QSpinBox>
#include <QPlainTextEdit>
@@ -8,18 +9,19 @@
class MacroConditionSceneTransform : public MacroCondition {
public:
MacroConditionSceneTransform(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionSceneTransform>();
return std::make_shared<MacroConditionSceneTransform>(m);
}
SceneSelection _scene;
OBSWeakSource _source;
SceneItemSelection _source;
bool _regex = false;
std::string _settings = "";
@@ -48,7 +50,7 @@ public:
private slots:
void SceneChanged(const SceneSelection &);
void SourceChanged(const QString &text);
void SourceChanged(const SceneItemSelection &);
void GetSettingsClicked();
void SettingsChanged();
void RegexChanged(int);
@@ -57,7 +59,7 @@ signals:
protected:
SceneSelectionWidget *_scenes;
QComboBox *_sources;
SceneItemSelectionWidget *_sources;
QPushButton *_getSettings;
QPlainTextEdit *_settings;
QCheckBox *_regex;

View File

@@ -1,6 +1,7 @@
#pragma once
#include "macro.hpp"
#include "scene-selection.hpp"
#include "scene-item-selection.hpp"
#include <QComboBox>
@@ -11,18 +12,19 @@ enum class SceneVisibilityCondition {
class MacroConditionSceneVisibility : public MacroCondition {
public:
MacroConditionSceneVisibility(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionSceneVisibility>();
return std::make_shared<MacroConditionSceneVisibility>(m);
}
SceneSelection _scene;
OBSWeakSource _source;
SceneItemSelection _source;
SceneVisibilityCondition _condition = SceneVisibilityCondition::SHOWN;
private:
@@ -49,14 +51,14 @@ public:
private slots:
void SceneChanged(const SceneSelection &);
void SourceChanged(const QString &text);
void SourceChanged(const SceneItemSelection &);
void ConditionChanged(int cond);
signals:
void HeaderInfoChanged(const QString &);
protected:
SceneSelectionWidget *_scenes;
QComboBox *_sources;
SceneItemSelectionWidget *_sources;
QComboBox *_conditions;
std::shared_ptr<MacroConditionSceneVisibility> _entryData;

View File

@@ -15,22 +15,23 @@ enum class SceneType {
class MacroConditionScene : public MacroCondition {
public:
MacroConditionScene(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionScene>();
return std::make_shared<MacroConditionScene>(m);
}
// This option is to be removed in a future version and be replaced by
// transition specific conditions
bool _waitForTransition = true;
SceneSelection _scene;
SceneType _type = SceneType::CURRENT;
// During a transition "current" scene could either stand for the scene
// being transitioned to or the scene still being transitioned away
// from.
bool _useTransitionTargetScene = false;
private:
std::chrono::high_resolution_clock::time_point _lastSceneChangeTime{};
@@ -57,14 +58,14 @@ public:
private slots:
void SceneChanged(const SceneSelection &);
void TypeChanged(int value);
void WaitForTransitionChanged(int state);
void UseTransitionTargetSceneChanged(int state);
signals:
void HeaderInfoChanged(const QString &);
protected:
SceneSelectionWidget *_scenes;
QComboBox *_sceneType;
QCheckBox *_waitForTransition;
QCheckBox *_useTransitionTargetScene;
std::shared_ptr<MacroConditionScene> _entryData;
private:

View File

@@ -14,14 +14,15 @@ enum class SourceCondition {
class MacroConditionSource : public MacroCondition {
public:
MacroConditionSource(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionSource>();
return std::make_shared<MacroConditionSource>(m);
}
OBSWeakSource _source = nullptr;

View File

@@ -12,13 +12,14 @@ enum class StreamState {
class MacroConditionStream : public MacroCondition {
public:
MacroConditionStream(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionStream>();
return std::make_shared<MacroConditionStream>(m);
}
StreamState _streamState = StreamState::STOP;

View File

@@ -0,0 +1,66 @@
#pragma once
#include "macro.hpp"
#include "scene-selection.hpp"
#include <QWidget>
#include <QComboBox>
enum class StudioModeCondition {
STUDIO_MODE_ACTIVE,
STUDIO_MODE_NOT_ACTIVE,
PREVIEW_SCENE,
};
class MacroConditionStudioMode : public MacroCondition {
public:
MacroConditionStudioMode(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionStudioMode>(m);
}
StudioModeCondition _condition =
StudioModeCondition::STUDIO_MODE_ACTIVE;
SceneSelection _scene;
private:
static bool _registered;
static const std::string id;
};
class MacroConditionStudioModeEdit : public QWidget {
Q_OBJECT
public:
MacroConditionStudioModeEdit(
QWidget *parent,
std::shared_ptr<MacroConditionStudioMode> cond = nullptr);
void UpdateEntryData();
static QWidget *Create(QWidget *parent,
std::shared_ptr<MacroCondition> cond)
{
return new MacroConditionStudioModeEdit(
parent,
std::dynamic_pointer_cast<MacroConditionStudioMode>(
cond));
}
private slots:
void ConditionChanged(int cond);
void SceneChanged(const SceneSelection &);
signals:
void HeaderInfoChanged(const QString &);
protected:
QComboBox *_condition;
SceneSelectionWidget *_scenes;
std::shared_ptr<MacroConditionStudioMode> _entryData;
private:
void SetWidgetVisibility();
bool _loading = true;
};

View File

@@ -17,13 +17,14 @@ enum class TimerType {
class MacroConditionTimer : public MacroCondition {
public:
MacroConditionTimer(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionTimer>();
return std::make_shared<MacroConditionTimer>(m);
}
void Pause();
void Continue();

View File

@@ -18,14 +18,15 @@ enum class TransitionCondition {
class MacroConditionTransition : public MacroCondition {
public:
MacroConditionTransition(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionTransition>();
return std::make_shared<MacroConditionTransition>(m);
}
void ConnectToTransitionSignals();
void DisconnectTransitionSignals();

View File

@@ -12,13 +12,14 @@ enum class VCamState {
class MacroConditionVCam : public MacroCondition {
public:
MacroConditionVCam(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionVCam>();
return std::make_shared<MacroConditionVCam>(m);
}
VCamState _state = VCamState::STOP;

View File

@@ -6,14 +6,15 @@
class MacroConditionWindow : public MacroCondition {
public:
MacroConditionWindow(Macro *m) : MacroCondition(m) {}
bool CheckCondition();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
std::string GetShortDesc();
std::string GetId() { return id; };
static std::shared_ptr<MacroCondition> Create()
static std::shared_ptr<MacroCondition> Create(Macro *m)
{
return std::make_shared<MacroConditionWindow>();
return std::make_shared<MacroConditionWindow>(m);
}
private:

View File

@@ -2,8 +2,12 @@
#include <QWidget>
#include <obs.hpp>
class Macro;
class MacroSegment {
public:
MacroSegment(Macro *m) : _macro(m) {}
Macro *GetMacro() { return _macro; }
void SetIndex(int idx) { _idx = idx; }
int GetIndex() { return _idx; }
void SetCollapsed(bool collapsed) { _collapsed = collapsed; }
@@ -16,6 +20,9 @@ public:
protected:
int _idx = 0;
bool _collapsed = false;
private:
Macro *_macro = nullptr;
};
class Section;

View File

@@ -1,5 +1,6 @@
#pragma once
#include <QComboBox>
#include <QDialog>
class Macro;
@@ -9,9 +10,22 @@ class MacroSelection : public QComboBox {
public:
MacroSelection(QWidget *parent);
void SetCurrentMacro(Macro *);
void HideSelectedMacro(); // Macro currently being edited
void ShowAllMacros();
private slots:
void MacroAdd(const QString &name);
void MacroRemove(const QString &name);
void MacroRename(const QString &oldName, const QString &newName);
};
class MacroSelectionDialog : public QDialog {
Q_OBJECT
public:
MacroSelectionDialog(QWidget *parent);
static bool AskForMacro(QWidget *parent, std::string &macroName);
private:
MacroSelection *_macroSelection;
};

View File

@@ -39,6 +39,7 @@ struct LogicTypeInfo {
class MacroCondition : public MacroSegment {
public:
MacroCondition(Macro *m) : MacroSegment(m) {}
virtual bool CheckCondition() = 0;
virtual bool Save(obs_data_t *obj) = 0;
virtual bool Load(obs_data_t *obj) = 0;
@@ -61,6 +62,7 @@ private:
class MacroAction : public MacroSegment {
public:
MacroAction(Macro *m) : MacroSegment(m) {}
virtual bool PerformAction() = 0;
virtual bool Save(obs_data_t *obj) = 0;
virtual bool Load(obs_data_t *obj) = 0;
@@ -73,7 +75,8 @@ public:
virtual ~Macro();
bool CeckMatch();
bool PerformAction(bool forceParallel = false);
bool PerformAction(bool forceParallel = false,
bool ignorePause = false);
bool Matched() { return _matched; }
std::string Name() { return _name; }
void SetName(const std::string &name);
@@ -81,8 +84,11 @@ public:
bool RunInParallel() { return _runInParallel; }
void SetPaused(bool pause = true);
bool Paused() { return _paused; }
void SetMatchOnChange(bool onChange) { _matchOnChange = onChange; }
bool MatchOnChange() { return _matchOnChange; }
int GetCount() { return _count; };
void ResetCount() { _count = 0; };
void Stop() { _stop = true; }
std::deque<std::shared_ptr<MacroCondition>> &Conditions()
{
return _conditions;
@@ -105,20 +111,23 @@ private:
void ClearHotkeys();
void SetHotkeysDesc();
void ResetTimers();
void RunActions(bool &ret);
void RunActions();
void RunActions(bool &ret, bool ignorePause);
void RunActions(bool ignorePause);
std::string _name = "";
std::deque<std::shared_ptr<MacroCondition>> _conditions;
std::deque<std::shared_ptr<MacroAction>> _actions;
bool _runInParallel = false;
bool _matched = false;
bool _lastMatched = false;
bool _matchOnChange = false;
bool _paused = false;
int _count = 0;
obs_hotkey_id _pauseHotkey = OBS_INVALID_HOTKEY_ID;
obs_hotkey_id _unpauseHotkey = OBS_INVALID_HOTKEY_ID;
obs_hotkey_id _togglePauseHotkey = OBS_INVALID_HOTKEY_ID;
bool _die = false;
bool _stop = false;
bool _done = true;
std::thread _thread;
@@ -146,18 +155,21 @@ private:
class MacroRefCondition : public MacroCondition {
public:
MacroRefCondition(Macro *m) : MacroCondition(m) {}
void ResolveMacroRef();
MacroRef _macro;
};
class MacroRefAction : public MacroAction {
public:
MacroRefAction(Macro *m) : MacroAction(m) {}
void ResolveMacroRef();
MacroRef _macro;
};
class MultiMacroRefAction : public MacroAction {
public:
MultiMacroRefAction(Macro *m) : MacroAction(m) {}
void ResolveMacroRef();
std::vector<MacroRef> _macros;
};

View File

@@ -0,0 +1,59 @@
#pragma once
#include <QComboBox>
#include <obs-data.h>
#include "scene-selection.hpp"
#include "utility.hpp"
class SceneItemSelection {
public:
void Save(obs_data_t *obj, const char *name = "sceneItem",
const char *targetName = "sceneItemTarget",
const char *idxName = "sceneItemIdx");
void Load(obs_data_t *obj, const char *name = "sceneItem",
const char *targetName = "sceneItemTarget",
const char *idxName = "sceneItemIdx");
enum class Target { ALL, ANY, INDIVIDUAL };
Target GetType() { return _target; }
std::vector<obs_scene_item *> GetSceneItems(SceneSelection &s);
std::string ToString();
private:
OBSWeakSource _sceneItem;
Target _target = Target::ALL;
int _idx = 0;
friend class SceneItemSelectionWidget;
};
class SceneItemSelectionWidget : public QWidget {
Q_OBJECT
public:
enum class AllSelectionType { ALL, ANY };
SceneItemSelectionWidget(
QWidget *parent, bool allSelection = true,
AllSelectionType allType = AllSelectionType::ALL);
void SetSceneItem(const SceneItemSelection &);
void SetScene(const SceneSelection &);
void SetShowAll(bool);
void SetShowAllSelectionType(AllSelectionType t);
signals:
void SceneItemChanged(const SceneItemSelection &);
private slots:
void SceneChanged(const SceneSelection &);
void SelectionChanged(const QString &name);
void IdxChanged(int);
private:
void SetupIdxSelection(int);
QComboBox *_sceneItems;
QComboBox *_idx;
SceneSelection _scene;
OBSWeakSource _sceneItem;
bool _showAll = false;
AllSelectionType _allType = AllSelectionType::ALL;
};

View File

@@ -0,0 +1,41 @@
#pragma once
#include <QDockWidget>
#include <QPushButton>
#include <QLabel>
#include <QTimer>
#include <obs-data.h>
class StatusControl : public QWidget {
Q_OBJECT
public:
StatusControl(QWidget *parent = 0, bool noLayout = false);
QPushButton *Button() { return _button; }
QLabel *StatusLabel() { return _status; }
QLabel *StatusPrefixLabel() { return _statusPrefix; }
private slots:
void ButtonClicked();
void UpdateStatus();
private:
void SetStopped();
void SetStarted();
QPushButton *_button;
QLabel *_status;
QLabel *_statusPrefix;
QTimer _timer;
QMetaObject::Connection _pulse;
bool _setToStopped = true;
};
class StatusDock : public QDockWidget {
Q_OBJECT
public:
StatusDock(QWidget *parent = 0);
};
void SetupDock();

View File

@@ -12,6 +12,8 @@ Most of this code is based on https://github.com/Palakis/obs-websocket
#include <QtCore/QThreadPool>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <QRunnable>
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/config/asio_no_tls.hpp>
@@ -117,3 +119,16 @@ enum class ClientStatus {
CONNECTED,
FAIL,
};
namespace Compatability {
// Reimplement QRunnable for std::function. Retrocompatability for Qt < 5.15
class StdFunctionRunnable : public QRunnable {
std::function<void()> cb;
public:
StdFunctionRunnable(std::function<void()> func);
void run() override;
};
QRunnable *CreateFunctionRunnable(std::function<void()> func);
}

View File

@@ -77,6 +77,7 @@ struct SwitcherData {
SwitcherThread *th = nullptr;
bool settingsWindowOpened = false;
bool firstBoot = true;
std::condition_variable cv;
std::mutex m;
@@ -117,6 +118,7 @@ struct SwitcherData {
std::deque<std::shared_ptr<Macro>> macros;
std::condition_variable macroWaitCv;
std::atomic_bool abortMacroWait = {false};
std::condition_variable macroTransitionCv;
bool macroSceneSwitched = false;
bool replayBufferSaved = false;

View File

@@ -27,13 +27,13 @@ std::string getSourceSettings(OBSWeakSource ws);
void setSourceSettings(obs_source_t *s, const std::string &settings);
bool compareSourceSettings(const OBSWeakSource &source,
const std::string &settings, bool regex);
std::vector<obs_scene_item *> getSceneItemsWithName(OBSScene scene,
std::vector<obs_scene_item *> getSceneItemsWithName(obs_scene_t *scene,
std::string &name);
std::string getDataFilePath(const std::string &file);
bool matchJson(const std::string &json1, const std::string &json2,
bool useRegex);
QString formatJsonString(std::string);
QString formatJsonString(const char *);
QString formatJsonString(QString);
QString escapeForRegex(QString &s);
void loadTransformState(obs_data_t *obj, struct obs_transform_info &info,
struct obs_sceneitem_crop &crop);
@@ -81,4 +81,5 @@ void populateFilterSelection(QComboBox *list,
void populateSceneItemSelection(QComboBox *list,
OBSWeakSource sceneWeakSource = nullptr);
void populateSceneItemSelection(QComboBox *list, SceneSelection &s);
void populateSourceTypeSelection(QComboBox *list);
void populateSourceGroupSelection(QComboBox *list);
bool windowPosValid(QPoint pos);

View File

@@ -4,13 +4,8 @@
#include <fstream>
#include <regex>
void startHotkeyFunc(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
bool pressed)
void startHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *, bool pressed)
{
UNUSED_PARAMETER(id);
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(hotkey);
if (pressed) {
if (!(switcher->th && switcher->th->isRunning())) {
switcher->Start();
@@ -18,13 +13,8 @@ void startHotkeyFunc(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
}
}
void stopHotkeyFunc(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
bool pressed)
void stopHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *, bool pressed)
{
UNUSED_PARAMETER(id);
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(hotkey);
if (pressed) {
if (switcher->th && switcher->th->isRunning()) {
switcher->Stop();
@@ -32,13 +22,9 @@ void stopHotkeyFunc(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
}
}
void startStopToggleHotkeyFunc(void *data, obs_hotkey_id id,
obs_hotkey_t *hotkey, bool pressed)
void startStopToggleHotkeyFunc(void *, obs_hotkey_id, obs_hotkey_t *,
bool pressed)
{
UNUSED_PARAMETER(id);
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(hotkey);
if (pressed) {
if (switcher->th && switcher->th->isRunning()) {
switcher->Stop();

View File

@@ -117,7 +117,7 @@ bool MacroActionAudio::PerformAction()
obs_source_set_muted(s, false);
break;
case AudioAction::SOURCE_VOLUME:
if (_fade) {
if (_fade && _duration.seconds != 0) {
startSourceFade(_duration, (float)_volume / 100.0f,
_audioSource);
} else {
@@ -125,7 +125,7 @@ bool MacroActionAudio::PerformAction()
}
break;
case AudioAction::MASTER_VOLUME:
if (_fade) {
if (_fade && _duration.seconds != 0) {
startMasterFade(_duration, (float)_volume / 100.0f);
} else {
obs_set_master_volume((float)_volume / 100.0f);
@@ -259,6 +259,7 @@ void MacroActionAudioEdit::SetWidgetVisibility()
setLayoutVisible(_fadeLayout, hasVolumeControl(_entryData->_action));
adjustSize();
}
void MacroActionAudioEdit::UpdateEntryData()
{
if (!_entryData) {

View File

@@ -16,10 +16,11 @@ bool MacroActionFactory::Register(const std::string &id, MacroActionInfo info)
return false;
}
std::shared_ptr<MacroAction> MacroActionFactory::Create(const std::string &id)
std::shared_ptr<MacroAction> MacroActionFactory::Create(const std::string &id,
Macro *m)
{
if (auto it = _methods.find(id); it != _methods.end())
return it->second._createFunc();
return it->second._createFunc(m);
return nullptr;
}
@@ -57,6 +58,7 @@ static inline void populateActionSelection(QComboBox *list)
for (auto entry : MacroActionFactory::GetActionTypes()) {
list->addItem(obs_module_text(entry.second._name.c_str()));
}
list->model()->sort(0);
}
MacroActionEdit::MacroActionEdit(QWidget *parent,
@@ -93,12 +95,13 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
}
auto idx = _entryData->get()->GetIndex();
auto macro = _entryData->get()->GetMacro();
std::string id = MacroActionFactory::GetIdByName(text);
HeaderInfoChanged("");
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->reset();
*_entryData = MacroActionFactory::Create(id);
*_entryData = MacroActionFactory::Create(id, macro);
(*_entryData)->SetIndex(idx);
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
@@ -140,12 +143,12 @@ void AdvSceneSwitcher::AddMacroAction(int idx)
if (idx - 1 >= 0) {
id = macro->Actions().at(idx - 1)->GetId();
} else {
MacroActionSwitchScene temp;
MacroActionSwitchScene temp(nullptr);
id = temp.GetId();
}
std::lock_guard<std::mutex> lock(switcher->m);
macro->Actions().emplace(macro->Actions().begin() + idx,
MacroActionFactory::Create(id));
MacroActionFactory::Create(id, macro));
if (idx - 1 >= 0) {
auto data = obs_data_create();
macro->Actions().at(idx - 1)->Save(data);

View File

@@ -16,6 +16,7 @@ const static std::map<PerformMacroAction, std::string> actionTypes = {
{PerformMacroAction::RESET_COUNTER,
"AdvSceneSwitcher.action.macro.type.resetCounter"},
{PerformMacroAction::RUN, "AdvSceneSwitcher.action.macro.type.run"},
{PerformMacroAction::STOP, "AdvSceneSwitcher.action.macro.type.stop"},
};
bool MacroActionMacro::PerformAction()
@@ -37,6 +38,9 @@ bool MacroActionMacro::PerformAction()
case PerformMacroAction::RUN:
_macro->PerformAction();
break;
case PerformMacroAction::STOP:
_macro->Stop();
break;
default:
break;
}
@@ -63,6 +67,9 @@ void MacroActionMacro::LogAction()
vblog(LOG_INFO, "run nested macro \"%s\"",
_macro->Name().c_str());
break;
case PerformMacroAction::STOP:
vblog(LOG_INFO, "stopped macro \"%s\"", _macro->Name().c_str());
break;
default:
break;
}
@@ -137,6 +144,10 @@ void MacroActionMacroEdit::UpdateEntryData()
}
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
_macros->SetCurrentMacro(_entryData->_macro.get());
if (_entryData->_action == PerformMacroAction::RUN ||
_entryData->_action == PerformMacroAction::STOP) {
_macros->HideSelectedMacro();
}
}
void MacroActionMacroEdit::MacroChanged(const QString &text)
@@ -159,11 +170,17 @@ void MacroActionMacroEdit::ActionChanged(int value)
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_action = static_cast<PerformMacroAction>(value);
if (_entryData->_action == PerformMacroAction::RUN ||
_entryData->_action == PerformMacroAction::STOP) {
_macros->HideSelectedMacro();
} else {
_macros->ShowAllMacros();
}
}
void MacroActionMacroEdit::MacroRemove(const QString &name)
void MacroActionMacroEdit::MacroRemove(const QString &)
{
UNUSED_PARAMETER(name);
if (_entryData) {
_entryData->_macro.UpdateRef();
}

View File

@@ -16,6 +16,8 @@ const static std::map<PluginStateAction, std::string> actionTypes = {
"AdvSceneSwitcher.action.pluginState.type.stop"},
{PluginStateAction::NO_MATCH_BEHAVIOUR,
"AdvSceneSwitcher.action.pluginState.type.noMatch"},
{PluginStateAction::IMPORT_SETTINGS,
"AdvSceneSwitcher.action.pluginState.type.import"},
};
const static std::map<NoMatch, std::string> noMatchValues = {
@@ -33,6 +35,19 @@ void stopPlugin()
t.detach();
}
void importSettings(const std::string &path)
{
if (switcher->settingsWindowOpened) {
return;
}
obs_data_t *obj = obs_data_create_from_json_file(path.c_str());
if (!obj) {
return;
}
switcher->loadSettings(obj);
obs_data_release(obj);
}
void setNoMatchBehaviour(int value, OBSWeakSource &scene)
{
switcher->switchIfNotMatching = static_cast<NoMatch>(value);
@@ -50,6 +65,11 @@ bool MacroActionPluginState::PerformAction()
case PluginStateAction::NO_MATCH_BEHAVIOUR:
setNoMatchBehaviour(_value, _scene);
break;
case PluginStateAction::IMPORT_SETTINGS:
importSettings(_settingsPath);
// There is no point in continuing
// The settings will be invalid
return false;
default:
break;
}
@@ -62,6 +82,13 @@ void MacroActionPluginState::LogAction()
case PluginStateAction::STOP:
blog(LOG_INFO, "stop() called by macro");
break;
case PluginStateAction::NO_MATCH_BEHAVIOUR:
vblog(LOG_INFO, "setting no match to %d", _value);
break;
case PluginStateAction::IMPORT_SETTINGS:
vblog(LOG_INFO, "importing settings from %s",
_settingsPath.c_str());
break;
default:
blog(LOG_WARNING, "ignored unknown pluginState action %d",
static_cast<int>(_action));
@@ -75,6 +102,7 @@ bool MacroActionPluginState::Save(obs_data_t *obj)
obs_data_set_int(obj, "action", static_cast<int>(_action));
obs_data_set_int(obj, "value", _value);
obs_data_set_string(obj, "scene", GetWeakSourceName(_scene).c_str());
obs_data_set_string(obj, "settingsPath", _settingsPath.c_str());
return true;
}
@@ -86,6 +114,7 @@ bool MacroActionPluginState::Load(obs_data_t *obj)
_value = obs_data_get_int(obj, "value");
const char *sceneName = obs_data_get_string(obj, "scene");
_scene = GetWeakSourceByName(sceneName);
_settingsPath = obs_data_get_string(obj, "settingsPath");
return true;
}
@@ -113,6 +142,9 @@ MacroActionPluginStateEdit::MacroActionPluginStateEdit(
_actions = new QComboBox();
_values = new QComboBox();
_scenes = new QComboBox();
_settings = new FileSelection();
_settingsWarning = new QLabel(obs_module_text(
"AdvSceneSwitcher.action.pluginState.importWarning"));
populateActionSelection(_actions);
populateSceneSelection(_scenes);
@@ -123,12 +155,16 @@ MacroActionPluginStateEdit::MacroActionPluginStateEdit(
SLOT(ValueChanged(int)));
QWidget::connect(_scenes, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(SceneChanged(const QString &)));
QWidget::connect(_settings, SIGNAL(PathChanged(const QString &)), this,
SLOT(PathChanged(const QString &)));
QHBoxLayout *mainLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{actions}}", _actions},
{"{{values}}", _values},
{"{{scenes}}", _scenes},
{"{{settings}}", _settings},
{"{{settingsWarning}}", _settingsWarning},
};
placeWidgets(
obs_module_text("AdvSceneSwitcher.action.pluginState.entry"),
@@ -149,7 +185,8 @@ void MacroActionPluginStateEdit::UpdateEntryData()
populateValueSelection(_values, _entryData->_action);
_values->setCurrentIndex(_entryData->_value);
_scenes->setCurrentText(GetWeakSourceName(_entryData->_scene).c_str());
SetWidgetVisibility(_entryData->_action, _entryData->_value);
_settings->SetPath(QString::fromStdString(_entryData->_settingsPath));
SetWidgetVisibility();
}
void MacroActionPluginStateEdit::ActionChanged(int value)
@@ -161,7 +198,7 @@ void MacroActionPluginStateEdit::ActionChanged(int value)
{
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_action = static_cast<PluginStateAction>(value);
SetWidgetVisibility(_entryData->_action, _entryData->_value);
SetWidgetVisibility();
}
_values->clear();
@@ -176,7 +213,7 @@ void MacroActionPluginStateEdit::ValueChanged(int value)
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_value = value;
SetWidgetVisibility(_entryData->_action, _entryData->_value);
SetWidgetVisibility();
}
void MacroActionPluginStateEdit::SceneChanged(const QString &text)
@@ -189,15 +226,40 @@ void MacroActionPluginStateEdit::SceneChanged(const QString &text)
_entryData->_scene = GetWeakSourceByQString(text);
}
void MacroActionPluginStateEdit::SetWidgetVisibility(PluginStateAction action,
int value)
void MacroActionPluginStateEdit::PathChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_settingsPath = text.toStdString();
}
void MacroActionPluginStateEdit::SetWidgetVisibility()
{
if (!_entryData) {
return;
}
_values->hide();
_scenes->hide();
if (action == PluginStateAction::NO_MATCH_BEHAVIOUR) {
_settings->hide();
_settingsWarning->hide();
switch (_entryData->_action) {
case PluginStateAction::STOP:
break;
case PluginStateAction::NO_MATCH_BEHAVIOUR:
_values->show();
if ((NoMatch)value == SWITCH) {
if ((NoMatch)_entryData->_value == SWITCH) {
_scenes->show();
}
break;
case PluginStateAction::IMPORT_SETTINGS:
_settings->show();
_settingsWarning->show();
break;
default:
break;
}
}

View File

@@ -0,0 +1,99 @@
#include "headers/macro-action-profile.hpp"
#include "headers/advanced-scene-switcher.hpp"
#include "headers/utility.hpp"
const std::string MacroActionProfile::id = "profile";
bool MacroActionProfile::_registered = MacroActionFactory::Register(
MacroActionProfile::id,
{MacroActionProfile::Create, MacroActionProfileEdit::Create,
"AdvSceneSwitcher.action.profile"});
bool MacroActionProfile::PerformAction()
{
obs_frontend_set_current_profile(_profile.c_str());
return true;
}
void MacroActionProfile::LogAction()
{
vblog(LOG_INFO, "set profile type to \"%s\"", _profile.c_str());
}
bool MacroActionProfile::Save(obs_data_t *obj)
{
MacroAction::Save(obj);
obs_data_set_string(obj, "profile", _profile.c_str());
return true;
}
bool MacroActionProfile::Load(obs_data_t *obj)
{
MacroAction::Load(obj);
_profile = obs_data_get_string(obj, "profile");
return true;
}
std::string MacroActionProfile::GetShortDesc()
{
return _profile;
}
void populateProfileSelection(QComboBox *box)
{
auto profiles = obs_frontend_get_profiles();
char **temp = profiles;
while (*temp) {
const char *name = *temp;
box->addItem(name);
temp++;
}
bfree(profiles);
box->model()->sort(0);
addSelectionEntry(
box, obs_module_text("AdvSceneSwitcher.selectProfile"), false);
box->setCurrentIndex(0);
}
MacroActionProfileEdit::MacroActionProfileEdit(
QWidget *parent, std::shared_ptr<MacroActionProfile> entryData)
: QWidget(parent)
{
_profiles = new QComboBox();
populateProfileSelection(_profiles);
QWidget::connect(_profiles, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(ProfileChanged(const QString &)));
QHBoxLayout *mainLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{profiles}}", _profiles},
};
placeWidgets(obs_module_text("AdvSceneSwitcher.action.profile.entry"),
mainLayout, widgetPlaceholders);
setLayout(mainLayout);
_entryData = entryData;
UpdateEntryData();
_loading = false;
}
void MacroActionProfileEdit::UpdateEntryData()
{
if (!_entryData) {
return;
}
_profiles->setCurrentText(QString::fromStdString(_entryData->_profile));
}
void MacroActionProfileEdit::ProfileChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_profile = text.toStdString();
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
}

View File

@@ -1,9 +1,7 @@
#include "headers/macro-action-random.hpp"
#include "headers/advanced-scene-switcher.hpp"
#include "headers/name-dialog.hpp"
#include "headers/utility.hpp"
#include <QDialogButtonBox>
#include <cstdlib>
const std::string MacroActionRandom::id = "random";
@@ -13,8 +11,8 @@ bool MacroActionRandom::_registered = MacroActionFactory::Register(
{MacroActionRandom::Create, MacroActionRandomEdit::Create,
"AdvSceneSwitcher.action.random"});
std::vector<MacroRef> getPossibleMacros(std::vector<MacroRef> &macros,
MacroRef &lastRandomMacro)
std::vector<MacroRef> getNextMacro(std::vector<MacroRef> &macros,
MacroRef &lastRandomMacro)
{
std::vector<MacroRef> res;
if (macros.size() == 1) {
@@ -40,7 +38,7 @@ bool MacroActionRandom::PerformAction()
return true;
}
auto macros = getPossibleMacros(_macros, lastRandomMacro);
auto macros = getNextMacro(_macros, lastRandomMacro);
if (macros.size() == 0) {
return true;
}
@@ -190,7 +188,7 @@ void MacroActionRandomEdit::AddMacro()
}
std::string macroName;
bool accepted = MacroDialog::AskForMacro(this, macroName);
bool accepted = MacroSelectionDialog::AskForMacro(this, macroName);
if (!accepted || macroName.empty()) {
return;
@@ -262,47 +260,3 @@ void MacroActionRandomEdit::SetMacroListSize()
setHeightToContentHeight(_macroList);
adjustSize();
}
MacroDialog::MacroDialog(QWidget *)
{
setModal(true);
setWindowModality(Qt::WindowModality::ApplicationModal);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setMinimumWidth(350);
setMinimumHeight(70);
QDialogButtonBox *buttonbox = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
buttonbox->setCenterButtons(true);
connect(buttonbox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
_macroSelection = new MacroSelection(window());
auto *selectionLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{macroSelection}}", _macroSelection},
};
placeWidgets(obs_module_text("AdvSceneSwitcher.askForMacro"),
selectionLayout, widgetPlaceholders);
auto *layout = new QVBoxLayout();
layout->addLayout(selectionLayout);
layout->addWidget(buttonbox);
setLayout(layout);
}
bool MacroDialog::AskForMacro(QWidget *parent, std::string &macroName)
{
MacroDialog dialog(parent);
dialog.setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
if (dialog.exec() != DialogCode::Accepted) {
return false;
}
macroName = dialog._macroSelection->currentText().toUtf8().constData();
if (macroName == obs_module_text("AdvSceneSwitcher.selectMacro")) {
return false;
}
return true;
}

View File

@@ -0,0 +1,117 @@
#include "headers/macro-action-scene-collection.hpp"
#include "headers/advanced-scene-switcher.hpp"
#include "headers/utility.hpp"
const std::string MacroActionSceneCollection::id = "scene_collection";
bool MacroActionSceneCollection::_registered = MacroActionFactory::Register(
MacroActionSceneCollection::id,
{MacroActionSceneCollection::Create,
MacroActionSceneCollectionEdit::Create,
"AdvSceneSwitcher.action.sceneCollection"});
bool MacroActionSceneCollection::PerformAction()
{
// Changing the scene collection will also reload the settings of the
// scene switcher, so to avoid issues of not being able to change
// settings ignore this action if the settings dialog is opened.
if (switcher->settingsWindowOpened) {
return false;
}
obs_frontend_set_current_scene_collection(_sceneCollection.c_str());
// It does not make sense to continue as the current settings will be
// invalid after switching scene collection.
return false;
}
void MacroActionSceneCollection::LogAction()
{
vblog(LOG_INFO, "set scene collection type to \"%s\"",
_sceneCollection.c_str());
}
bool MacroActionSceneCollection::Save(obs_data_t *obj)
{
MacroAction::Save(obj);
obs_data_set_string(obj, "sceneCollection", _sceneCollection.c_str());
return true;
}
bool MacroActionSceneCollection::Load(obs_data_t *obj)
{
MacroAction::Load(obj);
_sceneCollection = obs_data_get_string(obj, "sceneCollection");
return true;
}
std::string MacroActionSceneCollection::GetShortDesc()
{
return _sceneCollection;
}
void populateSceneCollectionSelection(QComboBox *box)
{
auto sceneCollections = obs_frontend_get_scene_collections();
char **temp = sceneCollections;
while (*temp) {
const char *name = *temp;
box->addItem(name);
temp++;
}
bfree(sceneCollections);
box->model()->sort(0);
addSelectionEntry(
box, obs_module_text("AdvSceneSwitcher.selectSceneCollection"),
false);
box->setCurrentIndex(0);
}
MacroActionSceneCollectionEdit::MacroActionSceneCollectionEdit(
QWidget *parent, std::shared_ptr<MacroActionSceneCollection> entryData)
: QWidget(parent)
{
_sceneCollections = new QComboBox();
populateSceneCollectionSelection(_sceneCollections);
QWidget::connect(_sceneCollections,
SIGNAL(currentTextChanged(const QString &)), this,
SLOT(SceneCollectionChanged(const QString &)));
QHBoxLayout *entryLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{sceneCollections}}", _sceneCollections},
};
placeWidgets(obs_module_text(
"AdvSceneSwitcher.action.sceneCollection.entry"),
entryLayout, widgetPlaceholders);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(entryLayout);
mainLayout->addWidget(new QLabel(obs_module_text(
"AdvSceneSwitcher.action.sceneCollection.warning")));
setLayout(mainLayout);
_entryData = entryData;
UpdateEntryData();
_loading = false;
}
void MacroActionSceneCollectionEdit::UpdateEntryData()
{
if (!_entryData) {
return;
}
_sceneCollections->setCurrentText(
QString::fromStdString(_entryData->_sceneCollection));
}
void MacroActionSceneCollectionEdit::SceneCollectionChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_sceneCollection = text.toStdString();
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
}

View File

@@ -22,37 +22,77 @@ const static std::map<SceneOrderAction, std::string> actionTypes = {
"AdvSceneSwitcher.action.sceneOrder.type.movePosition"},
};
bool MacroActionSceneOrder::PerformAction()
void moveSceneItemsUp(std::vector<obs_scene_item *> &items)
{
auto s = obs_weak_source_get_source(_scene.GetScene());
auto scene = obs_scene_from_source(s);
auto name = GetWeakSourceName(_source);
auto items = getSceneItemsWithName(scene, name);
// In the case of the same source being in two sequential positions
// moving the sources up will cause the sources to swap positions due to
// the order scene items are being iterated over, which is most likely
// not the desired effect.
// Instead we reverse the order of the scene items so all scene items
// will be moved up.
std::reverse(items.begin(), items.end());
for (auto &i : items) {
switch (_action) {
case SceneOrderAction::MOVE_UP:
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_UP);
break;
case SceneOrderAction::MOVE_DOWN:
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_DOWN);
break;
case SceneOrderAction::MOVE_TOP:
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_TOP);
break;
case SceneOrderAction::MOVE_BOTTOM:
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_BOTTOM);
break;
case SceneOrderAction::POSITION:
obs_sceneitem_set_order_position(i, _position);
break;
default:
break;
}
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_UP);
obs_sceneitem_release(i);
}
}
obs_source_release(s);
void moveSceneItemsDown(std::vector<obs_scene_item *> &items)
{
for (auto &i : items) {
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_DOWN);
obs_sceneitem_release(i);
}
}
void moveSceneItemsTop(std::vector<obs_scene_item *> &items)
{
for (auto &i : items) {
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_TOP);
obs_sceneitem_release(i);
}
}
void moveSceneItemsBottom(std::vector<obs_scene_item *> &items)
{
for (auto &i : items) {
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_BOTTOM);
obs_sceneitem_release(i);
}
}
void moveSceneItemsPos(std::vector<obs_scene_item *> &items, int pos)
{
for (auto &i : items) {
obs_sceneitem_set_order_position(i, pos);
obs_sceneitem_release(i);
}
}
bool MacroActionSceneOrder::PerformAction()
{
auto items = _source.GetSceneItems(_scene);
switch (_action) {
case SceneOrderAction::MOVE_UP:
moveSceneItemsUp(items);
break;
case SceneOrderAction::MOVE_DOWN:
moveSceneItemsDown(items);
break;
case SceneOrderAction::MOVE_TOP:
moveSceneItemsTop(items);
break;
case SceneOrderAction::MOVE_BOTTOM:
moveSceneItemsBottom(items);
break;
case SceneOrderAction::POSITION:
moveSceneItemsPos(items, _position);
break;
default:
break;
}
return true;
}
@@ -62,7 +102,7 @@ void MacroActionSceneOrder::LogAction()
if (it != actionTypes.end()) {
vblog(LOG_INFO,
"performed order action \"%s\" for source \"%s\" on scene \"%s\"",
it->second.c_str(), GetWeakSourceName(_source).c_str(),
it->second.c_str(), _source.ToString().c_str(),
_scene.ToString().c_str());
} else {
blog(LOG_WARNING, "ignored unknown scene order action %d",
@@ -74,7 +114,7 @@ bool MacroActionSceneOrder::Save(obs_data_t *obj)
{
MacroAction::Save(obj);
_scene.Save(obj);
obs_data_set_string(obj, "source", GetWeakSourceName(_source).c_str());
_source.Save(obj);
obs_data_set_int(obj, "action", static_cast<int>(_action));
obs_data_set_int(obj, "position", _position);
return true;
@@ -82,10 +122,16 @@ bool MacroActionSceneOrder::Save(obs_data_t *obj)
bool MacroActionSceneOrder::Load(obs_data_t *obj)
{
// Convert old data format
// TODO: Remove in future version
if (obs_data_has_user_value(obj, "source")) {
auto sourceName = obs_data_get_string(obj, "source");
obs_data_set_string(obj, "sceneItem", sourceName);
}
MacroAction::Load(obj);
_scene.Load(obj);
const char *sourceName = obs_data_get_string(obj, "source");
_source = GetWeakSourceByName(sourceName);
_source.Load(obj);
_action =
static_cast<SceneOrderAction>(obs_data_get_int(obj, "action"));
_position = obs_data_get_int(obj, "position");
@@ -94,10 +140,10 @@ bool MacroActionSceneOrder::Load(obs_data_t *obj)
std::string MacroActionSceneOrder::GetShortDesc()
{
if (_source) {
return _scene.ToString() + " - " + GetWeakSourceName(_source);
if (_source.ToString().empty()) {
return "";
}
return "";
return _scene.ToString() + " - " + _source.ToString();
}
static inline void populateActionSelection(QComboBox *list)
@@ -112,7 +158,7 @@ MacroActionSceneOrderEdit::MacroActionSceneOrderEdit(
: QWidget(parent)
{
_scenes = new SceneSelectionWidget(window(), false, false, true);
_sources = new QComboBox();
_sources = new SceneItemSelectionWidget(parent);
_actions = new QComboBox();
_position = new QSpinBox();
@@ -122,8 +168,11 @@ MacroActionSceneOrderEdit::MacroActionSceneOrderEdit(
SLOT(ActionChanged(int)));
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
this, SLOT(SceneChanged(const SceneSelection &)));
QWidget::connect(_sources, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(SourceChanged(const QString &)));
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
_sources, SLOT(SceneChanged(const SceneSelection &)));
QWidget::connect(_sources,
SIGNAL(SceneItemChanged(const SceneItemSelection &)),
this, SLOT(SourceChanged(const SceneItemSelection &)));
QWidget::connect(_position, SIGNAL(valueChanged(int)), this,
SLOT(PositionChanged(int)));
@@ -152,9 +201,7 @@ void MacroActionSceneOrderEdit::UpdateEntryData()
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
_scenes->SetScene(_entryData->_scene);
populateSceneItemSelection(_sources, _entryData->_scene);
_sources->setCurrentText(
GetWeakSourceName(_entryData->_source).c_str());
_sources->SetSceneItem(_entryData->_source);
_position->setValue(_entryData->_position);
_position->setVisible(_entryData->_action ==
SceneOrderAction::POSITION);
@@ -165,22 +212,19 @@ void MacroActionSceneOrderEdit::SceneChanged(const SceneSelection &s)
if (_loading || !_entryData) {
return;
}
{
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_scene = s;
}
_sources->clear();
populateSceneItemSelection(_sources, _entryData->_scene);
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_scene = s;
}
void MacroActionSceneOrderEdit::SourceChanged(const QString &text)
void MacroActionSceneOrderEdit::SourceChanged(const SceneItemSelection &item)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_source = GetWeakSourceByQString(text);
_entryData->_source = item;
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
}

View File

@@ -9,75 +9,167 @@ bool MacroActionSwitchScene::_registered = MacroActionFactory::Register(
{MacroActionSwitchScene::Create, MacroActionSwitchSceneEdit::Create,
"AdvSceneSwitcher.action.switchScene"});
void waitForTransitionChange(OBSWeakSource &target)
{
const int maxNrChecks = 100;
int curCheckNr = 0;
bool transitionEnded = false;
auto sceneCheckStartedOn = obs_frontend_get_current_scene();
obs_source_release(sceneCheckStartedOn);
switcher->abortMacroWait = false;
std::unique_lock<std::mutex> lock(switcher->m);
while (!transitionEnded && curCheckNr < maxNrChecks &&
!switcher->abortMacroWait) {
switcher->abortMacroWait = false;
switcher->macroTransitionCv.wait_for(
lock,
std::chrono::milliseconds(
(long long)switcher->interval),
[] { return switcher->abortMacroWait.load(); });
auto curScene = obs_frontend_get_current_scene();
obs_source_release(curScene);
transitionEnded = curScene != sceneCheckStartedOn ||
switcher->currentScene == target;
++curCheckNr;
}
}
bool MacroActionSwitchScene::PerformAction()
{
OBSWeakSource scene = getScene();
switchScene({scene, transition, (int)(_duration.seconds * 1000)});
auto scene = _scene.GetScene();
switchScene({scene, _transition.GetTransition(),
(int)(_duration.seconds * 1000)});
if (_blockUntilTransitionDone) {
waitForTransitionChange(scene);
return !switcher->abortMacroWait;
}
return true;
}
void MacroActionSwitchScene::LogAction()
{
if (switcher->verbose) {
logMatch();
auto t = _scene.GetType();
auto sceneName = GetWeakSourceName(_scene.GetScene(false));
switch (t) {
case SceneSelectionType::SCENE:
vblog(LOG_INFO, "switch to scene '%s'",
_scene.ToString().c_str());
break;
case SceneSelectionType::GROUP:
vblog(LOG_INFO, "switch to scene '%s' (scene group '%s')",
sceneName.c_str(), _scene.ToString().c_str());
break;
case SceneSelectionType::PREVIOUS:
vblog(LOG_INFO, "switch to previous scene '%s'",
sceneName.c_str());
break;
default:
break;
}
}
bool MacroActionSwitchScene::Save(obs_data_t *obj)
{
MacroAction::Save(obj);
SceneSwitcherEntry::save(obj);
_scene.Save(obj);
_transition.Save(obj);
_duration.Save(obj);
obs_data_set_bool(obj, "blockUntilTransitionDone",
_blockUntilTransitionDone);
return true;
}
bool MacroActionSwitchScene::Load(obs_data_t *obj)
{
// Convert old data format
// TODO: Remove in future version
if (obs_data_has_user_value(obj, "targetType")) {
auto sceneName = obs_data_get_string(obj, "target");
obs_data_set_string(obj, "scene", sceneName);
auto transitionName = obs_data_get_string(obj, "transition");
bool usePreviousScene =
strcmp(sceneName, previous_scene_name) == 0;
bool useCurrentTransition =
strcmp(transitionName, current_transition_name) == 0;
obs_data_set_int(
obj, "sceneType",
(usePreviousScene)
? static_cast<int>(SceneSelectionType::PREVIOUS)
: obs_data_get_int(obj, "targetType"));
obs_data_set_int(
obj, "transitionType",
(useCurrentTransition)
? static_cast<int>(
TransitionSelectionType::CURRENT)
: static_cast<int>(
TransitionSelectionType::TRANSITION));
}
MacroAction::Load(obj);
SceneSwitcherEntry::load(obj);
_scene.Load(obj);
_transition.Load(obj);
_duration.Load(obj);
_blockUntilTransitionDone =
obs_data_get_bool(obj, "blockUntilTransitionDone");
return true;
}
std::string MacroActionSwitchScene::GetShortDesc()
{
if (targetType == SwitchTargetType::Scene && scene) {
return GetWeakSourceName(scene);
}
if (targetType == SwitchTargetType::SceneGroup && group) {
return group->name;
}
return "";
return _scene.ToString();
}
MacroActionSwitchSceneEdit::MacroActionSwitchSceneEdit(
QWidget *parent, std::shared_ptr<MacroActionSwitchScene> entryData)
: SwitchWidget(parent, entryData.get(), true, true)
: QWidget(parent)
{
_scenes = new SceneSelectionWidget(window(), true, true);
_transitions = new TransitionSelectionWidget(this);
_duration = new DurationSelection(parent, false);
_blockUntilTransitionDone = new QCheckBox(obs_module_text(
"AdvSceneSwitcher.action.scene.blockUntilTransitionDone"));
_duration->SpinBox()->setSpecialValueText("-");
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
this, SLOT(SceneChanged(const SceneSelection &)));
QWidget::connect(_transitions,
SIGNAL(TransitionChanged(const TransitionSelection &)),
this,
SLOT(TransitionChanged(const TransitionSelection &)));
QWidget::connect(_duration, SIGNAL(DurationChanged(double)), this,
SLOT(DurationChanged(double)));
QWidget::connect(scenes, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(ChangeHeaderInfo(const QString &)));
QWidget::connect(_blockUntilTransitionDone, SIGNAL(stateChanged(int)),
this, SLOT(BlockUntilTransitionDoneChanged(int)));
QHBoxLayout *mainLayout = new QHBoxLayout;
QHBoxLayout *entryLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{scenes}}", scenes},
{"{{transitions}}", transitions},
{"{{scenes}}", _scenes},
{"{{transitions}}", _transitions},
{"{{duration}}", _duration},
{"{{blockUntilTransitionDone}}", _blockUntilTransitionDone},
};
placeWidgets(obs_module_text("AdvSceneSwitcher.action.scene.entry"),
mainLayout, widgetPlaceholders);
entryLayout, widgetPlaceholders);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(entryLayout);
mainLayout->addWidget(_blockUntilTransitionDone);
setLayout(mainLayout);
_entryData = entryData;
_scenes->SetScene(_entryData->_scene);
_transitions->SetTransition(_entryData->_transition);
_duration->SetDuration(_entryData->_duration);
SwitchWidget::loading = false;
_blockUntilTransitionDone->setChecked(
_entryData->_blockUntilTransitionDone);
_loading = false;
}
void MacroActionSwitchSceneEdit::DurationChanged(double seconds)
{
if (SwitchWidget::loading || !_entryData) {
if (_loading || !_entryData) {
return;
}
@@ -85,8 +177,34 @@ void MacroActionSwitchSceneEdit::DurationChanged(double seconds)
_entryData->_duration.seconds = seconds;
}
void MacroActionSwitchSceneEdit::ChangeHeaderInfo(const QString &)
void MacroActionSwitchSceneEdit::BlockUntilTransitionDoneChanged(int state)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_blockUntilTransitionDone = state;
}
void MacroActionSwitchSceneEdit::SceneChanged(const SceneSelection &s)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_scene = s;
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
}
void MacroActionSwitchSceneEdit::TransitionChanged(const TransitionSelection &t)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_transition = t;
}

View File

@@ -12,13 +12,8 @@ bool MacroActionSceneTransform::_registered = MacroActionFactory::Register(
bool MacroActionSceneTransform::PerformAction()
{
auto s = obs_weak_source_get_source(_scene.GetScene(false));
auto scene = obs_scene_from_source(s);
auto name = GetWeakSourceName(_source);
auto items = getSceneItemsWithName(scene, name);
auto items = _source.GetSceneItems(_scene);
for (auto &item : items) {
// Apply settings
obs_sceneitem_defer_update_begin(item);
obs_sceneitem_set_info(item, &_info);
obs_sceneitem_set_crop(item, &_crop);
@@ -26,8 +21,6 @@ bool MacroActionSceneTransform::PerformAction()
obs_sceneitem_release(item);
}
obs_source_release(s);
return true;
}
@@ -35,34 +28,40 @@ void MacroActionSceneTransform::LogAction()
{
vblog(LOG_INFO,
"performed transform action for source \"%s\" on scene \"%s\"",
GetWeakSourceName(_source).c_str(), _scene.ToString().c_str());
_source.ToString().c_str(), _scene.ToString().c_str());
}
bool MacroActionSceneTransform::Save(obs_data_t *obj)
{
MacroAction::Save(obj);
_scene.Save(obj);
obs_data_set_string(obj, "source", GetWeakSourceName(_source).c_str());
_source.Save(obj);
saveTransformState(obj, _info, _crop);
return true;
}
bool MacroActionSceneTransform::Load(obs_data_t *obj)
{
// Convert old data format
// TODO: Remove in future version
if (obs_data_has_user_value(obj, "source")) {
auto sourceName = obs_data_get_string(obj, "source");
obs_data_set_string(obj, "sceneItem", sourceName);
}
MacroAction::Load(obj);
_scene.Load(obj);
const char *sourceName = obs_data_get_string(obj, "source");
_source = GetWeakSourceByName(sourceName);
_source.Load(obj);
loadTransformState(obj, _info, _crop);
return true;
}
std::string MacroActionSceneTransform::GetShortDesc()
{
if (_source) {
return _scene.ToString() + " - " + GetWeakSourceName(_source);
if (_source.ToString().empty()) {
return "";
}
return "";
return _scene.ToString() + " - " + _source.ToString();
}
std::string MacroActionSceneTransform::GetSettings()
@@ -81,9 +80,13 @@ void MacroActionSceneTransform::SetSettings(std::string &settings)
return;
}
loadTransformState(data, _info, _crop);
auto items = _source.GetSceneItems(_scene);
if (items.empty()) {
return;
}
if (obs_data_has_user_value(data, "size")) {
auto obj = obs_data_get_obj(data, "size");
auto source = obs_weak_source_get_source(_source);
auto source = obs_sceneitem_get_source(items[0]);
if (double h = obs_data_get_double(obj, "height")) {
_info.scale.y =
h / double(obs_source_get_height(source));
@@ -93,9 +96,10 @@ void MacroActionSceneTransform::SetSettings(std::string &settings)
w / double(obs_source_get_width(source));
}
obs_data_release(obj);
obs_source_release(source);
}
for (auto item : items) {
obs_sceneitem_release(item);
}
obs_data_release(data);
}
@@ -104,15 +108,18 @@ MacroActionSceneTransformEdit::MacroActionSceneTransformEdit(
: QWidget(parent)
{
_scenes = new SceneSelectionWidget(window(), false, false, true);
_sources = new QComboBox();
_sources = new SceneItemSelectionWidget(parent);
_getSettings = new QPushButton(obs_module_text(
"AdvSceneSwitcher.action.sceneTransform.getTransform"));
_settings = new QPlainTextEdit();
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
this, SLOT(SceneChanged(const SceneSelection &)));
QWidget::connect(_sources, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(SourceChanged(const QString &)));
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
_sources, SLOT(SceneChanged(const SceneSelection &)));
QWidget::connect(_sources,
SIGNAL(SceneItemChanged(const SceneItemSelection &)),
this, SLOT(SourceChanged(const SceneItemSelection &)));
QWidget::connect(_getSettings, SIGNAL(clicked()), this,
SLOT(GetSettingsClicked()));
QWidget::connect(_settings, SIGNAL(textChanged()), this,
@@ -152,13 +159,8 @@ void MacroActionSceneTransformEdit::UpdateEntryData()
}
_scenes->SetScene(_entryData->_scene);
populateSceneItemSelection(_sources, _entryData->_scene);
_sources->setCurrentText(
GetWeakSourceName(_entryData->_source).c_str());
if (_entryData->_source) {
_settings->setPlainText(
formatJsonString(_entryData->GetSettings()));
}
_sources->SetSceneItem(_entryData->_source);
_settings->setPlainText(formatJsonString(_entryData->GetSettings()));
}
void MacroActionSceneTransformEdit::SceneChanged(const SceneSelection &s)
@@ -166,44 +168,39 @@ void MacroActionSceneTransformEdit::SceneChanged(const SceneSelection &s)
if (_loading || !_entryData) {
return;
}
{
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_scene = s;
}
_sources->clear();
populateSceneItemSelection(_sources, _entryData->_scene);
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_scene = s;
}
void MacroActionSceneTransformEdit::SourceChanged(const QString &text)
void MacroActionSceneTransformEdit::SourceChanged(const SceneItemSelection &item)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_source = GetWeakSourceByQString(text);
_entryData->_source = item;
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
}
void MacroActionSceneTransformEdit::GetSettingsClicked()
{
if (_loading || !_entryData || !_entryData->_scene.GetScene(false) ||
!_entryData->_source) {
if (_loading || !_entryData || !_entryData->_scene.GetScene(false)) {
return;
}
auto s = obs_weak_source_get_source(_entryData->_scene.GetScene(false));
auto scene = obs_scene_from_source(s);
auto name = GetWeakSourceName(_entryData->_source);
auto item = obs_scene_find_source_recursive(scene, name.c_str());
obs_source_release(s);
if (!item) {
auto items = _entryData->_source.GetSceneItems(_entryData->_scene);
if (items.empty()) {
return;
}
_settings->setPlainText(formatJsonString(getSceneItemTransform(item)));
auto settings = getSceneItemTransform(items[0]);
_settings->setPlainText(formatJsonString(settings));
for (auto item : items) {
obs_sceneitem_release(item);
}
}
void MacroActionSceneTransformEdit::SettingsChanged()

View File

@@ -29,23 +29,6 @@ struct VisibilityData {
bool visible;
};
static bool visibilitySourceEnum(obs_scene_t *, obs_sceneitem_t *item,
void *ptr)
{
VisibilityData *vInfo = reinterpret_cast<VisibilityData *>(ptr);
auto sourceName = obs_source_get_name(obs_sceneitem_get_source(item));
if (vInfo->name == sourceName) {
obs_sceneitem_set_visible(item, vInfo->visible);
}
if (obs_sceneitem_is_group(item)) {
obs_scene_t *scene = obs_sceneitem_group_get_scene(item);
obs_scene_enum_items(scene, visibilitySourceEnum, ptr);
}
return true;
}
static bool visibilitySourceTypeEnum(obs_scene_t *, obs_sceneitem_t *item,
void *ptr)
{
@@ -67,25 +50,29 @@ static bool visibilitySourceTypeEnum(obs_scene_t *, obs_sceneitem_t *item,
bool MacroActionSceneVisibility::PerformAction()
{
auto s = obs_weak_source_get_source(_scene.GetScene());
auto scene = obs_scene_from_source(s);
auto sourceName = GetWeakSourceName(_source);
VisibilityData vInfo = {"", _action == SceneVisibilityAction::SHOW};
switch (_sourceType) {
case SceneItemSourceType::SOURCE:
vInfo.name = sourceName;
obs_scene_enum_items(scene, visibilitySourceEnum, &vInfo);
case SceneItemSourceType::SOURCE: {
auto items = _source.GetSceneItems(_scene);
for (auto item : items) {
obs_sceneitem_set_visible(
item, _action == SceneVisibilityAction::SHOW);
obs_sceneitem_release(item);
}
break;
case SceneItemSourceType::SOURCE_GROUP:
vInfo.name = _sourceGroup;
}
case SceneItemSourceType::SOURCE_GROUP: {
auto s = obs_weak_source_get_source(_scene.GetScene());
auto scene = obs_scene_from_source(s);
VisibilityData vInfo = {_sourceGroup,
_action == SceneVisibilityAction::SHOW};
obs_scene_enum_items(scene, visibilitySourceTypeEnum, &vInfo);
obs_source_release(s);
break;
}
default:
break;
}
obs_source_release(s);
return true;
}
@@ -96,8 +83,7 @@ void MacroActionSceneVisibility::LogAction()
if (_sourceType == SceneItemSourceType::SOURCE) {
vblog(LOG_INFO,
"performed visibility action \"%s\" for source \"%s\" on scene \"%s\"",
it->second.c_str(),
GetWeakSourceName(_source).c_str(),
it->second.c_str(), _source.ToString().c_str(),
_scene.ToString().c_str());
} else {
vblog(LOG_INFO,
@@ -116,10 +102,9 @@ bool MacroActionSceneVisibility::Save(obs_data_t *obj)
MacroAction::Save(obj);
_scene.Save(obj);
if (_sourceType == SceneItemSourceType::SOURCE) {
obs_data_set_string(obj, "source",
GetWeakSourceName(_source).c_str());
_source.Save(obj);
} else {
obs_data_set_string(obj, "source", _sourceGroup.c_str());
obs_data_set_string(obj, "sourceGroup", _sourceGroup.c_str());
}
obs_data_set_int(obj, "action", static_cast<int>(_action));
obs_data_set_int(obj, "sourceType", static_cast<int>(_sourceType));
@@ -128,13 +113,20 @@ bool MacroActionSceneVisibility::Save(obs_data_t *obj)
bool MacroActionSceneVisibility::Load(obs_data_t *obj)
{
// Convert old data format
// TODO: Remove in future version
if (obs_data_has_user_value(obj, "source")) {
auto sourceName = obs_data_get_string(obj, "source");
obs_data_set_string(obj, "sceneItem", sourceName);
obs_data_set_string(obj, "sourceGroup", sourceName);
}
MacroAction::Load(obj);
_scene.Load(obj);
_source.Load(obj);
_sourceType = static_cast<SceneItemSourceType>(
obs_data_get_int(obj, "sourceType"));
const char *sourceName = obs_data_get_string(obj, "source");
_source = GetWeakSourceByName(sourceName);
_sourceGroup = sourceName;
_sourceGroup = obs_data_get_string(obj, "sourceGroup");
_action = static_cast<SceneVisibilityAction>(
obs_data_get_int(obj, "action"));
return true;
@@ -142,8 +134,9 @@ bool MacroActionSceneVisibility::Load(obs_data_t *obj)
std::string MacroActionSceneVisibility::GetShortDesc()
{
if (_sourceType == SceneItemSourceType::SOURCE && _source) {
return _scene.ToString() + " - " + GetWeakSourceName(_source);
if (_sourceType == SceneItemSourceType::SOURCE &&
!_source.ToString().empty()) {
return _scene.ToString() + " - " + _source.ToString();
}
if (_sourceType == SceneItemSourceType::SOURCE_GROUP &&
!_sourceGroup.empty()) {
@@ -175,11 +168,12 @@ MacroActionSceneVisibilityEdit::MacroActionSceneVisibilityEdit(
{
_scenes = new SceneSelectionWidget(window(), false, true, true);
_sourceTypes = new QComboBox();
_sources = new QComboBox();
_sources->setSizeAdjustPolicy(QComboBox::AdjustToContents);
_sources = new SceneItemSelectionWidget(parent);
_sourceGroups = new QComboBox();
_actions = new QComboBox();
populateSourceItemTypeSelection(_sourceTypes);
populateSourceGroupSelection(_sourceGroups);
populateActionSelection(_actions);
QWidget::connect(_actions, SIGNAL(currentIndexChanged(int)), this,
@@ -188,14 +182,19 @@ MacroActionSceneVisibilityEdit::MacroActionSceneVisibilityEdit(
this, SLOT(SceneChanged(const SceneSelection &)));
QWidget::connect(_sourceTypes, SIGNAL(currentIndexChanged(int)), this,
SLOT(SourceTypeChanged(int)));
QWidget::connect(_sources, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(SourceChanged(const QString &)));
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
_sources, SLOT(SceneChanged(const SceneSelection &)));
QWidget::connect(_sources,
SIGNAL(SceneItemChanged(const SceneItemSelection &)),
this, SLOT(SourceChanged(const SceneItemSelection &)));
QWidget::connect(_sourceGroups,
SIGNAL(currentTextChanged(const QString &)), this,
SLOT(SourceGroupChanged(const QString &)));
QHBoxLayout *mainLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{scenes}}", _scenes},
{"{{sourceTypes}}", _sourceTypes},
{"{{sources}}", _sources},
{"{{scenes}}", _scenes}, {"{{sourceTypes}}", _sourceTypes},
{"{{sources}}", _sources}, {"{{sourceGroups}}", _sourceGroups},
{"{{actions}}", _actions},
};
placeWidgets(obs_module_text(
@@ -218,14 +217,10 @@ void MacroActionSceneVisibilityEdit::UpdateEntryData()
_sourceTypes->setCurrentIndex(
static_cast<int>(_entryData->_sourceType));
_scenes->SetScene(_entryData->_scene);
if (_entryData->_sourceType == SceneItemSourceType::SOURCE) {
populateSceneItemSelection(_sources, _entryData->_scene);
_sources->setCurrentText(
GetWeakSourceName(_entryData->_source).c_str());
} else {
populateSourceTypeSelection(_sources);
_sources->setCurrentText(_entryData->_sourceGroup.c_str());
}
_sources->SetSceneItem((_entryData->_source));
_sourceGroups->setCurrentText(
QString::fromStdString(_entryData->_sourceGroup));
SetWidgetVisibility();
}
void MacroActionSceneVisibilityEdit::SceneChanged(const SceneSelection &s)
@@ -233,13 +228,9 @@ void MacroActionSceneVisibilityEdit::SceneChanged(const SceneSelection &s)
if (_loading || !_entryData) {
return;
}
{
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_scene = s;
}
_sources->clear();
populateSceneItemSelection(_sources, _entryData->_scene);
_sources->adjustSize();
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_scene = s;
}
void MacroActionSceneVisibilityEdit::SourceTypeChanged(int value)
@@ -247,35 +238,36 @@ void MacroActionSceneVisibilityEdit::SourceTypeChanged(int value)
if (_loading || !_entryData) {
return;
}
{
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_sourceType =
static_cast<SceneItemSourceType>(value);
}
_sources->clear();
if (_entryData->_sourceType == SceneItemSourceType::SOURCE) {
populateSceneItemSelection(_sources, _entryData->_scene);
} else {
populateSourceTypeSelection(_sources);
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_sourceType = static_cast<SceneItemSourceType>(value);
SetWidgetVisibility();
}
void MacroActionSceneVisibilityEdit::SourceChanged(const QString &text)
void MacroActionSceneVisibilityEdit::SourceChanged(
const SceneItemSelection &item)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
if (_entryData->_sourceType == SceneItemSourceType::SOURCE) {
_entryData->_source = GetWeakSourceByQString(text);
_entryData->_source = item;
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
}
void MacroActionSceneVisibilityEdit::SourceGroupChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
if (text == obs_module_text("AdvSceneSwitcher.selectItem")) {
_entryData->_sourceGroup = "";
} else {
if (text == obs_module_text("AdvSceneSwitcher.selectItem")) {
_entryData->_sourceGroup = "";
} else {
_entryData->_sourceGroup = text.toStdString();
}
_entryData->_sourceGroup = text.toStdString();
}
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
@@ -290,3 +282,15 @@ void MacroActionSceneVisibilityEdit::ActionChanged(int value)
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_action = static_cast<SceneVisibilityAction>(value);
}
void MacroActionSceneVisibilityEdit::SetWidgetVisibility()
{
if (!_entryData) {
return;
}
_sources->setVisible(_entryData->_sourceType ==
SceneItemSourceType::SOURCE);
_sourceGroups->setVisible(_entryData->_sourceType ==
SceneItemSourceType::SOURCE_GROUP);
adjustSize();
}

View File

@@ -0,0 +1,382 @@
#include "headers/macro-action-sequence.hpp"
#include "headers/advanced-scene-switcher.hpp"
#include "headers/utility.hpp"
const std::string MacroActionSequence::id = "sequence";
bool MacroActionSequence::_registered = MacroActionFactory::Register(
MacroActionSequence::id,
{MacroActionSequence::Create, MacroActionSequenceEdit::Create,
"AdvSceneSwitcher.action.sequence"});
int getNextUnpausedMacroIdx(std::vector<MacroRef> &macros, int startIdx)
{
for (; macros.size() > startIdx; ++startIdx) {
if (!macros[startIdx]->Paused()) {
return startIdx;
}
}
return -1;
}
MacroRef MacroActionSequence::GetNextMacro(bool advance)
{
int idx = _lastIdx;
MacroRef res;
int nextUnpausedIdx = getNextUnpausedMacroIdx(_macros, idx + 1);
if (nextUnpausedIdx != -1) {
res = _macros[nextUnpausedIdx];
idx = nextUnpausedIdx;
} else {
if (_restart) {
idx = getNextUnpausedMacroIdx(_macros, 0);
if (idx != -1) {
res = _macros[idx];
} else {
// End of sequence reached, as all available
// macros are either paused or the macro list
// is empty
idx = _macros.size();
}
} else {
// End of sequence reached
idx = _macros.size();
}
}
if (advance) {
_lastIdx = idx;
_lastSequenceMacro = res;
}
return res;
}
bool MacroActionSequence::PerformAction()
{
if (_macros.size() == 0) {
return true;
}
auto macro = GetNextMacro();
if (!macro.get()) {
return true;
}
return macro->PerformAction();
}
void MacroActionSequence::LogAction()
{
vblog(LOG_INFO, "running macro sequence");
}
bool MacroActionSequence::Save(obs_data_t *obj)
{
MacroAction::Save(obj);
obs_data_array_t *args = obs_data_array_create();
for (auto &m : _macros) {
obs_data_t *array_obj = obs_data_create();
m.Save(array_obj);
obs_data_array_push_back(args, array_obj);
obs_data_release(array_obj);
}
obs_data_set_array(obj, "macros", args);
obs_data_array_release(args);
obs_data_set_bool(obj, "restart", _restart);
return true;
}
bool MacroActionSequence::Load(obs_data_t *obj)
{
MacroAction::Load(obj);
obs_data_array_t *args = obs_data_get_array(obj, "macros");
size_t count = obs_data_array_count(args);
for (size_t i = 0; i < count; i++) {
obs_data_t *array_obj = obs_data_array_item(args, i);
MacroRef ref;
ref.Load(array_obj);
_macros.push_back(ref);
obs_data_release(array_obj);
}
obs_data_array_release(args);
_restart = obs_data_get_bool(obj, "restart");
return true;
}
MacroActionSequenceEdit::MacroActionSequenceEdit(
QWidget *parent, std::shared_ptr<MacroActionSequence> entryData)
: QWidget(parent)
{
_macroList = new QListWidget();
_add = new QPushButton();
_add->setMaximumSize(QSize(22, 22));
_add->setProperty("themeID",
QVariant(QString::fromUtf8("addIconSmall")));
_add->setFlat(true);
_remove = new QPushButton();
_remove->setMaximumSize(QSize(22, 22));
_remove->setProperty("themeID",
QVariant(QString::fromUtf8("removeIconSmall")));
_remove->setFlat(true);
_up = new QPushButton();
_up->setMaximumSize(QSize(22, 22));
_up->setProperty("themeID",
QVariant(QString::fromUtf8("upArrowIconSmall")));
_up->setFlat(true);
_down = new QPushButton();
_down->setMaximumSize(QSize(22, 22));
_down->setProperty("themeID",
QVariant(QString::fromUtf8("downArrowIconSmall")));
_down->setFlat(true);
_continueFrom = new QPushButton(obs_module_text(
"AdvSceneSwitcher.action.sequence.continueFrom"));
_restart = new QCheckBox(
obs_module_text("AdvSceneSwitcher.action.sequence.restart"));
_statusLine = new QLabel();
QWidget::connect(_add, SIGNAL(clicked()), this, SLOT(Add()));
QWidget::connect(_remove, SIGNAL(clicked()), this, SLOT(Remove()));
QWidget::connect(_up, SIGNAL(clicked()), this, SLOT(Up()));
QWidget::connect(_down, SIGNAL(clicked()), this, SLOT(Down()));
QWidget::connect(_continueFrom, SIGNAL(clicked()), this,
SLOT(ContinueFromClicked()));
QWidget::connect(_macroList, SIGNAL(currentRowChanged(int)), this,
SLOT(MacroSelectionChanged(int)));
QWidget::connect(window(),
SIGNAL(MacroRenamed(const QString &, const QString &)),
this,
SLOT(MacroRename(const QString &, const QString &)));
QWidget::connect(_restart, SIGNAL(stateChanged(int)), this,
SLOT(RestartChanged(int)));
auto *entryLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {};
placeWidgets(obs_module_text("AdvSceneSwitcher.action.sequence.entry"),
entryLayout, widgetPlaceholders);
auto *argButtonLayout = new QHBoxLayout;
argButtonLayout->addWidget(_add);
argButtonLayout->addWidget(_remove);
QFrame *line = new QFrame();
line->setFrameShape(QFrame::VLine);
line->setFrameShadow(QFrame::Sunken);
argButtonLayout->addWidget(line);
argButtonLayout->addWidget(_up);
argButtonLayout->addWidget(_down);
QFrame *line2 = new QFrame();
line2->setFrameShape(QFrame::VLine);
line2->setFrameShadow(QFrame::Sunken);
argButtonLayout->addWidget(line2);
argButtonLayout->addWidget(_continueFrom);
argButtonLayout->addStretch();
auto *mainLayout = new QVBoxLayout;
mainLayout->addLayout(entryLayout);
mainLayout->addWidget(_macroList);
mainLayout->addLayout(argButtonLayout);
mainLayout->addLayout(argButtonLayout);
mainLayout->addWidget(_restart);
mainLayout->addWidget(_statusLine);
setLayout(mainLayout);
UpdateStatusLine();
connect(&_statusTimer, SIGNAL(timeout()), this,
SLOT(UpdateStatusLine()));
_statusTimer.start(1000);
_entryData = entryData;
UpdateEntryData();
_loading = false;
}
void MacroActionSequenceEdit::UpdateEntryData()
{
if (!_entryData) {
return;
}
for (auto &m : _entryData->_macros) {
if (!m.get()) {
continue;
}
auto name = QString::fromStdString(m->Name());
QListWidgetItem *item = new QListWidgetItem(name, _macroList);
item->setData(Qt::UserRole, name);
}
SetMacroListSize();
_restart->setChecked(_entryData->_restart);
}
void MacroActionSequenceEdit::MacroRemove(const QString &name)
{
if (_entryData) {
auto it = _entryData->_macros.begin();
while (it != _entryData->_macros.end()) {
if (it->get()->Name() == name.toStdString()) {
it = _entryData->_macros.erase(it);
} else {
++it;
}
}
}
}
void MacroActionSequenceEdit::MacroRename(const QString &oldName,
const QString &newName)
{
auto count = _macroList->count();
for (int idx = 0; idx < count; ++idx) {
QListWidgetItem *item = _macroList->item(idx);
QString itemString = item->data(Qt::UserRole).toString();
if (oldName == itemString) {
item->setData(Qt::UserRole, newName);
item->setText(newName);
break;
}
}
}
void MacroActionSequenceEdit::Add()
{
if (_loading || !_entryData) {
return;
}
std::string macroName;
bool accepted = MacroSelectionDialog::AskForMacro(this, macroName);
if (!accepted || macroName.empty()) {
return;
}
MacroRef macro(macroName);
if (!macro.get()) {
return;
}
QVariant v = QVariant::fromValue(QString::fromStdString(macroName));
new QListWidgetItem(QString::fromStdString(macroName), _macroList);
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_macros.push_back(macro);
SetMacroListSize();
}
void MacroActionSequenceEdit::Remove()
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
auto item = _macroList->currentItem();
int idx = _macroList->currentRow();
if (!item || idx == -1) {
return;
}
_entryData->_macros.erase(std::next(_entryData->_macros.begin(), idx));
delete item;
SetMacroListSize();
}
void MacroActionSequenceEdit::Up()
{
if (_loading || !_entryData) {
return;
}
int idx = _macroList->currentRow();
if (idx != -1 && idx != 0) {
_macroList->insertItem(idx - 1, _macroList->takeItem(idx));
_macroList->setCurrentRow(idx - 1);
std::lock_guard<std::mutex> lock(switcher->m);
std::swap(_entryData->_macros[idx],
_entryData->_macros[idx - 1]);
}
}
void MacroActionSequenceEdit::Down()
{
int idx = _macroList->currentRow();
if (idx != -1 && idx != _macroList->count() - 1) {
_macroList->insertItem(idx + 1, _macroList->takeItem(idx));
_macroList->setCurrentRow(idx + 1);
std::lock_guard<std::mutex> lock(switcher->m);
std::swap(_entryData->_macros[idx],
_entryData->_macros[idx + 1]);
}
}
void MacroActionSequenceEdit::ContinueFromClicked()
{
if (_loading || !_entryData) {
return;
}
int idx = _macroList->currentRow();
if (idx == -1) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_lastIdx = idx - 1;
}
void MacroActionSequenceEdit::RestartChanged(int state)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_restart = state;
}
void MacroActionSequenceEdit::UpdateStatusLine()
{
QString lastMacroName =
obs_module_text("AdvSceneSwitcher.action.sequence.status.none");
QString nextMacroName =
obs_module_text("AdvSceneSwitcher.action.sequence.status.none");
if (_entryData) {
if (_entryData->_lastSequenceMacro.get()) {
lastMacroName = QString::fromStdString(
_entryData->_lastSequenceMacro->Name());
}
auto next = _entryData->GetNextMacro(false);
if (next.get()) {
nextMacroName = QString::fromStdString(next->Name());
}
}
QString format{
obs_module_text("AdvSceneSwitcher.action.sequence.status")};
_statusLine->setText(format.arg(lastMacroName, nextMacroName));
}
int MacroActionSequenceEdit::FindEntry(const std::string &macro)
{
int count = _macroList->count();
int idx = -1;
for (int i = 0; i < count; i++) {
QListWidgetItem *item = _macroList->item(i);
QString itemString = item->data(Qt::UserRole).toString();
if (QString::fromStdString(macro) == itemString) {
idx = i;
break;
}
}
return idx;
}
void MacroActionSequenceEdit::SetMacroListSize()
{
setHeightToContentHeight(_macroList);
adjustSize();
}

View File

@@ -10,9 +10,24 @@ bool MacroConditionAudio::_registered = MacroConditionFactory::Register(
{MacroConditionAudio::Create, MacroConditionAudioEdit::Create,
"AdvSceneSwitcher.condition.audio"});
static std::map<AudioCondition, std::string> audioConditionTypes = {
{AudioCondition::ABOVE, "AdvSceneSwitcher.condition.audio.state.above"},
{AudioCondition::BELOW, "AdvSceneSwitcher.condition.audio.state.below"},
static std::map<AudioOutputCondition, std::string> audioOutputConditionTypes = {
{AudioOutputCondition::ABOVE,
"AdvSceneSwitcher.condition.audio.state.above"},
{AudioOutputCondition::BELOW,
"AdvSceneSwitcher.condition.audio.state.below"},
};
static std::map<AudioVolumeCondition, std::string> audioVolumeConditionTypes = {
{AudioVolumeCondition::ABOVE,
"AdvSceneSwitcher.condition.audio.state.above"},
{AudioVolumeCondition::EXACT,
"AdvSceneSwitcher.condition.audio.state.exact"},
{AudioVolumeCondition::BELOW,
"AdvSceneSwitcher.condition.audio.state.below"},
{AudioVolumeCondition::MUTE,
"AdvSceneSwitcher.condition.audio.state.mute"},
{AudioVolumeCondition::UNMUTE,
"AdvSceneSwitcher.condition.audio.state.unmute"},
};
MacroConditionAudio::~MacroConditionAudio()
@@ -21,21 +36,72 @@ MacroConditionAudio::~MacroConditionAudio()
obs_volmeter_destroy(_volmeter);
}
bool MacroConditionAudio::CheckCondition()
bool MacroConditionAudio::CheckOutputCondition()
{
// peak will have a value from -60 db to 0 db
bool volumeThresholdreached = false;
bool ret = false;
auto s = obs_weak_source_get_source(_audioSource);
if (_condition == AudioCondition::ABOVE) {
volumeThresholdreached = ((double)_peak + 60) * 1.7 > _volume;
} else {
volumeThresholdreached = ((double)_peak + 60) * 1.7 < _volume;
switch (_outputCondition) {
case AudioOutputCondition::ABOVE:
// peak will have a value from -60 db to 0 db
ret = ((double)_peak + 60) * 1.7 > _volume;
break;
case AudioOutputCondition::BELOW:
// peak will have a value from -60 db to 0 db
ret = ((double)_peak + 60) * 1.7 < _volume;
break;
default:
break;
}
// Reset for next check
_peak = -std::numeric_limits<float>::infinity();
obs_source_release(s);
return volumeThresholdreached;
return ret;
}
bool MacroConditionAudio::CheckVolumeCondition()
{
bool ret = false;
auto s = obs_weak_source_get_source(_audioSource);
switch (_volumeCondition) {
case AudioVolumeCondition::ABOVE:
ret = obs_source_get_volume(s) > _volume / 100.f;
break;
case AudioVolumeCondition::EXACT:
ret = obs_source_get_volume(s) == _volume / 100.f;
break;
case AudioVolumeCondition::BELOW:
ret = obs_source_get_volume(s) < _volume / 100.f;
break;
case AudioVolumeCondition::MUTE:
ret = obs_source_muted(s);
break;
case AudioVolumeCondition::UNMUTE:
ret = !obs_source_muted(s);
break;
default:
break;
}
obs_source_release(s);
return ret;
}
bool MacroConditionAudio::CheckCondition()
{
switch (_checkType) {
case AudioConditionCheckType::OUTPUT_VOLUME:
return CheckOutputCondition();
case AudioConditionCheckType::CONFIGURED_VOLUME:
return CheckVolumeCondition();
default:
break;
}
return false;
}
bool MacroConditionAudio::Save(obs_data_t *obj)
@@ -44,7 +110,11 @@ bool MacroConditionAudio::Save(obs_data_t *obj)
obs_data_set_string(obj, "audioSource",
GetWeakSourceName(_audioSource).c_str());
obs_data_set_int(obj, "volume", _volume);
obs_data_set_int(obj, "condition", static_cast<int>(_condition));
obs_data_set_int(obj, "checkType", static_cast<int>(_checkType));
obs_data_set_int(obj, "outputCondition",
static_cast<int>(_outputCondition));
obs_data_set_int(obj, "volumeCondition",
static_cast<int>(_volumeCondition));
return true;
}
@@ -65,14 +135,66 @@ obs_volmeter_t *AddVolmeterToSource(MacroConditionAudio *entry,
return volmeter;
}
// TODO: Remove in future version
static void convertOldSettingsFormat(obs_data_t *obj)
{
auto oldCond = static_cast<AudioOutputCondition>(
obs_data_get_int(obj, "condition"));
switch (oldCond) {
case AudioOutputCondition::ABOVE:
obs_data_set_int(
obj, "checkType",
static_cast<int>(
AudioConditionCheckType::OUTPUT_VOLUME));
obs_data_set_int(obj, "outputCondition",
static_cast<int>(AudioOutputCondition::ABOVE));
break;
case AudioOutputCondition::BELOW:
obs_data_set_int(
obj, "checkType",
static_cast<int>(
AudioConditionCheckType::OUTPUT_VOLUME));
obs_data_set_int(obj, "outputCondition",
static_cast<int>(AudioOutputCondition::BELOW));
break;
case AudioOutputCondition::MUTE:
obs_data_set_int(
obj, "checkType",
static_cast<int>(
AudioConditionCheckType::CONFIGURED_VOLUME));
obs_data_set_int(obj, "volumeCondition",
static_cast<int>(AudioVolumeCondition::MUTE));
break;
case AudioOutputCondition::UNMUTE:
obs_data_set_int(
obj, "checkType",
static_cast<int>(
AudioConditionCheckType::CONFIGURED_VOLUME));
obs_data_set_int(
obj, "volumeCondition",
static_cast<int>(AudioVolumeCondition::UNMUTE));
break;
default:
break;
}
}
bool MacroConditionAudio::Load(obs_data_t *obj)
{
if (!obs_data_has_user_value(obj, "checkType")) {
convertOldSettingsFormat(obj);
}
MacroCondition::Load(obj);
const char *audioSourceName = obs_data_get_string(obj, "audioSource");
_audioSource = GetWeakSourceByName(audioSourceName);
_volume = obs_data_get_int(obj, "volume");
_condition =
static_cast<AudioCondition>(obs_data_get_int(obj, "condition"));
_checkType = static_cast<AudioConditionCheckType>(
obs_data_get_int(obj, "checkType"));
_outputCondition = static_cast<AudioOutputCondition>(
obs_data_get_int(obj, "outputCondition"));
_volumeCondition = static_cast<AudioVolumeCondition>(
obs_data_get_int(obj, "volumeCondition"));
_volmeter = AddVolmeterToSource(this, _audioSource);
return true;
}
@@ -85,13 +207,10 @@ std::string MacroConditionAudio::GetShortDesc()
return "";
}
void MacroConditionAudio::SetVolumeLevel(
void *data, const float magnitude[MAX_AUDIO_CHANNELS],
const float peak[MAX_AUDIO_CHANNELS],
const float inputPeak[MAX_AUDIO_CHANNELS])
void MacroConditionAudio::SetVolumeLevel(void *data, const float *,
const float peak[MAX_AUDIO_CHANNELS],
const float *)
{
UNUSED_PARAMETER(magnitude);
UNUSED_PARAMETER(inputPeak);
MacroConditionAudio *c = static_cast<MacroConditionAudio *>(data);
for (int i = 0; i < MAX_AUDIO_CHANNELS; i++) {
@@ -109,9 +228,26 @@ void MacroConditionAudio::ResetVolmeter()
_volmeter = AddVolmeterToSource(this, _audioSource);
}
static inline void populateConditionSelection(QComboBox *list)
static inline void populateCheckTypes(QComboBox *list)
{
for (auto entry : audioConditionTypes) {
list->addItem(obs_module_text(
"AdvSceneSwitcher.condition.audio.type.output"));
list->addItem(obs_module_text(
"AdvSceneSwitcher.condition.audio.type.volume"));
}
static inline void populateOutputConditionSelection(QComboBox *list)
{
list->clear();
for (auto entry : audioOutputConditionTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
}
}
static inline void populateVolumeConditionSelection(QComboBox *list)
{
list->clear();
for (auto entry : audioVolumeConditionTypes) {
list->addItem(obs_module_text(entry.second.c_str()));
}
}
@@ -120,6 +256,7 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
QWidget *parent, std::shared_ptr<MacroConditionAudio> entryData)
: QWidget(parent)
{
_checkTypes = new QComboBox();
_audioSources = new QComboBox();
_condition = new QComboBox();
_volume = new QSpinBox();
@@ -128,6 +265,8 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
_volume->setMaximum(100);
_volume->setMinimum(0);
QWidget::connect(_checkTypes, SIGNAL(currentIndexChanged(int)), this,
SLOT(CheckTypeChanged(int)));
QWidget::connect(_volume, SIGNAL(valueChanged(int)), this,
SLOT(VolumeThresholdChanged(int)));
QWidget::connect(_condition, SIGNAL(currentIndexChanged(int)), this,
@@ -136,11 +275,12 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
SIGNAL(currentTextChanged(const QString &)), this,
SLOT(SourceChanged(const QString &)));
populateCheckTypes(_checkTypes);
populateAudioSelection(_audioSources);
populateConditionSelection(_condition);
QHBoxLayout *switchLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{checkType}}", _checkTypes},
{"{{audioSources}}", _audioSources},
{"{{volume}}", _volume},
{"{{condition}}", _condition},
@@ -189,6 +329,7 @@ void MacroConditionAudioEdit::SourceChanged(const QString &text)
_entryData->_audioSource = GetWeakSourceByQString(text);
_entryData->ResetVolmeter();
UpdateVolmeterSource();
SetWidgetVisibility();
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
}
@@ -210,7 +351,32 @@ void MacroConditionAudioEdit::ConditionChanged(int cond)
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_condition = static_cast<AudioCondition>(cond);
if (_entryData->_checkType == AudioConditionCheckType::OUTPUT_VOLUME) {
_entryData->_outputCondition =
static_cast<AudioOutputCondition>(cond);
} else {
_entryData->_volumeCondition =
static_cast<AudioVolumeCondition>(cond);
}
SetWidgetVisibility();
}
void MacroConditionAudioEdit::CheckTypeChanged(int cond)
{
if (_loading || !_entryData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->_checkType = static_cast<AudioConditionCheckType>(cond);
const QSignalBlocker b(_condition);
if (_entryData->_checkType == AudioConditionCheckType::OUTPUT_VOLUME) {
populateOutputConditionSelection(_condition);
} else {
populateVolumeConditionSelection(_condition);
}
SetWidgetVisibility();
}
void MacroConditionAudioEdit::UpdateEntryData()
@@ -222,6 +388,35 @@ void MacroConditionAudioEdit::UpdateEntryData()
_audioSources->setCurrentText(
GetWeakSourceName(_entryData->_audioSource).c_str());
_volume->setValue(_entryData->_volume);
_condition->setCurrentIndex(static_cast<int>(_entryData->_condition));
_checkTypes->setCurrentIndex(static_cast<int>(_entryData->_checkType));
if (_entryData->_checkType == AudioConditionCheckType::OUTPUT_VOLUME) {
populateOutputConditionSelection(_condition);
_condition->setCurrentIndex(
static_cast<int>(_entryData->_outputCondition));
} else {
populateVolumeConditionSelection(_condition);
_condition->setCurrentIndex(
static_cast<int>(_entryData->_volumeCondition));
}
UpdateVolmeterSource();
SetWidgetVisibility();
}
void MacroConditionAudioEdit::SetWidgetVisibility()
{
if (!_entryData) {
return;
}
_volume->setVisible(
_entryData->_checkType ==
AudioConditionCheckType::OUTPUT_VOLUME ||
(_entryData->_checkType ==
AudioConditionCheckType::CONFIGURED_VOLUME &&
(_entryData->_volumeCondition == AudioVolumeCondition::ABOVE ||
_entryData->_volumeCondition == AudioVolumeCondition::EXACT ||
_entryData->_volumeCondition == AudioVolumeCondition::BELOW)));
_volMeter->setVisible(_entryData->_checkType ==
AudioConditionCheckType::OUTPUT_VOLUME);
adjustSize();
}

View File

@@ -18,10 +18,10 @@ bool MacroConditionFactory::Register(const std::string &id,
}
std::shared_ptr<MacroCondition>
MacroConditionFactory::Create(const std::string &id)
MacroConditionFactory::Create(const std::string &id, Macro *m)
{
if (auto it = _methods.find(id); it != _methods.end()) {
return it->second._createFunc();
return it->second._createFunc(m);
}
return nullptr;
}
@@ -87,6 +87,7 @@ static inline void populateConditionSelection(QComboBox *list)
for (auto entry : MacroConditionFactory::GetConditionTypes()) {
list->addItem(obs_module_text(entry.second._name.c_str()));
}
list->model()->sort(0);
}
MacroConditionEdit::MacroConditionEdit(
@@ -189,6 +190,7 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
}
auto idx = _entryData->get()->GetIndex();
auto macro = _entryData->get()->GetMacro();
std::string id = MacroConditionFactory::GetIdByName(text);
auto temp = DurationConstraint();
@@ -198,7 +200,7 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
std::lock_guard<std::mutex> lock(switcher->m);
auto logic = (*_entryData)->GetLogicType();
_entryData->reset();
*_entryData = MacroConditionFactory::Create(id);
*_entryData = MacroConditionFactory::Create(id, macro);
(*_entryData)->SetIndex(idx);
(*_entryData)->SetLogicType(logic);
auto widget =
@@ -260,14 +262,14 @@ void AdvSceneSwitcher::AddMacroCondition(int idx)
if (idx - 1 >= 0) {
id = macro->Conditions().at(idx - 1)->GetId();
} else {
MacroConditionScene temp;
MacroConditionScene temp(macro);
id = temp.GetId();
}
std::lock_guard<std::mutex> lock(switcher->m);
bool root = idx == 0;
auto cond =
macro->Conditions().emplace(macro->Conditions().begin() + idx,
MacroConditionFactory::Create(id));
auto cond = macro->Conditions().emplace(
macro->Conditions().begin() + idx,
MacroConditionFactory::Create(id, macro));
if (idx - 1 >= 0) {
auto data = obs_data_create();
macro->Conditions().at(idx - 1)->Save(data);

View File

@@ -10,21 +10,23 @@ bool MacroConditionHotkey::_registered = MacroConditionFactory::Register(
{MacroConditionHotkey::Create, MacroConditionHotkeyEdit::Create,
"AdvSceneSwitcher.condition.hotkey", false});
static void hotkeyCB(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
bool pressed)
static void hotkeyCB(void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed)
{
UNUSED_PARAMETER(id);
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(hotkey);
if (pressed) {
auto c = static_cast<MacroConditionHotkey *>(data);
c->SetPressed();
auto macro = c->GetMacro();
if (!macro) {
c->SetPressed();
}
if (macro && !macro->Paused()) {
c->SetPressed();
}
}
}
static uint32_t count = 1;
MacroConditionHotkey::MacroConditionHotkey()
MacroConditionHotkey::MacroConditionHotkey(Macro *m) : MacroCondition(m)
{
if (_hotkeyID != OBS_INVALID_HOTKEY_ID) {
obs_hotkey_unregister(_hotkeyID);
@@ -80,8 +82,11 @@ MacroConditionHotkeyEdit::MacroConditionHotkeyEdit(
: QWidget(parent)
{
_name = new QLineEdit();
QLabel *line1 = new QLabel(obs_module_text(
"AdvSceneSwitcher.condition.hotkey.entry.line1"));
QLabel *hint = new QLabel(
obs_module_text("AdvSceneSwitcher.condition.hotkey.tip"));
QWidget::connect(_name, SIGNAL(editingFinished()), this,
SLOT(NameChanged()));
@@ -89,10 +94,12 @@ MacroConditionHotkeyEdit::MacroConditionHotkeyEdit(
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{name}}", _name},
};
placeWidgets(obs_module_text("AdvSceneSwitcher.condition.hotkey.entry"),
placeWidgets(obs_module_text(
"AdvSceneSwitcher.condition.hotkey.entry.line2"),
switchLayout, widgetPlaceholders);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(line1);
mainLayout->addLayout(switchLayout);
mainLayout->addWidget(hint);
setLayout(mainLayout);

Some files were not shown because too many files have changed in this diff Show More