Attempt to fix traceback on game exit with some older games.

This commit is contained in:
Storm Dragon
2025-03-14 23:10:14 -04:00
parent 2ad22ff1ae
commit be6dfdf53a
9 changed files with 483 additions and 457 deletions

View File

@ -31,7 +31,7 @@ def initialize_gui(gameTitle):
dict: Dictionary of loaded sound objects
"""
# Initialize path service with game title
path_service = PathService.get_instance().initialize(gameTitle)
pathService = PathService.get_instance().initialize(gameTitle)
# Seed the random generator to the clock
random.seed()
@ -95,7 +95,7 @@ def display_text(text):
"""
# Get service instances
speech = Speech.get_instance()
volume_service = VolumeService.get_instance()
volumeService = VolumeService.get_instance()
# Store original text with blank lines for copying
originalText = text.copy()
@ -123,22 +123,22 @@ def display_text(text):
if event.type == pygame.KEYDOWN:
# Check for Alt modifier
mods = pygame.key.get_mods()
alt_pressed = mods & pygame.KMOD_ALT
altPressed = mods & pygame.KMOD_ALT
# Volume controls (require Alt)
if alt_pressed:
if altPressed:
if event.key == pygame.K_PAGEUP:
volume_service.adjust_master_volume(0.1, pygame.mixer)
volumeService.adjust_master_volume(0.1, pygame.mixer)
elif event.key == pygame.K_PAGEDOWN:
volume_service.adjust_master_volume(-0.1, pygame.mixer)
volumeService.adjust_master_volume(-0.1, pygame.mixer)
elif event.key == pygame.K_HOME:
volume_service.adjust_bgm_volume(0.1, pygame.mixer)
volumeService.adjust_bgm_volume(0.1, pygame.mixer)
elif event.key == pygame.K_END:
volume_service.adjust_bgm_volume(-0.1, pygame.mixer)
volumeService.adjust_bgm_volume(-0.1, pygame.mixer)
elif event.key == pygame.K_INSERT:
volume_service.adjust_sfx_volume(0.1, pygame.mixer)
volumeService.adjust_sfx_volume(0.1, pygame.mixer)
elif event.key == pygame.K_DELETE:
volume_service.adjust_sfx_volume(-0.1, pygame.mixer)
volumeService.adjust_sfx_volume(-0.1, pygame.mixer)
else:
if event.key in (pygame.K_ESCAPE, pygame.K_RETURN):
return