mini_arcade_core.scenes.registry ================================ .. py:module:: mini_arcade_core.scenes.registry .. autoapi-nested-parse:: SimScene registry for mini arcade core. Allows registering and creating scenes by string IDs. Classes ------- .. autoapisummary:: mini_arcade_core.scenes.registry.SceneFactory mini_arcade_core.scenes.registry.SceneRegistry Module Contents --------------- .. py:class:: SceneFactory Bases: :py:obj:`Protocol` Protocol for scene factory callables. .. py:method:: __call__(context: mini_arcade_core.runtime.context.RuntimeContext) -> mini_arcade_core.scenes.sim_scene.SimScene .. py:class:: SceneRegistry Registry for scene factories, allowing registration and creation of scenes by string IDs. .. py:property:: listed_scene_ids :type: list[str] Get a list of all registered scene IDs. :return: A list of registered scene IDs. :rtype: list[str] .. py:method:: register(scene_id: str, factory: SceneFactory) Register a scene factory under a given scene ID. :param scene_id: The string ID for the scene. :type scene_id: str :param factory: A callable that creates a SimScene instance. :type factory: SceneFactory .. py:method:: register_cls(scene_id: str, scene_cls: type[mini_arcade_core.scenes.sim_scene.SimScene]) Register a SimScene class under a given scene ID. :param scene_id: The string ID for the scene. :type scene_id: str :param scene_cls: The SimScene class to register. :type scene_cls: type["SimScene"] .. py:method:: create(scene_id: str, context: mini_arcade_core.runtime.context.RuntimeContext) -> mini_arcade_core.scenes.sim_scene.SimScene | None Create a scene instance using the registered factory for the given scene ID. :param scene_id: The string ID of the scene to create. :type scene_id: str :param game: The Game instance to pass to the scene factory. :type game: Game :return: A new SimScene instance. :rtype: SimScene :raises KeyError: If no factory is registered for the given scene ID. .. py:method:: load_catalog(catalog: Dict[str, type[mini_arcade_core.scenes.sim_scene.SimScene]]) Load a catalog of SimScene classes into the registry. :param catalog: A dictionary mapping scene IDs to SimScene classes. :type catalog: Dict[str, type["SimScene"]] .. py:method:: discover(*packages: str) -> SceneRegistry Import all modules in a package so @scene decorators run. :param packages: The package names to scan for scene modules. :type packages: str :return: The SceneRegistry instance (for chaining). :rtype: SceneRegistry