Skip to content

Commit 01a1d2f

Browse files
committed
CtInfo: Initial implementation of set_global_compat_tool
1 parent 48c0346 commit 01a1d2f

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

pupgui2/pupgui2ctinfodialog.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,5 @@ def search_ctinfo_games(self, text):
163163

164164
def btn_mark_global_clicked(self):
165165
print('Mark global clicked')
166+
set_global_compat_tool(self.ctool, self.install_loc.get('vdf_dir'))
167+
self.btn_refresh_games_clicked()

pupgui2/steamutil.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,28 @@ def determine_most_recent_steam_user(steam_users: List[SteamUser]) -> SteamUser:
767767
print('Warning: No Steam users found. Returning None')
768768
return None
769769

770-
def set_global_compat_tool(ctool: BasicCompatTool):
770+
def set_global_compat_tool(ctool: BasicCompatTool, steam_config_folder):
771+
""" Update the global compatibility tool to the ctool parameter defined in config.vdf CompatToolMapping (AppID '0') """
772+
771773
if ctool.ct_type == CTType.CUSTOM:
772-
print('Mark Global supported')
774+
config_vdf_file = os.path.join(os.path.expanduser(steam_config_folder), 'config.vdf')
775+
if not os.path.exists(config_vdf_file):
776+
return False
777+
778+
try:
779+
d = vdf.load(open(config_vdf_file))
780+
c = get_steam_vdf_compat_tool_mapping(d)
781+
782+
# Create or update the '0' CompatToolMapping entry
783+
if not c.get('0', {}):
784+
c['0'] = { 'name': ctool.get_internal_name(), 'config': '', 'priority': '75' }
785+
else:
786+
c['0']['name'] = ctool.get_internal_name()
787+
788+
# Unsure if this will work
789+
# vdf.dump(d, open(config_vdf_file, 'w'), pretty=True)
790+
except Exception as e:
791+
print(f'Error, could not update Global Steam compatibility tool to {ctool.displayname}: {e}, vdf: {config_vdf_file}')
792+
return False
793+
794+
return True

0 commit comments

Comments
 (0)