@@ -419,17 +419,35 @@ def is_botpack_up_to_date():
419419 return github_commit_id == local_commit_id
420420
421421
422+ def get_content_folder ():
423+ if Path (os .getcwd ()).name == 'RLBotGUI' :
424+ # This is the classic case where we're using embedded python, and our current working directory is already
425+ # something like C:\Users\tareh\AppData\Local\RLBotGUI. It will also match if you have cloned RLBotGUI.
426+ return Path (os .getcwd ())
427+
428+ # If we get here, we're likely using system python or something along those lines.
429+ local_app_data = os .getenv ('LOCALAPPDATA' )
430+ if local_app_data :
431+ # We appear to be on Windows platform. This is where the new Windows launch script puts things.
432+ guix_path = Path (os .getenv ('LOCALAPPDATA' )) / 'RLBotGUIX'
433+ guix_path .mkdir (exist_ok = True )
434+ return guix_path
435+
436+ # Probably on linux or mac at this point. Go with CWD again, because that's what they've used historically.
437+ return Path (os .getcwd ())
438+
439+
440+
422441@eel .expose
423442def download_bot_pack ():
443+ content_folder = get_content_folder ()
444+ botpack_location = content_folder / BOTPACK_FOLDER
445+
424446 # The bot pack in now hosted at https://github.com/RLBot/RLBotPack
425- BotpackDownloader ().download (BOTPACK_REPO_OWNER , BOTPACK_REPO_NAME , BOTPACK_REPO_BRANCH , BOTPACK_FOLDER )
447+ BotpackDownloader ().download (BOTPACK_REPO_OWNER , BOTPACK_REPO_NAME , BOTPACK_REPO_BRANCH , botpack_location )
426448
427449 # Configure the folder settings.
428- bot_folder_settings ['folders' ][os .path .abspath (BOTPACK_FOLDER )] = {'visible' : True }
429-
430- if os .path .abspath (OLD_BOTPACK_FOLDER ) in bot_folder_settings ['folders' ]:
431- # Toggle off the old one since it's been replaced.
432- bot_folder_settings ['folders' ][os .path .abspath (OLD_BOTPACK_FOLDER )] = {'visible' : False }
450+ bot_folder_settings ['folders' ][str (botpack_location )] = {'visible' : True }
433451
434452 settings = load_settings ()
435453 settings .setValue (BOT_FOLDER_SETTINGS_KEY , bot_folder_settings )
@@ -450,11 +468,11 @@ def hot_reload_python_bots():
450468
451469
452470def ensure_bot_directory ():
453- bot_directory = CREATED_BOTS_FOLDER
454- if not os . path . exists ( bot_directory ):
455- os .mkdir (bot_directory )
471+ content_folder = get_content_folder ()
472+ bot_directory = content_folder / CREATED_BOTS_FOLDER
473+ bot_directory .mkdir (exist_ok = True )
456474
457- bot_folder_settings ['folders' ][os . path . abspath ( CREATED_BOTS_FOLDER )] = {'visible' : True }
475+ bot_folder_settings ['folders' ][str ( bot_directory )] = {'visible' : True }
458476 settings = load_settings ()
459477 settings .setValue (BOT_FOLDER_SETTINGS_KEY , bot_folder_settings )
460478 settings .sync ()
0 commit comments