fmt + 步进版本号

This commit is contained in:
shenjack 2024-05-23 21:24:19 +08:00
parent a8be1eadd8
commit 7a960bb6ed
Signed by: shenjack
GPG Key ID: 7B1134A979775551
4 changed files with 33 additions and 21 deletions

View File

@ -146,7 +146,7 @@ dependencies = [
[[package]] [[package]]
name = "difficult_rocket_rs" name = "difficult_rocket_rs"
version = "0.3.4" version = "0.3.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"dict_derive", "dict_derive",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "difficult_rocket_rs" name = "difficult_rocket_rs"
version = "0.3.4" version = "0.3.5"
edition = "2021" edition = "2021"
license-file = '../../LICENSE' license-file = '../../LICENSE'
authors = ["shenjackyuanjie <3695888@qq.com>"] authors = ["shenjackyuanjie <3695888@qq.com>"]

View File

@ -16,11 +16,23 @@ from Difficult_Rocket.api.types import Options, Version
from lib_not_dr import loggers 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") 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 class _DR_mod_runtime(Options): # NOQA
name = "DR mod runtime" name = "DR mod runtime"
@ -39,12 +51,16 @@ class _DR_mod_runtime(Options): # NOQA
relationship = ( relationship = (
"larger" if self.DR_rust_version > self.DR_rust_version else "smaller" "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"DR_rust builtin version is {self.DR_rust_version} "
f"but true version is {get_version_str()}.\n" f"but true version is {get_version_str()}.\n"
f"Builtin version {relationship} than true version", f"Builtin version {relationship} than true version",
tag="load_dll", 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 self.use_DR_rust = self.use_DR_rust and self.DR_rust_available
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
@ -60,7 +76,7 @@ DR_mod_runtime = _DR_mod_runtime()
class DR_mod(ModInfo): # NOQA class DR_mod(ModInfo): # NOQA
mod_id = "difficult_rocket_mod" mod_id = "difficult_rocket_mod"
name = "Difficult Rocket mod" name = "Difficult Rocket mod"
version = Version("0.3.3.0") version = Version("0.3.4")
writer = "shenjackyuanjie" writer = "shenjackyuanjie"
link = "shenjack.top" link = "shenjack.top"
@ -93,14 +109,14 @@ class DR_mod(ModInfo): # NOQA
return True return True
def on_client_start(self, game: Game, client: ClientWindow): def on_client_start(self, game: Game, client: ClientWindow):
#from .sr1_ship import SR1ShipRender # from .sr1_ship import SR1ShipRender
from .menu import Menu from .menu import Menu
client.add_sub_screen("DR_game_menu", Menu) client.add_sub_screen("DR_game_menu", Menu)
logger.info("added dr_game_menu screen", tag="dr_game") logger.info("added dr_game_menu screen", tag="dr_game")
#client.add_sub_screen("SR1_ship", SR1ShipRender) # client.add_sub_screen("SR1_ship", SR1ShipRender)
#logger.info("added SR1_ship screen", tag="dr_game") # logger.info("added SR1_ship screen", tag="dr_game")
def on_unload(self, game: Game): def on_unload(self, game: Game):
game.client.window.screen_list.pop("SR1_ship") game.client.window.screen_list.pop("SR1_ship")

View File

@ -188,13 +188,14 @@ class SR1ShipRender(BaseScreen):
traceback.print_exc() traceback.print_exc()
self.logger.error(traceback.format_exc(), tag="load_xml") self.logger.error(traceback.format_exc(), tag="load_xml")
return False return False
def draw_parts( def draw_parts(
self, self,
cache: List[Tuple[SR1PartType_rs, SR1PartData_rs]], cache: List[Tuple[SR1PartType_rs, SR1PartData_rs]],
count: int, count: int,
each_count: int, each_count: int,
draw_part_box: bool, draw_part_box: bool,
draw_alpha: int draw_alpha: int,
): ):
# 渲染传入的parts # 渲染传入的parts
part_group = Group(2, parent=self.part_group) part_group = Group(2, parent=self.part_group)
@ -299,31 +300,26 @@ class SR1ShipRender(BaseScreen):
self.status.draw_done = False self.status.draw_done = False
# rust 渲染 # rust 渲染
if DR_mod_runtime.use_DR_rust: if DR_mod_runtime.use_DR_rust:
# 渲染所有未连接零件
#渲染所有未连接零件
all_disconnected_groups = self.rust_ship.disconnected_parts() all_disconnected_groups = self.rust_ship.disconnected_parts()
for parts_groups, connections in all_disconnected_groups: for parts_groups, connections in all_disconnected_groups:
draw_part_box = False draw_part_box = False
cache = [] cache = []
for p_type, p_data in parts_groups: for p_type, p_data in parts_groups:
cache.append((p_data.id,parts_groups)) cache.append((p_data.id, parts_groups))
count=self.draw_parts(cache, count, each_count, draw_part_box, 128) count = self.draw_parts(cache, count, each_count, draw_part_box, 128)
if count >= each_count: if count >= each_count:
count = 0 count = 0
yield yield
# 渲染所有已连接零件 # 渲染所有已连接零件
draw_part_box = False draw_part_box = False
cache = self.rust_ship.as_dict() 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: if count >= each_count:
count = 0 count = 0
yield yield
connect_line_group = Group(7, parent=self.part_group) connect_line_group = Group(7, parent=self.part_group)
for connect in self.rust_ship.connections().get_raw_data(): for connect in self.rust_ship.connections().get_raw_data():
# 连接线 # 连接线