Fix some warning

This commit is contained in:
shenjack-5600u 2024-06-09 20:06:08 +08:00
parent 309eee76e3
commit 3495799a89
Signed by: shenjack
GPG Key ID: FDF9864E11C7E79F
3 changed files with 11 additions and 9 deletions

View File

@ -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

View File

@ -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()

View File

@ -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