diff --git a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock index 2dfcd59..ab5c7d9 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock +++ b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock @@ -146,7 +146,7 @@ dependencies = [ [[package]] name = "difficult_rocket_rs" -version = "0.3.4" +version = "0.3.5" dependencies = [ "anyhow", "dict_derive", diff --git a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml index 7672a93..2793b0e 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml +++ b/mods/dr_game/Difficult_Rocket_rs/src/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "difficult_rocket_rs" -version = "0.3.4" +version = "0.3.5" edition = "2021" license-file = '../../LICENSE' authors = ["shenjackyuanjie <3695888@qq.com>"] diff --git a/mods/dr_game/__init__.py b/mods/dr_game/__init__.py index 6204165..f60f98c 100644 --- a/mods/dr_game/__init__.py +++ b/mods/dr_game/__init__.py @@ -16,11 +16,23 @@ from Difficult_Rocket.api.types import Options, Version from lib_not_dr import loggers -DR_rust_version = Version("0.3.4") # DR_mod 的 Rust 编写部分的兼容版本 +DR_rust_version = Version("0.3.5") # DR_mod 的 Rust 编写部分的兼容版本 logger = loggers.config.get_logger_from_old("client.dr_game", "client") +class ModLoadFaildError(BaseException): + """ + 就是用来告诉你, mod 加载错误 + """ + + +class DRrsNotMatch(ModLoadFaildError): + """ + 就是用来告诉你, mod 的 rust 版本不匹配 + """ + + class _DR_mod_runtime(Options): # NOQA name = "DR mod runtime" @@ -39,12 +51,16 @@ class _DR_mod_runtime(Options): # NOQA relationship = ( "larger" if self.DR_rust_version > self.DR_rust_version else "smaller" ) - logger.warn( + logger.fatal( f"DR_rust builtin version is {self.DR_rust_version} " f"but true version is {get_version_str()}.\n" f"Builtin version {relationship} than true version", tag="load_dll", ) + raise DRrsNotMatch( + f"DR rs found with version {get_version_str()}, " + f"but compat version is {DR_rust_version}" + ) self.use_DR_rust = self.use_DR_rust and self.DR_rust_available except Exception: traceback.print_exc() @@ -60,7 +76,7 @@ DR_mod_runtime = _DR_mod_runtime() class DR_mod(ModInfo): # NOQA mod_id = "difficult_rocket_mod" name = "Difficult Rocket mod" - version = Version("0.3.3.0") + version = Version("0.3.4") writer = "shenjackyuanjie" link = "shenjack.top" @@ -93,14 +109,14 @@ class DR_mod(ModInfo): # NOQA return True def on_client_start(self, game: Game, client: ClientWindow): - #from .sr1_ship import SR1ShipRender + # from .sr1_ship import SR1ShipRender from .menu import Menu client.add_sub_screen("DR_game_menu", Menu) logger.info("added dr_game_menu screen", tag="dr_game") - #client.add_sub_screen("SR1_ship", SR1ShipRender) - #logger.info("added SR1_ship screen", tag="dr_game") + # client.add_sub_screen("SR1_ship", SR1ShipRender) + # logger.info("added SR1_ship screen", tag="dr_game") def on_unload(self, game: Game): game.client.window.screen_list.pop("SR1_ship") diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index 4356889..cf58f13 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -188,13 +188,14 @@ class SR1ShipRender(BaseScreen): traceback.print_exc() self.logger.error(traceback.format_exc(), tag="load_xml") return False + def draw_parts( - self, - cache: List[Tuple[SR1PartType_rs, SR1PartData_rs]], + self, + cache: List[Tuple[SR1PartType_rs, SR1PartData_rs]], count: int, each_count: int, draw_part_box: bool, - draw_alpha: int + draw_alpha: int, ): # 渲染传入的parts part_group = Group(2, parent=self.part_group) @@ -299,31 +300,26 @@ class SR1ShipRender(BaseScreen): self.status.draw_done = False # rust 渲染 if DR_mod_runtime.use_DR_rust: - - - #渲染所有未连接零件 + # 渲染所有未连接零件 all_disconnected_groups = self.rust_ship.disconnected_parts() for parts_groups, connections in all_disconnected_groups: draw_part_box = False cache = [] for p_type, p_data in parts_groups: - cache.append((p_data.id,parts_groups)) - count=self.draw_parts(cache, count, each_count, draw_part_box, 128) + cache.append((p_data.id, parts_groups)) + count = self.draw_parts(cache, count, each_count, draw_part_box, 128) if count >= each_count: count = 0 yield - - - # 渲染所有已连接零件 draw_part_box = False cache = self.rust_ship.as_dict() - count=self.draw_parts(cache.items(), count, each_count, draw_part_box, 255) + count = self.draw_parts(cache.items(), count, each_count, draw_part_box, 255) if count >= each_count: count = 0 yield - + connect_line_group = Group(7, parent=self.part_group) for connect in self.rust_ship.connections().get_raw_data(): # 连接线