diff --git a/Difficult_Rocket/mod/loader/__init__.py b/Difficult_Rocket/mod/loader/__init__.py index 6d70c5c..b98c11b 100644 --- a/Difficult_Rocket/mod/loader/__init__.py +++ b/Difficult_Rocket/mod/loader/__init__.py @@ -9,7 +9,7 @@ import time import traceback import importlib from pathlib import Path -from typing import List, Dict, Optional, TypeVar +from typing import List, Dict, Optional, TypeVar, Type from Difficult_Rocket.mod.api import ModInfo from Difficult_Rocket.utils.translate import tr @@ -71,7 +71,7 @@ class ModManager(Options): .format(mod, event_name, e, traceback.format_exc()) ) - def load_mod(self, mod_path: Path) -> Optional[type(ModInfo)]: + def load_mod(self, mod_path: Path) -> Optional[Type[ModInfo]]: """ 加载指定路径下的 mod :param mod_path: mod 的路径 @@ -101,7 +101,7 @@ class ModManager(Options): tr().mod.load.faild.no_mod_class().format(mod_path), tag="load" ) return None - mod_class: type(ModInfo) = loading_mod.mod_class # 获取 mod 类 + mod_class: Type[ModInfo] = loading_mod.mod_class # 获取 mod 类 if mod_class.mod_id not in self.find_mod_paths: self.find_mod_paths[mod_class.mod_id] = mod_path return mod_class @@ -148,7 +148,7 @@ class ModManager(Options): self, extra_path: Optional[List[Path]] = None, extra_mod_path: Optional[List[Path]] = None, - ) -> List[type(ModInfo)]: + ) -> List[Type[ModInfo]]: """ 加载所有 mod (可提供额外的 mod 路径) :param extra_path: 额外的 mod 路径 @@ -176,7 +176,7 @@ class ModManager(Options): ) return mods - def init_mods(self, mods: List[type(ModInfo)]): + def init_mods(self, mods: List[Type[ModInfo]]): """ 加载 mod :param mods: 要加载的 mod 的 ModInfo 类 diff --git a/mods/dr_game/console.py b/mods/dr_game/console.py index e014688..41b4869 100644 --- a/mods/dr_game/console.py +++ b/mods/dr_game/console.py @@ -1,6 +1,8 @@ from . import DR_mod_runtime from Difficult_Rocket.main import Console +from typing import Optional + if DR_mod_runtime.use_DR_rust: from .Difficult_Rocket_rs import Console_rs @@ -20,8 +22,8 @@ class RustConsole(Console): def init(self, **kwargs) -> None: self.console = Console_rs() - def get_command(self) -> str: - return self.console.get_command() # ignore: noqa + def get_command(self) -> Optional[str]: + return self.console.get_command() def new_command(self) -> None: self.console.new_command() diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index ca36259..10498a2 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -575,8 +575,8 @@ class SR1ShipEditor(BaseScreen): self.group_camera.zoom *= zoom_d mouse_dx_d *= 1 - zoom_d mouse_dy_d *= 1 - zoom_d - self.group_camera.view_x += mouse_dx_d - self.group_camera.view_y += mouse_dy_d + self.group_camera.view_x += int(mouse_dx_d) + self.group_camera.view_y += int(mouse_dy_d) elif self.status.moving: # 如果是在移动整体渲染位置 size_x, size_y = self.size