This commit is contained in:
shenjack 2023-05-27 00:12:24 +08:00
parent 0d38df6ec9
commit 2577b91741
5 changed files with 41 additions and 19 deletions

View File

@ -7,7 +7,7 @@ fonts_folder = "libs/fonts"
[window] [window]
style = "None" style = "None"
width = 1683 width = 1311
height = 1474 height = 1474
visible = true visible = true
gui_scale = 1 gui_scale = 1

View File

@ -18,10 +18,19 @@
- 基于 `PyConsole` - 基于 `PyConsole`
- 用于替换 `DR sdk` 的默认控制台方法 - 用于替换 `DR sdk` 的默认控制台方法
## DR rs 0.2.9.2 ## DR rs 0.2.9.3
### `sr1_data` ### `sr1_data`
- `inflation`
- `Option<bool>` -> `Option<f64>`
### Bug 修复
- [#21](https://github.com/shenjackyuanjie/Difficult-Rocket/issues/21) `field: "missing field Activate"`
## DR rs 0.2.9.2
### Bug 修复 ### Bug 修复
- [#20](https://github.com/shenjackyuanjie/Difficult-Rocket/issues/20) `<DisconnectedParts/>` - [#20](https://github.com/shenjackyuanjie/Difficult-Rocket/issues/20) `<DisconnectedParts/>`

View File

@ -12,10 +12,9 @@ pub mod part_list {
use pyo3::prelude::*; use pyo3::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
// use quick_xml::de::from_str; // use quick_xml::de::from_str;
use serde_xml_rs::from_str;
use crate::types::sr1::{SR1PartList, SR1PartType, SR1PartTypeAttr}; use crate::types::sr1::{SR1PartList, SR1PartType, SR1PartTypeAttr};
use crate::types::sr1::{SR1PartListTrait, SR1PartTypeData}; use crate::types::sr1::{SR1PartListTrait, SR1PartTypeData};
use serde_xml_rs::from_str;
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
pub struct RawPartList { pub struct RawPartList {
@ -377,6 +376,7 @@ pub mod ship {
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
// use quick_xml::de::from_str; // use quick_xml::de::from_str;
use serde_xml_rs::from_str; use serde_xml_rs::from_str;
use serde_xml_rs::Error as XmlError;
use super::part_list::SR1PartTypeEnum; use super::part_list::SR1PartTypeEnum;
@ -444,7 +444,7 @@ pub mod ship {
pub chute_height: Option<f64>, pub chute_height: Option<f64>,
pub extension: Option<f64>, pub extension: Option<f64>,
pub inflate: Option<i8>, pub inflate: Option<i8>,
pub inflation: Option<i8>, pub inflation: Option<f64>,
pub exploded: Option<i8>, pub exploded: Option<i8>,
pub rope: Option<i8>, pub rope: Option<i8>,
// ? // ?
@ -473,7 +473,7 @@ pub mod ship {
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Staging { pub struct Staging {
#[serde(rename = "currentStage")] #[serde(rename = "currentStage")]
pub current_stage: u32, pub current_stage: i32,
#[serde(rename = "Step")] #[serde(rename = "Step")]
pub steps: Vec<Step>, pub steps: Vec<Step>,
} }
@ -481,7 +481,7 @@ pub mod ship {
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Step { pub struct Step {
#[serde(rename = "Activate")] #[serde(rename = "Activate")]
pub activates: Vec<Activate>, pub activates: Option<Vec<Activate>>, // Option for https://github.com/shenjackyuanjie/Difficult-Rocket/issues/21
} }
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
@ -595,8 +595,20 @@ pub mod ship {
#[inline] #[inline]
pub fn from_file(path: String) -> Option<RawShip> { pub fn from_file(path: String) -> Option<RawShip> {
let ship_file = fs::read_to_string(path).unwrap(); let ship_file = fs::read_to_string(path).unwrap();
let ship: RawShip = from_str(&ship_file).unwrap(); let ship = from_str(&ship_file);
Some(ship) match ship {
Ok(ship) => Some(ship),
Err(e) => {
println!("ERROR!\n{:?}\n----------", e);
match e {
XmlError::ParseIntError { source } => {
println!("ParseIntError: {:?}", source.kind());
None
}
_ => None,
}
}
}
} }
} }

View File

@ -434,7 +434,7 @@ pub mod sr1 {
moved: bool_to_i8(active.1.to_owned()), moved: bool_to_i8(active.1.to_owned()),
}); });
} }
actives.push(RawStep { activates: steps_ }); actives.push(RawStep { activates: Some(steps_) });
} }
let stages = RawStaging { let stages = RawStaging {
current_stage: current_stage.to_owned(), current_stage: current_stage.to_owned(),
@ -466,7 +466,7 @@ pub mod sr1 {
chute_height: self.attr.chute_height, chute_height: self.attr.chute_height,
extension: self.attr.extension, extension: self.attr.extension,
inflate: option_bool_to_option_i8(self.attr.inflate), inflate: option_bool_to_option_i8(self.attr.inflate),
inflation: option_bool_to_option_i8(self.attr.inflation), inflation: self.attr.inflation,
exploded: Some(bool_to_i8(self.explode)), exploded: Some(bool_to_i8(self.explode)),
rope: option_bool_to_option_i8(self.attr.rope), rope: option_bool_to_option_i8(self.attr.rope),
chute_angle: self.attr.chute_angle, chute_angle: self.attr.chute_angle,
@ -530,7 +530,7 @@ pub mod sr1 {
// Pod // Pod
pub name: Option<String>, pub name: Option<String>,
pub throttle: Option<f64>, pub throttle: Option<f64>,
pub current_stage: Option<u32>, pub current_stage: Option<i32>,
pub steps: Option<Vec<Vec<(i64, bool)>>>, pub steps: Option<Vec<Vec<(i64, bool)>>>,
// Solar // Solar
pub extension: Option<f64>, pub extension: Option<f64>,
@ -540,7 +540,7 @@ pub mod sr1 {
pub chute_height: Option<f64>, pub chute_height: Option<f64>,
pub chute_angle: Option<f64>, pub chute_angle: Option<f64>,
pub inflate: Option<bool>, pub inflate: Option<bool>,
pub inflation: Option<bool>, pub inflation: Option<f64>,
pub deployed: Option<bool>, pub deployed: Option<bool>,
pub rope: Option<bool>, pub rope: Option<bool>,
// part_type // part_type
@ -581,7 +581,7 @@ pub mod sr1 {
fuel: Option<f64>, fuel: Option<f64>,
name: Option<String>, name: Option<String>,
throttle: Option<f64>, throttle: Option<f64>,
current_stage: Option<u32>, current_stage: Option<i32>,
steps: Option<Vec<Vec<(i64, bool)>>>, steps: Option<Vec<Vec<(i64, bool)>>>,
extension: Option<f64>, extension: Option<f64>,
chute_x: Option<f64>, chute_x: Option<f64>,
@ -589,7 +589,7 @@ pub mod sr1 {
chute_height: Option<f64>, chute_height: Option<f64>,
chute_angle: Option<f64>, chute_angle: Option<f64>,
inflate: Option<bool>, inflate: Option<bool>,
inflation: Option<bool>, inflation: Option<f64>,
deployed: Option<bool>, deployed: Option<bool>,
rope: Option<bool>, rope: Option<bool>,
part_type: Option<SR1PartTypeEnum>, part_type: Option<SR1PartTypeEnum>,
@ -630,9 +630,11 @@ pub mod sr1 {
let mut steps = Vec::new(); let mut steps = Vec::new();
for step in &pod.stages.steps { for step in &pod.stages.steps {
let mut step_vec = Vec::new(); let mut step_vec = Vec::new();
for act in &step.activates { if let Some(active) = &step.activates {
for act in active {
step_vec.push((act.id, i8_to_bool(act.moved))); step_vec.push((act.id, i8_to_bool(act.moved)));
} }
}
steps.push(step_vec); steps.push(step_vec);
} }
steps steps
@ -653,7 +655,7 @@ pub mod sr1 {
chute_height: raw_data.chute_height, chute_height: raw_data.chute_height,
chute_angle: raw_data.chute_angle, chute_angle: raw_data.chute_angle,
inflate: option_i8_to_option_bool(raw_data.inflate), inflate: option_i8_to_option_bool(raw_data.inflate),
inflation: option_i8_to_option_bool(raw_data.inflation), inflation: raw_data.inflation,
deployed: option_i8_to_option_bool(raw_data.deployed), deployed: option_i8_to_option_bool(raw_data.deployed),
rope: option_i8_to_option_bool(raw_data.rope), rope: option_i8_to_option_bool(raw_data.rope),
part_type: Cell::new(part_type), part_type: Cell::new(part_type),

View File

@ -385,7 +385,6 @@ class SR1ShipRender(BaseScreen):
img_center = (abs(img_box[0]), abs(img_box[3])) img_center = (abs(img_box[0]), abs(img_box[3]))
print(f"img_box: {img_box} img_size: {img_size} img_center: {img_center}") print(f"img_box: {img_box} img_size: {img_size} img_center: {img_center}")
try: try:
from pyglet.image.codecs.pil import PILImageEncoder
from PIL import Image from PIL import Image
except ImportError: except ImportError:
traceback.print_exc() traceback.print_exc()