DR_rs 0.1.6.2

This commit is contained in:
shenjack 2023-02-01 08:04:40 +08:00
parent 8dfbf1249b
commit 77a42199f0
4 changed files with 22 additions and 8 deletions

View File

@ -25,7 +25,7 @@ from libs.MCDR.version import Version
game_version = Version("0.7.0.0") # 游戏版本 game_version = Version("0.7.0.0") # 游戏版本
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关) build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
DR_rust_version = Version("0.1.6.0") # DR 的 Rust 编写部分的版本 DR_rust_version = Version("0.1.6.2") # DR 的 Rust 编写部分的版本
__version__ = game_version __version__ = game_version
long_version: int = 11 long_version: int = 11

View File

@ -21,6 +21,8 @@
### 啊哈! 现在真就是 0.7 了 ### 啊哈! 现在真就是 0.7 了
毕竟加了一整个 `DR_rs`
### Add ### Add
- `libs.Difficult_Rocket_rs` (`DR_rs`) `0.1.0.0` - `libs.Difficult_Rocket_rs` (`DR_rs`) `0.1.0.0`

View File

@ -13,7 +13,7 @@ use pyo3::prelude::*;
#[pyfunction] #[pyfunction]
fn get_version_str() -> String { fn get_version_str() -> String {
return String::from("0.1.6.0"); return String::from("0.1.6.2");
} }
#[pyfunction] #[pyfunction]

View File

@ -53,10 +53,14 @@ pub mod camera {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
pub fn start(&self) -> PyResult<()> { pub fn begin(&self) -> PyResult<()> {
let view = self.get_view()?;
Python::with_gil(|py| -> PyResult<()> { Python::with_gil(|py| -> PyResult<()> {
let view = self.window.getattr(py, intern!(py, "view"))?;
let args = (-self.dx * self.zoom, -self.dy * self.zoom, 0);
let view_matrix = view.call_method1(py, intern!(py, "translate"), args)?;
let args = (self.zoom, self.zoom, 1);
let view_matrix = view_matrix.call_method1(py, intern!(py, "scale"), args)?;
self.window.setattr(py, intern!(py, "view"), view_matrix)?;
Ok(()) Ok(())
})?; })?;
return Ok(()) return Ok(())
@ -64,7 +68,15 @@ pub mod camera {
#[allow(unused_variables)] #[allow(unused_variables)]
pub fn end(&self) -> PyResult<()> { pub fn end(&self) -> PyResult<()> {
let view = self.get_view()?; Python::with_gil(|py| -> PyResult<()> {
let view = self.window.getattr(py, intern!(py, "view"))?;
let args = (1.0 / self.zoom, 1.0 / self.zoom, 1);
let view_matrix = view.call_method1(py, intern!(py, "scale"), args)?;
let args = (self.dx * self.zoom, self.dy * self.zoom, 0);
let view_matrix = view_matrix.call_method1(py, intern!(py, "translate"), args)?;
self.window.setattr(py, intern!(py, "view"), view_matrix)?;
Ok(())
})?;
return Ok(()) return Ok(())
} }
@ -72,11 +84,11 @@ pub mod camera {
/// https://github.com/PyO3/pyo3/issues/1205#issuecomment-1164096251 for advice on `__enter__` /// https://github.com/PyO3/pyo3/issues/1205#issuecomment-1164096251 for advice on `__enter__`
pub fn __enter__(py_self: PyRef<Self>) -> PyResult<PyRef<Self>> { pub fn __enter__(py_self: PyRef<Self>) -> PyResult<PyRef<Self>> {
// println!("enter!"); // println!("enter!");
py_self.start()?; py_self.begin()?;
Ok(py_self) Ok(py_self)
} }
pub fn __exit__(&mut self, _exc_type: PyObject, _exc_value: PyObject, _traceback: PyObject) -> PyResult<()>{ pub fn __exit__(&self, _exc_type: PyObject, _exc_value: PyObject, _traceback: PyObject) -> PyResult<()>{
// println!("exit!"); // println!("exit!");
self.end()?; self.end()?;
return Ok(()) return Ok(())