bump DR_rs to 0.1.7.0
This commit is contained in:
parent
db79b187aa
commit
ffe468b00b
@ -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.5") # DR 的 Rust 编写部分的版本
|
DR_rust_version = Version("0.1.7.0") # DR 的 Rust 编写部分的版本
|
||||||
__version__ = game_version
|
__version__ = game_version
|
||||||
|
|
||||||
long_version: int = 11
|
long_version: int = 11
|
||||||
|
@ -63,9 +63,9 @@ def get_sr1_part(part_xml: Element) -> Optional[SR1PartData]:
|
|||||||
|
|
||||||
class _SR1ShipRender_Option(Options):
|
class _SR1ShipRender_Option(Options):
|
||||||
# debug option
|
# debug option
|
||||||
debug_d_pos: bool = False
|
debug_d_pos: bool = True
|
||||||
debug_mouse_pos: bool = False
|
debug_mouse_pos: bool = True
|
||||||
debug_mouse_d_pos: bool = False
|
debug_mouse_d_pos: bool = True
|
||||||
|
|
||||||
|
|
||||||
SR1ShipRender_Option = _SR1ShipRender_Option()
|
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,
|
self.debug_label = Label(x=20, y=main_window.height - 20, font_size=DR_option.std_font_size,
|
||||||
text='SR1 render!', font_name=Fonts.微软等宽无线,
|
text='SR1 render!', font_name=Fonts.微软等宽无线,
|
||||||
width=main_window.width - 20, height=20,
|
width=main_window.width - 20, height=20,
|
||||||
anchor_x='left', anchor_y='top',
|
anchor_x='left', anchor_y='top')
|
||||||
batch=self.part_batch)
|
|
||||||
self.part_data: Dict[int, SR1PartData] = {}
|
self.part_data: Dict[int, SR1PartData] = {}
|
||||||
self.parts_sprite: Dict[int, Sprite] = {}
|
self.parts_sprite: Dict[int, Sprite] = {}
|
||||||
if DR_option.use_DR_rust:
|
if DR_option.use_DR_rust:
|
||||||
@ -138,7 +137,7 @@ class SR1ShipRender(BaseScreen):
|
|||||||
start_time = time.perf_counter_ns()
|
start_time = time.perf_counter_ns()
|
||||||
self.part_data: Dict[int, SR1PartData] = {}
|
self.part_data: Dict[int, SR1PartData] = {}
|
||||||
self.parts_sprite: Dict[int, Sprite] = {}
|
self.parts_sprite: Dict[int, Sprite] = {}
|
||||||
self.scale = 1.0
|
self.camera_rs.zoom = 1.0
|
||||||
if DR_option.use_DR_rust:
|
if DR_option.use_DR_rust:
|
||||||
self.camera_rs.dx = 0
|
self.camera_rs.dx = 0
|
||||||
self.camera_rs.dy = 0
|
self.camera_rs.dy = 0
|
||||||
@ -187,10 +186,10 @@ class SR1ShipRender(BaseScreen):
|
|||||||
def update_parts(self) -> bool:
|
def update_parts(self) -> bool:
|
||||||
if not self.rendered:
|
if not self.rendered:
|
||||||
return False
|
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.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.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
|
self.window_pointer.height / 2) + 10, 0
|
||||||
# if DR_option.use_DR_rust:
|
# if DR_option.use_DR_rust:
|
||||||
# # print(f'{self.dx=} {self.dy=} {self.scale=}')
|
# # print(f'{self.dx=} {self.dy=} {self.scale=}')
|
||||||
@ -210,11 +209,8 @@ class SR1ShipRender(BaseScreen):
|
|||||||
if self.need_update_parts:
|
if self.need_update_parts:
|
||||||
self.update_parts()
|
self.update_parts()
|
||||||
self.need_update_parts = False
|
self.need_update_parts = False
|
||||||
if DR_option.use_DR_rust:
|
with self.camera_rs:
|
||||||
self.camera_rs.begin()
|
|
||||||
self.part_batch.draw()
|
self.part_batch.draw()
|
||||||
if DR_option.use_DR_rust:
|
|
||||||
self.camera_rs.end()
|
|
||||||
self.debug_label.draw()
|
self.debug_label.draw()
|
||||||
if SR1ShipRender_Option.debug_d_pos:
|
if SR1ShipRender_Option.debug_d_pos:
|
||||||
self.debug_line.draw()
|
self.debug_line.draw()
|
||||||
@ -259,7 +255,7 @@ class SR1ShipRender(BaseScreen):
|
|||||||
def on_command(self, command: CommandText):
|
def on_command(self, command: CommandText):
|
||||||
if command.re_match('render'):
|
if command.re_match('render'):
|
||||||
if command.re_match('reset'):
|
if command.re_match('reset'):
|
||||||
self.scale = 1
|
self.camera_rs.zoom = 1
|
||||||
self.camera_rs.dx = 0
|
self.camera_rs.dx = 0
|
||||||
self.camera_rs.dy = 0
|
self.camera_rs.dy = 0
|
||||||
else:
|
else:
|
||||||
|
@ -60,5 +60,5 @@ if TYPE_CHECKING:
|
|||||||
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
|
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
class CenterCamera_rs(Camera_rs):
|
# class CenterCamera_rs(Camera_rs):
|
||||||
""" 用于依旧闲的没事 用 rust 写一个中央对齐的 camera """
|
# """ 用于依旧闲的没事 用 rust 写一个中央对齐的 camera """
|
||||||
|
@ -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.5");
|
return String::from("0.1.7.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyfunction]
|
#[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_function(wrap_pyfunction!(sr1_render::better_update_parts, m)?)?;
|
||||||
m.add_class::<sr1_render::types::PartDatas>()?;
|
m.add_class::<sr1_render::types::PartDatas>()?;
|
||||||
m.add_class::<render::camera::CameraRs>()?;
|
m.add_class::<render::camera::CameraRs>()?;
|
||||||
m.add_class::<render::camera::CenterCameraRs>()?;
|
// m.add_class::<render::camera::CenterCameraRs>()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
@ -25,8 +25,8 @@ pub mod camera {
|
|||||||
pub min_zoom: f64,
|
pub min_zoom: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyclass(extends = CameraRs, name = "CenterCamera_rs")]
|
// #[pyclass(extends = CameraRs, name = "CenterCamera_rs")]
|
||||||
pub struct CenterCameraRs;
|
// pub struct CenterCameraRs;
|
||||||
|
|
||||||
#[pymethods]
|
#[pymethods]
|
||||||
impl CameraRs {
|
impl CameraRs {
|
||||||
@ -70,7 +70,12 @@ pub mod camera {
|
|||||||
Python::with_gil(|py| -> PyResult<()> {
|
Python::with_gil(|py| -> PyResult<()> {
|
||||||
let view = self.window.getattr(py, intern!(py, "view"))?;
|
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 view_matrix = view.call_method1(py, intern!(py, "translate"), args)?;
|
||||||
|
|
||||||
let args = ((self.zoom, self.zoom, 1), );
|
let args = ((self.zoom, self.zoom, 1), );
|
||||||
@ -86,10 +91,15 @@ pub mod camera {
|
|||||||
Python::with_gil(|py| -> PyResult<()> {
|
Python::with_gil(|py| -> PyResult<()> {
|
||||||
let view = self.window.getattr(py, intern!(py, "view"))?;
|
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 args = ((1.0 / self.zoom, 1.0 / self.zoom, 1), );
|
||||||
let view_matrix = view.call_method1(py, intern!(py, "scale"), args)?;
|
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)?;
|
let view_matrix = view_matrix.call_method1(py, intern!(py, "translate"), args)?;
|
||||||
|
|
||||||
self.window.setattr(py, intern!(py, "view"), view_matrix)?;
|
self.window.setattr(py, intern!(py, "view"), view_matrix)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user