feat: add Linux support for Steam installations

This commit is contained in:
LemonNexus 2026-02-12 13:39:13 +00:00
parent 39f09d91db
commit 9c8e1a812e
1 changed files with 53 additions and 31 deletions

View File

@ -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."""
paths = []
if sys.platform == 'win32':
# Windows: Check registry
try: try:
# Try 64-bit registry
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\WOW6432Node\Valve\Steam") as key: with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\WOW6432Node\Valve\Steam") as key:
steam_path, _ = winreg.QueryValueEx(key, "InstallPath") steam_path, _ = winreg.QueryValueEx(key, "InstallPath")
return Path(steam_path) paths.append(Path(steam_path))
except Exception: except Exception:
pass pass
try: try:
# Try 32-bit registry
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Valve\Steam") as key: with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Valve\Steam") as key:
steam_path, _ = winreg.QueryValueEx(key, "InstallPath") steam_path, _ = winreg.QueryValueEx(key, "InstallPath")
return Path(steam_path) paths.append(Path(steam_path))
except Exception: except Exception:
pass 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 None 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")):