fix #21 also
This commit is contained in:
parent
0d38df6ec9
commit
2577b91741
@ -7,7 +7,7 @@ fonts_folder = "libs/fonts"
|
||||
|
||||
[window]
|
||||
style = "None"
|
||||
width = 1683
|
||||
width = 1311
|
||||
height = 1474
|
||||
visible = true
|
||||
gui_scale = 1
|
||||
|
@ -18,10 +18,19 @@
|
||||
- 基于 `PyConsole`
|
||||
- 用于替换 `DR sdk` 的默认控制台方法
|
||||
|
||||
## DR rs 0.2.9.2
|
||||
## DR rs 0.2.9.3
|
||||
|
||||
### `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 修复
|
||||
|
||||
- [#20](https://github.com/shenjackyuanjie/Difficult-Rocket/issues/20) `<DisconnectedParts/>`
|
||||
|
@ -12,10 +12,9 @@ pub mod part_list {
|
||||
use pyo3::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
// use quick_xml::de::from_str;
|
||||
use serde_xml_rs::from_str;
|
||||
|
||||
use crate::types::sr1::{SR1PartList, SR1PartType, SR1PartTypeAttr};
|
||||
use crate::types::sr1::{SR1PartListTrait, SR1PartTypeData};
|
||||
use serde_xml_rs::from_str;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct RawPartList {
|
||||
@ -377,6 +376,7 @@ pub mod ship {
|
||||
use serde::{Deserialize, Serialize};
|
||||
// use quick_xml::de::from_str;
|
||||
use serde_xml_rs::from_str;
|
||||
use serde_xml_rs::Error as XmlError;
|
||||
|
||||
use super::part_list::SR1PartTypeEnum;
|
||||
|
||||
@ -444,7 +444,7 @@ pub mod ship {
|
||||
pub chute_height: Option<f64>,
|
||||
pub extension: Option<f64>,
|
||||
pub inflate: Option<i8>,
|
||||
pub inflation: Option<i8>,
|
||||
pub inflation: Option<f64>,
|
||||
pub exploded: Option<i8>,
|
||||
pub rope: Option<i8>,
|
||||
// ?
|
||||
@ -473,7 +473,7 @@ pub mod ship {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Staging {
|
||||
#[serde(rename = "currentStage")]
|
||||
pub current_stage: u32,
|
||||
pub current_stage: i32,
|
||||
#[serde(rename = "Step")]
|
||||
pub steps: Vec<Step>,
|
||||
}
|
||||
@ -481,7 +481,7 @@ pub mod ship {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Step {
|
||||
#[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)]
|
||||
@ -595,8 +595,20 @@ pub mod ship {
|
||||
#[inline]
|
||||
pub fn from_file(path: String) -> Option<RawShip> {
|
||||
let ship_file = fs::read_to_string(path).unwrap();
|
||||
let ship: RawShip = from_str(&ship_file).unwrap();
|
||||
Some(ship)
|
||||
let ship = from_str(&ship_file);
|
||||
match ship {
|
||||
Ok(ship) => Some(ship),
|
||||
Err(e) => {
|
||||
println!("ERROR!\n{:?}\n----------", e);
|
||||
match e {
|
||||
XmlError::ParseIntError { source } => {
|
||||
println!("ParseIntError: {:?}", source.kind());
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ pub mod sr1 {
|
||||
moved: bool_to_i8(active.1.to_owned()),
|
||||
});
|
||||
}
|
||||
actives.push(RawStep { activates: steps_ });
|
||||
actives.push(RawStep { activates: Some(steps_) });
|
||||
}
|
||||
let stages = RawStaging {
|
||||
current_stage: current_stage.to_owned(),
|
||||
@ -466,7 +466,7 @@ pub mod sr1 {
|
||||
chute_height: self.attr.chute_height,
|
||||
extension: self.attr.extension,
|
||||
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)),
|
||||
rope: option_bool_to_option_i8(self.attr.rope),
|
||||
chute_angle: self.attr.chute_angle,
|
||||
@ -530,7 +530,7 @@ pub mod sr1 {
|
||||
// Pod
|
||||
pub name: Option<String>,
|
||||
pub throttle: Option<f64>,
|
||||
pub current_stage: Option<u32>,
|
||||
pub current_stage: Option<i32>,
|
||||
pub steps: Option<Vec<Vec<(i64, bool)>>>,
|
||||
// Solar
|
||||
pub extension: Option<f64>,
|
||||
@ -540,7 +540,7 @@ pub mod sr1 {
|
||||
pub chute_height: Option<f64>,
|
||||
pub chute_angle: Option<f64>,
|
||||
pub inflate: Option<bool>,
|
||||
pub inflation: Option<bool>,
|
||||
pub inflation: Option<f64>,
|
||||
pub deployed: Option<bool>,
|
||||
pub rope: Option<bool>,
|
||||
// part_type
|
||||
@ -581,7 +581,7 @@ pub mod sr1 {
|
||||
fuel: Option<f64>,
|
||||
name: Option<String>,
|
||||
throttle: Option<f64>,
|
||||
current_stage: Option<u32>,
|
||||
current_stage: Option<i32>,
|
||||
steps: Option<Vec<Vec<(i64, bool)>>>,
|
||||
extension: Option<f64>,
|
||||
chute_x: Option<f64>,
|
||||
@ -589,7 +589,7 @@ pub mod sr1 {
|
||||
chute_height: Option<f64>,
|
||||
chute_angle: Option<f64>,
|
||||
inflate: Option<bool>,
|
||||
inflation: Option<bool>,
|
||||
inflation: Option<f64>,
|
||||
deployed: Option<bool>,
|
||||
rope: Option<bool>,
|
||||
part_type: Option<SR1PartTypeEnum>,
|
||||
@ -630,8 +630,10 @@ pub mod sr1 {
|
||||
let mut steps = Vec::new();
|
||||
for step in &pod.stages.steps {
|
||||
let mut step_vec = Vec::new();
|
||||
for act in &step.activates {
|
||||
step_vec.push((act.id, i8_to_bool(act.moved)));
|
||||
if let Some(active) = &step.activates {
|
||||
for act in active {
|
||||
step_vec.push((act.id, i8_to_bool(act.moved)));
|
||||
}
|
||||
}
|
||||
steps.push(step_vec);
|
||||
}
|
||||
@ -653,7 +655,7 @@ pub mod sr1 {
|
||||
chute_height: raw_data.chute_height,
|
||||
chute_angle: raw_data.chute_angle,
|
||||
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),
|
||||
rope: option_i8_to_option_bool(raw_data.rope),
|
||||
part_type: Cell::new(part_type),
|
||||
|
@ -385,7 +385,6 @@ class SR1ShipRender(BaseScreen):
|
||||
img_center = (abs(img_box[0]), abs(img_box[3]))
|
||||
print(f"img_box: {img_box} img_size: {img_size} img_center: {img_center}")
|
||||
try:
|
||||
from pyglet.image.codecs.pil import PILImageEncoder
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
traceback.print_exc()
|
||||
|
Loading…
Reference in New Issue
Block a user