From ab1359e68cfe984d19385b145d499a63abf38f8c Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 5 Apr 2023 12:13:02 +0800 Subject: [PATCH] translate and DR_rs 0.2.6.0 --- Difficult_Rocket/__init__.py | 2 +- Difficult_Rocket/client/render/sr1_ship.py | 16 +++++++++++++--- configs/lang/en-us.toml | 13 +++++++------ libs/Difficult_Rocket_rs/src/src/lib.rs | 2 +- libs/Difficult_Rocket_rs/src/src/python.rs | 8 +++++--- libs/Difficult_Rocket_rs/src/src/types.rs | 7 ++++++- 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Difficult_Rocket/__init__.py b/Difficult_Rocket/__init__.py index 43f4689..10da0e4 100644 --- a/Difficult_Rocket/__init__.py +++ b/Difficult_Rocket/__init__.py @@ -24,7 +24,7 @@ from libs.MCDR.version import Version game_version = Version("0.7.1.4") # 游戏版本 build_version = Version("1.2.1.0") # 编译文件版本(与游戏本体无关) -DR_rust_version = Version("0.2.5.7") # DR 的 Rust 编写部分的版本 +DR_rust_version = Version("0.2.6.0") # DR 的 Rust 编写部分的版本 Api_version = Version("0.0.1.0") # API 版本 __version__ = game_version diff --git a/Difficult_Rocket/client/render/sr1_ship.py b/Difficult_Rocket/client/render/sr1_ship.py index 40ef445..8924d53 100644 --- a/Difficult_Rocket/client/render/sr1_ship.py +++ b/Difficult_Rocket/client/render/sr1_ship.py @@ -6,7 +6,6 @@ import time import logging -import contextlib from xml.etree import ElementTree from xml.etree.ElementTree import Element from typing import List, TYPE_CHECKING, Union, Dict, Optional, Generator @@ -113,6 +112,7 @@ class SR1ShipRender(BaseScreen): x=main_window.width / 2, y=main_window.height / 2) self.debug_mouse_label.visible = SR1ShipRender_Option.debug_mouse_pos self.textures: Union[SR1Textures, None] = None + self.xml_name = 'configs/dock1.xml' self.xml_doc: ElementTree = parse('configs/dock1.xml') self.xml_root: ElementTree.Element = self.xml_doc.getroot() self.part_batch = Batch() @@ -130,13 +130,19 @@ class SR1ShipRender(BaseScreen): self.camera_rs = CenterCamera_rs(main_window, min_zoom=(1 / 2) ** 10, max_zoom=10) self.rust_parts = None - # self.part_list_rs = + self.part_list_rs = SR1PartList_rs('configs/PartList.xml', 'default_part_list') def load_xml(self, file_path: str) -> bool: try: + start_time = time.time_ns() + logger.info(tr().client.sr1_render.xml.loading().format(file_path)) cache_doc = parse(file_path) self.xml_doc = cache_doc self.xml_root = self.xml_doc.getroot() + self.xml_name = file_path + logger.info(tr().client.sr1_render.xml.load_done()) + logger.info(tr().client.sr1_render.xml.load_time().format( + (time.time_ns() - start_time) / 1000000000)) return True except Exception as e: print(e) @@ -181,6 +187,7 @@ class SR1ShipRender(BaseScreen): def render_ship(self): if self.textures is None: self.load_textures() + logger.info(tr().client.sr1_render.ship.load().format(self.xml_name)) start_time = time.perf_counter_ns() self.part_data: Dict[int, SR1PartData] = {} self.parts_sprite: Dict[int, Sprite] = {} @@ -228,8 +235,11 @@ class SR1ShipRender(BaseScreen): self.render_ship() if self.drawing: - with contextlib.suppress(GeneratorExit): + try: next(self.gen_draw) + except GeneratorExit: + self.drawing = False + logger.info(tr().client.sr1_render.ship.render.done()) if self.need_update_parts: self.update_parts() diff --git a/configs/lang/en-us.toml b/configs/lang/en-us.toml index 722622b..c50e07e 100644 --- a/configs/lang/en-us.toml +++ b/configs/lang/en-us.toml @@ -16,12 +16,12 @@ logger.logfile_datefmt = "Log file date format : " game_start.at = "The main thread of the game starts with : " [client] -setup.done = "Client loaded" +setup.start = "Client start loading" setup.use_time = "Client loading has used: {} second" setup.use_time_ns = "Client loading has used: {} nano second" [window] -setup.done = "Window loaded" +setup.start = "Window start loading" setup.use_time = "Window loading has used: {} second" setup.use_time_ns = "Window loading has used: {} nano second" os.pid_is = "Window's PID: {} PPID: {}" @@ -48,7 +48,8 @@ game.stop = "game closing, saving data……" game.end = "game closed" [server] -setup.done = "Server loaded " +setup.start = "Server start loading" +setup.use_time = "Server loading has used: {} second" os.pid_is = "Server PID: {} PPID: {}" [game] @@ -57,12 +58,12 @@ command = "in game commands" window = "window" [client.sr1_render] -setup.done = "SR1 Renderer loaded" +setup.start = "SR1 Renderer start loading" setup.use_time = "SR1 Renderer loading has used: {} second" xml.loading = "Loading XML file: {}" xml.load_done = "XML file loaded" xml.load_time = "XML file loading has used: {} second" ship.load = "Loading ship: {}" ship.load_time = "Ship loading has used: {} second" -ship.info = "Ship info:\n- Parts: {}\n- Weight: {}\n- File size: {}" - +ship.info = "Ship info:\n- Parts: {}\n- Weight: {}" +ship.render.done = "Ship render done" diff --git a/libs/Difficult_Rocket_rs/src/src/lib.rs b/libs/Difficult_Rocket_rs/src/src/lib.rs index 456b447..7f00e9f 100644 --- a/libs/Difficult_Rocket_rs/src/src/lib.rs +++ b/libs/Difficult_Rocket_rs/src/src/lib.rs @@ -17,7 +17,7 @@ use pyo3::prelude::*; #[pyfunction] fn get_version_str() -> String { - return "0.2.5.7".to_string(); + return "0.2.6.0".to_string(); } #[pyfunction] diff --git a/libs/Difficult_Rocket_rs/src/src/python.rs b/libs/Difficult_Rocket_rs/src/src/python.rs index 38a2714..b6b0d85 100644 --- a/libs/Difficult_Rocket_rs/src/src/python.rs +++ b/libs/Difficult_Rocket_rs/src/src/python.rs @@ -26,10 +26,12 @@ pub mod data { #[new] fn new(file_path: String, list_name: String) -> Self { let raw_part_list: RawPartList = RawPartList::from_file(file_path).unwrap(); - Self { - part_list: raw_part_list.to_sr_part_list(Some(list_name.to_string())), - } + let part_list = raw_part_list.to_sr_part_list(Some(list_name)); + Self { part_list } } + // fn get_weight(&self, part_type: String) -> PyRe { + // self.part_list.get_weight() + // } } } diff --git a/libs/Difficult_Rocket_rs/src/src/types.rs b/libs/Difficult_Rocket_rs/src/src/types.rs index 1547901..1121a72 100644 --- a/libs/Difficult_Rocket_rs/src/src/types.rs +++ b/libs/Difficult_Rocket_rs/src/src/types.rs @@ -207,6 +207,7 @@ pub mod sr1 { #[derive(Debug, Clone)] pub struct SR1PartList { pub types: Vec, + pub cache: Option>, pub name: String, } @@ -233,7 +234,11 @@ pub mod sr1 { impl SR1PartList { #[inline] pub fn new(name: String, types: Vec) -> Self { - SR1PartList { name, types } + SR1PartList { + name, + cache: None, + types, + } } pub fn part_types_new(part_types: Vec, name: Option) -> Self {