Remove serde-xml and xml-rs require
This commit is contained in:
parent
487533c128
commit
e0017675fa
35
README.md
35
README.md
@ -104,38 +104,9 @@ python DR.py
|
||||
- `xmltodict` (已经内置 V0.12.0 路径:`./libs/xmltodict`)
|
||||
- `pyperclip` (已经内置 V1.8.2 路径: `./libs/pyperclip`)
|
||||
|
||||
```text
|
||||
# this requirement is for
|
||||
# DR basic running from source
|
||||
# DR build (by nuitka)
|
||||
# DR contributing
|
||||
|
||||
# for images
|
||||
# not for pypy >= 3.10
|
||||
pillow >= 10.0.0; (platform_python_implementation == "PyPy" and python_version < "3.10") or platform_python_implementation == "CPython"
|
||||
|
||||
# for sys info
|
||||
psutil >= 5.9.5
|
||||
|
||||
# for files
|
||||
rtoml >= 0.9.0
|
||||
tomlkit >= 0.11.8
|
||||
defusedxml >= 0.7.1
|
||||
|
||||
# for debug
|
||||
objprint >= 0.2.2
|
||||
viztracer >= 0.15.6; platform_python_implementation != "PyPy"
|
||||
vizplugins >= 0.1.3; platform_python_implementation != "PyPy"
|
||||
|
||||
# for compile
|
||||
nuitka >= 1.7.5
|
||||
ordered-set >= 4.1.0
|
||||
imageio >= 2.31.0; (platform_python_implementation == "PyPy" and python_version < "3.10") or platform_python_implementation == "CPython"
|
||||
wheel >= 0.40.0
|
||||
setuptools >= 67.8.0
|
||||
setuptools-rust >= 1.6.0
|
||||
|
||||
```
|
||||
[requirement.txt](requirement.txt)
|
||||
[requirement-build.txt](requirement-build.txt)
|
||||
[requirement-dev.txt](requirement-dev.txt)
|
||||
|
||||
## 感谢
|
||||
|
||||
|
@ -102,38 +102,9 @@ python DR.py
|
||||
- `xmltodict` (pre-installed V0.12.0 path:`./libs/xmltodict`)
|
||||
- `pyperclip` (pre-installed V1.8.2 path: `./libs/pyperclip`)
|
||||
|
||||
```text
|
||||
# this requirement is for
|
||||
# DR basic running from source
|
||||
# DR build (by nuitka)
|
||||
# DR contributing
|
||||
|
||||
# for images
|
||||
# not for pypy >= 3.10
|
||||
pillow >= 10.0.0; (platform_python_implementation == "PyPy" and python_version < "3.10") or platform_python_implementation == "CPython"
|
||||
|
||||
# for sys info
|
||||
psutil >= 5.9.5
|
||||
|
||||
# for files
|
||||
rtoml >= 0.9.0
|
||||
tomlkit >= 0.11.8
|
||||
defusedxml >= 0.7.1
|
||||
|
||||
# for debug
|
||||
objprint >= 0.2.2
|
||||
viztracer >= 0.15.6; platform_python_implementation != "PyPy"
|
||||
vizplugins >= 0.1.3; platform_python_implementation != "PyPy"
|
||||
|
||||
# for compile
|
||||
nuitka >= 1.7.5
|
||||
ordered-set >= 4.1.0
|
||||
imageio >= 2.31.0; (platform_python_implementation == "PyPy" and python_version < "3.10") or platform_python_implementation == "CPython"
|
||||
wheel >= 0.40.0
|
||||
setuptools >= 67.8.0
|
||||
setuptools-rust >= 1.6.0
|
||||
|
||||
```
|
||||
[requirement.txt](requirement.txt)
|
||||
[requirement-build.txt](requirement-build.txt)
|
||||
[requirement-dev.txt](requirement-dev.txt)
|
||||
|
||||
## thanks to
|
||||
|
||||
|
46
mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock
generated
46
mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock
generated
@ -153,8 +153,6 @@ dependencies = [
|
||||
"quick-xml",
|
||||
"rapier2d-f64",
|
||||
"serde",
|
||||
"serde-xml-rs",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -222,12 +220,6 @@ dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||
|
||||
[[package]]
|
||||
name = "matrixmultiply"
|
||||
version = "0.3.8"
|
||||
@ -548,18 +540,6 @@ dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-xml-rs"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb3aa78ecda1ebc9ec9847d5d3aba7d618823446a049ba2491940506da6e2782"
|
||||
dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.193"
|
||||
@ -639,26 +619,6 @@ version = "0.12.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.41",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
@ -756,12 +716,6 @@ version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.31"
|
||||
|
@ -29,9 +29,6 @@ fs-err = "2.11.0"
|
||||
quick-xml = { version = "0.31.0", features = ["serialize"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
xml-rs = "0.8.19"
|
||||
serde-xml-rs = "0.6.0"
|
||||
|
||||
nalgebra = "0.32.3"
|
||||
rapier2d-f64 = { version = "0.17.2", features = ["simd-stable"] }
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::io::Cursor;
|
||||
use std::ops::Deref;
|
||||
|
||||
use super::math::{Edge, Shape};
|
||||
@ -15,6 +17,9 @@ use crate::sr1_data::ship::{
|
||||
use crate::data_type::math::{Point2D, Rotatable};
|
||||
use crate::data_type::IdType;
|
||||
|
||||
use quick_xml::events::{BytesEnd, BytesStart, Event};
|
||||
use quick_xml::writer::Writer;
|
||||
|
||||
pub type ConnectionType = Vec<(Vec<SR1PartData>, Option<Vec<Connection>>)>;
|
||||
|
||||
pub fn radians_map_to_degrees(angle: f64) -> f64 {
|
||||
@ -722,11 +727,6 @@ impl SR1Ship {
|
||||
}
|
||||
|
||||
pub fn save(&self, file_name: String, save_status: &SaveStatus) -> Option<()> {
|
||||
use quick_xml::events::{BytesEnd, BytesStart, Event};
|
||||
use quick_xml::writer::Writer;
|
||||
use std::fs;
|
||||
use std::io::Cursor;
|
||||
|
||||
macro_rules! option_push_attr {
|
||||
($elem: ident, $test_block: expr, $push: expr) => {
|
||||
if ($test_block) {
|
||||
|
@ -9,6 +9,10 @@ use crate::data_type::sr1::{get_max_box, SR1PartData, SR1PartListTrait};
|
||||
use crate::data_type::sr1::{SR1PartList, SR1PartType, SR1Ship};
|
||||
use crate::data_type::IdType;
|
||||
use crate::sr1_data::part_list::RawPartList;
|
||||
use crate::sr1_data::ship::RawShip;
|
||||
|
||||
// use serde_xml_rs::to_string;
|
||||
use quick_xml::se::to_string;
|
||||
|
||||
#[pyclass]
|
||||
#[pyo3(name = "SaveStatus_rs")]
|
||||
@ -330,6 +334,7 @@ impl PySR1Ship {
|
||||
}
|
||||
|
||||
fn save(&self, file_path: String, save_status: Option<PySaveStatus>) -> PyResult<()> {
|
||||
println!("{:?}", save_status);
|
||||
self.ship.save(file_path, &save_status.unwrap_or_default().status).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
@ -337,9 +342,10 @@ impl PySR1Ship {
|
||||
|
||||
#[pyfunction]
|
||||
pub fn load_and_save_test(file_name: String) -> PyResult<()> {
|
||||
use crate::sr1_data::ship::RawShip;
|
||||
use serde_xml_rs::to_string;
|
||||
let ship = RawShip::from_file(file_name).unwrap();
|
||||
let _save_string = to_string(&ship);
|
||||
match to_string(&ship) {
|
||||
Ok(s) => println!("{}", s),
|
||||
Err(e) => println!("{}", e),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use crate::data_type::sr1::{SR1PartListTrait, SR1PartTypeData};
|
||||
use fs_err as fs;
|
||||
use pyo3::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_xml_rs::from_str;
|
||||
use quick_xml::de::from_str;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct RawPartList {
|
||||
@ -72,7 +72,9 @@ pub enum Location {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub struct Vertex {
|
||||
#[serde(rename = "@x")]
|
||||
pub x: Option<f64>,
|
||||
#[serde(rename = "@y")]
|
||||
pub y: Option<f64>,
|
||||
}
|
||||
|
||||
@ -87,19 +89,23 @@ pub struct Shape {
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub struct AttachPoint {
|
||||
pub location: Option<Location>,
|
||||
#[serde(rename = "@x")]
|
||||
pub x: Option<f64>,
|
||||
#[serde(rename = "@y")]
|
||||
pub y: Option<f64>,
|
||||
#[serde(rename = "flipX")]
|
||||
#[serde(rename = "@flipX")]
|
||||
pub flip_x: Option<bool>,
|
||||
#[serde(rename = "flipY")]
|
||||
#[serde(rename = "@flipY")]
|
||||
pub flip_y: Option<bool>,
|
||||
#[serde(rename = "breakAngle")]
|
||||
#[serde(rename = "@breakAngle")]
|
||||
pub break_angle: Option<i32>,
|
||||
#[serde(rename = "breakForce")]
|
||||
#[serde(rename = "@breakForce")]
|
||||
pub break_force: Option<f64>,
|
||||
#[serde(rename = "fuelLine")]
|
||||
#[serde(rename = "@fuelLine")]
|
||||
pub fuel_line: Option<bool>,
|
||||
#[serde(rename = "@group")]
|
||||
pub group: Option<i32>,
|
||||
#[serde(rename = "@order")]
|
||||
pub order: Option<i32>,
|
||||
}
|
||||
|
||||
@ -121,11 +127,13 @@ impl AttachPoints {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub struct Damage {
|
||||
#[serde(rename = "@disconnect")]
|
||||
pub disconnect: f64,
|
||||
#[serde(rename = "@explode")]
|
||||
pub explode: f64,
|
||||
#[serde(rename = "explosionPower")]
|
||||
#[serde(rename = "@explosionPower")]
|
||||
pub explosion_power: Option<f64>,
|
||||
#[serde(rename = "explosionSize")]
|
||||
#[serde(rename = "@explosionSize")]
|
||||
pub explosion_size: Option<f64>,
|
||||
}
|
||||
|
||||
@ -150,83 +158,105 @@ pub enum FuelType {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub struct Tank {
|
||||
#[serde(rename = "@fuel")]
|
||||
pub fuel: f64,
|
||||
#[serde(rename = "dryMass")]
|
||||
#[serde(rename = "@dryMass")]
|
||||
pub dry_mass: f64,
|
||||
// 0 -> 普通燃料
|
||||
// 1 -> Rcs
|
||||
// 2 -> 电量
|
||||
// 3 -> 固推
|
||||
#[serde(rename = "fuelType")]
|
||||
#[serde(rename = "@fuelType")]
|
||||
pub fuel_type: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub struct Engine {
|
||||
#[serde(rename = "@power")]
|
||||
pub power: f64,
|
||||
#[serde(rename = "@consumption")]
|
||||
pub consumption: f64,
|
||||
#[serde(rename = "@size")]
|
||||
pub size: f64,
|
||||
#[serde(rename = "@turn")]
|
||||
pub turn: f64,
|
||||
#[serde(rename = "fuelType")]
|
||||
#[serde(rename = "@fuelType")]
|
||||
pub fuel_type: Option<i32>,
|
||||
#[serde(rename = "throttleExponential")]
|
||||
#[serde(rename = "@throttleExponential")]
|
||||
pub throttle_exponential: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub struct Rcs {
|
||||
#[serde(rename = "@power")]
|
||||
pub power: f64,
|
||||
#[serde(rename = "@consumption")]
|
||||
pub consumption: f64,
|
||||
#[serde(rename = "@size")]
|
||||
pub size: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub struct Solar {
|
||||
#[serde(rename = "chargeRate")]
|
||||
#[serde(rename = "@chargeRate")]
|
||||
pub charge_rate: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub struct Lander {
|
||||
#[serde(rename = "maxAngle")]
|
||||
#[serde(rename = "@maxAngle")]
|
||||
pub max_angle: f64,
|
||||
#[serde(rename = "minLength")]
|
||||
#[serde(rename = "@minLength")]
|
||||
pub min_length: f64,
|
||||
#[serde(rename = "maxLength")]
|
||||
#[serde(rename = "@maxLength")]
|
||||
pub max_length: f64,
|
||||
#[serde(rename = "angleSpeed")]
|
||||
#[serde(rename = "@angleSpeed")]
|
||||
pub angle_speed: Option<f64>,
|
||||
#[serde(rename = "lengthSpeed")]
|
||||
#[serde(rename = "@lengthSpeed")]
|
||||
pub length_speed: Option<f64>,
|
||||
#[serde(rename = "@width")]
|
||||
pub width: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct RawPartType {
|
||||
// 基本属性
|
||||
#[serde(rename = "@id")]
|
||||
pub id: String,
|
||||
#[serde(rename = "@name")]
|
||||
pub name: String,
|
||||
#[serde(rename = "@description")]
|
||||
pub description: String,
|
||||
#[serde(rename = "@sprite")]
|
||||
pub sprite: String,
|
||||
#[serde(rename = "@type")]
|
||||
pub r#type: SR1PartTypeEnum,
|
||||
#[serde(rename = "@mass")]
|
||||
pub mass: f64,
|
||||
#[serde(rename = "@width")]
|
||||
pub width: u32,
|
||||
#[serde(rename = "@height")]
|
||||
pub height: u32,
|
||||
// 可选属性
|
||||
#[serde(rename = "@friction")]
|
||||
pub friction: Option<f64>,
|
||||
#[serde(rename = "@category")]
|
||||
pub category: Option<String>,
|
||||
#[serde(rename = "ignoreEditorIntersections")]
|
||||
#[serde(rename = "@ignoreEditorIntersections")]
|
||||
pub ignore_editor_intersections: Option<bool>,
|
||||
#[serde(rename = "disableEditorRotation")]
|
||||
#[serde(rename = "@disableEditorRotation")]
|
||||
pub disable_editor_rotation: Option<bool>,
|
||||
#[serde(rename = "canExplode")]
|
||||
#[serde(rename = "@canExplode")]
|
||||
pub can_explode: Option<bool>,
|
||||
#[serde(rename = "coverHeight")]
|
||||
#[serde(rename = "@coverHeight")]
|
||||
pub cover_height: Option<u32>,
|
||||
#[serde(rename = "sandboxOnly")]
|
||||
#[serde(rename = "@sandboxOnly")]
|
||||
pub sandbox_only: Option<bool>,
|
||||
#[serde(rename = "@drag")]
|
||||
pub drag: Option<f64>,
|
||||
#[serde(rename = "@hidden")]
|
||||
pub hidden: Option<bool>,
|
||||
#[serde(rename = "@buoyancy")]
|
||||
pub buoyancy: Option<f64>,
|
||||
// 通用属性子节点
|
||||
#[serde(rename = "Shape")]
|
||||
|
@ -1,15 +1,17 @@
|
||||
use std::fs;
|
||||
|
||||
use pyo3::prelude::*;
|
||||
use quick_xml::de::from_str;
|
||||
use quick_xml::se::to_string;
|
||||
// use quick_xml::Error as XmlError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
// use quick_xml::de::from_str;
|
||||
use serde_xml_rs::from_str;
|
||||
use serde_xml_rs::Error as XmlError;
|
||||
|
||||
use crate::data_type::sr1::{SR1PartData, SR1PartDataAttr, SR1Ship};
|
||||
use crate::data_type::sr1::{SR1PartDataTrait, SR1ShipTrait};
|
||||
use crate::data_type::IdType;
|
||||
|
||||
/// https://docs.rs/quick-xml/latest/quick_xml/de/index.html#basics
|
||||
/// using quick xml
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename = "Ship")]
|
||||
pub struct RawShip {
|
||||
@ -17,12 +19,13 @@ pub struct RawShip {
|
||||
pub parts: Parts,
|
||||
#[serde(rename = "Connections")]
|
||||
pub connects: Connections,
|
||||
#[serde(rename = "@version")]
|
||||
pub version: Option<i32>, // Option for https://github.com/shenjackyuanjie/Difficult-Rocket/issues/48
|
||||
// SR1 says version is also optional, let them happy
|
||||
// it's always 1
|
||||
#[serde(rename = "liftedOff")]
|
||||
#[serde(rename = "@liftedOff")]
|
||||
pub lift_off: i8,
|
||||
#[serde(rename = "touchingGround")]
|
||||
#[serde(rename = "@touchingGround")]
|
||||
pub touch_ground: Option<i8>, // Option for https://github.com/shenjackyuanjie/Difficult-Rocket/issues/49
|
||||
// SR1 says it's optional, let them happy
|
||||
// NOT always 0
|
||||
@ -50,47 +53,60 @@ pub struct Part {
|
||||
pub engine: Option<Engine>,
|
||||
#[serde(rename = "Pod")]
|
||||
pub pod: Option<Pod>,
|
||||
#[serde(rename = "partType")]
|
||||
#[serde(rename = "@partType")]
|
||||
pub part_type_id: String,
|
||||
#[serde(rename = "@id")]
|
||||
pub id: IdType,
|
||||
#[serde(rename = "@x")]
|
||||
pub x: f64,
|
||||
#[serde(rename = "@y")]
|
||||
pub y: f64,
|
||||
#[serde(rename = "editorAngle")]
|
||||
pub editor_angle: Option<i32>, // Option for https://github.com/shenjackyuanjie/Difficult-Rocket/issues/47
|
||||
// SR1 says it's optional, let them happy
|
||||
/// Option for https://github.com/shenjackyuanjie/Difficult-Rocket/issues/47
|
||||
/// SR1 says it's optional, let them happy
|
||||
#[serde(rename = "@editorAngle")]
|
||||
pub editor_angle: Option<i32>,
|
||||
#[serde(rename = "@angle")]
|
||||
pub angle: f64,
|
||||
#[serde(rename = "angleV")]
|
||||
#[serde(rename = "@angleV")]
|
||||
pub angle_v: f64,
|
||||
#[serde(rename = "flippedX")]
|
||||
#[serde(rename = "@flippedX")]
|
||||
pub flip_x: Option<i8>,
|
||||
#[serde(rename = "flippedY")]
|
||||
#[serde(rename = "@flippedY")]
|
||||
pub flip_y: Option<i8>,
|
||||
// 降落伞
|
||||
#[serde(rename = "chuteX")]
|
||||
#[serde(rename = "@chuteX")]
|
||||
pub chute_x: Option<f64>,
|
||||
#[serde(rename = "chuteY")]
|
||||
#[serde(rename = "@chuteY")]
|
||||
pub chute_y: Option<f64>,
|
||||
#[serde(rename = "chuteAngle")]
|
||||
#[serde(rename = "@chuteAngle")]
|
||||
pub chute_angle: Option<f64>,
|
||||
#[serde(rename = "chuteHeight")]
|
||||
#[serde(rename = "@chuteHeight")]
|
||||
pub chute_height: Option<f64>,
|
||||
#[serde(rename = "@extension")]
|
||||
pub extension: Option<f64>,
|
||||
#[serde(rename = "@inflation")]
|
||||
pub inflate: Option<i8>,
|
||||
#[serde(rename = "@inflationTarget")]
|
||||
pub inflation: Option<f64>,
|
||||
#[serde(rename = "@deployed")]
|
||||
pub exploded: Option<i8>,
|
||||
#[serde(rename = "@rope")]
|
||||
pub rope: Option<i8>,
|
||||
// ?
|
||||
#[serde(rename = "@activated")]
|
||||
pub activated: Option<i8>,
|
||||
#[serde(rename = "@deployed")]
|
||||
pub deployed: Option<i8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Engine {
|
||||
#[serde(rename = "@fuel")]
|
||||
pub fuel: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Tank {
|
||||
#[serde(rename = "@fuel")]
|
||||
pub fuel: f64,
|
||||
}
|
||||
|
||||
@ -98,13 +114,15 @@ pub struct Tank {
|
||||
pub struct Pod {
|
||||
#[serde(rename = "Staging")]
|
||||
pub stages: Staging,
|
||||
#[serde(rename = "@name")]
|
||||
pub name: String,
|
||||
#[serde(rename = "@throttle")]
|
||||
pub throttle: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Staging {
|
||||
#[serde(rename = "currentStage")]
|
||||
#[serde(rename = "@currentStage")]
|
||||
pub current_stage: i32,
|
||||
#[serde(rename = "Step")]
|
||||
pub steps: Option<Vec<Step>>,
|
||||
@ -119,8 +137,9 @@ pub struct Step {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename = "Activate")]
|
||||
pub struct Activate {
|
||||
#[serde(rename = "Id")]
|
||||
#[serde(rename = "@Id")]
|
||||
pub id: IdType,
|
||||
#[serde(rename = "@moved")]
|
||||
pub moved: i8, // 1 or 0
|
||||
}
|
||||
|
||||
@ -140,13 +159,13 @@ pub struct DisconnectedPart {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Connection {
|
||||
#[serde(rename = "parentAttachPoint")]
|
||||
#[serde(rename = "@parentAttachPoint")]
|
||||
pub parent_attach_point: i32,
|
||||
#[serde(rename = "childAttachPoint")]
|
||||
#[serde(rename = "@childAttachPoint")]
|
||||
pub child_attach_point: i32,
|
||||
#[serde(rename = "parentPart")]
|
||||
#[serde(rename = "@parentPart")]
|
||||
pub parent_part: IdType,
|
||||
#[serde(rename = "childPart")]
|
||||
#[serde(rename = "@childPart")]
|
||||
pub child_part: IdType,
|
||||
}
|
||||
|
||||
@ -236,20 +255,21 @@ impl RawShip {
|
||||
Ok(ship) => Some(ship),
|
||||
Err(e) => {
|
||||
println!("ERROR!\n{:?}\n----------", e);
|
||||
match e {
|
||||
XmlError::ParseIntError { source } => {
|
||||
println!("ParseIntError: {:?}", source.kind());
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
// match e {
|
||||
// XmlError::ParseIntError { source } => {
|
||||
// println!("ParseIntError: {:?}", source.kind());
|
||||
// None
|
||||
// }
|
||||
// _ => None,
|
||||
// }
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn save(&self, file_name: String) -> Option<()> {
|
||||
let part_list_file = serde_xml_rs::to_string(self);
|
||||
let part_list_file = to_string(self);
|
||||
print!("{:?}", part_list_file);
|
||||
if let Ok(part_list_file) = part_list_file {
|
||||
fs::write(file_name, part_list_file).unwrap();
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
import time
|
||||
import random
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from pathlib import Path
|
||||
@ -32,6 +31,8 @@ from Difficult_Rocket.client.screen import BaseScreen
|
||||
from Difficult_Rocket.api.camera import CenterGroupCamera
|
||||
from Difficult_Rocket.api.gui.widget import PressTextButton
|
||||
|
||||
from lib_not_dr import loggers
|
||||
|
||||
if DR_mod_runtime.use_DR_rust:
|
||||
from .Difficult_Rocket_rs import (
|
||||
SR1PartList_rs,
|
||||
@ -40,8 +41,10 @@ if DR_mod_runtime.use_DR_rust:
|
||||
SR1PartType_rs,
|
||||
)
|
||||
|
||||
logger = logging.getLogger("client.dr_game_sr1_ship")
|
||||
logger.level = logging.DEBUG
|
||||
|
||||
logger = loggers.get_logger("client.dr_game_sr1_ship")
|
||||
# logger = logging.getLogger("client.dr_game_sr1_ship")
|
||||
# logger.level = logging.DEBUG
|
||||
sr_tr = Tr(lang_path=Path(__file__).parent / "lang")
|
||||
|
||||
|
||||
@ -578,14 +581,17 @@ class SR1ShipRender(BaseScreen):
|
||||
|
||||
img.save(f"test{time.time()}.png", "PNG")
|
||||
|
||||
elif command.find("test"):
|
||||
if command.find("save"):
|
||||
if not self.status.draw_done:
|
||||
return
|
||||
if not DR_mod_runtime.use_DR_rust:
|
||||
return
|
||||
logger.info(sr_tr().sr1.ship.save.start().format(self.rust_ship))
|
||||
self.rust_ship.save("./test-save.xml")
|
||||
elif command.find("save"):
|
||||
print("应该保存飞船的")
|
||||
# if command.find("save"):
|
||||
if not self.status.draw_done:
|
||||
logger.warn('not draw done', tag='save ship')
|
||||
return
|
||||
if not DR_mod_runtime.use_DR_rust:
|
||||
return
|
||||
print('saving')
|
||||
logger.info(sr_tr().sr1.ship.save.start().format(self.rust_ship))
|
||||
self.rust_ship.save("./test-save.xml")
|
||||
|
||||
def on_mouse_drag(
|
||||
self,
|
||||
|
@ -1,31 +0,0 @@
|
||||
Set-Location .\mods\dr_game\Difficult_Rocket_rs\src
|
||||
|
||||
Write-Output $args[0]
|
||||
|
||||
$do = 0
|
||||
|
||||
if ("38" -notin $args -and "39" -notin $args -and "310" -notin $args -and "311" -notin $args -and "312" -notin $args) {
|
||||
$do = 1
|
||||
}
|
||||
|
||||
cargo fmt
|
||||
|
||||
if ($do -or "38" -in $args) {
|
||||
python3.8 setup.py build
|
||||
}
|
||||
if ($do -or "39" -in $args) {
|
||||
python3.9 setup.py build
|
||||
}
|
||||
if ($do -or "310" -in $args) {
|
||||
python3.10 setup.py build
|
||||
}
|
||||
if ($do -or "311" -in $args) {
|
||||
python3.11 setup.py build
|
||||
}
|
||||
if ($do -or "312" -in $args) {
|
||||
python3.12 setup.py build
|
||||
}
|
||||
|
||||
python3.8 post_build.py
|
||||
|
||||
Set-Location ..\..\..\..\
|
31
scripts/compile_mod.py
Normal file
31
scripts/compile_mod.py
Normal file
@ -0,0 +1,31 @@
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
# script -py <py_version> (3.8 ~ 3.12)
|
||||
parser.add_argument('-py', type=str, help='python version')
|
||||
parser.add_argument('-all', help='用所有的python版本编译', action='store_true')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# 移动到项目根目录
|
||||
os.chdir('./mods/dr_game/Difficult_Rocket_rs/src')
|
||||
|
||||
if not args.py:
|
||||
if args.all:
|
||||
all_version = ('38', '39', '310', '311', '312')
|
||||
for py_version in all_version:
|
||||
try:
|
||||
subprocess.run([f'python{py_version}', 'setup.py', 'build'])
|
||||
except FileNotFoundError:
|
||||
print(f'python{py_version} not found')
|
||||
else:
|
||||
subprocess.run([sys.executable, 'setup.py', 'build'])
|
||||
else:
|
||||
subprocess.run([args.py, 'setup.py', 'build'])
|
||||
|
||||
# post
|
||||
subprocess.run([sys.executable, 'post_build.py'])
|
Loading…
Reference in New Issue
Block a user