Sound file error hopefully fixed for pyinstaller.

This commit is contained in:
Storm Dragon
2025-09-13 01:33:16 -04:00
parent 82f1128087
commit 8218d28701
3 changed files with 26 additions and 3 deletions

View File

@@ -95,3 +95,26 @@ def get_level_path(game_dir, level_num):
level_path = os.path.join(base_path, "levels", game_dir, f"{level_num}.json")
return level_path
def get_game_dir_path(game_dir):
"""Get full path to game directory for end.ogg and other game files.
Args:
game_dir (str): Game directory name
Returns:
str: Full path to game directory
"""
if game_dir is None:
raise ValueError("game_dir cannot be None")
# Handle PyInstaller path issues - same logic as get_level_path
if hasattr(sys, "_MEIPASS"):
# Running as PyInstaller executable
base_path = sys._MEIPASS
else:
# Running as script
base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, "levels", game_dir)