From a52eb426a848ae946e3b01a1f693b1bebce1d80e Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 3 May 2023 00:25:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=99=BD=E8=AF=B4=E5=85=B6=E5=AE=9E=E4=B9=9F?= =?UTF-8?q?=E4=B8=8D=E6=80=8E=E4=B9=88=E5=8F=AF=E7=94=A8=EF=BC=8C=E4=BD=86?= =?UTF-8?q?=E6=98=AF=E8=87=B3=E5=B0=91=E6=9C=89=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Difficult_Rocket/client/__init__.py | 2 -- Difficult_Rocket/main.py | 4 ++++ docs/src/update_logs.md | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Difficult_Rocket/client/__init__.py b/Difficult_Rocket/client/__init__.py index 3eab958..972b922 100644 --- a/Difficult_Rocket/client/__init__.py +++ b/Difficult_Rocket/client/__init__.py @@ -197,8 +197,6 @@ class ClientWindow(Window): def setup(self): self.set_icon(pyglet.image.load('./textures/icon.png')) - self.logger.info(f"=== finding mods from {DR_runtime.mod_path} ===") - self.logger.info(f'find mods: {DR_runtime.find_mods()}') self.load_fonts() # TODO 读取配置文件,加载不同的屏幕,解耦 self.screen_list['DR_debug'] = DRDEBUGScreen(self) diff --git a/Difficult_Rocket/main.py b/Difficult_Rocket/main.py index f9991a6..1318e7b 100644 --- a/Difficult_Rocket/main.py +++ b/Difficult_Rocket/main.py @@ -80,6 +80,7 @@ class Game: if not mod_path.exists(): self.logger.info(tr().main.mod.find.faild.no_mod_folder()) return + # 寻找有效 mod paths = mod_path.iterdir() sys.path.append(DR_runtime.mod_path) for mod_path in paths: @@ -98,6 +99,7 @@ class Game: except ImportError as e: self.logger.warning(tr().main.mod.find.faild().format(mod_path, e)) self.logger.info(tr().main.mod.find.done()) + # 加载有效 mod module = [] for mod in mods: try: @@ -118,6 +120,8 @@ class Game: mod_list = [] for mod in module: mod_list.append((mod.mod_id, mod.version)) + # 调用 on_load + self.dispatch_event('on_load', game=self) DR_runtime.DR_Mod_List = mod_list def dispatch_event(self, event_name: str, *args, **kwargs) -> None: diff --git a/docs/src/update_logs.md b/docs/src/update_logs.md index 9657bdd..3f85388 100644 --- a/docs/src/update_logs.md +++ b/docs/src/update_logs.md @@ -28,6 +28,18 @@ > 啊啊啊啊啊 大重构 api +### DR_api `0.1.0.0` + +- 大概是一个可用的版本了 +- `ModInfo` + - `on_load(game: Game, old_self: Optional[ModInfo]) -> bool` + - `game`: Game 对象 用于存储 DR SDK 的信息 + - `old_self`: 旧的 ModInfo 对象, 可以用于从上次加载中恢复信息 + - 返回值: 是否加载成功 + - `on_client_start(game: Game, client: ClientWindow) -> None` + - `game`: Game 对象 用于存储 DR SDK 的信息 + - `client`: ClientWindow 对象 用于传递客户端状态 + ### DR_rs `0.2.7.0` - `__init__.py` @@ -52,6 +64,8 @@ - `DR_option` & `DR_runtime`(`long_version` `15`) - 完全移除 `DR_rust` 部分 - Completely removed the `DR_rust` part +- 现在 `client` 不会在 `setup()` 中调用 `DR_runtime` 的 `find_mods()` 方法 + - Now `client` will not call the `find_mods()` method of `DR_runtime` in `setup()` ### Changes