我这都跳了好几次步进版本号push了 DR_rs 0.2.5.0

This commit is contained in:
shenjack 2023-02-19 16:56:30 +08:00
parent 024e924438
commit 0a95312c12
7 changed files with 65 additions and 33 deletions

View File

@ -24,7 +24,7 @@ from libs.MCDR.version import Version
game_version = Version("0.7.0.3") # 游戏版本 game_version = Version("0.7.0.3") # 游戏版本
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关) build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
DR_rust_version = Version("0.2.3.0") # DR 的 Rust 编写部分的版本 DR_rust_version = Version("0.2.5.0") # DR 的 Rust 编写部分的版本
__version__ = game_version __version__ = game_version
long_version: int = 12 long_version: int = 12
@ -78,7 +78,8 @@ class _DR_option(Options):
if sys.platform != 'darwin': # MacOS 的测试只能在 Macos 上跑 if sys.platform != 'darwin': # MacOS 的测试只能在 Macos 上跑
self.pyglet_macosx_dev_test = False self.pyglet_macosx_dev_test = False
try: try:
from libs.Difficult_Rocket_rs import test_call, get_version_str from libs.Difficult_Rocket_rs import test_call, get_version_str, part_list_read_test
part_list_read_test("./configs/PartList.xml")
test_call(self) test_call(self)
print(f'DR_rust available: {get_version_str()}') print(f'DR_rust available: {get_version_str()}')
except ImportError: except ImportError:

View File

@ -1,4 +1,4 @@
<PartTypes xmlns="http://jundroo.com/simplerockets/partlist.xsd"> <PartTypes xmlns="http://jundroo.com/simplerockets/partlist.xsd">
<PartType id="pod-1" name="Command Pod Mk1" description="This is your ship's brain. Be careful with it." sprite="Pod.png" type="pod" mass="1.0" width="4" height="3" hidden="true"> <PartType id="pod-1" name="Command Pod Mk1" description="This is your ship's brain. Be careful with it." sprite="Pod.png" type="pod" mass="1.0" width="4" height="3" hidden="true">
<Damage disconnect="1500" explode="1500" explosionPower="5" explosionSize="10" /> <Damage disconnect="1500" explode="1500" explosionPower="5" explosionSize="10" />
<Shape> <Shape>

View File

@ -6,7 +6,7 @@
from .lib import * from .lib import *
from typing import TYPE_CHECKING, Dict, Tuple from typing import TYPE_CHECKING, Dict, Tuple, Optional
if TYPE_CHECKING: if TYPE_CHECKING:
from Difficult_Rocket.client.screen import BaseScreen from Difficult_Rocket.client.screen import BaseScreen
@ -22,6 +22,8 @@ if TYPE_CHECKING:
def simluation() -> None: ... def simluation() -> None: ...
""" 用来测试 rust 的物理模拟能不能用 """ """ 用来测试 rust 的物理模拟能不能用 """
def part_list_read_test(file_name: Optional[str] = "./configs/PartList.xml") -> None: ...
class PartDatas: class PartDatas:
""" 用于在 PyObj 里塞一个浓眉大眼的 HashMap<uszie, SR1PartData>""" """ 用于在 PyObj 里塞一个浓眉大眼的 HashMap<uszie, SR1PartData>"""
def __new__(cls, py_part_data: Dict[int, SR1PartData]) -> "PartDatas": ... def __new__(cls, py_part_data: Dict[int, SR1PartData]) -> "PartDatas": ...

View File

@ -116,7 +116,7 @@ dependencies = [
[[package]] [[package]]
name = "difficult_rocket_rs" name = "difficult_rocket_rs"
version = "0.2.2" version = "0.2.5"
dependencies = [ dependencies = [
"pyo3", "pyo3",
"rapier2d-f64", "rapier2d-f64",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "difficult_rocket_rs" name = "difficult_rocket_rs"
version = "0.2.2" version = "0.2.5"
edition = "2021" edition = "2021"
license-file = '../../LICENSE' license-file = '../../LICENSE'
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -14,8 +14,8 @@ crate-type = ["cdylib"]
[profile.dev.package.rapier2d-f64] [profile.dev.package.rapier2d-f64]
opt-level = 3 opt-level = 3
[profile.release] #[profile.release]
codegen-units = 1 #codegen-units = 1
#[dependencies.quick-xml] #[dependencies.quick-xml]
#version = "0.27.1" #version = "0.27.1"

View File

@ -16,7 +16,7 @@ use pyo3::prelude::*;
#[pyfunction] #[pyfunction]
fn get_version_str() -> String { fn get_version_str() -> String {
return String::from("0.2.2.0"); return String::from("0.2.5.0");
} }
#[pyfunction] #[pyfunction]
@ -35,6 +35,7 @@ fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(test_call, m)?)?; m.add_function(wrap_pyfunction!(test_call, m)?)?;
m.add_function(wrap_pyfunction!(sr1_render::better_update_parts, m)?)?; m.add_function(wrap_pyfunction!(sr1_render::better_update_parts, m)?)?;
m.add_function(wrap_pyfunction!(simulator::simluation, m)?)?; m.add_function(wrap_pyfunction!(simulator::simluation, m)?)?;
m.add_function(wrap_pyfunction!(sr1_data::part_list::read_part_list_py, m)?)?;
m.add_class::<sr1_render::types::PartDatas>()?; m.add_class::<sr1_render::types::PartDatas>()?;
m.add_class::<render::camera::CameraRs>()?; m.add_class::<render::camera::CameraRs>()?;
m.add_class::<render::screen::PartFrame>()?; m.add_class::<render::screen::PartFrame>()?;

View File

@ -7,24 +7,26 @@
*/ */
pub mod part_list { pub mod part_list {
use std::fs;
use pyo3::prelude::*; use pyo3::prelude::*;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use serde_xml_rs::{to_string, from_reader}; use serde_xml_rs::{from_str};
#[derive(Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PartList { pub struct PartList {
#[serde(rename = "PartType")] #[serde(rename = "PartType")]
part_types: Vec<PartType> part_types: Vec<PartType>
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Serialize, Deserialize, Copy, Clone)] #[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub enum PartTypes { pub enum PartTypes {
pod, pod,
detacher, detacher,
wheel, wheel,
fuselage, fuselage,
r#struct, strut,
tank, tank,
engine, engine,
parachute, parachute,
@ -36,36 +38,62 @@ pub mod part_list {
lander lander
} }
#[derive(Serialize, Deserialize, Copy, Clone)] #[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub enum Category { pub enum Category {
Satellite Satellite
} }
#[derive(Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PartType { pub struct PartType {
id: String, pub id: String,
name: String, pub name: String,
description: String, pub description: String,
sprite: String, pub sprite: String,
r#type: PartTypes, pub r#type: PartTypes,
mass: f64, pub mass: f64,
width: u32, pub width: u32,
height: u32, pub height: u32,
friction: Option<f64>, pub friction: Option<f64>,
category: Option<Category>, pub category: Option<Category>,
#[serde(rename = "ignoreEditorIntersections")] #[serde(rename = "ignoreEditorIntersections")]
ignore_editor_intersections: Option<bool>, pub ignore_editor_intersections: Option<bool>,
#[serde(rename = "disableEditorRotation")] #[serde(rename = "disableEditorRotation")]
disable_editor_rotation: Option<bool>, pub disable_editor_rotation: Option<bool>,
#[serde(rename = "canExplode")] #[serde(rename = "canExplode")]
can_explode: Option<bool>, pub can_explode: Option<bool>,
#[serde(rename = "coverHeight")] #[serde(rename = "coverHeight")]
cover_height: Option<u32>, pub cover_height: Option<u32>,
#[serde(rename = "sandboxOnly")] #[serde(rename = "sandboxOnly")]
sandbox_only: Option<bool>, pub sandbox_only: Option<bool>,
drag: Option<f64>, pub drag: Option<f64>,
hidden: Option<bool>, pub hidden: Option<bool>,
buoyancy: Option<f64> pub buoyancy: Option<f64>
}
#[inline]
pub fn read_part_list(file_name: String) -> Option<PartList> {
let part_list_file = fs::read_to_string(file_name.to_string());
match part_list_file {
Ok(part_list_file) => {
let part_list: PartList = 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(file_name: Option<String>) -> PyResult<()> {
let file_name = file_name.unwrap_or("./configs/PartList.xml".to_string());
let parts = read_part_list(file_name);
if let Some(parts) = parts {
println!("{:?}", parts);
}
Ok(())
} }
} }