From c656da613fd0fe7be9e5acdaaf7cacf4ceaf6136 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 10 Jun 2023 18:08:40 +0800 Subject: [PATCH] remove some raw Version import --- Difficult_Rocket/__init__.py | 4 +--- Difficult_Rocket/mod/api/__init__.py | 5 +--- Difficult_Rocket/mod/loader/__init__.py | 32 ++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Difficult_Rocket/__init__.py b/Difficult_Rocket/__init__.py index e75e021..688ab4c 100644 --- a/Difficult_Rocket/__init__.py +++ b/Difficult_Rocket/__init__.py @@ -12,9 +12,7 @@ import importlib.util from pathlib import Path from typing import Optional, List, Tuple -from Difficult_Rocket.api.types import Options - -from libs.MCDR.version import Version +from Difficult_Rocket.api.types import Options, Version game_version = Version("0.8.0.0") # 游戏版本 build_version = Version("1.2.1.0") # 编译文件版本(与游戏本体无关) diff --git a/Difficult_Rocket/mod/api/__init__.py b/Difficult_Rocket/mod/api/__init__.py index b1fe624..4ebc331 100644 --- a/Difficult_Rocket/mod/api/__init__.py +++ b/Difficult_Rocket/mod/api/__init__.py @@ -23,10 +23,7 @@ else: Game = TypeVar("Game") ClientWindow = TypeVar("ClientWindow") from Difficult_Rocket import DR_runtime -from Difficult_Rocket.utils.options import Options - -# from libs -from libs.MCDR.version import Version +from Difficult_Rocket.api.types import Options, Version RequireVersion = Tuple[Version, Version] # 第一个是最低兼容版本,第二个是最高兼容版本 diff --git a/Difficult_Rocket/mod/loader/__init__.py b/Difficult_Rocket/mod/loader/__init__.py index 6460ec0..58d54c4 100644 --- a/Difficult_Rocket/mod/loader/__init__.py +++ b/Difficult_Rocket/mod/loader/__init__.py @@ -4,8 +4,38 @@ # All rights reserved # ------------------------------- +import logging +from pathlib import Path +from typing import List, Dict, Optional + from Difficult_Rocket.api.screen import BaseScreen -from Difficult_Rocket import DR_option, DR_runtime +from Difficult_Rocket.api.types import Options, Version +from Difficult_Rocket.mod.api import ModInfo +# from Difficult_Rocket import DR_option, DR_runtime +class ModManager(Options): + name = 'Mod Manager' + logger: logging.Logger + + mods_path: List[Path] = [Path('./mods')] + loaded_mod_modules: Dict[str, ModInfo] = {} + + def find_mods(self) -> List[Path]: + """ + 查找mods文件夹下的所有mod + :return: + """ + mods = [] + for path in self.mods_path: + if not path.exists(): + path.mkdir(parents=True) + continue + for mod in path.iterdir(): + ... + + def init(self) -> None: + self.logger = logging.getLogger('client') + self.logger.name = 'mod_manager' + self.logger.info('Mod Manager init')