From b3f262e8173d9b1cca99c05768d07dcee657112a Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Tue, 24 Jan 2023 19:49:46 +0800 Subject: [PATCH] =?UTF-8?q?update=E3=80=81bump=20version=20[page=20skip]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Difficult_Rocket/__init__.py | 2 +- Difficult_Rocket/client/render/sr1_ship.py | 17 +++++------ libs/Difficult_Rocket_rs/__init__.py | 2 ++ libs/Difficult_Rocket_rs/src/src/lib.rs | 2 +- .../Difficult_Rocket_rs/src/src/sr1_render.rs | 28 +++++++++++-------- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Difficult_Rocket/__init__.py b/Difficult_Rocket/__init__.py index 2e51c1b..035302d 100644 --- a/Difficult_Rocket/__init__.py +++ b/Difficult_Rocket/__init__.py @@ -23,7 +23,7 @@ from libs.MCDR.version import Version game_version = Version("0.6.5.0") # 游戏版本 build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关) -DR_rust_version = Version("0.0.5.0") # DR 的 Rust 编写部分的版本 +DR_rust_version = Version("0.0.5.2") # DR 的 Rust 编写部分的版本 __version__ = game_version long_version: int = 10 diff --git a/Difficult_Rocket/client/render/sr1_ship.py b/Difficult_Rocket/client/render/sr1_ship.py index 39b34db..1437a42 100644 --- a/Difficult_Rocket/client/render/sr1_ship.py +++ b/Difficult_Rocket/client/render/sr1_ship.py @@ -175,13 +175,14 @@ class SR1ShipRender(BaseScreen): if DR_option.DR_rust_available: print(type(self.part_data)) self.rust_parts = PartDatas(self.part_data) + # print(self.rust_parts.get_rust_pointer()) self.rendered = True def update_parts(self) -> bool: - if DR_option.DR_rust_available: - return better_update_parts(self, SR1ShipRender_Option, self.window_pointer, self.rust_parts) if not self.rendered: return False + if DR_option.DR_rust_available: + return better_update_parts(self, SR1ShipRender_Option, self.window_pointer, self.rust_parts) self.debug_line.x2, self.debug_line.y2 = self.dx + (self.window_pointer.width / 2), self.dy + ( self.window_pointer.height / 2) self.debug_d_pos_label.text = f'x: {self.dx} y: {self.dy}' @@ -189,10 +190,8 @@ class SR1ShipRender(BaseScreen): self.window_pointer.height / 2) + 10, 0 for part_id in self.part_data: # x y scale - self.parts_sprite[part_id].x = self.part_data[ - part_id].x * DR_option.gui_scale * self.scale * 60 + self.window_pointer.width / 2 + self.dx - self.parts_sprite[part_id].y = self.part_data[ - part_id].y * DR_option.gui_scale * self.scale * 60 + self.window_pointer.height / 2 + self.dy + self.parts_sprite[part_id].x = self.part_data[part_id].x * DR_option.gui_scale * self.scale * 60 + self.window_pointer.width / 2 + self.dx + self.parts_sprite[part_id].y = self.part_data[part_id].y * DR_option.gui_scale * self.scale * 60 + self.window_pointer.height / 2 + self.dy self.parts_sprite[part_id].scale = self.scale * DR_option.gui_scale def on_draw(self): @@ -232,10 +231,8 @@ class SR1ShipRender(BaseScreen): self.dy += (mouse_dy - self.dy) * (1 - (0.5 ** scroll_y)) else: self.scale = 10 - self.debug_mouse_delta_line.x2 = (mouse_dx - self.dx) * (1 - (0.5 ** scroll_y)) + ( - self.window_pointer.width / 2) - self.debug_mouse_delta_line.y2 = (mouse_dy - self.dy) * (1 - (0.5 ** scroll_y)) + ( - self.window_pointer.height / 2) + self.debug_mouse_delta_line.x2 = (mouse_dx - self.dx) * (1 - (0.5 ** scroll_y)) + (self.window_pointer.width / 2) + self.debug_mouse_delta_line.y2 = (mouse_dy - self.dy) * (1 - (0.5 ** scroll_y)) + (self.window_pointer.height / 2) self.debug_mouse_label.text = f'x: {mouse_dx} y: {mouse_dy}' self.debug_mouse_label.position = x, y + 10, 0 self.update_parts() diff --git a/libs/Difficult_Rocket_rs/__init__.py b/libs/Difficult_Rocket_rs/__init__.py index 14b4934..7fafc06 100644 --- a/libs/Difficult_Rocket_rs/__init__.py +++ b/libs/Difficult_Rocket_rs/__init__.py @@ -21,6 +21,8 @@ if TYPE_CHECKING: """ 用于在 PyObj 里塞一个浓眉大眼的 HashMap""" def __new__(cls, py_part_data: Dict[int, SR1PartData]) -> "PartDatas": ... + def get_rust_pointer(self) -> int: ... + def better_update_parts(render: SR1ShipRender, option: SR1ShipRender_Option, window: BaseScreen, diff --git a/libs/Difficult_Rocket_rs/src/src/lib.rs b/libs/Difficult_Rocket_rs/src/src/lib.rs index 14d95ab..243aaa0 100644 --- a/libs/Difficult_Rocket_rs/src/src/lib.rs +++ b/libs/Difficult_Rocket_rs/src/src/lib.rs @@ -12,7 +12,7 @@ use pyo3::prelude::*; #[pyfunction] fn get_version_str() -> String { - return String::from("0.0.5.0"); + return String::from("0.0.5.2"); } #[pyfunction] diff --git a/libs/Difficult_Rocket_rs/src/src/sr1_render.rs b/libs/Difficult_Rocket_rs/src/src/sr1_render.rs index 1f8454f..822c7a2 100644 --- a/libs/Difficult_Rocket_rs/src/src/sr1_render.rs +++ b/libs/Difficult_Rocket_rs/src/src/sr1_render.rs @@ -9,7 +9,7 @@ use std::collections::HashMap; use pyo3::intern; use pyo3::prelude::*; -use pyo3::types::PyDict; +use crate::sr1_render::types::SR1PartData; #[allow(dead_code)] pub mod types { @@ -43,24 +43,24 @@ pub mod types { #[pyclass(name = "PartDatas")] pub struct PartDatas { - pub part_structs: HashMap + pub part_structs: HashMap, + } + + impl PartDatas { + fn get_rust_data(&self) -> &HashMap { + return &self.part_structs; + } } #[pymethods] impl PartDatas { #[new] - pub fn py_new(py_part_data: &PyDict) -> PyResult { + fn py_new(py_part_data: &PyDict) -> PyResult { let datas: HashMap = part_data_tp_SR1PartDatas(py_part_data)?; - // let datas: HashMap = HashMap::new(); return Ok(PartDatas { part_structs: datas }) } } - impl PartDatas{ - pub fn get_rust_data(&self) -> &HashMap { - return &self.part_structs; - } - } #[allow(non_snake_case)] pub fn part_data_to_SR1PartData(input: &PyAny) -> Result { @@ -125,10 +125,16 @@ pub fn better_update_parts(render: &PyAny, option: &PyAny, window: &PyAny, parts let y_center: f32 = window.getattr(intern!(window.py(), "height"))?.extract()?; let x_center: f32 = x_center / 2.0; let y_center: f32 = y_center / 2.0; - let part_datas: &PyDict = render.getattr(intern!(render.py(), "part_data"))?.extract()?; - let parts: HashMap = types::part_datas_to_points(part_datas)?; + let datas: &HashMap = &parts.part_structs; + + for keys in datas { + + println!("{}", keys.0); + } + if option.getattr("debug_d_pos")?.is_true()? { let line = render.getattr(intern!(render.py(), "debug_line"))?; } + // for part in parts. Ok(true) } \ No newline at end of file