Skip to content

Commit

Permalink
STL: Reference CtInstaller in external methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidoTek committed Nov 11, 2022
1 parent 2d1f388 commit 6518e60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pupgui2/resources/ctmods/ctmod_steamtinkerlaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def get_tool(self, version, install_dir, temp_dir):
if remove_existing_installation_result.button_clicked == MsgBoxResult.BUTTON_OK:
# Remove the Non-ProtonUp-Qt SteamTinkerLaunch if the user checked the box (disabled by defaukt)
if remove_existing_installation_result.is_checked:
remove_steamtinkerlaunch(compat_folder=os.path.join(install_dir, 'SteamTinkerLaunch'), remove_config=False)
remove_steamtinkerlaunch(compat_folder=os.path.join(install_dir, 'SteamTinkerLaunch'), remove_config=False, ctmod_object=self)

# Nothing more to do here, just continue with the rest of the installation as normal
print('User opted to continue installing SteamTinkerLaunch.')
Expand All @@ -282,7 +282,7 @@ def get_tool(self, version, install_dir, temp_dir):
print('Extracting SteamTinkerLaunch...')
if os.path.exists(constants.STEAM_STL_INSTALL_PATH):
has_existing_install = True # This will also be True for users who installed normally on Steam Deck, but not sure how to differentiate between PUPQT and manual Steam Deck installs
remove_steamtinkerlaunch(remove_config=False)
remove_steamtinkerlaunch(remove_config=False, ctmod_object=self)

if not os.path.exists(constants.STEAM_STL_INSTALL_PATH):
os.mkdir(constants.STEAM_STL_INSTALL_PATH)
Expand Down Expand Up @@ -364,7 +364,7 @@ def get_tool(self, version, install_dir, temp_dir):
# Cancel installation after shell modification warning
print('User asked to cancel installation. Not installing SteamTinkerLaunch...')
should_add_path = False # Shouldn't matter since installation will end here, but setting for completeness
remove_steamtinkerlaunch(remove_config=False) # shouldn't need compat_folder arg - (compat_folder=os.path.join(install_dir, 'SteamTinkerLaunch'))
remove_steamtinkerlaunch(remove_config=False, ctmod_object=self) # shouldn't need compat_folder arg - (compat_folder=os.path.join(install_dir, 'SteamTinkerLaunch'))
return
elif not shellmod_msgbox_result.is_checked and shellmod_msgbox_result.button_clicked == MsgBoxResult.BUTTON_OK:
# Continue installation but skip adding to PATH
Expand Down
18 changes: 11 additions & 7 deletions pupgui2/steamutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .datastructures import SteamApp, AWACYStatus, BasicCompatTool, CTType
from .constants import LOCAL_AWACY_GAME_LIST, STEAM_STL_INSTALL_PATH, STEAM_STL_CONFIG_PATH, STEAM_STL_SHELL_FILES, STEAM_STL_FISH_VARIABLES

from PySide6.QtWidgets import QMessageBox
from PySide6.QtWidgets import QMessageBox, QApplication

_cached_app_list = []
_cached_steam_ctool_id_map = None
Expand Down Expand Up @@ -314,7 +314,7 @@ def get_external_steamtinkerlaunch_intall(compat_folder):
return os.path.dirname(os.readlink(symlink_path)) if os.path.exists(symlink_path) and not os.readlink(symlink_path) == os.path.join(STEAM_STL_INSTALL_PATH, 'prefix', 'steamtinkerlaunch') else None


def remove_steamtinkerlaunch(compat_folder='', remove_config=True) -> bool:
def remove_steamtinkerlaunch(compat_folder='', remove_config=True, ctmod_object=None) -> bool:
"""
Removes SteamTinkerLaunch from system by removing the downloaad, removing from path
removing config files at `$HOME/.config/steamtinkerlaunch`.
Expand Down Expand Up @@ -345,11 +345,15 @@ def remove_steamtinkerlaunch(compat_folder='', remove_config=True) -> bool:
shutil.rmtree(stl_symlink_path)
else:
# If we can't remove the actual installation folder, tell the user to remove it themselves and continue with the rest of the uninstallation
# This currently segfaults
mb = QMessageBox()
mb.setWindowTitle('Unable to Remove SteamTinkerLaunch')
mb.setText(f'Access to SteamTinkerLaunch installation folder at \'{stl_symlink_path}\' was denied, please remove this folder manually.\n\nThe uninstallation will continue.')
mb.exec()
mb_title = QApplication.instance().translate('steamutil.py', 'Unable to Remove SteamTinkerLaunch')
mb_text = QApplication.instance().translate('steamutil.py', 'Access to SteamTinkerLaunch installation folder at {STL_SYMLINK_PATH} was denied, please remove this folder manually.\n\nThe uninstallation will continue.').format(STL_SYMLINK_PATH=stl_symlink_path)
if ctmod_object and hasattr(ctmod_object, 'message_box_message'):
ctmod_object.message_box_message.emit(mb_title, mb_text, QMessageBox.Icon.Warning)
else:
mb = QMessageBox()
mb.setWindowTitle(mb_title)
mb.setText(mb_text)
mb.exec()

print(f'Error: SteamTinkerLaunch is installed to {stl_symlink_path}, ProtonUp-Qt cannot modify this folder. Folder must be removed manually.')
elif os.path.exists(STEAM_STL_INSTALL_PATH):
Expand Down

0 comments on commit 6518e60

Please sign in to comment.