Compare commits

..

92 Commits

Author SHA1 Message Date
WarmUpTill
ba7886c8c1 Fix variables of nested macros' actions not being resolved 2026-06-16 20:43:09 +02:00
WarmUpTill
801268d08b Fix nested macro actions being executed twice when added to a queue 2026-06-16 20:29:11 +02:00
WarmUpTill
7dfd9ddcb5 Print plugin enabled/disabled summary during CMake configure
Some checks are pending
debian-build / build (push) Waiting to run
Push to master / Check Formatting 🔍 (push) Waiting to run
Push to master / Build Project 🧱 (push) Waiting to run
Push to master / Create Release 🛫 (push) Blocked by required conditions
2026-06-16 17:40:22 +02:00
WarmUpTill
6215c39024 Don't fail cmake configure step if openvr deps are not met 2026-06-16 17:40:22 +02:00
WarmUpTill
1c856911e8 Set default value for CMAKE_GENERATOR_PLATFORM on Windows 2026-06-16 17:40:22 +02:00
WarmUpTill
ed17c2ac6d Disconnect Twitch chat and event connection on plugin stop
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-06-13 22:05:32 +02:00
WarmUpTill
1ce332a91d Track all kWin wayland windows 2026-06-13 22:01:52 +02:00
WarmUpTill
2aa27fc051 Fix window conditions not triggering for native Wayland windows
When KWin compat is active, GetWindows() only returned XWayland windows
since it relied on X11's _NET_CLIENT_LIST. Native Wayland windows were
invisible to conditions even though GetCurrentWindowTitle() reported them
correctly via the KWin DBus notifier.
2026-06-13 22:01:52 +02:00
WarmUpTill
31b239d5dc Focus segment type selection when new segment is added
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-06-11 18:25:29 +02:00
WarmUpTill
7c3779e287 Sort macro export dialog resources alphabetically and add scrollbars 2026-06-11 18:25:29 +02:00
WarmUpTill
3f13c33b10 Fix crash on transition start in studio mode 2026-06-11 18:25:29 +02:00
WarmUpTill
8727a65513 Support both recommended and legacy layouts in Windows installer
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
Default to %ProgramData%\obs-studio\plugins\ on fresh installs.
Restore the previously recorded install path on upgrades, so users
who installed to a custom location are not silently moved.
2026-05-30 16:01:11 +02:00
WarmUpTill
baf3d0e63c Fix race condition in Twitch event sub reconnection logic 2026-05-30 16:01:11 +02:00
WarmUpTill
ea2d1e7e9d Fix crash when importing macros is slow
Probably not a real issue.
Noticed during debug of another problem.
2026-05-30 16:01:11 +02:00
WarmUpTill
f9f26ad50b Fix crash on shutdown
StopAllMacros was called before th->wait(), allowing Macro::Stop()
to run concurrently with the other threads still inside
CheckConditions. This caused races on _conditionCheckFuture (called
from both threads) and _helperThreads.

This could happen if conditions / actions were marked to run in parallel
to the main loop.
2026-05-30 16:01:11 +02:00
WarmUpTill
9911c41a35 Split advanced-scene-switcher-*-windows-x64.zip
One zip archive for the ProgramData path.
Another zip archive for the legacy Program Files path.

Requested in:
https://github.com/WarmUpTill/SceneSwitcher/discussions/1628
2026-05-30 16:01:11 +02:00
WarmUpTill
d590bc11f8 Fix freeze when choosing invalid OCR model 2026-05-30 16:01:11 +02:00
WarmUpTill
31c4c1f5d7 Convert "Program Files/" paths to "ProgramData/" paths on Windows
Affects OCR and object detection functionality of the video condition
2026-05-30 16:01:11 +02:00
WarmUpTill
42ff48d637 Add option to lock settings dialog with simple password
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
This is meant as a simple tampering protection.
The settings are not encrypted and the password is stored in plaintext.
2026-05-28 21:50:00 +02:00
WarmUpTill
d44376e869 deps: Update cpp-httplib to v0.46.0
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-05-27 11:38:26 +02:00
WarmUpTill
4b1fd9e700 Fix crash on startup
Resize of vector could invalidate the this pointers passed to the
PostLoad step lambdas
2026-05-27 11:32:30 +02:00
WarmUpTill
d61099f9c0 Fix freeze when showing setup wizzard
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-05-25 12:04:57 +02:00
WarmUpTill
c2b73a02ca Prevent plugin from being loaded twice 2026-05-25 11:49:37 +02:00
WarmUpTill
49a681bcfe Show "Macro Schedule" tab when date / timer condition is created 2026-05-25 11:49:37 +02:00
WarmUpTill
4cedb29123 Fix issues with Windows installer
Don't reuse the old installation dir since it might not be compatible
with the new layout.
Ensure previous legacy install is cleaned up to avoid plugin being
installed twice.
2026-05-25 11:49:37 +02:00
WarmUpTill
d80b3aaf69 CI: Ensure ccache is used on macOS 2026-05-25 11:49:37 +02:00
WarmUpTill
b1cc15386f Fix warnings 2026-05-25 11:49:37 +02:00
WarmUpTill
748744d1b7 Fix packaging issue on Ubuntu 2026-05-25 11:49:37 +02:00
WarmUpTill
912ff98e27 Ignore warnings generated by libremidi 2026-05-25 11:49:37 +02:00
WarmUpTill
a9614c5306 CI: Fix warnings 2026-05-25 11:49:34 +02:00
WarmUpTill
cb2f97f11d Adapt macOS fullscreen window detection to be more reliable 2026-05-25 00:22:59 +02:00
WarmUpTill
017ea233ec Fix macOS fullscreen window detection across "Spaces" 2026-05-25 00:22:59 +02:00
WarmUpTill
e8206173ff Tests: Add test-macro-condition-window.cpp 2026-05-25 00:22:59 +02:00
WarmUpTill
680f72e4f9 Rework temp var mapping handling on copy of macro segments 2026-05-25 00:22:59 +02:00
WarmUpTill
930e8b38d4 Refactor window platform helper functions 2026-05-25 00:22:59 +02:00
WarmUpTill
ee1d0136d9 Add temp vars for window position and size 2026-05-25 00:22:59 +02:00
WarmUpTill
20c276f4ea CI: Fix occasional formatting check failures 2026-05-25 00:22:59 +02:00
WarmUpTill
bea4f66eb1 Fix crash when accessing files in profile dir 2026-05-25 00:22:59 +02:00
WarmUpTill
c5185765ee CI: Pin openssl version on Windows
Must stick with OpenSSL 3 for now to stay compatbile with the asio
version supported by websocketpp
2026-05-25 00:22:59 +02:00
WarmUpTill
90130c119e Fix crash due to "keep source active" setting 2026-05-25 00:22:59 +02:00
WarmUpTill
a7ca06d25c Prevent crash when OCR traineddata file is missing 2026-05-25 00:22:59 +02:00
WarmUpTill
5a5d590c51 CI: Trigger rebuild of dependencies 2026-05-25 00:22:58 +02:00
WarmUpTill
336b398bc3 deps: Update libusb submodule to v1.0.30-rc2
Required for v145 toolset support on Windows
2026-05-25 00:22:58 +02:00
WarmUpTill
56c8f335db deps: Update leptonica submodule to 1.87.0
Required to support cmake 4+
2026-05-25 00:22:58 +02:00
WarmUpTill
b6a4d48948 Fix temp var mapping not working for new macro segments 2026-05-25 00:22:58 +02:00
WarmUpTill
774ccb7fbd Fix temp var mapping not working after copy-paste of segment 2026-05-25 00:22:58 +02:00
WarmUpTill
eda9dde23d Add temp vars indicating OCR match location 2026-05-25 00:22:58 +02:00
WarmUpTill
bbf91efd0d Add "Macro Schedule" tab 2026-05-25 00:22:54 +02:00
WarmUpTill
b022d59391 Add calendar widget 2026-05-15 19:15:19 +02:00
WarmUpTill
cf46a010a7 Add support for units "days" 2026-05-15 19:15:19 +02:00
WarmUpTill
595bab0d83 Add option to export Websocket, Twitch, HTTP connections 2026-05-15 19:15:19 +02:00
WarmUpTill
6fc819d72b Add API to expand export / import dialog 2026-05-15 19:15:19 +02:00
WarmUpTill
0553a9b2ee Call MacroRef::PostLoad() automatically 2026-05-15 19:15:19 +02:00
WarmUpTill
3caa3a4735 Add helpers to check, run, stop, and pause macros 2026-05-15 19:15:19 +02:00
WarmUpTill
2469057ad6 Fix double free
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-05-11 17:30:18 +02:00
WarmUpTill
b230ec5bc5 locale: Clarify "reevaluate condition state" option for run macro action 2026-05-11 17:30:18 +02:00
WarmUpTill
1669b4cb72 Fix "Run Macro" help being visible when option is not selected 2026-05-11 17:30:18 +02:00
WarmUpTill
2841fcaadb Fix variable dock not listing variables on startup 2026-05-11 17:30:11 +02:00
WarmUpTill
91810d9c40 Enable resolving plugin symbols in OBS crash reports 2026-05-11 17:24:35 +02:00
WarmUpTill
ccb5c8ba2c Don't highlight paused macro in macro list 2026-05-11 17:24:35 +02:00
WarmUpTill
265daebdf3 Don't log "on change" when macro is paused 2026-05-11 17:24:35 +02:00
WarmUpTill
a149a11c57 Don't highlight action trigger mode when macro is paused 2026-05-11 17:24:35 +02:00
WarmUpTill
d7cc7a4c7b Ensure plugin is stopped before running cleanup steps 2026-05-11 17:24:35 +02:00
WarmUpTill
41866bcb24 Replace "Ignore Entry" condition logic with SwitchButton toggle 2026-05-11 17:24:35 +02:00
WarmUpTill
c73a5866d7 Add option to keep source of video condition active
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-05-10 12:47:55 +02:00
WarmUpTill
18aaf1dd31 Add option to keep selected game capture sources active 2026-05-10 12:47:55 +02:00
WarmUpTill
d523a2e674 Add helper to keep sources active
To be used for e.g. the video condition / game capture condition, which
can only get the relevant information while a given source is "active".

A source can become active if it is not part of the currently selected
scene.
2026-05-10 12:47:55 +02:00
WarmUpTill
0f7eed6257 Fix "transitioning from" check not working in studio mode
Some checks are pending
debian-build / build (push) Waiting to run
Push to master / Check Formatting 🔍 (push) Waiting to run
Push to master / Build Project 🧱 (push) Waiting to run
Push to master / Create Release 🛫 (push) Blocked by required conditions
2026-05-09 13:05:50 +02:00
WarmUpTill
1f5a346190 Fix transition signals not being connected on scene selection change
This would be the case if a new transition condition was created, which
immediately is changed to "transitioning from ..." or "transitioning to
..." type.
2026-05-09 13:05:50 +02:00
WarmUpTill
7fd2979e86 Support legacy and new Windows install paths in zip archive
Some checks are pending
debian-build / build (push) Waiting to run
Push to master / Check Formatting 🔍 (push) Waiting to run
Push to master / Build Project 🧱 (push) Waiting to run
Push to master / Create Release 🛫 (push) Blocked by required conditions
See https://obsproject.com/kb/plugins-guide for more details
2026-05-08 22:15:44 +02:00
WarmUpTill
2077e1971d Adapt to new plugin folder structure / location for Windows 2026-05-08 22:15:44 +02:00
WarmUpTill
873e073eb6 Show all feature tabs when setup wizard is skipped
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-05-05 19:36:41 +02:00
WarmUpTill
4f3d9e3a00 Use static self-registration for action queue and variable setup
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
Removes explicit setup calls from the plugin core. Each module now
registers its own save/load/cleanup steps via a static initializer,
decoupling them from InitSceneSwitcher and SwitcherData.
2026-04-30 22:39:06 +02:00
WarmUpTill
c02896ea17 Clear websocket and mqtt connections on shutdown
This was previously implicitly done by a settings reload on shutdown,
but this has since been removed, and we need to clear the connections
explicitly.
2026-04-30 22:39:06 +02:00
WarmUpTill
4bfd40219b Deregister all inline scripts on SCRIPTING_SHUTDOWN 2026-04-30 22:39:06 +02:00
WarmUpTill
6a3de18069 Clear macros on shutdown
This was done implicitly in the shutdown handler by clearing the
plugin's settings.
Due to unwanted side effects this behavior has been disabled for the
shutdown and thus macros have to be cleared explicitly on shutdown.
2026-04-30 22:39:06 +02:00
WarmUpTill
8c51b44fbb Fix potential event sub freeze on disconnect 2026-04-30 22:39:06 +02:00
WarmUpTill
10daa38921 Cleanup 2026-04-30 22:39:06 +02:00
WarmUpTill
6e0f7ab38f Default to assuming OBS is shutting down
This reverts commit eea91b79b38b7c33561dc6c639d01dea8a802cdd.
2026-04-30 22:39:06 +02:00
WarmUpTill
86061b3cf1 Ignore OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP on shutdown
This prevents the plugin being restarted, connections being reset, and
potentially delaying the shutdown of OBS.
2026-04-30 22:39:06 +02:00
WarmUpTill
c3669cae3e Tests: Make building tests optional, enable for CI 2026-04-30 20:11:52 +02:00
WarmUpTill
a116360f87 Tests: Handle QFile::open() return value 2026-04-30 20:11:52 +02:00
WarmUpTill
713f695aa4 Show variable mapping for "Source" and "Twitch" action
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-04-27 19:20:51 +02:00
WarmUpTill
dec5c2d763 Add option to directly map temp var values to variables 2026-04-27 19:20:51 +02:00
WarmUpTill
f090dea136 Add "Run macro" option
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-04-21 17:48:05 +02:00
WarmUpTill
d00986df03 Add button to get current values to "Streaming" action 2026-04-21 17:45:35 +02:00
WarmUpTill
03e5397b7e CI: remove openssl workaround
Some checks are pending
debian-build / build (push) Waiting to run
Push to master / Check Formatting 🔍 (push) Waiting to run
Push to master / Build Project 🧱 (push) Waiting to run
Push to master / Create Release 🛫 (push) Blocked by required conditions
2026-04-20 20:47:46 +02:00
WarmUpTill
94d49db196 Add tests for process condition
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
2026-04-15 14:02:59 +02:00
WarmUpTill
1483f9d9dc Cleanup / style changes 2026-04-15 14:02:59 +02:00
WarmUpTill
99629e8c66 Add process path check 2026-04-15 14:02:59 +02:00
WarmUpTill
ba38b8bf27 Don't block UI while executing long runnig actions
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
The previous approach had the problem of losing any action internal
state changes in the created copy.

Revert "Fix temp var values of actions not being accessible"
This reverts commit df42538319.
Revert "Don't block UI while running actions"
This reverts commit a01d26e25d.
2026-04-04 21:14:05 +02:00
WarmUpTill
38513735dd Refresh available interactable soruces on show 2026-04-04 21:14:05 +02:00
168 changed files with 8250 additions and 1014 deletions

View File

@@ -19,14 +19,9 @@ inputs:
runs: runs:
using: 'composite' using: 'composite'
steps: steps:
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.13
with:
cmake-version: '3.x.x'
- name: Restore cached dependencies - name: Restore cached dependencies
id: restore-cache id: restore-cache
uses: actions/cache@v4 uses: actions/cache@v5
with: with:
path: ${{ env.DEP_DIR }} path: ${{ env.DEP_DIR }}
key: ${{ env.DEP_DIR }}-${{ runner.os }}-${{ inputs.target }} key: ${{ env.DEP_DIR }}-${{ runner.os }}-${{ inputs.target }}

View File

@@ -29,6 +29,7 @@ runs:
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
echo "/home/linuxbrew/.linuxbrew/opt/clang-format@16/bin" >> $GITHUB_PATH echo "/home/linuxbrew/.linuxbrew/opt/clang-format@16/bin" >> $GITHUB_PATH
brew update
brew install --quiet zsh brew install --quiet zsh
echo ::endgroup:: echo ::endgroup::
@@ -52,6 +53,7 @@ runs:
if (( ${changes[(I)(*.c|*.h|*.cpp|*.hpp|*.m|*.mm)]} )) { if (( ${changes[(I)(*.c|*.h|*.cpp|*.hpp|*.m|*.mm)]} )) {
echo ::group::Install clang-format-16 echo ::group::Install clang-format-16
brew update
brew install --quiet obsproject/tools/clang-format@16 brew install --quiet obsproject/tools/clang-format@16
echo ::endgroup:: echo ::endgroup::

View File

@@ -1,4 +1,4 @@
package 'cmake', path: 'Cmake\bin', bin: 'cmake' package 'cmake', path: 'Cmake\bin', bin: 'cmake'
package 'innosetup', path: 'Inno Setup 6', bin: 'iscc' package 'innosetup', path: 'Inno Setup 6', bin: 'iscc'
package 'OpenSSL', path: 'OpenSSL', bin: 'openssl' package 'OpenSSL', path: 'OpenSSL', bin: 'openssl', version: '3.6.2'
package 'Microsoft.VisualStudio.Locator', path: 'vswhere', bin: 'vswhere' package 'Microsoft.VisualStudio.Locator', path: 'vswhere', bin: 'vswhere'

View File

@@ -255,6 +255,10 @@ ${_usage_host:-}"
cmake_args+=( cmake_args+=(
-DCMAKE_PREFIX_PATH="${advss_deps_path}" -DCMAKE_PREFIX_PATH="${advss_deps_path}"
-DOPENSSL_ROOT_DIR="${advss_deps_path}"
-DOPENSSL_INCLUDE_DIR="${advss_deps_path}/include"
-DOPENSSL_CRYPTO_LIBRARY="${advss_deps_path}/lib/libcrypto.a"
-DOPENSSL_SSL_LIBRARY="${advss_deps_path}/lib/libssl.a"
--preset ${_preset} --preset ${_preset}
) )

View File

@@ -68,14 +68,53 @@ function Package {
Remove-Item @RemoveArgs Remove-Item @RemoveArgs
Log-Group "Archiving ${ProductName}..." $ReleasePath = "${ProjectRoot}/release/${Configuration}"
$CompressArgs = @{ $NewBinPath = "${ReleasePath}/${ProductName}/bin/64bit"
Path = (Get-ChildItem -Path "${ProjectRoot}/release/${Configuration}" -Exclude "${OutputName}*.*") $NewDataPath = "${ReleasePath}/${ProductName}/data"
CompressionLevel = 'Optimal' $CIWindowsDir = "${ProjectRoot}/build-aux/CI/windows"
DestinationPath = "${ProjectRoot}/release/${OutputName}.zip"
Verbose = ($Env:CI -ne $null) # --- Recommended zip (new layout, extract to %ProgramData%\obs-studio\) ---
Log-Group "Archiving ${ProductName} (recommended)..."
$RecStaging = "${ProjectRoot}/release/zip-staging-rec"
Remove-Item -Path $RecStaging -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $RecStaging | Out-Null
Copy-Item -Path "${CIWindowsDir}/README.txt" -Destination "${RecStaging}/README.txt"
if ( Test-Path -Path $NewBinPath ) {
$RecBinPath = "${RecStaging}/${ProductName}/bin/64bit"
New-Item -ItemType Directory -Force -Path $RecBinPath | Out-Null
Copy-Item -Path "${NewBinPath}/*" -Destination $RecBinPath -Recurse -Force
} }
Compress-Archive -Force @CompressArgs if ( Test-Path -Path $NewDataPath ) {
$RecDataPath = "${RecStaging}/${ProductName}/data"
New-Item -ItemType Directory -Force -Path $RecDataPath | Out-Null
Copy-Item -Path "${NewDataPath}/*" -Destination $RecDataPath -Recurse -Force
}
Compress-Archive -Force -Path (Get-ChildItem -Path $RecStaging) `
-CompressionLevel Optimal `
-DestinationPath "${ProjectRoot}/release/${OutputName}.zip"
Remove-Item -Path $RecStaging -Recurse -Force
Log-Group
# --- Legacy zip (old layout, extract to OBS install directory) ---
Log-Group "Archiving ${ProductName} (legacy)..."
$LegStaging = "${ProjectRoot}/release/zip-staging-leg"
Remove-Item -Path $LegStaging -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $LegStaging | Out-Null
Copy-Item -Path "${CIWindowsDir}/README-legacy.txt" -Destination "${LegStaging}/README.txt"
if ( Test-Path -Path $NewBinPath ) {
$LegBinPath = "${LegStaging}/obs-plugins/64bit"
New-Item -ItemType Directory -Force -Path $LegBinPath | Out-Null
Copy-Item -Path "${NewBinPath}/*" -Destination $LegBinPath -Recurse -Force
}
if ( Test-Path -Path $NewDataPath ) {
$LegDataPath = "${LegStaging}/data/obs-plugins/${ProductName}"
New-Item -ItemType Directory -Force -Path $LegDataPath | Out-Null
Copy-Item -Path "${NewDataPath}/*" -Destination $LegDataPath -Recurse -Force
}
Compress-Archive -Force -Path (Get-ChildItem -Path $LegStaging) `
-CompressionLevel Optimal `
-DestinationPath "${ProjectRoot}/release/${OutputName}-legacy.zip"
Remove-Item -Path $LegStaging -Recurse -Force
Log-Group Log-Group
if ( ( $BuildInstaller ) ) { if ( ( $BuildInstaller ) ) {
@@ -89,7 +128,25 @@ function Package {
Log-Information 'Creating InnoSetup installer...' Log-Information 'Creating InnoSetup installer...'
Push-Location -Stack BuildTemp Push-Location -Stack BuildTemp
Ensure-Location -Path "${ProjectRoot}/release" Ensure-Location -Path "${ProjectRoot}/release"
Copy-Item -Path ${Configuration} -Destination Package -Recurse Remove-Item -Path Package -Recurse -Force -ErrorAction SilentlyContinue
# Recommended layout (for %ProgramData%\obs-studio\plugins\)
$PkgRec = "Package/recommended"
New-Item -ItemType Directory -Force -Path $PkgRec | Out-Null
Copy-Item -Path "${Configuration}/*" -Destination $PkgRec -Recurse -Force
# Legacy layout (for OBS installation directory)
if ( Test-Path "${Configuration}/${ProductName}/bin/64bit" ) {
$PkgLegBin = "Package/legacy/obs-plugins/64bit"
New-Item -ItemType Directory -Force -Path $PkgLegBin | Out-Null
Copy-Item -Path "${Configuration}/${ProductName}/bin/64bit/*" -Destination $PkgLegBin -Recurse -Force
}
if ( Test-Path "${Configuration}/${ProductName}/data" ) {
$PkgLegData = "Package/legacy/data/obs-plugins/${ProductName}"
New-Item -ItemType Directory -Force -Path $PkgLegData | Out-Null
Copy-Item -Path "${Configuration}/${ProductName}/data/*" -Destination $PkgLegData -Recurse -Force
}
Invoke-External iscc ${IsccFile} /O"${ProjectRoot}/release" /F"${OutputName}-Installer" Invoke-External iscc ${IsccFile} /O"${ProjectRoot}/release" /F"${OutputName}-Installer"
Remove-Item -Path Package -Recurse Remove-Item -Path Package -Recurse
Pop-Location -Stack BuildTemp Pop-Location -Stack BuildTemp

View File

@@ -18,7 +18,5 @@ if (( ! ${+commands[brew]} )) {
} }
brew bundle --file ${SCRIPT_HOME}/.Brewfile brew bundle --file ${SCRIPT_HOME}/.Brewfile
# Workaround to make sure locally built openssl is picked up by cmake rehash
brew uninstall --ignore-dependencies openssl@3 || true
rehash || true
log_group log_group

View File

@@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
submodules: "recursive" submodules: "recursive"
- name: check_libobs_revision - name: check_libobs_revision
@@ -50,7 +50,7 @@ jobs:
mv ../*.deb . mv ../*.deb .
- name: Publish - name: Publish
if: success() if: success()
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
with: with:
name: "obs-scene-switcher.deb" name: "obs-scene-switcher.deb"
path: ${{ github.workspace }}/*.deb path: ${{ github.workspace }}/*.deb

View File

@@ -6,7 +6,7 @@ on:
description: "Project name detected by parsing build spec file" description: "Project name detected by parsing build spec file"
value: ${{ jobs.check-event.outputs.pluginName }} value: ${{ jobs.check-event.outputs.pluginName }}
env: env:
DEP_DIR: .deps/advss-build-dependencies-3 DEP_DIR: .deps/advss-build-dependencies-5
jobs: jobs:
check-event: check-event:
name: Check GitHub Event Data 🔎 name: Check GitHub Event Data 🔎
@@ -22,7 +22,7 @@ jobs:
commitHash: ${{ steps.setup.outputs.commitHash }} commitHash: ${{ steps.setup.outputs.commitHash }}
pluginName: ${{ steps.setup.outputs.pluginName }} pluginName: ${{ steps.setup.outputs.pluginName }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check Event Data ☑️ - name: Check Event Data ☑️
@@ -81,7 +81,7 @@ jobs:
run: run:
shell: zsh --no-rcs --errexit --pipefail {0} shell: zsh --no-rcs --errexit --pipefail {0}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
submodules: recursive submodules: recursive
fetch-depth: 0 fetch-depth: 0
@@ -111,7 +111,7 @@ jobs:
sudo xcode-select --switch /Applications/Xcode_16.1.0.app/Contents/Developer sudo xcode-select --switch /Applications/Xcode_16.1.0.app/Contents/Developer
print '::endgroup::' print '::endgroup::'
- uses: actions/cache@v4 - uses: actions/cache@v5
id: ccache-cache id: ccache-cache
with: with:
path: ${{ github.workspace }}/.ccache path: ${{ github.workspace }}/.ccache
@@ -163,13 +163,13 @@ jobs:
codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }} codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
- name: Upload Artifacts 📡 - name: Upload Artifacts 📡
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
with: with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }} name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-macos-universal.* path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-macos-universal.*
- name: Upload Debug Symbol Artifacts 🪲 - name: Upload Debug Symbol Artifacts 🪲
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
if: ${{ needs.check-event.outputs.config == 'Release' }} if: ${{ needs.check-event.outputs.config == 'Release' }}
with: with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs
@@ -183,7 +183,7 @@ jobs:
run: run:
shell: bash shell: bash
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
submodules: recursive submodules: recursive
fetch-depth: 0 fetch-depth: 0
@@ -202,7 +202,7 @@ jobs:
echo "pluginName=${product_name}" >> $GITHUB_OUTPUT echo "pluginName=${product_name}" >> $GITHUB_OUTPUT
echo "pluginVersion=${git_tag}" >> $GITHUB_OUTPUT echo "pluginVersion=${git_tag}" >> $GITHUB_OUTPUT
- uses: actions/cache@v4 - uses: actions/cache@v5
id: ccache-cache id: ccache-cache
with: with:
path: ${{ github.workspace }}/.ccache path: ${{ github.workspace }}/.ccache
@@ -210,13 +210,8 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-ccache-x86_64- ${{ runner.os }}-ccache-x86_64-
- name: Set up CMake 🏗️
uses: jwlawson/actions-setup-cmake@v1.13
with:
cmake-version: '3.x.x'
- name: Set up Homebrew 🍺 - name: Set up Homebrew 🍺
uses: Homebrew/actions/setup-homebrew@master uses: Homebrew/actions/setup-homebrew@main
- name: Build Plugin 🧱 - name: Build Plugin 🧱
uses: ./.github/actions/build-plugin uses: ./.github/actions/build-plugin
@@ -238,23 +233,24 @@ jobs:
config: ${{ needs.check-event.outputs.config }} config: ${{ needs.check-event.outputs.config }}
- name: Upload Source Tarball 🗜️ - name: Upload Source Tarball 🗜️
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
with: with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }} name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }}
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-source.* path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-source.*
- name: Upload Artifacts 📡 - name: Upload Artifacts 📡
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
with: with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-24.04-x86_64-${{ needs.check-event.outputs.commitHash }} name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-24.04-x86_64-${{ needs.check-event.outputs.commitHash }}
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-x86_64*.* path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-x86_64*.*
- name: Upload debug symbol artifacts 🪲 - name: Upload debug symbol artifacts 🪲
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
if: ${{ fromJSON(needs.check-event.outputs.package) }} if: ${{ fromJSON(needs.check-event.outputs.package) }}
with: with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-24.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-24.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-x86_64*-dbgsym.ddeb path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-x86_64*-dbgsym.ddeb
if-no-files-found: ignore
windows-build: windows-build:
name: Build for Windows 🪟 name: Build for Windows 🪟
@@ -264,7 +260,7 @@ jobs:
run: run:
shell: pwsh shell: pwsh
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
submodules: recursive submodules: recursive
fetch-depth: 0 fetch-depth: 0
@@ -311,7 +307,7 @@ jobs:
package: ${{ fromJSON(needs.check-event.outputs.package) }} package: ${{ fromJSON(needs.check-event.outputs.package) }}
- name: Upload Artifacts 📡 - name: Upload Artifacts 📡
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v7
with: with:
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }} name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }}
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-windows-x64*.* path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-windows-x64*.*

View File

@@ -5,7 +5,7 @@ jobs:
clang-format: clang-format:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
- name: clang-format check 🐉 - name: clang-format check 🐉
@@ -17,7 +17,7 @@ jobs:
cmake-format: cmake-format:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
- name: cmake-format check 🎛️ - name: cmake-format check 🎛️

View File

@@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v6
- name: Check locale files - name: Check locale files
run: | run: |

View File

@@ -59,7 +59,7 @@ jobs:
esac esac
- name: Download Build Artifacts 📥 - name: Download Build Artifacts 📥
uses: actions/download-artifact@v4 uses: actions/download-artifact@v8
if: fromJSON(steps.check.outputs.validTag) if: fromJSON(steps.check.outputs.validTag)
id: download id: download
@@ -106,7 +106,7 @@ jobs:
- name: Create Release 🛫 - name: Create Release 🛫
if: fromJSON(steps.check.outputs.validTag) if: fromJSON(steps.check.outputs.validTag)
id: create_release id: create_release
uses: softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda
with: with:
draft: true draft: true
prerelease: ${{ fromJSON(steps.check.outputs.prerelease) }} prerelease: ${{ fromJSON(steps.check.outputs.prerelease) }}

View File

@@ -134,6 +134,9 @@ target_sources(
lib/macro/macro-dock-window.hpp lib/macro/macro-dock-window.hpp
lib/macro/macro-edit.cpp lib/macro/macro-edit.cpp
lib/macro/macro-edit.hpp lib/macro/macro-edit.hpp
lib/macro/macro-export-builtin-extensions.cpp
lib/macro/macro-export-extensions.cpp
lib/macro/macro-export-extensions.hpp
lib/macro/macro-export-import-dialog.cpp lib/macro/macro-export-import-dialog.cpp
lib/macro/macro-export-import-dialog.hpp lib/macro/macro-export-import-dialog.hpp
lib/macro/macro-helpers.cpp lib/macro/macro-helpers.cpp
@@ -504,7 +507,11 @@ endif()
# --- End of section --- # --- End of section ---
add_subdirectory(plugins) add_subdirectory(plugins)
add_subdirectory(tests)
option(ADVSS_ENABLE_TESTS "Build advanced-scene-switcher unit tests" OFF)
if(ADVSS_ENABLE_TESTS)
add_subdirectory(tests)
endif()
# --- Install --- # --- Install ---

View File

@@ -41,7 +41,8 @@
"description": "Build for macOS 11.0+ (Universal binary) for CI", "description": "Build for macOS 11.0+ (Universal binary) for CI",
"generator": "Xcode", "generator": "Xcode",
"cacheVariables": { "cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": true "CMAKE_COMPILE_WARNING_AS_ERROR": true,
"ADVSS_ENABLE_TESTS": true
} }
}, },
{ {
@@ -69,7 +70,8 @@
"displayName": "Windows x64 CI build", "displayName": "Windows x64 CI build",
"description": "Build for Windows x64 on CI", "description": "Build for Windows x64 on CI",
"cacheVariables": { "cacheVariables": {
"CMAKE_COMPILE_WARNING_AS_ERROR": true "CMAKE_COMPILE_WARNING_AS_ERROR": true,
"ADVSS_ENABLE_TESTS": true
} }
}, },
{ {
@@ -97,7 +99,8 @@
"description": "Build for Linux x86_64 on CI", "description": "Build for Linux x86_64 on CI",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo", "CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_COMPILE_WARNING_AS_ERROR": true "CMAKE_COMPILE_WARNING_AS_ERROR": true,
"ADVSS_ENABLE_TESTS": true
} }
}, },
{ {
@@ -125,7 +128,8 @@
"description": "Build for Linux aarch64 on CI", "description": "Build for Linux aarch64 on CI",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo", "CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_COMPILE_WARNING_AS_ERROR": true "CMAKE_COMPILE_WARNING_AS_ERROR": true,
"ADVSS_ENABLE_TESTS": true
} }
} }
], ],

View File

@@ -0,0 +1,23 @@
Advanced Scene Switcher - Windows Installation (Legacy)
========================================================
For full installation instructions visit:
https://github.com/WarmUpTill/SceneSwitcher/wiki/Installation
This archive uses the legacy plugin layout for older OBS versions,
portable OBS installs, and Steam.
Extract the CONTENTS of this archive into your OBS installation directory,
typically:
C:\Program Files\obs-studio\
Merge the data\ and obs-plugins\ folders with the existing ones when prompted.
Steam users: right-click OBS in your library -> Manage -> Browse local files,
then extract the contents of this archive into that directory.
For OBS 28 and newer the recommended archive is preferred:
advanced-scene-switcher-<version>-windows-x64.zip

View File

@@ -0,0 +1,21 @@
Advanced Scene Switcher - Windows Installation
===============================================
For full installation instructions visit:
https://github.com/WarmUpTill/SceneSwitcher/wiki/Installation
This archive uses the recommended plugin layout for OBS 28 and newer.
Extract the CONTENTS of this archive into:
C:\ProgramData\obs-studio\plugins\
Tip: press Win+R and type %ProgramData%\obs-studio\plugins to open that folder.
After extracting, the path should look like:
C:\ProgramData\obs-studio\plugins\advanced-scene-switcher\bin\64bit\advanced-scene-switcher.dll
If the plugin does not appear in OBS, try the legacy archive instead:
advanced-scene-switcher-<version>-windows-x64-legacy.zip

View File

@@ -2,7 +2,7 @@
if(BUILD_OUT_OF_TREE) if(BUILD_OUT_OF_TREE)
if(OS_WINDOWS) if(OS_WINDOWS)
set(OBS_PLUGIN_DESTINATION "obs-plugins/64bit") set(OBS_PLUGIN_DESTINATION "${CMAKE_PROJECT_NAME}/bin/64bit")
else() else()
set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins") set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins")
endif() endif()
@@ -157,7 +157,9 @@ else()
set_target_properties(${target} PROPERTIES INSTALL_RPATH set_target_properties(${target} PROPERTIES INSTALL_RPATH
"$ORIGIN:$ORIGIN/..") "$ORIGIN:$ORIGIN/..")
endif() endif()
message(STATUS "ADVSS: ENABLED PLUGIN ${target}") get_filename_component(_plugin_dir_name "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
set_property(GLOBAL APPEND PROPERTY ADVSS_PLUGINS_ENABLED
${_plugin_dir_name})
endfunction() endfunction()
function(install_advss_plugin_dependency_target target dep) function(install_advss_plugin_dependency_target target dep)

View File

@@ -18,7 +18,9 @@ set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_C_LIBRARY_ARCHITECTURE}" "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_C_LIBRARY_ARCHITECTURE}"
) )
set(CPACK_GENERATOR "DEB") set(CPACK_GENERATOR
"DEB"
CACHE STRING "CPack generator to use")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PLUGIN_EMAIL}") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PLUGIN_EMAIL}")
set(CPACK_SET_DESTDIR ON) set(CPACK_SET_DESTDIR ON)
@@ -46,6 +48,19 @@ set(CPACK_SOURCE_PACKAGE_FILE_NAME
set(CPACK_ARCHIVE_THREADS 0) set(CPACK_ARCHIVE_THREADS 0)
include(CPack) include(CPack)
# CPack.cmake has a side effect that leaves binary packaging variables in the
# state intended for source packaging when it finishes. Specifically it sets
# CPACK_GENERATOR to CPACK_SOURCE_GENERATOR ("TXZ"), sets
# CPACK_INSTALLED_DIRECTORIES to the source root (which would cause CPackDeb to
# scan the entire source tree, including ccache object files that lack a Build
# ID), and clears CPACK_INSTALL_CMAKE_PROJECTS (preventing the cmake install
# mechanism from being used). In some cmake versions these overrides happen
# before CPackConfig.cmake is written. Reset all three so that binary DEB
# packaging works correctly regardless of cmake version.
set(CPACK_GENERATOR "DEB")
set(CPACK_INSTALLED_DIRECTORIES "")
set(CPACK_INSTALL_CMAKE_PROJECTS
"${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
find_package(libobs QUIET) find_package(libobs QUIET)

View File

@@ -6,7 +6,11 @@ include(buildspec_common)
# _check_dependencies_windows: Set up Windows slice for _check_dependencies # _check_dependencies_windows: Set up Windows slice for _check_dependencies
function(_check_dependencies_windows) function(_check_dependencies_windows)
set(arch ${CMAKE_GENERATOR_PLATFORM}) if(CMAKE_GENERATOR_PLATFORM)
set(arch ${CMAKE_GENERATOR_PLATFORM})
else()
set(arch x64)
endif()
set(platform windows-${arch}) set(platform windows-${arch})
set(dependencies_dir "${CMAKE_CURRENT_SOURCE_DIR}/.deps") set(dependencies_dir "${CMAKE_CURRENT_SOURCE_DIR}/.deps")

View File

@@ -6,3 +6,9 @@ include_guard(GLOBAL)
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
include(buildspec) include(buildspec)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"$ENV{ALLUSERSPROFILE}/obs-studio/plugins"
CACHE STRING "Default plugin installation directory" FORCE)
endif()

View File

@@ -30,13 +30,13 @@ function(set_target_properties_plugin target)
install( install(
TARGETS ${target} TARGETS ${target}
RUNTIME DESTINATION bin/64bit RUNTIME DESTINATION "${target}/bin/64bit"
LIBRARY DESTINATION obs-plugins/64bit) LIBRARY DESTINATION "${target}/bin/64bit")
install( install(
FILES "$<TARGET_PDB_FILE:${target}>" FILES "$<TARGET_PDB_FILE:${target}>"
CONFIGURATIONS RelWithDebInfo Debug Release CONFIGURATIONS RelWithDebInfo Debug Release
DESTINATION obs-plugins/64bit DESTINATION "${target}/bin/64bit"
OPTIONAL) OPTIONAL)
if(OBS_BUILD_DIR) if(OBS_BUILD_DIR)
@@ -44,11 +44,11 @@ function(set_target_properties_plugin target)
TARGET ${target} TARGET ${target}
POST_BUILD POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory COMMAND "${CMAKE_COMMAND}" -E make_directory
"${OBS_BUILD_DIR}/obs-plugins/64bit" "${OBS_BUILD_DIR}/plugins/${target}/bin/64bit"
COMMAND COMMAND
"${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${target}>" "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${target}>"
"$<$<CONFIG:Debug,RelWithDebInfo,Release>:$<TARGET_PDB_FILE:${target}>>" "$<$<CONFIG:Debug,RelWithDebInfo,Release>:$<TARGET_PDB_FILE:${target}>>"
"${OBS_BUILD_DIR}/obs-plugins/64bit" "${OBS_BUILD_DIR}/plugins/${target}/bin/64bit"
COMMENT "Copy ${target} to obs-studio directory ${OBS_BUILD_DIR}" COMMENT "Copy ${target} to obs-studio directory ${OBS_BUILD_DIR}"
VERBATIM) VERBATIM)
endif() endif()
@@ -105,7 +105,7 @@ function(target_install_resources target)
install( install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/"
DESTINATION data/obs-plugins/${target} DESTINATION "${target}/data"
USE_SOURCE_PERMISSIONS) USE_SOURCE_PERMISSIONS)
if(OBS_BUILD_DIR) if(OBS_BUILD_DIR)
@@ -113,11 +113,11 @@ function(target_install_resources target)
TARGET ${target} TARGET ${target}
POST_BUILD POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory COMMAND "${CMAKE_COMMAND}" -E make_directory
"${OBS_BUILD_DIR}/data/obs-plugins/${target}" "${OBS_BUILD_DIR}/plugins/${target}/data"
COMMAND COMMAND
"${CMAKE_COMMAND}" -E copy_directory "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/data" "${CMAKE_CURRENT_SOURCE_DIR}/data"
"${OBS_BUILD_DIR}/data/obs-plugins/${target}" "${OBS_BUILD_DIR}/plugins/${target}/data"
COMMENT "Copy ${target} resources to data directory" COMMENT "Copy ${target} resources to data directory"
VERBATIM) VERBATIM)
endif() endif()
@@ -133,7 +133,7 @@ function(target_add_resource target resource)
install( install(
FILES "${resource}" FILES "${resource}"
DESTINATION data/obs-plugins/${target} DESTINATION "${target}/data"
COMPONENT Runtime) COMPONENT Runtime)
if(OBS_BUILD_DIR) if(OBS_BUILD_DIR)
@@ -141,9 +141,9 @@ function(target_add_resource target resource)
TARGET ${target} TARGET ${target}
POST_BUILD POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory COMMAND "${CMAKE_COMMAND}" -E make_directory
"${OBS_BUILD_DIR}/data/obs-plugins/${target}" "${OBS_BUILD_DIR}/plugins/${target}/data"
COMMAND "${CMAKE_COMMAND}" -E copy "${resource}" COMMAND "${CMAKE_COMMAND}" -E copy "${resource}"
"${OBS_BUILD_DIR}/data/obs-plugins/${target}" "${OBS_BUILD_DIR}/plugins/${target}/data"
COMMENT "Copy ${target} resource ${resource} to library directory" COMMENT "Copy ${target} resource ${resource} to library directory"
VERBATIM) VERBATIM)
endif() endif()

View File

@@ -2,12 +2,13 @@
#define MyAppVersion "@CMAKE_PROJECT_VERSION@" #define MyAppVersion "@CMAKE_PROJECT_VERSION@"
#define MyAppPublisher "@PLUGIN_AUTHOR@" #define MyAppPublisher "@PLUGIN_AUTHOR@"
#define MyAppURL "@PLUGIN_WEBSITE@" #define MyAppURL "@PLUGIN_WEBSITE@"
#define MyAppId "@UUID_APP@"
[Setup] [Setup]
; NOTE: The value of AppId uniquely identifies this application. ; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications. ; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{@UUID_APP@} AppId={{{#MyAppId}}
AppName={#MyAppName} AppName={#MyAppName}
AppVersion={#MyAppVersion} AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher} AppPublisher={#MyAppPublisher}
@@ -20,15 +21,19 @@ OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows-Installer
Compression=lzma Compression=lzma
SolidCompression=yes SolidCompression=yes
DirExistsWarning=no DirExistsWarning=no
UsePreviousAppDir=no
SetupIconFile=installer.ico SetupIconFile=installer.ico
UninstallDisplayIcon={app}\data\obs-plugins\advanced-scene-switcher\res\images\logo.ico UninstallDisplayIcon={code:GetUninstallIconPath}
DisableDirPage=no DisableDirPage=no
[Languages] [Languages]
Name: "english"; MessagesFile: "compiler:Default.isl" Name: "english"; MessagesFile: "compiler:Default.isl"
[Files] [Files]
Source: "..\release\Package\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ; Recommended layout - used when installing to %ProgramData%\obs-studio\plugins\
Source: "..\release\Package\recommended\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: IsRecommendedLayout
; Legacy layout - used when installing to the OBS installation directory
Source: "..\release\Package\legacy\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check: IsLegacyLayout
Source: "..\LICENSE"; Flags: dontcopy Source: "..\LICENSE"; Flags: dontcopy
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
@@ -51,17 +56,64 @@ begin
); );
end; end;
// credit where it's due : // Returns true when the selected install directory is under %ProgramData%,
// following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45 // meaning the recommended plugin layout should be used.
function GetDirName(Value: string): string; function IsRecommendedLayout(): Boolean;
var
InstallPath: string;
begin begin
// initialize default path, which will be returned when the following registry Result := Pos(LowerCase(ExpandConstant('{commonappdata}')),
// key queries fail due to missing keys or for some different reason LowerCase(WizardDirValue())) = 1;
Result := '{autopf}\obs-studio';
// query the first registry value; if this succeeds, return the obtained value
if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then
Result := InstallPath
end; end;
function IsLegacyLayout(): Boolean;
begin
Result := not IsRecommendedLayout();
end;
function GetUninstallIconPath(Param: string): string;
begin
if IsRecommendedLayout() then
Result := ExpandConstant('{app}\advanced-scene-switcher\data\res\images\logo.ico')
else
Result := ExpandConstant('{app}\data\obs-plugins\advanced-scene-switcher\res\images\logo.ico');
end;
function GetDirName(Value: string): string;
var
PrevPath: string;
UninstallKey: string;
begin
Result := ExpandConstant('{commonappdata}\obs-studio\plugins');
UninstallKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + '{' + '{#MyAppId}' + '}_is1';
if RegQueryStringValue(HKLM, UninstallKey, 'InstallLocation', PrevPath) and (PrevPath <> '') then
Result := PrevPath;
end;
// Remove files placed by the legacy installer (obs-plugins/64bit and
// data/obs-plugins layout) so the plugin is not loaded twice by OBS.
// Only runs when upgrading from a legacy location to the recommended one.
procedure RemoveLegacyFiles();
var
OldInstallPath: string;
UninstallKey: string;
begin
if not IsRecommendedLayout() then
Exit;
UninstallKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + '{' + '{#MyAppId}' + '}_is1';
if not RegQueryStringValue(HKLM, UninstallKey, 'InstallLocation', OldInstallPath) then
Exit;
// Skip if the previous install was already in the recommended location
if Pos(LowerCase(ExpandConstant('{commonappdata}')), LowerCase(OldInstallPath)) = 1 then
Exit;
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher.dll');
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher.pdb');
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-lib.dll');
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-lib.pdb');
DelTree(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-plugins', True, True, True);
DelTree(OldInstallPath + '\data\obs-plugins\advanced-scene-switcher', True, True, True);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
RemoveLegacyFiles();
end;

View File

@@ -99,7 +99,6 @@ AdvSceneSwitcher.macroList.deleted="gelöscht"
AdvSceneSwitcher.macroList.duplicate="\"%1\" ist bereits ausgewählt!" AdvSceneSwitcher.macroList.duplicate="\"%1\" ist bereits ausgewählt!"
; Macro Logic ; Macro Logic
AdvSceneSwitcher.logic.none="Eintrag ignorieren"
AdvSceneSwitcher.logic.and="Und" AdvSceneSwitcher.logic.and="Und"
AdvSceneSwitcher.logic.or="Oder" AdvSceneSwitcher.logic.or="Oder"
AdvSceneSwitcher.logic.andNot="Und nicht" AdvSceneSwitcher.logic.andNot="Und nicht"
@@ -211,8 +210,8 @@ AdvSceneSwitcher.condition.record.state.start="Aufnahme läuft"
AdvSceneSwitcher.condition.record.state.pause="Aufnahme pausiert" AdvSceneSwitcher.condition.record.state.pause="Aufnahme pausiert"
AdvSceneSwitcher.condition.record.state.stop="Aufnahme gestoppt" AdvSceneSwitcher.condition.record.state.stop="Aufnahme gestoppt"
AdvSceneSwitcher.condition.process="Prozess" AdvSceneSwitcher.condition.process="Prozess"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}läuft{{focused}}und ist fokusiert" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}läuft{{focused}}und ist fokusiert"
AdvSceneSwitcher.condition.process.entry.focus="Aktueller Vordergrundprozess: {{focusProcess}}" AdvSceneSwitcher.condition.process.layout.focus="Aktueller Vordergrundprozess: {{focusProcess}}"
AdvSceneSwitcher.condition.idle="Leerlauf" AdvSceneSwitcher.condition.idle="Leerlauf"
AdvSceneSwitcher.condition.idle.entry="Keine Tastatur- oder Mauseingaben für {{duration}}" AdvSceneSwitcher.condition.idle.entry="Keine Tastatur- oder Mauseingaben für {{duration}}"
AdvSceneSwitcher.condition.pluginState="Plugin-Status" AdvSceneSwitcher.condition.pluginState="Plugin-Status"
@@ -416,7 +415,6 @@ AdvSceneSwitcher.action.replay.type.save="Replay Buffer speichern"
AdvSceneSwitcher.action.streaming="Stream" AdvSceneSwitcher.action.streaming="Stream"
AdvSceneSwitcher.action.streaming.type.stop="Stream stoppen" AdvSceneSwitcher.action.streaming.type.stop="Stream stoppen"
AdvSceneSwitcher.action.streaming.type.start="Stream starten" AdvSceneSwitcher.action.streaming.type.start="Stream starten"
AdvSceneSwitcher.action.streaming.entry="{{actions}}{{keyFrameInterval}}{{stringValue}}{{showPassword}}"
AdvSceneSwitcher.action.run="Ausführen" AdvSceneSwitcher.action.run="Ausführen"
AdvSceneSwitcher.action.sceneVisibility="Sichtbarkeit von Szenenelementen" AdvSceneSwitcher.action.sceneVisibility="Sichtbarkeit von Szenenelementen"
AdvSceneSwitcher.action.sceneVisibility.type.show="Anzeigen" AdvSceneSwitcher.action.sceneVisibility.type.show="Anzeigen"
@@ -452,7 +450,7 @@ AdvSceneSwitcher.action.macro="Makro"
AdvSceneSwitcher.action.macro.type.pause="Pausieren" AdvSceneSwitcher.action.macro.type.pause="Pausieren"
AdvSceneSwitcher.action.macro.type.unpause="Nicht mehr pausieren" AdvSceneSwitcher.action.macro.type.unpause="Nicht mehr pausieren"
AdvSceneSwitcher.action.macro.type.resetCounter="Zähler zurücksetzen" AdvSceneSwitcher.action.macro.type.resetCounter="Zähler zurücksetzen"
AdvSceneSwitcher.action.macro.type.run="Aktionen ausführen" AdvSceneSwitcher.action.macro.type.runActions="Aktionen ausführen"
AdvSceneSwitcher.action.macro.type.stop="Aktionen stoppen" AdvSceneSwitcher.action.macro.type.stop="Aktionen stoppen"
AdvSceneSwitcher.action.pluginState="Plugin-Status" AdvSceneSwitcher.action.pluginState="Plugin-Status"
AdvSceneSwitcher.action.pluginState.type.stop="Erweiterten Automatischen Szenenwechsler stoppen" AdvSceneSwitcher.action.pluginState.type.stop="Erweiterten Automatischen Szenenwechsler stoppen"

View File

@@ -47,6 +47,13 @@ AdvSceneSwitcher.generalTab.generalBehavior.hideLegacyTabs="Hide tabs which can
AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowMacroSearch="Always show macro search" AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowMacroSearch="Always show macro search"
AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs="Always show all feature tabs" AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs="Always show all feature tabs"
AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs.tooltip="Show tabs that are normally hidden until first used in a macro (e.g. Action Queues, Variables, Twitch, Websockets)." AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs.tooltip="Show tabs that are normally hidden until first used in a macro (e.g. Action Queues, Variables, Twitch, Websockets)."
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock="Lock settings dialog with password"
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title="Settings Locked"
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.passwordLabel="Enter password:"
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.wrongPassword="Wrong password!"
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.newPasswordLabel="New password:"
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.confirmPasswordLabel="Confirm password:"
AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.passwordMismatch="Passwords do not match!"
AdvSceneSwitcher.generalTab.matchBehavior="Match behavior" AdvSceneSwitcher.generalTab.matchBehavior="Match behavior"
AdvSceneSwitcher.generalTab.priority="Priority" AdvSceneSwitcher.generalTab.priority="Priority"
AdvSceneSwitcher.generalTab.priority.description="Switching methods priority (Highest priority is at the top)" AdvSceneSwitcher.generalTab.priority.description="Switching methods priority (Highest priority is at the top)"
@@ -202,6 +209,13 @@ AdvSceneSwitcher.macroTab.remove="Remove"
AdvSceneSwitcher.macroTab.export="Export" AdvSceneSwitcher.macroTab.export="Export"
AdvSceneSwitcher.macroTab.export.info="Paste the string below into the import dialog to import the selected macros:" AdvSceneSwitcher.macroTab.export.info="Paste the string below into the import dialog to import the selected macros:"
AdvSceneSwitcher.macroTab.export.usePlainText="Use plain text" AdvSceneSwitcher.macroTab.export.usePlainText="Use plain text"
AdvSceneSwitcher.macroTab.export.additionalContent="Export Additional Content"
AdvSceneSwitcher.macroTab.export.variables="Variables"
AdvSceneSwitcher.macroTab.export.actionQueues="Action Queues"
AdvSceneSwitcher.macroTab.export.httpServers="HTTP Servers"
AdvSceneSwitcher.macroTab.export.macroScheduleEntries="Macro Schedule"
AdvSceneSwitcher.macroTab.export.twitchConnections="Twitch Connections"
AdvSceneSwitcher.macroTab.export.websocketConnections="Websocket Connections"
AdvSceneSwitcher.macroTab.import="Import" AdvSceneSwitcher.macroTab.import="Import"
AdvSceneSwitcher.macroTab.import.info="Paste the export string into the below text box to import macros:" AdvSceneSwitcher.macroTab.import.info="Paste the export string into the below text box to import macros:"
AdvSceneSwitcher.macroTab.import.invalid="Invalid import data provided!" AdvSceneSwitcher.macroTab.import.invalid="Invalid import data provided!"
@@ -306,7 +320,6 @@ AdvSceneSwitcher.macroList.deleted="deleted"
AdvSceneSwitcher.macroList.duplicate="\"%1\" is alreay selected!" AdvSceneSwitcher.macroList.duplicate="\"%1\" is alreay selected!"
# Macro Logic # Macro Logic
AdvSceneSwitcher.logic.none="Ignore entry"
AdvSceneSwitcher.logic.and="And" AdvSceneSwitcher.logic.and="And"
AdvSceneSwitcher.logic.or="Or" AdvSceneSwitcher.logic.or="Or"
AdvSceneSwitcher.logic.andNot="And not" AdvSceneSwitcher.logic.andNot="And not"
@@ -484,8 +497,9 @@ AdvSceneSwitcher.condition.record.state.stop="Recording stopped"
AdvSceneSwitcher.condition.record.state.duration="Recording duration is longer than" AdvSceneSwitcher.condition.record.state.duration="Recording duration is longer than"
AdvSceneSwitcher.condition.record.entry="{{condition}}{{duration}}" AdvSceneSwitcher.condition.record.entry="{{condition}}{{duration}}"
AdvSceneSwitcher.condition.process="Process" AdvSceneSwitcher.condition.process="Process"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}is running{{focused}}and is focused" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}is running{{focused}}and is focused"
AdvSceneSwitcher.condition.process.entry.focus="Current foreground process:{{focusProcess}}" AdvSceneSwitcher.condition.process.layout.focus="Current foreground process:{{focusProcess}}"
AdvSceneSwitcher.condition.process.layout.path="{{checkPath}}Match binary path:{{path}}{{pathRegex}}"
AdvSceneSwitcher.condition.idle="Idle" AdvSceneSwitcher.condition.idle="Idle"
AdvSceneSwitcher.condition.idle.entry="No keyboard or mouse inputs for{{duration}}" AdvSceneSwitcher.condition.idle.entry="No keyboard or mouse inputs for{{duration}}"
AdvSceneSwitcher.condition.pluginState="Plugin state" AdvSceneSwitcher.condition.pluginState="Plugin state"
@@ -855,6 +869,7 @@ AdvSceneSwitcher.condition.streamDeck.stopListen="Stop listening"
AdvSceneSwitcher.condition.streamDeck.pluginDownload="<html><head/><body><p>The Stream Deck plugin can be found <a href=\"https://github.com/WarmUpTill/advanced-scene-switcher-streamdeck-plugin/releases\"><span style=\" text-decoration: underline; color:#268bd2;\">here on GitHub</span></a>.</p></body></html>" AdvSceneSwitcher.condition.streamDeck.pluginDownload="<html><head/><body><p>The Stream Deck plugin can be found <a href=\"https://github.com/WarmUpTill/advanced-scene-switcher-streamdeck-plugin/releases\"><span style=\" text-decoration: underline; color:#268bd2;\">here on GitHub</span></a>.</p></body></html>"
AdvSceneSwitcher.condition.gameCapture="Game capture" AdvSceneSwitcher.condition.gameCapture="Game capture"
AdvSceneSwitcher.condition.gameCapture.entry="{{sources}}hooked a game." AdvSceneSwitcher.condition.gameCapture.entry="{{sources}}hooked a game."
AdvSceneSwitcher.condition.screenshot="Screenshot" AdvSceneSwitcher.condition.screenshot="Screenshot"
AdvSceneSwitcher.condition.screenshot.entry="A screenshot was taken" AdvSceneSwitcher.condition.screenshot.entry="A screenshot was taken"
AdvSceneSwitcher.condition.mqtt="MQTT" AdvSceneSwitcher.condition.mqtt="MQTT"
@@ -941,7 +956,8 @@ AdvSceneSwitcher.action.streaming.type.server="Set server URL"
AdvSceneSwitcher.action.streaming.type.streamKey="Set stream key" AdvSceneSwitcher.action.streaming.type.streamKey="Set stream key"
AdvSceneSwitcher.action.streaming.type.username="Set username" AdvSceneSwitcher.action.streaming.type.username="Set username"
AdvSceneSwitcher.action.streaming.type.password="Set password" AdvSceneSwitcher.action.streaming.type.password="Set password"
AdvSceneSwitcher.action.streaming.entry="{{actions}}{{keyFrameInterval}}{{stringValue}}{{showPassword}}" AdvSceneSwitcher.action.streaming.getCurrentValue="Get current value"
AdvSceneSwitcher.action.streaming.layout="{{actions}}{{keyFrameInterval}}{{stringValue}}{{showPassword}}{{getCurrentValue}}"
AdvSceneSwitcher.action.run="Run" AdvSceneSwitcher.action.run="Run"
AdvSceneSwitcher.action.run.wait.entry="{{wait}}Wait for process exit or at most {{timeout}}{{waitHelp}}" AdvSceneSwitcher.action.run.wait.entry="{{wait}}Wait for process exit or at most {{timeout}}{{waitHelp}}"
AdvSceneSwitcher.action.run.wait.help.tooltip="Note that macro properties won't work if you leave this unticked, as the process spawns detached from the rest of logic and there's no control over it." AdvSceneSwitcher.action.run.wait.help.tooltip="Note that macro properties won't work if you leave this unticked, as the process spawns detached from the rest of logic and there's no control over it."
@@ -1070,12 +1086,12 @@ AdvSceneSwitcher.action.macro.type.pause="Pause"
AdvSceneSwitcher.action.macro.type.unpause="Unpause" AdvSceneSwitcher.action.macro.type.unpause="Unpause"
AdvSceneSwitcher.action.macro.type.togglePause="Toggle pause" AdvSceneSwitcher.action.macro.type.togglePause="Toggle pause"
AdvSceneSwitcher.action.macro.type.resetCounter="Reset counter" AdvSceneSwitcher.action.macro.type.resetCounter="Reset counter"
AdvSceneSwitcher.action.macro.type.run="Run macro" AdvSceneSwitcher.action.macro.type.runActions="Run macro actions"
AdvSceneSwitcher.action.macro.type.run.conditions.ignore="Do not consider condition state" AdvSceneSwitcher.action.macro.type.run.conditions.ignore="Do not consider condition state"
AdvSceneSwitcher.action.macro.type.run.conditions.true="Only if conditions evaluate to true" AdvSceneSwitcher.action.macro.type.run.conditions.true="Only if conditions evaluate to true"
AdvSceneSwitcher.action.macro.type.run.conditions.false="Only if conditions evaluate to false" AdvSceneSwitcher.action.macro.type.run.conditions.false="Only if conditions evaluate to false"
AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState="Reevaluate the condition state before executing this action" AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState="Check conditions now, even if macro is paused"
AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState.help="The plugin operates in phases:\n * The phase evaluating the macro conditions\n * The phase running macro actions\nMacros executed before this particular action might have side effects on the condition state of macros.\nCheck this option if you want those side effects to be taken into account when evaluating the condition state." AdvSceneSwitcher.action.macro.type.run.updateConditionMatchState.help="The plugin operates in phases:\n * The phase evaluating the macro conditions\n * The phase running macro actions\nMacros executed before this particular action might have side effects on the condition state of macros.\nAdditionally, paused macros are assumed to not match their conditions.\nCheck this option to force a fresh condition evaluation before running this action, regardless of whether the macro is paused."
AdvSceneSwitcher.action.macro.type.run.actionType.regular="actions" AdvSceneSwitcher.action.macro.type.run.actionType.regular="actions"
AdvSceneSwitcher.action.macro.type.run.actionType.else="else-actions" AdvSceneSwitcher.action.macro.type.run.actionType.else="else-actions"
AdvSceneSwitcher.action.macro.type.run.skipWhenPaused="Skip execution when macro is paused" AdvSceneSwitcher.action.macro.type.run.skipWhenPaused="Skip execution when macro is paused"
@@ -1086,6 +1102,9 @@ AdvSceneSwitcher.action.macro.type.disableAction="Disable action"
AdvSceneSwitcher.action.macro.type.enableAction="Enable action" AdvSceneSwitcher.action.macro.type.enableAction="Enable action"
AdvSceneSwitcher.action.macro.type.toggleAction="Toggle action" AdvSceneSwitcher.action.macro.type.toggleAction="Toggle action"
AdvSceneSwitcher.action.macro.type.getInfo="Get macro info" AdvSceneSwitcher.action.macro.type.getInfo="Get macro info"
AdvSceneSwitcher.action.macro.type.runMacro="Run macro"
AdvSceneSwitcher.action.macro.type.runMacro.noConditionsWarning="Warning: The selected macro has no conditions!"
AdvSceneSwitcher.action.macro.type.runMacro.help="Unlike \"Run macro actions\", this option will immediately re-evaluate the conditions of the selected macro and then run either its actions or else-actions depending on the result."
AdvSceneSwitcher.action.macro.type.nestedMacro="Nested macro" AdvSceneSwitcher.action.macro.type.nestedMacro="Nested macro"
AdvSceneSwitcher.action.macro.actionSelectionType.index="at index" AdvSceneSwitcher.action.macro.actionSelectionType.index="at index"
AdvSceneSwitcher.action.macro.actionSelectionType.label="with label" AdvSceneSwitcher.action.macro.actionSelectionType.label="with label"
@@ -1096,6 +1115,7 @@ AdvSceneSwitcher.action.macro.type.nestedMacro.elseActionHelp="This section allo
AdvSceneSwitcher.action.macro.layout.run="{{actions}}{{actionSections}}of{{macros}}" AdvSceneSwitcher.action.macro.layout.run="{{actions}}{{actionSections}}of{{macros}}"
AdvSceneSwitcher.action.macro.layout.run.condition="{{conditionBehaviors}}of{{conditionMacros}}" AdvSceneSwitcher.action.macro.layout.run.condition="{{conditionBehaviors}}of{{conditionMacros}}"
AdvSceneSwitcher.action.macro.layout.actionState="{{actions}}{{actionSelectionType}}{{actionIndex}}{{label}}{{regex}}{{actionTypes}}in{{actionSections}}section of{{macros}}" AdvSceneSwitcher.action.macro.layout.actionState="{{actions}}{{actionSelectionType}}{{actionIndex}}{{label}}{{regex}}{{actionTypes}}in{{actionSections}}section of{{macros}}"
AdvSceneSwitcher.action.macro.layout.runMacro="{{actions}}{{runMacroHelp}}{{macros}}"
AdvSceneSwitcher.action.macro.layout.other="{{actions}}{{macros}}" AdvSceneSwitcher.action.macro.layout.other="{{actions}}{{macros}}"
AdvSceneSwitcher.action.pluginState="Plugin state" AdvSceneSwitcher.action.pluginState="Plugin state"
AdvSceneSwitcher.action.pluginState.type.stop="Stop the Advanced Scene Switcher plugin" AdvSceneSwitcher.action.pluginState.type.stop="Stop the Advanced Scene Switcher plugin"
@@ -1789,6 +1809,10 @@ AdvSceneSwitcher.script.file.layout="Script file:{{path}}{{open}}"
AdvSceneSwitcher.tempVar.select="--select value--" AdvSceneSwitcher.tempVar.select="--select value--"
AdvSceneSwitcher.tempVar.selectionInfo.lastValues="Last values:" AdvSceneSwitcher.tempVar.selectionInfo.lastValues="Last values:"
AdvSceneSwitcher.tempVar.outputMappings="Save outputs to variables:"
AdvSceneSwitcher.tempVar.outputMappings.add="+ Add output mapping"
AdvSceneSwitcher.tempVar.outputMappings.toggle="Assign outputs to variables"
AdvSceneSwitcher.tempVar.outputMappings.remove="Remove output mapping"
AdvSceneSwitcher.tempVar.twitch.broadcaster_user_id="Twitch broadcaster user ID" AdvSceneSwitcher.tempVar.twitch.broadcaster_user_id="Twitch broadcaster user ID"
AdvSceneSwitcher.tempVar.twitch.broadcaster_user_id.description="The numerical Twitch user ID of the broadcaster." AdvSceneSwitcher.tempVar.twitch.broadcaster_user_id.description="The numerical Twitch user ID of the broadcaster."
@@ -2270,6 +2294,14 @@ AdvSceneSwitcher.tempVar.scene.position="Position in scenes list"
AdvSceneSwitcher.tempVar.window.window="Window title" AdvSceneSwitcher.tempVar.window.window="Window title"
AdvSceneSwitcher.tempVar.window.window.description="The window title of the matching window." AdvSceneSwitcher.tempVar.window.window.description="The window title of the matching window."
AdvSceneSwitcher.tempVar.window.windowX="Window X position"
AdvSceneSwitcher.tempVar.window.windowX.description="The X position (left edge) of the matching window in screen coordinates."
AdvSceneSwitcher.tempVar.window.windowY="Window Y position"
AdvSceneSwitcher.tempVar.window.windowY.description="The Y position (top edge) of the matching window in screen coordinates."
AdvSceneSwitcher.tempVar.window.windowWidth="Window width"
AdvSceneSwitcher.tempVar.window.windowWidth.description="The width of the matching window in pixels."
AdvSceneSwitcher.tempVar.window.windowHeight="Window height"
AdvSceneSwitcher.tempVar.window.windowHeight.description="The height of the matching window in pixels."
AdvSceneSwitcher.tempVar.window.windowClass="Window class" AdvSceneSwitcher.tempVar.window.windowClass="Window class"
AdvSceneSwitcher.tempVar.window.windowClass.description="The window class of the matching window." AdvSceneSwitcher.tempVar.window.windowClass.description="The window class of the matching window."
AdvSceneSwitcher.tempVar.window.windowText="Window text" AdvSceneSwitcher.tempVar.window.windowText="Window text"
@@ -2312,6 +2344,7 @@ AdvSceneSwitcher.tempVar.macro.info.secondsSinceLastRun="Seconds since last run"
AdvSceneSwitcher.tempVar.macro.info.secondsSinceLastRun.description="The number of seconds elapsed since the macro was last executed. Value is -1 if the macro has never been executed." AdvSceneSwitcher.tempVar.macro.info.secondsSinceLastRun.description="The number of seconds elapsed since the macro was last executed. Value is -1 if the macro has never been executed."
AdvSceneSwitcher.tempVar.process.name="Process name" AdvSceneSwitcher.tempVar.process.name="Process name"
AdvSceneSwitcher.tempVar.process.path="Process path"
AdvSceneSwitcher.tempVar.run.process.id="Process ID" AdvSceneSwitcher.tempVar.run.process.id="Process ID"
AdvSceneSwitcher.tempVar.run.process.id.description="PID of the process assigned by the system." AdvSceneSwitcher.tempVar.run.process.id.description="PID of the process assigned by the system."
@@ -2334,6 +2367,14 @@ AdvSceneSwitcher.tempVar.video.similarity="Similarity Rating"
AdvSceneSwitcher.tempVar.video.similarity.description="Values range from 0 to 1, where 0 means dissimilar and 1 means highly similar." AdvSceneSwitcher.tempVar.video.similarity.description="Values range from 0 to 1, where 0 means dissimilar and 1 means highly similar."
AdvSceneSwitcher.tempVar.video.patternCount="Pattern count" AdvSceneSwitcher.tempVar.video.patternCount="Pattern count"
AdvSceneSwitcher.tempVar.video.patternCount.description="The number of times the given pattern has been found in a given video input frame." AdvSceneSwitcher.tempVar.video.patternCount.description="The number of times the given pattern has been found in a given video input frame."
AdvSceneSwitcher.tempVar.video.matchX="Match X coordinate"
AdvSceneSwitcher.tempVar.video.matchX.description="The X coordinate of the top-left corner of the best pattern match.\nIf the 'check area' option is enabled, the coordinate is relative to the video source, not the area.\nSet to -1 if no match was found."
AdvSceneSwitcher.tempVar.video.matchY="Match Y coordinate"
AdvSceneSwitcher.tempVar.video.matchY.description="The Y coordinate of the top-left corner of the best pattern match.\nIf the 'check area' option is enabled, the coordinate is relative to the video source, not the area.\nSet to -1 if no match was found."
AdvSceneSwitcher.tempVar.video.matchWidth="Match width"
AdvSceneSwitcher.tempVar.video.matchWidth.description="The width of the matched pattern in pixels."
AdvSceneSwitcher.tempVar.video.matchHeight="Match height"
AdvSceneSwitcher.tempVar.video.matchHeight.description="The height of the matched pattern in pixels."
AdvSceneSwitcher.tempVar.video.objectCount="Object count" AdvSceneSwitcher.tempVar.video.objectCount="Object count"
AdvSceneSwitcher.tempVar.video.objectCount.description="The number of objects the given model has identified in a given video input frame." AdvSceneSwitcher.tempVar.video.objectCount.description="The number of objects the given model has identified in a given video input frame."
AdvSceneSwitcher.tempVar.video.brightness="Average brightness" AdvSceneSwitcher.tempVar.video.brightness="Average brightness"
@@ -2527,6 +2568,9 @@ AdvSceneSwitcher.selectDisplay="--select display--"
AdvSceneSwitcher.invaildEntriesWillNotBeSaved="invalid entries will not be saved" AdvSceneSwitcher.invaildEntriesWillNotBeSaved="invalid entries will not be saved"
AdvSceneSwitcher.selectWindowTip="Use \"OBS\" to specify OBS window\nUse \"Task Switching\"to specify ALT + TAB" AdvSceneSwitcher.selectWindowTip="Use \"OBS\" to specify OBS window\nUse \"Task Switching\"to specify ALT + TAB"
AdvSceneSwitcher.keepSourceActive="Keep source active"
AdvSceneSwitcher.keepSourceActive.help="When a source is not visible in the active scene it becomes inactive, which can cause it to stop producing output (e.g. video frames or game capture hooks).\nEnabling this option forces the source to remain active at all times, ensuring it continues to produce output even when not displayed.\n\nNote: Keeping a source permanently active may increase CPU and GPU usage, as the source continues to run even when not shown."
AdvSceneSwitcher.settings.suffix.type.invalid=" (Invalid)" AdvSceneSwitcher.settings.suffix.type.invalid=" (Invalid)"
AdvSceneSwitcher.settings.suffix.type.bool=" (Bool)" AdvSceneSwitcher.settings.suffix.type.bool=" (Bool)"
AdvSceneSwitcher.settings.suffix.type.int=" (Int)" AdvSceneSwitcher.settings.suffix.type.int=" (Int)"
@@ -2694,6 +2738,64 @@ Basic.Settings.Video.FPSCommon="Common FPS Values"
Basic.Settings.Video.FPSInteger="Integer FPS Value" Basic.Settings.Video.FPSInteger="Integer FPS Value"
Basic.Settings.Video.FPSFraction="Fractional FPS Value" Basic.Settings.Video.FPSFraction="Fractional FPS Value"
# Calendar widget
AdvSceneSwitcher.calendar.today="Today"
AdvSceneSwitcher.calendar.month="Month"
AdvSceneSwitcher.calendar.week="Week"
AdvSceneSwitcher.calendar.day="Day"
AdvSceneSwitcher.calendar.moreEvents="+%1 more"
# Macro Schedule tab
AdvSceneSwitcher.macroScheduleTab.title="Macro Schedule"
AdvSceneSwitcher.macroScheduleTab.help="No scheduled entries.\nClick '+' to schedule a macro."
AdvSceneSwitcher.macroScheduleTab.add="Add"
AdvSceneSwitcher.macroScheduleTab.add.tooltip="Add schedule entry"
AdvSceneSwitcher.macroScheduleTab.edit="Edit"
AdvSceneSwitcher.macroScheduleTab.remove="Remove"
AdvSceneSwitcher.macroScheduleTab.remove.tooltip="Remove schedule entry"
AdvSceneSwitcher.macroScheduleTab.enable="Enable"
AdvSceneSwitcher.macroScheduleTab.disable="Disable"
AdvSceneSwitcher.macroScheduleTab.showAll="Show All"
AdvSceneSwitcher.macroScheduleTab.column.name="Name"
AdvSceneSwitcher.macroScheduleTab.column.macro="Macro"
AdvSceneSwitcher.macroScheduleTab.column.schedule="Schedule"
AdvSceneSwitcher.macroScheduleTab.column.nextTrigger="Next Trigger"
AdvSceneSwitcher.macroScheduleTab.column.status="Status"
AdvSceneSwitcher.macroScheduleTab.remove.confirm="Are you sure you want to remove \"%1\"?"
AdvSceneSwitcher.macroScheduleTab.remove.confirmMultiple="Are you sure you want to remove %1 entries?"
AdvSceneSwitcher.macroScheduleTab.status.active="Active"
AdvSceneSwitcher.macroScheduleTab.status.disabled="Disabled"
AdvSceneSwitcher.macroScheduleTab.status.expired="Expired"
# Macro Schedule entry dialog
AdvSceneSwitcher.macroScheduleEntry.dialog.title.add="Add Schedule Entry"
AdvSceneSwitcher.macroScheduleEntry.dialog.title.edit="Edit Schedule Entry"
AdvSceneSwitcher.macroScheduleEntry.name="Name (optional):"
AdvSceneSwitcher.macroScheduleEntry.name.placeholder="e.g. Daily stream start"
AdvSceneSwitcher.macroScheduleEntry.macro="Macro:"
AdvSceneSwitcher.macroScheduleEntry.startDateTime="Start:"
AdvSceneSwitcher.macroScheduleEntry.endDate="End date:"
AdvSceneSwitcher.macroScheduleEntry.endDate.help="Controls how far the entry spans visually in the calendar and optionally triggers an action when the date is reached."
AdvSceneSwitcher.macroScheduleEntry.endDate.action.none="No action"
AdvSceneSwitcher.macroScheduleEntry.endDate.action.disableEntry="Disable schedule entry"
AdvSceneSwitcher.macroScheduleEntry.endDate.action.pauseMacro="Pause macro"
AdvSceneSwitcher.macroScheduleEntry.endDate.action.stopMacro="Stop macro"
AdvSceneSwitcher.macroScheduleEntry.repeat="Repeat"
AdvSceneSwitcher.macroScheduleEntry.repeat.once="Once"
AdvSceneSwitcher.macroScheduleEntry.repeat.every="Every %1"
AdvSceneSwitcher.macroScheduleEntry.repeat.interval="Repeat interval:"
AdvSceneSwitcher.macroScheduleEntry.noMacro="(no macro)"
AdvSceneSwitcher.macroScheduleEntry.repeatEnd="End repeat:"
AdvSceneSwitcher.macroScheduleEntry.repeatEnd.never="Never"
AdvSceneSwitcher.macroScheduleEntry.repeatEnd.afterNTimes="After"
AdvSceneSwitcher.macroScheduleEntry.repeatEnd.afterNTimes.suffix="occurrence(s)"
AdvSceneSwitcher.macroScheduleEntry.repeatEnd.untilDate="Until"
AdvSceneSwitcher.macroScheduleEntry.color="Color:"
AdvSceneSwitcher.macroScheduleEntry.color.dialog="Pick entry color"
AdvSceneSwitcher.macroScheduleEntry.checkConditions="Check macro conditions before running"
AdvSceneSwitcher.macroScheduleEntry.runElseActionsOnConditionFailure="Run else actions if conditions are not met"
AdvSceneSwitcher.macroScheduleEntry.enabled="Enabled"
# Legacy tabs below - please don't waste your time adding translations for these :) # Legacy tabs below - please don't waste your time adding translations for these :)
# Transition Tab # Transition Tab
AdvSceneSwitcher.transitionTab.title="Transition" AdvSceneSwitcher.transitionTab.title="Transition"

View File

@@ -83,7 +83,6 @@ AdvSceneSwitcher.macroTab.highlightTrueConditions="Resaltar condiciones de la ma
AdvSceneSwitcher.macroTab.highlightPerformedActions="Resaltar acciones realizadas recientemente de la macro seleccionada actualmente" AdvSceneSwitcher.macroTab.highlightPerformedActions="Resaltar acciones realizadas recientemente de la macro seleccionada actualmente"
; Lógica de macros ; Lógica de macros
AdvSceneSwitcher.logic.none="Omitir entrada"
AdvSceneSwitcher.logic.and="Y" AdvSceneSwitcher.logic.and="Y"
AdvSceneSwitcher.logic.or="O" AdvSceneSwitcher.logic.or="O"
AdvSceneSwitcher.logic.andNot="Y no" AdvSceneSwitcher.logic.andNot="Y no"
@@ -173,7 +172,7 @@ AdvSceneSwitcher.condition.record.state.start="Grabación en ejecución"
AdvSceneSwitcher.condition.record.state.pause="Grabación en pausa" AdvSceneSwitcher.condition.record.state.pause="Grabación en pausa"
AdvSceneSwitcher.condition.record.state.stop="Grabación detenida" AdvSceneSwitcher.condition.record.state.stop="Grabación detenida"
AdvSceneSwitcher.condition.process="Proceso" AdvSceneSwitcher.condition.process="Proceso"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}se está ejecutando{{focused}}y está enfocado" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}se está ejecutando{{focused}}y está enfocado"
AdvSceneSwitcher.condition.idle="Inactivo" AdvSceneSwitcher.condition.idle="Inactivo"
AdvSceneSwitcher.condition.idle.entry="No hay entradas de teclado o ratón durante {{duration}}" AdvSceneSwitcher.condition.idle.entry="No hay entradas de teclado o ratón durante {{duration}}"
AdvSceneSwitcher.condition.pluginState="Estado del complemento" AdvSceneSwitcher.condition.pluginState="Estado del complemento"
@@ -340,7 +339,6 @@ AdvSceneSwitcher.action.replay.type.save="Guardar búfer de reproducción"
AdvSceneSwitcher.action.streaming="Transmisión" AdvSceneSwitcher.action.streaming="Transmisión"
AdvSceneSwitcher.action.streaming.type.stop="Detener transmisión" AdvSceneSwitcher.action.streaming.type.stop="Detener transmisión"
AdvSceneSwitcher.action.streaming.type.start="Iniciar transmisión" AdvSceneSwitcher.action.streaming.type.start="Iniciar transmisión"
AdvSceneSwitcher.action.streaming.entry="{{actions}}{{keyFrameInterval}}{{stringValue}}{{showPassword}}"
AdvSceneSwitcher.action.run="Ejecutar" AdvSceneSwitcher.action.run="Ejecutar"
AdvSceneSwitcher.action.sceneVisibility="Visibilidad del elemento de escena" AdvSceneSwitcher.action.sceneVisibility="Visibilidad del elemento de escena"
AdvSceneSwitcher.action.sceneVisibility.type.show="Mostrar" AdvSceneSwitcher.action.sceneVisibility.type.show="Mostrar"
@@ -372,7 +370,7 @@ AdvSceneSwitcher.action.macro="Macro"
AdvSceneSwitcher.action.macro.type.pause="Pausa" AdvSceneSwitcher.action.macro.type.pause="Pausa"
AdvSceneSwitcher.action.macro.type.unpause="Reanudar" AdvSceneSwitcher.action.macro.type.unpause="Reanudar"
AdvSceneSwitcher.action.macro.type.resetCounter="Reiniciar contador" AdvSceneSwitcher.action.macro.type.resetCounter="Reiniciar contador"
AdvSceneSwitcher.action.macro.type.run="Ejecutar" AdvSceneSwitcher.action.macro.type.runActions="Ejecutar"
AdvSceneSwitcher.action.macro.type.stop="Detener" AdvSceneSwitcher.action.macro.type.stop="Detener"
AdvSceneSwitcher.action.pluginState="Estado del complemento" AdvSceneSwitcher.action.pluginState="Estado del complemento"
AdvSceneSwitcher.action.pluginState.type.stop="Detener el complemento Advanced Scene Switcher" AdvSceneSwitcher.action.pluginState.type.stop="Detener el complemento Advanced Scene Switcher"

View File

@@ -131,7 +131,6 @@ AdvSceneSwitcher.macroList.deleted="supprimé"
AdvSceneSwitcher.macroList.duplicate="\"%1\" est déjà sélectionné !" AdvSceneSwitcher.macroList.duplicate="\"%1\" est déjà sélectionné !"
; Macro Logic ; Macro Logic
AdvSceneSwitcher.logic.none="Ignorer l'entrée"
AdvSceneSwitcher.logic.and="Et" AdvSceneSwitcher.logic.and="Et"
AdvSceneSwitcher.logic.or="Ou" AdvSceneSwitcher.logic.or="Ou"
AdvSceneSwitcher.logic.andNot="Et pas" AdvSceneSwitcher.logic.andNot="Et pas"
@@ -279,8 +278,8 @@ AdvSceneSwitcher.condition.record.state.start="Enregistrement en cours"
AdvSceneSwitcher.condition.record.state.pause="Enregistrement en pause" AdvSceneSwitcher.condition.record.state.pause="Enregistrement en pause"
AdvSceneSwitcher.condition.record.state.stop="Arrêt de l'enregistrement" AdvSceneSwitcher.condition.record.state.stop="Arrêt de l'enregistrement"
AdvSceneSwitcher.condition.process="Processus" AdvSceneSwitcher.condition.process="Processus"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}en cours d'exécution{{focused}}et est au premier plan" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}en cours d'exécution{{focused}}et est au premier plan"
AdvSceneSwitcher.condition.process.entry.focus="Processus au premier plan actuel :{{focusProcess}}" AdvSceneSwitcher.condition.process.layout.focus="Processus au premier plan actuel :{{focusProcess}}"
AdvSceneSwitcher.condition.idle="Inactif" AdvSceneSwitcher.condition.idle="Inactif"
AdvSceneSwitcher.condition.idle.entry="Aucune entrée de clavier ou de souris pendant{{duration}}" AdvSceneSwitcher.condition.idle.entry="Aucune entrée de clavier ou de souris pendant{{duration}}"
AdvSceneSwitcher.condition.pluginState="État du plugin" AdvSceneSwitcher.condition.pluginState="État du plugin"
@@ -551,7 +550,7 @@ AdvSceneSwitcher.action.macro="Macro"
AdvSceneSwitcher.action.macro.type.pause="Pause" AdvSceneSwitcher.action.macro.type.pause="Pause"
AdvSceneSwitcher.action.macro.type.unpause="Reprendre" AdvSceneSwitcher.action.macro.type.unpause="Reprendre"
AdvSceneSwitcher.action.macro.type.resetCounter="Réinitialiser le compteur" AdvSceneSwitcher.action.macro.type.resetCounter="Réinitialiser le compteur"
AdvSceneSwitcher.action.macro.type.run="Exécuter les actions" AdvSceneSwitcher.action.macro.type.runActions="Exécuter les actions"
AdvSceneSwitcher.action.macro.type.stop="Arrêter les actions" AdvSceneSwitcher.action.macro.type.stop="Arrêter les actions"
AdvSceneSwitcher.action.macro.type.disableAction="Désactiver l'action" AdvSceneSwitcher.action.macro.type.disableAction="Désactiver l'action"
AdvSceneSwitcher.action.macro.type.enableAction="Activer l'action" AdvSceneSwitcher.action.macro.type.enableAction="Activer l'action"

View File

@@ -275,7 +275,6 @@ AdvSceneSwitcher.macroList.deleted="削除"
AdvSceneSwitcher.macroList.duplicate="\"%1\" はすでに選択されています!" AdvSceneSwitcher.macroList.duplicate="\"%1\" はすでに選択されています!"
# Macro Logic # Macro Logic
AdvSceneSwitcher.logic.none="入力無視"
; AdvSceneSwitcher.logic.and="And" ; AdvSceneSwitcher.logic.and="And"
; AdvSceneSwitcher.logic.or="Or" ; AdvSceneSwitcher.logic.or="Or"
; AdvSceneSwitcher.logic.andNot="And not" ; AdvSceneSwitcher.logic.andNot="And not"
@@ -445,8 +444,8 @@ AdvSceneSwitcher.condition.stream.service.tooltip="現在のサービス名: %1"
AdvSceneSwitcher.condition.record.state.duration="録音時間が長くなっています。" AdvSceneSwitcher.condition.record.state.duration="録音時間が長くなっています。"
; AdvSceneSwitcher.condition.record.entry="{{condition}}{{duration}}" ; AdvSceneSwitcher.condition.record.entry="{{condition}}{{duration}}"
AdvSceneSwitcher.condition.process="プロセス" AdvSceneSwitcher.condition.process="プロセス"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}が実行中{{focused}}に集中しています" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}が実行中{{focused}}に集中しています"
AdvSceneSwitcher.condition.process.entry.focus="現在のフォアグラウンドプロセス:{{focusProcess}}" AdvSceneSwitcher.condition.process.layout.focus="現在のフォアグラウンドプロセス:{{focusProcess}}"
AdvSceneSwitcher.condition.idle="アイドル" AdvSceneSwitcher.condition.idle="アイドル"
AdvSceneSwitcher.condition.idle.entry="{{duration}}の間、キーボードまたはマウスの入力がありません" AdvSceneSwitcher.condition.idle.entry="{{duration}}の間、キーボードまたはマウスの入力がありません"
AdvSceneSwitcher.condition.pluginState="プラグインの状態" AdvSceneSwitcher.condition.pluginState="プラグインの状態"
@@ -923,7 +922,7 @@ AdvSceneSwitcher.action.macro.type.pause="一時停止"
AdvSceneSwitcher.action.macro.type.unpause="一時停止解除" AdvSceneSwitcher.action.macro.type.unpause="一時停止解除"
AdvSceneSwitcher.action.macro.type.togglePause="一時停止を切り替え" AdvSceneSwitcher.action.macro.type.togglePause="一時停止を切り替え"
AdvSceneSwitcher.action.macro.type.resetCounter="カウンターリセット" AdvSceneSwitcher.action.macro.type.resetCounter="カウンターリセット"
AdvSceneSwitcher.action.macro.type.run="マクロを実行" AdvSceneSwitcher.action.macro.type.runActions="マクロを実行"
AdvSceneSwitcher.action.macro.type.run.conditions.ignore="条件の状態を考慮しない" AdvSceneSwitcher.action.macro.type.run.conditions.ignore="条件の状態を考慮しない"
AdvSceneSwitcher.action.macro.type.run.conditions.true="条件が true と評価された場合のみ" AdvSceneSwitcher.action.macro.type.run.conditions.true="条件が true と評価された場合のみ"
AdvSceneSwitcher.action.macro.type.run.conditions.false="条件が false と評価された場合のみ" AdvSceneSwitcher.action.macro.type.run.conditions.false="条件が false と評価された場合のみ"

View File

@@ -239,7 +239,6 @@ AdvSceneSwitcher.macroList.deleted="excluída"
AdvSceneSwitcher.macroList.duplicate="\"%1\" já está selecionada!" AdvSceneSwitcher.macroList.duplicate="\"%1\" já está selecionada!"
; Macro Logic ; Macro Logic
AdvSceneSwitcher.logic.none="Ignorar entrada"
AdvSceneSwitcher.logic.and="E" AdvSceneSwitcher.logic.and="E"
AdvSceneSwitcher.logic.or="Ou" AdvSceneSwitcher.logic.or="Ou"
AdvSceneSwitcher.logic.andNot="E não" AdvSceneSwitcher.logic.andNot="E não"
@@ -395,8 +394,8 @@ AdvSceneSwitcher.condition.record.state.stop="Gravação parada"
AdvSceneSwitcher.condition.record.state.duration="Duração da gravação é maior que" AdvSceneSwitcher.condition.record.state.duration="Duração da gravação é maior que"
AdvSceneSwitcher.condition.record.entry="{{condition}}{{duration}}" AdvSceneSwitcher.condition.record.entry="{{condition}}{{duration}}"
AdvSceneSwitcher.condition.process="Processo" AdvSceneSwitcher.condition.process="Processo"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}está em execução{{focused}}e está em foco" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}está em execução{{focused}}e está em foco"
AdvSceneSwitcher.condition.process.entry.focus="Processo atual em primeiro plano:{{focusProcess}}" AdvSceneSwitcher.condition.process.layout.focus="Processo atual em primeiro plano:{{focusProcess}}"
AdvSceneSwitcher.condition.idle="Inativo" AdvSceneSwitcher.condition.idle="Inativo"
AdvSceneSwitcher.condition.idle.entry="Sem entradas de teclado ou mouse por {{duration}}" AdvSceneSwitcher.condition.idle.entry="Sem entradas de teclado ou mouse por {{duration}}"
AdvSceneSwitcher.condition.pluginState="Estado do plugin" AdvSceneSwitcher.condition.pluginState="Estado do plugin"
@@ -765,7 +764,6 @@ AdvSceneSwitcher.action.streaming.type.server="Definir URL do servidor"
AdvSceneSwitcher.action.streaming.type.streamKey="Definir chave de transmissão" AdvSceneSwitcher.action.streaming.type.streamKey="Definir chave de transmissão"
AdvSceneSwitcher.action.streaming.type.username="Definir nome de usuário" AdvSceneSwitcher.action.streaming.type.username="Definir nome de usuário"
AdvSceneSwitcher.action.streaming.type.password="Definir senha" AdvSceneSwitcher.action.streaming.type.password="Definir senha"
AdvSceneSwitcher.action.streaming.entry="{{actions}}{{keyFrameInterval}}{{stringValue}}{{showPassword}}"
AdvSceneSwitcher.action.run="Executar" AdvSceneSwitcher.action.run="Executar"
AdvSceneSwitcher.action.run.wait.entry="{{wait}}Aguardar a saída do processo ou no máximo {{timeout}}{{waitHelp}}" AdvSceneSwitcher.action.run.wait.entry="{{wait}}Aguardar a saída do processo ou no máximo {{timeout}}{{waitHelp}}"
AdvSceneSwitcher.action.run.wait.help.tooltip="Observe que as propriedades da macro não funcionarão se você deixar isso desmarcado, pois o processo é iniciado de forma independente do restante da lógica e não há controle sobre ele." AdvSceneSwitcher.action.run.wait.help.tooltip="Observe que as propriedades da macro não funcionarão se você deixar isso desmarcado, pois o processo é iniciado de forma independente do restante da lógica e não há controle sobre ele."
@@ -840,7 +838,7 @@ AdvSceneSwitcher.action.macro="Macro"
AdvSceneSwitcher.action.macro.type.pause="Pausar" AdvSceneSwitcher.action.macro.type.pause="Pausar"
AdvSceneSwitcher.action.macro.type.unpause="Retomar" AdvSceneSwitcher.action.macro.type.unpause="Retomar"
AdvSceneSwitcher.action.macro.type.resetCounter="Reiniciar contador" AdvSceneSwitcher.action.macro.type.resetCounter="Reiniciar contador"
AdvSceneSwitcher.action.macro.type.run="Executar macro" AdvSceneSwitcher.action.macro.type.runActions="Executar macro"
AdvSceneSwitcher.action.macro.type.run.conditions.ignore="Não considerar o estado da condição" AdvSceneSwitcher.action.macro.type.run.conditions.ignore="Não considerar o estado da condição"
AdvSceneSwitcher.action.macro.type.run.conditions.true="Apenas se as condições forem verdadeiras" AdvSceneSwitcher.action.macro.type.run.conditions.true="Apenas se as condições forem verdadeiras"
AdvSceneSwitcher.action.macro.type.run.conditions.false="Apenas se as condições forem falsas" AdvSceneSwitcher.action.macro.type.run.conditions.false="Apenas se as condições forem falsas"

View File

@@ -70,7 +70,6 @@ AdvSceneSwitcher.macroTab.name="Имя:"
AdvSceneSwitcher.macroTab.defaultname="Макрос %1" AdvSceneSwitcher.macroTab.defaultname="Макрос %1"
AdvSceneSwitcher.macroTab.copy="Создать копию" AdvSceneSwitcher.macroTab.copy="Создать копию"
; Macro Logic ; Macro Logic
AdvSceneSwitcher.logic.none="Игнорировать вход"
AdvSceneSwitcher.logic.and="И" AdvSceneSwitcher.logic.and="И"
AdvSceneSwitcher.logic.or="Или" AdvSceneSwitcher.logic.or="Или"
AdvSceneSwitcher.logic.andNot="И не" AdvSceneSwitcher.logic.andNot="И не"
@@ -103,7 +102,7 @@ AdvSceneSwitcher.condition.record.state.start="Запись запущена"
AdvSceneSwitcher.condition.record.state.pause="Запись приостановлена" AdvSceneSwitcher.condition.record.state.pause="Запись приостановлена"
AdvSceneSwitcher.condition.record.state.stop="Запись остановлена" AdvSceneSwitcher.condition.record.state.stop="Запись остановлена"
AdvSceneSwitcher.condition.process="Процесс" AdvSceneSwitcher.condition.process="Процесс"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}запущен{{focused}}и сфокусирован" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}запущен{{focused}}и сфокусирован"
AdvSceneSwitcher.condition.idle="Простой" AdvSceneSwitcher.condition.idle="Простой"
AdvSceneSwitcher.condition.idle.entry="Не было ни клавиатуры, ни мыши в течении{{duration}}" AdvSceneSwitcher.condition.idle.entry="Не было ни клавиатуры, ни мыши в течении{{duration}}"
AdvSceneSwitcher.condition.pluginState="Состояние плагина" AdvSceneSwitcher.condition.pluginState="Состояние плагина"
@@ -135,7 +134,6 @@ AdvSceneSwitcher.action.replay.type.save="Сохранить буфер восп
AdvSceneSwitcher.action.streaming="Потоковое вещание" AdvSceneSwitcher.action.streaming="Потоковое вещание"
AdvSceneSwitcher.action.streaming.type.stop="Остановить потоковое вещание" AdvSceneSwitcher.action.streaming.type.stop="Остановить потоковое вещание"
AdvSceneSwitcher.action.streaming.type.start="Начать потоковое вещание" AdvSceneSwitcher.action.streaming.type.start="Начать потоковое вещание"
AdvSceneSwitcher.action.streaming.entry="{{actions}}{{keyFrameInterval}}{{stringValue}}{{showPassword}}"
AdvSceneSwitcher.action.run="Запустить" AdvSceneSwitcher.action.run="Запустить"

View File

@@ -78,7 +78,6 @@ AdvSceneSwitcher.macroTab.expandAll="Hepsini Genişlet"
AdvSceneSwitcher.macroTab.collapseAll="Hepsini Küçült" AdvSceneSwitcher.macroTab.collapseAll="Hepsini Küçült"
; Macro Logic ; Macro Logic
AdvSceneSwitcher.logic.none="Girişi yoksay"
AdvSceneSwitcher.logic.and="Ve" AdvSceneSwitcher.logic.and="Ve"
AdvSceneSwitcher.logic.or="Ya da" AdvSceneSwitcher.logic.or="Ya da"
AdvSceneSwitcher.logic.andNot="ve değil" AdvSceneSwitcher.logic.andNot="ve değil"
@@ -150,7 +149,7 @@ AdvSceneSwitcher.condition.record.state.start="Kayıt Çalışıyor"
AdvSceneSwitcher.condition.record.state.pause="Kayıt durakladı" AdvSceneSwitcher.condition.record.state.pause="Kayıt durakladı"
AdvSceneSwitcher.condition.record.state.stop="Kayıt durdu" AdvSceneSwitcher.condition.record.state.stop="Kayıt durdu"
AdvSceneSwitcher.condition.process="İşlem" AdvSceneSwitcher.condition.process="İşlem"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}çalışıyor{{focused}}ve odaklandı" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}çalışıyor{{focused}}ve odaklandı"
AdvSceneSwitcher.condition.idle="Boşta" AdvSceneSwitcher.condition.idle="Boşta"
AdvSceneSwitcher.condition.idle.entry="...için klavye veya fare girişi yok {{duration}}" AdvSceneSwitcher.condition.idle.entry="...için klavye veya fare girişi yok {{duration}}"
AdvSceneSwitcher.condition.pluginState="Eklenti durumu" AdvSceneSwitcher.condition.pluginState="Eklenti durumu"
@@ -270,7 +269,6 @@ AdvSceneSwitcher.action.replay.type.save="Tekrar arabelleğini kaydet"
AdvSceneSwitcher.action.streaming="Yayın" AdvSceneSwitcher.action.streaming="Yayın"
AdvSceneSwitcher.action.streaming.type.stop="Yayın durdur" AdvSceneSwitcher.action.streaming.type.stop="Yayın durdur"
AdvSceneSwitcher.action.streaming.type.start="Yayın başlat" AdvSceneSwitcher.action.streaming.type.start="Yayın başlat"
AdvSceneSwitcher.action.streaming.entry="{{actions}}{{keyFrameInterval}}{{stringValue}}{{showPassword}}"
AdvSceneSwitcher.action.run="Çalıştır" AdvSceneSwitcher.action.run="Çalıştır"
AdvSceneSwitcher.action.sceneVisibility="Sahne öğesi görünürlüğü" AdvSceneSwitcher.action.sceneVisibility="Sahne öğesi görünürlüğü"
AdvSceneSwitcher.action.sceneVisibility.type.show="Göster" AdvSceneSwitcher.action.sceneVisibility.type.show="Göster"
@@ -301,7 +299,7 @@ AdvSceneSwitcher.action.macro="Makro"
AdvSceneSwitcher.action.macro.type.pause="Duraklat" AdvSceneSwitcher.action.macro.type.pause="Duraklat"
AdvSceneSwitcher.action.macro.type.unpause="Duraklatma" AdvSceneSwitcher.action.macro.type.unpause="Duraklatma"
AdvSceneSwitcher.action.macro.type.resetCounter="Sayacı sıfırla" AdvSceneSwitcher.action.macro.type.resetCounter="Sayacı sıfırla"
AdvSceneSwitcher.action.macro.type.run="Çalıştır" AdvSceneSwitcher.action.macro.type.runActions="Çalıştır"
AdvSceneSwitcher.action.pluginState="Eklenti durumu" AdvSceneSwitcher.action.pluginState="Eklenti durumu"
AdvSceneSwitcher.action.pluginState.type.stop="Advanced Scene Switcher eklentisini durdurun" AdvSceneSwitcher.action.pluginState.type.stop="Advanced Scene Switcher eklentisini durdurun"
AdvSceneSwitcher.action.pluginState.type.noMatch="Eşleşmeme davranışını değiştirin:" AdvSceneSwitcher.action.pluginState.type.noMatch="Eşleşmeme davranışını değiştirin:"

View File

@@ -259,7 +259,6 @@ AdvSceneSwitcher.macroList.deleted="删除"
AdvSceneSwitcher.macroList.duplicate="\"%1\" 已选择!" AdvSceneSwitcher.macroList.duplicate="\"%1\" 已选择!"
; Macro Logic ; Macro Logic
AdvSceneSwitcher.logic.none="忽略条件"
AdvSceneSwitcher.logic.and="且" AdvSceneSwitcher.logic.and="且"
AdvSceneSwitcher.logic.or="或" AdvSceneSwitcher.logic.or="或"
AdvSceneSwitcher.logic.andNot="且不" AdvSceneSwitcher.logic.andNot="且不"
@@ -424,8 +423,8 @@ AdvSceneSwitcher.condition.record.state.stop="录制停止"
AdvSceneSwitcher.condition.record.state.duration="录制时间长于" AdvSceneSwitcher.condition.record.state.duration="录制时间长于"
AdvSceneSwitcher.condition.record.entry="{{condition}}{{duration}}" AdvSceneSwitcher.condition.record.entry="{{condition}}{{duration}}"
AdvSceneSwitcher.condition.process="进程" AdvSceneSwitcher.condition.process="进程"
AdvSceneSwitcher.condition.process.entry="{{processes}}{{regex}}为正在运行中{{focused}}且为焦点" AdvSceneSwitcher.condition.process.layout="{{processes}}{{regex}}为正在运行中{{focused}}且为焦点"
AdvSceneSwitcher.condition.process.entry.focus="当前焦点进程: {{focusProcess}}" AdvSceneSwitcher.condition.process.layout.focus="当前焦点进程: {{focusProcess}}"
AdvSceneSwitcher.condition.idle="闲置检测" AdvSceneSwitcher.condition.idle="闲置检测"
AdvSceneSwitcher.condition.idle.entry="{{duration}}内没有键盘或鼠标输入" AdvSceneSwitcher.condition.idle.entry="{{duration}}内没有键盘或鼠标输入"
AdvSceneSwitcher.condition.pluginState="插件状态" AdvSceneSwitcher.condition.pluginState="插件状态"
@@ -825,7 +824,6 @@ AdvSceneSwitcher.action.streaming.type.server="设置服务器"
AdvSceneSwitcher.action.streaming.type.streamKey="设置推流码" AdvSceneSwitcher.action.streaming.type.streamKey="设置推流码"
AdvSceneSwitcher.action.streaming.type.username="设置用户名" AdvSceneSwitcher.action.streaming.type.username="设置用户名"
AdvSceneSwitcher.action.streaming.type.password="设置密码" AdvSceneSwitcher.action.streaming.type.password="设置密码"
AdvSceneSwitcher.action.streaming.entry="{{actions}}{{keyFrameInterval}}{{stringValue}}{{showPassword}}"
AdvSceneSwitcher.action.run="运行" AdvSceneSwitcher.action.run="运行"
AdvSceneSwitcher.action.run.wait.entry="{{wait}}进程退出或最多等待{{timeout}}{{waitHelp}}" AdvSceneSwitcher.action.run.wait.entry="{{wait}}进程退出或最多等待{{timeout}}{{waitHelp}}"
AdvSceneSwitcher.action.run.wait.help.tooltip="请注意,如果不勾选此选项,宏属性将不起作用,因为进程的启动会脱离逻辑的其他部分,因此无法对其进行控制." AdvSceneSwitcher.action.run.wait.help.tooltip="请注意,如果不勾选此选项,宏属性将不起作用,因为进程的启动会脱离逻辑的其他部分,因此无法对其进行控制."
@@ -900,7 +898,7 @@ AdvSceneSwitcher.action.macro="宏"
AdvSceneSwitcher.action.macro.type.pause="停用" AdvSceneSwitcher.action.macro.type.pause="停用"
AdvSceneSwitcher.action.macro.type.unpause="启用" AdvSceneSwitcher.action.macro.type.unpause="启用"
AdvSceneSwitcher.action.macro.type.resetCounter="重置计数器" AdvSceneSwitcher.action.macro.type.resetCounter="重置计数器"
AdvSceneSwitcher.action.macro.type.run="运行宏" AdvSceneSwitcher.action.macro.type.runActions="运行宏"
AdvSceneSwitcher.action.macro.type.run.conditions.ignore="忽略条件结果" AdvSceneSwitcher.action.macro.type.run.conditions.ignore="忽略条件结果"
AdvSceneSwitcher.action.macro.type.run.conditions.true="仅当条件结果为真时" AdvSceneSwitcher.action.macro.type.run.conditions.true="仅当条件结果为真时"
AdvSceneSwitcher.action.macro.type.run.conditions.false="仅当条件结果为假时" AdvSceneSwitcher.action.macro.type.run.conditions.false="仅当条件结果为假时"

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#fefefe" xmlns="http://www.w3.org/2000/svg"
width="800px" height="800px" viewBox="0 0 52 52" enable-background="new 0 0 52 52" xml:space="preserve">
<path d="M42.6,17.8c2.4,0,7.2-2,7.2-8.4c0-6.4-4.6-6.8-6.1-6.8c-2.8,0-5.6,2-8.1,6.3c-2.5,4.4-5.3,9.1-5.3,9.1
l-0.1,0c-0.6-3.1-1.1-5.6-1.3-6.7c-0.5-2.7-3.6-8.4-9.9-8.4c-6.4,0-12.2,3.7-12.2,3.7l0,0C5.8,7.3,5.1,8.5,5.1,9.9
c0,2.1,1.7,3.9,3.9,3.9c0.6,0,1.2-0.2,1.7-0.4l0,0c0,0,4.8-2.7,5.9,0c0.3,0.8,0.6,1.7,0.9,2.7c1.2,4.2,2.4,9.1,3.3,13.5l-4.2,6
c0,0-4.7-1.7-7.1-1.7s-7.2,2-7.2,8.4s4.6,6.8,6.1,6.8c2.8,0,5.6-2,8.1-6.3c2.5-4.4,5.3-9.1,5.3-9.1c0.8,4,1.5,7.1,1.9,8.5
c1.6,4.5,5.3,7.2,10.1,7.2c0,0,5,0,10.9-3.3c1.4-0.6,2.4-2,2.4-3.6c0-2.1-1.7-3.9-3.9-3.9c-0.6,0-1.2,0.2-1.7,0.4l0,0
c0,0-4.2,2.4-5.6,0.5c-1-2-1.9-4.6-2.6-7.8c-0.6-2.8-1.3-6.2-2-9.5l4.3-6.2C35.5,16.1,40.2,17.8,42.6,17.8z"/>
</svg>

After

Width:  |  Height:  |  Size: 973 B

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#202020" xmlns="http://www.w3.org/2000/svg"
width="800px" height="800px" viewBox="0 0 52 52" enable-background="new 0 0 52 52" xml:space="preserve">
<path d="M42.6,17.8c2.4,0,7.2-2,7.2-8.4c0-6.4-4.6-6.8-6.1-6.8c-2.8,0-5.6,2-8.1,6.3c-2.5,4.4-5.3,9.1-5.3,9.1
l-0.1,0c-0.6-3.1-1.1-5.6-1.3-6.7c-0.5-2.7-3.6-8.4-9.9-8.4c-6.4,0-12.2,3.7-12.2,3.7l0,0C5.8,7.3,5.1,8.5,5.1,9.9
c0,2.1,1.7,3.9,3.9,3.9c0.6,0,1.2-0.2,1.7-0.4l0,0c0,0,4.8-2.7,5.9,0c0.3,0.8,0.6,1.7,0.9,2.7c1.2,4.2,2.4,9.1,3.3,13.5l-4.2,6
c0,0-4.7-1.7-7.1-1.7s-7.2,2-7.2,8.4s4.6,6.8,6.1,6.8c2.8,0,5.6-2,8.1-6.3c2.5-4.4,5.3-9.1,5.3-9.1c0.8,4,1.5,7.1,1.9,8.5
c1.6,4.5,5.3,7.2,10.1,7.2c0,0,5,0,10.9-3.3c1.4-0.6,2.4-2,2.4-3.6c0-2.1-1.7-3.9-3.9-3.9c-0.6,0-1.2,0.2-1.7,0.4l0,0
c0,0-4.2,2.4-5.6,0.5c-1-2-1.9-4.6-2.6-7.8c-0.6-2.8-1.3-6.2-2-9.5l4.3-6.2C35.5,16.1,40.2,17.8,42.6,17.8z"/>
</svg>

After

Width:  |  Height:  |  Size: 973 B

2
deps/leptonica vendored

2
deps/libusb vendored

View File

@@ -258,6 +258,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="settingsLock">
<property name="text">
<string>AdvSceneSwitcher.generalTab.generalBehavior.settingsLock</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@@ -19,8 +19,10 @@
#include <obs-frontend-api.h> #include <obs-frontend-api.h>
#include <QAction> #include <QAction>
#include <QDirIterator> #include <QDirIterator>
#include <QInputDialog>
#include <QLibrary> #include <QLibrary>
#include <QMainWindow> #include <QMainWindow>
#include <QMessageBox>
#include <QTextStream> #include <QTextStream>
#include <regex> #include <regex>
@@ -41,9 +43,12 @@ AdvSceneSwitcher::AdvSceneSwitcher(QWidget *parent)
{ {
switcher->settingsWindowOpened = true; switcher->settingsWindowOpened = true;
ui->setupUi(this); ui->setupUi(this);
std::lock_guard<std::mutex> lock(switcher->m); {
switcher->Prune(); std::lock_guard<std::mutex> lock(switcher->m);
LoadUI(); switcher->Prune();
LoadUI();
}
CheckFirstTimeSetup();
} }
AdvSceneSwitcher::~AdvSceneSwitcher() AdvSceneSwitcher::~AdvSceneSwitcher()
@@ -139,7 +144,6 @@ void AdvSceneSwitcher::LoadUI()
SetTabOrder(ui->tabWidget); SetTabOrder(ui->tabWidget);
SetCurrentTab(ui->tabWidget); SetCurrentTab(ui->tabWidget);
RestoreWindowGeo(); RestoreWindowGeo();
CheckFirstTimeSetup();
loading = false; loading = false;
} }
@@ -322,8 +326,7 @@ void SwitcherData::SetPreconditions()
{ {
// Window title // Window title
lastTitle = currentTitle; lastTitle = currentTitle;
std::string title; auto title = GetCurrentWindowTitle();
GetCurrentWindowTitle(title);
for (auto &window : ignoreWindowsSwitches) { for (auto &window : ignoreWindowsSwitches) {
bool equals = (title == window); bool equals = (title == window);
bool matches = false; bool matches = false;
@@ -343,7 +346,7 @@ void SwitcherData::SetPreconditions()
currentTitle = title; currentTitle = title;
// Process name // Process name
GetForegroundProcessName(currentForegroundProcess); currentForegroundProcess = GetForegroundProcessName();
// Macro // Macro
InvalidateMacroTempVarValues(); InvalidateMacroTempVarValues();
@@ -458,12 +461,13 @@ void SwitcherData::Stop()
SetMacroAbortWait(true); SetMacroAbortWait(true);
GetMacroWaitCV().notify_all(); GetMacroWaitCV().notify_all();
GetMacroTransitionCV().notify_all(); GetMacroTransitionCV().notify_all();
StopAllMacros(); SignalStopAllMacros();
StopAndClearAllActionQueues(); StopAndClearAllActionQueues();
CloseAllInputDialogs(); CloseAllInputDialogs();
th->wait(); th->wait();
delete th; delete th;
th = nullptr; th = nullptr;
WaitForAllMacros();
RunStopSteps(); RunStopSteps();
} }
@@ -507,6 +511,8 @@ bool SwitcherData::AnySceneTransitionStarted()
******************************************************************************/ ******************************************************************************/
extern "C" EXPORT void FreeSceneSwitcher() extern "C" EXPORT void FreeSceneSwitcher()
{ {
switcher->Stop();
PlatformCleanup(); PlatformCleanup();
RunPluginCleanupSteps(); RunPluginCleanupSteps();
@@ -628,13 +634,20 @@ static void handleSceneCollectionCleanup()
return; return;
} }
// OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP is also called on
// shutdown.
// Here we also don't want to clear the settings.
if (switcher->obsIsShuttingDown) {
return;
}
SaveSceneSwitcher(nullptr, false, nullptr); SaveSceneSwitcher(nullptr, false, nullptr);
} }
// Note to future self: // Note to future self:
// be careful using switcher->m here as there is potential for deadlocks when using // be careful using switcher->m here as there is potential for deadlocks when using
// frontend functions such as obs_frontend_set_current_scene() // frontend functions such as obs_frontend_set_current_scene()
static void OBSEvent(enum obs_frontend_event event, void *switcher) static void OBSEvent(enum obs_frontend_event event, void *)
{ {
if (!switcher) { if (!switcher) {
return; return;
@@ -708,19 +721,54 @@ static void LoadPlugins()
} }
} }
static bool settingsPasswordIsCorrect(QWidget *parent)
{
bool ok;
QString input = QInputDialog::getText(
parent,
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.passwordLabel"),
QLineEdit::Password, QString(), &ok);
if (!ok) {
return false;
}
if (input.toStdString() == switcher->settingsLockPassword) {
return true;
}
QMessageBox::warning(
parent,
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.wrongPassword"));
return false;
}
void OpenSettingsWindow() void OpenSettingsWindow()
{ {
if (switcher->settingsWindowOpened) { if (switcher->settingsWindowOpened) {
AdvSceneSwitcher::window->show(); AdvSceneSwitcher::window->show();
AdvSceneSwitcher::window->raise(); AdvSceneSwitcher::window->raise();
AdvSceneSwitcher::window->activateWindow(); AdvSceneSwitcher::window->activateWindow();
} else { return;
AdvSceneSwitcher::window =
new AdvSceneSwitcher(static_cast<QMainWindow *>(
obs_frontend_get_main_window()));
AdvSceneSwitcher::window->setAttribute(Qt::WA_DeleteOnClose);
AdvSceneSwitcher::window->show();
} }
auto parent =
static_cast<QMainWindow *>(obs_frontend_get_main_window());
if (switcher->settingsLockEnabled &&
!switcher->settingsLockPassword.empty() &&
!settingsPasswordIsCorrect(parent)) {
return;
}
AdvSceneSwitcher::window = new AdvSceneSwitcher(parent);
AdvSceneSwitcher::window->setAttribute(Qt::WA_DeleteOnClose);
AdvSceneSwitcher::window->show();
} }
void AdvSceneSwitcher::HighlightMacroSettingsButton(bool enable) void AdvSceneSwitcher::HighlightMacroSettingsButton(bool enable)
@@ -768,8 +816,6 @@ void HighlightMacroSettingsButton(bool enable)
enable); enable);
} }
void SetupActionQueues();
extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module, extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module,
translateFunc translate) translateFunc translate)
{ {
@@ -781,12 +827,11 @@ extern "C" EXPORT void InitSceneSwitcher(obs_module_t *module,
PlatformInit(); PlatformInit();
LoadPlugins(); LoadPlugins();
SetupDock(); SetupDock();
SetupActionQueues();
RunPluginInitSteps(); RunPluginInitSteps();
obs_frontend_add_save_callback(SaveSceneSwitcher, nullptr); obs_frontend_add_save_callback(SaveSceneSwitcher, nullptr);
obs_frontend_add_event_callback(OBSEvent, switcher); obs_frontend_add_event_callback(OBSEvent, nullptr);
QAction *action = (QAction *)obs_frontend_add_tools_menu_qaction( QAction *action = (QAction *)obs_frontend_add_tools_menu_qaction(
obs_module_text("AdvSceneSwitcher.pluginName")); obs_module_text("AdvSceneSwitcher.pluginName"));

View File

@@ -68,6 +68,7 @@ public slots:
void on_warnPluginLoadFailure_stateChanged(int state); void on_warnPluginLoadFailure_stateChanged(int state);
void on_suppressCrashRecoveryDialog_stateChanged(int state); void on_suppressCrashRecoveryDialog_stateChanged(int state);
void on_hideLegacyTabs_stateChanged(int state); void on_hideLegacyTabs_stateChanged(int state);
void on_settingsLock_stateChanged(int state);
void on_priorityUp_clicked(); void on_priorityUp_clicked();
void on_priorityDown_clicked(); void on_priorityDown_clicked();
void on_threadPriority_currentTextChanged(const QString &text); void on_threadPriority_currentTextChanged(const QString &text);

View File

@@ -19,6 +19,8 @@
#include <obs-frontend-api.h> #include <obs-frontend-api.h>
#include <QFileDialog> #include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>
namespace advss { namespace advss {
@@ -243,6 +245,64 @@ void AdvSceneSwitcher::on_hideLegacyTabs_stateChanged(int state)
ui->priorityBox->setVisible(!switcher->hideLegacyTabs); ui->priorityBox->setVisible(!switcher->hideLegacyTabs);
} }
void AdvSceneSwitcher::on_settingsLock_stateChanged(int state)
{
if (loading) {
return;
}
if (!state) {
switcher->settingsLockEnabled = false;
switcher->settingsLockPassword = "";
return;
}
bool ok;
QString newPassword = QInputDialog::getText(
this,
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.newPasswordLabel"),
QLineEdit::Password, QString(), &ok);
const auto disablePassword = [this]() {
QSignalBlocker blocker(ui->settingsLock);
ui->settingsLock->setChecked(false);
ui->settingsLock->setCheckState(Qt::Unchecked);
switcher->settingsLockEnabled = false;
switcher->settingsLockPassword = "";
};
if (!ok || newPassword.isEmpty()) {
disablePassword();
return;
}
QString confirm = QInputDialog::getText(
this,
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.confirmPasswordLabel"),
QLineEdit::Password, QString(), &ok);
if (!ok || newPassword != confirm) {
if (ok) {
QMessageBox::warning(
this,
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.title"),
obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.settingsLock.passwordMismatch"));
}
disablePassword();
return;
}
switcher->settingsLockEnabled = true;
switcher->settingsLockPassword = newPassword.toStdString();
}
void AdvSceneSwitcher::SetDeprecationWarnings() void AdvSceneSwitcher::SetDeprecationWarnings()
{ {
QString toolTip = QString toolTip =
@@ -391,12 +451,16 @@ void AdvSceneSwitcher::CheckFirstTimeSetup()
return; return;
} }
auto macro = FirstRunWizard::ShowWizard(this); bool wasSkipped = false;
auto macro = FirstRunWizard::ShowWizard(this, &wasSkipped);
if (macro) { if (macro) {
renameMacroIfNecessary(macro); renameMacroIfNecessary(macro);
QTimer::singleShot(0, this, QTimer::singleShot(0, this,
[this, macro]() { ui->macros->Add(macro); }); [this, macro]() { ui->macros->Add(macro); });
} }
if (wasSkipped) {
ui->alwaysShowFeatureTabs->setChecked(true);
}
switcher->Start(); switcher->Start();
} }
@@ -468,7 +532,6 @@ void SwitcherData::LoadSettings(obs_data_t *obj)
// Needs to be loaded before any entries which might rely on scene group // Needs to be loaded before any entries which might rely on scene group
// selections to be available. // selections to be available.
loadSceneGroups(obj); loadSceneGroups(obj);
LoadVariables(obj);
RunLoadSteps(obj); RunLoadSteps(obj);
@@ -507,7 +570,6 @@ void SwitcherData::SaveSettings(obs_data_t *obj)
saveSceneGroups(obj); saveSceneGroups(obj);
SaveMacros(obj); SaveMacros(obj);
SaveGlobalMacroSettings(obj); SaveGlobalMacroSettings(obj);
SaveVariables(obj);
saveWindowTitleSwitches(obj); saveWindowTitleSwitches(obj);
saveScreenRegionSwitches(obj); saveScreenRegionSwitches(obj);
savePauseSwitches(obj); savePauseSwitches(obj);
@@ -565,6 +627,9 @@ void SwitcherData::SaveGeneralSettings(obs_data_t *obj)
disableFilterComboboxFilter); disableFilterComboboxFilter);
obs_data_set_bool(obj, "warnPluginLoadFailure", warnPluginLoadFailure); obs_data_set_bool(obj, "warnPluginLoadFailure", warnPluginLoadFailure);
obs_data_set_bool(obj, "hideLegacyTabs", hideLegacyTabs); obs_data_set_bool(obj, "hideLegacyTabs", hideLegacyTabs);
obs_data_set_bool(obj, "settingsLockEnabled", settingsLockEnabled);
obs_data_set_string(obj, "settingsLockPassword",
settingsLockPassword.c_str());
SaveFunctionPriorities(obj, functionNamesByPriority); SaveFunctionPriorities(obj, functionNamesByPriority);
@@ -636,6 +701,8 @@ void SwitcherData::LoadGeneralSettings(obs_data_t *obj)
warnPluginLoadFailure = obs_data_get_bool(obj, "warnPluginLoadFailure"); warnPluginLoadFailure = obs_data_get_bool(obj, "warnPluginLoadFailure");
obs_data_set_default_bool(obj, "hideLegacyTabs", true); obs_data_set_default_bool(obj, "hideLegacyTabs", true);
hideLegacyTabs = obs_data_get_bool(obj, "hideLegacyTabs"); hideLegacyTabs = obs_data_get_bool(obj, "hideLegacyTabs");
settingsLockEnabled = obs_data_get_bool(obj, "settingsLockEnabled");
settingsLockPassword = obs_data_get_string(obj, "settingsLockPassword");
SetDefaultFunctionPriorities(obj); SetDefaultFunctionPriorities(obj);
LoadFunctionPriorities(obj, functionNamesByPriority); LoadFunctionPriorities(obj, functionNamesByPriority);
@@ -958,6 +1025,7 @@ void AdvSceneSwitcher::SetupGeneralTab()
ui->warnPluginLoadFailure->setChecked(switcher->warnPluginLoadFailure); ui->warnPluginLoadFailure->setChecked(switcher->warnPluginLoadFailure);
ui->suppressCrashRecoveryDialog->setChecked(GetSuppressCrashDialog()); ui->suppressCrashRecoveryDialog->setChecked(GetSuppressCrashDialog());
ui->hideLegacyTabs->setChecked(switcher->hideLegacyTabs); ui->hideLegacyTabs->setChecked(switcher->hideLegacyTabs);
ui->settingsLock->setChecked(switcher->settingsLockEnabled);
populatePriorityFunctionList(ui->priorityList); populatePriorityFunctionList(ui->priorityList);
populateThreadPriorityList(ui->threadPriority); populateThreadPriorityList(ui->threadPriority);

View File

@@ -92,12 +92,11 @@ bool SwitcherData::checkExeSwitch(OBSWeakSource &scene,
} }
std::string title = switcher->currentTitle; std::string title = switcher->currentTitle;
QStringList runningProcesses;
bool ignored = false; bool ignored = false;
bool match = false; bool match = false;
// Check for match // Check for match
GetProcessList(runningProcesses); const auto runningProcesses = GetProcessList();
for (ExecutableSwitch &s : executableSwitches) { for (ExecutableSwitch &s : executableSwitches) {
if (!s.initialized()) { if (!s.initialized()) {
continue; continue;

View File

@@ -178,47 +178,19 @@ void AdvSceneSwitcher::on_ignoreWindows_currentRowChanged(int idx)
} }
} }
void checkWindowTitleSwitchDirect(WindowSwitch &s, static bool windowInfoMatchesSwitch(const WindowInfo &info,
std::string &currentWindowTitle, bool &match, const WindowSwitch &s)
OBSWeakSource &scene,
OBSWeakSource &transition)
{ {
bool focus = (!s.focus || s.window == currentWindowTitle); if (s.focus && !info.focused) {
bool fullscreen = (!s.fullscreen || IsFullscreen(s.window)); return false;
bool max = (!s.maximized || IsMaximized(s.window));
if (focus && fullscreen && max) {
match = true;
scene = s.getScene();
transition = s.transition;
} }
} if (s.fullscreen && !info.fullscreen) {
return false;
void checkWindowTitleSwitchRegex(WindowSwitch &s,
std::string &currentWindowTitle,
std::vector<std::string> windowList,
bool &match, OBSWeakSource &scene,
OBSWeakSource &transition)
{
for (auto &window : windowList) {
try {
std::regex expr(s.window);
if (!std::regex_match(window, expr)) {
continue;
}
} catch (const std::regex_error &) {
}
bool focus = (!s.focus || window == currentWindowTitle);
bool fullscreen = (!s.fullscreen || IsFullscreen(window));
bool max = (!s.maximized || IsMaximized(window));
if (focus && fullscreen && max) {
match = true;
scene = s.getScene();
transition = s.transition;
}
} }
if (s.maximized && !info.maximized) {
return false;
}
return true;
} }
bool SwitcherData::checkWindowTitleSwitch(OBSWeakSource &scene, bool SwitcherData::checkWindowTitleSwitch(OBSWeakSource &scene,
@@ -228,24 +200,37 @@ bool SwitcherData::checkWindowTitleSwitch(OBSWeakSource &scene,
return false; return false;
} }
std::string currentWindowTitle = switcher->currentTitle;
bool match = false; bool match = false;
std::vector<std::string> windowList;
GetWindowList(windowList); WindowQueryOptions options;
options.focus = true;
options.fullscreen = true;
options.maximized = true;
const auto windows = GetWindows(options);
for (WindowSwitch &s : windowSwitches) { for (WindowSwitch &s : windowSwitches) {
if (!s.initialized()) { if (!s.initialized()) {
continue; continue;
} }
if (std::find(windowList.begin(), windowList.end(), s.window) != for (const auto &info : windows) {
windowList.end()) { bool titleMatch = false;
checkWindowTitleSwitchDirect(s, currentWindowTitle, try {
match, scene, transition); std::regex expr(s.window);
} else { titleMatch = info.title == s.window ||
checkWindowTitleSwitchRegex(s, currentWindowTitle, std::regex_match(info.title, expr);
windowList, match, scene, } catch (const std::regex_error &) {
transition); titleMatch = info.title == s.window;
}
if (!titleMatch || !windowInfoMatchesSwitch(info, s)) {
continue;
}
match = true;
scene = s.getScene();
transition = s.transition;
break;
} }
if (match) { if (match) {

View File

@@ -32,6 +32,9 @@
#endif #endif
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <climits>
#include <dirent.h>
#include <unistd.h>
#include "kwin-helpers.h" #include "kwin-helpers.h"
namespace advss { namespace advss {
@@ -233,28 +236,89 @@ std::string getWindowName(Window window)
return windowTitle; return windowTitle;
} }
void GetWindowList(std::vector<std::string> &windows) std::vector<WindowInfo> GetWindows(const WindowQueryOptions &options)
{ {
windows.resize(0); const std::string foregroundTitle = GetCurrentWindowTitle();
for (auto window : getTopLevelWindows()) { const auto topLevel = getTopLevelWindows();
auto name = getWindowName(window); auto display = disp();
if (name.empty()) {
continue;
}
windows.emplace_back(name);
}
}
void GetWindowList(QStringList &windows) std::vector<WindowInfo> result;
{ result.reserve(topLevel.size());
windows.clear();
for (auto window : getTopLevelWindows()) { for (auto window : topLevel) {
auto name = getWindowName(window); auto name = getWindowName(window);
if (name.empty()) { if (name.empty()) {
continue; continue;
} }
windows << QString::fromStdString(name);
WindowInfo info;
info.title = name;
if (options.focus) {
info.focused = (name == foregroundTitle);
}
if (options.fullscreen || options.maximized) {
QStringList states = getStates(window);
if (options.fullscreen) {
info.fullscreen = states.contains(
"_NET_WM_STATE_FULLSCREEN");
}
if (options.maximized) {
info.maximized =
states.contains(
"_NET_WM_STATE_MAXIMIZED_VERT") &&
states.contains(
"_NET_WM_STATE_MAXIMIZED_HORZ");
}
}
if (options.geometry && display) {
XWindowAttributes attrs;
if (XGetWindowAttributes(display, window, &attrs)) {
int x = 0;
int y = 0;
Window child;
XTranslateCoordinates(
display, window,
DefaultRootWindow(display), 0, 0, &x,
&y, &child);
info.x = x;
info.y = y;
info.width = attrs.width;
info.height = attrs.height;
}
}
// windowClass and text not implemented on Linux
result.emplace_back(std::move(info));
} }
// When KWin compat is active, native Wayland windows are not tracked by
// X11 and therefore do not appear in the list above. Merge in any window
// reported by KWin that is not already present (matched by title) so that
// title and focus conditions work for native Wayland windows.
if (KWin) {
for (const auto &[pid, title] :
FocusNotifier::getWindowList()) {
bool found = false;
for (const auto &info : result) {
if (info.title == title) {
found = true;
break;
}
}
if (!found) {
WindowInfo waylandWindow;
waylandWindow.title = title;
waylandWindow.focused =
(title == foregroundTitle);
result.emplace_back(std::move(waylandWindow));
}
}
}
return result;
} }
int getActiveWindow(Window *&window) int getActiveWindow(Window *&window)
@@ -278,91 +342,24 @@ int getActiveWindow(Window *&window)
&bytes, (uint8_t **)&window); &bytes, (uint8_t **)&window);
} }
void GetCurrentWindowTitle(std::string &title) std::string GetCurrentWindowTitle()
{ {
if (KWin) { if (KWin) {
title = FocusNotifier::getActiveWindowTitle(); return FocusNotifier::getActiveWindowTitle();
return;
} }
Window *data = 0; Window *data = 0;
if (getActiveWindow(data) != Success || !data) { if (getActiveWindow(data) != Success || !data) {
return; return {};
} }
if (!data[0]) { if (!data[0]) {
XFree(data); XFree(data);
return; return {};
} }
auto name = getWindowName(data[0]); auto name = getWindowName(data[0]);
XFree(data); XFree(data);
return name;
if (name.empty()) {
return;
}
title = name;
}
bool windowStatesAreSet(const std::string &windowTitle,
std::vector<QString> &expectedStates)
{
if (!ewmhIsSupported()) {
return false;
}
std::vector<Window> windows = getTopLevelWindows();
for (auto &window : windows) {
auto name = getWindowName(window);
if (name.empty()) {
continue;
}
bool equals = windowTitle == name;
bool matches = QString::fromStdString(name).contains(
QRegularExpression(
QString::fromStdString(windowTitle)));
if (!(equals || matches)) {
continue;
}
QStringList states = getStates(window);
if (states.isEmpty()) {
if (expectedStates.empty()) {
return true;
}
return false;
}
for (const auto &state : expectedStates) {
if (!states.contains(state)) {
return false;
}
}
return true;
}
return false;
}
bool IsMaximized(const std::string &title)
{
std::vector<QString> states;
states.emplace_back("_NET_WM_STATE_MAXIMIZED_VERT");
states.emplace_back("_NET_WM_STATE_MAXIMIZED_HORZ");
return windowStatesAreSet(title, states);
}
bool IsFullscreen(const std::string &title)
{
std::vector<QString> states;
states.emplace_back("_NET_WM_STATE_FULLSCREEN");
return windowStatesAreSet(title, states);
}
std::optional<std::string> GetTextInWindow(const std::string &)
{
// Not implemented
return {};
} }
static void getProcessListProcps(QStringList &processes) static void getProcessListProcps(QStringList &processes)
@@ -409,16 +406,17 @@ static void getProcessListProcps2(QStringList &processes)
#endif #endif
} }
void GetProcessList(QStringList &processes) QStringList GetProcessList()
{ {
processes.clear(); QStringList processes;
if (libprocpsSupported) { if (libprocpsSupported) {
getProcessListProcps(processes); getProcessListProcps(processes);
return; return processes;
} }
if (libprocps2Supported) { if (libprocps2Supported) {
getProcessListProcps2(processes); getProcessListProcps2(processes);
} }
return processes;
} }
long getForegroundProcessPid() long getForegroundProcessPid()
@@ -469,24 +467,83 @@ std::string getProcNameFromPid(long pid)
return name; return name;
} }
void GetForegroundProcessName(QString &proc) std::string GetForegroundProcessName()
{ {
std::string temp; auto pid = getForegroundProcessPid();
GetForegroundProcessName(temp); return getProcNameFromPid(pid);
proc = QString::fromStdString(temp);
} }
void GetForegroundProcessName(std::string &proc) static std::string getProcessPathFromPid(long pid)
{
std::string linkPath = "/proc/" + std::to_string(pid) + "/exe";
char buf[PATH_MAX];
ssize_t len = readlink(linkPath.c_str(), buf, sizeof(buf) - 1);
if (len <= 0) {
return {};
}
buf[len] = '\0';
return buf;
}
std::string GetForegroundProcessPath()
{ {
proc.resize(0);
auto pid = getForegroundProcessPid(); auto pid = getForegroundProcessPid();
proc = getProcNameFromPid(pid); if (pid <= 0) {
return {};
}
return getProcessPathFromPid(pid);
}
QStringList GetProcessPathsFromName(const QString &name)
{
QStringList paths;
const std::string nameStr = name.toStdString();
DIR *procDir = opendir("/proc");
if (!procDir) {
return paths;
}
struct dirent *entry;
while ((entry = readdir(procDir)) != nullptr) {
bool isPid = (entry->d_name[0] != '\0');
for (const char *c = entry->d_name; *c; c++) {
if (!isdigit(*c)) {
isPid = false;
break;
}
}
if (!isPid) {
continue;
}
std::string pid = entry->d_name;
std::string commPath = "/proc/" + pid + "/comm";
std::ifstream commFile(commPath);
if (!commFile) {
continue;
}
std::string comm;
std::getline(commFile, comm);
if (comm != nameStr) {
continue;
}
std::string path = getProcessPathFromPid(std::stol(pid));
if (path.empty()) {
continue;
}
QString qPath = QString::fromStdString(path);
if (!paths.contains(qPath)) {
paths.append(qPath);
}
}
closedir(procDir);
return paths;
} }
bool IsInFocus(const QString &executable) bool IsInFocus(const QString &executable)
{ {
std::string current; const auto current = GetForegroundProcessName();
GetForegroundProcessName(current);
// True if executable switch equals current window // True if executable switch equals current window
bool equals = (executable.toStdString() == current); bool equals = (executable.toStdString() == current);

View File

@@ -12,35 +12,82 @@
namespace advss { namespace advss {
std::mutex FocusNotifier::_mutex;
int FocusNotifier::activePID = -1; int FocusNotifier::activePID = -1;
std::string FocusNotifier::activeTitle = {}; std::string FocusNotifier::activeTitle = {};
std::map<std::string, std::pair<int, std::string>> FocusNotifier::_windows;
int FocusNotifier::getActiveWindowPID() int FocusNotifier::getActiveWindowPID()
{ {
std::lock_guard<std::mutex> lock(_mutex);
return activePID; return activePID;
} }
std::string FocusNotifier::getActiveWindowTitle() std::string FocusNotifier::getActiveWindowTitle()
{ {
std::lock_guard<std::mutex> lock(_mutex);
return activeTitle; return activeTitle;
} }
std::vector<std::pair<int, std::string>> FocusNotifier::getWindowList()
{
std::lock_guard<std::mutex> lock(_mutex);
std::vector<std::pair<int, std::string>> result;
result.reserve(_windows.size());
for (const auto &entry : _windows) {
result.emplace_back(entry.second);
}
return result;
}
void FocusNotifier::focusChanged(const int pid) void FocusNotifier::focusChanged(const int pid)
{ {
std::lock_guard<std::mutex> lock(_mutex);
activePID = pid; activePID = pid;
} }
void FocusNotifier::focusTitle(const QString &title) void FocusNotifier::focusTitle(const QString &title)
{ {
std::lock_guard<std::mutex> lock(_mutex);
activeTitle = title.toStdString(); activeTitle = title.toStdString();
} }
void FocusNotifier::focusUpdate(const int pid, const QString &title)
{
std::lock_guard<std::mutex> lock(_mutex);
activePID = pid;
activeTitle = title.toStdString();
}
void FocusNotifier::windowAdded(const QString &id, const int pid,
const QString &title)
{
std::lock_guard<std::mutex> lock(_mutex);
_windows[id.toStdString()] = {pid, title.toStdString()};
}
void FocusNotifier::windowRemoved(const QString &id)
{
std::lock_guard<std::mutex> lock(_mutex);
_windows.erase(id.toStdString());
}
void FocusNotifier::windowTitleChanged(const QString &id, const QString &title)
{
std::lock_guard<std::mutex> lock(_mutex);
auto it = _windows.find(id.toStdString());
if (it != _windows.end()) {
it->second.second = title.toStdString();
}
}
bool isKWinAvailable() bool isKWinAvailable()
{ {
const QDBusConnectionInterface *interface = const QDBusConnectionInterface *interface =
QDBusConnection::sessionBus().interface(); QDBusConnection::sessionBus().interface();
if (!interface) if (!interface) {
return false; return false;
}
const QStringList services = const QStringList services =
interface->registeredServiceNames().value(); interface->registeredServiceNames().value();
@@ -53,25 +100,32 @@ bool startKWinScript(QString &scriptObjectPath)
"/tmp/AdvancedSceneSwitcher/KWinFocusNotifier.js"; "/tmp/AdvancedSceneSwitcher/KWinFocusNotifier.js";
const QString script = const QString script =
R"(workspace.windowActivated.connect(function(client) { R"(var adss = "com.github.AdvancedSceneSwitcher";
if (!client) return; var adssPath = "/com/github/AdvancedSceneSwitcher";
if (!client.pid) return;
if (!client.caption) return;
callDBus( function trackWindow(window) {
"com.github.AdvancedSceneSwitcher", var id = window.internalId.toString();
"/com/github/AdvancedSceneSwitcher", callDBus(adss, adssPath, adss, "windowAdded", id, window.pid, window.caption);
"com.github.AdvancedSceneSwitcher", window.captionChanged.connect(function() {
"focusChanged", callDBus(adss, adssPath, adss, "windowTitleChanged", id, window.caption);
client.pid });
); }
callDBus(
"com.github.AdvancedSceneSwitcher", var windows = workspace.windowList();
"/com/github/AdvancedSceneSwitcher", for (var i = 0; i < windows.length; i++) {
"com.github.AdvancedSceneSwitcher", trackWindow(windows[i]);
"focusTitle", }
client.caption
); workspace.windowAdded.connect(trackWindow);
workspace.windowRemoved.connect(function(window) {
callDBus(adss, adssPath, adss, "windowRemoved", window.internalId.toString());
});
workspace.windowActivated.connect(function(client) {
callDBus(adss, adssPath, adss, "focusUpdate",
client ? client.pid : 0,
client ? client.caption : "");
}))"; }))";
if (const QDir dir; !dir.mkpath(QFileInfo(scriptPath).absolutePath())) { if (const QDir dir; !dir.mkpath(QFileInfo(scriptPath).absolutePath())) {

View File

@@ -2,7 +2,11 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <map>
#include <mutex>
#include <string> #include <string>
#include <utility>
#include <vector>
namespace advss { namespace advss {
@@ -10,18 +14,27 @@ class FocusNotifier final : public QObject {
Q_OBJECT Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.github.AdvancedSceneSwitcher") Q_CLASSINFO("D-Bus Interface", "com.github.AdvancedSceneSwitcher")
static std::mutex _mutex;
static int activePID; static int activePID;
static std::string activeTitle; static std::string activeTitle;
// Maps KWin internal window ID to {pid, title}
static std::map<std::string, std::pair<int, std::string>> _windows;
public: public:
using QObject::QObject; using QObject::QObject;
static int getActiveWindowPID(); static int getActiveWindowPID();
static std::string getActiveWindowTitle(); static std::string getActiveWindowTitle();
static std::vector<std::pair<int, std::string>> getWindowList();
public slots: public slots:
void focusChanged(const int pid); void focusChanged(const int pid);
void focusTitle(const QString &title); void focusTitle(const QString &title);
void focusUpdate(const int pid, const QString &title);
void windowAdded(const QString &id, const int pid,
const QString &title);
void windowRemoved(const QString &id);
void windowTitleChanged(const QString &id, const QString &title);
}; };
bool isKWinAvailable(); bool isKWinAvailable();

View File

@@ -49,10 +49,12 @@ MacroActionEdit::MacroActionEdit(QWidget *parent,
_section->AddHeaderWidget(_enable); _section->AddHeaderWidget(_enable);
_section->AddHeaderWidget(_actionSelection); _section->AddHeaderWidget(_actionSelection);
_section->AddHeaderWidget(_headerInfo); _section->AddHeaderWidget(_headerInfo);
_section->AddHeaderWidget(_varMappingToggle);
auto actionLayout = new QVBoxLayout; auto actionLayout = new QVBoxLayout;
actionLayout->setContentsMargins({7, 7, 7, 7}); actionLayout->setContentsMargins({7, 7, 7, 7});
actionLayout->addWidget(_section); actionLayout->addWidget(_section);
actionLayout->addWidget(_outputMappings);
_contentLayout->addLayout(actionLayout); _contentLayout->addLayout(actionLayout);
auto mainLayout = new QHBoxLayout; auto mainLayout = new QHBoxLayout;
@@ -61,7 +63,6 @@ MacroActionEdit::MacroActionEdit(QWidget *parent,
mainLayout->addWidget(_frame); mainLayout->addWidget(_frame);
setLayout(mainLayout); setLayout(mainLayout);
_entryData = entryData;
SetupWidgets(true); SetupWidgets(true);
actionStateTimer->start(300); actionStateTimer->start(300);
@@ -90,7 +91,10 @@ void MacroActionEdit::SetupWidgets(bool basicSetup)
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData); auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)), QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
this, SLOT(HeaderInfoChanged(const QString &))); this, SLOT(HeaderInfoChanged(const QString &)));
QWidget::connect(widget, SIGNAL(ShowVariableMappings(bool)), this,
SLOT(ShowVariableMappings(bool)));
_section->SetContent(widget, (*_entryData)->GetCollapsed()); _section->SetContent(widget, (*_entryData)->GetCollapsed());
SetupVarMappings((*_entryData).get());
SetFocusPolicyOfWidgets(); SetFocusPolicyOfWidgets();
_allWidgetsAreSetup = true; _allWidgetsAreSetup = true;
@@ -121,7 +125,10 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData); auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)), QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
this, SLOT(HeaderInfoChanged(const QString &))); this, SLOT(HeaderInfoChanged(const QString &)));
QWidget::connect(widget, SIGNAL(ShowVariableMappings(bool)), this,
SLOT(ShowVariableMappings(bool)));
_section->SetContent(widget); _section->SetContent(widget);
SetupVarMappings((*_entryData).get());
SetFocusPolicyOfWidgets(); SetFocusPolicyOfWidgets();
} }
@@ -157,4 +164,9 @@ std::shared_ptr<MacroSegment> MacroActionEdit::Data() const
return *_entryData; return *_entryData;
} }
void MacroActionEdit::FocusTypeSelection()
{
_actionSelection->setFocus();
}
} // namespace advss } // namespace advss

View File

@@ -17,6 +17,7 @@ public:
std::shared_ptr<MacroAction> * = nullptr); std::shared_ptr<MacroAction> * = nullptr);
void SetupWidgets(bool basicSetup = false); void SetupWidgets(bool basicSetup = false);
void SetEntryData(std::shared_ptr<MacroAction> *); void SetEntryData(std::shared_ptr<MacroAction> *);
void FocusTypeSelection() override;
private slots: private slots:
void ActionSelectionChanged(const QString &text); void ActionSelectionChanged(const QString &text);

View File

@@ -120,6 +120,15 @@ bool MacroActionMacro::PerformAction()
case Action::TOGGLE_ACTION: case Action::TOGGLE_ACTION:
AdjustActionState(macro); AdjustActionState(macro);
break; break;
case Action::RUN_MACRO: {
if (_runOptions.skipWhenPaused && macro->Paused()) {
break;
}
const bool conditionsMatched =
macro->CheckConditions(true);
macro->PerformActions(conditionsMatched, false, true);
break;
}
case Action::GET_INFO: { case Action::GET_INFO: {
SetTempVarValue( SetTempVarValue(
"conditionCount", "conditionCount",
@@ -210,6 +219,9 @@ void MacroActionMacro::LogAction() const
case Action::GET_INFO: case Action::GET_INFO:
ablog(LOG_INFO, "get info for \"%s\"", macro->Name().c_str()); ablog(LOG_INFO, "get info for \"%s\"", macro->Name().c_str());
break; break;
case Action::RUN_MACRO:
ablog(LOG_INFO, "run macro \"%s\"", macro->Name().c_str());
break;
default: default:
break; break;
} }
@@ -251,6 +263,7 @@ bool MacroActionMacro::Load(obs_data_t *obj)
if (obs_data_has_user_value(obj, "nestedMacro")) { if (obs_data_has_user_value(obj, "nestedMacro")) {
OBSDataAutoRelease nestedMacroData = OBSDataAutoRelease nestedMacroData =
obs_data_get_obj(obj, "nestedMacro"); obs_data_get_obj(obj, "nestedMacro");
_nestedMacro = std::make_shared<Macro>();
_nestedMacro->Load(nestedMacroData); _nestedMacro->Load(nestedMacroData);
} }
@@ -297,6 +310,15 @@ void MacroActionMacro::ResolveVariablesToFixedValues()
{ {
_actionIndex.ResolveVariables(); _actionIndex.ResolveVariables();
_label.ResolveVariables(); _label.ResolveVariables();
if (_action == Action::NESTED_MACRO) {
for (auto &action : _nestedMacro->Actions()) {
action->ResolveVariablesToFixedValues();
}
for (auto &action : _nestedMacro->ElseActions()) {
action->ResolveVariablesToFixedValues();
}
}
} }
static void runActionsHelper(Macro *macro, bool runElseActions, bool setInputs, static void runActionsHelper(Macro *macro, bool runElseActions, bool setInputs,
@@ -403,7 +425,9 @@ static void populateActionSelection(QComboBox *list)
{MacroActionMacro::Action::NESTED_MACRO, {MacroActionMacro::Action::NESTED_MACRO,
"AdvSceneSwitcher.action.macro.type.nestedMacro"}, "AdvSceneSwitcher.action.macro.type.nestedMacro"},
{MacroActionMacro::Action::RUN_ACTIONS, {MacroActionMacro::Action::RUN_ACTIONS,
"AdvSceneSwitcher.action.macro.type.run"}, "AdvSceneSwitcher.action.macro.type.runActions"},
{MacroActionMacro::Action::RUN_MACRO,
"AdvSceneSwitcher.action.macro.type.runMacro"},
{MacroActionMacro::Action::STOP, {MacroActionMacro::Action::STOP,
"AdvSceneSwitcher.action.macro.type.stop"}, "AdvSceneSwitcher.action.macro.type.stop"},
{MacroActionMacro::Action::DISABLE_ACTION, {MacroActionMacro::Action::DISABLE_ACTION,
@@ -483,6 +507,10 @@ MacroActionMacroEdit::MacroActionMacroEdit(
_actionSections(new QComboBox(this)), _actionSections(new QComboBox(this)),
_skipWhenPaused(new QCheckBox(obs_module_text( _skipWhenPaused(new QCheckBox(obs_module_text(
"AdvSceneSwitcher.action.macro.type.run.skipWhenPaused"))), "AdvSceneSwitcher.action.macro.type.run.skipWhenPaused"))),
_noConditionsWarning(new QLabel(obs_module_text(
"AdvSceneSwitcher.action.macro.type.runMacro.noConditionsWarning"))),
_runMacroHelp(new HelpIcon(obs_module_text(
"AdvSceneSwitcher.action.macro.type.runMacro.help"))),
_setInputs(new QCheckBox(obs_module_text( _setInputs(new QCheckBox(obs_module_text(
"AdvSceneSwitcher.action.macro.type.run.setInputs"))), "AdvSceneSwitcher.action.macro.type.run.setInputs"))),
_inputs(new MacroInputEdit()), _inputs(new MacroInputEdit()),
@@ -556,6 +584,7 @@ MacroActionMacroEdit::MacroActionMacroEdit(
layout->addLayout(_setInputsLayout); layout->addLayout(_setInputsLayout);
layout->addWidget(_inputs); layout->addWidget(_inputs);
layout->addWidget(_skipWhenPaused); layout->addWidget(_skipWhenPaused);
layout->addWidget(_noConditionsWarning);
layout->addWidget(_nestedMacro); layout->addWidget(_nestedMacro);
setLayout(layout); setLayout(layout);
_entryData = entryData; _entryData = entryData;
@@ -725,6 +754,7 @@ void MacroActionMacroEdit::InputsChanged(const StringList &inputs)
void MacroActionMacroEdit::SetWidgetVisibility() void MacroActionMacroEdit::SetWidgetVisibility()
{ {
_entryLayout->removeWidget(_actions); _entryLayout->removeWidget(_actions);
_entryLayout->removeWidget(_runMacroHelp);
_entryLayout->removeWidget(_actionIndex); _entryLayout->removeWidget(_actionIndex);
_entryLayout->removeWidget(_macros); _entryLayout->removeWidget(_macros);
_entryLayout->removeWidget(_actionSections); _entryLayout->removeWidget(_actionSections);
@@ -740,6 +770,7 @@ void MacroActionMacroEdit::SetWidgetVisibility()
const std::unordered_map<std::string, QWidget *> placeholders = { const std::unordered_map<std::string, QWidget *> placeholders = {
{"{{actions}}", _actions}, {"{{actions}}", _actions},
{"{{runMacroHelp}}", _runMacroHelp},
{"{{actionIndex}}", _actionIndex}, {"{{actionIndex}}", _actionIndex},
{"{{macros}}", _macros}, {"{{macros}}", _macros},
{"{{actionSections}}", _actionSections}, {"{{actionSections}}", _actionSections},
@@ -764,6 +795,9 @@ void MacroActionMacroEdit::SetWidgetVisibility()
case MacroActionMacro::Action::GET_INFO: case MacroActionMacro::Action::GET_INFO:
layoutText = "AdvSceneSwitcher.action.macro.layout.other"; layoutText = "AdvSceneSwitcher.action.macro.layout.other";
break; break;
case MacroActionMacro::Action::RUN_MACRO:
layoutText = "AdvSceneSwitcher.action.macro.layout.runMacro";
break;
case MacroActionMacro::Action::RUN_ACTIONS: case MacroActionMacro::Action::RUN_ACTIONS:
layoutText = "AdvSceneSwitcher.action.macro.layout.run"; layoutText = "AdvSceneSwitcher.action.macro.layout.run";
break; break;
@@ -790,7 +824,8 @@ void MacroActionMacroEdit::SetWidgetVisibility()
} }
if (action == MacroActionMacro::Action::RUN_ACTIONS || if (action == MacroActionMacro::Action::RUN_ACTIONS ||
action == MacroActionMacro::Action::STOP) { action == MacroActionMacro::Action::STOP ||
action == MacroActionMacro::Action::RUN_MACRO) {
_macros->HideSelectedMacro(); _macros->HideSelectedMacro();
} else { } else {
_macros->ShowAllMacros(); _macros->ShowAllMacros();
@@ -835,8 +870,19 @@ void MacroActionMacroEdit::SetWidgetVisibility()
_actionSections->setVisible( _actionSections->setVisible(
action == MacroActionMacro::Action::RUN_ACTIONS || action == MacroActionMacro::Action::RUN_ACTIONS ||
isModifyingActionState); isModifyingActionState);
_skipWhenPaused->setVisible(action == _skipWhenPaused->setVisible(
MacroActionMacro::Action::RUN_ACTIONS); action == MacroActionMacro::Action::RUN_ACTIONS ||
action == MacroActionMacro::Action::RUN_MACRO);
if (action == MacroActionMacro::Action::RUN_MACRO) {
auto macro = _entryData->_macro.GetMacro();
_noConditionsWarning->setVisible(!macro ||
macro->Conditions().empty());
} else {
_noConditionsWarning->setVisible(false);
}
_runMacroHelp->setVisible(action ==
MacroActionMacro::Action::RUN_MACRO);
_nestedMacro->setVisible(action == _nestedMacro->setVisible(action ==
MacroActionMacro::Action::NESTED_MACRO); MacroActionMacro::Action::NESTED_MACRO);

View File

@@ -11,6 +11,7 @@
#include <QCheckBox> #include <QCheckBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel>
namespace advss { namespace advss {
@@ -57,6 +58,7 @@ public:
TOGGLE_PAUSE, TOGGLE_PAUSE,
NESTED_MACRO, NESTED_MACRO,
GET_INFO, GET_INFO,
RUN_MACRO,
}; };
void SetAction(Action); void SetAction(Action);
@@ -131,6 +133,8 @@ private:
QCheckBox *_reevaluateConditionState; QCheckBox *_reevaluateConditionState;
QComboBox *_actionSections; QComboBox *_actionSections;
QCheckBox *_skipWhenPaused; QCheckBox *_skipWhenPaused;
QLabel *_noConditionsWarning;
HelpIcon *_runMacroHelp;
QCheckBox *_setInputs; QCheckBox *_setInputs;
MacroInputEdit *_inputs; MacroInputEdit *_inputs;
QHBoxLayout *_entryLayout; QHBoxLayout *_entryLayout;

View File

@@ -19,10 +19,11 @@ const std::string MacroActionVariable::id = "variable";
std::vector<TempVariableRef> MacroActionVariable::GetTempVarRefs() const std::vector<TempVariableRef> MacroActionVariable::GetTempVarRefs() const
{ {
if (!_tempVar.HasValidID()) { auto refs = MacroSegment::GetTempVarRefs();
return {}; if (_tempVar.HasValidID()) {
refs.push_back(_tempVar);
} }
return {_tempVar}; return refs;
} }
bool MacroActionVariable::_registered = MacroActionFactory::Register( bool MacroActionVariable::_registered = MacroActionFactory::Register(

View File

@@ -1,10 +1,12 @@
#include "macro-condition-edit.hpp" #include "macro-condition-edit.hpp"
#include "advanced-scene-switcher.hpp" #include "advanced-scene-switcher.hpp"
#include "macro-signals.hpp"
#include "macro-settings.hpp" #include "macro-settings.hpp"
#include "macro.hpp" #include "macro.hpp"
#include "path-helpers.hpp" #include "path-helpers.hpp"
#include "plugin-state-helpers.hpp" #include "plugin-state-helpers.hpp"
#include "section.hpp" #include "section.hpp"
#include "switch-button.hpp"
#include "ui-helpers.hpp" #include "ui-helpers.hpp"
#include "utility.hpp" #include "utility.hpp"
@@ -102,12 +104,15 @@ MacroConditionEdit::MacroConditionEdit(
QWidget *parent, std::shared_ptr<MacroCondition> *entryData, QWidget *parent, std::shared_ptr<MacroCondition> *entryData,
bool isRootCondition) bool isRootCondition)
: MacroSegmentEdit(parent), : MacroSegmentEdit(parent),
_enable(new SwitchButton()),
_logicSelection(new QComboBox()), _logicSelection(new QComboBox()),
_conditionSelection(new FilterComboBox()), _conditionSelection(new FilterComboBox()),
_dur(new DurationModifierEdit()), _dur(new DurationModifierEdit()),
_entryData(entryData), _entryData(entryData),
_isRoot(isRootCondition) _isRoot(isRootCondition)
{ {
QWidget::connect(_enable, SIGNAL(checked(bool)), this,
SLOT(ConditionEnableChanged(bool)));
QWidget::connect(_logicSelection, SIGNAL(currentIndexChanged(int)), QWidget::connect(_logicSelection, SIGNAL(currentIndexChanged(int)),
this, SLOT(LogicSelectionChanged(int))); this, SLOT(LogicSelectionChanged(int)));
QWidget::connect(_conditionSelection, QWidget::connect(_conditionSelection,
@@ -122,14 +127,17 @@ MacroConditionEdit::MacroConditionEdit(
Logic::PopulateLogicTypeSelection(_logicSelection, isRootCondition); Logic::PopulateLogicTypeSelection(_logicSelection, isRootCondition);
populateConditionSelection(_conditionSelection); populateConditionSelection(_conditionSelection);
_section->AddHeaderWidget(_enable);
_section->AddHeaderWidget(_logicSelection); _section->AddHeaderWidget(_logicSelection);
_section->AddHeaderWidget(_conditionSelection); _section->AddHeaderWidget(_conditionSelection);
_section->AddHeaderWidget(_headerInfo); _section->AddHeaderWidget(_headerInfo);
_section->AddHeaderWidget(_dur); _section->AddHeaderWidget(_dur);
_section->AddHeaderWidget(_varMappingToggle);
QVBoxLayout *conditionLayout = new QVBoxLayout; QVBoxLayout *conditionLayout = new QVBoxLayout;
conditionLayout->setContentsMargins({7, 7, 7, 7}); conditionLayout->setContentsMargins({7, 7, 7, 7});
conditionLayout->addWidget(_section); conditionLayout->addWidget(_section);
conditionLayout->addWidget(_outputMappings);
_contentLayout->addLayout(conditionLayout); _contentLayout->addLayout(conditionLayout);
QHBoxLayout *mainLayout = new QHBoxLayout; QHBoxLayout *mainLayout = new QHBoxLayout;
@@ -152,8 +160,17 @@ void MacroConditionEdit::LogicSelectionChanged(int idx)
const auto logic = static_cast<Logic::Type>( const auto logic = static_cast<Logic::Type>(
_logicSelection->itemData(idx).toInt()); _logicSelection->itemData(idx).toInt());
(*_entryData)->SetLogicType(logic); (*_entryData)->SetLogicType(logic);
}
SetEnableAppearance(logic != Logic::Type::NONE); void MacroConditionEdit::ConditionEnableChanged(bool value)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
(*_entryData)->SetEnabled(value);
SetDisableEffect(!value);
} }
bool MacroConditionEdit::IsRootNode() const bool MacroConditionEdit::IsRootNode() const
@@ -166,7 +183,9 @@ void MacroConditionEdit::SetLogicSelection()
const auto logic = (*_entryData)->GetLogicType(); const auto logic = (*_entryData)->GetLogicType();
_logicSelection->setCurrentIndex( _logicSelection->setCurrentIndex(
_logicSelection->findData(static_cast<int>(logic))); _logicSelection->findData(static_cast<int>(logic)));
SetEnableAppearance(logic != Logic::Type::NONE); const bool enabled = (*_entryData)->Enabled();
_enable->setChecked(enabled);
SetEnableAppearance(enabled);
} }
void MacroConditionEdit::SetRootNode(bool root) void MacroConditionEdit::SetRootNode(bool root)
@@ -204,7 +223,10 @@ void MacroConditionEdit::SetupWidgets(bool basicSetup)
MacroConditionFactory::CreateWidget(id, this, *_entryData); MacroConditionFactory::CreateWidget(id, this, *_entryData);
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)), QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
this, SLOT(HeaderInfoChanged(const QString &))); this, SLOT(HeaderInfoChanged(const QString &)));
QWidget::connect(widget, SIGNAL(ShowVariableMappings(bool)), this,
SLOT(ShowVariableMappings(bool)));
_section->SetContent(widget, (*_entryData)->GetCollapsed()); _section->SetContent(widget, (*_entryData)->GetCollapsed());
SetupVarMappings((*_entryData).get());
SetFocusPolicyOfWidgets(); SetFocusPolicyOfWidgets();
_allWidgetsAreSetup = true; _allWidgetsAreSetup = true;
@@ -234,10 +256,12 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
{ {
auto lock = LockContext(); auto lock = LockContext();
auto logic = (*_entryData)->GetLogicType(); auto logic = (*_entryData)->GetLogicType();
const bool enabled = (*_entryData)->Enabled();
_entryData->reset(); _entryData->reset();
*_entryData = MacroConditionFactory::Create(id, macro); *_entryData = MacroConditionFactory::Create(id, macro);
(*_entryData)->SetIndex(idx); (*_entryData)->SetIndex(idx);
(*_entryData)->SetLogicType(logic); (*_entryData)->SetLogicType(logic);
(*_entryData)->SetEnabled(enabled);
(*_entryData)->PostLoad(); (*_entryData)->PostLoad();
RunAndClearPostLoadSteps(); RunAndClearPostLoadSteps();
} }
@@ -245,9 +269,15 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
MacroConditionFactory::CreateWidget(id, this, *_entryData); MacroConditionFactory::CreateWidget(id, this, *_entryData);
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)), QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
this, SLOT(HeaderInfoChanged(const QString &))); this, SLOT(HeaderInfoChanged(const QString &)));
QWidget::connect(widget, SIGNAL(ShowVariableMappings(bool)), this,
SLOT(ShowVariableMappings(bool)));
_section->SetContent(widget); _section->SetContent(widget);
SetupVarMappings((*_entryData).get());
_dur->setVisible(MacroConditionFactory::UsesDurationModifier(id)); _dur->setVisible(MacroConditionFactory::UsesDurationModifier(id));
SetFocusPolicyOfWidgets(); SetFocusPolicyOfWidgets();
emit MacroSignalManager::Instance()->ConditionTypeCreated(
QString::fromStdString(id));
} }
void MacroConditionEdit::DurationChanged(const Duration &seconds) void MacroConditionEdit::DurationChanged(const Duration &seconds)
@@ -275,4 +305,9 @@ std::shared_ptr<MacroSegment> MacroConditionEdit::Data() const
return *_entryData; return *_entryData;
} }
void MacroConditionEdit::FocusTypeSelection()
{
_conditionSelection->setFocus();
}
} // namespace advss } // namespace advss

View File

@@ -8,6 +8,8 @@
namespace advss { namespace advss {
class SwitchButton;
class DurationModifierEdit : public QWidget { class DurationModifierEdit : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
@@ -41,17 +43,20 @@ public:
void SetRootNode(bool); void SetRootNode(bool);
void SetupWidgets(bool basicSetup = false); void SetupWidgets(bool basicSetup = false);
void SetEntryData(std::shared_ptr<MacroCondition> *); void SetEntryData(std::shared_ptr<MacroCondition> *);
void FocusTypeSelection() override;
private slots: private slots:
void LogicSelectionChanged(int idx); void LogicSelectionChanged(int idx);
void ConditionSelectionChanged(const QString &text); void ConditionSelectionChanged(const QString &text);
void DurationChanged(const Duration &value); void DurationChanged(const Duration &value);
void DurationModifierChanged(DurationModifier::Type m); void DurationModifierChanged(DurationModifier::Type m);
void ConditionEnableChanged(bool);
private: private:
void SetLogicSelection(); void SetLogicSelection();
std::shared_ptr<MacroSegment> Data() const; std::shared_ptr<MacroSegment> Data() const;
SwitchButton *_enable;
QComboBox *_logicSelection; QComboBox *_logicSelection;
FilterComboBox *_conditionSelection; FilterComboBox *_conditionSelection;
DurationModifierEdit *_dur; DurationModifierEdit *_dur;

View File

@@ -8,10 +8,11 @@ const std::string MacroConditionTempVar::id = "temp_var";
std::vector<TempVariableRef> MacroConditionTempVar::GetTempVarRefs() const std::vector<TempVariableRef> MacroConditionTempVar::GetTempVarRefs() const
{ {
if (!_tempVar.HasValidID()) { auto refs = MacroSegment::GetTempVarRefs();
return {}; if (_tempVar.HasValidID()) {
refs.push_back(_tempVar);
} }
return {_tempVar}; return refs;
} }
bool MacroConditionTempVar::_registered = MacroConditionFactory::Register( bool MacroConditionTempVar::_registered = MacroConditionFactory::Register(

View File

@@ -31,6 +31,10 @@ bool MacroCondition::Load(obs_data_t *obj)
{ {
MacroSegment::Load(obj); MacroSegment::Load(obj);
_logic.Load(obj, "logic"); _logic.Load(obj, "logic");
if (_logic.GetType() == Logic::Type::NONE) {
SetEnabled(false);
_logic.SetType(Logic::Type::AND);
}
_durationModifier.Load(obj); _durationModifier.Load(obj);
return true; return true;
} }
@@ -50,7 +54,8 @@ void MacroCondition::ValidateLogicSelection(bool isRootCondition,
return; return;
} }
_logic.SetType(Logic::Type::NONE); _logic.SetType(Logic::Type::AND);
SetEnabled(false);
blog(LOG_WARNING, blog(LOG_WARNING,
"setting invalid logic selection to 'ignore' for macro %s", "setting invalid logic selection to 'ignore' for macro %s",
context); context);

View File

@@ -650,6 +650,18 @@ void MacroEdit::HighlightCondition(int idx, QColor color) const
ui->conditionsList->Highlight(idx, color); ui->conditionsList->Highlight(idx, color);
} }
void MacroEdit::ScrollAndFocusNewSegment(MacroSegmentList *list, int newIdx,
int *currentIdx)
{
QTimer::singleShot(0, this, [this, list, newIdx, currentIdx]() {
list->ensureWidgetVisible(list->WidgetAt(*currentIdx));
auto *widget = list->WidgetAt(newIdx);
if (widget) {
widget->FocusTypeSelection();
}
});
}
static void resetSegmentHighlights(MacroSegmentList *list) static void resetSegmentHighlights(MacroSegmentList *list)
{ {
MacroSegmentEdit *widget = nullptr; MacroSegmentEdit *widget = nullptr;
@@ -1087,10 +1099,7 @@ void MacroEdit::AddMacroAction(Macro *macro, int idx, const std::string &id,
ui->actionsList->SetHelpMsgVisible(false); ui->actionsList->SetHelpMsgVisible(false);
emit(MacroSegmentOrderChanged()); emit(MacroSegmentOrderChanged());
QTimer::singleShot(0, this, [this]() { ScrollAndFocusNewSegment(ui->actionsList, idx, &currentActionIdx);
ui->actionsList->ensureWidgetVisible(
ui->actionsList->WidgetAt(currentActionIdx));
});
} }
void MacroEdit::AddMacroAction(int idx) void MacroEdit::AddMacroAction(int idx)
@@ -1118,6 +1127,9 @@ void MacroEdit::AddMacroAction(int idx)
macro->Actions().at(idx - 1)->Save(data); macro->Actions().at(idx - 1)->Save(data);
} }
AddMacroAction(macro.get(), idx, id, data); AddMacroAction(macro.get(), idx, id, data);
if (idx < (int)macro->Actions().size()) {
macro->Actions().at(idx)->FixupVarMappingRefs();
}
} }
void MacroEdit::on_actionAdd_clicked() void MacroEdit::on_actionAdd_clicked()
@@ -1395,10 +1407,8 @@ void MacroEdit::AddMacroElseAction(Macro *macro, int idx, const std::string &id,
ui->elseActionsList->SetHelpMsgVisible(false); ui->elseActionsList->SetHelpMsgVisible(false);
emit(MacroSegmentOrderChanged()); emit(MacroSegmentOrderChanged());
QTimer::singleShot(0, this, [this]() { ScrollAndFocusNewSegment(ui->elseActionsList, idx,
ui->elseActionsList->ensureWidgetVisible( &currentElseActionIdx);
ui->elseActionsList->WidgetAt(currentElseActionIdx));
});
} }
void MacroEdit::AddMacroElseAction(int idx) void MacroEdit::AddMacroElseAction(int idx)
@@ -1426,6 +1436,9 @@ void MacroEdit::AddMacroElseAction(int idx)
macro->ElseActions().at(idx - 1)->Save(data); macro->ElseActions().at(idx - 1)->Save(data);
} }
AddMacroElseAction(macro.get(), idx, id, data); AddMacroElseAction(macro.get(), idx, id, data);
if (idx < (int)macro->ElseActions().size()) {
macro->ElseActions().at(idx)->FixupVarMappingRefs();
}
} }
void MacroEdit::RemoveMacroElseAction(int idx) void MacroEdit::RemoveMacroElseAction(int idx)
@@ -1570,6 +1583,9 @@ void MacroEdit::AddMacroCondition(int idx)
macro->Conditions().at(idx - 1)->Save(data); macro->Conditions().at(idx - 1)->Save(data);
} }
AddMacroCondition(macro.get(), idx, id, data.Get(), logic); AddMacroCondition(macro.get(), idx, id, data.Get(), logic);
if (idx < (int)macro->Conditions().size()) {
macro->Conditions().at(idx)->FixupVarMappingRefs();
}
} }
void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id, void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
@@ -1602,10 +1618,7 @@ void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
ui->conditionsList->SetHelpMsgVisible(false); ui->conditionsList->SetHelpMsgVisible(false);
emit(MacroSegmentOrderChanged()); emit(MacroSegmentOrderChanged());
QTimer::singleShot(0, this, [this]() { ScrollAndFocusNewSegment(ui->conditionsList, idx, &currentConditionIdx);
ui->conditionsList->ensureWidgetVisible(
ui->conditionsList->WidgetAt(currentConditionIdx));
});
} }
void MacroEdit::on_conditionAdd_clicked() void MacroEdit::on_conditionAdd_clicked()

View File

@@ -116,6 +116,8 @@ private:
void PopulateMacroActions(Macro &m, uint32_t afterIdx = 0); void PopulateMacroActions(Macro &m, uint32_t afterIdx = 0);
void PopulateMacroElseActions(Macro &m, uint32_t afterIdx = 0); void PopulateMacroElseActions(Macro &m, uint32_t afterIdx = 0);
void PopulateMacroConditions(Macro &m, uint32_t afterIdx = 0); void PopulateMacroConditions(Macro &m, uint32_t afterIdx = 0);
void ScrollAndFocusNewSegment(MacroSegmentList *list, int newIdx,
int *currentIdx);
void SetupMacroSegmentSelection(MacroSection type, int idx); void SetupMacroSegmentSelection(MacroSection type, int idx);
void void
SetupContextMenu(const QPoint &pos, SetupContextMenu(const QPoint &pos,

View File

@@ -0,0 +1,89 @@
#include "macro-export-extensions.hpp"
#include "action-queue.hpp"
#include "variable.hpp"
#include <obs.hpp>
namespace advss {
static bool setup();
static bool setupDone = setup();
static bool setup()
{
// --- Variables ---
AddMacroExportExtension(
{"AdvSceneSwitcher.macroTab.export.variables", "variables",
[](obs_data_t *data, const QStringList &selectedIds) {
if (selectedIds.isEmpty()) {
SaveVariables(data);
return;
}
OBSDataArrayAutoRelease array =
obs_data_array_create();
for (const auto &v : GetVariables()) {
const QString name =
QString::fromStdString(v->Name());
if (!selectedIds.contains(name)) {
continue;
}
OBSDataAutoRelease item = obs_data_create();
v->Save(item);
obs_data_array_push_back(array, item);
}
obs_data_set_array(data, "variables", array);
},
[](obs_data_t *data, const QStringList &) {
ImportVariables(data);
},
[]() -> QList<QPair<QString, QString>> {
QList<QPair<QString, QString>> items;
for (const auto &v : GetVariables()) {
const QString name =
QString::fromStdString(v->Name());
items.append({name, name});
}
return items;
}});
// --- Action Queues ---
AddMacroExportExtension(
{"AdvSceneSwitcher.macroTab.export.actionQueues",
"actionQueues",
[](obs_data_t *data, const QStringList &selectedIds) {
if (selectedIds.isEmpty()) {
SaveActionQueues(data);
return;
}
OBSDataArrayAutoRelease array =
obs_data_array_create();
for (const auto &q : GetActionQueues()) {
const QString name =
QString::fromStdString(q->Name());
if (!selectedIds.contains(name)) {
continue;
}
OBSDataAutoRelease item = obs_data_create();
q->Save(item);
obs_data_array_push_back(array, item);
}
obs_data_set_array(data, "actionQueues", array);
},
[](obs_data_t *data, const QStringList &) {
ImportQueues(data);
},
[]() -> QList<QPair<QString, QString>> {
QList<QPair<QString, QString>> items;
for (const auto &q : GetActionQueues()) {
const QString name =
QString::fromStdString(q->Name());
items.append({name, name});
}
return items;
}});
return true;
}
} // namespace advss

View File

@@ -0,0 +1,17 @@
#include "macro-export-extensions.hpp"
namespace advss {
static std::vector<MacroExportExtension> extensions;
void AddMacroExportExtension(const MacroExportExtension &ext)
{
extensions.emplace_back(ext);
}
const std::vector<MacroExportExtension> &GetMacroExportExtensions()
{
return extensions;
}
} // namespace advss

View File

@@ -0,0 +1,41 @@
#pragma once
#include "export-symbol-helper.hpp"
#include <functional>
#include <obs-data.h>
#include <QList>
#include <QPair>
#include <QString>
#include <vector>
namespace advss {
struct MacroExportExtension {
const char *displayNameKey;
const char *jsonKey;
// Export callback.
// Write content into 'data'. 'selectedIds' contains the item IDs the
// user explicitly checked; if empty (no per-item widget provided) save
// everything.
std::function<void(obs_data_t *data, const QStringList &selectedIds)>
save;
// Import callback.
// Read content from 'data'. 'selectedIds' contains the item IDs the
// user explicitly checked; if empty import every item found in 'data'.
std::function<void(obs_data_t *data, const QStringList &selectedIds)>
load;
// Optional: enumerate items available for export as (id, displayName)
// pairs. When nullptr the extension appears as a single all-or-nothing
// checkbox in the export dialog.
std::function<QList<QPair<QString, QString>>()> getExportItems =
nullptr;
};
EXPORT void AddMacroExportExtension(const MacroExportExtension &ext);
const std::vector<MacroExportExtension> &GetMacroExportExtensions();
} // namespace advss

View File

@@ -1,22 +1,183 @@
#include "macro-export-import-dialog.hpp" #include "macro-export-import-dialog.hpp"
#include "macro-export-extensions.hpp"
#include "obs-module-helper.hpp" #include "obs-module-helper.hpp"
#include "section.hpp"
#include <obs.hpp> #include <obs.hpp>
#include <QLayout>
#include <QLabel>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QLabel>
#include <QLayout>
#include <QScrollArea>
#include <QSplitter>
#include <algorithm>
#include <numeric>
namespace advss { namespace advss {
static bool usePlainText = false; static bool usePlainText = false;
MacroExportImportDialog::MacroExportImportDialog(Type type) // ---------------------------------------------------------------------------
// Compress / decompress helpers
// ---------------------------------------------------------------------------
static QString compressMacroString(const QString &input)
{
QByteArray inputData = input.toUtf8();
auto compressedData = qCompress(inputData);
QByteArray encodedData = compressedData.toBase64();
return QString::fromUtf8(encodedData);
}
static QString decompressMacroString(const QString &input)
{
QByteArray encodedData = input.toUtf8();
QByteArray compressedData = QByteArray::fromBase64(encodedData);
auto outputData = qUncompress(compressedData);
return QString::fromUtf8(outputData);
}
static bool isValidData(const QString &json)
{
OBSDataAutoRelease data =
obs_data_create_from_json(json.toStdString().c_str());
return !!data;
}
// ---------------------------------------------------------------------------
// Extension section
// ---------------------------------------------------------------------------
QWidget *MacroExportImportDialog::BuildExtensionWidget()
{
auto wrapper = new QWidget(this);
auto wrapperLayout = new QVBoxLayout(wrapper);
wrapperLayout->setContentsMargins(0, 0, 0, 0);
wrapperLayout->setSpacing(4);
wrapperLayout->addWidget(new QLabel(obs_module_text(
"AdvSceneSwitcher.macroTab.export.additionalContent")));
auto outerContent = new QWidget();
auto outerLayout = new QVBoxLayout(outerContent);
outerLayout->setContentsMargins(4, 4, 4, 4);
outerLayout->setSpacing(4);
const auto &extensions = GetMacroExportExtensions();
std::vector<int> order(extensions.size());
std::iota(order.begin(), order.end(), 0);
std::sort(order.begin(), order.end(), [&](int a, int b) {
return QString::localeAwareCompare(
obs_module_text(extensions[a].displayNameKey),
obs_module_text(extensions[b].displayNameKey)) <
0;
});
for (int extIdx : order) {
const auto &ext = extensions[extIdx];
ExtensionUI ui;
// Simple all-or-nothing checkbox (no sub-items).
if (!ext.getExportItems) {
ui.mainCheck = new QCheckBox(
obs_module_text(ext.displayNameKey),
outerContent);
ui.mainCheck->setChecked(false);
connect(ui.mainCheck, &QCheckBox::stateChanged, this,
&MacroExportImportDialog::UpdateExportString);
outerLayout->addWidget(ui.mainCheck);
_extensionUIs.append(std::move(ui));
_extensionOrder.push_back(extIdx);
continue;
}
// Extensions with per-item selection get their own inner
// Section: the main checkbox sits in the header (next to the
// toggle arrow) and the per-item checkboxes live in the
// collapsible content area.
auto items = ext.getExportItems();
if (items.isEmpty()) {
continue;
}
std::sort(items.begin(), items.end(),
[](const QPair<QString, QString> &a,
const QPair<QString, QString> &b) {
return QString::localeAwareCompare(
a.second, b.second) < 0;
});
auto innerSection = new Section(200, outerContent);
ui.mainCheck =
new QCheckBox(obs_module_text(ext.displayNameKey));
ui.mainCheck->setChecked(false);
innerSection->AddHeaderWidget(ui.mainCheck);
auto subWidget = new QWidget();
auto subLayout = new QVBoxLayout(subWidget);
subLayout->setContentsMargins(4, 2, 4, 2);
subLayout->setSpacing(2);
for (const auto &[id, displayName] : items) {
auto cb = new QCheckBox(displayName, subWidget);
cb->setChecked(false);
subLayout->addWidget(cb);
ui.itemChecks.append({id, cb});
connect(cb, &QCheckBox::stateChanged, this,
&MacroExportImportDialog::UpdateExportString);
}
// Main checkbox toggles all sub-items.
// Capture uiIdx (position in _extensionUIs after append).
const int uiIdx = _extensionUIs.size();
connect(ui.mainCheck, &QCheckBox::stateChanged, this,
[this, uiIdx](int state) {
if (state == Qt::PartiallyChecked)
return;
const bool checked = (state == Qt::Checked);
if (uiIdx < _extensionUIs.size()) {
for (auto &[id, cb] :
_extensionUIs[uiIdx].itemChecks) {
QSignalBlocker b(cb);
cb->setChecked(checked);
}
}
UpdateExportString();
});
innerSection->SetContent(subWidget, true);
outerLayout->addWidget(innerSection);
_extensionUIs.append(std::move(ui));
_extensionOrder.push_back(extIdx);
}
outerLayout->addStretch();
auto scrollArea = new QScrollArea(wrapper);
scrollArea->setWidget(outerContent);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setFrameShape(QFrame::NoFrame);
wrapperLayout->addWidget(scrollArea);
return wrapper;
}
// ---------------------------------------------------------------------------
// Constructor
// ---------------------------------------------------------------------------
MacroExportImportDialog::MacroExportImportDialog(Type type,
const QString &baseJson)
: QDialog(nullptr), : QDialog(nullptr),
_baseJson(baseJson),
_importExportString(new QPlainTextEdit(this)), _importExportString(new QPlainTextEdit(this)),
_usePlainText(new QCheckBox(obs_module_text( _usePlainText(new QCheckBox(obs_module_text(
"AdvSceneSwitcher.macroTab.export.usePlainText"))) "AdvSceneSwitcher.macroTab.export.usePlainText")))
{ {
_importExportString->setReadOnly(type == Type::EXPORT_MACRO); _importExportString->setReadOnly(type == Type::EXPORT_MACRO);
auto label = new QLabel(obs_module_text( auto label = new QLabel(obs_module_text(
type == Type::EXPORT_MACRO type == Type::EXPORT_MACRO
? "AdvSceneSwitcher.macroTab.export.info" ? "AdvSceneSwitcher.macroTab.export.info"
@@ -39,40 +200,90 @@ MacroExportImportDialog::MacroExportImportDialog(Type type)
connect(_usePlainText, &QCheckBox::stateChanged, this, connect(_usePlainText, &QCheckBox::stateChanged, this,
&MacroExportImportDialog::UsePlainTextChanged); &MacroExportImportDialog::UsePlainTextChanged);
auto layout = new QVBoxLayout; auto layout = new QVBoxLayout(this);
layout->addWidget(label);
layout->addWidget(_importExportString); if (type == Type::EXPORT_MACRO && !GetMacroExportExtensions().empty()) {
layout->addWidget(_usePlainText); auto splitter = new QSplitter(Qt::Vertical, this);
splitter->setChildrenCollapsible(false);
splitter->addWidget(BuildExtensionWidget());
auto textWidget = new QWidget(splitter);
auto textLayout = new QVBoxLayout(textWidget);
textLayout->setContentsMargins(0, 0, 0, 0);
textLayout->addWidget(label);
textLayout->addWidget(_importExportString);
textLayout->addWidget(_usePlainText);
splitter->addWidget(textWidget);
layout->addWidget(splitter);
} else {
layout->addWidget(label);
layout->addWidget(_importExportString);
layout->addWidget(_usePlainText);
}
layout->addWidget(buttons); layout->addWidget(buttons);
setLayout(layout); setLayout(layout);
setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle")); setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
if (type == Type::EXPORT_MACRO) {
RefreshExportText();
}
} }
QString compressMacroString(const QString &input) // ---------------------------------------------------------------------------
// Export string helpers
// ---------------------------------------------------------------------------
QString MacroExportImportDialog::BuildExportJson() const
{ {
QByteArray inputData = input.toUtf8(); OBSDataAutoRelease data =
auto compressedData = qCompress(inputData); obs_data_create_from_json(_baseJson.toStdString().c_str());
QByteArray encodedData = compressedData.toBase64(); if (!data) {
return QString::fromUtf8(encodedData); return _baseJson;
}
const auto &extensions = GetMacroExportExtensions();
for (int i = 0; i < (int)_extensionUIs.size(); ++i) {
const auto &ui = _extensionUIs[i];
QStringList selectedIds;
if (ui.itemChecks.isEmpty()) {
if (!ui.mainCheck->isChecked()) {
continue;
}
} else {
for (const auto &[id, cb] : ui.itemChecks) {
if (cb->isChecked()) {
selectedIds << id;
}
}
if (selectedIds.isEmpty()) {
continue;
}
}
extensions[_extensionOrder[i]].save(data, selectedIds);
}
const char *json = obs_data_get_json(data);
return json ? QString::fromUtf8(json) : QString{};
} }
QString decompressMacroString(const QString &input) void MacroExportImportDialog::RefreshExportText()
{ {
QByteArray encodedData = input.toUtf8(); const QString json = BuildExportJson();
QByteArray compressedData = QByteArray::fromBase64(encodedData); if (usePlainText) {
auto outputData = qUncompress(compressedData); _importExportString->setPlainText(json);
return QString::fromUtf8(outputData); } else {
_importExportString->setPlainText(compressMacroString(json));
}
} }
void MacroExportImportDialog::ExportMacros(const QString &json) void MacroExportImportDialog::UpdateExportString()
{ {
MacroExportImportDialog dialog( RefreshExportText();
MacroExportImportDialog::Type::EXPORT_MACRO);
dialog._importExportString->setPlainText(compressMacroString(json));
dialog.adjustSize();
dialog.updateGeometry();
dialog.exec();
} }
void MacroExportImportDialog::UsePlainTextChanged(int value) void MacroExportImportDialog::UsePlainTextChanged(int value)
@@ -90,26 +301,45 @@ void MacroExportImportDialog::UsePlainTextChanged(int value)
usePlainText = value; usePlainText = value;
} }
static bool isValidData(const QString &json) // ---------------------------------------------------------------------------
// Static entry points
// ---------------------------------------------------------------------------
void MacroExportImportDialog::ExportMacros(obs_data_t *macroData)
{ {
OBSDataAutoRelease data = const char *rawJson = obs_data_get_json(macroData);
obs_data_create_from_json(json.toStdString().c_str()); const QString baseJson = rawJson ? QString::fromUtf8(rawJson)
return !!data; : QString{};
MacroExportImportDialog dialog(Type::EXPORT_MACRO, baseJson);
dialog.adjustSize();
dialog.updateGeometry();
dialog.exec();
} }
bool MacroExportImportDialog::ImportMacros(QString &json) bool MacroExportImportDialog::ImportMacros(QString &json)
{ {
MacroExportImportDialog dialog( MacroExportImportDialog dialog(Type::IMPORT_MACRO);
MacroExportImportDialog::Type::IMPORT_MACRO); if (dialog.exec() != QDialog::Accepted) {
if (dialog.exec() == QDialog::Accepted) { return false;
json = decompressMacroString(
dialog._importExportString->toPlainText());
if (!isValidData(json)) { // Fallback to support raw json format
json = dialog._importExportString->toPlainText();
}
return true;
} }
return false;
json = decompressMacroString(dialog._importExportString->toPlainText());
if (!isValidData(json)) {
// Fallback: support raw (uncompressed) JSON pasted directly.
json = dialog._importExportString->toPlainText();
}
// Invoke all extension load callbacks.
OBSDataAutoRelease data =
obs_data_create_from_json(json.toStdString().c_str());
if (data) {
for (const auto &ext : GetMacroExportExtensions()) {
ext.load(data, {});
}
}
return true;
} }
} // namespace advss } // namespace advss

View File

@@ -1,25 +1,47 @@
#pragma once #pragma once
#include <QCheckBox> #include <QCheckBox>
#include <QDialog> #include <QDialog>
#include <QList>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <obs-data.h>
#include <vector>
namespace advss { namespace advss {
class MacroExportImportDialog : public QDialog { class MacroExportImportDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
enum class Type { EXPORT_MACRO, IMPORT_MACRO }; enum class Type { EXPORT_MACRO, IMPORT_MACRO };
MacroExportImportDialog(Type type);
static void ExportMacros(const QString &json); static void ExportMacros(obs_data_t *macroData);
static bool ImportMacros(QString &json); static bool ImportMacros(QString &json);
private slots: private slots:
void UsePlainTextChanged(int); void UsePlainTextChanged(int);
void UpdateExportString();
private: private:
explicit MacroExportImportDialog(Type type,
const QString &baseJson = {});
// Per-extension widgets
struct ExtensionUI {
QCheckBox *mainCheck = nullptr;
// (itemId, checkbox) pairs - empty when no per-item selection.
QList<QPair<QString, QCheckBox *>> itemChecks;
};
QWidget *BuildExtensionWidget();
QString BuildExportJson() const;
void RefreshExportText();
QString _baseJson;
QPlainTextEdit *_importExportString; QPlainTextEdit *_importExportString;
QCheckBox *_usePlainText; QCheckBox *_usePlainText;
QList<ExtensionUI> _extensionUIs;
std::vector<int> _extensionOrder;
}; };
} // namespace advss } // namespace advss

View File

@@ -214,6 +214,20 @@ bool MacroIsPaused(const Macro *macro)
return macro ? macro->Paused() : true; return macro ? macro->Paused() : true;
} }
void SetMacroPaused(Macro *macro, bool paused)
{
if (macro) {
macro->SetPaused(paused);
}
}
void StopMacro(Macro *macro)
{
if (macro) {
macro->Stop();
}
}
bool MacroWasPausedSince( bool MacroWasPausedSince(
const Macro *macro, const Macro *macro,
const std::chrono::high_resolution_clock::time_point &time) const std::chrono::high_resolution_clock::time_point &time)
@@ -237,14 +251,20 @@ void AddMacroHelperThread(Macro *macro, std::thread &&newThread)
macro->AddHelperThread(std::move(newThread)); macro->AddHelperThread(std::move(newThread));
} }
bool RunMacroActions(Macro *macro) bool RunMacroActions(Macro *macro, bool forceParallel, bool ignorePause)
{ {
return macro && macro->PerformActions(true); return macro && macro->PerformActions(true, forceParallel, ignorePause);
} }
bool RunMacroElseActions(Macro *macro) bool RunMacroElseActions(Macro *macro, bool forceParallel, bool ignorePause)
{ {
return macro && macro->PerformActions(false); return macro &&
macro->PerformActions(false, forceParallel, ignorePause);
}
bool CheckMacroConditions(Macro *macro, bool ignorePause)
{
return macro && macro->CheckConditions(ignorePause);
} }
void ResetMacroConditionTimers(Macro *macro) void ResetMacroConditionTimers(Macro *macro)

View File

@@ -58,6 +58,8 @@ LastMacroConditionCheckTime(const Macro *);
EXPORT bool MacroIsStopped(const Macro *); EXPORT bool MacroIsStopped(const Macro *);
EXPORT bool MacroIsPaused(const Macro *); EXPORT bool MacroIsPaused(const Macro *);
EXPORT void SetMacroPaused(Macro *, bool paused);
EXPORT void StopMacro(Macro *);
EXPORT bool EXPORT bool
MacroWasPausedSince(const Macro *, MacroWasPausedSince(const Macro *,
const std::chrono::high_resolution_clock::time_point &); const std::chrono::high_resolution_clock::time_point &);
@@ -66,11 +68,16 @@ EXPORT bool MacroWasCheckedSinceLastStart(const Macro *);
EXPORT void AddMacroHelperThread(Macro *, std::thread &&); EXPORT void AddMacroHelperThread(Macro *, std::thread &&);
EXPORT bool CheckMacros(); EXPORT bool CheckMacros();
EXPORT bool CheckMacroConditions(Macro *, bool ignorePause = false);
EXPORT bool RunMacroActions(Macro *); EXPORT bool RunMacroActions(Macro *, bool forceParallel = false,
bool RunMacroElseActions(Macro *); bool ignorePause = false);
EXPORT bool RunMacroElseActions(Macro *, bool forceParallel = false,
bool ignorePause = false);
EXPORT bool RunMacros(); EXPORT bool RunMacros();
void StopAllMacros();
void SignalStopAllMacros();
void WaitForAllMacros();
EXPORT void LoadMacros(obs_data_t *obj); EXPORT void LoadMacros(obs_data_t *obj);
EXPORT void SaveMacros(obs_data_t *obj); EXPORT void SaveMacros(obs_data_t *obj);

View File

@@ -1,6 +1,8 @@
#include "macro-ref.hpp" #include "macro-ref.hpp"
#include "macro.hpp" #include "macro.hpp"
#include "plugin-state-helpers.hpp"
namespace advss { namespace advss {
MacroRef::MacroRef(std::string name) MacroRef::MacroRef(std::string name)
@@ -19,6 +21,7 @@ void MacroRef::Load(obs_data_t *obj)
auto name = obs_data_get_string(obj, "macro"); auto name = obs_data_get_string(obj, "macro");
_postLoadName = name; _postLoadName = name;
_macro = GetWeakMacroByName(name); _macro = GetWeakMacroByName(name);
AddPostLoadStep([this]() { MacroRef::PostLoad(); });
} }
void MacroRef::PostLoad() void MacroRef::PostLoad()
@@ -71,11 +74,11 @@ void LoadMacroList(obs_data_t *obj, std::vector<MacroRef> &macros,
{ {
obs_data_array_t *array = obs_data_get_array(obj, name.c_str()); obs_data_array_t *array = obs_data_get_array(obj, name.c_str());
size_t count = obs_data_array_count(array); size_t count = obs_data_array_count(array);
macros.reserve(macros.size() + count);
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
obs_data_t *array_obj = obs_data_array_item(array, i); obs_data_t *array_obj = obs_data_array_item(array, i);
MacroRef ref; macros.emplace_back();
ref.Load(array_obj); macros.back().Load(array_obj);
macros.push_back(ref);
obs_data_release(array_obj); obs_data_release(array_obj);
} }
obs_data_array_release(array); obs_data_array_release(array);

View File

@@ -72,15 +72,24 @@ void MacroEdit::PasteMacroSegment()
} }
AddMacroCondition(macro.get(), macro->Conditions().size(), AddMacroCondition(macro.get(), macro->Conditions().size(),
copyInfo.segment->GetId(), data.Get(), logic); copyInfo.segment->GetId(), data.Get(), logic);
if (!macro->Conditions().empty()) {
macro->Conditions().back()->FixupVarMappingRefs();
}
break; break;
} }
case MacroSegmentCopyInfo::Type::ACTION: case MacroSegmentCopyInfo::Type::ACTION:
AddMacroAction(macro.get(), macro->Actions().size(), AddMacroAction(macro.get(), macro->Actions().size(),
copyInfo.segment->GetId(), data.Get()); copyInfo.segment->GetId(), data.Get());
if (!macro->Actions().empty()) {
macro->Actions().back()->FixupVarMappingRefs();
}
break; break;
case MacroSegmentCopyInfo::Type::ELSE: case MacroSegmentCopyInfo::Type::ELSE:
AddMacroElseAction(macro.get(), macro->ElseActions().size(), AddMacroElseAction(macro.get(), macro->ElseActions().size(),
copyInfo.segment->GetId(), data.Get()); copyInfo.segment->GetId(), data.Get());
if (!macro->ElseActions().empty()) {
macro->ElseActions().back()->FixupVarMappingRefs();
}
break; break;
default: default:
break; break;

View File

@@ -1,8 +1,10 @@
#include "macro-segment.hpp" #include "macro-segment.hpp"
#include "macro.hpp" #include "macro.hpp"
#include "mouse-wheel-guard.hpp" #include "mouse-wheel-guard.hpp"
#include "path-helpers.hpp"
#include "section.hpp" #include "section.hpp"
#include "ui-helpers.hpp" #include "ui-helpers.hpp"
#include "variable.hpp"
#include <QApplication> #include <QApplication>
#include <QEvent> #include <QEvent>
@@ -15,7 +17,65 @@ namespace advss {
std::vector<TempVariableRef> MacroSegment::GetTempVarRefs() const std::vector<TempVariableRef> MacroSegment::GetTempVarRefs() const
{ {
return {}; std::vector<TempVariableRef> refs;
for (const auto &mapping : _varMappings) {
if (mapping.tempVar.HasValidID()) {
refs.push_back(mapping.tempVar);
}
}
return refs;
}
void MacroSegment::ApplyVarMappings()
{
auto macro = GetMacro();
for (const auto &mapping : _varMappings) {
auto var = mapping.variable.lock();
if (!var) {
continue;
}
const auto tempVar = mapping.tempVar.GetTempVariable(macro);
if (!tempVar) {
continue;
}
const auto value = tempVar->Value();
if (!value) {
continue;
}
var->SetValue(*value);
}
}
const std::vector<VarMapping> &MacroSegment::GetVarMappings() const
{
return _varMappings;
}
void MacroSegment::SetVarMappings(const std::vector<VarMapping> &mappings)
{
_varMappings = mappings;
IncrementTempVarInUseGeneration();
}
void MacroSegment::FixupVarMappingRefs()
{
for (auto &mapping : _varMappings) {
if (!mapping.tempVar.HasValidID()) {
continue;
}
for (const auto &var : _tempVariables) {
if (var.ID() == mapping.tempVar.GetID()) {
mapping.tempVar = var.GetRef();
break;
}
}
}
NotifyUIAboutTempVarChange(this);
}
std::vector<TempVariable> MacroSegment::GetOwnTempVars() const
{
return _tempVariables;
} }
MacroSegment::MacroSegment(Macro *m, bool supportsVariableValue) MacroSegment::MacroSegment(Macro *m, bool supportsVariableValue)
@@ -24,14 +84,32 @@ MacroSegment::MacroSegment(Macro *m, bool supportsVariableValue)
{ {
} }
void MacroSegment::SetVarMappingExpanded(bool expanded)
{
_varMappingExpanded = expanded;
}
bool MacroSegment::Save(obs_data_t *obj) const bool MacroSegment::Save(obs_data_t *obj) const
{ {
OBSDataAutoRelease data = obs_data_create(); OBSDataAutoRelease data = obs_data_create();
obs_data_set_bool(data, "collapsed", _collapsed); obs_data_set_bool(data, "collapsed", _collapsed);
obs_data_set_bool(data, "varMappingExpanded", _varMappingExpanded);
obs_data_set_bool(data, "useCustomLabel", _useCustomLabel); obs_data_set_bool(data, "useCustomLabel", _useCustomLabel);
obs_data_set_string(data, "customLabel", _customLabel.c_str()); obs_data_set_string(data, "customLabel", _customLabel.c_str());
obs_data_set_bool(data, "enabled", _enabled); obs_data_set_bool(data, "enabled", _enabled);
obs_data_set_int(data, "version", 1); obs_data_set_int(data, "version", 2);
OBSDataArrayAutoRelease mappingsArray = obs_data_array_create();
for (const auto &mapping : _varMappings) {
OBSDataAutoRelease item = obs_data_create();
mapping.tempVar.Save(item, GetMacro(), "tempVar");
obs_data_set_string(
item, "variable",
GetWeakVariableName(mapping.variable).c_str());
obs_data_array_push_back(mappingsArray, item);
}
obs_data_set_array(data, "varMappings", mappingsArray);
obs_data_set_obj(obj, "segmentSettings", data); obs_data_set_obj(obj, "segmentSettings", data);
return true; return true;
} }
@@ -40,6 +118,7 @@ bool MacroSegment::Load(obs_data_t *obj)
{ {
OBSDataAutoRelease data = obs_data_get_obj(obj, "segmentSettings"); OBSDataAutoRelease data = obs_data_get_obj(obj, "segmentSettings");
_collapsed = obs_data_get_bool(data, "collapsed"); _collapsed = obs_data_get_bool(data, "collapsed");
_varMappingExpanded = obs_data_get_bool(data, "varMappingExpanded");
_useCustomLabel = obs_data_get_bool(data, "useCustomLabel"); _useCustomLabel = obs_data_get_bool(data, "useCustomLabel");
_customLabel = obs_data_get_string(data, "customLabel"); _customLabel = obs_data_get_string(data, "customLabel");
obs_data_set_default_bool(data, "enabled", true); obs_data_set_default_bool(data, "enabled", true);
@@ -50,6 +129,26 @@ bool MacroSegment::Load(obs_data_t *obj)
_enabled = obs_data_get_bool(obj, "enabled"); _enabled = obs_data_get_bool(obj, "enabled");
} }
// Reset the previously unused "enabled" value for conditions to "true"
if (obs_data_get_int(data, "version") < 2 &&
obs_data_has_user_value(obj, "logic")) {
_enabled = true;
}
_varMappings.clear();
OBSDataArrayAutoRelease mappingsArray =
obs_data_get_array(data, "varMappings");
const size_t count = obs_data_array_count(mappingsArray);
_varMappings.reserve(count);
for (size_t i = 0; i < count; i++) {
OBSDataAutoRelease item = obs_data_array_item(mappingsArray, i);
VarMapping mapping;
mapping.variable = GetWeakVariableByName(
obs_data_get_string(item, "variable"));
_varMappings.push_back(std::move(mapping));
_varMappings.back().tempVar.Load(item, GetMacro(), "tempVar");
}
ClearAvailableTempvars(); ClearAvailableTempvars();
return true; return true;
} }
@@ -167,24 +266,6 @@ bool MacroSegment::IsTempVarInUse(const std::string &id) const
return false; return false;
} }
void MacroSegment::CopyTempVarValuesFrom(const MacroSegment &other)
{
for (const auto &src : other._tempVariables) {
for (auto &dst : _tempVariables) {
if (dst.ID() != src.ID()) {
continue;
}
auto value = src.Value();
if (value) {
dst.SetValue(*value);
} else {
dst.InvalidateValue();
}
break;
}
}
}
void MacroSegment::SetTempVarValue(const std::string &id, void MacroSegment::SetTempVarValue(const std::string &id,
const std::string &value) const std::string &value)
{ {
@@ -244,11 +325,38 @@ MacroSegmentEdit::MacroSegmentEdit(QWidget *parent)
_headerInfo(new QLabel()), _headerInfo(new QLabel()),
_frame(new QWidget), _frame(new QWidget),
_contentLayout(new QVBoxLayout), _contentLayout(new QVBoxLayout),
_outputMappings(new TempVarOutputMappingsWidget(this)),
_varMappingToggle(new QPushButton(this)),
_noBorderframe(new QFrame), _noBorderframe(new QFrame),
_borderFrame(new QFrame), _borderFrame(new QFrame),
_dropLineAbove(new QFrame), _dropLineAbove(new QFrame),
_dropLineBelow(new QFrame) _dropLineBelow(new QFrame)
{ {
const auto iconPath = QString::fromStdString(GetDataFilePath(
"res/images/" + GetThemeTypeName() + "Variable.svg"));
_varMappingToggle->setIcon(QIcon(iconPath));
_varMappingToggle->setMaximumWidth(22);
_varMappingToggle->setFlat(true);
_varMappingToggle->setCheckable(true);
_varMappingToggle->setVisible(false);
_varMappingToggle->setToolTip(obs_module_text(
"AdvSceneSwitcher.tempVar.outputMappings.toggle"));
QWidget::connect(_varMappingToggle, &QPushButton::toggled,
_outputMappings,
&TempVarOutputMappingsWidget::SetPanelExpanded);
QWidget::connect(_varMappingToggle, &QPushButton::toggled, this,
[this](bool checked) {
if (Data()) {
Data()->SetVarMappingExpanded(checked);
}
});
QWidget::connect(_outputMappings,
&TempVarOutputMappingsWidget::ExpandableChanged,
_varMappingToggle, &QPushButton::setVisible);
QWidget::connect(_section, &Section::Collapsed, _outputMappings,
&TempVarOutputMappingsWidget::SetSectionCollapsed);
_dropLineAbove->setLineWidth(3); _dropLineAbove->setLineWidth(3);
_dropLineAbove->setFixedHeight(11); _dropLineAbove->setFixedHeight(11);
_dropLineBelow->setLineWidth(3); _dropLineBelow->setLineWidth(3);
@@ -310,6 +418,21 @@ MacroSegmentEdit::MacroSegmentEdit(QWidget *parent)
_headerInfo->installEventFilter(this); _headerInfo->installEventFilter(this);
} }
void MacroSegmentEdit::SetupVarMappings(MacroSegment *segment)
{
_outputMappings->SetSegment(segment);
_varMappingToggle->setChecked(segment &&
segment->GetVarMappingExpanded());
}
void MacroSegmentEdit::ShowVariableMappings(bool show)
{
_varMappingToggle->setChecked(show);
if (Data()) {
Data()->SetVarMappingExpanded(show);
}
}
bool MacroSegmentEdit::eventFilter(QObject *obj, QEvent *ev) bool MacroSegmentEdit::eventFilter(QObject *obj, QEvent *ev)
{ {
if (obj == _headerInfo && ev->type() == QEvent::MouseMove) { if (obj == _headerInfo && ev->type() == QEvent::MouseMove) {

View File

@@ -9,15 +9,23 @@
#include <QWidget> #include <QWidget>
#include <QFrame> #include <QFrame>
#include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QTimer> #include <QTimer>
#include <obs-data.h> #include <obs-data.h>
#include <memory>
class QLabel; class QLabel;
namespace advss { namespace advss {
class Macro; class Macro;
class Variable;
struct VarMapping {
TempVariableRef tempVar;
std::weak_ptr<Variable> variable;
};
class EXPORT MacroSegment : public Lockable { class EXPORT MacroSegment : public Lockable {
public: public:
@@ -28,6 +36,8 @@ public:
int GetIndex() const { return _idx; } int GetIndex() const { return _idx; }
void SetCollapsed(bool collapsed) { _collapsed = collapsed; } void SetCollapsed(bool collapsed) { _collapsed = collapsed; }
bool GetCollapsed() const { return _collapsed; } bool GetCollapsed() const { return _collapsed; }
void SetVarMappingExpanded(bool expanded);
bool GetVarMappingExpanded() const { return _varMappingExpanded; }
void SetUseCustomLabel(bool enable) { _useCustomLabel = enable; } void SetUseCustomLabel(bool enable) { _useCustomLabel = enable; }
bool GetUseCustomLabel() const { return _useCustomLabel; } bool GetUseCustomLabel() const { return _useCustomLabel; }
void SetCustomLabel(const std::string &label) { _customLabel = label; } void SetCustomLabel(const std::string &label) { _customLabel = label; }
@@ -43,6 +53,11 @@ public:
void SetEnabled(bool); void SetEnabled(bool);
bool Enabled() const; bool Enabled() const;
virtual std::string GetVariableValue() const; virtual std::string GetVariableValue() const;
void ApplyVarMappings();
const std::vector<VarMapping> &GetVarMappings() const;
void SetVarMappings(const std::vector<VarMapping> &mappings);
std::vector<TempVariable> GetOwnTempVars() const;
void FixupVarMappingRefs();
protected: protected:
friend bool SupportsVariableValue(MacroSegment *); friend bool SupportsVariableValue(MacroSegment *);
@@ -57,7 +72,6 @@ protected:
bool IsTempVarInUse(const std::string &id) const; bool IsTempVarInUse(const std::string &id) const;
void SetTempVarValue(const std::string &id, const std::string &value); void SetTempVarValue(const std::string &id, const std::string &value);
void CopyTempVarValuesFrom(const MacroSegment &other);
template<typename T, typename = std::enable_if_t< template<typename T, typename = std::enable_if_t<
std::is_same<std::decay_t<T>, bool>::value>> std::is_same<std::decay_t<T>, bool>::value>>
@@ -88,6 +102,7 @@ private:
// UI helper // UI helper
bool _highlight = false; bool _highlight = false;
bool _collapsed = false; bool _collapsed = false;
bool _varMappingExpanded = false;
bool _enabled = true; bool _enabled = true;
// Custom header labels // Custom header labels
@@ -100,6 +115,7 @@ private:
int _variableRefs = 0; int _variableRefs = 0;
std::string _variableValue; std::string _variableValue;
std::vector<TempVariable> _tempVariables; std::vector<TempVariable> _tempVariables;
std::vector<VarMapping> _varMappings;
friend class Macro; friend class Macro;
}; };
@@ -118,9 +134,13 @@ public:
void SetSelected(bool); void SetSelected(bool);
virtual std::shared_ptr<MacroSegment> Data() const = 0; virtual std::shared_ptr<MacroSegment> Data() const = 0;
virtual void SetupWidgets(bool basicSetup = false) = 0; virtual void SetupWidgets(bool basicSetup = false) = 0;
virtual void FocusTypeSelection() {}
void SetupVarMappings(MacroSegment *segment);
public slots: public slots:
void HeaderInfoChanged(const QString &); void HeaderInfoChanged(const QString &);
void ShowVariableMappings(bool show);
protected slots: protected slots:
void Collapsed(bool) const; void Collapsed(bool) const;
@@ -135,6 +155,8 @@ protected:
QLabel *_headerInfo; QLabel *_headerInfo;
QWidget *_frame; QWidget *_frame;
QVBoxLayout *_contentLayout; QVBoxLayout *_contentLayout;
TempVarOutputMappingsWidget *_outputMappings;
QPushButton *_varMappingToggle;
bool _allWidgetsAreSetup = false; bool _allWidgetsAreSetup = false;
private: private:

View File

@@ -18,6 +18,7 @@ signals:
void Remove(const QString &); void Remove(const QString &);
void SegmentOrderChanged(); void SegmentOrderChanged();
void HighlightChanged(bool value); void HighlightChanged(bool value);
void ConditionTypeCreated(const QString &typeId);
private: private:
MacroSignalManager(QObject *parent = nullptr); MacroSignalManager(QObject *parent = nullptr);

View File

@@ -1,5 +1,4 @@
#include "advanced-scene-switcher.hpp" #include "advanced-scene-switcher.hpp"
#include "action-queue.hpp"
#include "macro-action-edit.hpp" #include "macro-action-edit.hpp"
#include "macro-condition-edit.hpp" #include "macro-condition-edit.hpp"
#include "macro-export-import-dialog.hpp" #include "macro-export-import-dialog.hpp"
@@ -316,13 +315,9 @@ void AdvSceneSwitcher::ExportMacros() const
obs_data_array_push_back(macroArray, obj); obs_data_array_push_back(macroArray, obj);
} }
obs_data_set_array(data, "macros", macroArray); obs_data_set_array(data, "macros", macroArray);
SaveVariables(data);
SaveActionQueues(data);
obs_data_set_string(data, "version", g_GIT_TAG); obs_data_set_string(data, "version", g_GIT_TAG);
auto json = obs_data_get_json(data);
QString exportString(json);
MacroExportImportDialog::ExportMacros(exportString); MacroExportImportDialog::ExportMacros(data);
} }
bool AdvSceneSwitcher::ResolveMacroImportNameConflict( bool AdvSceneSwitcher::ResolveMacroImportNameConflict(
@@ -384,8 +379,6 @@ void AdvSceneSwitcher::ImportMacros()
ImportMacros(); ImportMacros();
return; return;
} }
ImportVariables(data);
ImportQueues(data);
auto version = obs_data_get_string(data, "version"); auto version = obs_data_get_string(data, "version");
if (strcmp(version, g_GIT_TAG) != 0) { if (strcmp(version, g_GIT_TAG) != 0) {
@@ -402,7 +395,7 @@ void AdvSceneSwitcher::ImportMacros()
std::vector<std::shared_ptr<Macro>> importedMacros; std::vector<std::shared_ptr<Macro>> importedMacros;
auto &tempMacros = GetTemporaryMacros(); auto &tempMacros = GetTemporaryMacros();
auto lock = LockContext(); std::unique_lock<std::mutex> lock(*GetMutex());
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
tempMacros.clear(); tempMacros.clear();
@@ -412,10 +405,14 @@ void AdvSceneSwitcher::ImportMacros()
macro->Load(array_obj); macro->Load(array_obj);
RunAndClearPostLoadSteps(); RunAndClearPostLoadSteps();
if (macroNameExists(macro->Name()) && if (macroNameExists(macro->Name())) {
!ResolveMacroImportNameConflict(macro)) { lock.unlock();
groupSize--; bool resolved = ResolveMacroImportNameConflict(macro);
continue; lock.lock();
if (!resolved) {
groupSize--;
continue;
}
} }
importedMacros.emplace_back(macro); importedMacros.emplace_back(macro);
@@ -557,6 +554,10 @@ void AdvSceneSwitcher::HighlightOnChange() const
return; return;
} }
if (macro->Paused()) {
return;
}
if (macro->ActionTriggerModePreventedActionsSince( if (macro->ActionTriggerModePreventedActionsSince(
lastOnChangeHighlightCheckTime)) { lastOnChangeHighlightCheckTime)) {
HighlightWidget(ui->actionTriggerMode, Qt::yellow, HighlightWidget(ui->actionTriggerMode, Qt::yellow,

View File

@@ -17,6 +17,17 @@
namespace advss { namespace advss {
static bool setup()
{
AddPluginCleanupStep([]() {
GetTopLevelMacros().clear();
GetTemporaryMacros().clear();
});
return true;
}
static bool setupDone = setup();
Macro::Macro(const std::string &name) : _dockSettings(this) Macro::Macro(const std::string &name) : _dockSettings(this)
{ {
SetName(name); SetName(name);
@@ -113,16 +124,16 @@ static bool checkCondition(const std::shared_ptr<MacroCondition> &condition)
condition->WithLock([&condition, &conditionMatched]() { condition->WithLock([&condition, &conditionMatched]() {
conditionMatched = condition->EvaluateCondition(); conditionMatched = condition->EvaluateCondition();
}); });
condition->ApplyVarMappings();
const auto endTime = std::chrono::high_resolution_clock::now(); const auto endTime = std::chrono::high_resolution_clock::now();
const auto timeSpent = endTime - startTime; const auto timeSpent = endTime - startTime;
if (timeSpent >= perfLogThreshold) { if (timeSpent >= perfLogThreshold) {
const long int ms =
std::chrono::duration_cast<std::chrono::milliseconds>(
timeSpent)
.count();
blog(LOG_WARNING, blog(LOG_WARNING,
"spent %ld ms in %s condition check of macro '%s'!", ms, "spent %lld ms in %s condition check of macro '%s'!",
(long long)std::chrono::duration_cast<
std::chrono::milliseconds>(timeSpent)
.count(),
condition->GetId().c_str(), condition->GetId().c_str(),
condition->GetMacro()->Name().c_str()); condition->GetMacro()->Name().c_str());
} }
@@ -145,6 +156,15 @@ bool Macro::CheckConditionHelper(
return conditionMatched; return conditionMatched;
}; };
if (!condition->Enabled()) {
vblog(LOG_INFO, "ignoring condition '%s' for '%s'",
condition->GetId().c_str(), _name.c_str());
if (!_useShortCircuitEvaluation) {
(void)evaluateCondition();
}
return _matched;
}
const auto logicType = condition->GetLogicType(); const auto logicType = condition->GetLogicType();
if (logicType == Logic::Type::NONE) { if (logicType == Logic::Type::NONE) {
vblog(LOG_INFO, "ignoring condition '%s' for '%s'", vblog(LOG_INFO, "ignoring condition '%s' for '%s'",
@@ -269,7 +289,7 @@ bool Macro::CheckConditions(bool ignorePause)
const bool hasActionsToExecute = _matched ? (_actions.size() > 0) const bool hasActionsToExecute = _matched ? (_actions.size() > 0)
: (_elseActions.size() > 0); : (_elseActions.size() > 0);
if (!_actionModeMatch && hasActionsToExecute) { if (!_actionModeMatch && hasActionsToExecute && !_paused) {
_lastActionRunModePreventTime = _lastActionRunModePreventTime =
std::chrono::high_resolution_clock::now(); std::chrono::high_resolution_clock::now();
} }
@@ -368,7 +388,7 @@ bool Macro::ShouldRunActions() const
!_paused && (_matched || _elseActions.size() > 0) && !_paused && (_matched || _elseActions.size() > 0) &&
_actionModeMatch; _actionModeMatch;
if (VerboseLoggingEnabled() && !_actionModeMatch) { if (VerboseLoggingEnabled() && !_actionModeMatch && !_paused) {
if (_matched && _actions.size() > 0) { if (_matched && _actions.size() > 0) {
blog(LOG_INFO, "skip actions for Macro %s (on change)", blog(LOG_INFO, "skip actions for Macro %s (on change)",
_name.c_str()); _name.c_str());
@@ -428,14 +448,11 @@ bool Macro::RunActionsHelper(
} }
if (action->Enabled()) { if (action->Enabled()) {
action->LogAction(); action->LogAction();
std::shared_ptr<MacroAction> actionCopy; bool actionResult = false;
action->WithLock([&action, &actionCopy]() { action->WithLock([&action, &actionResult]() {
actionCopy = action->Copy(); actionResult = action->PerformAction();
});
bool actionResult = actionCopy->PerformAction();
action->WithLock([&action, &actionCopy]() {
action->CopyTempVarValuesFrom(*actionCopy);
}); });
action->ApplyVarMappings();
actionsExecutedSuccessfully = actionsExecutedSuccessfully =
actionsExecutedSuccessfully && actionResult; actionsExecutedSuccessfully && actionResult;
} else { } else {
@@ -1299,7 +1316,14 @@ bool RunMacros()
return true; return true;
} }
void StopAllMacros() void SignalStopAllMacros()
{
for (const auto &m : GetAllMacros()) {
m->SignalStop();
}
}
void WaitForAllMacros()
{ {
for (const auto &m : GetAllMacros()) { for (const auto &m : GetAllMacros()) {
m->Stop(); m->Stop();

View File

@@ -61,6 +61,7 @@ public:
PauseStateSaveBehavior GetPauseStateSaveBehavior() const; PauseStateSaveBehavior GetPauseStateSaveBehavior() const;
void Stop(); void Stop();
void SignalStop() { _stop = true; }
bool GetStop() const { return _stop; } bool GetStop() const { return _stop; }
void ResetTimers(); void ResetTimers();
@@ -228,7 +229,7 @@ void LoadMacros(obs_data_t *obj);
void SaveMacros(obs_data_t *obj); void SaveMacros(obs_data_t *obj);
bool CheckMacros(); bool CheckMacros();
bool RunMacros(); bool RunMacros();
void StopAllMacros(); void WaitForAllMacros();
void InvalidateMacroTempVarValues(); void InvalidateMacroTempVarValues();
std::shared_ptr<Macro> GetMacroWithInvalidConditionInterval(); std::shared_ptr<Macro> GetMacroWithInvalidConditionInterval();

View File

@@ -6,6 +6,7 @@
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include <util/platform.h> #include <util/platform.h>
#include <set>
#include <vector> #include <vector>
#include <QStringList> #include <QStringList>
#include <QRegularExpression> #include <QRegularExpression>
@@ -14,56 +15,18 @@
namespace advss { namespace advss {
void GetWindowList(std::vector<std::string> &windows) static std::string nsStringToStdString(NSString *str)
{ {
windows.resize(0); if (!str) {
return "";
@autoreleasepool {
CFArrayRef cfApps = CGWindowListCopyWindowInfo(
kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
NSMutableArray *apps = (__bridge NSMutableArray *)cfApps;
for (NSDictionary *app in apps) {
std::string name([[app objectForKey:@"kCGWindowName"]
UTF8String],
[[app objectForKey:@"kCGWindowName"]
lengthOfBytesUsingEncoding:
NSUTF8StringEncoding]);
std::string owner(
[[app objectForKey:@"kCGWindowOwnerName"]
UTF8String],
[[app objectForKey:@"kCGWindowOwnerName"]
lengthOfBytesUsingEncoding:
NSUTF8StringEncoding]);
if (!name.empty() &&
find(windows.begin(), windows.end(), name) ==
windows.end()) {
windows.emplace_back(name);
}
if (!owner.empty() &&
find(windows.begin(), windows.end(), owner) ==
windows.end()) {
windows.emplace_back(owner);
}
}
apps = nil;
CFRelease(cfApps);
} }
const char *utf8 = [str UTF8String];
return utf8 ? utf8 : "";
} }
void GetWindowList(QStringList &windows) std::string GetCurrentWindowTitle()
{ {
windows.clear(); std::string title;
std::vector<std::string> temp;
GetWindowList(temp);
for (auto &w : temp) {
windows << QString::fromStdString(w);
}
}
void GetCurrentWindowTitle(std::string &title)
{
title.resize(0);
@autoreleasepool { @autoreleasepool {
CFArrayRef cfApps = CGWindowListCopyWindowInfo( CFArrayRef cfApps = CGWindowListCopyWindowInfo(
kCGWindowListOptionOnScreenOnly, kCGNullWindowID); kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
@@ -107,102 +70,52 @@ void GetCurrentWindowTitle(std::string &title)
apps = nil; apps = nil;
CFRelease(cfApps); CFRelease(cfApps);
} }
return title;
} }
bool isWindowOriginOnScreen(NSDictionary *app, NSScreen *screen,
bool fullscreen = false)
{
NSArray *screens = [NSScreen screens];
NSRect mainScreenFrame = [screens[0] frame];
NSRect screenFrame;
if (fullscreen) {
screenFrame = [screen frame];
} else {
screenFrame = [screen visibleFrame];
}
NSRect windowBounds;
CGRectMakeWithDictionaryRepresentation(
(CFDictionaryRef)[app objectForKey:@"kCGWindowBounds"],
&windowBounds);
return (windowBounds.origin.x == screenFrame.origin.x &&
(mainScreenFrame.size.height - screenFrame.size.height -
windowBounds.origin.y ==
screenFrame.origin.y));
}
bool isWindowMaximizedOnScreen(NSDictionary *app, NSScreen *screen) bool isWindowMaximizedOnScreen(NSDictionary *app, NSScreen *screen)
{ {
double maximizedTolerance = 0.99;
NSRect screenFrame = [screen frame];
NSRect windowBounds; NSRect windowBounds;
CGRectMakeWithDictionaryRepresentation( CGRectMakeWithDictionaryRepresentation(
(CFDictionaryRef)[app objectForKey:@"kCGWindowBounds"], (CFDictionaryRef)[app objectForKey:@"kCGWindowBounds"],
&windowBounds); &windowBounds);
int sumX = windowBounds.origin.x + windowBounds.size.width; // CGWindowList: flipped coords, origin at top-left of main display.
int sumY = windowBounds.origin.y + windowBounds.size.height; // NSScreen: Cocoa coords, origin at bottom-left of main display.
NSRect mainFrame = [[NSScreen screens][0] frame];
NSRect visFrame = [screen visibleFrame];
// Return false if window spans over multiple screens // Convert visible area to CGWindow coordinates.
if (sumX > screenFrame.size.width) { // screenTop is just below the menubar; screenBottom is just above the
// dock.
CGFloat screenLeft = visFrame.origin.x;
CGFloat screenTop =
mainFrame.size.height - visFrame.origin.y - visFrame.size.height;
CGFloat screenRight = screenLeft + visFrame.size.width;
CGFloat screenBottom = screenTop + visFrame.size.height;
const double tolerance = 4.0;
// Width must span the full visible width.
if (fabs(windowBounds.origin.x - screenLeft) > tolerance) {
return false; return false;
} }
if (sumY > screenFrame.size.height) { if (fabs((windowBounds.origin.x + windowBounds.size.width) -
screenRight) > tolerance) {
return false; return false;
} }
// Bottom edge must align with the visible bottom (above dock).
return ((double)sumX / (double)screenFrame.size.width) > if (fabs((windowBounds.origin.y + windowBounds.size.height) -
maximizedTolerance && screenBottom) > tolerance) {
((double)sumY / (double)screenFrame.size.height) > return false;
maximizedTolerance;
}
bool nameMachesPattern(std::string windowName, std::string pattern)
{
return QString::fromStdString(windowName)
.contains(QRegularExpression(QString::fromStdString(pattern)));
}
bool IsMaximized(const std::string &title)
{
@autoreleasepool {
NSArray *screens = [NSScreen screens];
CFArrayRef cfApps = CGWindowListCopyWindowInfo(
kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
NSMutableArray *apps = (__bridge NSMutableArray *)cfApps;
for (NSDictionary *app in apps) {
std::string name([[app objectForKey:@"kCGWindowName"]
UTF8String],
[[app objectForKey:@"kCGWindowName"]
lengthOfBytesUsingEncoding:
NSUTF8StringEncoding]);
std::string owner(
[[app objectForKey:@"kCGWindowOwnerName"]
UTF8String],
[[app objectForKey:@"kCGWindowOwnerName"]
lengthOfBytesUsingEncoding:
NSUTF8StringEncoding]);
bool equals = (title == name || title == owner);
bool matches = nameMachesPattern(name, title) ||
nameMachesPattern(owner, title);
if (equals || matches) {
for (NSScreen *screen in screens) {
if (isWindowOriginOnScreen(app,
screen) &&
isWindowMaximizedOnScreen(app,
screen)) {
apps = nil;
CFRelease(cfApps);
return true;
}
}
}
}
apps = nil;
CFRelease(cfApps);
} }
return false; // Top edge must be at or above the menubar line (some apps extend
// their window frame behind the menubar).
if (windowBounds.origin.y > screenTop + tolerance) {
return false;
}
return true;
} }
bool isWindowFullscreenOnScreen(NSDictionary *app, NSScreen *screen) bool isWindowFullscreenOnScreen(NSDictionary *app, NSScreen *screen)
@@ -216,52 +129,176 @@ bool isWindowFullscreenOnScreen(NSDictionary *app, NSScreen *screen)
return NSEqualSizes(windowBounds.size, screenFrame.size); return NSEqualSizes(windowBounds.size, screenFrame.size);
} }
bool IsFullscreen(const std::string &title) std::vector<WindowInfo> GetWindows(const WindowQueryOptions &options)
{ {
std::vector<WindowInfo> result;
const std::string foregroundTitle = GetCurrentWindowTitle();
@autoreleasepool { @autoreleasepool {
NSArray *screens = [NSScreen screens]; NSArray *screens = [NSScreen screens];
CFArrayRef cfApps = CGWindowListCopyWindowInfo(
kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
NSMutableArray *apps = (__bridge NSMutableArray *)cfApps;
for (NSDictionary *app in apps) {
std::string name([[app objectForKey:@"kCGWindowName"]
UTF8String],
[[app objectForKey:@"kCGWindowName"]
lengthOfBytesUsingEncoding:
NSUTF8StringEncoding]);
std::string owner(
[[app objectForKey:@"kCGWindowOwnerName"]
UTF8String],
[[app objectForKey:@"kCGWindowOwnerName"]
lengthOfBytesUsingEncoding:
NSUTF8StringEncoding]);
bool equals = (title == name || title == owner); CFArrayRef cfApps = CGWindowListCopyWindowInfo(
bool matches = nameMachesPattern(name, title) || kCGWindowListExcludeDesktopElements, kCGNullWindowID);
nameMachesPattern(owner, title); NSMutableArray *apps = (__bridge NSMutableArray *)cfApps;
if (equals || matches) {
// Pre-compute which PIDs own at least one fullscreen-sized window.
// A fullscreen app reports a small chrome/title bar window first and
// its full-size content window second; checking only the first
// window's bounds gives a false negative.
std::set<int> fullscreenPIDs;
if (options.fullscreen) {
for (NSDictionary *app in apps) {
int layer = [[app objectForKey:@"kCGWindowLayer"]
intValue];
if (layer != 0) {
continue;
}
for (NSScreen *screen in screens) { for (NSScreen *screen in screens) {
if (isWindowOriginOnScreen(app, screen, if (isWindowFullscreenOnScreen(app,
true) && screen)) {
isWindowFullscreenOnScreen( int pid = [[app objectForKey:
app, screen)) { @"kCGWindowOwnerPID"]
apps = nil; intValue];
CFRelease(cfApps); fullscreenPIDs.insert(pid);
return true; break;
} }
} }
} }
} }
std::set<int> maximizedPIDs;
if (options.maximized) {
for (NSDictionary *app in apps) {
int layer = [[app objectForKey:@"kCGWindowLayer"]
intValue];
if (layer != 0) {
continue;
}
for (NSScreen *screen in screens) {
if (isWindowMaximizedOnScreen(app,
screen)) {
int pid = [[app objectForKey:
@"kCGWindowOwnerPID"]
intValue];
maximizedPIDs.insert(pid);
break;
}
}
}
}
// Pre-compute the largest-area window bounds per PID.
// CGWindowList often lists small auxiliary windows (toolbars,
// chrome) before the main content window; using the largest area
// avoids reporting those wrong bounds for geometry.
std::map<int, NSRect> largestBoundsPerPID;
if (options.geometry || options.maximized) {
for (NSDictionary *app in apps) {
int layer = [[app objectForKey:@"kCGWindowLayer"]
intValue];
if (layer != 0) {
continue;
}
NSRect b = NSZeroRect;
CGRectMakeWithDictionaryRepresentation(
(CFDictionaryRef)[app
objectForKey:@"kCGWindowBounds"],
&b);
int pid = [[app objectForKey:@"kCGWindowOwnerPID"]
intValue];
auto it = largestBoundsPerPID.find(pid);
if (it == largestBoundsPerPID.end() ||
b.size.width * b.size.height >
it->second.size.width *
it->second.size.height) {
largestBoundsPerPID[pid] = b;
}
}
}
// Track titles already added to avoid duplicates (name + owner)
std::vector<std::string> seen;
for (NSDictionary *app in apps) {
int layer =
[[app objectForKey:@"kCGWindowLayer"] intValue];
if (layer != 0) {
continue;
}
std::string name = nsStringToStdString(
[app objectForKey:@"kCGWindowName"]);
std::string owner = nsStringToStdString(
[app objectForKey:@"kCGWindowOwnerName"]);
// Collect geometry once (used for multiple fields)
NSRect bounds = NSZeroRect;
if (options.geometry || options.fullscreen ||
options.maximized) {
CGRectMakeWithDictionaryRepresentation(
(CFDictionaryRef)[app
objectForKey:@"kCGWindowBounds"],
&bounds);
}
// Process both the window name and the owner name as
// separate entries, matching the old GetWindowList() behaviour
for (int pass = 0; pass < 2; ++pass) {
const std::string &title = (pass == 0) ? name
: owner;
if (title.empty()) {
continue;
}
if (std::find(seen.begin(), seen.end(),
title) != seen.end()) {
continue;
}
seen.emplace_back(title);
WindowInfo info;
info.title = title;
if (options.focus) {
info.focused =
(title == foregroundTitle);
}
if (options.geometry || options.fullscreen ||
options.maximized) {
int pid = [[app objectForKey:
@"kCGWindowOwnerPID"]
intValue];
auto it = largestBoundsPerPID.find(pid);
const NSRect &geoBounds =
(it != largestBoundsPerPID.end())
? it->second
: bounds;
info.x = (int)geoBounds.origin.x;
info.y = (int)geoBounds.origin.y;
info.width = (int)geoBounds.size.width;
info.height = (int)geoBounds.size.height;
if (options.fullscreen) {
info.fullscreen =
fullscreenPIDs.count(pid) >
0;
}
if (options.maximized) {
info.maximized =
maximizedPIDs.count(pid) >
0;
}
}
// windowClass and text not implemented on macOS
result.emplace_back(std::move(info));
}
}
apps = nil; apps = nil;
CFRelease(cfApps); CFRelease(cfApps);
} }
return false; return result;
}
std::optional<std::string> GetTextInWindow(const std::string &)
{
// Not implemented
return {};
} }
int SecondsSinceLastInput() int SecondsSinceLastInput()
@@ -273,9 +310,9 @@ int SecondsSinceLastInput()
return (int)time; return (int)time;
} }
void GetProcessList(QStringList &list) QStringList GetProcessList()
{ {
list.clear(); QStringList list;
@autoreleasepool { @autoreleasepool {
NSWorkspace *ws = [NSWorkspace sharedWorkspace]; NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSArray *array = [ws runningApplications]; NSArray *array = [ws runningApplications];
@@ -291,11 +328,11 @@ void GetProcessList(QStringList &list)
} }
} }
} }
return list;
} }
void GetForegroundProcessName(std::string &proc) std::string GetForegroundProcessName()
{ {
proc.resize(0);
@autoreleasepool { @autoreleasepool {
NSWorkspace *ws = [NSWorkspace sharedWorkspace]; NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSArray *array = [ws runningApplications]; NSArray *array = [ws runningApplications];
@@ -308,23 +345,72 @@ void GetForegroundProcessName(std::string &proc)
break; break;
} }
const char *str = name.UTF8String; const char *str = name.UTF8String;
proc = std::string(str); if (str) {
return str;
}
break; break;
} }
} }
return {};
} }
void GetForegroundProcessName(QString &proc) std::string GetForegroundProcessPath()
{ {
std::string temp; @autoreleasepool {
GetForegroundProcessName(temp); NSWorkspace *ws = [NSWorkspace sharedWorkspace];
proc = QString::fromStdString(temp); for (NSRunningApplication *app in [ws runningApplications]) {
if (!app.isActive) {
continue;
}
NSURL *url = app.executableURL;
if (!url) {
break;
}
const char *str = url.path.UTF8String;
if (str) {
return str;
}
break;
}
}
return {};
}
QStringList GetProcessPathsFromName(const QString &name)
{
QStringList paths;
@autoreleasepool {
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
for (NSRunningApplication *app in [ws runningApplications]) {
NSString *appName = app.localizedName;
if (!appName) {
continue;
}
const char *nameStr = appName.UTF8String;
if (!nameStr || name != QString::fromUtf8(nameStr)) {
continue;
}
NSURL *url = app.executableURL;
if (!url) {
continue;
}
const char *pathStr = url.path.UTF8String;
if (!pathStr) {
continue;
}
QString path = QString::fromUtf8(pathStr);
if (!paths.contains(path)) {
paths.append(path);
}
}
}
return paths;
} }
bool IsInFocus(const QString &executable) bool IsInFocus(const QString &executable)
{ {
std::string current; const auto current = GetForegroundProcessName();
GetForegroundProcessName(current);
// True if executable switch equals current window // True if executable switch equals current window
bool equals = (executable.toStdString() == current); bool equals = (executable.toStdString() == current);

View File

@@ -11,15 +11,36 @@ namespace advss {
enum class HotkeyType; enum class HotkeyType;
EXPORT void GetWindowList(std::vector<std::string> &windows); struct WindowQueryOptions {
EXPORT void GetWindowList(QStringList &windows); bool geometry = false;
EXPORT void GetCurrentWindowTitle(std::string &title); bool focus = false;
EXPORT bool IsFullscreen(const std::string &title); bool fullscreen = false;
EXPORT bool IsMaximized(const std::string &title); bool maximized = false;
EXPORT std::optional<std::string> GetTextInWindow(const std::string &window); bool windowClass = false; // Windows only, no-op on other platforms
bool text = false; // Windows only, expensive, no-op on other platforms
};
struct WindowInfo {
std::string title;
bool focused = false;
bool fullscreen = false;
bool maximized = false;
int x = 0;
int y = 0;
int width = 0;
int height = 0;
std::string windowClass;
std::optional<std::string> text;
};
EXPORT std::vector<WindowInfo>
GetWindows(const WindowQueryOptions &options = {});
EXPORT std::string GetCurrentWindowTitle();
EXPORT int SecondsSinceLastInput(); EXPORT int SecondsSinceLastInput();
EXPORT void GetProcessList(QStringList &processes); EXPORT QStringList GetProcessList();
EXPORT void GetForegroundProcessName(std::string &name); EXPORT std::string GetForegroundProcessName();
EXPORT std::string GetForegroundProcessPath();
EXPORT QStringList GetProcessPathsFromName(const QString &name);
EXPORT bool IsInFocus(const QString &executable); EXPORT bool IsInFocus(const QString &executable);
void PlatformInit(); void PlatformInit();
void PlatformCleanup(); void PlatformCleanup();

View File

@@ -16,14 +16,17 @@ static void setupTab(QTabWidget *);
static ActionQueueTable *tabWidget = nullptr; static ActionQueueTable *tabWidget = nullptr;
void RegisterActionQueueTab() static bool setup()
{ {
AddPluginInitStep([]() { AddPluginInitStep([] {
AddSetupTabCallback("actionQueueTab", ActionQueueTable::Create, AddSetupTabCallback("actionQueueTab", ActionQueueTable::Create,
setupTab); setupTab);
}); });
return true;
} }
static bool setupDone = setup();
static void setTabVisible(QTabWidget *tabWidget, bool visible) static void setTabVisible(QTabWidget *tabWidget, bool visible)
{ {
SetTabVisibleByName( SetTabVisibleByName(

View File

@@ -12,20 +12,16 @@ std::deque<std::shared_ptr<Item>> &GetActionQueues()
return queues; return queues;
} }
void RegisterActionQueueTab(); static bool setup()
void SetupActionQueues()
{ {
static bool done = false;
if (done) {
return;
}
AddSaveStep(SaveActionQueues); AddSaveStep(SaveActionQueues);
AddLoadStep(LoadActionQueues); AddLoadStep(LoadActionQueues);
RegisterActionQueueTab(); AddPluginCleanupStep([]() { queues.clear(); });
done = true; return true;
} }
static bool setupDone = setup();
ActionQueue::ActionQueue() : Item() ActionQueue::ActionQueue() : Item()
{ {
_lastEmpty = std::chrono::high_resolution_clock::now(); _lastEmpty = std::chrono::high_resolution_clock::now();

View File

@@ -101,7 +101,6 @@ signals:
}; };
std::deque<std::shared_ptr<Item>> &GetActionQueues(); std::deque<std::shared_ptr<Item>> &GetActionQueues();
void SetupActionQueues();
void SaveActionQueues(obs_data_t *); void SaveActionQueues(obs_data_t *);
void LoadActionQueues(obs_data_t *); void LoadActionQueues(obs_data_t *);
void ImportQueues(obs_data_t *); void ImportQueues(obs_data_t *);

View File

@@ -163,6 +163,8 @@ public:
bool disableHints = false; bool disableHints = false;
bool disableFilterComboboxFilter = false; bool disableFilterComboboxFilter = false;
bool hideLegacyTabs = true; bool hideLegacyTabs = true;
bool settingsLockEnabled = false;
std::string settingsLockPassword;
bool saveWindowGeo = false; bool saveWindowGeo = false;
QPoint windowPos = {}; QPoint windowPos = {};
QSize windowSize = {}; QSize windowSize = {};

View File

@@ -8,7 +8,6 @@
namespace advss { namespace advss {
const std::map<Logic::Type, const char *> Logic::localeMap = { const std::map<Logic::Type, const char *> Logic::localeMap = {
{Logic::Type::NONE, {"AdvSceneSwitcher.logic.none"}},
{Logic::Type::AND, {"AdvSceneSwitcher.logic.and"}}, {Logic::Type::AND, {"AdvSceneSwitcher.logic.and"}},
{Logic::Type::OR, {"AdvSceneSwitcher.logic.or"}}, {Logic::Type::OR, {"AdvSceneSwitcher.logic.or"}},
{Logic::Type::AND_NOT, {"AdvSceneSwitcher.logic.andNot"}}, {Logic::Type::AND_NOT, {"AdvSceneSwitcher.logic.andNot"}},
@@ -67,7 +66,7 @@ void Logic::PopulateLogicTypeSelection(QComboBox *list, bool isRootCondition)
return typeValue < rootOffset; return typeValue < rootOffset;
}} }}
: std::function<bool(int)>{[](int typeValue) { : std::function<bool(int)>{[](int typeValue) {
return typeValue >= rootOffset; return typeValue > rootOffset;
}}; }};
for (const auto &[type, name] : localeMap) { for (const auto &[type, name] : localeMap) {
const int typeValue = static_cast<int>(type); const int typeValue = static_cast<int>(type);

View File

@@ -28,6 +28,8 @@ static constexpr bool handleUncleanShutdown = true;
static bool wasCleanShutdown = false; static bool wasCleanShutdown = false;
static bool suppressCrashDialog = false; static bool suppressCrashDialog = false;
static char *sentinelFile = nullptr;
bool GetSuppressCrashDialog() bool GetSuppressCrashDialog()
{ {
return suppressCrashDialog; return suppressCrashDialog;
@@ -58,7 +60,6 @@ static void handleShutdown(enum obs_frontend_event event, void *)
return; return;
} }
char *sentinelFile = obs_module_config_path(sentinel.data());
if (!sentinelFile) { if (!sentinelFile) {
return; return;
} }
@@ -78,7 +79,8 @@ static void handleShutdown(enum obs_frontend_event event, void *)
static void setup() static void setup()
{ {
char *sentinelFile = obs_module_config_path(sentinel.data()); // Freed in handleShutdown()
sentinelFile = obs_module_config_path(sentinel.data());
if (!sentinelFile) { if (!sentinelFile) {
return; return;
} }
@@ -106,7 +108,6 @@ static void setup()
file.write("running"); file.write("running");
file.close(); file.close();
bfree(sentinelFile);
obs_frontend_add_event_callback(handleShutdown, nullptr); obs_frontend_add_event_callback(handleShutdown, nullptr);
return; return;

View File

@@ -11,6 +11,7 @@ static void populateUnits(QComboBox *list)
list->addItem(obs_module_text("AdvSceneSwitcher.unit.seconds")); list->addItem(obs_module_text("AdvSceneSwitcher.unit.seconds"));
list->addItem(obs_module_text("AdvSceneSwitcher.unit.minutes")); list->addItem(obs_module_text("AdvSceneSwitcher.unit.minutes"));
list->addItem(obs_module_text("AdvSceneSwitcher.unit.hours")); list->addItem(obs_module_text("AdvSceneSwitcher.unit.hours"));
list->addItem(obs_module_text("AdvSceneSwitcher.unit.days"));
} }
DurationSelection::DurationSelection(QWidget *parent, bool showUnitSelection, DurationSelection::DurationSelection(QWidget *parent, bool showUnitSelection,
@@ -66,6 +67,8 @@ static int durationUnitToMultiplier(Duration::Unit u)
return 60; return 60;
case Duration::Unit::HOURS: case Duration::Unit::HOURS:
return 3600; return 3600;
case Duration::Unit::DAYS:
return 86400;
default: default:
break; break;
} }

View File

@@ -121,6 +121,8 @@ static std::string durationUnitToString(Duration::Unit u)
return obs_module_text("AdvSceneSwitcher.unit.minutes"); return obs_module_text("AdvSceneSwitcher.unit.minutes");
case Duration::Unit::HOURS: case Duration::Unit::HOURS:
return obs_module_text("AdvSceneSwitcher.unit.hours"); return obs_module_text("AdvSceneSwitcher.unit.hours");
case Duration::Unit::DAYS:
return obs_module_text("AdvSceneSwitcher.unit.days");
default: default:
break; break;
} }
@@ -151,6 +153,8 @@ static int durationUnitToMultiplier(Duration::Unit u)
return 60; return 60;
case Duration::Unit::HOURS: case Duration::Unit::HOURS:
return 3600; return 3600;
case Duration::Unit::DAYS:
return 86400;
default: default:
break; break;
} }

View File

@@ -27,6 +27,7 @@ public:
SECONDS, SECONDS,
MINUTES, MINUTES,
HOURS, HOURS,
DAYS,
}; };
EXPORT Unit GetUnit() const { return _unit; } EXPORT Unit GetUnit() const { return _unit; }

View File

@@ -55,9 +55,7 @@ static void WriteFirstRun(bool value)
static QString DetectFocusedWindow() static QString DetectFocusedWindow()
{ {
std::string title; return QString::fromStdString(GetCurrentWindowTitle());
GetCurrentWindowTitle(title);
return QString::fromStdString(title);
} }
// =========================================================================== // ===========================================================================
@@ -400,10 +398,14 @@ void FirstRunWizard::markFirstRunComplete()
} }
// static // static
std::shared_ptr<Macro> FirstRunWizard::ShowWizard(QWidget *parent) std::shared_ptr<Macro> FirstRunWizard::ShowWizard(QWidget *parent,
bool *wasSkipped)
{ {
auto wizard = new FirstRunWizard(parent); auto wizard = new FirstRunWizard(parent);
wizard->exec(); wizard->exec();
if (wasSkipped) {
*wasSkipped = (wizard->result() == QDialog::Rejected);
}
wizard->deleteLater(); wizard->deleteLater();
return wizard->_macro; return wizard->_macro;
} }

View File

@@ -113,7 +113,8 @@ class FirstRunWizard : public QWizard {
Q_OBJECT Q_OBJECT
public: public:
explicit FirstRunWizard(QWidget *parent = nullptr); explicit FirstRunWizard(QWidget *parent = nullptr);
static std::shared_ptr<Macro> ShowWizard(QWidget *parent); static std::shared_ptr<Macro> ShowWizard(QWidget *parent,
bool *wasSkipped = nullptr);
static bool static bool
CreateMacro(std::shared_ptr<Macro> &macro, const std::string &macroName, CreateMacro(std::shared_ptr<Macro> &macro, const std::string &macroName,
const std::string &conditionId, obs_data_t *conditionData, const std::string &conditionId, obs_data_t *conditionData,

View File

@@ -75,6 +75,18 @@ static std::vector<std::function<void()>> &getStopSteps()
return steps; return steps;
} }
static std::vector<std::function<void(obs_data_t *)>> &getEarlySaveSteps()
{
static std::vector<std::function<void(obs_data_t *)>> steps;
return steps;
}
static std::vector<std::function<void(obs_data_t *)>> &getEarlyLoadSteps()
{
static std::vector<std::function<void(obs_data_t *)>> steps;
return steps;
}
static std::vector<std::function<void(obs_data_t *)>> &getSaveSteps() static std::vector<std::function<void(obs_data_t *)>> &getSaveSteps()
{ {
static std::vector<std::function<void(obs_data_t *)>> steps; static std::vector<std::function<void(obs_data_t *)>> steps;
@@ -109,6 +121,18 @@ void LoadPluginSettings(obs_data_t *obj)
GetSwitcher()->LoadSettings(obj); GetSwitcher()->LoadSettings(obj);
} }
void AddEarlySaveStep(std::function<void(obs_data_t *)> step)
{
std::lock_guard<std::mutex> lock(mutex);
getEarlySaveSteps().emplace_back(step);
}
void AddEarlyLoadStep(std::function<void(obs_data_t *)> step)
{
std::lock_guard<std::mutex> lock(mutex);
getEarlyLoadSteps().emplace_back(step);
}
void AddSaveStep(std::function<void(obs_data_t *)> step) void AddSaveStep(std::function<void(obs_data_t *)> step)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
@@ -136,6 +160,9 @@ void AddIntervalResetStep(std::function<void()> step)
void RunSaveSteps(obs_data_t *obj) void RunSaveSteps(obs_data_t *obj)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
for (const auto &func : getEarlySaveSteps()) {
func(obj);
}
for (const auto &func : getSaveSteps()) { for (const auto &func : getSaveSteps()) {
func(obj); func(obj);
} }
@@ -144,6 +171,9 @@ void RunSaveSteps(obs_data_t *obj)
void RunLoadSteps(obs_data_t *obj) void RunLoadSteps(obs_data_t *obj)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
for (const auto &func : getEarlyLoadSteps()) {
func(obj);
}
for (const auto &func : getLoadSteps()) { for (const auto &func : getLoadSteps()) {
func(obj); func(obj);
} }
@@ -310,7 +340,7 @@ bool HighlightUIElementsEnabled()
bool OBSIsShuttingDown() bool OBSIsShuttingDown()
{ {
return GetSwitcher() && GetSwitcher()->obsIsShuttingDown; return !GetSwitcher() || GetSwitcher()->obsIsShuttingDown;
} }
bool InitialLoadIsComplete() bool InitialLoadIsComplete()

View File

@@ -8,6 +8,8 @@ namespace advss {
void SavePluginSettings(obs_data_t *); void SavePluginSettings(obs_data_t *);
EXPORT void LoadPluginSettings(obs_data_t *); EXPORT void LoadPluginSettings(obs_data_t *);
void AddEarlySaveStep(std::function<void(obs_data_t *)>);
void AddEarlyLoadStep(std::function<void(obs_data_t *)>);
EXPORT void AddSaveStep(std::function<void(obs_data_t *)>); EXPORT void AddSaveStep(std::function<void(obs_data_t *)>);
EXPORT void AddLoadStep(std::function<void(obs_data_t *)>); EXPORT void AddLoadStep(std::function<void(obs_data_t *)>);
EXPORT void AddPostLoadStep(std::function<void()>); EXPORT void AddPostLoadStep(std::function<void()>);

View File

@@ -173,11 +173,10 @@ void PopulateTransitionSelection(QComboBox *sel, bool addCurrent, bool addAny,
void PopulateWindowSelection(QComboBox *sel, bool addSelect) void PopulateWindowSelection(QComboBox *sel, bool addSelect)
{ {
std::vector<std::string> windows; const auto windows = GetWindows();
GetWindowList(windows);
for (std::string &window : windows) { for (const auto &info : windows) {
sel->addItem(window.c_str()); sel->addItem(info.title.c_str());
} }
sel->model()->sort(0); sel->model()->sort(0);
@@ -257,8 +256,7 @@ void PopulateMediaSelection(QComboBox *sel, bool addSelect)
void PopulateProcessSelection(QComboBox *sel, bool addSelect) void PopulateProcessSelection(QComboBox *sel, bool addSelect)
{ {
QStringList processes; auto processes = GetProcessList();
GetProcessList(processes);
processes.sort(); processes.sort();
for (QString &process : processes) { for (QString &process : processes) {
sel->addItem(process); sel->addItem(process);

View File

@@ -162,4 +162,48 @@ bool IsMediaSource(obs_source_t *source)
return (flags & OBS_SOURCE_CONTROLLABLE_MEDIA) != 0; return (flags & OBS_SOURCE_CONTROLLABLE_MEDIA) != 0;
} }
SourceActiveKeeper::~SourceActiveKeeper()
{
ReleaseRef();
}
void SourceActiveKeeper::SetActive(bool active)
{
if (_active == active) {
return;
}
if (active) {
_active = true;
AcquireRef();
} else {
ReleaseRef();
_active = false;
}
}
void SourceActiveKeeper::SetSource(obs_source_t *source)
{
if (_source == source) {
return;
}
ReleaseRef();
_source = source;
AcquireRef();
}
void SourceActiveKeeper::AcquireRef()
{
if (_active && _source) {
obs_source_inc_active(_source);
}
}
void SourceActiveKeeper::ReleaseRef()
{
if (_active && _source) {
obs_source_dec_active(_source);
_source = nullptr;
}
}
} // namespace advss } // namespace advss

View File

@@ -20,4 +20,25 @@ EXPORT OBSWeakSource GetWeakFilterByQString(OBSWeakSource source,
EXPORT int GetSceneItemCount(const OBSWeakSource &); EXPORT int GetSceneItemCount(const OBSWeakSource &);
EXPORT bool IsMediaSource(obs_source_t *source); EXPORT bool IsMediaSource(obs_source_t *source);
// RAII helper that keeps an OBS source active (via obs_source_inc_active /
// obs_source_dec_active) for as long as the keeper is enabled.
class EXPORT SourceActiveKeeper {
public:
SourceActiveKeeper() = default;
~SourceActiveKeeper();
SourceActiveKeeper(const SourceActiveKeeper &) = delete;
SourceActiveKeeper &operator=(const SourceActiveKeeper &) = delete;
void SetActive(bool active);
void SetSource(obs_source_t *source);
private:
void AcquireRef();
void ReleaseRef();
OBSSource _source;
bool _active = false;
};
} // namespace advss } // namespace advss

View File

@@ -66,4 +66,15 @@ void Lockable::WithLock(const std::function<void()> &func)
func(); func();
} }
SuspendLock::SuspendLock(Lockable &lockable)
: _mtx(static_cast<std::mutex &>(lockable._mtx))
{
_mtx.unlock();
}
SuspendLock::~SuspendLock()
{
_mtx.lock();
}
} // namespace advss } // namespace advss

View File

@@ -51,6 +51,24 @@ public:
private: private:
PerInstanceMutex _mtx; PerInstanceMutex _mtx;
friend class SuspendLock;
};
// RAII guard that temporarily releases a Lockable's per-segment lock.
// Use this inside PerformAction() / CheckCondition() to unblock the UI
// during long-running operations while still running on the original segment.
// The caller MUST be holding the lock (i.e. be inside WithLock) when
// constructing this object; the lock is re-acquired on destruction.
class EXPORT SuspendLock {
public:
SuspendLock(Lockable &lockable);
~SuspendLock();
SuspendLock(const SuspendLock &) = delete;
SuspendLock &operator=(const SuspendLock &) = delete;
private:
std::mutex &_mtx;
}; };
} // namespace advss } // namespace advss

View File

@@ -5,11 +5,20 @@
#include "macro-edit.hpp" #include "macro-edit.hpp"
#include "macro-segment.hpp" #include "macro-segment.hpp"
#include "plugin-state-helpers.hpp" #include "plugin-state-helpers.hpp"
#include "sync-helpers.hpp"
#include "ui-helpers.hpp" #include "ui-helpers.hpp"
#include "utility.hpp" #include "utility.hpp"
#include "variable.hpp"
#include <QVariant>
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QHBoxLayout>
#include <QLabel>
#include <QPropertyAnimation>
#include <QPushButton>
#include <QToolButton>
#include <QVariant>
#include <QVBoxLayout>
#include <atomic> #include <atomic>
Q_DECLARE_METATYPE(advss::TempVariableRef); Q_DECLARE_METATYPE(advss::TempVariableRef);
@@ -731,4 +740,293 @@ void NotifyUIAboutTempVarChange(MacroSegment *segment)
segment); segment);
} }
TempVarOutputMappingsWidget::TempVarOutputMappingsWidget(QWidget *parent)
: QWidget(parent),
_rowsLayout(new QVBoxLayout()),
_addButton(new QPushButton(
obs_module_text("AdvSceneSwitcher.tempVar.outputMappings.add"),
this)),
_animation(new QPropertyAnimation(this, "maximumHeight", this))
{
_rowsLayout->setContentsMargins(0, 0, 0, 0);
_rowsLayout->setSpacing(2);
auto rowsContainer = new QWidget(this);
rowsContainer->setLayout(_rowsLayout);
auto label = new QLabel(
obs_module_text("AdvSceneSwitcher.tempVar.outputMappings"),
this);
auto mainLayout = new QVBoxLayout();
mainLayout->addWidget(label);
mainLayout->addWidget(rowsContainer);
mainLayout->addWidget(_addButton);
setLayout(mainLayout);
_animation->setDuration(300);
_animation->setEasingCurve(QEasingCurve::InOutQuad);
connect(_animation, &QPropertyAnimation::finished, this,
&TempVarOutputMappingsWidget::AnimationFinished);
hide();
connect(_addButton, &QPushButton::clicked, this,
&TempVarOutputMappingsWidget::Add);
connect(TempVarSignalManager::Instance(),
SIGNAL(SegmentTempVarsChanged(MacroSegment *)), this,
SLOT(SegmentTempVarsChanged(MacroSegment *)));
}
void TempVarOutputMappingsWidget::SetSegment(MacroSegment *segment)
{
_segment = segment;
_panelExpanded = false;
Rebuild();
}
void TempVarOutputMappingsWidget::Add()
{
if (!_segment) {
return;
}
auto mappings = _segment->GetVarMappings();
mappings.push_back(VarMapping{});
{
auto lock = LockContext();
_segment->SetVarMappings(mappings);
}
Rebuild();
}
void TempVarOutputMappingsWidget::Remove(int rowIdx)
{
if (!_segment) {
return;
}
auto mappings = _segment->GetVarMappings();
if (rowIdx < 0 || rowIdx >= (int)mappings.size()) {
return;
}
mappings.erase(mappings.begin() + rowIdx);
{
auto lock = LockContext();
_segment->SetVarMappings(mappings);
}
Rebuild();
}
void TempVarOutputMappingsWidget::SegmentTempVarsChanged(MacroSegment *segment)
{
if (segment != _segment) {
return;
}
// Re-populate each temp var combobox in case temp vars were added/removed
_loading = true;
const auto &mappings = _segment->GetVarMappings();
for (int i = 0; i < (int)_rows.size(); i++) {
auto combo = _rows[i].tempVarCombo;
const QSignalBlocker blocker(combo);
combo->clear();
PopulateTempVarCombo(combo);
if (i < (int)mappings.size() &&
mappings[i].tempVar.HasValidID()) {
QVariant v;
v.setValue(mappings[i].tempVar);
combo->setCurrentIndex(combo->findData(v));
}
}
_loading = false;
UpdateVisibility();
}
void TempVarOutputMappingsWidget::WriteBackMappings()
{
if (_loading || !_segment) {
return;
}
std::vector<VarMapping> mappings;
for (const auto &row : _rows) {
VarMapping m;
const int idx = row.tempVarCombo->currentIndex();
if (idx >= 0) {
m.tempVar = row.tempVarCombo->itemData(idx)
.value<TempVariableRef>();
}
auto item = row.varSelection->GetCurrentItem();
if (!item) {
continue;
}
m.variable = GetWeakVariableByName(item->Name());
mappings.push_back(std::move(m));
}
auto lock = LockContext();
_segment->SetVarMappings(mappings);
}
void TempVarOutputMappingsWidget::Rebuild()
{
_loading = true;
// Remove all existing row widgets from layout and delete them
for (auto &row : _rows) {
_rowsLayout->removeWidget(row.container);
delete row.container;
}
_rows.clear();
if (!_segment) {
_loading = false;
UpdateVisibility();
return;
}
const auto &mappings = _segment->GetVarMappings();
for (int i = 0; i < (int)mappings.size(); i++) {
const auto &mapping = mappings[i];
auto container = new QWidget(this);
auto rowLayout = new QHBoxLayout();
rowLayout->setContentsMargins(0, 0, 0, 0);
auto tempVarCombo = new FilterComboBox(
container,
obs_module_text("AdvSceneSwitcher.tempVar.select"));
tempVarCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
tempVarCombo->setMaximumWidth(350);
tempVarCombo->setDuplicatesEnabled(true);
PopulateTempVarCombo(tempVarCombo);
if (mapping.tempVar.HasValidID()) {
QVariant v;
v.setValue(mapping.tempVar);
tempVarCombo->setCurrentIndex(
tempVarCombo->findData(v));
}
auto arrowLabel = new QLabel(container);
{
QIcon icon;
const auto path = (GetThemeTypeName() == "Light")
? "theme:Light/right.svg"
: "theme:Dark/right.svg";
icon.addFile(QString::fromUtf8(path), QSize(),
QIcon::Normal, QIcon::Off);
arrowLabel->setPixmap(icon.pixmap(16, 16));
}
auto varSel = new VariableSelection(container);
varSel->SetVariable(mapping.variable);
auto removeBtn = new QToolButton(container);
removeBtn->setProperty("themeID", QVariant(QString::fromUtf8(
"removeIconSmall")));
removeBtn->setProperty(
"class", QVariant(QString::fromUtf8("icon-trash")));
removeBtn->setToolTip(obs_module_text(
"AdvSceneSwitcher.tempVar.outputMappings.remove"));
rowLayout->addWidget(tempVarCombo, 1);
rowLayout->addWidget(arrowLabel);
rowLayout->addWidget(varSel, 1);
rowLayout->addWidget(removeBtn);
container->setLayout(rowLayout);
_rowsLayout->addWidget(container);
_rows.push_back({container, tempVarCombo, varSel});
const int capturedIdx = i;
connect(removeBtn, &QPushButton::clicked, this,
[this, capturedIdx]() { Remove(capturedIdx); });
connect(tempVarCombo,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &TempVarOutputMappingsWidget::WriteBackMappings);
connect(varSel, &VariableSelection::SelectionChanged, this,
[this](const QString &) { WriteBackMappings(); });
}
_loading = false;
UpdateVisibility();
}
bool TempVarOutputMappingsWidget::IsExpandable() const
{
return _segment && !_segment->GetOwnTempVars().empty();
}
void TempVarOutputMappingsWidget::SetPanelExpanded(bool expanded)
{
_panelExpanded = expanded;
UpdateHeight();
}
void TempVarOutputMappingsWidget::SetSectionCollapsed(bool collapsed)
{
_sectionCollapsed = collapsed;
UpdateHeight();
}
void TempVarOutputMappingsWidget::AnimateTo(int targetHeight)
{
if (_animation->state() == QAbstractAnimation::Running) {
_animation->stop();
}
if (targetHeight > 0 && !isVisible()) {
setMinimumHeight(0);
setMaximumHeight(0);
show();
}
const int currentMax = maximumHeight();
const int currentHeight = (currentMax >= QWIDGETSIZE_MAX) ? height()
: currentMax;
_animationTargetHeight = targetHeight;
_animation->setStartValue(currentHeight);
_animation->setEndValue(targetHeight);
_animation->start();
}
void TempVarOutputMappingsWidget::AnimationFinished()
{
if (_animationTargetHeight > 0) {
setMaximumHeight(QWIDGETSIZE_MAX);
} else {
hide();
setMaximumHeight(QWIDGETSIZE_MAX);
}
}
void TempVarOutputMappingsWidget::UpdateHeight()
{
const bool shouldShow = _panelExpanded && !_sectionCollapsed &&
IsExpandable();
if (shouldShow) {
AnimateTo(sizeHint().height());
} else {
AnimateTo(0);
}
}
void TempVarOutputMappingsWidget::UpdateVisibility()
{
const bool expandable = IsExpandable();
emit ExpandableChanged(expandable);
UpdateHeight();
}
void TempVarOutputMappingsWidget::PopulateTempVarCombo(
FilterComboBox *combo) const
{
if (!_segment) {
return;
}
for (const auto &var : _segment->GetOwnTempVars()) {
QVariant v;
v.setValue(var.GetRef());
combo->addItem(QString::fromStdString(var.Name()), v);
}
}
} // namespace advss } // namespace advss

View File

@@ -5,11 +5,12 @@
#include <obs-data.h> #include <obs-data.h>
#include <mutex> #include <mutex>
#include <optional> #include <optional>
#include <QEnterEvent>
#include <QEvent>
#include <QStringList>
#include <string> #include <string>
class QPropertyAnimation;
class QPushButton;
class QVBoxLayout;
namespace advss { namespace advss {
class Macro; class Macro;
@@ -17,6 +18,9 @@ class MacroEdit;
class MacroSegment; class MacroSegment;
class TempVariableRef; class TempVariableRef;
class TempVariableSelection; class TempVariableSelection;
class TempVarOutputMappingsWidget;
class VariableSelection;
struct VarMapping;
// TempVariables are variables that are local to a given macro. // TempVariables are variables that are local to a given macro.
// They can be created and used by macro segments. // They can be created and used by macro segments.
@@ -70,6 +74,7 @@ public:
EXPORT std::optional<const TempVariable> GetTempVariable(Macro *) const; EXPORT std::optional<const TempVariable> GetTempVariable(Macro *) const;
EXPORT bool operator==(const TempVariableRef &other) const; EXPORT bool operator==(const TempVariableRef &other) const;
bool HasValidID() const { return !_id.empty(); } bool HasValidID() const { return !_id.empty(); }
std::string GetID() const { return _id; }
private: private:
enum class SegmentType { NONE, CONDITION, ACTION, ELSEACTION }; enum class SegmentType { NONE, CONDITION, ACTION, ELSEACTION };
@@ -127,4 +132,48 @@ private:
void NotifyUIAboutTempVarChange(MacroSegment *); void NotifyUIAboutTempVarChange(MacroSegment *);
EXPORT void IncrementTempVarInUseGeneration(); EXPORT void IncrementTempVarInUseGeneration();
class ADVSS_EXPORT TempVarOutputMappingsWidget : public QWidget {
Q_OBJECT
public:
TempVarOutputMappingsWidget(QWidget *parent);
void SetSegment(MacroSegment *segment);
void SetPanelExpanded(bool expanded);
void SetSectionCollapsed(bool collapsed);
bool IsExpandable() const;
signals:
void ExpandableChanged(bool);
private slots:
void Add();
void Remove(int rowIdx);
void SegmentTempVarsChanged(MacroSegment *segment);
void WriteBackMappings();
void AnimationFinished();
private:
void Rebuild();
void UpdateVisibility();
void UpdateHeight();
void AnimateTo(int targetHeight);
void PopulateTempVarCombo(FilterComboBox *combo) const;
struct MappingRow {
QWidget *container;
FilterComboBox *tempVarCombo;
VariableSelection *varSelection;
};
MacroSegment *_segment = nullptr;
QVBoxLayout *_rowsLayout;
QPushButton *_addButton;
std::vector<MappingRow> _rows;
bool _loading = false;
bool _panelExpanded = false;
bool _sectionCollapsed = false;
int _animationTargetHeight = 0;
QPropertyAnimation *_animation;
};
} // namespace advss } // namespace advss

View File

@@ -29,6 +29,7 @@ static void save(obs_data_t *data)
{ {
tabSettings.Save(data, "tabSettings"); tabSettings.Save(data, "tabSettings");
dockSettings.Save(data, "dockSettings"); dockSettings.Save(data, "dockSettings");
obs_data_set_bool(data, "addVariablesDock", addDock); obs_data_set_bool(data, "addVariablesDock", addDock);
} }
@@ -63,7 +64,6 @@ static void load(obs_data_t *data)
{ {
tabSettings.Load(data, "tabSettings"); tabSettings.Load(data, "tabSettings");
dockSettings.Load(data, "dockSettings"); dockSettings.Load(data, "dockSettings");
enableDock(obs_data_get_bool(data, "addVariablesDock")); enableDock(obs_data_get_bool(data, "addVariablesDock"));
} }

View File

@@ -1,9 +1,12 @@
#include "variable.hpp" #include "variable.hpp"
#include "math-helpers.hpp" #include "math-helpers.hpp"
#include "obs-module-helper.hpp" #include "obs-module-helper.hpp"
#include "plugin-state-helpers.hpp"
#include "ui-helpers.hpp" #include "ui-helpers.hpp"
#include "utility.hpp" #include "utility.hpp"
#include <obs.hpp>
#include <QGridLayout> #include <QGridLayout>
namespace advss { namespace advss {
@@ -15,6 +18,15 @@ static std::deque<std::shared_ptr<Item>> variables;
static std::mutex lastVariableChangeMutex; static std::mutex lastVariableChangeMutex;
static std::chrono::high_resolution_clock::time_point lastVariableChange{}; static std::chrono::high_resolution_clock::time_point lastVariableChange{};
static bool setup()
{
AddEarlySaveStep(SaveVariables);
AddEarlyLoadStep(LoadVariables);
AddPluginCleanupStep([]() { variables.clear(); });
return true;
}
static bool setupDone = setup();
static void setLastVariableChangeTime() static void setLastVariableChangeTime()
{ {
std::lock_guard<std::mutex> lock(lastVariableChangeMutex); std::lock_guard<std::mutex> lock(lastVariableChangeMutex);
@@ -418,34 +430,31 @@ static bool variableWithNameExists(const std::string &name)
void SaveVariables(obs_data_t *obj) void SaveVariables(obs_data_t *obj)
{ {
obs_data_array_t *variablesArray = obs_data_array_create(); OBSDataArrayAutoRelease variablesArray = obs_data_array_create();
for (const auto &v : variables) { for (const auto &v : variables) {
obs_data_t *array_obj = obs_data_create(); OBSDataAutoRelease array_obj = obs_data_create();
v->Save(array_obj); v->Save(array_obj);
obs_data_array_push_back(variablesArray, array_obj); obs_data_array_push_back(variablesArray, array_obj);
obs_data_release(array_obj);
} }
obs_data_set_array(obj, "variables", variablesArray); obs_data_set_array(obj, "variables", variablesArray);
obs_data_array_release(variablesArray);
} }
void LoadVariables(obs_data_t *obj) void LoadVariables(obs_data_t *obj)
{ {
variables.clear(); variables.clear();
obs_data_array_t *variablesArray = obs_data_get_array(obj, "variables"); OBSDataArrayAutoRelease variablesArray =
obs_data_get_array(obj, "variables");
size_t count = obs_data_array_count(variablesArray); size_t count = obs_data_array_count(variablesArray);
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
obs_data_t *array_obj = obs_data_array_item(variablesArray, i); OBSDataAutoRelease array_obj =
obs_data_array_item(variablesArray, i);
auto var = Variable::Create(); auto var = Variable::Create();
variables.emplace_back(var); variables.emplace_back(var);
variables.back()->Load(array_obj); variables.back()->Load(array_obj);
obs_data_release(array_obj);
} }
obs_data_array_release(variablesArray);
} }
static void signalImportedVariables(void *varsPtr) static void signalImportedVariables(void *varsPtr)
@@ -460,16 +469,15 @@ static void signalImportedVariables(void *varsPtr)
void ImportVariables(obs_data_t *data) void ImportVariables(obs_data_t *data)
{ {
obs_data_array_t *array = obs_data_get_array(data, "variables"); OBSDataArrayAutoRelease array = obs_data_get_array(data, "variables");
size_t count = obs_data_array_count(array); size_t count = obs_data_array_count(array);
auto importedVars = new std::vector<std::shared_ptr<Item>>; auto importedVars = new std::vector<std::shared_ptr<Item>>;
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
obs_data_t *arrayElement = obs_data_array_item(array, i); OBSDataAutoRelease arrayElement = obs_data_array_item(array, i);
auto var = Variable::Create(); auto var = Variable::Create();
var->Load(arrayElement); var->Load(arrayElement);
obs_data_release(arrayElement);
if (variableWithNameExists(var->Name())) { if (variableWithNameExists(var->Name())) {
continue; continue;
@@ -479,8 +487,6 @@ void ImportVariables(obs_data_t *data)
importedVars->emplace_back(var); importedVars->emplace_back(var);
} }
obs_data_array_release(array);
QueueUITask(signalImportedVariables, importedVars); QueueUITask(signalImportedVariables, importedVars);
} }

View File

@@ -1,10 +1,12 @@
#include "platform-funcs.hpp" #include "platform-funcs.hpp"
#include "plugin-state-helpers.hpp"
#include <windows.h> #include <windows.h>
#include <UIAutomation.h> #include <UIAutomation.h>
#include <util/platform.h> #include <util/platform.h>
#include <TlHelp32.h> #include <TlHelp32.h>
#include <Psapi.h> #include <Psapi.h>
#include <memory>
#include <locale> #include <locale>
#include <codecvt> #include <codecvt>
#include <string> #include <string>
@@ -16,6 +18,9 @@
#include <QWidget> #include <QWidget>
#include <mutex> #include <mutex>
#define ADVSS_WIDEN_(x) L##x
#define ADVSS_WIDEN(x) ADVSS_WIDEN_(x)
namespace advss { namespace advss {
#define MAX_SEARCH 1000 #define MAX_SEARCH 1000
@@ -133,9 +138,9 @@ const std::vector<std::string> getOBSWindows()
return lastDoneHelper->windows; return lastDoneHelper->windows;
} }
void GetWindowList(std::vector<std::string> &windows) static std::vector<std::string> getAllWindowTitles()
{ {
windows.resize(0); std::vector<std::string> windows;
EnumWindowsWithMetro(GetTitleCB, reinterpret_cast<LPARAM>(&windows)); EnumWindowsWithMetro(GetTitleCB, reinterpret_cast<LPARAM>(&windows));
// Also add OBS windows // Also add OBS windows
@@ -147,20 +152,133 @@ void GetWindowList(std::vector<std::string> &windows)
// Add entry for OBS Studio itself - see GetCurrentWindowTitle() // Add entry for OBS Studio itself - see GetCurrentWindowTitle()
windows.emplace_back("OBS"); windows.emplace_back("OBS");
return windows;
} }
void GetWindowList(QStringList &windows) static bool isWindowMaximized(HWND hwnd)
{ {
windows.clear(); if (!hwnd || hwnd == GetDesktopWindow() || hwnd == GetShellWindow()) {
return false;
std::vector<std::string> w;
GetWindowList(w);
for (auto window : w) {
windows << QString::fromStdString(window);
} }
if (IsZoomed(hwnd)) {
return true;
}
RECT appBounds;
MONITORINFO monitorInfo = {0};
monitorInfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST),
&monitorInfo);
GetWindowRect(hwnd, &appBounds);
return monitorInfo.rcMonitor.bottom == appBounds.bottom &&
monitorInfo.rcMonitor.top == appBounds.top &&
monitorInfo.rcMonitor.left == appBounds.left &&
monitorInfo.rcMonitor.right == appBounds.right;
} }
void GetCurrentWindowTitle(std::string &title) static bool isWindowFullscreen(HWND hwnd)
{
if (!hwnd || hwnd == GetDesktopWindow() || hwnd == GetShellWindow()) {
return false;
}
RECT appBounds;
MONITORINFO monitorInfo = {0};
monitorInfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST),
&monitorInfo);
GetWindowRect(hwnd, &appBounds);
return monitorInfo.rcMonitor.bottom == appBounds.bottom &&
monitorInfo.rcMonitor.top == appBounds.top &&
monitorInfo.rcMonitor.left == appBounds.left &&
monitorInfo.rcMonitor.right == appBounds.right;
}
static std::string getWindowClass(HWND hwnd)
{
std::wstring wClass;
wClass.resize(256);
int len = GetClassNameW(hwnd, &wClass[0], (int)wClass.size());
if (len <= 0) {
return "";
}
wClass.resize(len);
size_t utf8len = os_wcs_to_utf8(wClass.c_str(), 0, nullptr, 0);
std::string result;
result.resize(utf8len);
os_wcs_to_utf8(wClass.c_str(), 0, &result[0], utf8len + 1);
return result;
}
static HWND getHWNDfromTitle(const std::string &title);
static std::optional<std::string> GetTextInWindow(const std::string &window);
std::vector<WindowInfo> GetWindows(const WindowQueryOptions &options)
{
const std::string foregroundTitle = GetCurrentWindowTitle();
const auto titles = getAllWindowTitles();
std::vector<WindowInfo> result;
result.reserve(titles.size());
for (const auto &title : titles) {
WindowInfo info;
info.title = title;
const bool needHwnd = options.geometry || options.fullscreen ||
options.maximized ||
options.windowClass || options.text ||
options.focus;
if (options.focus) {
info.focused = (title == foregroundTitle);
}
if (!needHwnd || (!options.geometry && !options.fullscreen &&
!options.maximized && !options.windowClass &&
!options.text)) {
result.emplace_back(std::move(info));
continue;
}
HWND hwnd = getHWNDfromTitle(title);
if (!hwnd) {
result.emplace_back(std::move(info));
continue;
}
if (options.geometry || options.fullscreen ||
options.maximized) {
RECT rect;
if (GetWindowRect(hwnd, &rect)) {
info.x = rect.left;
info.y = rect.top;
info.width = rect.right - rect.left;
info.height = rect.bottom - rect.top;
}
}
if (options.maximized) {
info.maximized = isWindowMaximized(hwnd);
}
if (options.fullscreen) {
info.fullscreen = isWindowFullscreen(hwnd);
}
if (options.windowClass) {
info.windowClass = getWindowClass(hwnd);
}
if (options.text) {
info.text = GetTextInWindow(title);
}
result.emplace_back(std::move(info));
}
return result;
}
std::string GetCurrentWindowTitle()
{ {
HWND window = GetForegroundWindow(); HWND window = GetForegroundWindow();
DWORD pid; DWORD pid;
@@ -178,15 +296,15 @@ void GetCurrentWindowTitle(std::string &title)
// //
// So instead rely on Qt to get the title of the active window. // So instead rely on Qt to get the title of the active window.
if (GetCurrentProcessId() == pid) { if (GetCurrentProcessId() == pid) {
auto window = QApplication::activeWindow(); auto obsWindow = QApplication::activeWindow();
if (window) { if (obsWindow) {
title = window->windowTitle().toStdString(); return obsWindow->windowTitle().toStdString();
} else {
title = "OBS";
} }
return; return "OBS";
} }
std::string title;
GetWindowTitle(window, title); GetWindowTitle(window, title);
return title;
} }
static HWND getHWNDfromTitle(const std::string &title) static HWND getHWNDfromTitle(const std::string &title)
@@ -198,36 +316,6 @@ static HWND getHWNDfromTitle(const std::string &title)
return hwnd; return hwnd;
} }
bool IsMaximized(const std::string &title)
{
RECT appBounds;
MONITORINFO monitorInfo = {0};
HWND hwnd = NULL;
hwnd = getHWNDfromTitle(title);
if (!hwnd) {
return false;
}
monitorInfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST),
&monitorInfo);
if (hwnd && hwnd != GetDesktopWindow() && hwnd != GetShellWindow()) {
if (IsZoomed(hwnd)) {
return true;
}
GetWindowRect(hwnd, &appBounds);
if (monitorInfo.rcMonitor.bottom == appBounds.bottom &&
monitorInfo.rcMonitor.top == appBounds.top &&
monitorInfo.rcMonitor.left == appBounds.left &&
monitorInfo.rcMonitor.right == appBounds.right) {
return true;
}
}
return false;
}
static std::wstring GetControlText(HWND hwnd, IUIAutomationElement *element) static std::wstring GetControlText(HWND hwnd, IUIAutomationElement *element)
{ {
VARIANT var; VARIANT var;
@@ -254,7 +342,7 @@ static std::wstring GetControlText(HWND hwnd, IUIAutomationElement *element)
return text; return text;
} }
std::optional<std::string> GetTextInWindow(const std::string &window) static std::optional<std::string> GetTextInWindow(const std::string &window)
{ {
HWND hwnd = getHWNDfromTitle(window); HWND hwnd = getHWNDfromTitle(window);
if (!hwnd) { if (!hwnd) {
@@ -321,51 +409,22 @@ std::optional<std::string> GetTextInWindow(const std::string &window)
return tmp; return tmp;
} }
bool IsFullscreen(const std::string &title) QStringList GetProcessList()
{ {
RECT appBounds; QStringList processes;
MONITORINFO monitorInfo = {0};
HWND hwnd = NULL;
hwnd = getHWNDfromTitle(title);
if (!hwnd) {
return false;
}
monitorInfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST),
&monitorInfo);
if (hwnd && hwnd != GetDesktopWindow() && hwnd != GetShellWindow()) {
GetWindowRect(hwnd, &appBounds);
if (monitorInfo.rcMonitor.bottom == appBounds.bottom &&
monitorInfo.rcMonitor.top == appBounds.top &&
monitorInfo.rcMonitor.left == appBounds.left &&
monitorInfo.rcMonitor.right == appBounds.right) {
return true;
}
}
return false;
}
void GetProcessList(QStringList &processes)
{
HANDLE procSnapshot; HANDLE procSnapshot;
PROCESSENTRY32 procEntry; PROCESSENTRY32 procEntry;
procSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); procSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (procSnapshot == INVALID_HANDLE_VALUE) { if (procSnapshot == INVALID_HANDLE_VALUE) {
return; return processes;
} }
procEntry.dwSize = sizeof(PROCESSENTRY32); procEntry.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(procSnapshot, &procEntry)) { if (!Process32First(procSnapshot, &procEntry)) {
CloseHandle(procSnapshot); CloseHandle(procSnapshot);
return; return processes;
} }
do { do {
@@ -383,9 +442,10 @@ void GetProcessList(QStringList &processes)
} while (Process32Next(procSnapshot, &procEntry)); } while (Process32Next(procSnapshot, &procEntry));
CloseHandle(procSnapshot); CloseHandle(procSnapshot);
return processes;
} }
static void GetForegroundProcessName(QString &proc) static QString getForegroundProcessNameStr()
{ {
// only checks if the current foreground window is from the same executable, // only checks if the current foreground window is from the same executable,
// may return true for any window from a program // may return true for any window from a program
@@ -396,31 +456,90 @@ static void GetForegroundProcessName(QString &proc)
HANDLE process = OpenProcess( HANDLE process = OpenProcess(
PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId); PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId);
if (process == NULL) { if (process == NULL) {
return; return {};
} }
WCHAR executablePath[600]; WCHAR executablePath[600];
GetModuleFileNameEx(process, 0, executablePath, 600); GetModuleFileNameEx(process, 0, executablePath, 600);
CloseHandle(process); CloseHandle(process);
proc = QString::fromWCharArray(executablePath) return QString::fromWCharArray(executablePath)
.split(QRegularExpression("(/|\\\\)")) .split(QRegularExpression("(/|\\\\)"))
.back(); .back();
} }
void GetForegroundProcessName(std::string &proc) std::string GetForegroundProcessName()
{ {
QString temp; return getForegroundProcessNameStr().toStdString();
GetForegroundProcessName(temp); }
proc = temp.toStdString();
std::string GetForegroundProcessPath()
{
HWND foregroundWindow = GetForegroundWindow();
DWORD processId = 0;
GetWindowThreadProcessId(foregroundWindow, &processId);
HANDLE process = OpenProcess(
PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId);
if (process == NULL) {
return {};
}
WCHAR executablePath[600];
GetModuleFileNameEx(process, 0, executablePath, 600);
CloseHandle(process);
return QString::fromWCharArray(executablePath).toStdString();
}
QStringList GetProcessPathsFromName(const QString &name)
{
QStringList paths;
HANDLE procSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (procSnapshot == INVALID_HANDLE_VALUE) {
return paths;
}
PROCESSENTRY32 procEntry;
procEntry.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(procSnapshot, &procEntry)) {
CloseHandle(procSnapshot);
return paths;
}
do {
QString exeName = QString::fromWCharArray(procEntry.szExeFile);
if (exeName != name) {
continue;
}
HANDLE process =
OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE, procEntry.th32ProcessID);
if (process == NULL) {
continue;
}
WCHAR executablePath[600];
if (GetModuleFileNameEx(process, 0, executablePath, 600)) {
QString path = QString::fromWCharArray(executablePath);
if (!paths.contains(path)) {
paths.append(path);
}
}
CloseHandle(process);
} while (Process32Next(procSnapshot, &procEntry));
CloseHandle(procSnapshot);
return paths;
} }
bool IsInFocus(const QString &executable) bool IsInFocus(const QString &executable)
{ {
// only checks if the current foreground window is from the same executable, // only checks if the current foreground window is from the same executable,
// may return true for any window from a program // may return true for any window from a program
QString foregroundProc; const auto foregroundProc = getForegroundProcessNameStr();
GetForegroundProcessName(foregroundProc);
// True if executable switch equals current window // True if executable switch equals current window
bool equals = (executable == foregroundProc); bool equals = (executable == foregroundProc);
@@ -450,9 +569,86 @@ int SecondsSinceLastInput()
return (getTime() - getLastInputTime()) / 1000; return (getTime() - getLastInputTime()) / 1000;
} }
static void addPluginFolderToSymbolPath()
{
// This runs after OBS_FRONTEND_EVENT_FINISHED_LOADING, which fires after
// obs_load_all_modules() completes. By that point OBS has already called
// reset_win32_symbol_paths() -> SymInitializeW(), so DbgHelp is
// initialized and we can append our plugins subfolder (where the PDB
// files live) to the existing search path.
HMODULE dbghelp = LoadLibraryW(L"DbgHelp");
if (!dbghelp) {
return;
}
typedef BOOL(WINAPI * SymGetSearchPathW_t)(HANDLE, PWSTR, DWORD);
typedef BOOL(WINAPI * SymSetSearchPathW_t)(HANDLE, PCWSTR);
typedef BOOL(WINAPI * SymRefreshModuleList_t)(HANDLE);
auto symGetSearchPathW = reinterpret_cast<SymGetSearchPathW_t>(
GetProcAddress(dbghelp, "SymGetSearchPathW"));
auto symSetSearchPathW = reinterpret_cast<SymSetSearchPathW_t>(
GetProcAddress(dbghelp, "SymSetSearchPathW"));
auto symRefreshModuleList = reinterpret_cast<SymRefreshModuleList_t>(
GetProcAddress(dbghelp, "SymRefreshModuleList"));
if (!symGetSearchPathW || !symSetSearchPathW || !symRefreshModuleList) {
FreeLibrary(dbghelp);
return;
}
HMODULE hModule = NULL;
if (!GetModuleHandleExW(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCWSTR>(addPluginFolderToSymbolPath),
&hModule)) {
FreeLibrary(dbghelp);
return;
}
wchar_t dllDir[MAX_PATH];
if (!GetModuleFileNameW(hModule, dllDir, MAX_PATH)) {
FreeLibrary(dbghelp);
return;
}
wchar_t *lastSep = wcsrchr(dllDir, L'\\');
if (!lastSep) {
FreeLibrary(dbghelp);
return;
}
*lastSep = L'\0';
wchar_t pluginsPath[MAX_PATH];
wcsncpy_s(pluginsPath, MAX_PATH, dllDir, _TRUNCATE);
wcsncat_s(pluginsPath, MAX_PATH, L"\\" ADVSS_WIDEN(ADVSS_PLUGIN_FOLDER),
_TRUNCATE);
constexpr DWORD currentPathLen = 4096;
constexpr DWORD newPathLen = 8192;
auto currentPath = std::make_unique<wchar_t[]>(currentPathLen);
auto newPath = std::make_unique<wchar_t[]>(newPathLen);
symGetSearchPathW(GetCurrentProcess(), currentPath.get(),
currentPathLen);
if (currentPath[0] != L'\0') {
_snwprintf_s(newPath.get(), newPathLen, _TRUNCATE, L"%s;%s",
currentPath.get(), pluginsPath);
} else {
wcsncpy_s(newPath.get(), newPathLen, pluginsPath, _TRUNCATE);
}
symSetSearchPathW(GetCurrentProcess(), newPath.get());
symRefreshModuleList(GetCurrentProcess());
FreeLibrary(dbghelp);
}
void PlatformInit() void PlatformInit()
{ {
CoInitialize(NULL); CoInitialize(NULL);
AddFinishedLoadingStep(addPluginFolderToSymbolPath);
} }
void PlatformCleanup() void PlatformCleanup()

View File

@@ -1,5 +1,16 @@
#include <obs-module.h> #include <obs-module.h>
#include <obs-frontend-api.h> #include <obs-frontend-api.h>
#include <stdlib.h>
#ifdef _WIN32
#define ADVSS_SETENV(k, v) _putenv_s(k, v)
#define ADVSS_UNSETENV(k) _putenv_s(k, "")
#else
#define ADVSS_SETENV(k, v) setenv(k, v, 1)
#define ADVSS_UNSETENV(k) unsetenv(k)
#endif
#define ADVSS_INSTANCE_ENV "ADVSS_INSTANCE_LOADED"
OBS_DECLARE_MODULE() OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("advanced-scene-switcher", "en-US") OBS_MODULE_USE_DEFAULT_LOCALE("advanced-scene-switcher", "en-US")
@@ -17,6 +28,12 @@ void obs_module_post_load(void)
bool obs_module_load(void) bool obs_module_load(void)
{ {
if (getenv(ADVSS_INSTANCE_ENV)) {
blog(LOG_WARNING,
"[adv-ss] Another instance is already loaded - skipping.");
return false;
}
ADVSS_SETENV(ADVSS_INSTANCE_ENV, "1");
obs_frontend_push_ui_translation(obs_module_get_string); obs_frontend_push_ui_translation(obs_module_get_string);
InitSceneSwitcher(obs_current_module(), obs_module_text); InitSceneSwitcher(obs_current_module(), obs_module_text);
return true; return true;
@@ -25,4 +42,5 @@ bool obs_module_load(void)
void obs_module_unload(void) void obs_module_unload(void)
{ {
FreeSceneSwitcher(); FreeSceneSwitcher();
ADVSS_UNSETENV(ADVSS_INSTANCE_ENV);
} }

View File

@@ -1,14 +1,16 @@
macro(add_plugin plugin) macro(add_plugin plugin)
option(ENABLE_${plugin}_PLUGIN "Enable the ${plugin} plugin" ON) option(ENABLE_${plugin}_PLUGIN "Enable the ${plugin} plugin" ON)
if(ENABLE_${plugin}_PLUGIN) if(ENABLE_${plugin}_PLUGIN)
set_property(GLOBAL APPEND PROPERTY ADVSS_PLUGINS_PENDING ${plugin})
add_subdirectory(${plugin}) add_subdirectory(${plugin})
else()
set_property(GLOBAL APPEND PROPERTY ADVSS_PLUGINS_DISABLED_BY_OPTION
${plugin})
endif() endif()
endmacro() endmacro()
# ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- #
add_subdirectory(base)
# Add plugins below, which have dependencies to external libraries or other # Add plugins below, which have dependencies to external libraries or other
# components which might potentially not be fulfilled. # components which might potentially not be fulfilled.
@@ -28,12 +30,43 @@ install_advss_plugin_dependency(...)
... to install the plugin and its dependencies. ... to install the plugin and its dependencies.
#]] #]]
add_plugin(base)
add_plugin(http) add_plugin(http)
add_plugin(midi) add_plugin(midi)
add_plugin(mqtt) add_plugin(mqtt)
add_plugin(openvr) add_plugin(openvr)
add_plugin(schedule)
add_plugin(scripting) add_plugin(scripting)
add_plugin(stream-deck) add_plugin(stream-deck)
add_plugin(twitch) add_plugin(twitch)
add_plugin(usb) add_plugin(usb)
add_plugin(video) add_plugin(video)
# ---------------------------------------------------------------------------- #
# Print plugin summary
get_property(_advss_enabled GLOBAL PROPERTY ADVSS_PLUGINS_ENABLED)
get_property(_advss_pending GLOBAL PROPERTY ADVSS_PLUGINS_PENDING)
get_property(_advss_disabled_opt GLOBAL
PROPERTY ADVSS_PLUGINS_DISABLED_BY_OPTION)
set(_advss_disabled_deps)
foreach(_p ${_advss_pending})
if(NOT _p IN_LIST _advss_enabled)
list(APPEND _advss_disabled_deps ${_p})
endif()
endforeach()
message(STATUS "")
message(STATUS "ADVSS Plugin Summary")
message(STATUS "====================")
foreach(_p ${_advss_enabled})
message(STATUS " ENABLED: ${_p}")
endforeach()
foreach(_p ${_advss_disabled_deps})
message(STATUS " DISABLED: ${_p} (missing dependencies)")
endforeach()
foreach(_p ${_advss_disabled_opt})
message(STATUS " DISABLED: ${_p} (ENABLE_${_p}_PLUGIN=OFF)")
endforeach()
message(STATUS "")

View File

@@ -11,10 +11,11 @@ const std::string MacroActionFilter::id = "filter";
std::vector<TempVariableRef> MacroActionFilter::GetTempVarRefs() const std::vector<TempVariableRef> MacroActionFilter::GetTempVarRefs() const
{ {
if (!_tempVar.HasValidID()) { auto refs = MacroSegment::GetTempVarRefs();
return {}; if (_tempVar.HasValidID()) {
refs.push_back(_tempVar);
} }
return {_tempVar}; return refs;
} }
bool MacroActionFilter::_registered = MacroActionFactory::Register( bool MacroActionFilter::_registered = MacroActionFactory::Register(

View File

@@ -95,7 +95,7 @@ static void waitHelper(std::unique_lock<std::mutex> *lock, Macro *macro,
} }
} }
void MacroActionMedia::PerformActionHelper(obs_source_t *source) const void MacroActionMedia::PerformActionHelper(obs_source_t *source)
{ {
obs_media_state state = obs_source_media_get_state(source); obs_media_state state = obs_source_media_get_state(source);
@@ -130,6 +130,7 @@ void MacroActionMedia::PerformActionHelper(obs_source_t *source) const
SeekToPercentage(source); SeekToPercentage(source);
break; break;
case Action::WAIT_FOR_PLAYBACK_STOP: { case Action::WAIT_FOR_PLAYBACK_STOP: {
SuspendLock suspendLock(*this);
std::unique_lock<std::mutex> lock(*GetMutex()); std::unique_lock<std::mutex> lock(*GetMutex());
waitHelper(&lock, GetMacro(), source); waitHelper(&lock, GetMacro(), source);
break; break;

View File

@@ -45,7 +45,7 @@ public:
SceneSelection _scene; SceneSelection _scene;
private: private:
void PerformActionHelper(obs_source_t *) const; void PerformActionHelper(obs_source_t *);
void SeekToPercentage(obs_source_t *source) const; void SeekToPercentage(obs_source_t *source) const;
static bool _registered; static bool _registered;

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