Skip to content

Commit

Permalink
Enable Luxtorpeda for all supported games-Button: Backend Logic
Browse files Browse the repository at this point in the history
See #342 for details
  • Loading branch information
DavidoTek committed Jan 11, 2024
1 parent 82f8a64 commit 437bbf7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pupgui2/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def PALETTE_DARK():
LOCAL_AWACY_GAME_LIST = os.path.join(TEMP_DIR, 'awacy_games.json')
PROTONDB_API_URL = 'https://www.protondb.com/api/v1/reports/summaries/{game_id}.json'
PROTONDB_APP_PAGE_URL = 'https://protondb.com/app/'
LUXTORPEDA_PACKAGESSNIPER_URL = 'https://luxtorpeda-dev.github.io/packagessniper_v2.json'
LUXTORPEDA_CTOOL_NAME = 'luxtorpeda'

STEAM_BOXTRON_FLATPAK_APPSTREAM = 'appstream://com.valvesoftware.Steam.CompatibilityTool.Boxtron'
STEAM_STL_FLATPAK_APPSTREAM = 'appstream://com.valvesoftware.Steam.Utility.steamtinkerlaunch'
Expand Down
30 changes: 29 additions & 1 deletion pupgui2/steamutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from pupgui2.constants import APP_NAME, APP_ID, APP_ICON_FILE
from pupgui2.constants import PROTON_EAC_RUNTIME_APPID, PROTON_BATTLEYE_RUNTIME_APPID, PROTON_NEXT_APPID, STEAMLINUXRUNTIME_APPID, STEAMLINUXRUNTIME_SOLDIER_APPID, STEAMLINUXRUNTIME_SNIPER_APPID
from pupgui2.constants import LUXTORPEDA_CTOOL_NAME
from pupgui2.constants import LOCAL_AWACY_GAME_LIST, PROTONDB_API_URL
from pupgui2.constants import STEAM_STL_INSTALL_PATH, STEAM_STL_CONFIG_PATH, STEAM_STL_SHELL_FILES, STEAM_STL_FISH_VARIABLES, HOME_DIR
from pupgui2.datastructures import SteamApp, AWACYStatus, BasicCompatTool, CTType, SteamUser, RuntimeType
Expand Down Expand Up @@ -791,4 +792,31 @@ def determine_most_recent_steam_user(steam_users: List[SteamUser]) -> SteamUser:
return steam_users[0]

print('Warning: No Steam users found. Returning None')
return None
return None


def luxtorpeda_set_all_games(steam_app_list: List[SteamApp], luxtorpeda_supported_app_ids: List[int], steam_config_folder: str) -> bool:
"""
Enables Luxtorpeda for all games in the steam_app_list that are in the luxtorpeda_supported_app_ids list.
Parameters:
steam_app_list: List[SteamApp]
List of Steam apps
luxtorpeda_supported_app_ids: List[int]
List of app ids that are supported by Luxtorpeda
Return Type: bool
"""

if not os.path.exists(os.path.join(os.path.expanduser(steam_config_folder), 'config.vdf')):
return False

if len(luxtorpeda_supported_app_ids) == 0:
return False

for app in steam_app_list:
if app.app_id in luxtorpeda_supported_app_ids:
# For now ignore when steam_update_ctool fails for individual apps (return value is ignored)
steam_update_ctool(app, LUXTORPEDA_CTOOL_NAME, steam_config_folder)

return True
25 changes: 24 additions & 1 deletion pupgui2/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import zipfile
import tarfile
import random
import json

import zstandard

Expand All @@ -20,7 +21,7 @@
from PySide6.QtWidgets import QApplication, QStyleFactory, QMessageBox, QCheckBox

from pupgui2.constants import POSSIBLE_INSTALL_LOCATIONS, CONFIG_FILE, PALETTE_DARK, TEMP_DIR
from pupgui2.constants import AWACY_GAME_LIST_URL, LOCAL_AWACY_GAME_LIST
from pupgui2.constants import AWACY_GAME_LIST_URL, LOCAL_AWACY_GAME_LIST, LUXTORPEDA_PACKAGESSNIPER_URL
from pupgui2.constants import GITHUB_API, GITLAB_API, GITLAB_API_RATELIMIT_TEXT
from pupgui2.datastructures import BasicCompatTool, CTType, Launcher, SteamApp, LutrisGame, HeroicGame
from pupgui2.steamutil import remove_steamtinkerlaunch
Expand Down Expand Up @@ -872,3 +873,25 @@ def get_random_game_name(games: List[Union[SteamApp, LutrisGame, HeroicGame]]) -
tooltip_game_name = random_game.title

return tooltip_game_name


def get_luxtorpeda_supported_app_ids() -> List[int]:
"""
Downloads the latest package list from LUXTORPEDA_PACKAGESSNIPER_URL and returns a list of supported app IDs
Blocking until json is downloaded and parsed
Return Type: List[int]
"""
try:
r = requests.get(LUXTORPEDA_PACKAGESSNIPER_URL)
j = json.loads(r.content)

games = j.get('games', [])

app_ids = [int(g.get('app_id')) for g in games if g.get('app_id', 'z').isdigit()]

return app_ids

except Exception as e:
print('Error fetching Luxtorpeda packages list: ' + str(e))
return []

0 comments on commit 437bbf7

Please sign in to comment.