From 8218d28701fb1d8432e4258edfa6b9e7a1f980d0 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 13 Sep 2025 01:33:16 -0400 Subject: [PATCH] Sound file error hopefully fixed for pyinstaller. --- libstormgames | 2 +- src/game_selection.py | 23 +++++++++++++++++++++++ wicked_quest.py | 4 ++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libstormgames b/libstormgames index f207926..8cca66d 160000 --- a/libstormgames +++ b/libstormgames @@ -1 +1 @@ -Subproject commit f2079261d14cafdd7f9650fb6d2044532dfc43a9 +Subproject commit 8cca66d44e694002ce5d19d130837ba6a068ac86 diff --git a/src/game_selection.py b/src/game_selection.py index 99f9bd2..50bfe15 100644 --- a/src/game_selection.py +++ b/src/game_selection.py @@ -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) diff --git a/wicked_quest.py b/wicked_quest.py index c36ab0a..c1eb72f 100755 --- a/wicked_quest.py +++ b/wicked_quest.py @@ -9,7 +9,7 @@ from src.pack_sound_system import PackSoundSystem from src.level import Level from src.object import Object from src.player import Player -from src.game_selection import select_game, get_level_path +from src.game_selection import select_game, get_level_path, get_game_dir_path from src.save_manager import SaveManager from src.survival_generator import SurvivalGenerator @@ -446,7 +446,7 @@ class WickedQuest: totalTime = pygame.time.get_ticks() - self.gameStartTime if self.player.xPos >= self.currentLevel.rightBoundary: # Check for end of game scene - gamePath = os.path.dirname(get_level_path(self.currentGame, 1)) + gamePath = get_game_dir_path(self.currentGame) for ext in ['.wav', '.ogg', '.mp3']: endFile = os.path.join(gamePath, f'end{ext}') if os.path.exists(endFile):