Skip to content

Commit dbf50f9

Browse files
authored
Merge pull request #241 from Toufool/dev
Merge Dev to Master
2 parents 193e870 + 083cced commit dbf50f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+12150
-5587
lines changed

.github/workflows/lint-and-build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
branches:
1313
- main
1414
- master
15+
- dev*
1516
paths:
1617
- "**.py"
1718
- "**.ui"

.github/workflows/printenv.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ on:
88
required: true
99
default: false
1010
type: boolean
11-
# push:
12-
# branches:
13-
# - master
14-
# - dev
11+
push:
12+
branches:
13+
- master
14+
- dev
1515

1616
env:
1717
GITHUB_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}

.pre-commit-config.yaml

+5-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ repos:
1717
hooks:
1818
- id: pretty-format-ini
1919
args: [--autofix]
20-
# TODO: Re-enable in dev, master doesn't have Ruff configs
21-
# - repo: https://github.com/charliermarsh/ruff-pre-commit
22-
# rev: "v0.0.262" # Must match requirements-dev.txt
23-
# hooks:
24-
# - id: ruff
25-
# args: [--fix]
20+
- repo: https://github.com/charliermarsh/ruff-pre-commit
21+
rev: "v0.0.269" # Must match requirements-dev.txt
22+
hooks:
23+
- id: ruff
24+
args: [--fix]
2625
- repo: https://github.com/pre-commit/mirrors-autopep8
2726
rev: "v2.0.2" # Must match requirements-dev.txt
2827
hooks:

.vscode/extensions.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"davidanson.vscode-markdownlint",
66
"eamodio.gitlens",
77
"emeraldwalk.runonsave",
8+
"github.vscode-github-actions",
89
"ms-python.autopep8",
910
"ms-python.python",
1011
"ms-python.vscode-pylance",

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ This program can be used to automatically start, split, and reset your preferred
6464
- Perceptual Hash: An explanation on pHash comparison can be found [here](http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html). It is highly recommended to NOT use pHash if you use masked images, or it'll be very inaccurate.
6565

6666
#### Capture Method
67+
<!-- Keep all descriptions in sync with in-code descriptions in src/capture_method/*CaptureMethod.py-->
6768

6869
- **Windows Graphics Capture** (fast, most compatible, capped at 60fps)
6970
Only available in Windows 10.0.17134 and up.
@@ -83,13 +84,13 @@ This program can be used to automatically start, split, and reset your preferred
8384
- **Force Full Content Rendering** (very slow, can affect rendering)
8485
Uses BitBlt behind the scene, but passes a special flag to PrintWindow to force rendering the entire desktop.
8586
About 10-15x slower than BitBlt based on original window size and can mess up some applications' rendering pipelines.
86-
- **Video Capture Device**
87+
- **Video Capture Device**
8788
Uses a Video Capture Device, like a webcam, virtual cam, or capture card.
88-
If you want to use this with OBS' Virtual Camera, use the [Virtualcam plugin](https://github.com/Avasam/obs-virtual-cam/releases) instead.
8989

9090
#### Capture Device
9191

92-
Select the Video Capture Device that you wanna use if selecting the `Video Capture Device` Capture Method. <!-- Will show `[occupied]` if a device is detected but can't be started. (currently disabled because poking at devices to turn turn them off freezes some like the GV-USB2)-->
92+
Select the Video Capture Device that you wanna use if selecting the `Video Capture Device` Capture Method.
93+
<!-- Will show `[occupied]` if a device is detected but can't be started. (feature currently disabled because poking at devices to turn turn them off freezes some like the GV-USB2)-->
9394

9495
#### Show Live Similarity
9596

@@ -216,7 +217,6 @@ The AutoSplit LiveSplit Component will directly connect AutoSplit with LiveSplit
216217

217218
- For many games, it will be difficult to find a split image for the last split of the run.
218219
- The window of the capture region cannot be minimized.
219-
- OBS' integrated Virtual Camera does not work and makes AutoSplit crash.
220220

221221
## Resources
222222

docs/CONTRIBUTING.md

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ Your Pull Request has to pass all checks ot be accepted. If it is still a work-i
2828
Most coding standards will be enforced by automated tooling.
2929
As time goes on, project-specific standards and "gotchas" in the frameworks we use will be listed here.
3030

31+
### Magic numbers
32+
33+
Please avoid using magic numbers and prefer constants and enums that have a meaningful name when possible.
34+
If a constant is shared throughout the app, it should live in `src/utils.py`. Unless it is very-specific to a module.
35+
For image shape and channels, please use `utils.ImageShape` and `utils.ColorChannel`.
36+
3137
## Testing
3238

3339
None 😦 Please help us create test suites, we lack the time, but we really want (need!) them. <https://github.com/Toufool/AutoSplit/issues/216>

pyproject.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ ignore = [
4646

4747
### FIXME (no warnings in Ruff yet: https://github.com/charliermarsh/ruff/issues/1256):
4848
"PTH",
49+
# Ignore until linux support
50+
"EXE",
4951
]
5052

5153
[tool.ruff.per-file-ignores]
5254
"typings/**/*.pyi" = [
55+
"F811", # Re-exports false positives
5356
"F821", # https://github.com/charliermarsh/ruff/issues/3011
5457
# The following can't be controlled for external libraries:
5558
"N8", # Naming conventions
@@ -73,7 +76,7 @@ required-imports = ["from __future__ import annotations"]
7376
known-local-folder = [
7477
"capture_method",
7578
"gen",
76-
"AutoControlledWorker",
79+
"AutoControlledThread",
7780
"AutoSplit",
7881
"AutoSplitImage",
7982
"compare",
@@ -104,7 +107,6 @@ max-branches = 15
104107
# https://github.com/hhatto/autopep8#more-advanced-usage
105108
[tool.autopep8]
106109
max_line_length = 120
107-
recursive = true
108110
aggressive = 3
109111
ignore = [
110112
"E124", # Closing bracket may not match multi-line method invocation style (enforced by add-trailing-comma)
@@ -138,7 +140,7 @@ reportUnusedCallResult = "none"
138140
reportMissingTypeStubs = "warning"
139141
# False positives with TYPE_CHECKING
140142
reportImportCycles = "information"
141-
# False positives with PyQt .connect
143+
# False positives with PySide .connect
142144
reportFunctionMemberAccess = "none"
143145
# Extra runtime safety
144146
reportUnnecessaryComparison = "warning"

res/about.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Thank you!</string>
9797
<x>60</x>
9898
<y>150</y>
9999
<width>147</width>
100-
<height>47</height>
100+
<height>51</height>
101101
</rect>
102102
</property>
103103
<property name="text">

res/design.ui

+15
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,9 @@
972972
<property name="shortcut">
973973
<string>F1</string>
974974
</property>
975+
<property name="shortcutContext">
976+
<enum>Qt::ApplicationShortcut</enum>
977+
</property>
975978
</action>
976979
<action name="action_about">
977980
<property name="text">
@@ -988,6 +991,9 @@
988991
<property name="shortcut">
989992
<string>Ctrl+S</string>
990993
</property>
994+
<property name="shortcutContext">
995+
<enum>Qt::ApplicationShortcut</enum>
996+
</property>
991997
</action>
992998
<action name="action_load_profile">
993999
<property name="text">
@@ -996,6 +1002,9 @@
9961002
<property name="shortcut">
9971003
<string>Ctrl+O</string>
9981004
</property>
1005+
<property name="shortcutContext">
1006+
<enum>Qt::ApplicationShortcut</enum>
1007+
</property>
9991008
</action>
10001009
<action name="action_save_profile_as">
10011010
<property name="text">
@@ -1004,6 +1013,9 @@
10041013
<property name="shortcut">
10051014
<string>Ctrl+Shift+S</string>
10061015
</property>
1016+
<property name="shortcutContext">
1017+
<enum>Qt::ApplicationShortcut</enum>
1018+
</property>
10071019
</action>
10081020
<action name="action_check_for_updates">
10091021
<property name="text">
@@ -1017,6 +1029,9 @@
10171029
<property name="shortcut">
10181030
<string>Ctrl+,</string>
10191031
</property>
1032+
<property name="shortcutContext">
1033+
<enum>Qt::ApplicationShortcut</enum>
1034+
</property>
10201035
<property name="menuRole">
10211036
<enum>QAction::PreferencesRole</enum>
10221037
</property>
Binary file not shown.

scripts/build.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
& "$PSScriptRoot/compile_resources.ps1"
22

33
$arguments = @(
4+
"$PSScriptRoot/../src/AutoSplit.py",
45
'--onefile',
56
'--windowed',
67
'--additional-hooks-dir=Pyinstaller/hooks',
78
'--icon=res/icon.ico',
89
'--splash=res/splash.png')
910

10-
pyinstaller $arguments "$PSScriptRoot/../src/AutoSplit.py"
11+
Start-Process -Wait -NoNewWindow pyinstaller -ArgumentList $arguments

scripts/compile_resources.ps1

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ $originalDirectory = $pwd
22
Set-Location "$PSScriptRoot/.."
33

44
New-Item -Force -ItemType directory ./src/gen | Out-Null
5-
pyuic6 './res/about.ui' -o './src/gen/about.py'
6-
pyuic6 './res/design.ui' -o './src/gen/design.py'
7-
pyuic6 './res/settings.ui' -o './src/gen/settings.py'
8-
pyuic6 './res/update_checker.ui' -o './src/gen/update_checker.py'
5+
pyside6-uic './res/about.ui' -o './src/gen/about.py'
6+
pyside6-uic './res/design.ui' -o './src/gen/design.py'
7+
pyside6-uic './res/settings.ui' -o './src/gen/settings.py'
8+
pyside6-uic './res/update_checker.ui' -o './src/gen/update_checker.py'
99
pyside6-rcc './res/resources.qrc' -o './src/gen/resources_rc.py'
10+
$files = Get-ChildItem ./src/gen/ *.py
11+
foreach ($file in $files) {
12+
(Get-Content $file.PSPath) |
13+
ForEach-Object { $_ -replace 'import resources_rc', 'from . import resources_rc' } |
14+
Set-Content $file.PSPath
15+
}
1016
Write-Host 'Generated code from .ui files'
1117

1218
$build_vars_path = "$PSScriptRoot/../src/gen/build_vars.py"

scripts/designer.ps1

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
$qt6_applications_path = python3 -c 'import qt6_applications; print(qt6_applications.__path__[0])'
1+
$qt6_applications_import = 'import qt6_applications; print(qt6_applications.__path__[0])'
2+
$qt6_applications_path = python -c $qt6_applications_import
3+
if ($null -eq $qt6_applications_path) {
4+
Write-Host 'Designer not found, installing qt6_applications'
5+
python -m pip install qt6_applications
6+
}
7+
$qt6_applications_path = python -c $qt6_applications_import
28
& "$qt6_applications_path/Qt/bin/designer" `
39
"$PSScriptRoot/../res/design.ui" `
410
"$PSScriptRoot/../res/about.ui" `

scripts/install.ps1

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
# Alias python3 to python on Windows
2-
If ($IsWindows) {
3-
$python = (Get-Command python).Source
4-
$python3 = "$((Get-Item $python).Directory.FullName)/python3.exe"
5-
New-Item -ItemType SymbolicLink -Path $python3 -Target $python -ErrorAction SilentlyContinue
6-
}
7-
81
# Installing Python dependencies
92
$dev = If ($Env:GITHUB_JOB -eq 'Build') { '' } Else { '-dev' }
103
# Ensures installation tools are up to date. This also aliases pip to pip3 on MacOS.
11-
python3 -m pip install wheel pip setuptools --upgrade
4+
python -m pip install wheel pip setuptools --upgrade
125
pip install -r "$PSScriptRoot/requirements$dev.txt" --upgrade
136

147
# Don't compile resources on the Build CI job as it'll do so in build script

scripts/requirements-dev.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ add-trailing-comma>=2.3.0 # Added support for with statement
1111
autopep8>=2.0.0 # New checks
1212
ruff>=0.0.269 # New TODO and PYI violations
1313
#
14-
# Run `./scripts/designer.ps1` to quickly open the bundled PyQt Designer.
14+
# Run `./scripts/designer.ps1` to quickly open the bundled Qt Designer.
1515
# Can also be downloaded externally as a non-python package
1616
# qt6-applications
1717
# Types
18-
types-d3dshot
18+
types-D3DShot ; sys_platform == 'win32'
1919
types-keyboard
2020
types-Pillow
2121
types-psutil
2222
types-PyAutoGUI
2323
types-pyinstaller
24-
types-pywin32
24+
types-pywin32 ; sys_platform == 'win32'
2525
types-requests
2626
types-toml

scripts/requirements.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ certifi
77
ImageHash>=4.3.1 # Contains type information + setup as package not module
88
git+https://github.com/boppreh/keyboard.git#egg=keyboard # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568
99
numpy>=1.23.2 # Python 3.11 wheels
10-
opencv-python-headless>=4.6 # Breaking changes importing cv2.cv2
10+
# opencv-python-headless>=4.6 # Breaking changes importing cv2.cv2
11+
./res/opencv_python_headless-4.7.0+be945d8-cp37-abi3-win_amd64.whl # New typing + OBS Camera fixes
1112
packaging
1213
Pillow>=9.2 # gnome-screeshot checks
1314
psutil
1415
PyAutoGUI
15-
PyQt6>=6.4.2 # Python 3.11 support
16+
PyWinCtl>=0.0.42 # py.typed
17+
PySide6-Essentials>=6.5.1 # fixes incomplete tuple return types https://bugreports.qt.io/browse/PYSIDE-2285
1618
requests<=2.28.1 # 2.28.2 has issues with PyInstaller https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/534
1719
toml
1820
typing-extensions>=4.4.0 # @override decorator support
1921
#
2022
# Build and compile resources
2123
pyinstaller>=5.5 # Python 3.11 support
2224
pyinstaller-hooks-contrib>=2022.9 # opencv-python 4.6 support. Changes for pywintypes and comtypes
23-
PySide6-Essentials>=6.4.0.1 # Python 3.11 support
2425
#
2526
# https://peps.python.org/pep-0508/#environment-markers
2627
#

scripts/start.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
param ([string]$p1)
22
& "$PSScriptRoot/compile_resources.ps1"
3-
python3 "$PSScriptRoot/../src/AutoSplit.py" $p1
3+
python "$PSScriptRoot/../src/AutoSplit.py" $p1

src/AutoControlledWorker.py src/AutoControlledThread.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import TYPE_CHECKING
44

5-
from PyQt6 import QtCore
5+
from PySide6 import QtCore
66

77
import error_messages
88
import user_profile
@@ -11,11 +11,12 @@
1111
from AutoSplit import AutoSplit
1212

1313

14-
class AutoControlledWorker(QtCore.QObject):
14+
class AutoControlledThread(QtCore.QThread):
1515
def __init__(self, autosplit: AutoSplit):
1616
self.autosplit = autosplit
1717
super().__init__()
1818

19+
@QtCore.Slot()
1920
def run(self):
2021
while True:
2122
try:

0 commit comments

Comments
 (0)