make dr_rs

This commit is contained in:
沈瑗杰 2023-01-25 01:39:50 +08:00
parent c158db62f9
commit cbdeb41c48
7 changed files with 25 additions and 20 deletions

View File

@ -21,9 +21,9 @@ from Difficult_Rocket.api.types import Options
from libs.MCDR.version import Version from libs.MCDR.version import Version
game_version = Version("0.6.5.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.0.6.4") # DR 的 Rust 编写部分的版本 DR_rust_version = Version("0.1.0.0") # DR 的 Rust 编写部分的版本
__version__ = game_version __version__ = game_version
long_version: int = 11 long_version: int = 11

View File

@ -307,7 +307,7 @@ class ClientWindow(Window):
elif command.re_match('default'): elif command.re_match('default'):
self.set_size(int(self.main_config['window_default']['width']), self.set_size(int(self.main_config['window_default']['width']),
int(self.main_config['window_default']['height'])) int(self.main_config['window_default']['height']))
self.command_tree.parse(command.plain_command) # self.command_tree.parse(command.plain_command)
@_call_screen_after @_call_screen_after
def on_message(self, message: line.CommandLine.text): def on_message(self, message: line.CommandLine.text):

View File

@ -64,9 +64,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()
@ -181,17 +181,17 @@ 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.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}'
self.debug_d_pos_label.position = self.dx + (self.window_pointer.width / 2), self.dy + (
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=}')
# from objprint import op # from objprint import op
# op(random.choices(self.parts_sprite), indent=1) # op(random.choices(self.parts_sprite), indent=1)
return better_update_parts(self, SR1ShipRender_Option, self.window_pointer, return better_update_parts(self, SR1ShipRender_Option, self.window_pointer,
self.rust_parts, DR_option.gui_scale, 60) self.rust_parts, DR_option.gui_scale, 60)
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}'
self.debug_d_pos_label.position = self.dx + (self.window_pointer.width / 2), self.dy + (
self.window_pointer.height / 2) + 10, 0
for part_id in self.part_data: for part_id in self.part_data:
# x y scale # 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].x = self.part_data[part_id].x * DR_option.gui_scale * self.scale * 60 + self.window_pointer.width / 2 + self.dx
@ -247,19 +247,23 @@ class SR1ShipRender(BaseScreen):
# self.render_ship() # self.render_ship()
self.need_draw = True self.need_draw = True
print('应该渲染飞船的') print('应该渲染飞船的')
elif command.re_match('sr1'): elif command.re_match('sr'):
print('sr ?')
if command.re_match('delta'): if command.re_match('delta'):
SR1ShipRender_Option.debug_d_pos = not SR1ShipRender_Option.debug_mouse_d_pos SR1ShipRender_Option.debug_d_pos = not SR1ShipRender_Option.debug_mouse_d_pos
self.debug_line.visible = SR1ShipRender_Option.debug_d_pos self.debug_line.visible = SR1ShipRender_Option.debug_d_pos
self.debug_d_pos_label.visible = SR1ShipRender_Option.debug_d_pos self.debug_d_pos_label.visible = SR1ShipRender_Option.debug_d_pos
# print('sr1 delta')
elif command.re_match('mouse'): elif command.re_match('mouse'):
if command.re_match('delta'): if command.re_match('delta'):
SR1ShipRender_Option.debug_mouse_pos = not SR1ShipRender_Option.debug_mouse_pos SR1ShipRender_Option.debug_mouse_pos = not SR1ShipRender_Option.debug_mouse_pos
self.debug_mouse_line.visible = SR1ShipRender_Option.debug_mouse_pos self.debug_mouse_line.visible = SR1ShipRender_Option.debug_mouse_pos
self.debug_mouse_label.visible = SR1ShipRender_Option.debug_mouse_pos self.debug_mouse_label.visible = SR1ShipRender_Option.debug_mouse_pos
# print('sr1 mouse delta')
else: else:
SR1ShipRender_Option.debug_mouse_d_pos = not SR1ShipRender_Option.debug_mouse_d_pos SR1ShipRender_Option.debug_mouse_d_pos = not SR1ShipRender_Option.debug_mouse_d_pos
self.debug_mouse_delta_line.visible = SR1ShipRender_Option.debug_mouse_d_pos self.debug_mouse_delta_line.visible = SR1ShipRender_Option.debug_mouse_d_pos
# print('sr1 mouse')
def on_mouse_drag(self, x: int, y: int, dx: int, dy: int, buttons: int, modifiers: int): def on_mouse_drag(self, x: int, y: int, dx: int, dy: int, buttons: int, modifiers: int):
if not self.focus: if not self.focus:

View File

@ -23,7 +23,7 @@
### Add ### Add
- `libs.Difficult_Rocket_rs` (`DR_rs`) - `libs.Difficult_Rocket_rs` (`DR_rs`) `0.1.0.0`
- `get_version_str` - `get_version_str`
- 返回 `DR_rs` 的版本号 可以用于检查我有没有忘记跑 `after_build.py` - 返回 `DR_rs` 的版本号 可以用于检查我有没有忘记跑 `after_build.py`
- 别问为啥不是返回一个 `Version` 对象 问就是懒得转换 - 别问为啥不是返回一个 `Version` 对象 问就是懒得转换

View File

@ -0,0 +1,3 @@
python3.8 setup.py build
python3.9 setup.py build
python3.9 after_build.py

View File

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

View File

@ -88,7 +88,6 @@ pub mod types {
for key in input.iter() { for key in input.iter() {
result.insert(key.0.extract()?, part_data_to_SR1PartData(key.1)?); result.insert(key.0.extract()?, part_data_to_SR1PartData(key.1)?);
} }
println!("it calls me success");
return Ok(result) return Ok(result)
} }
@ -113,7 +112,6 @@ pub mod types {
#[pyfunction] #[pyfunction]
#[allow(unused_variables)] #[allow(unused_variables)]
pub fn better_update_parts(render: &PyAny, option: &PyAny, window: &PyAny, pub fn better_update_parts(render: &PyAny, option: &PyAny, window: &PyAny,
@ -137,15 +135,15 @@ pub fn better_update_parts(render: &PyAny, option: &PyAny, window: &PyAny,
// let index = keys.0.to_string(); // let index = keys.0.to_string();
let sprite = part_sprites.get_item(keys.0)?; let sprite = part_sprites.get_item(keys.0)?;
let new_x: f64 = keys.1.x * global_scale * render_scale as f64 * sr1_xml_scale as f64 + x_center as f64 + dx; let new_x: f64 = keys.1.x * global_scale * render_scale as f64 * sr1_xml_scale as f64 + x_center as f64 + dx;
let new_y: f64 = keys.1.y * global_scale * render_scale as f64 * sr1_xml_scale as f64 + x_center as f64 + dy; let new_y: f64 = keys.1.y * global_scale * render_scale as f64 * sr1_xml_scale as f64 + y_center as f64 + dy;
let new_scale: f32 = render_scale * global_scale as f32; let new_scale: f32 = render_scale * global_scale as f32;
sprite.setattr(intern!(sprite.py(), "x"), new_x)?; sprite.setattr(intern!(sprite.py(), "x"), new_x)?;
sprite.setattr(intern!(sprite.py(), "y"), new_y)?; sprite.setattr(intern!(sprite.py(), "y"), new_y)?;
sprite.setattr(intern!(sprite.py(), "scale"), new_scale)?; sprite.setattr(intern!(sprite.py(), "scale"), new_scale)?;
part_sprites.set_item(keys.0, sprite)?; // part_sprites.set_item(keys.0, sprite)?;
// println!("{}", keys.0); // println!("{}", keys.0);
} }
render.setattr(intern!(render.py(), "parts_sprite"), part_sprites)?; // render.setattr(intern!(render.py(), "parts_sprite"), part_sprites)?;
println!("dx: {} dy: {} scale: {}", dx, dy, render_scale); // println!("dx: {} dy: {} scale: {}", dx, dy, render_scale);
Ok(true) Ok(true)
} }