fetch up with DR
This commit is contained in:
parent
09e386e0fe
commit
692483320b
@ -167,6 +167,8 @@ class GroupCamera(Group):
|
|||||||
@zoom.setter
|
@zoom.setter
|
||||||
def zoom(self, value: float):
|
def zoom(self, value: float):
|
||||||
self._zoom = value
|
self._zoom = value
|
||||||
|
self._zoom_x = self._zoom
|
||||||
|
self._zoom_y = self._zoom
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self._view_x = 0
|
self._view_x = 0
|
||||||
|
@ -80,7 +80,11 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.buffer.attach_texture(self.render_texture)
|
self.buffer.attach_texture(self.render_texture)
|
||||||
|
|
||||||
self.main_batch = Batch()
|
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.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,
|
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.微软等宽无线,
|
self.render_d_label = Label('debug label NODATA', font_name=Fonts.微软等宽无线,
|
||||||
x=main_window.width / 2, y=main_window.height / 2)
|
x=main_window.width / 2, y=main_window.height / 2)
|
||||||
self.render_d_label.visible = self.status.draw_d_pos
|
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
|
# Optional data
|
||||||
self.textures: SR1Textures = SR1Textures()
|
self.textures: SR1Textures = SR1Textures()
|
||||||
@ -253,9 +256,7 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.parts_sprite: Dict[int, Sprite] = {}
|
self.parts_sprite: Dict[int, Sprite] = {}
|
||||||
self.part_line_box = {}
|
self.part_line_box = {}
|
||||||
self.part_line_list = []
|
self.part_line_list = []
|
||||||
self.camera.zoom = 1.0
|
self.group_camera.reset()
|
||||||
self.camera.dx = 0
|
|
||||||
self.camera.dy = 0
|
|
||||||
# 调用生成器 减少卡顿
|
# 调用生成器 减少卡顿
|
||||||
try:
|
try:
|
||||||
self.gen_draw = self.gen_sprite()
|
self.gen_draw = self.gen_sprite()
|
||||||
@ -275,11 +276,11 @@ class SR1ShipRender(BaseScreen):
|
|||||||
|
|
||||||
def draw_batch(self, window: "ClientWindow"):
|
def draw_batch(self, window: "ClientWindow"):
|
||||||
if self.status.draw_done:
|
if self.status.draw_done:
|
||||||
self.render_d_label.text = f'x: {self.camera.dx} y: {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.camera.dx + (self.window_pointer.width / 2), self.camera.dy + (
|
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.window_pointer.height / 2) + 10, 0 # 0 for z
|
||||||
self.render_d_line.x2 = self.camera.dx
|
self.render_d_line.x2 = self.group_camera.view_x
|
||||||
self.render_d_line.y2 = self.camera.dy
|
self.render_d_line.y2 = self.group_camera.view_y
|
||||||
self.buffer.bind()
|
self.buffer.bind()
|
||||||
window.clear()
|
window.clear()
|
||||||
self.main_batch.draw() # use group camera, no need to with
|
self.main_batch.draw() # use group camera, no need to with
|
||||||
|
Loading…
Reference in New Issue
Block a user