add group for sr1 render
This commit is contained in:
parent
5958a14d47
commit
61b45fac7f
@ -223,8 +223,7 @@ class ClientWindow(Window):
|
||||
self.SPF = Decimal('1') / self.FPS
|
||||
self.fps_log = FpsLogger(stable_fps=int(self.FPS))
|
||||
# batch
|
||||
self.part_batch = Batch()
|
||||
self.label_batch = Batch()
|
||||
self.main_batch = Batch()
|
||||
self.main_group = Group(0)
|
||||
# frame
|
||||
self.frame = pyglet.gui.Frame(self, order=20)
|
||||
@ -233,10 +232,8 @@ class ClientWindow(Window):
|
||||
# setup
|
||||
self.setup()
|
||||
# 命令显示
|
||||
self.command_batch = Batch()
|
||||
self.command_group = Group(1, parent=self.main_group)
|
||||
self.input_box = TextEntry(x=50, y=30, width=300,
|
||||
batch=self.command_batch, text='') # 实例化
|
||||
batch=self.main_batch, text='', group=Group(1000, parent=self.main_group)) # 实例化
|
||||
self.input_box.push_handlers(self)
|
||||
self.input_box.set_handler('on_commit', self.on_input)
|
||||
self.set_handlers(self.input_box)
|
||||
@ -269,9 +266,9 @@ class ClientWindow(Window):
|
||||
try:
|
||||
pyglet.app.event_loop.run(1 / self.main_config['runtime']['fps'])
|
||||
except KeyboardInterrupt:
|
||||
self.logger.warn("==========client stop. KeyboardInterrupt info==========")
|
||||
self.logger.warning("==========client stop. KeyboardInterrupt info==========")
|
||||
traceback.print_exc()
|
||||
self.logger.warn("==========client stop. KeyboardInterrupt info end==========")
|
||||
self.logger.warning("==========client stop. KeyboardInterrupt info end==========")
|
||||
self.dispatch_event("on_close", 'input')
|
||||
sys.exit(0)
|
||||
|
||||
@ -305,10 +302,6 @@ class ClientWindow(Window):
|
||||
now_FPS = pyglet.clock.get_frequency()
|
||||
self.fps_log.update_tick(now_FPS, decimal_tick)
|
||||
|
||||
def on_command_draw(self):
|
||||
self.command_batch.draw()
|
||||
|
||||
@_call_back(on_command_draw)
|
||||
@_call_screen_after
|
||||
def on_draw(self, *dt):
|
||||
while (command := self.game.console.get_command()) is not None:
|
||||
@ -337,10 +330,9 @@ class ClientWindow(Window):
|
||||
# self.set_location(*self.get_location())
|
||||
print('on hide!')
|
||||
|
||||
@_call_screen_after
|
||||
@_call_screen_before
|
||||
def draw_batch(self):
|
||||
self.part_batch.draw()
|
||||
self.label_batch.draw()
|
||||
self.main_batch.draw()
|
||||
|
||||
"""
|
||||
command line event
|
||||
|
@ -7,8 +7,8 @@ fonts_folder = "libs/fonts"
|
||||
|
||||
[window]
|
||||
style = "None"
|
||||
width = 1032
|
||||
height = 735
|
||||
width = 1268
|
||||
height = 1031
|
||||
visible = true
|
||||
gui_scale = 1
|
||||
caption = "Difficult Rocket v{DR_version}"
|
||||
|
@ -17,7 +17,7 @@ from Difficult_Rocket.api.mod import ModInfo
|
||||
from Difficult_Rocket.client import ClientWindow
|
||||
from Difficult_Rocket.api.types import Options, Version
|
||||
|
||||
DR_rust_version = Version("0.2.15.") # DR_mod 的 Rust 编写部分的兼容版本
|
||||
DR_rust_version = Version("0.2.15.1") # DR_mod 的 Rust 编写部分的兼容版本
|
||||
|
||||
logger = logging.getLogger('client.dr_game')
|
||||
|
||||
|
@ -107,10 +107,8 @@ class SR1ShipRender(BaseScreen):
|
||||
# self.xml_doc: ElementTree = parse('configs/dock1.xml')
|
||||
# self.xml_root: ElementTree.Element = self.xml_doc.getroot()
|
||||
self.load_xml('configs/dock1.xml')
|
||||
self.part_box_batch = Batch()
|
||||
self.part_batch = Batch()
|
||||
self.part_group = Group(2)
|
||||
self.part_line_group = Group(1, parent=self.part_group)
|
||||
self.main_batch = Batch()
|
||||
self.part_group = Group(10, parent=main_window.main_group)
|
||||
self.debug_label = Label(x=20, y=main_window.height - 100, font_size=DR_status.std_font_size,
|
||||
text='SR1 render!', font_name=Fonts.微软等宽无线,
|
||||
width=main_window.width - 20, height=20,
|
||||
@ -163,7 +161,7 @@ class SR1ShipRender(BaseScreen):
|
||||
# 你就这里改吧
|
||||
cache_sprite = Sprite(img=self.textures.get_texture(part.textures),
|
||||
x=render_x, y=render_y, z=random.random(),
|
||||
batch=self.part_batch, group=self.part_group)
|
||||
batch=self.main_batch, group=self.part_group)
|
||||
# 你得帮我换算一下 XML 里的 x y 和这里的屏幕像素的关系(OK
|
||||
# 旋转啥的不是大问题, 我找你要那个渲染代码就是要 x y 的换算逻辑
|
||||
cache_sprite.rotation = SR1Rotation.get_rotation(part.angle)
|
||||
@ -176,6 +174,7 @@ class SR1ShipRender(BaseScreen):
|
||||
self.parts_sprite[part.id] = cache_sprite
|
||||
|
||||
if DR_mod_runtime.use_DR_rust:
|
||||
line_box_group = Group(6, parent=self.part_group)
|
||||
part_debug_box = self.rust_ship.get_part_box(part.id)
|
||||
if part_debug_box:
|
||||
# 线框
|
||||
@ -184,16 +183,16 @@ class SR1ShipRender(BaseScreen):
|
||||
color = (random.randrange(0, 255), random.randrange(0, 255), random.randrange(0, 255), random.randrange(100, 200))
|
||||
part_line_box.append(Line(x=part_debug_box[0][0] * 30, y=part_debug_box[0][1] * 30,
|
||||
x2=part_debug_box[0][0] * 30, y2=part_debug_box[1][1] * 30,
|
||||
batch=self.part_box_batch, width=width, color=color))
|
||||
batch=self.main_batch, width=width, color=color, group=line_box_group))
|
||||
part_line_box.append(Line(x=part_debug_box[0][0] * 30, y=part_debug_box[1][1] * 30,
|
||||
x2=part_debug_box[1][0] * 30, y2=part_debug_box[1][1] * 30,
|
||||
batch=self.part_box_batch, width=width, color=color))
|
||||
batch=self.main_batch, width=width, color=color, group=line_box_group))
|
||||
part_line_box.append(Line(x=part_debug_box[1][0] * 30, y=part_debug_box[1][1] * 30,
|
||||
x2=part_debug_box[1][0] * 30, y2=part_debug_box[0][1] * 30,
|
||||
batch=self.part_box_batch, width=width, color=color))
|
||||
batch=self.main_batch, width=width, color=color, group=line_box_group))
|
||||
part_line_box.append(Line(x=part_debug_box[1][0] * 30, y=part_debug_box[0][1] * 30,
|
||||
x2=part_debug_box[0][0] * 30, y2=part_debug_box[0][1] * 30,
|
||||
batch=self.part_box_batch, width=width, color=color))
|
||||
batch=self.main_batch, width=width, color=color, group=line_box_group))
|
||||
self.part_line_box[part.id] = part_line_box
|
||||
# if not part_render: # 如果不渲染(渲染有毛病)
|
||||
# self.parts_sprite[part.id].visible = False
|
||||
@ -202,6 +201,7 @@ class SR1ShipRender(BaseScreen):
|
||||
count = 0
|
||||
yield each_count
|
||||
if DR_mod_runtime.use_DR_rust:
|
||||
connect_line_group = Group(5, parent=self.part_group)
|
||||
for connect in self.rust_ship.connection:
|
||||
# 连接线
|
||||
parent_part_data = self.part_data[connect[2]]
|
||||
@ -209,7 +209,7 @@ class SR1ShipRender(BaseScreen):
|
||||
color = (random.randrange(100, 255), random.randrange(0, 255), random.randrange(0, 255), 255)
|
||||
self.part_line_list.append(Line(x=parent_part_data.x * 60, y=parent_part_data.y * 60,
|
||||
x2=child_part_data.x * 60, y2=child_part_data.y * 60,
|
||||
batch=self.part_batch, group=self.part_line_group,
|
||||
batch=self.main_batch, group=connect_line_group,
|
||||
width=1, color=color))
|
||||
count += 1
|
||||
if count >= each_count:
|
||||
@ -262,6 +262,10 @@ class SR1ShipRender(BaseScreen):
|
||||
self.window_pointer.height / 2) + 10, 0
|
||||
self.need_update_parts = False
|
||||
|
||||
def draw_batch(self, window: "ClientWindow"):
|
||||
with self.camera:
|
||||
self.main_batch.draw()
|
||||
|
||||
def on_draw(self, window: "ClientWindow"):
|
||||
if self.need_draw:
|
||||
self.render_ship()
|
||||
@ -277,11 +281,6 @@ class SR1ShipRender(BaseScreen):
|
||||
self.update_parts()
|
||||
self.need_update_parts = False
|
||||
|
||||
with self.camera:
|
||||
self.part_box_batch.draw()
|
||||
self.part_batch.draw()
|
||||
self.part_box_batch.draw()
|
||||
|
||||
self.debug_label.draw()
|
||||
|
||||
if SR1ShipRender_Option.debug_mouse_d_pos:
|
||||
|
Loading…
Reference in New Issue
Block a user