feat: add Linux support for Steam installations
- Added get_steam_paths() that works on both Windows and Linux - Windows: Uses Registry to find Steam - Linux: Checks common Steam paths (~/.steam/steam, ~/.local/share/Steam) - find_entropia_cache_path() now supports both platforms - Platform-specific standard installation paths - Fixed path display for both Windows (\\) and Linux (/) formats - Output folder label shows correct format for platform
This commit is contained in:
parent
63beb27a3c
commit
e248c60d53
|
|
@ -14,9 +14,13 @@ import sys
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
import winreg
|
|
||||||
|
# Platform-specific imports
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
import winreg
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt6.QtWidgets import (
|
from PyQt6.QtWidgets import (
|
||||||
|
|
@ -42,25 +46,36 @@ except ImportError:
|
||||||
APP_NAME = "Entropia Universe Icon Extractor"
|
APP_NAME = "Entropia Universe Icon Extractor"
|
||||||
|
|
||||||
|
|
||||||
def find_steam_installation() -> Optional[Path]:
|
def get_steam_paths() -> List[Path]:
|
||||||
"""Find Steam installation directory from Windows Registry."""
|
"""Get all possible Steam installation paths for the current platform."""
|
||||||
try:
|
paths = []
|
||||||
# Try 64-bit registry
|
|
||||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\WOW6432Node\Valve\Steam") as key:
|
|
||||||
steam_path, _ = winreg.QueryValueEx(key, "InstallPath")
|
|
||||||
return Path(steam_path)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
if sys.platform == 'win32':
|
||||||
# Try 32-bit registry
|
# Windows: Check registry
|
||||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Valve\Steam") as key:
|
try:
|
||||||
steam_path, _ = winreg.QueryValueEx(key, "InstallPath")
|
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\WOW6432Node\Valve\Steam") as key:
|
||||||
return Path(steam_path)
|
steam_path, _ = winreg.QueryValueEx(key, "InstallPath")
|
||||||
except Exception:
|
paths.append(Path(steam_path))
|
||||||
pass
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
return None
|
try:
|
||||||
|
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Valve\Steam") as key:
|
||||||
|
steam_path, _ = winreg.QueryValueEx(key, "InstallPath")
|
||||||
|
paths.append(Path(steam_path))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# Linux/macOS common Steam paths
|
||||||
|
home = Path.home()
|
||||||
|
linux_paths = [
|
||||||
|
home / ".steam" / "steam",
|
||||||
|
home / ".local" / "share" / "Steam",
|
||||||
|
home / ".steam" / "root",
|
||||||
|
]
|
||||||
|
paths.extend([p for p in linux_paths if p.exists()])
|
||||||
|
|
||||||
|
return paths
|
||||||
|
|
||||||
|
|
||||||
def parse_library_folders_vdf(vdf_path: Path) -> List[Path]:
|
def parse_library_folders_vdf(vdf_path: Path) -> List[Path]:
|
||||||
|
|
@ -75,11 +90,10 @@ def parse_library_folders_vdf(vdf_path: Path) -> List[Path]:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
# Find all "path" entries in the vdf file
|
# Find all "path" entries in the vdf file
|
||||||
import re
|
|
||||||
paths = re.findall(r'"path"\s+"([^"]+)"', content)
|
paths = re.findall(r'"path"\s+"([^"]+)"', content)
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
# Replace escaped backslashes
|
# Replace escaped backslashes (Windows format in VDF)
|
||||||
path = path.replace('\\\\', '\\')
|
path = path.replace('\\\\', '\\')
|
||||||
libraries.append(Path(path))
|
libraries.append(Path(path))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
@ -91,19 +105,27 @@ def parse_library_folders_vdf(vdf_path: Path) -> List[Path]:
|
||||||
def find_entropia_cache_path() -> Optional[Path]:
|
def find_entropia_cache_path() -> Optional[Path]:
|
||||||
"""
|
"""
|
||||||
Find Entropia Universe cache folder.
|
Find Entropia Universe cache folder.
|
||||||
Checks multiple locations:
|
Checks multiple locations based on platform.
|
||||||
1. Standard installation (ProgramData)
|
|
||||||
2. Steam installation
|
|
||||||
3. Other Steam libraries
|
|
||||||
"""
|
"""
|
||||||
# Check standard installation first
|
# Check standard installation first (platform-specific)
|
||||||
standard_path = Path("C:/ProgramData/Entropia Universe/public_users_data/cache/icon")
|
if sys.platform == 'win32':
|
||||||
if standard_path.exists() and list(standard_path.rglob("*.tga")):
|
standard_paths = [
|
||||||
return standard_path
|
Path("C:/ProgramData/Entropia Universe/public_users_data/cache/icon"),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
# Linux standard paths
|
||||||
|
standard_paths = [
|
||||||
|
Path.home() / ".local" / "share" / "Entropia Universe" / "public_users_data" / "cache" / "icon",
|
||||||
|
]
|
||||||
|
|
||||||
# Check Steam installation
|
for path in standard_paths:
|
||||||
steam_path = find_steam_installation()
|
if path.exists() and list(path.rglob("*.tga")):
|
||||||
if steam_path:
|
return path
|
||||||
|
|
||||||
|
# Check Steam installations
|
||||||
|
steam_paths = get_steam_paths()
|
||||||
|
|
||||||
|
for steam_path in steam_paths:
|
||||||
# Check default Steam library
|
# Check default Steam library
|
||||||
eu_path = steam_path / "steamapps" / "common" / "Entropia Universe" / "public_users_data" / "cache" / "icon"
|
eu_path = steam_path / "steamapps" / "common" / "Entropia Universe" / "public_users_data" / "cache" / "icon"
|
||||||
if eu_path.exists() and list(eu_path.rglob("*.tga")):
|
if eu_path.exists() and list(eu_path.rglob("*.tga")):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue