Document Lua plugin APIs.

Trying to fix the singleton-ness in the plugin manager because it
prevents injecting settings until the game is fully committed (new game
wizard completed). Added the docs describing what I think I've been able
to discover.
This commit is contained in:
Dan Albert
2023-04-25 20:26:28 -07:00
parent b6059f692e
commit 664efa3ace
3 changed files with 64 additions and 3 deletions

View File

@@ -4,11 +4,12 @@ from pathlib import Path
from typing import Dict, List
from game.settings import Settings
from .luaplugin import LuaPlugin
class LuaPluginManager:
"""Manages available and loaded lua plugins."""
_plugins_loaded = False
_plugins: Dict[str, LuaPlugin] = {}
@@ -48,5 +49,12 @@ class LuaPluginManager:
@classmethod
def load_settings(cls, settings: Settings) -> None:
"""Attaches all loaded plugins to the given settings object.
The LuaPluginManager singleton can only be attached to a single Settings object
at a time, and plugins will update the Settings object directly, so attaching
the plugin manager to a detached Settings object (say, during the new game
wizard, but then canceling the new game) will break the settings UI.
"""
for plugin in cls.plugins():
plugin.set_settings(settings)