forked from Linux-Gaming/PortProtonQt
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
953ec83cf5
|
||
|
|
f9e0081fd6
|
||
|
|
bc4ba2169d
|
||
|
|
cfc05c2017
|
||
|
|
55fba9260e
|
No files matched your search
+1
-1
@@ -23,7 +23,7 @@
|
||||
- В скриптах добавлена поддержка внешних Proton из каталогов Steam `steamapps` и `compatibilitytools.d`
|
||||
- Добавлена классическая тема, приближенная по внешнему виду к PortProton для облегчения перехода на PortProtonQt
|
||||
- Для обложек добавлена поддержка APNG, animated WebP, GIF и JXL
|
||||
- Добавлена поддержка запуска `.mdf`
|
||||
- Добавлена поддержка запуска `.mdf`, `.nrg`, `.bin` и `.img`
|
||||
- Добавлена приостановка фоновой активности при потере фокуса окна
|
||||
- При запуске теперь генерируются отсутствующие изображения в `data/img` для найденных `.exe`
|
||||
- Для игр из Steam добавлено создание ярлыков на рабочем столе и в меню
|
||||
|
||||
@@ -57,7 +57,7 @@ PortProtonQt использует код и зависимости от след
|
||||
|
||||
- [Icoextract](https://github.com/jlu5/icoextract) — библиотека для извлечения иконок, лицензия [MIT](https://github.com/jlu5/icoextract/blob/master/LICENSE).
|
||||
- [HowLongToBeat Python API](https://github.com/ScrappyCocco/HowLongToBeat-PythonAPI) — библиотека для взаимодействия с HowLongToBeat, лицензия [MIT](https://github.com/ScrappyCocco/HowLongToBeat-PythonAPI/blob/master/LICENSE.md).
|
||||
- [mdf2iso](https://github.com/ScrappyCocco/HowLongToBeat-PythonAPI) — библиотека для конвертации mdf в iso, лицензия [GPLv2](https://salsa.debian.org/debian/mdf2iso/-/blob/master/gpl.txt).
|
||||
- [iat](https://sourceforge.net/projects/iat.berlios) — библиотека для конвертации mdf, nrg, bin и img в iso, лицензия GPLv3
|
||||
Полный текст лицензий см. в файле [LICENSE](LICENSE).
|
||||
|
||||
> [!WARNING]
|
||||
|
||||
@@ -18,7 +18,7 @@ pkgver() {
|
||||
}
|
||||
|
||||
build() {
|
||||
arch-meson PortProtonQt build
|
||||
arch-meson PortProtonQt build -Dnightly=true
|
||||
meson compile -C build
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ git clone https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt.git
|
||||
%build
|
||||
cd %{oname}
|
||||
%meson \
|
||||
-Dnightly=true \
|
||||
-Dpython_purelibdir=%{python3_sitelib} \
|
||||
-Dudev_rulesdir=%{_udevrulesdir}
|
||||
%meson_build
|
||||
@@ -120,6 +121,8 @@ install -Dpm 0644 ./completions/_portprotonqt -t %{buildroot}%{zsh_completions_d
|
||||
%{_datadir}/polkit-1/rules.d/ru.linux_gaming.PortProtonQt.rules
|
||||
%{_datadir}/applications/ru.linux_gaming.PortProtonQt.desktop
|
||||
%{_datadir}/portproton/scripts/
|
||||
%{_datadir}/portproton/conf/
|
||||
%{_datadir}/portproton/img/
|
||||
%{bash_completions_dir}/portprotonqt
|
||||
%{fish_completions_dir}/portprotonqt.fish
|
||||
%{zsh_completions_dir}/_portprotonqt
|
||||
|
||||
@@ -119,6 +119,8 @@ install -Dpm 0644 ./completions/_portprotonqt -t %{buildroot}%{zsh_completions_d
|
||||
%{_datadir}/polkit-1/rules.d/ru.linux_gaming.PortProtonQt.rules
|
||||
%{_datadir}/applications/ru.linux_gaming.PortProtonQt.desktop
|
||||
%{_datadir}/portproton/scripts/
|
||||
%{_datadir}/portproton/conf/
|
||||
%{_datadir}/portproton/img/
|
||||
%{bash_completions_dir}/portprotonqt
|
||||
%{fish_completions_dir}/portprotonqt.fish
|
||||
%{zsh_completions_dir}/_portprotonqt
|
||||
|
||||
@@ -11,4 +11,4 @@ Terminal=false
|
||||
Icon=ru.linux_gaming.PortProtonQt
|
||||
StartupWMClass=ru.linux_gaming.PortProtonQt
|
||||
Categories=Game;Utility;
|
||||
MimeType=x-scheme-handler/portproton;application/x-ms-dos-exec;application/x-executable;application/x-dosexec;application/x-iso9660-image;application/x-cd-image;application/x-raw-disk-image;application/x-mdf;application/x-mds-disk;
|
||||
MimeType=x-scheme-handler/portproton;application/x-ms-dos-exec;application/x-executable;application/x-dosexec;application/x-iso9660-image;application/x-cd-image;application/x-raw-disk-image;application/x-mdf;application/x-mds-disk;application/x-nrg;
|
||||
@@ -87,12 +87,12 @@ def bump_meson(path: Path, old: str, new: str) -> bool:
|
||||
|
||||
def bump_app_py(path: Path, old: str, new: str) -> bool:
|
||||
"""
|
||||
Update __app_version__ in app.py
|
||||
Update APP_VERSION fallback in app.py
|
||||
"""
|
||||
if not path.exists():
|
||||
return False
|
||||
text = path.read_text(encoding='utf-8')
|
||||
pattern = re.compile(r"(?m)^(\s*__app_version__\s*=\s*)\"" + re.escape(old) + r"\"$")
|
||||
pattern = re.compile(r"(?m)^(\s*APP_VERSION\s*=\s*)\"" + re.escape(old) + r"\"$")
|
||||
new_text, count = pattern.subn(lambda m: m.group(1) + f'"{new}"', text)
|
||||
if count:
|
||||
path.write_text(new_text, encoding='utf-8')
|
||||
|
||||
@@ -679,7 +679,8 @@ def get_files_from_meson_build(meson_file_path):
|
||||
'install_headers', # Header files installation
|
||||
'install_man', # Manual pages installation
|
||||
'install_symlink', # Symlinks installation
|
||||
'install_emptydir' # Empty directories installation
|
||||
'install_emptydir', # Empty directories installation
|
||||
'configure_file', # Files generated and potentially installed
|
||||
]
|
||||
|
||||
# Process each install function
|
||||
|
||||
+25
@@ -12,6 +12,20 @@ python3 = import('python').find_installation('python3')
|
||||
conf = configuration_data()
|
||||
conf.set('PYTHON', python3.full_path())
|
||||
|
||||
version_conf = configuration_data()
|
||||
version_conf.set_quoted('APP_VERSION', meson.project_version())
|
||||
version_conf.set_quoted('APP_COMMIT', '')
|
||||
|
||||
if get_option('nightly')
|
||||
git = find_program('git', required: false)
|
||||
if git.found()
|
||||
git_commit = run_command(git, 'rev-parse', '--short', 'HEAD', check: false)
|
||||
if git_commit.returncode() == 0
|
||||
version_conf.set_quoted('APP_COMMIT', git_commit.stdout().strip())
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Directories
|
||||
prefix = get_option('prefix')
|
||||
datadir = prefix / get_option('datadir')
|
||||
@@ -25,6 +39,17 @@ pkgdatadir = pythondir / meson.project_name()
|
||||
# C compiler for vk_gpu_info
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
configured_version = configure_file(
|
||||
input: 'portprotonqt/_version.py.in',
|
||||
output: '_version.py',
|
||||
configuration: version_conf,
|
||||
)
|
||||
|
||||
install_data(
|
||||
configured_version,
|
||||
install_dir: pythondir / meson.project_name(),
|
||||
)
|
||||
|
||||
# Install Python package
|
||||
subdir('portprotonqt')
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
|
||||
option('python_purelibdir', type: 'string', value: '', description: 'Python pure library installation directory (overrides purelib)')
|
||||
option('udev_rulesdir', type: 'string', value: '', description: 'Udev rules installation directory (overrides default)')
|
||||
option('nightly', type: 'boolean', value: false, description: 'Include git commit in application version')
|
||||
@@ -0,0 +1,2 @@
|
||||
APP_VERSION = @APP_VERSION@
|
||||
APP_COMMIT = @APP_COMMIT@
|
||||
+14
-1
@@ -1,12 +1,22 @@
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import subprocess
|
||||
import shutil
|
||||
from logging import Logger
|
||||
|
||||
__app_id__ = "ru.linux_gaming.PortProtonQt"
|
||||
__app_name__ = "PortProtonQt"
|
||||
__app_version__ = "0.1.12"
|
||||
|
||||
try:
|
||||
version_module = importlib.import_module("portprotonqt._version")
|
||||
APP_COMMIT = version_module.APP_COMMIT
|
||||
APP_VERSION = version_module.APP_VERSION
|
||||
except ImportError:
|
||||
APP_COMMIT = ""
|
||||
APP_VERSION = "0.1.12"
|
||||
|
||||
__app_version__ = APP_VERSION
|
||||
|
||||
from PySide6.QtCore import QTimer
|
||||
from PySide6.QtWidgets import QApplication, QMenu, QSystemTrayIcon
|
||||
@@ -36,6 +46,9 @@ from portprotonqt.cli import (
|
||||
from portprotonqt.localization import _, get_steam_language
|
||||
|
||||
def get_version():
|
||||
if APP_COMMIT:
|
||||
return f"{__app_version__} ({APP_COMMIT})"
|
||||
|
||||
try:
|
||||
commit = subprocess.check_output(
|
||||
["git", "rev-parse", "--short", "HEAD"],
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ from pathlib import Path
|
||||
|
||||
from portprotonqt.steam_api import get_steam_home
|
||||
|
||||
LAUNCH_FILE_EXTENSIONS = ('.exe', '.iso', '.mdf')
|
||||
LAUNCH_FILE_EXTENSIONS = ('.exe', '.iso', '.mdf', '.nrg', '.bin', '.img')
|
||||
|
||||
|
||||
def parse_args():
|
||||
@@ -65,7 +65,7 @@ def parse_args():
|
||||
parser.add_argument(
|
||||
'file_or_url',
|
||||
nargs='?',
|
||||
help="Launch file path (.exe/.iso/.mdf) or portproton:// URL"
|
||||
help="Launch file path (.exe/.iso/.mdf/.nrg/.bin/.img) or portproton:// URL"
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ def extract_exec_target_path(exec_value: str | list[str]) -> str | None:
|
||||
return None
|
||||
|
||||
for part in reversed(parts):
|
||||
if part.lower().endswith((".exe", ".iso", ".mdf")):
|
||||
if part.lower().endswith((".exe", ".iso", ".mdf", ".nrg", ".bin", ".img")):
|
||||
return os.path.expanduser(part)
|
||||
|
||||
if parts[0] in ("env", "flatpak"):
|
||||
|
||||
@@ -27,7 +27,7 @@ from portprotonqt.icon_extractor import IconExtractor, IconExtractorError
|
||||
|
||||
logger = get_logger(__name__)
|
||||
theme_manager = ThemeManager()
|
||||
DISC_IMAGE_EXTENSIONS = (".iso", ".mdf")
|
||||
DISC_IMAGE_EXTENSIONS = (".iso", ".mdf", ".nrg", ".bin", ".img")
|
||||
|
||||
|
||||
def generate_thumbnail(inputfile, outfile, size=128, force_resize=True):
|
||||
|
||||
@@ -26,7 +26,7 @@ from portprotonqt.image_utils import COVER_IMAGE_EXTENSIONS
|
||||
|
||||
logger = get_logger(__name__)
|
||||
theme_manager = ThemeManager()
|
||||
DISC_IMAGE_EXTENSIONS = (".iso", ".mdf")
|
||||
DISC_IMAGE_EXTENSIONS = (".iso", ".mdf", ".nrg", ".bin", ".img")
|
||||
THUMBNAIL_PRELOAD_ROWS = 5
|
||||
THUMBNAIL_QUEUE_LIMIT = 24
|
||||
THUMBNAIL_SCROLL_DELAY_MS = 80
|
||||
|
||||
@@ -5,6 +5,7 @@ import stat
|
||||
import subprocess
|
||||
import tempfile
|
||||
import shlex
|
||||
from typing import BinaryIO
|
||||
from portprotonqt.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
@@ -12,6 +13,15 @@ logger = get_logger(__name__)
|
||||
SYNC_HEADER = b'\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00'
|
||||
SYNC_HEADER_MDF = b'\x80\xc0\x80\x80\x80\x80\x80\xc0\x80\x80\x80\x80'
|
||||
ISO_9660_SIG = b'\x01\x43\x44\x30\x30\x31\x01\x00'
|
||||
DISC_BLOCK_SIZES = (2048, 2336, 2352, 2368, 2448)
|
||||
SVCD_SUB_HEADERS = (
|
||||
b"\x00\x00\x08\x00\x00\x00\x08\x00",
|
||||
b"\x00\x00\x09\x00\x00\x00\x09\x00",
|
||||
b"\x00\x00\x88\x00\x00\x00\x88\x00",
|
||||
b"\x00\x00\x89\x00\x00\x00\x89\x00",
|
||||
)
|
||||
UDF_SIGNATURES = (b"BEA01", b"BOOT2", b"CD001", b"CDW02", b"NSR02", b"NSR03", b"TEA01")
|
||||
CONVERTIBLE_DISC_EXTENSIONS = (".mdf", ".nrg", ".bin", ".img")
|
||||
|
||||
|
||||
class DiscImageManager:
|
||||
@@ -52,58 +62,126 @@ class DiscImageManager:
|
||||
logger.error("Failed to read ISO 9660 signature for %s: %s", file_path, e)
|
||||
return False
|
||||
|
||||
def _write_iso_from_mdf(self, mdf_path: str, iso_path: str) -> None:
|
||||
"""Convert MDF to ISO using logic from test.py or legacy fallback."""
|
||||
with open(mdf_path, "rb") as source:
|
||||
source.seek(0)
|
||||
h0 = source.read(12)
|
||||
source.seek(2352)
|
||||
h2352 = source.read(12)
|
||||
def _is_svcd_sub_header(self, header: bytes) -> bool:
|
||||
"""Return True if header matches known SVCD subheader bytes."""
|
||||
return header[:8] in SVCD_SUB_HEADERS
|
||||
|
||||
if h0 == SYNC_HEADER:
|
||||
if h2352 == SYNC_HEADER_MDF:
|
||||
sector_size = 2448
|
||||
elif h2352 == SYNC_HEADER:
|
||||
sector_size = 2352
|
||||
def _calculate_disc_layout(self, source: BinaryIO) -> tuple[int, int]:
|
||||
"""Return pregap and block size using the iat detection rules."""
|
||||
source.seek(0, os.SEEK_END)
|
||||
image_size = source.tell()
|
||||
cd_id_start = -1
|
||||
cd_id_end = 0
|
||||
header_size = 0
|
||||
|
||||
for offset in range(32768, image_size):
|
||||
source.seek(offset)
|
||||
header = source.read(12)
|
||||
if header == SYNC_HEADER:
|
||||
header_size = self._add_header_size(header_size, 16)
|
||||
continue
|
||||
if self._is_svcd_sub_header(header):
|
||||
header_size = self._add_header_size(header_size, 8)
|
||||
continue
|
||||
if header[:5] in UDF_SIGNATURES:
|
||||
if cd_id_start < 0:
|
||||
cd_id_start = offset
|
||||
else:
|
||||
raise ValueError(f"Unknown SYNC format for {mdf_path}")
|
||||
cd_id_end = offset
|
||||
break
|
||||
|
||||
source.seek(0, os.SEEK_END)
|
||||
num_sectors = source.tell() // sector_size
|
||||
source.seek(0)
|
||||
with open(iso_path, "wb") as target:
|
||||
for _ in range(num_sectors):
|
||||
sector_start = source.tell()
|
||||
header = source.read(16)
|
||||
if len(header) < 16:
|
||||
break
|
||||
mode = header[15]
|
||||
data_offset = 24 if mode == 2 else 16
|
||||
source.seek(sector_start + data_offset)
|
||||
data = source.read(2048)
|
||||
if len(data) < 2048:
|
||||
break
|
||||
target.write(data)
|
||||
source.seek(sector_start + sector_size)
|
||||
return
|
||||
if cd_id_start < 0 or cd_id_end <= cd_id_start:
|
||||
return self._detect_sector_layout(source)
|
||||
|
||||
# Legacy fallback
|
||||
block_size = self._calculate_block_size(cd_id_end - cd_id_start)
|
||||
pregap = cd_id_start - (block_size * 16) - header_size - 1
|
||||
return max(pregap, 0), block_size
|
||||
|
||||
def _add_header_size(self, header_size: int, value: int) -> int:
|
||||
"""Add a detected header size once, matching iat's mixed header logic."""
|
||||
if header_size in (value, 24):
|
||||
return header_size
|
||||
return header_size + value
|
||||
|
||||
def _calculate_block_size(self, block_delta: int) -> int:
|
||||
"""Return closest iat-supported block size for descriptor spacing."""
|
||||
for block_size in DISC_BLOCK_SIZES[:-1]:
|
||||
if block_delta % block_size == 0:
|
||||
return block_size
|
||||
return DISC_BLOCK_SIZES[-1]
|
||||
|
||||
def _detect_sector_layout(self, source: BinaryIO) -> tuple[int, int]:
|
||||
"""Fallback sector layout detection for images without two descriptors."""
|
||||
source.seek(0)
|
||||
h0 = source.read(12)
|
||||
source.seek(2352)
|
||||
h2352 = source.read(12)
|
||||
if h0 == SYNC_HEADER and h2352 == SYNC_HEADER_MDF:
|
||||
return 0, 2448
|
||||
if h0 == SYNC_HEADER:
|
||||
return 0, 2352
|
||||
return 0, 2352
|
||||
|
||||
def _write_sync_sector_data(self, target: BinaryIO, sector: bytes) -> None:
|
||||
"""Write ISO user data from a sector with a sync header."""
|
||||
mode = sector[15]
|
||||
if mode == 0:
|
||||
target.write(sector[16:2352])
|
||||
elif mode == 1:
|
||||
target.write(sector[16:2064])
|
||||
elif mode == 2:
|
||||
self._write_mode_two_sector_data(target, sector)
|
||||
else:
|
||||
raise ValueError(f"Unknown MDF sector mode {mode}")
|
||||
|
||||
def _write_mode_two_sector_data(self, target: BinaryIO, sector: bytes) -> None:
|
||||
"""Write ISO user data from a Mode 2 sector."""
|
||||
sub_header = sector[16:24]
|
||||
if sub_header[:4] != sub_header[4:8]:
|
||||
target.write(sector[16:2352])
|
||||
return
|
||||
if sub_header[2] & 0x20:
|
||||
target.write(sector[24:2348])
|
||||
return
|
||||
target.write(sector[24:2072])
|
||||
|
||||
def _write_headerless_sector_data(self, target: BinaryIO, sector: bytes) -> bool:
|
||||
"""Write ISO user data from a 2336-byte headerless sector."""
|
||||
sub_header = sector[:8]
|
||||
if sub_header[:4] != sub_header[4:8]:
|
||||
return False
|
||||
if self._is_svcd_sub_header(sub_header):
|
||||
target.write(sector[8:2332])
|
||||
else:
|
||||
target.write(sector[8:2056])
|
||||
return True
|
||||
|
||||
def _write_iso_from_mdf(self, mdf_path: str, iso_path: str) -> None:
|
||||
"""Convert MDF to ISO using iat-compatible sector extraction."""
|
||||
with open(mdf_path, "rb") as source, open(iso_path, "wb") as target:
|
||||
sector_index = 0
|
||||
while True:
|
||||
sector = source.read(2352)
|
||||
pregap, block_size = self._calculate_disc_layout(source)
|
||||
image_size = os.path.getsize(mdf_path)
|
||||
source.seek(pregap)
|
||||
sector_index = pregap
|
||||
while sector_index < image_size:
|
||||
sector = source.read(block_size)
|
||||
if not sector:
|
||||
return
|
||||
if len(sector) != 2352:
|
||||
if len(sector) != block_size:
|
||||
raise ValueError(f"Truncated MDF sector at {sector_index}")
|
||||
mode = sector[15]
|
||||
if mode == 1:
|
||||
target.write(sector[16:2064])
|
||||
elif mode == 2:
|
||||
target.write(sector[24:2072])
|
||||
if sector.startswith(SYNC_HEADER):
|
||||
self._write_sync_sector_data(target, sector)
|
||||
elif block_size == 2336 and not self._write_headerless_sector_data(target, sector):
|
||||
sector_index += 1
|
||||
source.seek(sector_index)
|
||||
continue
|
||||
elif block_size == 2048:
|
||||
target.write(sector)
|
||||
else:
|
||||
raise ValueError(f"Unknown MDF sector mode {mode} at {sector_index}")
|
||||
sector_index += 1
|
||||
sector_index += 1
|
||||
source.seek(sector_index)
|
||||
continue
|
||||
sector_index += block_size
|
||||
|
||||
def _convert_mdf_to_iso(self, mdf_path: str) -> str | None:
|
||||
"""Convert raw 2352-byte sector MDF to temporary ISO."""
|
||||
@@ -223,7 +301,10 @@ class DiscImageManager:
|
||||
logger.error("7zz or 7z is required to extract MDF set %s", mdf_path)
|
||||
return None
|
||||
|
||||
mdf_sources = self._get_mdf_sources(normalized_mdf)
|
||||
if normalized_mdf.lower().endswith(".mdf"):
|
||||
mdf_sources = self._get_mdf_sources(normalized_mdf)
|
||||
else:
|
||||
mdf_sources = [normalized_mdf]
|
||||
source_stamp = self._get_disc_source_stamp(mdf_sources)
|
||||
if not source_stamp:
|
||||
return None
|
||||
@@ -261,7 +342,7 @@ class DiscImageManager:
|
||||
def sync_iso_to_rw(self, iso_path: str) -> str | None:
|
||||
"""Extract disc image content to writable runtime directory if source changed."""
|
||||
normalized_iso = os.path.abspath(os.path.expanduser(iso_path))
|
||||
if normalized_iso.lower().endswith(".mdf"):
|
||||
if normalized_iso.lower().endswith(CONVERTIBLE_DISC_EXTENSIONS):
|
||||
return self._sync_mdf_set_to_rw(normalized_iso)
|
||||
rw_root = self._iso_rw_paths.get(normalized_iso, self._get_iso_rw_root(normalized_iso))
|
||||
os.makedirs(rw_root, exist_ok=True)
|
||||
|
||||
@@ -69,7 +69,7 @@ from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import datetime
|
||||
|
||||
logger = get_logger(__name__)
|
||||
DISC_IMAGE_EXTENSIONS = (".iso", ".mdf")
|
||||
DISC_IMAGE_EXTENSIONS = (".iso", ".mdf", ".nrg", ".bin", ".img")
|
||||
|
||||
class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWindowWorkersMixin, QMainWindow):
|
||||
games_loaded = Signal(list)
|
||||
|
||||
Reference in new issue
Block a user