From 00d41941dd58c6611a9eed9bf468fdd9cae383a4 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 19 Feb 2023 21:02:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=BD=E8=80=B6=EF=BC=81=20=E7=8E=B0?= =?UTF-8?q?=E5=9C=A8ok=E4=BA=86=20=E7=BC=A9=E6=94=BE=EF=BC=81=200.7.1.0!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Difficult_Rocket/__init__.py | 2 +- Difficult_Rocket/client/render/sr1_ship.py | 57 ++++++++++++++++---- README.md | 6 +-- configs/main.toml | 4 +- docs/README-en.md | 6 +-- docs/src/update_logs.md | 6 ++- libs/Difficult_Rocket_rs/src/src/sr1_data.rs | 18 ++++--- pyproject.toml | 2 +- 8 files changed, 74 insertions(+), 27 deletions(-) diff --git a/Difficult_Rocket/__init__.py b/Difficult_Rocket/__init__.py index d05bb03..db2f6d7 100644 --- a/Difficult_Rocket/__init__.py +++ b/Difficult_Rocket/__init__.py @@ -22,7 +22,7 @@ from Difficult_Rocket.api.types import Options from libs.MCDR.version import Version -game_version = Version("0.7.0.3") # 游戏版本 +game_version = Version("0.7.1.0") # 游戏版本 build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关) DR_rust_version = Version("0.2.5.0") # DR 的 Rust 编写部分的版本 __version__ = game_version diff --git a/Difficult_Rocket/client/render/sr1_ship.py b/Difficult_Rocket/client/render/sr1_ship.py index b1be2b6..774f3b9 100644 --- a/Difficult_Rocket/client/render/sr1_ship.py +++ b/Difficult_Rocket/client/render/sr1_ship.py @@ -14,6 +14,7 @@ from typing import List, TYPE_CHECKING, Union, Dict, Optional, Callable, Generat from defusedxml.ElementTree import parse # pyglet +from pyglet.math import Vec4 from pyglet.text import Label from pyglet.shapes import Line from pyglet.sprite import Sprite @@ -82,7 +83,7 @@ class SR1ShipRender(BaseScreen): self.focus = True self.need_draw = False self.drawing = False - self.gen_draw: Optional[Callable] = None + self.gen_draw: Optional[Generator] = None self.need_update_parts = False self.dx = 0 self.dy = 0 @@ -117,7 +118,7 @@ class SR1ShipRender(BaseScreen): self.parts_sprite: Dict[int, Sprite] = {} if DR_option.use_DR_rust: self.camera_rs = Camera_rs(main_window, - min_zoom=(1 / 2) ** 6, max_zoom=10) + min_zoom=(1 / 2) ** 10, max_zoom=10) self.rust_parts = None def load_xml(self, file_path: str) -> bool: @@ -253,13 +254,50 @@ class SR1ShipRender(BaseScreen): return mouse_dx = x - (self.window_pointer.width / 2) mouse_dy = y - (self.window_pointer.height / 2) - self.debug_mouse_line.x2, self.debug_mouse_line.y2 = x, y - if self.camera_rs.zoom * (0.5 ** scroll_y) < 10: - self.camera_rs.zoom = self.camera_rs.zoom * (0.5 ** scroll_y) - self.camera_rs.dx += (mouse_dx - self.camera_rs.dx) * (1 - (0.5 ** scroll_y)) - self.camera_rs.dy += (mouse_dy - self.camera_rs.dy) * (1 - (0.5 ** scroll_y)) + # 鼠标缩放位置相对于屏幕中心的位置 + mouse_dx_d = mouse_dx - self.camera_rs.dx + mouse_dy_d = mouse_dy - self.camera_rs.dy + # 鼠标相对偏移量的偏移量 + if scroll_y > 0: + zoom_d = ((2 ** scroll_y) - 1) * 0.5 + 1 + elif scroll_y == 0: + zoom_d = 1 else: - self.camera_rs.zoom = 10 + zoom_d = ((2 ** scroll_y) - 1) * 0.5 + 1 + print(f"1: {self.camera_rs.zoom=} {self.camera_rs.dx} {self.camera_rs.dy} {scroll_y=}") + # 缩放的变换量 + print(f'{self.camera_rs.zoom * zoom_d=}') + if self.camera_rs.zoom == 10: + if scroll_y >= 0: + self.camera_rs.dx += mouse_dx_d * 0.5 + self.camera_rs.dy += mouse_dy_d * 0.5 + else: + self.camera_rs.zoom *= zoom_d + self.camera_rs.dx += mouse_dx_d + self.camera_rs.dy += mouse_dy_d + else: + mouse_dx_d *= (1 - zoom_d) + mouse_dy_d *= (1 - zoom_d) + self.camera_rs.zoom *= zoom_d + if self.camera_rs.zoom * zoom_d >= 10: + zoom_d = 10 / self.camera_rs.zoom + self.camera_rs.zoom = 10 + self.camera_rs.dx += mouse_dx_d + self.camera_rs.dy += mouse_dy_d + # if self.camera_rs.zoom / (0.5 ** (scroll_y * 0.5)) <= 10: + # self.camera_rs.zoom = self.camera_rs.zoom / zoom_d + # self.camera_rs.dx -= (mouse_dx - self.camera_rs.dx) * (1 - zoom_d) + # self.camera_rs.dy -= (mouse_dy - self.camera_rs.dy) * (1 - zoom_d) + # elif self.camera_rs.zoom == 10: + # self.camera_rs.dx -= mouse_dx * (0.1 ** scroll_y) + # self.camera_rs.dy -= mouse_dy * (0.1 ** scroll_y) + # else: + # self.camera_rs.zoom = 10 + # self.camera_rs.dx -= (mouse_dx - self.camera_rs.dx) * zoom_d + # self.camera_rs.dy -= (mouse_dy - self.camera_rs.dy) * zoom_d + + print(f"{self.camera_rs.zoom=} {self.camera_rs.dx} {self.camera_rs.dy} {scroll_y=}") + 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.debug_mouse_delta_line.y2 = (mouse_dy - self.camera_rs.dy) * (1 - (0.5 ** scroll_y)) + ( @@ -275,6 +313,7 @@ class SR1ShipRender(BaseScreen): self.camera_rs.zoom = 1 self.camera_rs.dx = 0 self.camera_rs.dy = 0 + self.window_pointer.view = Vec4() else: self.need_draw = True print('应该渲染飞船的') @@ -299,7 +338,7 @@ class SR1ShipRender(BaseScreen): def screenshot(window): from libs.pyglet.gl import GLubyte, GLint, GL_RGBA, GL_UNSIGNED_BYTE, \ - glReadPixels, glGetIntegerv + glReadPixels # from libs.pyglet.gl.gl_compat import GL_AUX_BUFFERS, GL_AUX0 import pyglet width = window.width diff --git a/README.md b/README.md index 7ca48ae..20c5b4e 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ ## 版本 -[![Generic badge](https://img.shields.io/badge/Release-0.7.0.2-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) -[![Generic badge](https://img.shields.io/badge/Pre_Release-0.7.0.2-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) -[![Generic badge](https://img.shields.io/badge/Devloping-0.7.1-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) +[![Generic badge](https://img.shields.io/badge/Release-0.7.1.0-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) +[![Generic badge](https://img.shields.io/badge/Pre_Release-0.7.1.0-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) +[![Generic badge](https://img.shields.io/badge/Devloping-0.7.2-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) ## English README please look [here](./docs/README-en.md) diff --git a/configs/main.toml b/configs/main.toml index f487571..fad0895 100644 --- a/configs/main.toml +++ b/configs/main.toml @@ -8,8 +8,8 @@ fonts_folder = "libs/fonts" [window] style = "None" -width = 1802 -height = 1211 +width = 1173 +height = 830 visible = true gui_scale = 1 caption = "Difficult Rocket v{DR_version}|DR_rs v{DR_Rust_get_version}" diff --git a/docs/README-en.md b/docs/README-en.md index f5fe3d3..ff1cad8 100644 --- a/docs/README-en.md +++ b/docs/README-en.md @@ -17,9 +17,9 @@ ## Version -[![Generic badge](https://img.shields.io/badge/Release-0.7.0.2-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) -[![Generic badge](https://img.shields.io/badge/Pre_Release-0.7.0.2-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) -[![Generic badge](https://img.shields.io/badge/Devloping-0.7.1-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) +[![Generic badge](https://img.shields.io/badge/Release-0.7.1.0-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) +[![Generic badge](https://img.shields.io/badge/Pre_Release-0.7.1.0-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) +[![Generic badge](https://img.shields.io/badge/Devloping-0.7.2-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases) ## 中文README请移步 [这里](../README.md) diff --git a/docs/src/update_logs.md b/docs/src/update_logs.md index 44db412..6847d80 100644 --- a/docs/src/update_logs.md +++ b/docs/src/update_logs.md @@ -10,14 +10,14 @@ ## Readme First! ##### most badge can be clicked and jump [![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/) -![Generic badge](https://img.shields.io/badge/Version-0.7.0.2-yellow.svg) +![Generic badge](https://img.shields.io/badge/Version-0.7.1.0-yellow.svg) - [![Readme-github](https://img.shields.io/badge/Readme-Github-blue.svg?style=flat-square&logo=Github)](https://github.com/shenjackyuanjie/Difficult-Rocket) - [![Readme-gitee](https://img.shields.io/badge/Readme-Gitee-blue.svg?style=flat-square&logo=Gitee)](https://gitee.com/shenjackyuanjie/Difficult-Rocket) - [![Readme-gitee](https://img.shields.io/badge/Readme-中文(点我!)-blue.svg?style=flat-square)](../../README.md) - Using [SemVer 2.0.0](https://semver.org/) to manage version -## 2023 V 0.7.0.3 +## 20230219 V 0.7.1.0 ### 命令 @@ -28,6 +28,8 @@ - 更改了 `ClientWindow` 启动参数的设置, 实装 ClientOption 的使用 - 将 `SR1PartData` 的字段 `type_` 重命名为 `p_type` +- 现在鼠标滚动更顺滑了 + ### `DR_Rs` diff --git a/libs/Difficult_Rocket_rs/src/src/sr1_data.rs b/libs/Difficult_Rocket_rs/src/src/sr1_data.rs index 322c00f..35ebc15 100644 --- a/libs/Difficult_Rocket_rs/src/src/sr1_data.rs +++ b/libs/Difficult_Rocket_rs/src/src/sr1_data.rs @@ -43,6 +43,12 @@ pub mod part_list { Satellite } + #[derive(Debug, Serialize, Deserialize, Clone)] + pub struct Vertex { + pub x: f64, + pub y: f64 + } + #[derive(Debug, Serialize, Deserialize, Clone)] pub struct PartType { pub id: String, @@ -67,7 +73,9 @@ pub mod part_list { pub sandbox_only: Option, pub drag: Option, pub hidden: Option, - pub buoyancy: Option + pub buoyancy: Option, + #[serde(rename = "@Shape")] + pub shapes: Option> } #[inline] @@ -87,12 +95,10 @@ pub mod part_list { #[pyfunction] #[pyo3(name = "part_list_read_test", signature = (file_name = "./configs/PartList.xml".to_string()))] - pub fn read_part_list_py(file_name: Option) -> PyResult<()> { + pub fn read_part_list_py(_py: Python, file_name: Option) -> PyResult<()> { let file_name = file_name.unwrap_or("./configs/PartList.xml".to_string()); - let parts = read_part_list(file_name); - if let Some(parts) = parts { - println!("{:?}", parts); - } + // let parts = read_part_list(file_name); + read_part_list(file_name); Ok(()) } diff --git a/pyproject.toml b/pyproject.toml index 9a60e0c..2d36fab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "pdm.pep517.api" [project] name = "difficult-rocket" -version = "0.7.0.2" +version = "0.7.1.0" description = "A rocket game" authors = [ {name = "shenjackyuanjie", email = "3695888@qq.com"}