* add `-def1` ... `-def5` arguments, which can be used to generate your preferred custom config if no `-def` argument is provided, `-def1` will be used by default, to automatically copy from the following folders: * `.\_DEFAULT\0` ............... essential emu files, like latest GSE dlls (*steam_api.dll* and *steam_api64.dll*) * `.\_DEFAULT\1` ............... other GSE files and folders, including default ini files * `.\_DEFAULT\<appid>` ... other GSE files and folders, but only for the current `<appid>`, if the folder exists * (Windows only) add some useful helper tools, written in *AutoIt3*: * **gse_acw_helper.exe** - add the required achievements schema db files for *Achievement Watcher*, if .\steam_misc\extra_acw\extra_acw.zip file exists (if generated by `generate_emu_config.exe -acw <appid>`) * **gse_debug_switch.exe** - automatically switch between release and debug versions of the emulator, if *steam_api.7z* / *steam_api64.7z* file exists (or *steamclient.7z* / *steamclient64.7z*, if you use the steamclient version) paths to release and debug files inside 7z, can be customized in .\steam_misc\tools\au3\scripts\gse_debug_switch.ini * **gse_generate_interfaces.exe** - simple x64-x86 launcher for *generate_interfaces.exe* it also writes all found steam interfaces to CODEX *steam_emu.ini* (if generated by `generate_emu_config -cdx <appid>`) make sure to name your original dll to one of these formats, so it can automatically find its interfaces: * `valve_api.dll / valve_api64.dll` * `steam_api.dll.bak / steam_api64.dll.bak` or `steam_api.dll.org / steam_api64.dll.org` * `steam_api.bak / steam_api64.bak` or `steam_api.org / steam_api64.org` * `steam_api_orig.dll / steam_api64_orig.dll` or `steam_api_legit.dll / steam_api64_legit.dll` * **gse_lobby_connect.exe** - simple x64-x86 launcher for *lobby_connect.exe* * new folder structure, compatible with current and future helper tools --- default arguments are `-acw -cdx -clr <appid>` NEVER delete `.\steam_misc\app_backup`, `.\steam_misc\app_info`, `.\steam_misc\tools` and `.\steam_settings` folders MIGHT need `.\steam_misc\extra_acw` and `.\steam_misc\extra_cdx` for compatibility with Achievement Watcher and CODEX * add `-scx` argument to automatically download images / videos for trading cards, backgrounds, badges, emoticons and other tradable items unfortunately I couldn't find any direct steam api method to download the files, so I had to write a rudimentary web scrapper to extract the download links from a third-party website, hence the *scx_gen.py* script might need updating in the future if the website design changes * download screenshots and videos: * download thumbnails for both screenshots and videos, and compress them to `.zip` files * screenshots and videos are now numbered from first to last published, as in the Steam store page * add `-vids_low` / `-vids_max` arguments to download all videos, in low and / or high quality * create / update .\\*top_owners_ids.txt* when .\\*top_owners_ids.html* is present * generate controller action sets txt files for all found controller vdf configs, and zip them inside .\steam_misc\app_backup\app_backup.zip by default, the emu supports only `xboxone` and `xbox360` controller configs, though if the're are any issues with the default supported controller action sets inside .\steam_settings\controller folder, you could try to unpack and overwrite action sets for other unsupported controller configs * (Windows only) add *AdvancedRun* launchers (cmd console + silent) for `.bat` files and `.py` scripts * **[alex47exe]** major overhaul of **migrate_gse** - uses the same `.\_DEFAULT\0` and `.\_DEFAULT\1` folder structure for default configs it can convert old `.txt` format to `.ini` format, minus *branches.json*, which would require using *top_owners_ids.txt* and some login code from **generate_emu_config**, which should actually be used to properly generate the config files, instead of converting from the old `.txt` format * [alex47exe] *generate_interfaces.exe* - find all Steam Interfaces instead of only old ones the emu will ignore the ones it doesn't require, while we'll have the complete list to write it to CODEX *steam_emu.ini* * [alex47exe] *lobby_connect.exe* - improve cmd console text alignment * [alex47exe] `mods_img` instead of `mod_images` (better folder consistency), better example for `mods_img`, minor tweaks to `.ini` and `.md` files
366 lines
23 KiB
Python
366 lines
23 KiB
Python
import platform
|
|
import os
|
|
import sys
|
|
import glob
|
|
import configparser
|
|
import traceback
|
|
import shutil
|
|
from configobj import ConfigObj
|
|
|
|
def help():
|
|
exe_name = os.path.basename(sys.argv[0])
|
|
print(f"\nUsage: {exe_name} [Switches] [settings folder path]")
|
|
print(f"\nSwitches:")
|
|
print(f" -revert: convert all .ini files back to .txt files")
|
|
print(f" /?, -?, --?, /h, -h, --h, /help, -help, --help")
|
|
print(f" show this help page")
|
|
print(f"\nExamples:")
|
|
print(f" Example: {exe_name}")
|
|
print(f" Example: {exe_name} -revert")
|
|
print(f' Example: {exe_name} "D:\\game\\steam_settings"')
|
|
print(f' Example: {exe_name} -revert "D:\\game\\steam_settings"')
|
|
print("\nNote:")
|
|
print(" Running the tool without any switches will make it attempt to read the global settings folder")
|
|
print("")
|
|
|
|
NEW_STEAM_SETTINGS_FOLDER = os.path.join('_OUTPUT', 'steam_settings')
|
|
|
|
def create_new_steam_settings_folder():
|
|
if not os.path.exists(NEW_STEAM_SETTINGS_FOLDER):
|
|
os.makedirs(NEW_STEAM_SETTINGS_FOLDER)
|
|
|
|
# use CongigObj to correctly update existing 'configs.app.ini' copied from ./_DEFAULT configuration --- START, read ini
|
|
configs_app = ConfigObj(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.app.ini"), encoding='utf-8')
|
|
configs_app_initial = configs_app
|
|
|
|
# use CongigObj to correctly update existing 'configs.main.ini' copied from ./_DEFAULT configuration --- START, read ini
|
|
configs_main = ConfigObj(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.main.ini"), encoding='utf-8')
|
|
configs_main_initial = configs_main
|
|
|
|
# use CongigObj to correctly update existing 'configs.overlay.ini' copied from ./_DEFAULT configuration --- START, read ini
|
|
configs_overlay = ConfigObj(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.overlay.ini"), encoding='utf-8')
|
|
configs_overlay_initial = configs_overlay
|
|
|
|
# use CongigObj to correctly update existing 'configs.user.ini' copied from ./_DEFAULT configuration --- START, read ini
|
|
configs_user = ConfigObj(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.user.ini"), encoding='utf-8')
|
|
configs_user_initial = configs_user
|
|
|
|
def convert_to_ini(global_settings: str):
|
|
# oh no, they're too many! --- they are indeed... it is way simpler to use ConfigObj to properly update the default ini files
|
|
for file in glob.glob('*.*', root_dir=global_settings):
|
|
file = file.lower()
|
|
if file == 'steam_appid.txt':
|
|
steam_appid = fr.readline().strip('\n').strip('\r')
|
|
elif file == 'force_account_name.txt' or file == 'account_name.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_user["user::general"]["account_name"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'force_branch_name.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_app["app::general"]["branch_name"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'force_language.txt' or file == 'language.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_user["user::general"]["language"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'force_listen_port.txt' or file == 'listen_port.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_main["main::connectivity"]["listen_port"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'force_steamid.txt' or file == 'user_steam_id.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_user["user::general"]["account_steamid"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'ip_country.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_user["user::general"]["ip_country"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'overlay_appearance.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
ov_lines = [lll.strip() for lll in fr.readlines() if lll.strip() and lll.strip()[0] != ';' and lll.strip()[0] != '#']
|
|
for ovl in ov_lines:
|
|
[ov_name, ov_val] = ovl.split(' ', 1)
|
|
configs_overlay["overlay::appearance"][ov_name.strip()] = ov_val.strip() #updated ini through ConfigObj
|
|
# NOTE generating 'branches.json' would require copy pasting some code from 'generate_config_emu.py'
|
|
# if possible, avoid using 'migrate_gse' alltogether, and use 'generate_emu_config' instead
|
|
#elif file == 'build_id.txt':
|
|
#with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
#configs_app["app::general"]["build_id"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'disable_account_avatar.txt':
|
|
configs_main["main::general"]["enable_account_avatar"] = 0 #updated ini through ConfigObj
|
|
elif file == 'disable_networking.txt':
|
|
configs_main["main::connectivity"]["disable_networking"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_sharing_stats_with_gameserver.txt':
|
|
configs_main["main::connectivity"]["disable_sharing_stats_with_gameserver"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_source_query.txt':
|
|
configs_main["main::connectivity"]["disable_source_query"] = 1 #updated ini through ConfigObj
|
|
elif file == 'overlay_hook_delay_sec.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_overlay["overlay::general"]["hook_delay_sec"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'overlay_renderer_detector_timeout_sec.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_overlay["overlay::general"]["renderer_detector_timeout_sec"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'enable_experimental_overlay.txt' or file == 'disable_overlay.txt':
|
|
enable_ovl = 0
|
|
if file == 'enable_experimental_overlay.txt':
|
|
enable_ovl = 1
|
|
configs_overlay["overlay::general"]["enable_experimental_overlay"] = enable_ovl #updated ini through ConfigObj
|
|
elif file == 'app_paths.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
app_lines = [lll.strip('\n').strip('\r') for lll in fr.readlines() if lll.strip() and lll.strip()[0] != '#']
|
|
for app_lll in app_lines:
|
|
[appid, apppath] = app_lll.split('=', 1)
|
|
configs_app["app::paths"][appid.strip()] = apppath #updated ini through ConfigObj
|
|
elif file == 'dlc.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
dlc_lines = [lll.strip('\n').strip('\r') for lll in fr.readlines() if lll.strip() and lll.strip()[0] != '#']
|
|
configs_app["app::dlcs"]["unlock_all"] = 0 #updated ini through ConfigObj
|
|
for dlc_lll in dlc_lines:
|
|
[dlcid, dlcname] = dlc_lll.split('=', 1)
|
|
configs_app["app::dlcs"][dlcid.strip()] = dlcname #updated ini through ConfigObj
|
|
elif file == 'achievements_bypass.txt':
|
|
configs_main["main::misc"]["achievements_bypass"] = 1 #updated ini through ConfigObj
|
|
elif file == 'crash_printer_location.txt':
|
|
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
|
|
configs_main["main::general"]["crash_printer_location"] = fr.readline().strip('\n').strip('\r') #updated ini through ConfigObj
|
|
elif file == 'disable_lan_only.txt':
|
|
configs_main["main::connectivity"]["disable_lan_only"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_leaderboards_create_unknown.txt':
|
|
configs_main["main::general"]["disable_leaderboards_create_unknown"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_lobby_creation.txt':
|
|
configs_main["main::connectivity"]["disable_lobby_creation"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_overlay_achievement_notification.txt':
|
|
configs_overlay["overlay::general"]["disable_achievement_notification"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_overlay_friend_notification.txt':
|
|
configs_overlay["overlay::general"]["disable_friend_notification"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_overlay_warning_any.txt':
|
|
configs_overlay["overlay::general"]["disable_warning_any"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_overlay_warning_bad_appid.txt':
|
|
configs_overlay["overlay::general"]["disable_warning_bad_appid"] = 1 #updated ini through ConfigObj
|
|
elif file == 'disable_overlay_warning_local_save.txt':
|
|
configs_overlay["overlay::general"]["disable_warning_local_save"] = 1 #updated ini through ConfigObj
|
|
elif file == 'download_steamhttp_requests.txt':
|
|
configs_main["main::connectivity"]["download_steamhttp_requests"] = 1 #updated ini through ConfigObj
|
|
elif file == 'force_steamhttp_success.txt':
|
|
configs_main["main::misc"]["force_steamhttp_success"] = 1 #updated ini through ConfigObj
|
|
elif file == 'new_app_ticket.txt':
|
|
configs_main["main::general"]["new_app_ticket"] = 1 #updated ini through ConfigObj
|
|
elif file == 'gc_token.txt':
|
|
configs_main["main::general"]["gc_token"] = 1 #updated ini through ConfigObj
|
|
elif file == 'immediate_gameserver_stats.txt':
|
|
configs_main["main::general"]["immediate_gameserver_stats"] = 1 #updated ini through ConfigObj
|
|
elif file == 'is_beta_branch.txt':
|
|
configs_main["main::general"]["is_beta_branch"] = 1 #updated ini through ConfigObj
|
|
elif file == 'matchmaking_server_details_via_source_query.txt':
|
|
configs_main["main::general"]["matchmaking_server_details_via_source_query"] = 1 #updated ini through ConfigObj
|
|
elif file == 'matchmaking_server_list_actual_type.txt':
|
|
configs_main["main::general"]["matchmaking_server_list_actual_type"] = 1 #updated ini through ConfigObj
|
|
elif file == 'offline.txt':
|
|
configs_main["main::connectivity"]["offline"] = 1 #updated ini through ConfigObj
|
|
elif file == 'share_leaderboards_over_network.txt':
|
|
configs_main["main::connectivity"]["share_leaderboards_over_network"] = 1 #updated ini through ConfigObj
|
|
elif file == 'steam_deck.txt':
|
|
configs_main["main::general"]["steam_deck"] = 1 #updated ini through ConfigObj
|
|
|
|
def write_txt_file(filename: str, dict_ini: dict, section: str, key: str):
|
|
val = dict_ini.get(section, {}).get(key, None)
|
|
if val is None:
|
|
return False
|
|
|
|
create_new_steam_settings_folder()
|
|
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, filename), "wt", encoding='utf-8') as fw:
|
|
fw.write(str(val))
|
|
|
|
return True
|
|
|
|
def write_txt_file_bool(filename: str, dict_ini: dict, section: str, key: str, write_if: bool):
|
|
val = dict_ini.get(section, {}).get(key, None)
|
|
if val is None:
|
|
return False
|
|
val = str(val).lower()[0]
|
|
bool_val = val == '1' or val == "t" or val == "y"
|
|
if bool_val != write_if:
|
|
return False
|
|
|
|
create_new_steam_settings_folder()
|
|
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, filename), "wt", encoding='utf-8') as fw:
|
|
fw.write(f'{key}={val}')
|
|
|
|
return True
|
|
|
|
def write_txt_file_multi(filename: str, dict_ini: dict, section: str):
|
|
val = dict_ini.get(section, {})
|
|
if len(val) <= 0:
|
|
return False
|
|
|
|
create_new_steam_settings_folder()
|
|
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, filename), "wt", encoding='utf-8') as fw:
|
|
for kv in val.items():
|
|
fw.write(f'{kv[0]}={kv[1]}\n')
|
|
|
|
return True
|
|
|
|
def convert_to_txt(global_settings: str):
|
|
# oh no, they're too many! --- they are indeed... it seems ConfigParser does the job here
|
|
config = configparser.ConfigParser(strict=False, empty_lines_in_values=False)
|
|
for file in glob.glob('*.ini*', root_dir=global_settings):
|
|
config.read(os.path.join(global_settings, file), encoding='utf-8')
|
|
|
|
dict_ini = dict(config)
|
|
if 'DEFAULT' in dict_ini: # remove the "magic" default section
|
|
del dict_ini['DEFAULT']
|
|
|
|
done = 0
|
|
done += write_txt_file_bool('achievements_bypass.txt', dict_ini, 'main::misc', 'achievements_bypass', True)
|
|
done += write_txt_file_multi('app_paths.txt', dict_ini, 'app::paths')
|
|
# NOTE generating 'branches.json' would require copy pasting some code from 'generate_config_emu.py'
|
|
# if possible, avoid using 'migrate_gse' alltogether, and use 'generate_emu_config' instead
|
|
#done += write_txt_file('build_id.txt', dict_ini, 'app::general', 'build_id') # disabled after 'branches.json' update
|
|
done += write_txt_file('crash_printer_location.txt', dict_ini, 'main::general', 'crash_printer_location')
|
|
done += write_txt_file_bool('disable_account_avatar.txt', dict_ini, 'main::general', 'enable_account_avatar', False)
|
|
done += write_txt_file_bool('disable_lan_only.txt', dict_ini, 'main::connectivity', 'disable_lan_only',True)
|
|
done += write_txt_file_bool('disable_leaderboards_create_unknown.txt', dict_ini, 'main::general', 'disable_leaderboards_create_unknown', True)
|
|
done += write_txt_file_bool('disable_lobby_creation.txt', dict_ini, 'main::connectivity', 'disable_lobby_creation', True)
|
|
done += write_txt_file_bool('disable_networking.txt', dict_ini, 'main::connectivity', 'disable_networking', True)
|
|
done += write_txt_file_bool('disable_overlay_achievement_notification.txt', dict_ini, 'overlay::general', 'disable_achievement_notification', True)
|
|
done += write_txt_file_bool('disable_overlay_friend_notification.txt', dict_ini, 'overlay::general', 'disable_friend_notification', True)
|
|
done += write_txt_file_bool('disable_overlay_warning_any.txt', dict_ini, 'overlay::general', 'disable_warning_any', True)
|
|
done += write_txt_file_bool('disable_overlay_warning_bad_appid.txt', dict_ini, 'overlay::general', 'disable_warning_bad_appid', True)
|
|
done += write_txt_file_bool('disable_overlay_warning_local_save.txt', dict_ini, 'overlay::general', 'disable_warning_local_save', True)
|
|
done += write_txt_file_bool('disable_sharing_stats_with_gameserver.txt', dict_ini, 'main::connectivity', 'disable_sharing_stats_with_gameserver', True)
|
|
done += write_txt_file_bool('disable_source_query.txt', dict_ini, 'main::connectivity', 'disable_source_query', True)
|
|
done += write_txt_file_multi('dlc.txt', dict_ini, 'app::dlcs')
|
|
done += write_txt_file_bool('download_steamhttp_requests.txt', dict_ini, 'main::connectivity', 'download_steamhttp_requests', True)
|
|
done += write_txt_file_bool('disable_overlay.txt', dict_ini, 'overlay::general', 'enable_experimental_overlay', False)
|
|
done += write_txt_file_bool('enable_experimental_overlay.txt', dict_ini, 'overlay::general', 'enable_experimental_overlay', True)
|
|
done += write_txt_file('force_account_name.txt', dict_ini, 'user::general', 'account_name')
|
|
done += write_txt_file('force_branch_name.txt', dict_ini, 'app::general', 'branch_name')
|
|
done += write_txt_file('force_language.txt', dict_ini, 'user::general', 'language')
|
|
done += write_txt_file('force_listen_port.txt', dict_ini, 'main::connectivity', 'listen_port')
|
|
done += write_txt_file_bool('force_steamhttp_success.txt', dict_ini, 'main::misc', 'force_steamhttp_success', True)
|
|
done += write_txt_file('force_steamid.txt', dict_ini, 'user::general', 'account_steamid')
|
|
done += write_txt_file_bool('gc_token.txt', dict_ini, 'main::general', 'gc_token', True)
|
|
done += write_txt_file_bool('immediate_gameserver_stats.txt', dict_ini, 'main::general', 'immediate_gameserver_stats', True)
|
|
done += write_txt_file('ip_country.txt', dict_ini, 'user::general', 'ip_country')
|
|
done += write_txt_file_bool('is_beta_branch.txt', dict_ini, 'app::general', 'is_beta_branch', True)
|
|
done += write_txt_file_bool('matchmaking_server_details_via_source_query.txt', dict_ini, 'main::general', 'matchmaking_server_details_via_source_query', True)
|
|
done += write_txt_file_bool('matchmaking_server_list_actual_type.txt', dict_ini, 'main::general', 'matchmaking_server_list_actual_type', True)
|
|
done += write_txt_file_bool('new_app_ticket.txt', dict_ini, 'main::general', 'new_app_ticket', True)
|
|
done += write_txt_file_bool('offline.txt', dict_ini, 'main::connectivity', 'offline', True)
|
|
done += write_txt_file_multi('overlay_appearance.txt', dict_ini, 'overlay::appearance')
|
|
done += write_txt_file('overlay_hook_delay_sec.txt', dict_ini, 'overlay::general', 'hook_delay_sec')
|
|
done += write_txt_file('overlay_renderer_detector_timeout_sec.txt', dict_ini, 'overlay::general', 'renderer_detector_timeout_sec')
|
|
done += write_txt_file_bool('share_leaderboards_over_network.txt', dict_ini, 'main::connectivity', 'share_leaderboards_over_network', True)
|
|
done += write_txt_file_bool('steam_deck.txt', dict_ini, 'main::general', 'steam_deck', True)
|
|
|
|
return done
|
|
|
|
|
|
def main():
|
|
is_windows = platform.system().lower() == "windows"
|
|
global_settings = ''
|
|
|
|
CONVERT_TO_INI = True
|
|
SHOW_HELP = False
|
|
|
|
argc = len(sys.argv)
|
|
for idx in range(1, argc):
|
|
arg = sys.argv[idx]
|
|
if arg.lower() == "-revert":
|
|
CONVERT_TO_INI = False
|
|
elif arg == "/?" or arg == "-?" or arg == "--?" or arg.lower() == "/h" or arg.lower() == "-h" or arg.lower() == "--h" or arg.lower() == "/help" or arg.lower() == "-help" or arg.lower() == "--help":
|
|
SHOW_HELP = True
|
|
elif os.path.isdir(arg):
|
|
global_settings = arg
|
|
else:
|
|
print(f'invalid arg #{idx} "{arg}"', file=sys.stderr)
|
|
help()
|
|
sys.exit(1)
|
|
|
|
if SHOW_HELP:
|
|
help()
|
|
sys.exit(0)
|
|
|
|
if not global_settings:
|
|
if is_windows:
|
|
appdata = os.getenv('APPDATA')
|
|
if appdata:
|
|
global_settings = os.path.join(appdata, 'GSE Saves', 'settings')
|
|
else:
|
|
xdg = os.getenv('XDG_DATA_HOME')
|
|
if xdg:
|
|
global_settings = os.path.join(xdg, 'GSE Saves', 'settings')
|
|
|
|
if not global_settings:
|
|
home_env = os.getenv('HOME')
|
|
if home_env:
|
|
global_settings = os.path.join(home_env, 'GSE Saves', 'settings')
|
|
|
|
if not global_settings or not os.path.isdir(global_settings):
|
|
print('failed to detect folder', file=sys.stderr)
|
|
help()
|
|
sys.exit(1)
|
|
|
|
print(f'searching inside the folder: "{global_settings}"')
|
|
|
|
if CONVERT_TO_INI:
|
|
shutil.copytree(os.path.join("_DEFAULT", str(0)), "_OUTPUT", dirs_exist_ok=True) # copy from ./_DEFAULT/0 dir
|
|
shutil.copytree(os.path.join("_DEFAULT", str(1)), "_OUTPUT", dirs_exist_ok=True) # copy from ./_DEFAULT/1 dir
|
|
convert_to_ini(global_settings)
|
|
|
|
if convert_to_ini(global_settings):
|
|
create_new_steam_settings_folder()
|
|
configs_app.write() # use CongigObj to correctly update existing 'configs.app.ini' copied from ./_DEFAULT configuration --- END, write ini
|
|
# ConfigObj overrides the default ini format, adding spaces before and after '=' and '""' for empty keys, so we'll use this to undo the changes
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.app.ini"), 'r') as file:
|
|
filedata = file.read()
|
|
filedata = filedata.replace(' = ""', '=')
|
|
filedata = filedata.replace(' = ', '=')
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.app.ini"), 'w') as file:
|
|
file.write(filedata)
|
|
configs_main.write() # use CongigObj to correctly update existing 'configs.main.ini' copied from ./_DEFAULT configuration --- END, write ini
|
|
# ConfigObj overrides the default ini format, adding spaces before and after '=' and '""' for empty keys, so we'll use this to undo the changes
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.main.ini"), 'r') as file:
|
|
filedata = file.read()
|
|
filedata = filedata.replace(' = ""', '=')
|
|
filedata = filedata.replace(' = ', '=')
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.main.ini"), 'w') as file:
|
|
file.write(filedata)
|
|
configs_overlay.write() # use CongigObj to correctly update existing 'configs.overlay.ini' copied from ./_DEFAULT configuration --- END, write ini
|
|
# ConfigObj overrides the default ini format, adding spaces before and after '=' and '""' for empty keys, so we'll use this to undo the changes
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.overlay.ini"), 'r') as file:
|
|
filedata = file.read()
|
|
filedata = filedata.replace(' = ""', '=')
|
|
filedata = filedata.replace(' = ', '=')
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.overlay.ini"), 'w') as file:
|
|
file.write(filedata)
|
|
configs_user.write() # use CongigObj to correctly update existing 'configs.user.ini' copied from ./_DEFAULT configuration --- END, write ini
|
|
# ConfigObj overrides the default ini format, adding spaces before and after '=' and '""' for empty keys, so we'll use this to undo the changes
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.user.ini"), 'r') as file:
|
|
filedata = file.read()
|
|
filedata = filedata.replace(' = ""', '=')
|
|
filedata = filedata.replace(' = ', '=')
|
|
with open(os.path.join(NEW_STEAM_SETTINGS_FOLDER, "configs.user.ini"), 'w') as file:
|
|
file.write(filedata)
|
|
print(f'new settings written inside: "{os.path.join(os.path.curdir, NEW_STEAM_SETTINGS_FOLDER)}"')
|
|
else:
|
|
print('nothing found!', file=sys.stderr)
|
|
sys.exit(1)
|
|
else:
|
|
if convert_to_txt(global_settings):
|
|
print(f'new settings written inside: "{os.path.join(os.path.curdir, NEW_STEAM_SETTINGS_FOLDER)}"')
|
|
else:
|
|
print('nothing found!', file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
main()
|
|
sys.exit(0)
|
|
except Exception as e:
|
|
print("Unexpected error:")
|
|
print(e)
|
|
print("-----------------------")
|
|
for line in traceback.format_exception(e):
|
|
print(line)
|
|
print("-----------------------")
|
|
sys.exit(1)
|