DR_rs 0.2.5.7
This commit is contained in:
parent
767fd4877d
commit
2463d84c67
@ -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.6") # DR 的 Rust 编写部分的版本
|
||||
DR_rust_version = Version("0.2.5.7") # DR 的 Rust 编写部分的版本
|
||||
Api_version = Version("0.0.1.0") # API 版本
|
||||
__version__ = game_version
|
||||
|
||||
|
@ -33,7 +33,7 @@ if TYPE_CHECKING:
|
||||
from Difficult_Rocket.client import ClientWindow
|
||||
|
||||
if DR_option.use_DR_rust:
|
||||
from libs.Difficult_Rocket_rs import CenterCamera_rs, SR1PartData
|
||||
from libs.Difficult_Rocket_rs import CenterCamera_rs, SR1PartList_rs
|
||||
|
||||
|
||||
logger = logging.getLogger('client')
|
||||
@ -84,6 +84,7 @@ class SR1ShipRender(BaseScreen):
|
||||
def __init__(self,
|
||||
main_window: "ClientWindow"):
|
||||
super().__init__(main_window)
|
||||
load_start_time = time.time_ns()
|
||||
self.rendered = False
|
||||
self.focus = True
|
||||
self.need_draw = False
|
||||
@ -121,11 +122,15 @@ class SR1ShipRender(BaseScreen):
|
||||
anchor_x='left', anchor_y='top')
|
||||
self.part_data: Dict[int, SR1PartData] = {}
|
||||
self.parts_sprite: Dict[int, Sprite] = {}
|
||||
load_end_time = time.time_ns()
|
||||
logger.info(tr().client.sr1_render.setup.done())
|
||||
logger.info(tr().client.sr1_render.setup.use_time().format(
|
||||
(load_end_time - load_start_time) / 1000000000))
|
||||
if DR_option.use_DR_rust:
|
||||
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 =
|
||||
|
||||
def load_xml(self, file_path: str) -> bool:
|
||||
try:
|
||||
|
@ -55,3 +55,14 @@ os.pid_is = "Server PID: {} PPID: {}"
|
||||
input = "console"
|
||||
command = "in game commands"
|
||||
window = "window"
|
||||
|
||||
[client.sr1_render]
|
||||
setup.done = "SR1 Renderer loaded"
|
||||
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: {}"
|
||||
|
||||
|
@ -55,3 +55,13 @@ os.pid_is = "服务端 PID: {} PPID: {}"
|
||||
input = "控制台"
|
||||
command = "游戏内命令行"
|
||||
window = "窗口"
|
||||
|
||||
[client.sr1_render]
|
||||
setup.done = "SR1 渲染器载入完成"
|
||||
setup.use_time = "SR1 渲染器载入消耗时间: {} 秒"
|
||||
xml.loading = "正在加载XML文件: {}"
|
||||
xml.load_done = "XML 文件加载完成"
|
||||
xml.load_time = "XML 文件加载消耗时间: {} 秒"
|
||||
ship.load = "正在加载飞船: {}"
|
||||
ship.load_time = "飞船加载消耗时间: {} 秒"
|
||||
ship.info = "飞船信息:\n- 部件数量: {}\n- 部件重量: {}\n- 文件大小: {}"
|
||||
|
@ -6,17 +6,18 @@
|
||||
* -------------------------------
|
||||
*/
|
||||
|
||||
mod logger;
|
||||
mod python;
|
||||
mod render;
|
||||
mod simulator;
|
||||
mod sr1_data;
|
||||
mod render;
|
||||
mod logger;
|
||||
mod types;
|
||||
|
||||
use pyo3::prelude::*;
|
||||
|
||||
#[pyfunction]
|
||||
fn get_version_str() -> String {
|
||||
return "0.2.5.6".to_string();
|
||||
return "0.2.5.7".to_string();
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
@ -38,5 +39,6 @@ fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||
m.add_class::<render::camera::CameraRs>()?;
|
||||
m.add_class::<render::camera::CenterCameraRs>()?;
|
||||
m.add_class::<render::screen::PartFrame>()?;
|
||||
m.add_class::<python::data::PySR1PartList>()?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -5,4 +5,3 @@
|
||||
* All rights reserved
|
||||
* -------------------------------
|
||||
*/
|
||||
|
||||
|
34
libs/Difficult_Rocket_rs/src/src/python.rs
Normal file
34
libs/Difficult_Rocket_rs/src/src/python.rs
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* -------------------------------
|
||||
* Difficult Rocket
|
||||
* Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
||||
* All rights reserved
|
||||
* -------------------------------
|
||||
*/
|
||||
|
||||
pub mod data {
|
||||
use pyo3::prelude::*;
|
||||
use serde_xml_rs::from_str;
|
||||
|
||||
use crate::sr1_data::part_list::RawPartList;
|
||||
use crate::sr1_data::ship::RawShip;
|
||||
use crate::types::sr1::{SR1PartList, SR1PartListTrait, SR1Ship};
|
||||
|
||||
#[pyclass]
|
||||
#[pyo3(name = "SR1PartList_rs")]
|
||||
#[pyo3(text_signature = "(file_path = './configs/PartList.xml', list_name = 'NewPartList')")]
|
||||
pub struct PySR1PartList {
|
||||
pub part_list: SR1PartList,
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl PySR1PartList {
|
||||
#[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())),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -326,10 +326,19 @@ pub mod part_list {
|
||||
}
|
||||
|
||||
impl RawPartList {
|
||||
#[inline]
|
||||
pub fn new(parts: Vec<RawPartType>) -> Self {
|
||||
RawPartList { part_types: parts }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_file(file_name: String) -> Option<RawPartList> {
|
||||
let part_list_file = fs::read_to_string(file_name).unwrap();
|
||||
let part_list: RawPartList = from_str(part_list_file.as_str()).unwrap();
|
||||
Some(part_list)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn list_print(&self) -> () {
|
||||
for part_data in self.part_types.iter() {
|
||||
println!("{:?}\n", part_data);
|
||||
@ -351,27 +360,11 @@ pub mod part_list {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn read_part_list(file_name: String) -> Option<RawPartList> {
|
||||
let part_list_file = fs::read_to_string(file_name.to_string());
|
||||
|
||||
match part_list_file {
|
||||
Ok(part_list_file) => {
|
||||
let part_list: RawPartList = from_str(part_list_file.as_str()).unwrap();
|
||||
Some(part_list)
|
||||
}
|
||||
Err(_) => {
|
||||
println!("Error while reading File {}", file_name);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
#[pyo3(name = "part_list_read_test", signature = (file_name = "./configs/PartList.xml".to_string()))]
|
||||
pub fn read_part_list_py(_py: Python, file_name: Option<String>) -> PyResult<()> {
|
||||
let file_name = file_name.unwrap_or("./configs/PartList.xml".to_string());
|
||||
let _parts = read_part_list(file_name);
|
||||
let _parts = RawPartList::from_file(file_name);
|
||||
if let Some(parts) = _parts {
|
||||
// println!("{:?}", parts)
|
||||
parts.list_print();
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
pub mod sr1 {
|
||||
use std::collections::HashMap;
|
||||
// use super::math::{Shape, Point2D};
|
||||
use crate::sr1_data::part_list::Damage as RawDamage;
|
||||
use crate::sr1_data::part_list::{
|
||||
@ -210,12 +211,12 @@ pub mod sr1 {
|
||||
}
|
||||
|
||||
impl SR1PartList {
|
||||
pub fn to_raw_part_list(&self) -> RawPartList {
|
||||
let mut types: Vec<RawPartType> = Vec::new();
|
||||
for part_type in &self.types {
|
||||
types.insert(0, part_type.to_raw_part_type());
|
||||
pub fn get_hash_map(&self) -> HashMap<String, SR1PartType> {
|
||||
let mut map = HashMap::new();
|
||||
for part in self.types.iter() {
|
||||
map.insert(part.id.clone(), part.clone());
|
||||
}
|
||||
RawPartList { part_types: types }
|
||||
map
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user