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;
|
||||
@@ -1282,11 +1282,7 @@ init_wine_ver () {
|
||||
}
|
||||
|
||||
pw_init_runtime () {
|
||||
if [[ ! -f "${PW_WINELIB}/runtime/files/bin/vkcube" ]] \
|
||||
|| [[ ! -f "${PW_WINELIB}/pressure-vessel/bin/pressure-vessel-wrap" ]]
|
||||
then
|
||||
export PW_USE_RUNTIME="0"
|
||||
fi
|
||||
check_flatpak && export PW_USE_RUNTIME="0"
|
||||
if [[ "$PW_USE_RUNTIME" != "1" ]] \
|
||||
|| [[ "$PW_WINE_USE" == "USE_SYSTEM_WINE" ]]
|
||||
then
|
||||
@@ -2519,7 +2515,7 @@ pw_enable_gamemode_basic () {
|
||||
start_portproton () {
|
||||
pw_check_and_download_plugins
|
||||
|
||||
if [[ "${PW_DISABLE_RUNTIME_DOWNLOAD}" == "1" ]] ; then
|
||||
if check_flatpak ; then
|
||||
try_remove_dir "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}"
|
||||
else
|
||||
pw_check_and_download_runtime
|
||||
@@ -4107,12 +4103,7 @@ gui_edit_db () {
|
||||
if [[ $PW_WINE_USE =~ (PROTON_LG|WINE_LG) ]] || [[ $PW_VULKAN_USE == "0" ]] ; then
|
||||
DISABLE_EDIT_DB_LIST+=" PW_USE_SUPPLIED_DXVK_VKD3D"
|
||||
fi
|
||||
|
||||
if [[ ! -f "${PW_WINELIB}/runtime/files/bin/vkcube" ]] \
|
||||
|| [[ ! -f "${PW_WINELIB}/pressure-vessel/bin/pressure-vessel-wrap" ]]
|
||||
then
|
||||
DISABLE_EDIT_DB_LIST+=" PW_USE_RUNTIME"
|
||||
fi
|
||||
check_flatpak && DISABLE_EDIT_DB_LIST+=" PW_USE_RUNTIME"
|
||||
|
||||
# GALLIUM NINE
|
||||
[[ ! -f "${PW_TMPFS_PATH}/gallium_nine.tmp" ]] && DISABLE_EDIT_DB_LIST+=" PW_USE_GALLIUM_NINE"
|
||||
|
||||
@@ -37,11 +37,6 @@ if [[ -z "$PORT_DATA_PATH" ]] ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f "$HOME/.config/PortProtonQt.conf" ]] \
|
||||
&& grep "disable_runtime_download = True" "$HOME/.config/PortProtonQt.conf" ; then
|
||||
export PW_DISABLE_RUNTIME_DOWNLOAD=1
|
||||
fi
|
||||
|
||||
export PORT_SCRIPTS_PATH PORT_IMG_PATH PORT_DATA_PATH PORT_CONF_PATH
|
||||
export PW_LOG_FILE="${PORT_DATA_PATH}/PortProton.log"
|
||||
|
||||
|
||||
@@ -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
-2
@@ -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"],
|
||||
@@ -156,7 +169,6 @@ def main():
|
||||
portproton_location = get_portproton_location()
|
||||
if portproton_location:
|
||||
os.environ["PORT_DATA_PATH"] = portproton_location
|
||||
ui_config.get_disable_runtime_download()
|
||||
|
||||
# Check if running as Steam compatibility tool (STEAM_COMPAT=1).
|
||||
is_steam_compat = os.environ.get("STEAM_COMPAT") == "1"
|
||||
|
||||
+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"):
|
||||
|
||||
@@ -11,7 +11,6 @@ from portprotonqt.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
THEME_VARIANTS = ("dark", "light", "auto")
|
||||
DOWNLOADS_SECTION = "Downloads"
|
||||
|
||||
|
||||
def _get_theme_base_name(theme_name: str) -> str:
|
||||
@@ -245,64 +244,21 @@ class UIConfig(BaseConfig):
|
||||
|
||||
def get_economy_mode(self) -> bool:
|
||||
"""Get economy mode setting."""
|
||||
return self._get_download_bool("economy_mode", False)
|
||||
return self._get_bool("economy_mode", False)
|
||||
|
||||
def set_economy_mode(self, enabled: bool):
|
||||
"""Set economy mode setting."""
|
||||
validate_bool(enabled, "economy_mode")
|
||||
self._save_download_value("economy_mode", enabled)
|
||||
|
||||
def _get_download_bool(self, option: str, default: bool) -> bool:
|
||||
cp = self._read_config()
|
||||
if cp is None:
|
||||
return self._save_download_value(option, default)
|
||||
|
||||
try:
|
||||
if cp.has_option(DOWNLOADS_SECTION, option):
|
||||
return cp.getboolean(DOWNLOADS_SECTION, option, fallback=default)
|
||||
if cp.has_option(self._section, option):
|
||||
return cp.getboolean(self._section, option, fallback=default)
|
||||
except ValueError as e:
|
||||
logger.warning("Error reading %s: %s", option, e)
|
||||
return self._save_download_value(option, default)
|
||||
except configparser.Error as e:
|
||||
logger.warning("Error reading %s: %s", option, e)
|
||||
return self._save_download_value(option, default)
|
||||
|
||||
return self._save_download_value(option, default)
|
||||
|
||||
def _save_download_value(self, option: str, value: bool) -> bool:
|
||||
validate_bool(value, option)
|
||||
cp = self._read_config() or configparser.ConfigParser()
|
||||
if DOWNLOADS_SECTION not in cp:
|
||||
cp[DOWNLOADS_SECTION] = {}
|
||||
|
||||
cp[DOWNLOADS_SECTION][option] = str(value)
|
||||
if cp.has_section(self._section):
|
||||
cp.remove_option(self._section, option)
|
||||
self._save_config(cp)
|
||||
return value
|
||||
self._save_value("economy_mode", enabled, "bool")
|
||||
|
||||
def get_download_wine_to_steam(self) -> bool:
|
||||
"""Get Steam compatibility tools download setting."""
|
||||
return self._get_download_bool("download_wine_to_steam", False)
|
||||
return self._get_bool("download_wine_to_steam", False)
|
||||
|
||||
def set_download_wine_to_steam(self, enabled: bool) -> None:
|
||||
"""Set Steam compatibility tools download setting."""
|
||||
validate_bool(enabled, "download_wine_to_steam")
|
||||
self._save_download_value("download_wine_to_steam", enabled)
|
||||
|
||||
def get_disable_runtime_download(self) -> bool:
|
||||
"""Get PortProton runtime download setting."""
|
||||
default = bool(os.getenv("FLATPAK_ID"))
|
||||
return self._get_download_bool("disable_runtime_download", default)
|
||||
|
||||
def set_disable_runtime_download(self, enabled: bool) -> None:
|
||||
"""Set PortProton runtime download setting."""
|
||||
if os.getenv("FLATPAK_ID"):
|
||||
enabled = True
|
||||
validate_bool(enabled, "disable_runtime_download")
|
||||
self._save_download_value("disable_runtime_download", enabled)
|
||||
self._save_value("download_wine_to_steam", enabled, "bool")
|
||||
|
||||
|
||||
def load_theme_metainfo(theme_name: str) -> dict:
|
||||
|
||||
@@ -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)
|
||||
@@ -2364,23 +2364,6 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
|
||||
hide_autoinstall_layout.addStretch()
|
||||
uiForm.addRow(hide_autoinstall_layout)
|
||||
|
||||
disable_runtime_download_layout = None
|
||||
if not os.getenv("FLATPAK_ID"):
|
||||
self.disableRuntimeDownloadCheckBox = QCheckBox()
|
||||
self.disableRuntimeDownloadCheckBox.setStyleSheet(self.theme.CHECKBOX_STYLE)
|
||||
self.disableRuntimeDownloadCheckBox.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
self.disableRuntimeDownloadTitle = QLabel(_("Disable PortProton runtime download"))
|
||||
self.disableRuntimeDownloadTitle.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
|
||||
self.disableRuntimeDownloadTitle.setStyleSheet(self.theme.SETTINGS_TITLE_CHECKBOX_STYLE)
|
||||
self.disableRuntimeDownloadTitle.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
self.disableRuntimeDownloadCheckBox.setChecked(ui_config.get_disable_runtime_download())
|
||||
disable_runtime_download_layout = QHBoxLayout()
|
||||
disable_runtime_download_layout.setContentsMargins(0, 0, 0, 0)
|
||||
disable_runtime_download_layout.addWidget(self.disableRuntimeDownloadCheckBox)
|
||||
disable_runtime_download_layout.addWidget(self.disableRuntimeDownloadTitle)
|
||||
disable_runtime_download_layout.addStretch()
|
||||
|
||||
download_wine_to_steam_layout = None
|
||||
self.steamCompatCheckBox = QCheckBox()
|
||||
self.steamCompatCheckBox.setStyleSheet(self.theme.CHECKBOX_STYLE)
|
||||
self.steamCompatCheckBox.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
@@ -2411,6 +2394,7 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
|
||||
download_wine_to_steam_layout.addWidget(self.downloadWineToSteamCheckBox)
|
||||
download_wine_to_steam_layout.addWidget(self.downloadWineToSteamTitle)
|
||||
download_wine_to_steam_layout.addStretch()
|
||||
uiForm.addRow(download_wine_to_steam_layout)
|
||||
|
||||
self.economyModeCheckBox = QCheckBox()
|
||||
self.economyModeCheckBox.setStyleSheet(self.theme.CHECKBOX_STYLE)
|
||||
@@ -2434,6 +2418,7 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
|
||||
economy_mode_layout.addWidget(self.economyModeCheckBox)
|
||||
economy_mode_layout.addWidget(self.economyModeTitle)
|
||||
economy_mode_layout.addStretch()
|
||||
uiForm.addRow(economy_mode_layout)
|
||||
|
||||
self.forceSystemDpiCheckBox = QCheckBox()
|
||||
self.forceSystemDpiCheckBox.setStyleSheet(self.theme.CHECKBOX_STYLE)
|
||||
@@ -2451,20 +2436,7 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
|
||||
force_system_dpi_layout.addStretch()
|
||||
uiForm.addRow(force_system_dpi_layout)
|
||||
|
||||
# 3. Download Settings Section
|
||||
downloadFrame, downloadForm = create_section(_("Download Settings"), self.theme)
|
||||
downloadForm.setRowWrapPolicy(QFormLayout.RowWrapPolicy.DontWrapRows)
|
||||
scrollLayout.addWidget(downloadFrame)
|
||||
|
||||
if disable_runtime_download_layout is not None:
|
||||
downloadForm.addRow(disable_runtime_download_layout)
|
||||
|
||||
if download_wine_to_steam_layout is not None:
|
||||
downloadForm.addRow(download_wine_to_steam_layout)
|
||||
|
||||
downloadForm.addRow(economy_mode_layout)
|
||||
|
||||
# 4. Gamepad Settings Section
|
||||
# 3. Gamepad Settings Section
|
||||
padFrame, padForm = create_section(_("Gamepad Settings"), self.theme)
|
||||
padForm.setRowWrapPolicy(QFormLayout.RowWrapPolicy.DontWrapRows)
|
||||
scrollLayout.addWidget(padFrame)
|
||||
@@ -2485,7 +2457,7 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
|
||||
auto_fullscreen_layout.addStretch()
|
||||
padForm.addRow(auto_fullscreen_layout)
|
||||
|
||||
# 5. Hardware Settings Section
|
||||
# 4. Hardware Settings Section
|
||||
hwFrame, hwForm = create_section(_("Hardware Settings"), self.theme)
|
||||
hwForm.setRowWrapPolicy(QFormLayout.RowWrapPolicy.DontWrapRows)
|
||||
scrollLayout.addWidget(hwFrame)
|
||||
@@ -2520,7 +2492,7 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
|
||||
else:
|
||||
hwForm.addRow(QLabel(_("No GPUs found")), QLabel(""))
|
||||
|
||||
# 6. Proxy Settings Section
|
||||
# 5. Proxy Settings Section
|
||||
proxyFrame, proxyForm = create_section(_("Proxy Settings"), self.theme)
|
||||
proxyForm.setRowWrapPolicy(QFormLayout.RowWrapPolicy.DontWrapRows)
|
||||
scrollLayout.addWidget(proxyFrame)
|
||||
@@ -2708,11 +2680,6 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
|
||||
if hasattr(self, 'downloadWineToSteamCheckBox'):
|
||||
ui_config.set_download_wine_to_steam(self.downloadWineToSteamCheckBox.isChecked())
|
||||
|
||||
if hasattr(self, 'disableRuntimeDownloadCheckBox'):
|
||||
ui_config.set_disable_runtime_download(self.disableRuntimeDownloadCheckBox.isChecked())
|
||||
else:
|
||||
ui_config.get_disable_runtime_download()
|
||||
|
||||
# Save GPU selection to user.conf (only if the combo box exists)
|
||||
if hasattr(self, 'gpuCombo'):
|
||||
selected_gpu = self.gpuCombo.currentText()
|
||||
|
||||
Reference in new issue
Block a user