Compare commits
No commits in common. "18b8ba153144d56a597e8a4e8df912ae2eee38a7" and "15380d4fb7eb538fb24d52dfedef85798c998c81" have entirely different histories.
18b8ba1531
...
15380d4fb7
@ -8,7 +8,7 @@ from pathlib import Path
|
||||
|
||||
from Difficult_Rocket.api.types import Options, Version
|
||||
|
||||
sdk_version = Version("0.9.1.0") # SDK 版本
|
||||
sdk_version = Version("0.9.0.1") # SDK 版本
|
||||
build_version = Version("3.0.0.0") # 编译文件版本(与游戏本体无关)
|
||||
api_version = Version("0.1.2.1") # API 版本
|
||||
__version__ = sdk_version
|
||||
|
@ -341,11 +341,8 @@ class ClientWindow(Window):
|
||||
def add_sub_screen(self, title: str, sub_screen: Type[BaseScreen]):
|
||||
self.screen_list[title] = sub_screen(self)
|
||||
|
||||
def remove_sub_screen(self, title: str) -> BaseScreen:
|
||||
"""
|
||||
去除一个页面, 返回被去掉的页面
|
||||
"""
|
||||
return self.screen_list.pop(title)
|
||||
def remove_sub_screen(self, title: str):
|
||||
self.screen_list.pop(title)
|
||||
|
||||
"""
|
||||
draws and some event
|
||||
|
@ -19,8 +19,7 @@ setup(
|
||||
RustExtension(
|
||||
target="Difficult_Rocket_rs.Difficult_Rocket_rs",
|
||||
binding=Binding.PyO3,
|
||||
rustc_flags=["-Ctarget-cpu=native"],
|
||||
strip=Strip.No,
|
||||
strip=Strip.All,
|
||||
)
|
||||
],
|
||||
zip_safe=False,
|
||||
|
@ -115,6 +115,9 @@ class DR_mod(ModInfo): # NOQA
|
||||
client.add_sub_screen("DR_game_menu", Menu)
|
||||
logger.info("added dr_game_menu screen", tag="dr_game")
|
||||
|
||||
# client.add_sub_screen("SR1_ship", SR1ShipRender)
|
||||
# logger.info("added SR1_ship screen", tag="dr_game")
|
||||
|
||||
def on_unload(self, game: Game):
|
||||
game.client.window.screen_list.pop("SR1_ship")
|
||||
|
||||
|
@ -38,7 +38,6 @@ class Menu(BaseScreen):
|
||||
# 占位, 高二看看能不能咕出来点啥 (20230911)
|
||||
# 欸呀, 正好是 911 纪念日哦
|
||||
# 好, 高二 第一学期 期末都考完了, 我过来做测试了 (20240119)
|
||||
# 高二, 马上要研学了, 似乎做了点啥, 但似乎又没做点啥 (20240526)
|
||||
|
||||
# self.wiki_button1 = PressTextButton(
|
||||
# x=200,
|
||||
@ -127,7 +126,7 @@ class PressEnterShipEditorButton(PressTextButton):
|
||||
batch: Optional[Batch] = None,
|
||||
group: Optional[Group] = None,
|
||||
theme: Optional[ButtonThemeOptions] = None,
|
||||
draw_theme: Optional[BaseButtonTheme] = None,
|
||||
draw_theme: Optional[type(BaseButtonTheme)] = None,
|
||||
dict_theme: Optional[dict] = None,
|
||||
):
|
||||
super().__init__(
|
||||
|
@ -16,7 +16,7 @@ from pyglet.math import Mat4
|
||||
from pyglet.text import Label
|
||||
from pyglet.sprite import Sprite
|
||||
from pyglet.graphics import Batch, Group
|
||||
from pyglet.shapes import Line, Box
|
||||
from pyglet.shapes import Line, Rectangle
|
||||
|
||||
from . import DR_mod_runtime
|
||||
from .types import SR1Textures, SR1Rotation
|
||||
@ -121,8 +121,8 @@ class SR1ShipRender(BaseScreen):
|
||||
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
|
||||
|
||||
@ -133,7 +133,8 @@ class SR1ShipRender(BaseScreen):
|
||||
self.ship_name: Optional[str] = None
|
||||
|
||||
# List/Dict data
|
||||
self.part_sprites: Dict[int, Tuple[Sprite, Box]] = {}
|
||||
self.part_sprites: Dict[int, List[Sprite]] = {}
|
||||
self.part_box_dict: Dict[int, Rectangle] = {}
|
||||
self.part_outlines: Dict[int, List[Line]] = {}
|
||||
self.connection_lines: List[Line] = []
|
||||
|
||||
@ -195,7 +196,7 @@ class SR1ShipRender(BaseScreen):
|
||||
part_group: Group,
|
||||
line_group: Group,
|
||||
batch: Batch,
|
||||
) -> Tuple[Sprite, Box]:
|
||||
) -> Tuple[Sprite, List[Line]]:
|
||||
"""
|
||||
还是重写一下渲染逻辑
|
||||
把渲染单个部件的逻辑提取出来放到这里
|
||||
@ -218,20 +219,58 @@ class SR1ShipRender(BaseScreen):
|
||||
random.randrange(0, 255),
|
||||
200,
|
||||
)
|
||||
part_line_box = []
|
||||
width = 4
|
||||
(x, y), (x2, y2) = part_data.get_part_box_by_type(part_type)
|
||||
box = Box(
|
||||
x=x * 30,
|
||||
y=y * 30,
|
||||
width=part_type.width * 30,
|
||||
height=part_type.height * 30,
|
||||
thickness=width,
|
||||
color=line_colors,
|
||||
batch=batch,
|
||||
group=line_group,
|
||||
part_line_box.append(
|
||||
Line(
|
||||
x=x * 30,
|
||||
y=y * 30,
|
||||
x2=x * 30,
|
||||
y2=y2 * 30,
|
||||
batch=batch,
|
||||
width=width,
|
||||
color=line_colors,
|
||||
group=line_group,
|
||||
)
|
||||
)
|
||||
box.rotation = part_data.angle_r
|
||||
return part_sprite, box
|
||||
part_line_box.append(
|
||||
Line(
|
||||
x=x * 30,
|
||||
y=y2 * 30,
|
||||
x2=x2 * 30,
|
||||
y2=y2 * 30,
|
||||
batch=batch,
|
||||
width=width,
|
||||
color=line_colors,
|
||||
group=line_group,
|
||||
)
|
||||
)
|
||||
part_line_box.append(
|
||||
Line(
|
||||
x=x2 * 30,
|
||||
y=y2 * 30,
|
||||
x2=x2 * 30,
|
||||
y2=y * 30,
|
||||
batch=batch,
|
||||
width=width,
|
||||
color=line_colors,
|
||||
group=line_group,
|
||||
)
|
||||
)
|
||||
part_line_box.append(
|
||||
Line(
|
||||
x=x2 * 30,
|
||||
y=y * 30,
|
||||
x2=x * 30,
|
||||
y2=y * 30,
|
||||
batch=batch,
|
||||
width=width,
|
||||
color=line_colors,
|
||||
group=line_group,
|
||||
)
|
||||
)
|
||||
return part_sprite, part_line_box
|
||||
|
||||
def sprite_batch(self, draw_batch: int = 100) -> Generator:
|
||||
"""
|
||||
@ -244,7 +283,6 @@ class SR1ShipRender(BaseScreen):
|
||||
self.status.draw_done = False
|
||||
# rust 渲染
|
||||
if DR_mod_runtime.use_DR_rust:
|
||||
self.rust_ship: SR1Ship_rs
|
||||
# 2 先渲染
|
||||
# 6 后渲染
|
||||
# 保证部件不会遮盖住连接线
|
||||
@ -254,11 +292,13 @@ class SR1ShipRender(BaseScreen):
|
||||
# 渲染连接的部件
|
||||
for part_type, part_data in self.rust_ship.as_list():
|
||||
# 渲染部件
|
||||
part_sprite, part_box = self.part_render_init(
|
||||
part_sprite, part_line_box = self.part_render_init(
|
||||
part_data, part_type, part_group, line_group, self.main_batch
|
||||
)
|
||||
part_box.opacity = 100
|
||||
self.part_sprites[part_data.id] = (part_sprite, part_box)
|
||||
for line in part_line_box:
|
||||
line.opacity = 100
|
||||
self.part_sprites[part_data.id] = part_sprite
|
||||
self.part_outlines[part_data.id] = part_line_box
|
||||
# TODO: 连接线渲染
|
||||
count += 2
|
||||
if count >= draw_batch:
|
||||
@ -266,17 +306,19 @@ class SR1ShipRender(BaseScreen):
|
||||
count = 0
|
||||
|
||||
# 渲染未连接的部件
|
||||
for part_groups, part_connections in self.rust_ship.disconnected_parts():
|
||||
for part_type, part_data in part_groups[0]:
|
||||
for part_group, part_connections in self.rust_ship.disconnected_parts():
|
||||
for part_type, part_data in part_group[0]:
|
||||
# 未连接的需要同时把连接线也给渲染了
|
||||
# TODO: 连接线渲染
|
||||
part_sprite, part_box = self.part_render_init(
|
||||
part_sprite, part_line_box = self.part_render_init(
|
||||
part_data, part_type, part_group, line_group, self.main_batch
|
||||
)
|
||||
part_box.opacity = 100
|
||||
for line in part_line_box:
|
||||
line.opacity = 100
|
||||
# 未连接的部件透明度降低
|
||||
part_sprite.opacity = 100
|
||||
self.part_sprites[part_data.id] = (part_sprite, part_box)
|
||||
self.part_sprites[part_data.id] = part_sprite
|
||||
self.part_outlines[part_data.id] = part_line_box
|
||||
count += 2
|
||||
if count >= draw_batch:
|
||||
yield count
|
||||
@ -319,7 +361,8 @@ class SR1ShipRender(BaseScreen):
|
||||
self.status.draw_done = False
|
||||
logger.info(sr_tr().sr1.ship.ship.load().format(self.ship_name), tag="ship")
|
||||
start_time = time.perf_counter_ns()
|
||||
self.part_sprites = {}
|
||||
self.part_sprites: Dict[int, Sprite] = {}
|
||||
self.part_outlines: Dict[int, List[Line]] = {}
|
||||
self.connection_lines: List[Line] = []
|
||||
self.group_camera.reset()
|
||||
# 调用生成器 减少卡顿
|
||||
|
@ -1,16 +1,13 @@
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import os
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
# script -py <py_version> (3.8 ~ 3.12)
|
||||
parser.add_argument("-py", type=str, help="python version")
|
||||
parser.add_argument("-all", help="用所有的python版本编译", action="store_true")
|
||||
parser.add_argument("-clean", help="清理编译文件", action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -20,16 +17,8 @@ if __name__ == "__main__":
|
||||
|
||||
subprocess.run(["cargo", "fmt", "--all"])
|
||||
|
||||
if args.clean:
|
||||
subprocess.run(["cargo", "clean"])
|
||||
|
||||
os.chdir("../")
|
||||
|
||||
if args.clean:
|
||||
subprocess.run([sys.executable, "setup.py", "clean"])
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
if not args.py:
|
||||
if args.all:
|
||||
all_version = ("38", "39", "310", "311", "312")
|
||||
|
Loading…
Reference in New Issue
Block a user