bump DR_rs to 0.1.7.0

This commit is contained in:
shenjack-mac 2023-02-02 16:10:21 +08:00
parent db79b187aa
commit ffe468b00b
5 changed files with 29 additions and 23 deletions

View File

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

View File

@ -63,9 +63,9 @@ def get_sr1_part(part_xml: Element) -> Optional[SR1PartData]:
class _SR1ShipRender_Option(Options):
# debug option
debug_d_pos: bool = False
debug_mouse_pos: bool = False
debug_mouse_d_pos: bool = False
debug_d_pos: bool = True
debug_mouse_pos: bool = True
debug_mouse_d_pos: bool = True
SR1ShipRender_Option = _SR1ShipRender_Option()
@ -111,8 +111,7 @@ class SR1ShipRender(BaseScreen):
self.debug_label = Label(x=20, y=main_window.height - 20, font_size=DR_option.std_font_size,
text='SR1 render!', font_name=Fonts.微软等宽无线,
width=main_window.width - 20, height=20,
anchor_x='left', anchor_y='top',
batch=self.part_batch)
anchor_x='left', anchor_y='top')
self.part_data: Dict[int, SR1PartData] = {}
self.parts_sprite: Dict[int, Sprite] = {}
if DR_option.use_DR_rust:
@ -138,7 +137,7 @@ class SR1ShipRender(BaseScreen):
start_time = time.perf_counter_ns()
self.part_data: Dict[int, SR1PartData] = {}
self.parts_sprite: Dict[int, Sprite] = {}
self.scale = 1.0
self.camera_rs.zoom = 1.0
if DR_option.use_DR_rust:
self.camera_rs.dx = 0
self.camera_rs.dy = 0
@ -187,10 +186,10 @@ class SR1ShipRender(BaseScreen):
def update_parts(self) -> bool:
if not self.rendered:
return False
self.debug_line.x2, self.debug_line.y2 = self.camera_rs.dx + (self.window_pointer.width / 2), self.dy + (
self.debug_line.x2, self.debug_line.y2 = self.camera_rs.dx + (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.dy + (
self.debug_d_pos_label.position = self.camera_rs.dx + (self.window_pointer.width / 2), self.camera_rs.dy + (
self.window_pointer.height / 2) + 10, 0
# if DR_option.use_DR_rust:
# # print(f'{self.dx=} {self.dy=} {self.scale=}')
@ -210,11 +209,8 @@ class SR1ShipRender(BaseScreen):
if self.need_update_parts:
self.update_parts()
self.need_update_parts = False
if DR_option.use_DR_rust:
self.camera_rs.begin()
with self.camera_rs:
self.part_batch.draw()
if DR_option.use_DR_rust:
self.camera_rs.end()
self.debug_label.draw()
if SR1ShipRender_Option.debug_d_pos:
self.debug_line.draw()
@ -259,7 +255,7 @@ class SR1ShipRender(BaseScreen):
def on_command(self, command: CommandText):
if command.re_match('render'):
if command.re_match('reset'):
self.scale = 1
self.camera_rs.zoom = 1
self.camera_rs.dx = 0
self.camera_rs.dy = 0
else:

View File

@ -60,5 +60,5 @@ if TYPE_CHECKING:
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
class CenterCamera_rs(Camera_rs):
""" 用于依旧闲的没事 用 rust 写一个中央对齐的 camera """
# class CenterCamera_rs(Camera_rs):
# """ 用于依旧闲的没事 用 rust 写一个中央对齐的 camera """

View File

@ -13,7 +13,7 @@ use pyo3::prelude::*;
#[pyfunction]
fn get_version_str() -> String {
return String::from("0.1.6.5");
return String::from("0.1.7.0");
}
#[pyfunction]
@ -33,6 +33,6 @@ fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sr1_render::better_update_parts, m)?)?;
m.add_class::<sr1_render::types::PartDatas>()?;
m.add_class::<render::camera::CameraRs>()?;
m.add_class::<render::camera::CenterCameraRs>()?;
// m.add_class::<render::camera::CenterCameraRs>()?;
Ok(())
}

View File

@ -25,8 +25,8 @@ pub mod camera {
pub min_zoom: f64,
}
#[pyclass(extends = CameraRs, name = "CenterCamera_rs")]
pub struct CenterCameraRs;
// #[pyclass(extends = CameraRs, name = "CenterCamera_rs")]
// pub struct CenterCameraRs;
#[pymethods]
impl CameraRs {
@ -70,7 +70,12 @@ pub mod camera {
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 x: f64 = self.window.getattr(py, intern!(py, "width"))?.extract(py)?;
let y: f64 = self.window.getattr(py, intern!(py, "height"))?.extract(py)?;
let x: f64 = x / 2.0 / self.zoom + (self.dx / self.zoom);
let y: f64 = y / 2.0 / self.zoom + (self.dy / self.zoom);
let args = ((x * self.zoom, y * self.zoom, 0), );
let view_matrix = view.call_method1(py, intern!(py, "translate"), args)?;
let args = ((self.zoom, self.zoom, 1), );
@ -86,10 +91,15 @@ pub mod camera {
Python::with_gil(|py| -> PyResult<()> {
let view = self.window.getattr(py, intern!(py, "view"))?;
let x: f64 = self.window.getattr(py, intern!(py, "width"))?.extract(py)?;
let y: f64 = self.window.getattr(py, intern!(py, "height"))?.extract(py)?;
let x: f64 = x / 2.0 / self.zoom + (self.dx / self.zoom);
let y: f64 = y / 2.0 / self.zoom + (self.dy / self.zoom);
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 args = ((-x * self.zoom, -y * self.zoom, 0), );
let view_matrix = view_matrix.call_method1(py, intern!(py, "translate"), args)?;
self.window.setattr(py, intern!(py, "view"), view_matrix)?;