mirror of
https://github.com/Omni-guides/Jackify.git
synced 2026-01-17 19:47:00 +01:00
Sync from development - prepare for v0.1.5
This commit is contained in:
@@ -448,7 +448,7 @@ exit"""
|
||||
|
||||
if shortcut_name in name:
|
||||
appid = shortcut.get('appid')
|
||||
exe_path = shortcut.get('Exe', '')
|
||||
exe_path = shortcut.get('Exe', '').strip('"')
|
||||
|
||||
logger.info(f"Found shortcut: {name}")
|
||||
logger.info(f" AppID: {appid}")
|
||||
@@ -1759,21 +1759,15 @@ echo Prefix creation complete.
|
||||
progress_callback("=== Steam Integration ===")
|
||||
progress_callback(f"{self._get_progress_timestamp()} Creating Steam shortcut with native service")
|
||||
|
||||
# Dual approach: Registry injection for FNV, launch options for Enderal
|
||||
# Registry injection approach for both FNV and Enderal
|
||||
from ..handlers.modlist_handler import ModlistHandler
|
||||
modlist_handler = ModlistHandler()
|
||||
special_game_type = modlist_handler.detect_special_game_type(modlist_install_dir)
|
||||
|
||||
# Generate launch options only for Enderal (FNV uses registry injection)
|
||||
|
||||
# No launch options needed - both FNV and Enderal use registry injection
|
||||
custom_launch_options = None
|
||||
if special_game_type == "enderal":
|
||||
custom_launch_options = self._generate_special_game_launch_options(special_game_type, modlist_install_dir)
|
||||
if not custom_launch_options:
|
||||
logger.error(f"Failed to generate launch options for Enderal modlist")
|
||||
return False, None, None, None
|
||||
logger.info("Using launch options approach for Enderal modlist")
|
||||
elif special_game_type == "fnv":
|
||||
logger.info("Using registry injection approach for FNV modlist")
|
||||
if special_game_type in ["fnv", "enderal"]:
|
||||
logger.info(f"Using registry injection approach for {special_game_type.upper()} modlist")
|
||||
else:
|
||||
logger.debug("Standard modlist - no special game handling needed")
|
||||
|
||||
@@ -1849,23 +1843,19 @@ echo Prefix creation complete.
|
||||
if progress_callback:
|
||||
progress_callback(f"{self._get_progress_timestamp()} Setup verification completed")
|
||||
|
||||
# Step 5: Inject game registry entries for FNV modlists (Enderal uses launch options)
|
||||
# Step 5: Inject game registry entries for FNV and Enderal modlists
|
||||
# Get prefix path (needed for logging regardless of game type)
|
||||
prefix_path = self.get_prefix_path(appid)
|
||||
|
||||
if special_game_type == "fnv":
|
||||
logger.info("Step 5: Injecting FNV game registry entries")
|
||||
|
||||
if special_game_type in ["fnv", "enderal"]:
|
||||
logger.info(f"Step 5: Injecting {special_game_type.upper()} game registry entries")
|
||||
if progress_callback:
|
||||
progress_callback(f"{self._get_progress_timestamp()} Injecting FNV game registry entries...")
|
||||
|
||||
progress_callback(f"{self._get_progress_timestamp()} Injecting {special_game_type.upper()} game registry entries...")
|
||||
|
||||
if prefix_path:
|
||||
self._inject_game_registry_entries(str(prefix_path))
|
||||
else:
|
||||
logger.warning("Could not find prefix path for registry injection")
|
||||
elif special_game_type == "enderal":
|
||||
logger.info("Step 5: Skipping registry injection for Enderal (using launch options)")
|
||||
if progress_callback:
|
||||
progress_callback(f"{self._get_progress_timestamp()} Skipping registry injection for Enderal")
|
||||
else:
|
||||
logger.info("Step 5: Skipping registry injection for standard modlist")
|
||||
if progress_callback:
|
||||
@@ -2690,31 +2680,64 @@ echo Prefix creation complete.
|
||||
return False
|
||||
|
||||
def _find_proton_binary(self, proton_common_dir: Path) -> Optional[Path]:
|
||||
"""Locate a Proton wrapper script to use (prefer Experimental)."""
|
||||
candidates = []
|
||||
preferred = [
|
||||
"Proton - Experimental",
|
||||
"Proton 9.0",
|
||||
"Proton 8.0",
|
||||
"Proton Hotfix",
|
||||
]
|
||||
|
||||
for name in preferred:
|
||||
p = proton_common_dir / name / "proton"
|
||||
if p.exists():
|
||||
candidates.append(p)
|
||||
|
||||
# As a fallback, scan all Proton* dirs
|
||||
if not candidates and proton_common_dir.exists():
|
||||
for p in proton_common_dir.glob("Proton*/proton"):
|
||||
candidates.append(p)
|
||||
|
||||
if not candidates:
|
||||
logger.error("No Proton wrapper found under steamapps/common")
|
||||
"""Locate a Proton wrapper script to use, respecting user's configuration."""
|
||||
try:
|
||||
from jackify.backend.handlers.config_handler import ConfigHandler
|
||||
from jackify.backend.handlers.wine_utils import WineUtils
|
||||
|
||||
config = ConfigHandler()
|
||||
user_proton_path = config.get('proton_path', 'auto')
|
||||
|
||||
# If user selected a specific Proton, try that first
|
||||
if user_proton_path != 'auto':
|
||||
# Resolve symlinks to handle ~/.steam/steam -> ~/.local/share/Steam
|
||||
resolved_proton_path = os.path.realpath(user_proton_path)
|
||||
|
||||
# Check for wine binary in different Proton structures
|
||||
valve_proton_wine = Path(resolved_proton_path) / "dist" / "bin" / "wine"
|
||||
ge_proton_wine = Path(resolved_proton_path) / "files" / "bin" / "wine"
|
||||
|
||||
if valve_proton_wine.exists() or ge_proton_wine.exists():
|
||||
# Found user's Proton, now find the proton wrapper script
|
||||
proton_wrapper = Path(resolved_proton_path) / "proton"
|
||||
if proton_wrapper.exists():
|
||||
logger.info(f"Using user-selected Proton wrapper: {proton_wrapper}")
|
||||
return proton_wrapper
|
||||
else:
|
||||
logger.warning(f"User-selected Proton missing wrapper script: {proton_wrapper}")
|
||||
else:
|
||||
logger.warning(f"User-selected Proton path invalid: {user_proton_path}")
|
||||
|
||||
# Fall back to auto-detection
|
||||
logger.info("Falling back to automatic Proton detection")
|
||||
candidates = []
|
||||
preferred = [
|
||||
"Proton - Experimental",
|
||||
"Proton 9.0",
|
||||
"Proton 8.0",
|
||||
"Proton Hotfix",
|
||||
]
|
||||
|
||||
for name in preferred:
|
||||
p = proton_common_dir / name / "proton"
|
||||
if p.exists():
|
||||
candidates.append(p)
|
||||
|
||||
# As a fallback, scan all Proton* dirs
|
||||
if not candidates and proton_common_dir.exists():
|
||||
for p in proton_common_dir.glob("Proton*/proton"):
|
||||
candidates.append(p)
|
||||
|
||||
if not candidates:
|
||||
logger.error("No Proton wrapper found under steamapps/common")
|
||||
return None
|
||||
|
||||
logger.info(f"Using auto-detected Proton wrapper: {candidates[0]}")
|
||||
return candidates[0]
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error finding Proton binary: {e}")
|
||||
return None
|
||||
|
||||
logger.info(f"Using Proton wrapper: {candidates[0]}")
|
||||
return candidates[0]
|
||||
|
||||
def replace_existing_shortcut(self, shortcut_name: str, exe_path: str, modlist_install_dir: str) -> Tuple[bool, Optional[int]]:
|
||||
"""
|
||||
@@ -2948,6 +2971,15 @@ echo Prefix creation complete.
|
||||
)
|
||||
if success:
|
||||
logger.info(f"Updated registry entry for {config['name']}")
|
||||
|
||||
# Special handling for Enderal: Create required user directory
|
||||
if app_id == "976620": # Enderal Special Edition
|
||||
try:
|
||||
enderal_docs_path = os.path.join(modlist_compatdata_path, "pfx", "drive_c", "users", "steamuser", "Documents", "My Games", "Enderal Special Edition")
|
||||
os.makedirs(enderal_docs_path, exist_ok=True)
|
||||
logger.info(f"Created Enderal user directory: {enderal_docs_path}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to create Enderal user directory: {e}")
|
||||
else:
|
||||
logger.warning(f"Failed to update registry entry for {config['name']}")
|
||||
else:
|
||||
|
||||
@@ -293,15 +293,7 @@ class ModlistService:
|
||||
elif context.get('machineid'):
|
||||
cmd += ['-m', context['machineid']]
|
||||
cmd += ['-o', install_dir_str, '-d', download_dir_str]
|
||||
|
||||
# Check for debug mode and add --debug flag
|
||||
from ..handlers.config_handler import ConfigHandler
|
||||
config_handler = ConfigHandler()
|
||||
debug_mode = config_handler.get('debug_mode', False)
|
||||
if debug_mode:
|
||||
cmd.append('--debug')
|
||||
logger.debug("DEBUG: Added --debug flag to jackify-engine command")
|
||||
|
||||
|
||||
# NOTE: API key is passed via environment variable only, not as command line argument
|
||||
|
||||
# Store original environment values (copied from working code)
|
||||
|
||||
185
jackify/backend/services/native_steam_operations_service.py
Normal file
185
jackify/backend/services/native_steam_operations_service.py
Normal file
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Native Steam Operations Service
|
||||
|
||||
This service provides direct Steam operations using VDF parsing and path discovery.
|
||||
Replaces protontricks dependencies with native Steam functionality.
|
||||
"""
|
||||
|
||||
import os
|
||||
import logging
|
||||
import vdf
|
||||
from pathlib import Path
|
||||
from typing import Dict, Optional, List
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NativeSteamOperationsService:
|
||||
"""
|
||||
Service providing native Steam operations for shortcut discovery and prefix management.
|
||||
|
||||
Replaces protontricks functionality with:
|
||||
- Direct VDF parsing for shortcut discovery
|
||||
- Native compatdata path construction
|
||||
- Direct Steam library detection
|
||||
"""
|
||||
|
||||
def __init__(self, steamdeck: bool = False):
|
||||
self.steamdeck = steamdeck
|
||||
self.logger = logger
|
||||
|
||||
def list_non_steam_shortcuts(self) -> Dict[str, str]:
|
||||
"""
|
||||
List non-Steam shortcuts via direct VDF parsing.
|
||||
|
||||
Returns:
|
||||
Dict mapping shortcut name to AppID string
|
||||
"""
|
||||
logger.info("Listing non-Steam shortcuts via native VDF parsing...")
|
||||
shortcuts = {}
|
||||
|
||||
try:
|
||||
# Find all possible shortcuts.vdf locations
|
||||
shortcuts_paths = self._find_shortcuts_vdf_paths()
|
||||
|
||||
for shortcuts_path in shortcuts_paths:
|
||||
logger.debug(f"Checking shortcuts.vdf at: {shortcuts_path}")
|
||||
|
||||
if not shortcuts_path.exists():
|
||||
continue
|
||||
|
||||
try:
|
||||
with open(shortcuts_path, 'rb') as f:
|
||||
data = vdf.binary_load(f)
|
||||
|
||||
shortcuts_data = data.get('shortcuts', {})
|
||||
for shortcut_key, shortcut_data in shortcuts_data.items():
|
||||
if isinstance(shortcut_data, dict):
|
||||
app_name = shortcut_data.get('AppName', '').strip()
|
||||
app_id = shortcut_data.get('appid', '')
|
||||
|
||||
if app_name and app_id:
|
||||
# Convert to positive AppID string (compatible format)
|
||||
positive_appid = str(abs(int(app_id)))
|
||||
shortcuts[app_name] = positive_appid
|
||||
logger.debug(f"Found non-Steam shortcut: '{app_name}' with AppID {positive_appid}")
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"Error reading shortcuts.vdf at {shortcuts_path}: {e}")
|
||||
continue
|
||||
|
||||
if not shortcuts:
|
||||
logger.warning("No non-Steam shortcuts found in any shortcuts.vdf")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error listing non-Steam shortcuts: {e}")
|
||||
|
||||
return shortcuts
|
||||
|
||||
def set_steam_permissions(self, modlist_dir: str, steamdeck: bool = False) -> bool:
|
||||
"""
|
||||
Handle Steam access permissions for native operations.
|
||||
|
||||
Since we're using direct file access, no special permissions needed.
|
||||
|
||||
Args:
|
||||
modlist_dir: Modlist directory path (for future use)
|
||||
steamdeck: Steam Deck flag (for future use)
|
||||
|
||||
Returns:
|
||||
Always True (no permissions needed for native operations)
|
||||
"""
|
||||
logger.debug("Using native Steam operations, no permission setting needed")
|
||||
return True
|
||||
|
||||
def get_wine_prefix_path(self, appid: str) -> Optional[str]:
|
||||
"""
|
||||
Get WINEPREFIX path via direct compatdata discovery.
|
||||
|
||||
Args:
|
||||
appid: Steam AppID string
|
||||
|
||||
Returns:
|
||||
WINEPREFIX path string or None if not found
|
||||
"""
|
||||
logger.debug(f"Getting WINEPREFIX for AppID {appid} using native path discovery")
|
||||
|
||||
try:
|
||||
# Find all possible compatdata locations
|
||||
compatdata_paths = self._find_compatdata_paths()
|
||||
|
||||
for compatdata_base in compatdata_paths:
|
||||
prefix_path = compatdata_base / appid / "pfx"
|
||||
logger.debug(f"Checking prefix path: {prefix_path}")
|
||||
|
||||
if prefix_path.exists():
|
||||
logger.debug(f"Found WINEPREFIX: {prefix_path}")
|
||||
return str(prefix_path)
|
||||
|
||||
logger.error(f"WINEPREFIX not found for AppID {appid} in any compatdata location")
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting WINEPREFIX for AppID {appid}: {e}")
|
||||
return None
|
||||
|
||||
def _find_shortcuts_vdf_paths(self) -> List[Path]:
|
||||
"""Find all possible shortcuts.vdf file locations"""
|
||||
paths = []
|
||||
|
||||
# Standard Steam locations
|
||||
steam_locations = [
|
||||
Path.home() / ".steam/steam",
|
||||
Path.home() / ".local/share/Steam",
|
||||
Path.home() / ".var/app/com.valvesoftware.Steam/home/.steam/steam",
|
||||
Path.home() / ".var/app/com.valvesoftware.Steam/home/.local/share/Steam"
|
||||
]
|
||||
|
||||
for steam_root in steam_locations:
|
||||
if not steam_root.exists():
|
||||
continue
|
||||
|
||||
# Find userdata directories
|
||||
userdata_path = steam_root / "userdata"
|
||||
if userdata_path.exists():
|
||||
for user_dir in userdata_path.iterdir():
|
||||
if user_dir.is_dir() and user_dir.name.isdigit():
|
||||
shortcuts_path = user_dir / "config" / "shortcuts.vdf"
|
||||
paths.append(shortcuts_path)
|
||||
|
||||
return paths
|
||||
|
||||
def _find_compatdata_paths(self) -> List[Path]:
|
||||
"""Find all possible compatdata directory locations"""
|
||||
paths = []
|
||||
|
||||
# Standard compatdata locations
|
||||
standard_locations = [
|
||||
Path.home() / ".steam/steam/steamapps/compatdata",
|
||||
Path.home() / ".local/share/Steam/steamapps/compatdata",
|
||||
Path.home() / ".var/app/com.valvesoftware.Steam/home/.steam/steam/steamapps/compatdata",
|
||||
Path.home() / ".var/app/com.valvesoftware.Steam/home/.local/share/Steam/steamapps/compatdata"
|
||||
]
|
||||
|
||||
for path in standard_locations:
|
||||
if path.exists():
|
||||
paths.append(path)
|
||||
|
||||
# Also check additional Steam libraries via libraryfolders.vdf
|
||||
try:
|
||||
from jackify.shared.paths import PathHandler
|
||||
all_steam_libs = PathHandler.get_all_steam_library_paths()
|
||||
|
||||
for lib_path in all_steam_libs:
|
||||
compatdata_path = lib_path / "steamapps" / "compatdata"
|
||||
if compatdata_path.exists():
|
||||
paths.append(compatdata_path)
|
||||
|
||||
except Exception as e:
|
||||
logger.debug(f"Could not get additional Steam library paths: {e}")
|
||||
|
||||
return paths
|
||||
Reference in New Issue
Block a user