Attempt to fix traceback on game exit with some older games.
This commit is contained in:
32
__init__.py
32
__init__.py
@ -126,42 +126,42 @@ __all__ = [
|
||||
]
|
||||
|
||||
# Create global instances for backward compatibility
|
||||
config_service = ConfigService.get_instance()
|
||||
volume_service = VolumeService.get_instance()
|
||||
path_service = PathService.get_instance()
|
||||
configService = ConfigService.get_instance()
|
||||
volumeService = VolumeService.get_instance()
|
||||
pathService = PathService.get_instance()
|
||||
|
||||
# Set up backward compatibility hooks for initialize_gui
|
||||
_original_initialize_gui = initialize_gui
|
||||
_originalInitializeGui = initialize_gui
|
||||
|
||||
def initialize_gui_with_services(game_title):
|
||||
def initialize_gui_with_services(gameTitle):
|
||||
"""Wrapper around initialize_gui that initializes services."""
|
||||
# Initialize path service
|
||||
path_service.initialize(game_title)
|
||||
pathService.initialize(gameTitle)
|
||||
|
||||
# Connect config service to path service
|
||||
config_service.set_game_info(game_title, path_service)
|
||||
configService.set_game_info(gameTitle, pathService)
|
||||
|
||||
# Call original initialize_gui
|
||||
return _original_initialize_gui(game_title)
|
||||
return _originalInitializeGui(gameTitle)
|
||||
|
||||
# Replace initialize_gui with the wrapped version
|
||||
initialize_gui = initialize_gui_with_services
|
||||
|
||||
# Initialize global scoreboard constructor
|
||||
_original_scoreboard_init = Scoreboard.__init__
|
||||
_originalScoreboardInit = Scoreboard.__init__
|
||||
|
||||
def scoreboard_init_with_services(self, score=0, config_service=None, speech=None):
|
||||
def scoreboard_init_with_services(self, score=0, configService=None, speech=None):
|
||||
"""Wrapper around Scoreboard.__init__ that ensures services are initialized."""
|
||||
# Use global services if not specified
|
||||
if config_service is None:
|
||||
config_service = ConfigService.get_instance()
|
||||
if configService is None:
|
||||
configService = ConfigService.get_instance()
|
||||
|
||||
# Ensure path_service is connected if using defaults
|
||||
if not hasattr(config_service, 'path_service') and path_service.game_path is not None:
|
||||
config_service.path_service = path_service
|
||||
# Ensure pathService is connected if using defaults
|
||||
if not hasattr(configService, 'pathService') and pathService.game_path is not None:
|
||||
configService.pathService = pathService
|
||||
|
||||
# Call original init with services
|
||||
_original_scoreboard_init(self, score, config_service, speech)
|
||||
_originalScoreboardInit(self, score, configService, speech)
|
||||
|
||||
# Replace Scoreboard.__init__ with the wrapped version
|
||||
Scoreboard.__init__ = scoreboard_init_with_services
|
||||
|
Reference in New Issue
Block a user