translate and DR_rs 0.2.6.0

This commit is contained in:
shenjack 2023-04-05 12:13:02 +08:00
parent f1afdc5467
commit ab1359e68c
6 changed files with 33 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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<f64> {
// self.part_list.get_weight()
// }
}
}

View File

@ -207,6 +207,7 @@ pub mod sr1 {
#[derive(Debug, Clone)]
pub struct SR1PartList {
pub types: Vec<SR1PartType>,
pub cache: Option<HashMap<String, SR1PartType>>,
pub name: String,
}
@ -233,7 +234,11 @@ pub mod sr1 {
impl SR1PartList {
#[inline]
pub fn new(name: String, types: Vec<SR1PartType>) -> Self {
SR1PartList { name, types }
SR1PartList {
name,
cache: None,
types,
}
}
pub fn part_types_new(part_types: Vec<SR1PartType>, name: Option<String>) -> Self {