Compare commits

..

2 Commits

Author SHA1 Message Date
aa8af9ebef
DR sdk 0.8.7.0 2023-08-12 01:49:01 +08:00
692483320b
fetch up with DR 2023-08-12 01:20:24 +08:00
6 changed files with 49 additions and 16 deletions

View File

@ -10,7 +10,7 @@ from pathlib import Path
from Difficult_Rocket.api.types import Options, Version
sdk_version = Version("0.8.6.0") # SDK 版本
sdk_version = Version("0.8.7.0") # SDK 版本
build_version = Version("2.1.3.0") # 编译文件版本(与游戏本体无关)
Api_version = Version("0.1.1.0") # API 版本
__version__ = sdk_version

View File

@ -167,11 +167,13 @@ class GroupCamera(Group):
@zoom.setter
def zoom(self, value: float):
self._zoom = value
self._zoom_x = self._zoom
self._zoom_y = self._zoom
def reset(self):
self._view_x = 0
self._view_y = 0
self._zoom = 1
self.zoom = 1
def set_state(self):
self._previous_view = self._window.view

View File

@ -2,9 +2,16 @@
# DR game/DR rs 更新日志
- 最新版本号
- DR game: 0.3.2.1
- DR game: 0.3.3.0
- DR rs: 0.2.21.0
## 20230812 DR game 0.3.3.0
### Changes
- 将 `sr1_ship` 渲染器使用的 Camera 改成 `CenterGroupCamera`
- 删除了之前的 Camera 相关代码
## 20230809 DR game 0.3.2.1
### Fix

View File

@ -2,7 +2,30 @@
# DR SDK 更新日志
- 最新版本号
- DR sdk: 0.8.6.0
- DR sdk: 0.8.7.0
- DR api: 0.1.1.0
## DR sdk 0.8.7.0
### Add
- 添加了 `Difficult_Rocket.utils.camera.GroupCamera`
- 和 `Difficult_Rocket.utils.camera.CenterGroupCamera`
- 实际上就是使用 `pyglet.graphics.Group` 来实现的 `Camera`
- 具有相同的功能
- 顺便同样在 `api.camera` 里添加了导出
- 这次我一定不会再忘记导出了
- Added `Difficult_Rocket.utils.camera.GroupCamera`
- And `Difficult_Rocket.utils.camera.CenterGroupCamera`
- Actually, it is implemented `Camera` using `pyglet.graphics.Group`
- Has the same function
- By the way, the export was also added in `api.camera`
- This time I will never forget to export it again
- 为所有 `xxCamera` 添加了
- `reset` 方法
- 用于一键重置缩放+平移
- Added `reset` method for all `xxCamera`
- Used to reset zoom + translation with one click
## DR sdk 0.8.6.1

View File

@ -53,7 +53,7 @@ DR_mod_runtime = _DR_mod_runtime()
class DR_mod(ModInfo): # NOQA
mod_id = "difficult_rocket_mod"
name = "Difficult Rocket mod"
version = Version("0.3.2.1")
version = Version("0.3.3.0")
writer = "shenjackyuanjie"
link = "shenjack.top"

View File

@ -20,15 +20,15 @@ from pyglet.shapes import Line, Rectangle
from pyglet.image import Framebuffer, Texture
from . import DR_mod_runtime
from .types import SR1Textures, SR1Rotation
# Difficult Rocket
from Difficult_Rocket import DR_status
from Difficult_Rocket.utils.translate import Tr
from Difficult_Rocket.api.camera import CenterCamera, CenterGroupCamera
from Difficult_Rocket.api.types import Fonts, Options
from Difficult_Rocket.command.line import CommandText
from Difficult_Rocket.client.screen import BaseScreen
from .types import SR1Textures, SR1Rotation
from Difficult_Rocket.api.camera import CenterGroupCamera
if TYPE_CHECKING:
from Difficult_Rocket.client import ClientWindow
@ -80,7 +80,11 @@ class SR1ShipRender(BaseScreen):
self.buffer.attach_texture(self.render_texture)
self.main_batch = Batch()
self.group_camera = CenterGroupCamera(window=main_window, order=10, parent=main_window.main_group)
self.group_camera = CenterGroupCamera(window=main_window,
order=10,
parent=main_window.main_group,
min_zoom=(1 / 2) ** 10,
max_zoom=10)
self.part_group = Group(0, parent=self.group_camera)
self.debug_label = Label(x=20, y=main_window.height - 100, font_size=DR_status.std_font_size,
@ -94,7 +98,6 @@ class SR1ShipRender(BaseScreen):
self.render_d_label = Label('debug label NODATA', font_name=Fonts.微软等宽无线,
x=main_window.width / 2, y=main_window.height / 2)
self.render_d_label.visible = self.status.draw_d_pos
self.camera = CenterCamera(main_window, min_zoom=(1 / 2) ** 10, max_zoom=10)
# Optional data
self.textures: SR1Textures = SR1Textures()
@ -253,9 +256,7 @@ class SR1ShipRender(BaseScreen):
self.parts_sprite: Dict[int, Sprite] = {}
self.part_line_box = {}
self.part_line_list = []
self.camera.zoom = 1.0
self.camera.dx = 0
self.camera.dy = 0
self.group_camera.reset()
# 调用生成器 减少卡顿
try:
self.gen_draw = self.gen_sprite()
@ -275,11 +276,11 @@ class SR1ShipRender(BaseScreen):
def draw_batch(self, window: "ClientWindow"):
if self.status.draw_done:
self.render_d_label.text = f'x: {self.camera.dx} y: {self.camera.dy}'
self.render_d_label.position = self.camera.dx + (self.window_pointer.width / 2), self.camera.dy + (
self.render_d_label.text = f'x: {self.group_camera.view_x} y: {self.group_camera.view_y}'
self.render_d_label.position = self.group_camera.view_x + (self.window_pointer.width / 2), self.group_camera.view_y + (
self.window_pointer.height / 2) + 10, 0 # 0 for z
self.render_d_line.x2 = self.camera.dx
self.render_d_line.y2 = self.camera.dy
self.render_d_line.x2 = self.group_camera.view_x
self.render_d_line.y2 = self.group_camera.view_y
self.buffer.bind()
window.clear()
self.main_batch.draw() # use group camera, no need to with