Skip to content

Commit

Permalink
Merge pull request #241 from Toufool/dev
Browse files Browse the repository at this point in the history
Merge Dev to Master
  • Loading branch information
Avasam authored Jun 6, 2023
2 parents 193e870 + 083cced commit dbf50f9
Show file tree
Hide file tree
Showing 41 changed files with 12,150 additions and 5,587 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
branches:
- main
- master
- dev*
paths:
- "**.py"
- "**.ui"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/printenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:
required: true
default: false
type: boolean
# push:
# branches:
# - master
# - dev
push:
branches:
- master
- dev

env:
GITHUB_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
Expand Down
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ repos:
hooks:
- id: pretty-format-ini
args: [--autofix]
# TODO: Re-enable in dev, master doesn't have Ruff configs
# - repo: https://github.com/charliermarsh/ruff-pre-commit
# rev: "v0.0.262" # Must match requirements-dev.txt
# hooks:
# - id: ruff
# args: [--fix]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.269" # Must match requirements-dev.txt
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: "v2.0.2" # Must match requirements-dev.txt
hooks:
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"davidanson.vscode-markdownlint",
"eamodio.gitlens",
"emeraldwalk.runonsave",
"github.vscode-github-actions",
"ms-python.autopep8",
"ms-python.python",
"ms-python.vscode-pylance",
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ This program can be used to automatically start, split, and reset your preferred
- 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.

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

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

#### Capture Device

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)-->
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. (feature currently disabled because poking at devices to turn turn them off freezes some like the GV-USB2)-->

#### Show Live Similarity

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

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

## Resources

Expand Down
6 changes: 6 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Your Pull Request has to pass all checks ot be accepted. If it is still a work-i
Most coding standards will be enforced by automated tooling.
As time goes on, project-specific standards and "gotchas" in the frameworks we use will be listed here.

### Magic numbers

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

## Testing

None 😦 Please help us create test suites, we lack the time, but we really want (need!) them. <https://github.com/Toufool/AutoSplit/issues/216>
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ ignore = [

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

[tool.ruff.per-file-ignores]
"typings/**/*.pyi" = [
"F811", # Re-exports false positives
"F821", # https://github.com/charliermarsh/ruff/issues/3011
# The following can't be controlled for external libraries:
"N8", # Naming conventions
Expand All @@ -73,7 +76,7 @@ required-imports = ["from __future__ import annotations"]
known-local-folder = [
"capture_method",
"gen",
"AutoControlledWorker",
"AutoControlledThread",
"AutoSplit",
"AutoSplitImage",
"compare",
Expand Down Expand Up @@ -104,7 +107,6 @@ max-branches = 15
# https://github.com/hhatto/autopep8#more-advanced-usage
[tool.autopep8]
max_line_length = 120
recursive = true
aggressive = 3
ignore = [
"E124", # Closing bracket may not match multi-line method invocation style (enforced by add-trailing-comma)
Expand Down Expand Up @@ -138,7 +140,7 @@ reportUnusedCallResult = "none"
reportMissingTypeStubs = "warning"
# False positives with TYPE_CHECKING
reportImportCycles = "information"
# False positives with PyQt .connect
# False positives with PySide .connect
reportFunctionMemberAccess = "none"
# Extra runtime safety
reportUnnecessaryComparison = "warning"
Expand Down
2 changes: 1 addition & 1 deletion res/about.ui
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Thank you!</string>
<x>60</x>
<y>150</y>
<width>147</width>
<height>47</height>
<height>51</height>
</rect>
</property>
<property name="text">
Expand Down
15 changes: 15 additions & 0 deletions res/design.ui
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,9 @@
<property name="shortcut">
<string>F1</string>
</property>
<property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum>
</property>
</action>
<action name="action_about">
<property name="text">
Expand All @@ -988,6 +991,9 @@
<property name="shortcut">
<string>Ctrl+S</string>
</property>
<property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum>
</property>
</action>
<action name="action_load_profile">
<property name="text">
Expand All @@ -996,6 +1002,9 @@
<property name="shortcut">
<string>Ctrl+O</string>
</property>
<property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum>
</property>
</action>
<action name="action_save_profile_as">
<property name="text">
Expand All @@ -1004,6 +1013,9 @@
<property name="shortcut">
<string>Ctrl+Shift+S</string>
</property>
<property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum>
</property>
</action>
<action name="action_check_for_updates">
<property name="text">
Expand All @@ -1017,6 +1029,9 @@
<property name="shortcut">
<string>Ctrl+,</string>
</property>
<property name="shortcutContext">
<enum>Qt::ApplicationShortcut</enum>
</property>
<property name="menuRole">
<enum>QAction::PreferencesRole</enum>
</property>
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion scripts/build.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
& "$PSScriptRoot/compile_resources.ps1"

$arguments = @(
"$PSScriptRoot/../src/AutoSplit.py",
'--onefile',
'--windowed',
'--additional-hooks-dir=Pyinstaller/hooks',
'--icon=res/icon.ico',
'--splash=res/splash.png')

pyinstaller $arguments "$PSScriptRoot/../src/AutoSplit.py"
Start-Process -Wait -NoNewWindow pyinstaller -ArgumentList $arguments
14 changes: 10 additions & 4 deletions scripts/compile_resources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ $originalDirectory = $pwd
Set-Location "$PSScriptRoot/.."

New-Item -Force -ItemType directory ./src/gen | Out-Null
pyuic6 './res/about.ui' -o './src/gen/about.py'
pyuic6 './res/design.ui' -o './src/gen/design.py'
pyuic6 './res/settings.ui' -o './src/gen/settings.py'
pyuic6 './res/update_checker.ui' -o './src/gen/update_checker.py'
pyside6-uic './res/about.ui' -o './src/gen/about.py'
pyside6-uic './res/design.ui' -o './src/gen/design.py'
pyside6-uic './res/settings.ui' -o './src/gen/settings.py'
pyside6-uic './res/update_checker.ui' -o './src/gen/update_checker.py'
pyside6-rcc './res/resources.qrc' -o './src/gen/resources_rc.py'
$files = Get-ChildItem ./src/gen/ *.py
foreach ($file in $files) {
(Get-Content $file.PSPath) |
ForEach-Object { $_ -replace 'import resources_rc', 'from . import resources_rc' } |
Set-Content $file.PSPath
}
Write-Host 'Generated code from .ui files'

$build_vars_path = "$PSScriptRoot/../src/gen/build_vars.py"
Expand Down
8 changes: 7 additions & 1 deletion scripts/designer.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
$qt6_applications_path = python3 -c 'import qt6_applications; print(qt6_applications.__path__[0])'
$qt6_applications_import = 'import qt6_applications; print(qt6_applications.__path__[0])'
$qt6_applications_path = python -c $qt6_applications_import
if ($null -eq $qt6_applications_path) {
Write-Host 'Designer not found, installing qt6_applications'
python -m pip install qt6_applications
}
$qt6_applications_path = python -c $qt6_applications_import
& "$qt6_applications_path/Qt/bin/designer" `
"$PSScriptRoot/../res/design.ui" `
"$PSScriptRoot/../res/about.ui" `
Expand Down
9 changes: 1 addition & 8 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
# Alias python3 to python on Windows
If ($IsWindows) {
$python = (Get-Command python).Source
$python3 = "$((Get-Item $python).Directory.FullName)/python3.exe"
New-Item -ItemType SymbolicLink -Path $python3 -Target $python -ErrorAction SilentlyContinue
}

# Installing Python dependencies
$dev = If ($Env:GITHUB_JOB -eq 'Build') { '' } Else { '-dev' }
# Ensures installation tools are up to date. This also aliases pip to pip3 on MacOS.
python3 -m pip install wheel pip setuptools --upgrade
python -m pip install wheel pip setuptools --upgrade
pip install -r "$PSScriptRoot/requirements$dev.txt" --upgrade

# Don't compile resources on the Build CI job as it'll do so in build script
Expand Down
6 changes: 3 additions & 3 deletions scripts/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ add-trailing-comma>=2.3.0 # Added support for with statement
autopep8>=2.0.0 # New checks
ruff>=0.0.269 # New TODO and PYI violations
#
# Run `./scripts/designer.ps1` to quickly open the bundled PyQt Designer.
# Run `./scripts/designer.ps1` to quickly open the bundled Qt Designer.
# Can also be downloaded externally as a non-python package
# qt6-applications
# Types
types-d3dshot
types-D3DShot ; sys_platform == 'win32'
types-keyboard
types-Pillow
types-psutil
types-PyAutoGUI
types-pyinstaller
types-pywin32
types-pywin32 ; sys_platform == 'win32'
types-requests
types-toml
7 changes: 4 additions & 3 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ certifi
ImageHash>=4.3.1 # Contains type information + setup as package not module
git+https://github.com/boppreh/keyboard.git#egg=keyboard # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568
numpy>=1.23.2 # Python 3.11 wheels
opencv-python-headless>=4.6 # Breaking changes importing cv2.cv2
# opencv-python-headless>=4.6 # Breaking changes importing cv2.cv2
./res/opencv_python_headless-4.7.0+be945d8-cp37-abi3-win_amd64.whl # New typing + OBS Camera fixes
packaging
Pillow>=9.2 # gnome-screeshot checks
psutil
PyAutoGUI
PyQt6>=6.4.2 # Python 3.11 support
PyWinCtl>=0.0.42 # py.typed
PySide6-Essentials>=6.5.1 # fixes incomplete tuple return types https://bugreports.qt.io/browse/PYSIDE-2285
requests<=2.28.1 # 2.28.2 has issues with PyInstaller https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/534
toml
typing-extensions>=4.4.0 # @override decorator support
#
# Build and compile resources
pyinstaller>=5.5 # Python 3.11 support
pyinstaller-hooks-contrib>=2022.9 # opencv-python 4.6 support. Changes for pywintypes and comtypes
PySide6-Essentials>=6.4.0.1 # Python 3.11 support
#
# https://peps.python.org/pep-0508/#environment-markers
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
param ([string]$p1)
& "$PSScriptRoot/compile_resources.ps1"
python3 "$PSScriptRoot/../src/AutoSplit.py" $p1
python "$PSScriptRoot/../src/AutoSplit.py" $p1
5 changes: 3 additions & 2 deletions src/AutoControlledWorker.py → src/AutoControlledThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING

from PyQt6 import QtCore
from PySide6 import QtCore

import error_messages
import user_profile
Expand All @@ -11,11 +11,12 @@
from AutoSplit import AutoSplit


class AutoControlledWorker(QtCore.QObject):
class AutoControlledThread(QtCore.QThread):
def __init__(self, autosplit: AutoSplit):
self.autosplit = autosplit
super().__init__()

@QtCore.Slot()
def run(self):
while True:
try:
Expand Down
Loading

0 comments on commit dbf50f9

Please sign in to comment.