好耶! 现在ok了 缩放! 0.7.1.0!
This commit is contained in:
parent
0a95312c12
commit
00d41941dd
@ -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
|
||||
|
@ -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:
|
||||
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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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}"
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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`
|
||||
|
||||
|
@ -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<bool>,
|
||||
pub drag: Option<f64>,
|
||||
pub hidden: Option<bool>,
|
||||
pub buoyancy: Option<f64>
|
||||
pub buoyancy: Option<f64>,
|
||||
#[serde(rename = "@Shape")]
|
||||
pub shapes: Option<Vec<Vertex>>
|
||||
}
|
||||
|
||||
#[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<String>) -> PyResult<()> {
|
||||
pub fn read_part_list_py(_py: Python, file_name: Option<String>) -> 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(())
|
||||
}
|
||||
|
||||
|
@ -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"}
|
||||
|
Loading…
Reference in New Issue
Block a user