Skip to content

Commit

Permalink
STL: Prompt users with Non-PUPQT installs before reinstalling
Browse files Browse the repository at this point in the history
  • Loading branch information
sonic2kk committed Sep 29, 2022
1 parent 6b3a6c6 commit ac020e0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
19 changes: 18 additions & 1 deletion pupgui2/resources/ctmods/ctmod_steamtinkerlaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import datetime, locale, os, requests, shutil, subprocess, tarfile
from PySide6.QtCore import *
from PySide6.QtWidgets import QMessageBox
from ...steamutil import get_fish_user_paths, remove_steamtinkerlaunch
from ...steamutil import get_fish_user_paths, remove_steamtinkerlaunch, get_external_steamtinkerlaunch_intall
from ... import constants
from ...util import host_which

Expand Down Expand Up @@ -208,6 +208,23 @@ def get_tool(self, version, install_dir, temp_dir):
Return Type: bool
"""

# If there's an existing STL installation that isn't installed by ProtonUp-Qt, ask the user if they still want to install
has_external_install = get_external_steamtinkerlaunch_intall(install_dir)
if has_external_install:
mb = QMessageBox()
mb.setWindowTitle(QObject.tr('Existing SteamTinkerLaunch Installation'))
mb.setText(QObject.tr(f'It looks like you have an existing SteamTinkerLaunch installation at '{has_external_install}' on your system that was not installed by ProtonUp-Qt.\n \
Reinstalling SteamTinkerLaunch with ProtonUp-Qt will move your installation folder to {constants.STEAM_STL_INSTALL_PATH}. Do you wish to continue? (This will not affect your SteamTinkerLaunch configuration.)'))
mb.addButton(QMessageBox.Yes)
mb.addButton(QMessageBox.No)
mb.setDefaultButton(QMessageBox.No)
accept = mb.exec()

if not accept:
print('Cancelling SteamTinkerLaunch installation...')
return False
# User said Yes to installing anyway

print('Downloading SteamTinkerLaunch...')

data = self.__fetch_github_data(version)
Expand Down
11 changes: 10 additions & 1 deletion pupgui2/steamutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ def is_steam_running() -> bool:
get_fish_user_paths = lambda mfile: ([line.strip() for line in mfile.readlines() if 'fish_user_paths' in line] or ['SETUVAR fish_user_paths:\\x1d'])[0].split('fish_user_paths:')[1:][0].split('\\x1e')


def get_external_steamtinkerlaunch_intall(compat_folder):

symlink_path = os.path.join(compat_folder, 'steamtinkerlaunch')
return os.path.dirname(os.readlink(symlink_path)) if os.path.exists(symlink_path) and not os.path.exists(os.path.join(STEAM_STL_INSTALL_PATH, 'prefix')) else None

# os.path.dirname(os.readlink(os.path.join(compat_folder, 'steamtinkerlaunch'))) if not os.path.exists(os.path.join(STEAM_STL_INSTALL_PATH, 'prefix')) else None


def remove_steamtinkerlaunch(compat_folder='', remove_config=True) -> bool:
"""
Removes SteamTinkerLaunch from system by removing the downloaad, removing from path
Expand All @@ -323,7 +331,8 @@ def remove_steamtinkerlaunch(compat_folder='', remove_config=True) -> bool:
# Adding `prefix` to path to be especially sure the user didn't just make an `stl` folder
#
# STL script is always named `steamtinkerlaunch`
stl_symlink_path = os.path.dirname(os.readlink(os.path.join(compat_folder, 'steamtinkerlaunch'))) if not os.path.exists(os.path.join(STEAM_STL_INSTALL_PATH, 'prefix')) else None
# stl_symlink_path = os.path.dirname(os.readlink(os.path.join(compat_folder, 'steamtinkerlaunch'))) if not os.path.exists(os.path.join(STEAM_STL_INSTALL_PATH, 'prefix')) else None
stl_symlink_path = get_external_steamtinkerlaunch_intall(compat_folder)

if os.path.exists(compat_folder):
print('Removing SteamTinkerLaunch compatibility tool...')
Expand Down

0 comments on commit ac020e0

Please sign in to comment.