Sound file error hopefully fixed for pyinstaller.
This commit is contained in:
Submodule libstormgames updated: f2079261d1...8cca66d44e
@@ -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")
|
level_path = os.path.join(base_path, "levels", game_dir, f"{level_num}.json")
|
||||||
return level_path
|
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)
|
||||||
|
@@ -9,7 +9,7 @@ from src.pack_sound_system import PackSoundSystem
|
|||||||
from src.level import Level
|
from src.level import Level
|
||||||
from src.object import Object
|
from src.object import Object
|
||||||
from src.player import Player
|
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.save_manager import SaveManager
|
||||||
from src.survival_generator import SurvivalGenerator
|
from src.survival_generator import SurvivalGenerator
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@ class WickedQuest:
|
|||||||
totalTime = pygame.time.get_ticks() - self.gameStartTime
|
totalTime = pygame.time.get_ticks() - self.gameStartTime
|
||||||
if self.player.xPos >= self.currentLevel.rightBoundary:
|
if self.player.xPos >= self.currentLevel.rightBoundary:
|
||||||
# Check for end of game scene
|
# 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']:
|
for ext in ['.wav', '.ogg', '.mp3']:
|
||||||
endFile = os.path.join(gamePath, f'end{ext}')
|
endFile = os.path.join(gamePath, f'end{ext}')
|
||||||
if os.path.exists(endFile):
|
if os.path.exists(endFile):
|
||||||
|
Reference in New Issue
Block a user