Skip to content

Commit aa975fa

Browse files
authored
Batch of updates and fixes for 2.0.0 (#188)
* Point python_grabber to andreaschiavinato * Added summary of histogram * Backport changes from linux branch * Improved pyright and formatters usage * Config updates * Fix links * Disable next/previous while delaying * proper `is_running` variable * Fix loading and clearing of start image * Rename "already_running" to "already_open" * Fix delay intervals * Add support for start image pause time * Default to MediaCapture's d3d * Re-enable buttons after delay * Beta 1 (feature-freeze, bugfixes only)
1 parent a698ec8 commit aa975fa

29 files changed

+479
-321
lines changed

.flake8

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ max-line-length=120
55
exclude=src/gen/, typings/cv2-stubs/__init__.pyi
66
ignore=
77
W503, ; Linebreak before binary operator
8+
E124, ; Closing bracket may not match multi-line method invocation style (enforced by add-trailing-comma)
89
E402, ; Allow imports at the bottom of file
910
Y026, ; Not using typing_extensions
1011
SIM105, ; contextlib.suppress is roughly 3x slower than try/except
1112
CCE001, ; False positives for attribute docstrings
1213
per-file-ignores=
13-
; Docstrings in type stubs
14-
; Function bodys contain other than just ... (eg: raise)
15-
; Single quote docstrings
16-
typings/cv2-stubs/__init__.pyi: Q000,E704,E501,N8,A001,A002,A003,CCE002,F401, Y021,Y010,Q002
1714
; Quotes
15+
; Allow ... on same line as class
1816
; Allow ... on same line as def
1917
; Line too long
2018
; Naming conventions can't be controlled for external libraries
@@ -23,7 +21,8 @@ per-file-ignores=
2321
; Attribute names can't be controlled for external libraries
2422
; False positive Class level expression with elipsis
2523
; Type re-exports
26-
*.pyi: Q000,E704,E501,N8,A001,A002,A003,CCE002,F401
24+
; mypy 3.7 Union issue
25+
*.pyi: Q000,E701,E704,E501,N8,A001,A002,A003,CCE002,F401,Y037
2726
; PyQt methods
2827
ignore-names=closeEvent,paintEvent,keyPressEvent,mousePressEvent,mouseMoveEvent,mouseReleaseEvent
2928
; McCabe max-complexity is also taken care of by Pylint and doesn't fail the build there

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ jobs:
4747
runs-on: windows-latest
4848
strategy:
4949
fail-fast: false
50+
# Pyright is version and platform sensible
5051
matrix:
5152
python-version: ["3.9", "3.10"]
5253
steps:
5354
- name: Checkout ${{ github.repository }}/${{ github.ref }}
5455
uses: actions/checkout@v3
55-
- name: Set up Node
56-
uses: actions/setup-node@v3
5756
- name: Set up Python ${{ matrix.python-version }}
5857
uses: actions/setup-python@v4
5958
with:
@@ -63,11 +62,15 @@ jobs:
6362
- run: scripts/install.ps1
6463
shell: pwsh
6564
- name: Analysing the code with Pyright
66-
run: pyright src/ --warnings
65+
uses: jakebailey/pyright-action@v1
66+
with:
67+
working-directory: src/
68+
extra-args: --warnings
6769
Pylint:
6870
runs-on: windows-latest
6971
strategy:
7072
fail-fast: false
73+
# Pylint is version and platform sensible
7174
matrix:
7275
python-version: ["3.9", "3.10"]
7376
steps:
@@ -87,6 +90,7 @@ jobs:
8790
runs-on: windows-latest
8891
strategy:
8992
fail-fast: false
93+
# Flake8 is tied to the version of Python on which it runs. Platform checks are ignored
9094
matrix:
9195
python-version: ["3.9", "3.10"]
9296
steps:
@@ -103,6 +107,7 @@ jobs:
103107
- name: Analysing the code with Flake8
104108
run: flake8 src/ typings/
105109
Bandit:
110+
# Bandit only matters on the version deployed. Platform checks are ignored
106111
runs-on: windows-latest
107112
steps:
108113
- name: Checkout ${{ github.repository }}/${{ github.ref }}
@@ -121,6 +126,7 @@ jobs:
121126
runs-on: windows-latest
122127
strategy:
123128
fail-fast: false
129+
# Only the Python version we plan on shipping matters.
124130
matrix:
125131
python-version: ["3.10"]
126132
steps:

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"bungcip.better-toml",
55
"davidanson.vscode-markdownlint",
66
"eamodio.gitlens",
7+
"emeraldwalk.runonsave",
8+
"ms-python.autopep8",
79
"ms-python.flake8",
10+
"ms-python.isort",
811
"ms-python.pylint",
912
"ms-python.python",
1013
"ms-python.vscode-pylance",
@@ -18,6 +21,8 @@
1821
// Must disable in this workspace //
1922
// https://github.com/microsoft/vscode/issues/40239 //
2023
//
24+
// We use autopep8
25+
"ms-python.black-formatter",
2126
// VSCode has implemented an optimized version
2227
"coenraads.bracket-pair-colorizer",
2328
"coenraads.bracket-pair-colorizer-2",

.vscode/settings.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
"trailing-spaces.syntaxIgnore": [
2424
"markdown"
2525
],
26+
"emeraldwalk.runonsave": {
27+
"commands": [
28+
{
29+
"match": "\\.pyi?",
30+
"cmd": "unify ${file} --in-place --quote=\"\\\"\""
31+
},
32+
{
33+
"match": "\\.pyi?",
34+
"cmd": "add-trailing-comma ${file} --py36-plus"
35+
},
36+
]
37+
},
2638
"files.associations": {
2739
"*.json": "json",
2840
"extensions.json": "jsonc",
@@ -47,15 +59,18 @@
4759
"*.lock": true,
4860
},
4961
"[python]": {
62+
// Cannot use autotpep8 until https://github.com/microsoft/vscode-autopep8/issues/32 is fixed
63+
"editor.defaultFormatter": "ms-python.python",
5064
"editor.tabSize": 4,
5165
"editor.rulers": [
5266
72, // PEP8-17 docstrings
5367
// 79, // PEP8-17 default max
5468
// 88, // Black default
55-
99, // PEP8-17 acceptable max
69+
// 99, // PEP8-17 acceptable max
5670
120, // Our hard rule
5771
],
5872
},
73+
"python.formatting.provider": "autopep8",
5974
"python.analysis.diagnosticMode": "workspace",
6075
"python.linting.enabled": true,
6176
// Use the new Pylint extension instead
@@ -115,6 +130,7 @@
115130
"powershell.codeFormatting.useCorrectCasing": true,
116131
"powershell.codeFormatting.whitespaceBetweenParameters": true,
117132
"powershell.integratedConsole.showOnStartup": false,
133+
"terminal.integrated.defaultProfile.windows": "PowerShell",
118134
"xml.codeLens.enabled": true,
119135
"xml.format.spaceBeforeEmptyCloseTag": false,
120136
}

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,8 @@ This program can be used to automatically start, split, and reset your preferred
2727

2828
### Building
2929

30-
(This is not required for normal use)
31-
32-
- Python 3.9 - 3.10.
33-
- Microsoft Visual C++ 14.0 or greater may be required to build the executable. Get it with [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
34-
35-
- Read [requirements.txt](/scripts/requirements.txt) for more information on how to install, run and build the python code.
36-
- Run `./scripts/install.ps1` to install all dependencies.
37-
- Run the app directly with `./scripts/start.ps1 [--auto-controlled]`.
38-
- Run `./scripts/build.ps1` to build an executable.
39-
- Recompile resources after modifications by running `./scripts/compile_resources.ps1`.
40-
- All configured for VSCode, including Run (F5) and Build (Ctrl+Shift+B) commands.
30+
(This is not required for normal use)
31+
Refer to the [build instructions](build%20instructions.md) if you'd like to build the application yourself or run it directly in Python.
4132

4233
## OPTIONS
4334

@@ -72,6 +63,7 @@ This program can be used to automatically start, split, and reset your preferred
7263
- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (or pHash).
7364
- L2 Norm: This method should be fine to use for most cases. It finds the difference between each pixel, squares it, sums it over the entire image and takes the square root. This is very fast but is a problem if your image is high frequency. Any translational movement or rotation can cause similarity to be very different.
7465
- Histograms: An explanation on Histograms comparison can be found [here](https://mpatacchiola.github.io/blog/2016/11/12/the-simplest-classifier-histogram-intersection.html). This is a great method to use if you are using several masked images.
66+
> This algorithm is particular reliable when the colour is a strong predictor of the object identity. The histogram intersection [...] is robust to occluding objects in the foreground.
7567
- 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. It is very inaccurate.
7668

7769
#### Capture Method
@@ -224,7 +216,7 @@ The AutoSplit LiveSplit Component will directly connect AutoSplit with LiveSplit
224216
- Place the .dll file into your `[...]\LiveSplit\Components` folder.
225217
- Open LiveSplit -> Right Click -> Edit Layout -> Plus Button -> Control -> AutoSplit Integration.
226218
- Click Layout Settings -> AutoSplit Integration
227-
- Click the Browse buttons to locate your AutoSplit Path (path to AutoSplit.exe) and Profile Path (path to your AutoSplit `.toml` profile file) respectively.
219+
- Click the Browse buttons to locate your AutoSplit Path (path to AutoSplit executable) and Profile Path (path to your AutoSplit `.toml` profile file) respectively.
228220
- If you have not yet set saved a profile, you can do so using AutoSplit, and then go back and set your Settings Path.
229221
- Once set, click OK, and then OK again to close the Layout Editor. Right click LiveSplit -> Save Layout to save your layout. AutoSplit and your selected profile will now open automatically when opening that LiveSplit Layout `.lsl` file.
230222

build instructions.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Install and Build instructions
2+
3+
## Requirements
4+
5+
### Windows
6+
7+
- Microsoft Visual C++ 14.0 or greater may be required to build the executable. Get it with [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
8+
9+
### All platforms
10+
11+
- [Python](https://www.python.org/downloads/) 3.9+.
12+
- [Node](https://nodejs.org) is optional, but required for complete linting.
13+
- Alternatively you can install the [pyright python wrapper](https://pypi.org/project/pyright/) which has a bit of an overhead delay.
14+
- [VSCode](https://code.visualstudio.com/Download) is not required, but highly recommended.
15+
- Everything already configured in the workspace, including Run (F5) and Build (Ctrl+Shift+B) commands, default shell, and recommended extensions.
16+
- [PyCharm](https://www.jetbrains.com/pycharm/) is also a good Python IDE, but nothing is configured. If you are a PyCharm user, feel free to open a PR with all necessary workspace configurations!
17+
18+
## Install and Build steps
19+
20+
- Read [requirements.txt](/scripts/requirements.txt) for more information on how to install, run and build the python code.
21+
- Run `./scripts/install.ps1` to install all dependencies.
22+
- Run the app directly with `./scripts/start.ps1 [--auto-controlled]`.
23+
- Or debug by pressing `F5` in VSCode
24+
- Run `./scripts/build.ps1` or press `CTRL+Shift+B` in VSCode to build an executable.
25+
- Recompile resources after modifications by running `./scripts/compile_resources.ps1`.

pyproject.toml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
max_line_length = 120
55
recursive = true
66
aggressive = 3
7-
ignore = ["E70"] # Allow ... on same line as def
7+
ignore = [
8+
"E124", # Closing bracket may not match multi-line method invocation style (enforced by add-trailing-comma)
9+
"E70" # Allow ... on same line as def
10+
]
811

912

1013
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md#sample-pyprojecttoml-file
1114
[tool.pyright]
1215
typeCheckingMode = "strict"
1316
# Extra strict
14-
reportImplicitStringConcatenation="error"
15-
reportCallInDefaultInitializer="error"
16-
reportMissingSuperCall="none" # False positives on base classes
17-
reportPropertyTypeMismatch="error"
18-
reportUninitializedInstanceVariable="error"
19-
reportUnnecessaryTypeIgnoreComment="error"
17+
reportImplicitStringConcatenation = "error"
18+
reportCallInDefaultInitializer = "error"
19+
reportMissingSuperCall = "none" # False positives on base classes
20+
reportPropertyTypeMismatch = "error"
21+
reportUninitializedInstanceVariable = "error"
22+
reportUnnecessaryTypeIgnoreComment = "error"
2023
# Exclude from scanning when running pyright
2124
exclude = [
2225
# Auto generated, produces unecessary `# type: ignore`
@@ -27,7 +30,7 @@ ignore = [
2730
# We expect stub files to be incomplete or contain useless statements
2831
"**/*.pyi",
2932
]
30-
reportUnusedCallResult="none"
33+
reportUnusedCallResult = "none"
3134
# Type stubs may not be completable
3235
reportMissingTypeStubs = "warning"
3336
# False positives with TYPE_CHECKING
@@ -105,13 +108,6 @@ max-branches = 15
105108
valid-classmethod-first-arg = "self"
106109
# https://pylint.pycqa.org/en/latest/user_guide/options.html#naming-styles
107110
module-naming-style = "any"
108-
# Can't make private class with PascalCase
109-
class-rgx = "_?_?[a-zA-Z]+?$"
110-
good-names = [
111-
# PyQt methods
112-
"closeEvent", "paintEvent", "keyPressEvent", "mousePressEvent", "mouseMoveEvent", "mouseReleaseEvent",
113-
# https://github.com/PyCQA/pylint/issues/2018
114-
"id", "x", "y", "a0", "i", "t0", "t1"]
115111
disable = [
116112
# No need to mention the fixmes
117113
"fixme",
@@ -121,6 +117,8 @@ disable = [
121117
"unused-import",
122118
"wrong-import-order",
123119
"wrong-import-position",
120+
# Already taken care of by Flake8-naming, which does a better job
121+
"invalid-name",
124122
# Already taken care of and grayed out. Also conflicts with Pylance reportIncompatibleMethodOverride
125123
"unused-argument",
126124
# Only reports a single instance. Pyright does a better job anyway

res/about.ui

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
</property>
3333
<property name="windowIcon">
3434
<iconset resource="resources.qrc">
35-
<normaloff>:/resources/icon.ico</normaloff>:/resources/icon.ico</iconset>
35+
<normaloff>:/resources/icon.ico</normaloff>
36+
:/resources/icon.ico
37+
</iconset>
3638
</property>
3739
<widget class="QPushButton" name="ok_button">
3840
<property name="geometry">
@@ -101,7 +103,7 @@ Thank you!</string>
101103
</rect>
102104
</property>
103105
<property name="text">
104-
<string/>
106+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;amp;business=BYRHQG69YRHBA&amp;amp;item_name=AutoSplit+development&amp;amp;currency_code=USD&amp;amp;source=url&quot;&gt;&lt;img src=&quot;:/resources/btn_donateCC_LG.png&quot;/&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
105107
</property>
106108
<property name="pixmap">
107109
<pixmap resource="resources.qrc">:/resources/btn_donateCC_LG.png</pixmap>

res/design.ui

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,26 @@
3232
</property>
3333
<property name="windowIcon">
3434
<iconset resource="resources.qrc">
35-
<normaloff>:/resources/icon.ico</normaloff>:/resources/icon.ico</iconset>
35+
<normaloff>:/resources/icon.ico</normaloff>
36+
:/resources/icon.ico
37+
</iconset>
3638
</property>
3739
<widget class="QWidget" name="central_widget">
3840
<widget class="QLabel" name="x_label">
3941
<property name="geometry">
4042
<rect>
41-
<x>30</x>
43+
<x>11</x>
4244
<y>143</y>
43-
<width>7</width>
44-
<height>16</height>
45+
<width>44</width>
46+
<height>20</height>
4547
</rect>
4648
</property>
4749
<property name="text">
4850
<string>X</string>
4951
</property>
52+
<property name="alignment">
53+
<set>Qt::AlignCenter</set>
54+
</property>
5055
</widget>
5156
<widget class="QPushButton" name="select_region_button">
5257
<property name="geometry">
@@ -235,28 +240,34 @@
235240
<widget class="QLabel" name="width_label">
236241
<property name="geometry">
237242
<rect>
238-
<x>17</x>
243+
<x>11</x>
239244
<y>183</y>
240-
<width>33</width>
241-
<height>16</height>
245+
<width>44</width>
246+
<height>20</height>
242247
</rect>
243248
</property>
244249
<property name="text">
245250
<string>Width</string>
246251
</property>
252+
<property name="alignment">
253+
<set>Qt::AlignCenter</set>
254+
</property>
247255
</widget>
248256
<widget class="QLabel" name="height_label">
249257
<property name="geometry">
250258
<rect>
251-
<x>70</x>
259+
<x>66</x>
252260
<y>183</y>
253-
<width>41</width>
254-
<height>16</height>
261+
<width>44</width>
262+
<height>20</height>
255263
</rect>
256264
</property>
257265
<property name="text">
258266
<string>Height</string>
259267
</property>
268+
<property name="alignment">
269+
<set>Qt::AlignCenter</set>
270+
</property>
260271
</widget>
261272
<widget class="QLabel" name="fps_value_label">
262273
<property name="geometry">
@@ -416,15 +427,18 @@
416427
<widget class="QLabel" name="y_label">
417428
<property name="geometry">
418429
<rect>
419-
<x>85</x>
430+
<x>66</x>
420431
<y>143</y>
421-
<width>7</width>
422-
<height>16</height>
432+
<width>44</width>
433+
<height>20</height>
423434
</rect>
424435
</property>
425436
<property name="text">
426437
<string>Y</string>
427438
</property>
439+
<property name="alignment">
440+
<set>Qt::AlignCenter</set>
441+
</property>
428442
</widget>
429443
<widget class="QPushButton" name="align_region_button">
430444
<property name="geometry">

0 commit comments

Comments
 (0)