ready for rust render
This commit is contained in:
parent
42dfd60ce9
commit
d22a5389e7
@ -3,6 +3,9 @@ name = "difficult_rocket_rs"
|
|||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license-file = '../../LICENSE'
|
license-file = '../../LICENSE'
|
||||||
|
authors = [
|
||||||
|
"shenjackyuanjie <3695888@qq.com>"
|
||||||
|
]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
@ -97,6 +97,8 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.render_option = SR1ShipRender_Option()
|
self.render_option = SR1ShipRender_Option()
|
||||||
self.dx = 0
|
self.dx = 0
|
||||||
self.dy = 0
|
self.dy = 0
|
||||||
|
self.width = main_window.width
|
||||||
|
self.height = main_window.height
|
||||||
|
|
||||||
self.main_batch = Batch()
|
self.main_batch = Batch()
|
||||||
self.part_group = Group(10, parent=main_window.main_group)
|
self.part_group = Group(10, parent=main_window.main_group)
|
||||||
@ -112,6 +114,7 @@ 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.render_option.debug_d_pos
|
self.render_d_label.visible = self.render_option.debug_d_pos
|
||||||
|
self.camera = CenterCamera(main_window, min_zoom=(1 / 2) ** 10, max_zoom=10)
|
||||||
|
|
||||||
# Optional data
|
# Optional data
|
||||||
self.gen_draw: Optional[Generator] = None
|
self.gen_draw: Optional[Generator] = None
|
||||||
@ -128,16 +131,15 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.part_line_box: Dict[int, List[Line]] = {}
|
self.part_line_box: Dict[int, List[Line]] = {}
|
||||||
self.part_line_list: List[Line] = []
|
self.part_line_list: List[Line] = []
|
||||||
|
|
||||||
|
|
||||||
load_end_time = time.time_ns()
|
|
||||||
logger.info(sr_tr().mod.info.setup.use_time().format((load_end_time - load_start_time) / 1000000000))
|
|
||||||
self.camera = CenterCamera(main_window, min_zoom=(1 / 2) ** 10, max_zoom=10)
|
|
||||||
if DR_mod_runtime.use_DR_rust:
|
if DR_mod_runtime.use_DR_rust:
|
||||||
self.rust_parts = None
|
self.rust_parts = None
|
||||||
self.part_list_rs = SR1PartList_rs('assets/builtin/PartList.xml', 'builtin_part_list')
|
self.part_list_rs = SR1PartList_rs('assets/builtin/PartList.xml', 'builtin_part_list')
|
||||||
|
|
||||||
self.load_xml('assets/builtin/dock1.xml')
|
self.load_xml('assets/builtin/dock1.xml')
|
||||||
|
|
||||||
|
load_end_time = time.time_ns()
|
||||||
|
logger.info(sr_tr().mod.info.setup.use_time().format((load_end_time - load_start_time) / 1000000000))
|
||||||
|
|
||||||
def load_xml(self, file_path: str) -> bool:
|
def load_xml(self, file_path: str) -> bool:
|
||||||
"""
|
"""
|
||||||
加载 xml 文件
|
加载 xml 文件
|
||||||
@ -178,25 +180,29 @@ class SR1ShipRender(BaseScreen):
|
|||||||
"""
|
"""
|
||||||
count = 0
|
count = 0
|
||||||
self.drawing = True
|
self.drawing = True
|
||||||
|
# rust 渲染
|
||||||
|
|
||||||
|
|
||||||
|
# python 渲染
|
||||||
for part_id, part in part_datas.items():
|
for part_id, part in part_datas.items():
|
||||||
# 下面就是调用 pyglet 去渲染的部分
|
# 下面就是调用 pyglet 去渲染的部分
|
||||||
# render_scale = DR_status.gui_scale # 这个是 DR 的缩放比例 可以调节的
|
# render_scale = DR_status.gui_scale # 这个是 DR 的缩放比例 可以调节的
|
||||||
# 在不缩放的情况下,XML的1个单位长度对应60个像素
|
# 在不缩放的情况下,XML的1个单位长度对应60个像素
|
||||||
render_x = part.x * 60
|
# render_x = part.x * 60
|
||||||
render_y = part.y * 60
|
# render_y = part.y * 60
|
||||||
cache_sprite = Sprite(img=self.textures.get_texture(part.textures),
|
# cache_sprite = Sprite(img=self.textures.get_texture(part.textures),
|
||||||
x=render_x, y=render_y, z=random.random(),
|
# x=render_x, y=render_y, z=random.random(),
|
||||||
batch=self.main_batch, group=self.part_group)
|
# batch=self.main_batch, group=self.part_group)
|
||||||
# 你得帮我换算一下 XML 里的 x y 和这里的屏幕像素的关系(OK
|
# # 你得帮我换算一下 XML 里的 x y 和这里的屏幕像素的关系
|
||||||
# 旋转啥的不是大问题, 我找你要那个渲染代码就是要 x y 的换算逻辑
|
# # 旋转啥的不是大问题, 我找你要那个渲染代码就是要 x y 的换算逻辑
|
||||||
cache_sprite.rotation = SR1Rotation.get_rotation(part.angle)
|
# cache_sprite.rotation = SR1Rotation.get_rotation(part.angle)
|
||||||
if part.flip_x:
|
# if part.flip_x:
|
||||||
cache_sprite.scale_x = -1
|
# cache_sprite.scale_x = -1
|
||||||
if part.flip_y:
|
# if part.flip_y:
|
||||||
cache_sprite.scale_y = -1
|
# cache_sprite.scale_y = -1
|
||||||
cache_sprite.x = cache_sprite.x - cache_sprite.scale_x / 2
|
# cache_sprite.x = cache_sprite.x - cache_sprite.scale_x / 2
|
||||||
cache_sprite.y = cache_sprite.y - cache_sprite.scale_y / 2
|
# cache_sprite.y = cache_sprite.y - cache_sprite.scale_y / 2
|
||||||
self.parts_sprite[part.id] = cache_sprite
|
# self.parts_sprite[part.id] = cache_sprite
|
||||||
|
|
||||||
if DR_mod_runtime.use_DR_rust:
|
if DR_mod_runtime.use_DR_rust:
|
||||||
line_box_group = Group(6, parent=self.part_group)
|
line_box_group = Group(6, parent=self.part_group)
|
||||||
|
Loading…
Reference in New Issue
Block a user