DR_rs 0.2.5.6
This commit is contained in:
parent
3ec65f8045
commit
6ea058701e
@ -24,7 +24,7 @@ from libs.MCDR.version import Version
|
||||
|
||||
game_version = Version("0.7.1.4") # 游戏版本
|
||||
build_version = Version("1.2.1.0") # 编译文件版本(与游戏本体无关)
|
||||
DR_rust_version = Version("0.2.5.5") # DR 的 Rust 编写部分的版本
|
||||
DR_rust_version = Version("0.2.5.6") # DR 的 Rust 编写部分的版本
|
||||
Api_version = Version("0.0.0.1") # API 版本
|
||||
__version__ = game_version
|
||||
|
||||
|
@ -31,7 +31,7 @@ if TYPE_CHECKING:
|
||||
from Difficult_Rocket.client import ClientWindow
|
||||
|
||||
if DR_option.use_DR_rust:
|
||||
from libs.Difficult_Rocket_rs import PartDatas, Camera_rs
|
||||
from libs.Difficult_Rocket_rs import PartDatas, CenterCamera_rs
|
||||
|
||||
|
||||
def get_sr1_part(part_xml: Element) -> Optional[SR1PartData]:
|
||||
@ -117,8 +117,8 @@ class SR1ShipRender(BaseScreen):
|
||||
self.part_data: Dict[int, SR1PartData] = {}
|
||||
self.parts_sprite: Dict[int, Sprite] = {}
|
||||
if DR_option.use_DR_rust:
|
||||
self.camera_rs = Camera_rs(main_window,
|
||||
min_zoom=(1 / 2) ** 10, max_zoom=10)
|
||||
self.camera_rs = CenterCamera_rs(main_window,
|
||||
min_zoom=(1 / 2) ** 10, max_zoom=10)
|
||||
self.rust_parts = None
|
||||
|
||||
def load_xml(self, file_path: str) -> bool:
|
||||
@ -205,7 +205,7 @@ class SR1ShipRender(BaseScreen):
|
||||
if not self.rendered:
|
||||
return False
|
||||
self.debug_line.x2, self.debug_line.y2 = self.camera_rs.dx + (
|
||||
self.window_pointer.width / 2), self.camera_rs.dy + (
|
||||
self.window_pointer.width / 2), self.camera_rs.dy + (
|
||||
self.window_pointer.height / 2)
|
||||
self.debug_d_pos_label.text = f'x: {self.camera_rs.dx} y: {self.camera_rs.dy}'
|
||||
self.debug_d_pos_label.position = self.camera_rs.dx + (self.window_pointer.width / 2), self.camera_rs.dy + (
|
||||
@ -279,9 +279,9 @@ class SR1ShipRender(BaseScreen):
|
||||
|
||||
self.debug_mouse_line.x2, self.debug_mouse_line.y2 = x, y
|
||||
self.debug_mouse_delta_line.x2 = (mouse_dx - self.camera_rs.dx) * (1 - (0.5 ** scroll_y)) + (
|
||||
self.window_pointer.width / 2)
|
||||
self.window_pointer.width / 2)
|
||||
self.debug_mouse_delta_line.y2 = (mouse_dy - self.camera_rs.dy) * (1 - (0.5 ** scroll_y)) + (
|
||||
self.window_pointer.height / 2)
|
||||
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.need_update_parts = True
|
||||
|
@ -22,19 +22,36 @@
|
||||
- [-blue.svg?style=flat-square)](../../README.md)
|
||||
- Using [SemVer 2.0.0](https://semver.org/) to manage version
|
||||
|
||||
## 20230302 DR `0.7.1.5` + Build `1.2.1.0`
|
||||
## 20230302 DR `0.7.1.5` + Build `1.2.1.0` + DR_rs `0.2.5.6`
|
||||
|
||||
WORKING ON
|
||||
|
||||
### DR_rs V 0.2.5.6
|
||||
|
||||
- 重新把 `CenterCamera_rs` 放回去了
|
||||
- (事实证明是我确实没好好看文档)
|
||||
- 导出了 `CenterCamera_rs`
|
||||
- Replaced `CenterCamera_rs` back
|
||||
- (It turns out that I didn't read the document carefully)
|
||||
- Exported `CenterCamera_rs`
|
||||
|
||||
### Build V 1.2.1.0
|
||||
|
||||
- Actions 崩溃了 等等吧
|
||||
- 恢复了, 摆烂了, 就现在这样挺好的
|
||||
- Actions crashed, wait a minute
|
||||
- Recovered, it's good now
|
||||
|
||||
### Build V 1.2.0.0
|
||||
|
||||
- 现在打包之前会移除无用文件
|
||||
- Now useless files will be removed before packaging
|
||||
|
||||
### 重命名
|
||||
|
||||
- `Difficult_Rocket.client.render.sr1_ship`
|
||||
- `Camera_rs` -> `CenterCamera_rs`
|
||||
|
||||
### typing
|
||||
|
||||
- 移除了以下文件的 `from x import *`
|
||||
|
@ -65,9 +65,8 @@ if TYPE_CHECKING:
|
||||
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
|
||||
|
||||
|
||||
class CenterCamera_rs(Camera_rs):
|
||||
""" 用于依旧闲的没事 用 rust 写一个中央对齐的 camera """
|
||||
|
||||
class PartFrame_rs:
|
||||
...
|
||||
|
||||
|
||||
# class CenterCamera_rs(Camera_rs):
|
||||
# """ 用于依旧闲的没事 用 rust 写一个中央对齐的 camera """
|
||||
|
@ -16,7 +16,7 @@ use pyo3::prelude::*;
|
||||
|
||||
#[pyfunction]
|
||||
fn get_version_str() -> String {
|
||||
return "0.2.5.5".to_string();
|
||||
return "0.2.5.6".to_string();
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
@ -38,6 +38,7 @@ fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(sr1_data::part_list::read_part_list_py, m)?)?;
|
||||
m.add_class::<sr1_render::types::PartDatas>()?;
|
||||
m.add_class::<render::camera::CameraRs>()?;
|
||||
m.add_class::<render::camera::CenterCameraRs>()?;
|
||||
m.add_class::<render::screen::PartFrame>()?;
|
||||
Ok(())
|
||||
}
|
@ -32,9 +32,46 @@ pub mod camera {
|
||||
impl CenterCameraRs {
|
||||
#[new]
|
||||
#[pyo3(signature = (window, zoom=1.0, dx=1.0, dy=1.0, min_zoom=1.0, max_zoom=1.0))]
|
||||
pub fn py_new(window: &PyAny, zoom: f64, dx: f64, dy: f64,min_zoom: f64, max_zoom: f64) -> PyResult<Self> {
|
||||
return Ok(CameraRs {dx, dy, zoom, min_zoom, max_zoom,
|
||||
window: window.into()})
|
||||
pub fn py_new(window: &PyAny, zoom: f64, dx: f64, dy: f64,min_zoom: f64, max_zoom: f64) -> PyResult<(Self, CameraRs)> {
|
||||
return Ok((CenterCameraRs {}, CameraRs {dx, dy, zoom, min_zoom, max_zoom,
|
||||
window: window.into()}))
|
||||
}
|
||||
|
||||
// pub fn __enter__(py_self: PyRef<Self>) -> PyResult<PyRef<Self>> {
|
||||
// // println!("enter!");
|
||||
// CenterCameraRs::begin()?;
|
||||
// Ok(py_self)
|
||||
// }
|
||||
|
||||
pub fn begin(self_: PyRef<'_, Self>) -> PyResult<()> {
|
||||
println!("begin!");
|
||||
let super_: &CameraRs = self_.as_ref();
|
||||
// 获取父类
|
||||
Python::with_gil(|py| -> PyResult<()> {
|
||||
let view = super_.window.getattr(py, intern!(py, "view"))?;
|
||||
// 获取存储的 view
|
||||
let x: f64 = super_.window.getattr(py, intern!(py, "width"))?.extract(py)?;
|
||||
let y: f64 = super_.window.getattr(py, intern!(py, "height"))?.extract(py)?;
|
||||
let x: f64 = x / 2.0 / super_.zoom + (super_.dx / super_.zoom);
|
||||
let y: f64 = y / 2.0 / super_.zoom + (super_.dy / super_.zoom);
|
||||
// 计算中心点
|
||||
|
||||
// view.call_method1(py, "translate", (x, y))?;
|
||||
// view.call_method1(py, "scale", (super_.zoom, super_.zoom))?;
|
||||
|
||||
let args = ((x * super_.zoom, y * super_.zoom, 0), );
|
||||
let view_matrix = view.call_method1(py, intern!(py, "translate"), args)?;
|
||||
// view_matrix = self.view.translate((x * zoom, y * zoom, 0))
|
||||
|
||||
let args = ((super_.zoom, super_.zoom, 1), );
|
||||
let view_matrix = view_matrix.call_method1(py, intern!(py, "scale"), args)?;
|
||||
// view_matrix = view_matrix.scale((zoom, zoom, 1))
|
||||
|
||||
super_.window.setattr(py, intern!(py, "view"), view_matrix)?;
|
||||
// self.view = view_matrix
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user