Skip to content

Commit

Permalink
Merge pull request #415 from loathingKernel/develop
Browse files Browse the repository at this point in the history
Preparation for PySide6
  • Loading branch information
loathingKernel authored Jul 15, 2024
2 parents 9cecdd3 + 25a0ee4 commit e36ed5c
Show file tree
Hide file tree
Showing 103 changed files with 2,007 additions and 2,090 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/job_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ jobs:
- name: Install Target Dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-presence.txt
- name: Move files
run: mv rare/__main__.py __main__.py
- name: Build
run: >-
pyinstaller -F --name Rare
--add-data "rare/resources/languages/*:rare/resources/languages"
--add-data "rare/resources/languages/rare_*.qm:rare/resources/languages/"
--add-data "rare/resources/images/*:rare/resources/images/"
--windowed
--icon rare/resources/images/Rare.icns
Expand All @@ -43,4 +44,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Rare-${{ inputs.version }}.dmg
path: Rare.dmg
path: Rare.dmg
19 changes: 12 additions & 7 deletions .github/workflows/job_nuitka-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-python@v4
with:
cache: pip
python-version: '3.9'
python-version: '3.12'
check-latest: true
architecture: x64
- name: Install build dependencies
Expand All @@ -31,7 +31,7 @@ jobs:
--assume-yes-for-downloads
--msvc=latest
--lto=yes
--jobs=2
--jobs=4
--static-libpython=no
--standalone
--enable-plugin=anti-bloat
Expand All @@ -42,18 +42,23 @@ jobs:
--follow-imports
--nofollow-import-to="*.tests"
--nofollow-import-to="*.distutils"
--nofollow-import-to="distutils"
--nofollow-import-to="unittest"
--nofollow-import-to="pydoc"
--nofollow-import-to="tkinter"
--nofollow-import-to="test"
--prefer-source-code
--include-package=pypresence
--include-package-data=qtawesome
--include-data-dir=rare\resources\images=rare\resources\images
--include-data-files=rare\resources\languages=rare\resources\languages="*.qm"
--include-data-dir=rare\resources\images\=rare\resources\images\
--include-data-files=rare\resources\languages\=rare\resources\languages\="rare_*.qm"
--windows-icon-from-ico=rare\resources\images\Rare.ico
--windows-company-name=Rare
--windows-company-name=RareDevs
--windows-product-name=Rare
--windows-file-description=rare.exe
--windows-file-version=${{ inputs.version }}
--windows-product-version=${{ inputs.version }}
--disable-console
--windows-console-mode=disable
rare
- name: Fix QtNetwork SSL
run: |
Expand All @@ -67,4 +72,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Rare-Windows-${{ inputs.version }}.zip
path: Rare-Windows.zip
path: Rare-Windows.zip
2 changes: 1 addition & 1 deletion AppImageBuilder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ script:
# copy Logo
- cp AppDir/usr/src/rare/resources/images/Rare.png AppDir/usr/share/icons/hicolor/256x256/apps/
# Install application dependencies
- python3 -m pip install --ignore-installed --prefix=/usr --root=AppDir pypresence qtawesome legendary-gl orjson
- python3 -m pip install --ignore-installed --prefix=/usr --root=AppDir pypresence qtawesome legendary-gl orjson vdf

AppDir:
path: AppDir
Expand Down
4 changes: 2 additions & 2 deletions freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from rare import __version__

name = 'Rare'
author = 'Dummerle'
description = 'A GUI for Legendary'
author = 'RareDevs'
description = 'A gui for legendary'

shortcut_table = [
("DesktopShortcut", # Shortcut
Expand Down
8 changes: 6 additions & 2 deletions misc/generate_version_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
core = LegendaryCore()
core.login()

print(" ".join(map(lambda game: game.app_name,
random.choices(list(filter(lambda x: len(x.app_name) != 32, core.get_game_list(False))), k=2))))
print(" ".join(
map(
lambda game: game.app_name,
random.choices(list(filter(lambda x: len(x.app_name) != 32, core.get_game_list(False))), k=2)
)
))
4 changes: 2 additions & 2 deletions misc/nuitka_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ python -m nuitka ^
--prefer-source-code ^
--include-package=pypresence ^
--include-package-data=qtawesome ^
--include-data-dir=rare\resources\images=rare\resources\images ^
--include-data-files=rare\resources\languages=rare\resources\languages="*.qm" ^
--include-data-dir=rare\resources\images\=rare\resources\images\ ^
--include-data-files=rare\resources\languages\=rare\resources\languages\="rare_*.qm" ^
--windows-icon-from-ico=rare\resources\images\Rare.ico ^
--windows-company-name=Rare ^
--windows-product-name=Rare ^
Expand Down
6 changes: 4 additions & 2 deletions misc/nuitka_build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/bash

python -m nuitka \
--assume-yes-for-downloads \
--mingw64 \
Expand All @@ -21,8 +23,8 @@ python -m nuitka \
--prefer-source-code \
--include-package=pypresence \
--include-package-data=qtawesome \
--include-data-dir=rare/resources/images=rare/resources/images \
--include-data-files=rare/resources/languages=rare/resources/languages="*.qm" \
--include-data-dir=rare/resources/images/=rare/resources/images/ \
--include-data-files=rare/resources/languages/=rare/resources/languages/="rare_*.qm" \
--windows-icon-from-ico=rare/resources/images/Rare.ico \
--windows-company-name=Rare \
--windows-product-name=Rare \
Expand Down
6 changes: 2 additions & 4 deletions misc/py2ts.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/sh
#!/usr/bin/env bash

cwd="$(pwd)"
cd "$(dirname "$0")"/.. || exit

#py_files=$(find rare -iname "*.py" -not -path rare/ui)
#ui_files=$(find rare/ui -iname "*.ui")

# shellcheck disable=SC2046
pylupdate5 -noobsolete $(find rare/ -iname "*.py") -ts rare/resources/languages/source.ts

cd "$cwd" || exit
15 changes: 10 additions & 5 deletions misc/qrc2py.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
_rcc_cmd="pyrcc5 -compress 6 -threshold 0"

cwd="$(pwd)"
cd "$(dirname "$0")"/../ || exit
cd "$(dirname "${0}")"/../ || exit

resources=(
"rare/resources/images/"
Expand All @@ -10,6 +11,10 @@ resources=(
)

resources_changed=0
if [[ "$1" == "--force" ]]
then
resources_changed=1
fi

for r in "${resources[@]}"
do
Expand All @@ -22,15 +27,15 @@ done
if [[ $resources_changed -eq 1 ]]
then
echo "Re-compiling main resources"
pyrcc5 -compress 6 \
$_rcc_cmd \
rare/resources/resources.qrc \
-o rare/resources/resources.py
fi

if [[ $(git diff --name-only HEAD "rare/resources/stylesheets/RareStyle/") ]]
then
echo "Re-compiling RareStyle stylesheet resources"
pyrcc5 -compress 6 \
$_rcc_cmd \
rare/resources/stylesheets/RareStyle/stylesheet.qrc \
-o rare/resources/stylesheets/RareStyle/__init__.py
fi
Expand All @@ -39,7 +44,7 @@ fi
if [[ $(git diff --name-only HEAD "rare/resources/stylesheets/ChildOfMetropolis/") ]]
then
echo "Re-compiling ChildOfMetropolis stylesheet resources"
pyrcc5 -compress 6 \
$_rcc_cmd \
rare/resources/stylesheets/ChildOfMetropolis/stylesheet.qrc \
-o rare/resources/stylesheets/ChildOfMetropolis/__init__.py
fi
Expand Down
1 change: 1 addition & 0 deletions misc/ts2qm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
import os

for f in os.listdir(os.path.join(os.path.dirname(__file__), "../rare/resources/languages/")):
Expand Down
2 changes: 1 addition & 1 deletion misc/ui2py.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

if [ -n "${1}" ]; then
if [ ! -f "${1}" ]; then
Expand Down
33 changes: 18 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line-length = 120
target-version = ['py39', 'py310', 'py311']
target-version = ['py39', 'py310', 'py311', 'py312']
include = '\.py$'
force-exclude = '''
/(
Expand All @@ -13,27 +13,27 @@ force-exclude = '''
[tool.poetry]
name = "rare"
version = "1.10.11"
description = "A GUI for Legendary"
authors = ["Dummerle"]
description = "A gui for legendary"
authors = ["RareDevs"]
license = "GPL3"
readme = "README.md"
repository = "https://github.com/RareDevs/Rare"

[tool.poetry.dependencies]
python = "^3.9"
PyQt5 = "^5.15.7"
requests = "^2.28.1"
PyQt5 = "^5.15.7"
QtAwesome = "^1.1.1"
pypresence = { version = "^4.2.1", optional = true }
pywin32 = { version = "^304", markers = "platform_system == 'Windows'" }
legendary-gl = "^0.20.34"
pywebview = [
{ version = "^3.6.3", extras = ["cef"], platform = "windows", optional = true },
{ version = "^3.6.3", extras = ["gtk"], platform = "linux", optional = true },
{ version = "^3.6.3", extras = ["gtk"], platform = "freebsd", optional = true },
]
legendary-gl = "^0.20.34"
orjson = "^3.8.0"
vdf = "^4.3"
pywin32 = { version = "^304", markers = "platform_system == 'Windows'" }
pypresence = { version = "^4.2.1", optional = true }

[tool.poetry.scripts]
start = "rare.main:main"
Expand All @@ -50,22 +50,25 @@ PyQt5-stubs = "^5.15.6.0"

[nuitka]
assume-yes-for-downloads = true
follow-imports = true
prefer-source-code = true
mingw64 = true
lto = true
lto = false
jobs = 4
static-libpython = false
standalone = true
show-scons = false
enable-plugin = ["anti-bloat", "pyqt5"]
show-anti-bloat-changes = true
nofollow-import-to = ["*.tests", "*.distutils"]
follow-stdlib = true
follow-imports = true
nofollow-import-to = ["*.tests", "*.distutils", "distutils", "unittest", "pydoc", "tkinter", "test"]
prefer-source-code = true
include-package = "pypresence"
include-package-data = "qtawesome"
include-data-dir = "rare/resources/images=rare/resources/images"
include-data-files = "rare/resources/languages=rare/resources/laguanges=*.qm"
include-data-dir = "rare/resources/images/=rare/resources/images/"
include-data-files = "rare/resources/languages/=rare/resources/laguanges/=rare_*.qm"
windows-icon-from-ico = "rare/resources/images/Rare.ico"
windows-company-name = "Rare"
windows-product-name = "Rare"
windows-file-version = "1.9.0"
windows-product-version = "1.9.0"
windows-file-version = "1.10.11.0"
windows-product-version = "1.10.11.0"
windows-disable-console = true
44 changes: 19 additions & 25 deletions rare/commands/launcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def run(self) -> None:


class RareLauncherException(RareAppException):
def __init__(self, app: 'RareLauncher', args: Namespace, parent=None):
def __init__(self, app: "RareLauncher", args: Namespace, parent=None):
super(RareLauncherException, self).__init__(parent=parent)
self.__app = app
self.__args = args
Expand Down Expand Up @@ -148,14 +148,13 @@ def __init__(self, args: InitArgs):
if not game:
self.logger.error(f"Game {args.app_name} not found. Exiting")
return
self.rgame = RareGameSlim(self.core, game)
self.rgame = RareGameSlim(self.core, game, self)

language = self.settings.value(*options.language)
self.load_translator(language)

if (
QSettings(self).value(*options.log_games)
or (game.app_name in DETACHED_APP_NAMES and platform.system() == "Windows")
if QSettings(self).value(*options.log_games) or (
game.app_name in DETACHED_APP_NAMES and platform.system() == "Windows"
):
self.console = ConsoleDialog(game.app_title)
self.console.show()
Expand Down Expand Up @@ -271,15 +270,12 @@ def on_exit(self, exit_code: int):
if self.console:
self.console.on_process_exit(self.core.get_game(self.rgame.app_name).app_title, exit_code)

self.send_message(
FinishedModel(
action=Actions.finished,
app_name=self.rgame.app_name,
exit_code=exit_code,
playtime=int(time.time() - self.start_time)
)

)
self.send_message(FinishedModel(
action=Actions.finished,
app_name=self.rgame.app_name,
exit_code=exit_code,
playtime=int(time.time() - self.start_time),
))
self.stop()

@pyqtSlot(object)
Expand Down Expand Up @@ -313,7 +309,7 @@ def launch_game(self, args: LaunchArgs):

if self.rgame.app_name in DETACHED_APP_NAMES and platform.system() == "Windows":
if self.console:
self.console.log(f"Launching as a detached process")
self.console.log("Launching as a detached process")
subprocess.Popen([args.executable] + args.arguments, cwd=args.working_directory,
env={i: args.environment.value(i) for i in args.environment.keys()})
self.stop() # stop because we do not attach to the output
Expand All @@ -323,12 +319,10 @@ def launch_game(self, args: LaunchArgs):
self.game_process.setWorkingDirectory(args.working_directory)
self.game_process.setProcessEnvironment(args.environment)
# send start message after process started
self.game_process.started.connect(lambda: self.send_message(
StateChangedModel(
action=Actions.state_update, app_name=self.rgame.app_name,
new_state=StateChangedModel.States.started
)
))
self.game_process.started.connect(lambda: self.send_message(StateChangedModel(
action=Actions.state_update, app_name=self.rgame.app_name,
new_state=StateChangedModel.States.started
)))
# self.logger.debug("Executing prelaunch command %s, %s", args.executable, args.arguments)
self.game_process.start(args.executable, args.arguments)

Expand All @@ -338,8 +332,8 @@ def error_occurred(self, error_str: str):
self.console.on_process_exit(self.core.get_game(self.rgame.app_name).app_title, error_str)
self.send_message(ErrorModel(
error_string=error_str, app_name=self.rgame.app_name,
action=Actions.error)
)
action=Actions.error
))
self.stop()

def start_prepare(self, sync_action=None):
Expand Down Expand Up @@ -428,8 +422,8 @@ def stop(self):
def launch(args: Namespace) -> int:
args = InitArgs.from_argparse(args)

QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling, True)
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps, True)

app = RareLauncher(args)
app.setQuitOnLastWindowClosed(True)
Expand Down
4 changes: 2 additions & 2 deletions rare/commands/launcher/cloud_sync_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ def __init__(self, igame: InstalledGame, dt_local: datetime, dt_remote: datetime

def __on_upload(self):
self.status = CloudSyncDialogResult.UPLOAD
self.done(QDialog.Accepted)
self.done(QDialog.DialogCode.Accepted)

def __on_download(self):
self.status = CloudSyncDialogResult.DOWNLOAD
self.done(QDialog.Accepted)
self.done(QDialog.DialogCode.Accepted)

def done_handler(self):
self.result_ready.emit(self.status)
Expand Down
Loading

0 comments on commit e36ed5c

Please sign in to comment.