更新 DR_rs
This commit is contained in:
parent
f63562eaf7
commit
a48a5ddec4
@ -24,7 +24,7 @@ from libs.MCDR.version import Version
|
|||||||
|
|
||||||
game_version = Version("0.7.0.2") # 游戏版本
|
game_version = Version("0.7.0.2") # 游戏版本
|
||||||
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
|
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
|
||||||
DR_rust_version = Version("0.1.9.0") # DR 的 Rust 编写部分的版本
|
DR_rust_version = Version("0.1.10.0") # DR 的 Rust 编写部分的版本
|
||||||
__version__ = game_version
|
__version__ = game_version
|
||||||
|
|
||||||
long_version: int = 12
|
long_version: int = 12
|
||||||
|
@ -21,7 +21,7 @@ class SR1PartData:
|
|||||||
x: float
|
x: float
|
||||||
y: float
|
y: float
|
||||||
id: int
|
id: int
|
||||||
type_: str
|
p_type: str
|
||||||
active: bool
|
active: bool
|
||||||
angle: float
|
angle: float
|
||||||
angle_v: float
|
angle_v: float
|
||||||
|
@ -80,8 +80,7 @@ class Options:
|
|||||||
""" 如果子类定义了这个函数,则会在 __init__ 之后调用这个函数 """
|
""" 如果子类定义了这个函数,则会在 __init__ 之后调用这个函数 """
|
||||||
|
|
||||||
def load_file(self) -> bool:
|
def load_file(self) -> bool:
|
||||||
"""
|
"""如果子类定义了这个函数,则会在 __init__ 和 init 之后再调用这个函数
|
||||||
如果子类定义了这个函数,则会在 __init__ 和 init 之后再调用这个函数
|
|
||||||
|
|
||||||
请注意,这个函数请尽量使用 try 包裹住可能出现错误的部分
|
请注意,这个函数请尽量使用 try 包裹住可能出现错误的部分
|
||||||
否则会在控制台输出你的报错"""
|
否则会在控制台输出你的报错"""
|
||||||
|
@ -198,7 +198,7 @@ class ClientWindow(Window):
|
|||||||
self.screen_list: List[BaseScreen]
|
self.screen_list: List[BaseScreen]
|
||||||
self.screen_list.append(DRDEBUGScreen(self))
|
self.screen_list.append(DRDEBUGScreen(self))
|
||||||
self.screen_list.append(DRScreen(self))
|
self.screen_list.append(DRScreen(self))
|
||||||
self.screen_list.append(SR1ShipRender(self, DR_option.gui_scale))
|
self.screen_list.append(SR1ShipRender(self))
|
||||||
|
|
||||||
def load_fonts(self) -> None:
|
def load_fonts(self) -> None:
|
||||||
fonts_folder_path = self.main_config['runtime']['fonts_folder']
|
fonts_folder_path = self.main_config['runtime']['fonts_folder']
|
||||||
|
@ -56,7 +56,7 @@ def get_sr1_part(part_xml: Element) -> Optional[SR1PartData]:
|
|||||||
# f'angle: {part_angle} angle_v: {part_angle_v} editor_angle: {part_editor_angle} '
|
# f'angle: {part_angle} angle_v: {part_angle_v} editor_angle: {part_editor_angle} '
|
||||||
# f'flip_x: {part_flip_x} flip_y: {part_flip_y} explode: {part_explode} '
|
# f'flip_x: {part_flip_x} flip_y: {part_flip_y} explode: {part_explode} '
|
||||||
# f'textures: {SR1PartTexture.get_textures_from_type(part_type)}')
|
# f'textures: {SR1PartTexture.get_textures_from_type(part_type)}')
|
||||||
return SR1PartData(x=part_x, y=part_y, id=part_id, type_=part_type,
|
return SR1PartData(x=part_x, y=part_y, id=part_id, p_type=part_type,
|
||||||
active=part_activate, angle=part_angle, angle_v=part_angle_v,
|
active=part_activate, angle=part_angle, angle_v=part_angle_v,
|
||||||
editor_angle=part_editor_angle, flip_x=part_flip_x,
|
editor_angle=part_editor_angle, flip_x=part_flip_x,
|
||||||
flip_y=part_flip_y, explode=part_explode, textures=part_textures)
|
flip_y=part_flip_y, explode=part_explode, textures=part_textures)
|
||||||
@ -76,11 +76,9 @@ class SR1ShipRender(BaseScreen):
|
|||||||
"""用于渲染 sr1 船的类"""
|
"""用于渲染 sr1 船的类"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
main_window: "ClientWindow",
|
main_window: "ClientWindow"):
|
||||||
scale: float):
|
|
||||||
super().__init__(main_window)
|
super().__init__(main_window)
|
||||||
self.rendered = False
|
self.rendered = False
|
||||||
self.scale = scale
|
|
||||||
self.focus = True
|
self.focus = True
|
||||||
self.need_draw = False
|
self.need_draw = False
|
||||||
self.drawing = False
|
self.drawing = False
|
||||||
@ -155,7 +153,6 @@ class SR1ShipRender(BaseScreen):
|
|||||||
cache_sprite.scale_x = -1 # 就是直接取反缩放,应该没问题····吧?(待会试试就知道了
|
cache_sprite.scale_x = -1 # 就是直接取反缩放,应该没问题····吧?(待会试试就知道了
|
||||||
if part.flip_y:
|
if part.flip_y:
|
||||||
cache_sprite.scale_y = -1
|
cache_sprite.scale_y = -1
|
||||||
cache_sprite.scale = self.scale * DR_option.gui_scale
|
|
||||||
cache_sprite.x = cache_sprite.x - cache_sprite.scale_x / 2
|
cache_sprite.x = cache_sprite.x - cache_sprite.scale_x / 2
|
||||||
cache_sprite.y = cache_sprite.y - cache_sprite.scale_y / 2
|
cache_sprite.y = cache_sprite.y - cache_sprite.scale_y / 2
|
||||||
self.parts_sprite[part.id] = cache_sprite
|
self.parts_sprite[part.id] = cache_sprite
|
||||||
@ -269,7 +266,6 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.debug_mouse_label.position = x, y + 10, 0
|
self.debug_mouse_label.position = x, y + 10, 0
|
||||||
self.need_update_parts = True
|
self.need_update_parts = True
|
||||||
# self.update_parts()
|
# self.update_parts()
|
||||||
# print(f'{self.scale=} {self.dx=} {self.dy=} {x=} {y=} {scroll_x=} {scroll_y=} {1 - (0.5 ** scroll_y)=}')
|
|
||||||
|
|
||||||
def on_command(self, command: CommandText):
|
def on_command(self, command: CommandText):
|
||||||
if command.re_match('render'):
|
if command.re_match('render'):
|
||||||
|
23
build_rs.ps1
23
build_rs.ps1
@ -1,8 +1,25 @@
|
|||||||
Set-Location .\libs\Difficult_Rocket_rs\src
|
Set-Location .\libs\Difficult_Rocket_rs\src
|
||||||
|
|
||||||
python3.8 setup.py build
|
Write-Output $args[0]
|
||||||
python3.9 setup.py build
|
|
||||||
python3.11 setup.py build
|
$do = 0
|
||||||
|
|
||||||
|
if ("38" -notin $args -and "39" -notin $args -and "310" -notin $args -and "311" -notin $args) {
|
||||||
|
$do = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
python3.8 after_build.py
|
python3.8 after_build.py
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ fonts_folder = "libs/fonts"
|
|||||||
|
|
||||||
[window]
|
[window]
|
||||||
style = "None"
|
style = "None"
|
||||||
width = 928
|
width = 1242
|
||||||
height = 1532
|
height = 884
|
||||||
visible = true
|
visible = true
|
||||||
gui_scale = 1
|
gui_scale = 1
|
||||||
caption = "Difficult Rocket v{DR_version}|DR_rs v{DR_Rust_get_version}"
|
caption = "Difficult Rocket v{DR_version}|DR_rs v{DR_Rust_get_version}"
|
||||||
|
@ -24,6 +24,16 @@
|
|||||||
- `get_buf`
|
- `get_buf`
|
||||||
- 用于截屏 并将文件保存至根目录下面的 `test.png`
|
- 用于截屏 并将文件保存至根目录下面的 `test.png`
|
||||||
|
|
||||||
|
### 更新
|
||||||
|
|
||||||
|
- 更改了 `ClientWindow` 启动参数的设置, 实装 ClientOption 的使用
|
||||||
|
- 将 `SR1PartData` 的字段 `type_` 重命名为 `p_type`
|
||||||
|
|
||||||
|
### `DR_Rs`
|
||||||
|
|
||||||
|
- 移动了 `SR1PartData` 的位置
|
||||||
|
- 为 `SR1PartData` 添加了 `connections: Option<Vec<(usize, usize)>>` 的字段
|
||||||
|
|
||||||
## 20230207 V 0.7.0.2
|
## 20230207 V 0.7.0.2
|
||||||
|
|
||||||
淦, 忘记步进版本号了(
|
淦, 忘记步进版本号了(
|
||||||
|
51
libs/Difficult_Rocket_rs/src/Cargo.lock
generated
51
libs/Difficult_Rocket_rs/src/Cargo.lock
generated
@ -22,16 +22,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "difficult_rocket_rs"
|
name = "difficult_rocket_rs"
|
||||||
version = "0.1.6"
|
version = "0.1.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pyo3",
|
"pyo3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indoc"
|
name = "indoc"
|
||||||
version = "1.0.8"
|
version = "1.0.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da2d6f23ffea9d7e76c53eee25dfb67bcd8fde7f1198b0855350698c9f07c780"
|
checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
@ -76,9 +76,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot_core"
|
name = "parking_lot_core"
|
||||||
version = "0.9.6"
|
version = "0.9.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf"
|
checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
@ -89,18 +89,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.50"
|
version = "1.0.51"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
|
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyo3"
|
name = "pyo3"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ccd4149c8c3975099622b4e1962dac27565cf5663b76452c3e2b66e0b6824277"
|
checksum = "06a3d8e8a46ab2738109347433cb7b96dffda2e4a218b03ef27090238886b147"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"indoc",
|
"indoc",
|
||||||
@ -115,9 +115,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyo3-build-config"
|
name = "pyo3-build-config"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9cd09fe469834db21ee60e0051030339e5d361293d8cb5ec02facf7fdcf52dbf"
|
checksum = "75439f995d07ddfad42b192dfcf3bc66a7ecfd8b4a1f5f6f046aa5c2c5d7677d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
@ -125,9 +125,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyo3-ffi"
|
name = "pyo3-ffi"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c427c9a96b9c5b12156dbc11f76b14f49e9aae8905ca783ea87c249044ef137"
|
checksum = "839526a5c07a17ff44823679b68add4a58004de00512a95b6c1c98a6dcac0ee5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"pyo3-build-config",
|
"pyo3-build-config",
|
||||||
@ -135,9 +135,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyo3-macros"
|
name = "pyo3-macros"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "16b822bbba9d60630a44d2109bc410489bb2f439b33e3a14ddeb8a40b378a7c4"
|
checksum = "bd44cf207476c6a9760c4653559be4f206efafb924d3e4cbf2721475fc0d6cc5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"pyo3-macros-backend",
|
"pyo3-macros-backend",
|
||||||
@ -147,9 +147,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyo3-macros-backend"
|
name = "pyo3-macros-backend"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "84ae898104f7c99db06231160770f3e40dad6eb9021daddc0fedfa3e41dff10a"
|
checksum = "dc1f43d8e30460f36350d18631ccf85ded64c059829208fe680904c65bcd0a4c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -199,9 +199,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "target-lexicon"
|
name = "target-lexicon"
|
||||||
version = "0.12.5"
|
version = "0.12.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d"
|
checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
@ -217,9 +217,18 @@ checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.42.0"
|
version = "0.45.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
|
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.42.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "difficult_rocket_rs"
|
name = "difficult_rocket_rs"
|
||||||
version = "0.1.6"
|
version = "0.1.10"
|
||||||
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,7 +14,7 @@ use pyo3::prelude::*;
|
|||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
fn get_version_str() -> String {
|
fn get_version_str() -> String {
|
||||||
return String::from("0.1.9.0");
|
return String::from("0.1.10.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
|
@ -11,7 +11,7 @@ use std::time;
|
|||||||
use pyo3::intern;
|
use pyo3::intern;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
// use pyo3::types::PyDict;
|
// use pyo3::types::PyDict;
|
||||||
use crate::sr1_render::types::SR1PartData;
|
use crate::types::sr1::SR1PartData;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub mod types {
|
pub mod types {
|
||||||
@ -20,21 +20,7 @@ pub mod types {
|
|||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::{PyDict};
|
use pyo3::types::{PyDict};
|
||||||
|
|
||||||
pub struct SR1PartData {
|
use crate::types::sr1::SR1PartData;
|
||||||
pub x: f64,
|
|
||||||
pub y: f64,
|
|
||||||
pub id: i64,
|
|
||||||
pub type_: String,
|
|
||||||
pub active: bool,
|
|
||||||
pub angle: f64,
|
|
||||||
pub angle_v: f64,
|
|
||||||
pub editor_angle: usize,
|
|
||||||
pub flip_x: bool,
|
|
||||||
pub flip_y: bool,
|
|
||||||
pub explode: bool,
|
|
||||||
pub textures: String,
|
|
||||||
// pub connections: Vec<usize>
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Point {
|
pub struct Point {
|
||||||
pub x: f64,
|
pub x: f64,
|
||||||
@ -65,12 +51,12 @@ pub mod types {
|
|||||||
|
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn part_data_to_SR1PartData(input: &PyAny) -> Result<SR1PartData, PyErr> {
|
pub fn part_data_to_SR1PartData(input: &PyAny) -> PyResult<SR1PartData> {
|
||||||
return Ok(SR1PartData{
|
return Ok(SR1PartData{
|
||||||
x: input.getattr(intern!(input.py(), "x"))?.extract()?,
|
x: input.getattr(intern!(input.py(), "x"))?.extract()?,
|
||||||
y: input.getattr(intern!(input.py(), "y"))?.extract()?,
|
y: input.getattr(intern!(input.py(), "y"))?.extract()?,
|
||||||
id: input.getattr(intern!(input.py(), "id"))?.extract()?,
|
id: input.getattr(intern!(input.py(), "id"))?.extract()?,
|
||||||
type_: input.getattr(intern!(input.py(), "type_"))?.extract()?,
|
p_type: input.getattr(intern!(input.py(), "p_type"))?.extract()?,
|
||||||
active: input.getattr(intern!(input.py(), "active"))?.extract()?,
|
active: input.getattr(intern!(input.py(), "active"))?.extract()?,
|
||||||
angle: input.getattr(intern!(input.py(), "angle"))?.extract()?,
|
angle: input.getattr(intern!(input.py(), "angle"))?.extract()?,
|
||||||
angle_v: input.getattr(intern!(input.py(), "angle_v"))?.extract()?,
|
angle_v: input.getattr(intern!(input.py(), "angle_v"))?.extract()?,
|
||||||
@ -79,12 +65,13 @@ pub mod types {
|
|||||||
flip_y: input.getattr(intern!(input.py(), "flip_y"))?.extract()?,
|
flip_y: input.getattr(intern!(input.py(), "flip_y"))?.extract()?,
|
||||||
explode: input.getattr(intern!(input.py(), "explode"))?.extract()?,
|
explode: input.getattr(intern!(input.py(), "explode"))?.extract()?,
|
||||||
textures: input.getattr(intern!(input.py(), "textures"))?.extract()?,
|
textures: input.getattr(intern!(input.py(), "textures"))?.extract()?,
|
||||||
|
connections: None
|
||||||
// connections: input.getattr(intern!(input.py(), "connections"))?.extract()?,
|
// connections: input.getattr(intern!(input.py(), "connections"))?.extract()?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn part_data_tp_SR1PartDatas(input: &PyDict) -> Result<HashMap<i64, SR1PartData>, PyErr> {
|
pub fn part_data_tp_SR1PartDatas(input: &PyDict) -> PyResult<HashMap<i64, SR1PartData>> {
|
||||||
let mut result: HashMap<i64, SR1PartData> = HashMap::with_capacity(input.len());
|
let mut result: HashMap<i64, SR1PartData> = HashMap::with_capacity(input.len());
|
||||||
for key in input.iter() {
|
for key in input.iter() {
|
||||||
result.insert(key.0.extract()?, part_data_to_SR1PartData(key.1)?);
|
result.insert(key.0.extract()?, part_data_to_SR1PartData(key.1)?);
|
||||||
@ -92,23 +79,6 @@ pub mod types {
|
|||||||
return Ok(result)
|
return Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn part_data_to_point(input: &PyAny) -> Result<Point, PyErr> {
|
|
||||||
return Ok(Point{
|
|
||||||
x: input.getattr(intern!(input.py(), "x"))?.extract()?,
|
|
||||||
y: input.getattr(intern!(input.py(), "y"))?.extract()?,
|
|
||||||
id: input.getattr(intern!(input.py(), "id"))?.extract()?,
|
|
||||||
type_: input.getattr(intern!(input.py(), "type_"))?.extract()?
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn part_datas_to_points(input: &PyDict) -> Result<HashMap<i64, Point>, PyErr> {
|
|
||||||
let mut result: HashMap<i64, Point> = HashMap::with_capacity(input.len());
|
|
||||||
for key in input.iter() {
|
|
||||||
result.insert(key.0.extract()?, part_data_to_point(key.1)?);
|
|
||||||
}
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,23 +97,15 @@ pub fn better_update_parts(render: &PyAny, option: &PyAny, window: &PyAny,
|
|||||||
let y_center: f32 = y_center / 2.0;
|
let y_center: f32 = y_center / 2.0;
|
||||||
let datas: &HashMap<i64, SR1PartData> = &parts.part_structs;
|
let datas: &HashMap<i64, SR1PartData> = &parts.part_structs;
|
||||||
let part_sprites = render.getattr(intern!(render.py(), "parts_sprite"))?;
|
let part_sprites = render.getattr(intern!(render.py(), "parts_sprite"))?;
|
||||||
// let part_sprites: &PyDict = part_sprites.downcast::<PyDict>()?;
|
|
||||||
let get_stuf_time = start_time.elapsed();
|
let get_stuf_time = start_time.elapsed();
|
||||||
// println!("get stuf took {} second", get_stuf_time.as_secs_f64());
|
|
||||||
|
|
||||||
for keys in datas {
|
for keys in datas {
|
||||||
// let index = keys.0.to_string();
|
|
||||||
let sprite = part_sprites.get_item(keys.0)?;
|
let sprite = part_sprites.get_item(keys.0)?;
|
||||||
let new_x: f64 = keys.1.x * sr1_xml_scale as f64 + x_center as f64;
|
let new_x: f64 = keys.1.x * sr1_xml_scale as f64 + x_center as f64;
|
||||||
let new_y: f64 = keys.1.y * sr1_xml_scale as f64 + y_center as f64;
|
let new_y: f64 = keys.1.y * sr1_xml_scale as f64 + y_center as f64;
|
||||||
sprite.setattr(intern!(sprite.py(), "x"), new_x)?;
|
sprite.setattr(intern!(sprite.py(), "x"), new_x)?;
|
||||||
sprite.setattr(intern!(sprite.py(), "y"), new_y)?;
|
sprite.setattr(intern!(sprite.py(), "y"), new_y)?;
|
||||||
// part_sprites.set_item(keys.0, sprite)?;
|
|
||||||
// println!("{}", keys.0);
|
|
||||||
}
|
}
|
||||||
let run_time = start_time.elapsed();
|
let run_time = start_time.elapsed();
|
||||||
// println!("run took {} second or {} fps", run_time.as_secs_f64(), 1 as f64 / run_time.as_secs_f64());
|
|
||||||
// render.setattr(intern!(render.py(), "parts_sprite"), part_sprites)?;
|
|
||||||
// println!("dx: {} dy: {} scale: {}", dx, dy, render_scale);
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
@ -6,10 +6,94 @@
|
|||||||
* -------------------------------
|
* -------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub mod sr1 {
|
pub mod sr1 {
|
||||||
pub mod data {
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
pub fn map_ptype_textures(ptype: String) -> String {
|
||||||
|
let mut value_map: HashMap<&str, &str> = HashMap::with_capacity(27 * 2);
|
||||||
|
value_map.insert("pod-1", "Pod");
|
||||||
|
value_map.insert("detacher-1", "DetacherVertical");
|
||||||
|
value_map.insert("detacher-2", "DetacherRadial");
|
||||||
|
value_map.insert("wheel-1", "Wheel");
|
||||||
|
value_map.insert("wheel-2", "Wheel");
|
||||||
|
value_map.insert("fuselage-1", "Fuselage");
|
||||||
|
value_map.insert("strut-1", "Beam");
|
||||||
|
value_map.insert("fueltank-0", "TankTiny");
|
||||||
|
value_map.insert("fueltank-1", "TankSmall");
|
||||||
|
value_map.insert("fueltank-2", "TankMedium");
|
||||||
|
value_map.insert("fueltank-3", "TankLarge");
|
||||||
|
value_map.insert("fueltank-4", "Puffy750");
|
||||||
|
value_map.insert("fueltank-5", "SideTank");
|
||||||
|
value_map.insert("engine-0", "EngineTiny");
|
||||||
|
value_map.insert("engine-1", "EngineSmall");
|
||||||
|
value_map.insert("engine-2", "EngineMedium");
|
||||||
|
value_map.insert("engine-3", "EngineLarge");
|
||||||
|
value_map.insert("engine-4", "SolidRocketBooster");
|
||||||
|
value_map.insert("ion-0", "EngineIon");
|
||||||
|
value_map.insert("parachute-1", "ParachuteCanister");
|
||||||
|
value_map.insert("nosecone-1", "NoseCone");
|
||||||
|
value_map.insert("rcs-1", "RcsBlock");
|
||||||
|
value_map.insert("solar-1", "SolarPanelBase");
|
||||||
|
value_map.insert("battery-0", "Battery");
|
||||||
|
value_map.insert("dock-1", "DockingConnector");
|
||||||
|
value_map.insert("port-1", "DockingPort");
|
||||||
|
value_map.insert("lander-1", "LanderLegPreview");
|
||||||
|
let result = value_map.get(ptype.as_str());
|
||||||
|
match result {
|
||||||
|
None => "Pod".to_string(),
|
||||||
|
Some(i) => {
|
||||||
|
let i = *i;
|
||||||
|
i.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SR1PartData {
|
||||||
|
pub x: f64,
|
||||||
|
pub y: f64,
|
||||||
|
pub id: i64,
|
||||||
|
pub p_type: String,
|
||||||
|
pub active: bool,
|
||||||
|
pub angle: f64, // 弧度制
|
||||||
|
pub angle_v: f64,
|
||||||
|
pub editor_angle: usize,
|
||||||
|
pub flip_x: bool,
|
||||||
|
pub flip_y: bool,
|
||||||
|
pub explode: bool,
|
||||||
|
pub textures: String,
|
||||||
|
pub connections: Option<Vec<(usize, usize)>>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub mod dr {
|
||||||
|
pub enum PartType {
|
||||||
|
Pod,
|
||||||
|
Separator,
|
||||||
|
Wheel,
|
||||||
|
Fuselage,
|
||||||
|
Beam,
|
||||||
|
Engine,
|
||||||
|
FuelTank,
|
||||||
|
Parachute,
|
||||||
|
Nosecone,
|
||||||
|
SolarPanel,
|
||||||
|
Battery,
|
||||||
|
Dock,
|
||||||
|
Port,
|
||||||
|
Lander
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DRPartData {
|
||||||
|
pub x: f64,
|
||||||
|
pub y: f64,
|
||||||
|
pub id: i64,
|
||||||
|
pub p_type: PartType,
|
||||||
|
pub active: bool,
|
||||||
|
pub angle: f64, // 角度制
|
||||||
|
pub angle_v: f64,
|
||||||
|
pub editor_angle: usize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ defusedxml >= 0.7.1
|
|||||||
objprint >= 0.2.2
|
objprint >= 0.2.2
|
||||||
|
|
||||||
# for compile
|
# for compile
|
||||||
nuitka >= 1.3.8
|
nuitka >= 1.4.5
|
||||||
ordered-set >= 4.1.0
|
ordered-set >= 4.1.0
|
||||||
imageio >= 2.25.0
|
imageio >= 2.25.0
|
||||||
wheel >= 0.38.4
|
wheel >= 0.38.4
|
||||||
setuptools >= 66.1.1
|
setuptools >= 67.2.0
|
||||||
setuptools-rust >= 1.5.2
|
setuptools-rust >= 1.5.2
|
||||||
|
@ -20,12 +20,12 @@ defusedxml >= 0.7.1
|
|||||||
# for debug
|
# for debug
|
||||||
objprint >= 0.2.2
|
objprint >= 0.2.2
|
||||||
viztracer >= 0.15.6
|
viztracer >= 0.15.6
|
||||||
vizplugins
|
vizplugins >= 0.1.3
|
||||||
|
|
||||||
# for compile
|
# for compile
|
||||||
nuitka >= 1.3.8
|
nuitka >= 1.4.5
|
||||||
ordered-set >= 4.1.0
|
ordered-set >= 4.1.0
|
||||||
imageio >= 2.25.0
|
imageio >= 2.25.0
|
||||||
wheel >= 0.38.4
|
wheel >= 0.38.4
|
||||||
setuptools >= 66.1.1
|
setuptools >= 67.2.0
|
||||||
setuptools-rust >= 1.5.2
|
setuptools-rust >= 1.5.2
|
||||||
|
Loading…
Reference in New Issue
Block a user