Compare commits

..

16 Commits

Author SHA1 Message Date
12c974c825
呐呐呐 2024-08-01 01:51:45 +08:00
931852dc98
稍微重命名一下 2024-07-31 22:51:35 +08:00
c6ad46a81f
加上 color 的定义,覆盖一下 super 2024-07-31 19:17:35 +08:00
9c1149dea8
ruaaaa 2024-07-31 19:04:55 +08:00
2ea9019afa
aaaa 2024-07-29 23:43:00 +08:00
a7517173f9
添加 highlight 2024-07-29 23:06:14 +08:00
6fa7809aa6
好好好 2024-07-29 18:54:26 +08:00
443fbefbee
这个shape可算是写完了(泪 2024-07-29 18:12:54 +08:00
e6a3a46734
进行一个按钮的写 2024-07-28 10:39:13 +08:00
6490ace480
死灵法师出现了! wtm! 2024-07-28 08:05:05 +08:00
695fad3c24
clockwise? 2024-07-27 03:35:27 +08:00
114f3c6e6a
property 2024-07-27 03:31:54 +08:00
7b1b9202c6
就是说……
太长了点
2024-07-27 03:23:40 +08:00
d191a3650c
修复了目前的一些问题(就是懒得具体看了 2024-07-27 00:28:09 +08:00
649cd4cd9c
fix 一些小东西 2024-07-26 11:41:54 +08:00
6a0c7cf11d
update dependecy 2024-07-26 00:30:29 +08:00
16 changed files with 857 additions and 295 deletions

View File

@ -4,7 +4,9 @@
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING
from Difficult_Rocket.api.types import Options, Version from Difficult_Rocket.api.types import Options, Version
@ -13,6 +15,21 @@ build_version = Version("3.0.0.0") # 编译文件版本(与游戏本体无关)
api_version = Version("0.1.2.2") # API 版本 api_version = Version("0.1.2.2") # API 版本
__version__ = sdk_version __version__ = sdk_version
if TYPE_CHECKING:
from Difficult_Rocket import (
api,
data,
client,
command,
crash,
exception,
server,
mod,
utils,
main,
runtime
)
__all__ = [ __all__ = [
# __init__ # __init__
"DR_status", "DR_status",

View File

@ -116,8 +116,8 @@ class BaseScreen(EventDispatcher, Options):
:event: :event:
""" """
def on_draw(self, dt: float, window: ClientWindow): # TODO: wait for pyglet 2.1 # def on_draw(self, dt: float, window: ClientWindow): # TODO: wait for pyglet 2.1
# def on_draw(self, window: ClientWindow): def on_draw(self, window: ClientWindow):
"""The window contents must be redrawn. """The window contents must be redrawn.
The `EventLoop` will dispatch this event when the window The `EventLoop` will dispatch this event when the window

View File

@ -285,7 +285,6 @@ class ClientWindow(Window):
self.push_handlers(self.input_box) self.push_handlers(self.input_box)
self.input_box.enabled = True self.input_box.enabled = True
# 设置刷新率 # 设置刷新率
# pyglet.clock.schedule_interval(self.draw_update, float(self.SPF))
# 完成设置后的信息输出 # 完成设置后的信息输出
self.logger.info(tr().window.os.pid_is().format(os.getpid(), os.getppid())) self.logger.info(tr().window.os.pid_is().format(os.getpid(), os.getppid()))
end_time = time.time_ns() end_time = time.time_ns()
@ -295,7 +294,7 @@ class ClientWindow(Window):
self.logger.debug(tr().window.setup.use_time_ns().format(self.use_time)) self.logger.debug(tr().window.setup.use_time_ns().format(self.use_time))
def setup(self): def setup(self):
self.set_icon(pyglet.image.load("assets/textures/icon.png")) self.set_icon(pyglet.image.load("assets/textures/icon.ico"))
self.load_fonts() self.load_fonts()
self.screen_list["DR_debug"] = DRDEBUGScreen(self) self.screen_list["DR_debug"] = DRDEBUGScreen(self)
self.game.dispatch_mod_event("on_client_start", game=self.game, client=self) self.game.dispatch_mod_event("on_client_start", game=self.game, client=self)
@ -307,10 +306,9 @@ class ClientWindow(Window):
pyglet_load_fonts_folder(fonts_folder_path) pyglet_load_fonts_folder(fonts_folder_path)
def start_game(self) -> None: def start_game(self) -> None:
self.set_icon(pyglet.image.load("assets/textures/icon.png"))
try: try:
pyglet.clock.schedule_interval(self.draw_call, float(self.SPF)) # pyglet.clock.schedule(self.draw_call)
pyglet.app.run(None) pyglet.app.run(0)
except KeyboardInterrupt: except KeyboardInterrupt:
self.logger.warn( self.logger.warn(
"==========client stop. KeyboardInterrupt info==========", tag="starter" "==========client stop. KeyboardInterrupt info==========", tag="starter"
@ -356,17 +354,17 @@ class ClientWindow(Window):
now_FPS = pyglet.clock.get_frequency() now_FPS = pyglet.clock.get_frequency()
self.fps_log.update_tick(now_FPS, decimal_tick) self.fps_log.update_tick(now_FPS, decimal_tick)
def draw_call(self, dt: float): def draw_call(self):
self.switch_to() self.switch_to()
self.on_draw(dt) self.on_draw()
self.flip() self.flip()
@_call_screen_after @_call_screen_after
def on_draw(self, dt: float): def on_draw(self, *dt: float):
while (command := self.game.console.get_command()) is not None: while (command := self.game.console.get_command()) is not None:
self.on_command(line.CommandText(command)) self.on_command(line.CommandText(command))
self.clear() self.clear()
self.draw_update(dt) self.draw_update(float(self.SPF))
self.draw_batch() self.draw_batch()
@_call_screen_after @_call_screen_after

View File

@ -4,28 +4,656 @@
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
from typing import Optional, Tuple, Type from __future__ import annotations
import math
from typing import Optional, Tuple, Type, Sequence
from dataclasses import dataclass
from enum import Enum
# from libs import pyglet # from libs import pyglet
import pyglet import pyglet
from pyglet.gl import GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA
from pyglet.graphics.shader import ShaderProgram
from pyglet.text import Label from pyglet.text import Label
from pyglet.gui import widgets from pyglet.gui import widgets
from pyglet.window import mouse from pyglet.window import mouse
# from pyglet.sprite import Sprite from pyglet.shapes import Rectangle, BorderedRectangle, ShapeBase, _rotate_point
from pyglet.shapes import Rectangle, BorderedRectangle from pyglet.gui.widgets import WidgetBase
# from pyglet.image import AbstractImage
from pyglet.graphics import Batch, Group from pyglet.graphics import Batch, Group
from Difficult_Rocket.api.types import Options, FontData from Difficult_Rocket.api.types import Options, FontData
# from Difficult_Rocket import DR_status # from Difficult_Rocket import DR_status
RGBA = Tuple[int, int, int, int] RGBA = Tuple[int, int, int, int]
@dataclass
class WikiShapeColors:
# 这里都是 未按下的颜色
# 外面一圈高光
highlight: RGBA = (255, 255, 255, 255)
# 边框
border: RGBA = (0, 0, 0, 255)
# 下巴
down_pad: RGBA = (49, 50, 51, 255)
# 左下角和右上角的重叠点
corner: RGBA = (124, 124, 125, 255)
# 左上拐角
left_up: RGBA = (109, 109, 110, 255)
# 右下拐角
right_down: RGBA = (90, 91, 92, 255)
# 内部填充
inner: RGBA = (72, 73, 74, 255)
class WikiButtonStyles(Enum):
wiki_normal = WikiShapeColors()
wiki_press = WikiShapeColors(
corner=(106, 107, 108, 255),
down_pad=(35, 35, 36, 255),
left_up=(90, 91, 92, 255),
right_down=(70, 71, 71, 255),
inner=(49, 50, 51, 255),
)
game1_normal = WikiShapeColors(
border=(30, 30, 31, 255),
corner=(253, 253, 254, 255),
down_pad=(88, 88, 90, 255),
left_up=(251, 251, 253, 255),
right_down=(248, 250, 251, 255),
inner=(244, 246, 249, 255),
)
game1_select = WikiShapeColors(
border=(30, 30, 31, 255),
corner=(244, 244, 245, 255),
down_pad=(88, 88, 90, 255),
left_up=(236, 237, 238, 255),
right_down=(227, 227, 229, 255),
inner=(208, 209, 212, 255),
)
game1_press = WikiShapeColors(
border=(30, 30, 31, 255),
corner=(236, 236, 237, 255),
down_pad=(110, 111, 114, 255),
left_up=(224, 224, 225, 255),
right_down=(208, 209, 211, 255),
inner=(177, 178, 181, 255),
)
game2_normal = WikiShapeColors(
border=(30, 30, 31, 255),
corner=(131, 190, 109, 255),
down_pad=(29, 77, 19, 255),
left_up=(1117, 183, 93, 255),
right_down=(99, 174, 73, 255),
inner=(82, 165, 53, 255),
)
game2_select = WikiShapeColors(
border=(30, 30, 31, 255),
corner=(114, 167, 99, 255),
down_pad=(29, 77, 19, 255),
left_up=(99, 157, 82, 255),
right_down=(79, 145, 60, 255),
inner=(60, 133, 39, 255),
)
game2_press = WikiShapeColors(
border=(30, 30, 31, 255),
corner=(102, 143, 91, 255),
down_pad=(14, 77, 3, 255),
left_up=(85, 131, 73, 255),
right_down=(63, 115, 50, 255),
inner=(42, 100, 28, 255),
)
@dataclass
class WikiButtonStatus:
popout: bool = False
highlight: bool = False
pad: float = 2
down_pad: float = 5
colors: WikiShapeColors = WikiShapeColors()
class WikiButtonShape(ShapeBase):
def __init__(
self,
x: float,
y: float,
width: float,
height: float,
pad: float = 2,
down_pad: float = 5.0,
pop_out: bool = True,
highlight: bool = False,
colors: WikiShapeColors | None = None,
blend_src: int = GL_SRC_ALPHA,
blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
batch: Batch | None = None,
group: Group | None = None,
program: ShaderProgram | None = None,
):
self._x = x
self._y = y
self._width = width
self._height = height
self._pad = pad
self._down_pad = down_pad
self._pop_out = pop_out
self._highlight = highlight
self._colors = colors or WikiButtonStyles.wiki_normal.value
vertex = 32
if pop_out:
vertex += 4
super().__init__(vertex, blend_src, blend_dest, batch, group, program)
@property
def pop_out(self) -> bool:
return self._pop_out
@property
def pad(self) -> float:
return self._pad
@property
def down_pad(self) -> float:
return self._down_pad
@property
def color(self) -> WikiShapeColors:
return self._colors
@property
def colors(self) -> WikiShapeColors:
return self._colors
@property
def highlight(self) -> bool:
return self._highlight
@pop_out.setter
def pop_out(self, value: bool) -> None:
self._pop_out = value
self._create_vertex_list()
@pad.setter
def pad(self, value: float) -> None:
self._pad = value
self._update_vertices()
@down_pad.setter
def down_pad(self, value: float) -> None:
self._down_pad = value
self._update_vertices()
@color.setter
def color(self, value: WikiShapeColors) -> None:
self._colors = value
self._update_color()
@colors.setter
def colors(self, value: WikiShapeColors) -> None:
self._colors = value
self._update_color()
@highlight.setter
def highlight(self, value: bool) -> None:
self._highlight = value
self._create_vertex_list()
def _update_color(self) -> None:
if self._pop_out:
colors = (
self._colors.border * 4
+ self._colors.down_pad * 4
+ self._colors.corner * 8
+ self._colors.right_down * 6
+ self._colors.left_up * 6
+ self._colors.inner * 4
+ self._colors.highlight * 4
)
else:
colors = (
self._colors.border * 4
+ self._colors.corner * 8
+ self._colors.right_down * 6
+ self._colors.left_up * 6
+ self._colors.inner * 4
+ self._colors.highlight * 4
)
self._vertex_list.colors[:] = colors
def __contains__(self, point: tuple[float, float]) -> bool:
assert len(point) == 2
point = _rotate_point((self._x, self._y), point, math.radians(self._rotation))
x, y = self._x - self._anchor_x, self._y - self._anchor_y
return x < point[0] < x + self._width and y < point[1] < y + self._height
def _get_vertices(self) -> Sequence[float]:
if not self._visible:
return (0, 0) * self._num_verts
left = -self._anchor_x
right = left + self._width
bottom = -self.anchor_y
top = bottom + self._height
pad = self._pad
down_pad = self._down_pad
in_left = left + pad
i_right = right - pad
in_bottom = bottom + pad
inner_top = top - pad
"""
pop out ( 默认的弹出状态 )
20 顶点 (还有外面一圈高光)
3 2
18 15 14
19 16 17
11 10 13
7 9 6
4 5
0 1
unpop
16 顶点
3 2
7 15 6
13 12 14
10 9 11
4 8 5
0 1
"""
# fmt: off
out_border = [
left, bottom, # 0
right, bottom, # 1
right, top, # 2
left, top, # 3
]
if self._highlight:
highlight = [
left - pad, bottom - pad, # max+1
right + pad, bottom - pad, # max+2
right + pad, top + pad, # max+3
left - pad, top + pad, # max+4
]
else:
highlight = [0, 0, 0, 0, 0, 0, 0, 0]
if self._pop_out:
down_top = in_bottom + down_pad
# 底下那个下巴
down_part = [
in_left, in_bottom, # 4
i_right, in_bottom, # 5
i_right, down_top, # 6
in_left, down_top, # 7
]
# 左下角的小方块
left_down = [
in_left, down_top, # 8
in_left + pad, down_top, # 9
in_left + pad, down_top + pad, # 10
in_left, down_top + pad, # 11
]
# 右上角的小方块
right_up = [
i_right - pad, inner_top - pad, # 12
i_right, inner_top - pad, # 13
i_right, inner_top, # 14
i_right - pad, inner_top, # 15
]
# 左上的拐弯条
# 1 2
# 4 3
# 0 5
left_up = [
in_left, down_top + pad, # 16
in_left, inner_top, # 17
i_right - pad, inner_top, # 18
i_right - pad, inner_top - pad, # 19
in_left + pad, inner_top - pad, # 20
in_left + pad, down_top + pad, # 21
]
# 右下的拐弯条
# 3 2
# 5 4
# 0 1
right_down = [
in_left + pad, down_top, # 22
i_right, down_top, # 23
i_right, inner_top - pad, # 24
i_right - pad, inner_top - pad, # 25
i_right - pad, down_top + pad, # 26
in_left + pad, down_top + pad, # 27
]
# 中间的方块
inner_box = [
in_left + pad, down_top + pad, # 28
i_right - pad, down_top + pad, # 29
i_right - pad, inner_top - pad, # 30
in_left + pad, inner_top - pad, # 31
]
return (out_border +
down_part +
left_down + right_up +
left_up + right_down +
inner_box +
highlight)
else:
# 左下角的小方块
left_down = [
in_left, in_bottom, # 4
in_left + pad, in_bottom, # 5
in_left + pad, in_bottom + pad, # 6
in_left, in_bottom + pad, # 7
]
# 右上角的小方块
right_up = [
i_right - pad, inner_top - pad, # 8
i_right, inner_top - pad, # 9
i_right, inner_top, # 10
i_right - pad, inner_top, # 11
]
# 左上的拐弯条
# 1 2
# 4 3
# 0 5
left_up = [
in_left, in_bottom + pad, # 12
in_left, inner_top, # 13
i_right - pad, inner_top, # 14
i_right - pad, inner_top - pad, # 15
in_left + pad, inner_top - pad, # 16
in_left + pad, in_bottom + pad, # 17
]
# 右下的拐弯条
# 3 2
# 5 4
# 0 1
right_down = [
in_left + pad, in_bottom, # 18
i_right, in_bottom, # 19
i_right, inner_top - pad, # 20
i_right - pad, inner_top - pad, # 21
i_right - pad, in_bottom + pad, # 22
in_left + pad, in_bottom + pad, # 23
]
# 中间的方块
inner_box = [
in_left + pad, in_bottom + pad, # 24
i_right - pad, in_bottom + pad, # 25
i_right - pad, inner_top - pad, # 26
in_left + pad, inner_top - pad, # 27
]
return (out_border +
left_down + right_up +
left_up + right_down +
inner_box +
highlight)
# fmt: on
def _create_vertex_list(self) -> None:
if self._vertex_list:
self._vertex_list.delete()
colors = self._colors.border * 4
# fmt: off
indices = [
0, 1, 2, # 最基本的两个三角形
0, 2, 3, # 用来画黑色边框
]
if self._pop_out:
indices += [4, 5, 6, 4, 6, 7] # 下巴
indices += [8, 9, 10, 8, 10, 11] # 左下角
indices += [12, 13, 14, 12, 14, 15] # 右上角
indices += [16, 17, 20, 16, 20, 21,
18, 19, 20, 18, 17, 20] # 左上拐弯
indices += [22, 23, 26, 22, 26, 27,
23, 24, 26, 24, 25, 26] # 右下拐弯
indices += [28, 29, 30, 28, 30, 31] # 中间的方块
if self._highlight:
indices = [32, 33, 34, 32, 34, 35] + indices # 高光
colors += (
self._colors.down_pad * 4
+ self._colors.corner * 8
+ self._colors.right_down * 6
+ self._colors.left_up * 6
+ self._colors.inner * 4
+ self._colors.highlight * 4
)
self._num_verts = 36
else:
indices += [4, 5, 6, 4, 6, 7] # 左下角
indices += [8, 9, 10, 8, 10, 11] # 右上角
indices += [12, 16, 17, 12, 13, 16,
14, 15, 16, 14, 13, 16] # 左上拐弯
indices += [18, 22, 23, 18, 19, 22,
20, 21, 22, 20, 19, 22] # 右下拐弯
indices += [24, 25, 26, 24, 26, 27]
if self._highlight:
indices = [28, 29, 30, 28, 30, 31] + indices # 高光
colors += (
self._colors.corner * 8
+ self._colors.right_down * 6
+ self._colors.left_up * 6
+ self._colors.inner * 4
+ self._colors.highlight * 4
)
self._num_verts = 32
# fmt: on
self._vertex_list = self._program.vertex_list_indexed(
self._num_verts,
self._draw_mode,
indices,
self._batch,
self._group,
position=("f", self._get_vertices()),
colors=("Bn", colors),
translation=("f", (self._x, self._y) * self._num_verts),
)
def _update_vertices(self) -> None:
self._vertex_list.position[:] = self._get_vertices()
class 拐角(ShapeBase):
def __init__(
self,
x: float,
y: float,
width: float,
height: float,
thick1: float = 1.0,
thick2: float = 1.0,
color: tuple[int, int, int, int] = (255, 255, 255, 255),
clockwise: bool = True,
blend_src: int = GL_SRC_ALPHA,
blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
batch: Batch | None = None,
group: Group | None = None,
program: ShaderProgram | None = None,
) -> None:
self._x = x
self._y = y
self._width = width
self._height = height
self._thick1 = thick1
self._thick2 = thick2
self._clockwise = clockwise
self._rgba = color
super().__init__(6, blend_src, blend_dest, batch, group, program)
def __contains__(self, point: tuple[float, float]) -> bool:
assert len(point) == 2
# 先大框
point = _rotate_point((self._x, self._y), point, math.radians(self._rotation))
x, y = self._x - self._anchor_x, self._y - self._anchor_y
return (x < point[0] < x + self._width and y < point[1] < y + self._height) and (
(
(point[1] > y + self._height - self._thick2)
or (point[0] < x + self._thick1)
)
if self._clockwise
else (
(point[1] < y + self._thick1)
or (point[0] > x + self._width - self._thick2)
)
)
def _get_vertices(self) -> Sequence[float]:
if not self.visible:
return (0, 0) * self._num_verts
t1, t2 = self._thick1, self._thick2
left = -self._anchor_x
bottom = -self._anchor_y
right = left + self._width
top = bottom + self._height
x1 = left
x2 = left + t1
x3 = right - t1
x4 = right
y1 = bottom
y2 = bottom + t1
y3 = top - t2
y4 = top
# fmt: off
return ([
x1, y1,
x1, y4,
x4, y4,
x4, y3,
x2, y3,
x2, y1
] if self._clockwise else[
x1, y1,
x4, y1,
x4, y4,
x3, y4,
x3, y2,
x1, y2
])
# fmt: on
def _update_color(self) -> None:
self._vertex_list.colors[:] = self._rgba * self._num_verts
def _update_vertices(self) -> None:
self._vertex_list.position[:] = self._get_vertices() # pyright: ignore reportAttributeAccessIssue
def _create_vertex_list(self) -> None:
# 1 2
# 4 3
# 0 5
# or
# 3 2
# 5 4
# 0 1
# fmt: off
groups = [
1, 2, 3,
1, 3, 4,
1, 4, 5,
1, 5, 0,
]
# fmt: on
self._vertex_list = self._program.vertex_list_indexed(
self._num_verts,
self._draw_mode,
groups,
self._batch, # pyright: ignore reportArgumentType
self._group, # pyright: ignore reportArgumentType
position=("f", self._get_vertices()),
colors=("Bn", self._rgba * self._num_verts),
translation=("f", (self._x, self._y) * self._num_verts),
)
@property
def thick1(self) -> float:
return self._thick1
@property
def thick2(self) -> float:
return self.thick2
@property
def thickness(self) -> float:
return self._thick1
@thickness.setter
def thickness(self, value: float):
self._thick1 = value
self._thick2 = value
self._update_vertices()
@property
def width(self) -> float:
return self._width
@property
def height(self) -> float:
return self.height
@property
def clockwise(self) -> bool:
return self._clockwise
@thick1.setter
def thick1(self, value: float):
self._thick1 = value
self._update_vertices()
@thick2.setter
def thick2(self, value: float):
self._thick2 = value
self._update_vertices()
@width.setter
def width(self, value: float):
self._width = value
self._update_vertices()
@height.setter
def height(self, value: float):
self._height = value
self._update_vertices()
@clockwise.setter
def clockwise(self, value: bool):
self._clockwise = bool(value)
self._update_vertices()
class WikiButton(WidgetBase):
def __init__(
self, x: int, y: int, width: int, height: int, batch: Batch, group: Group
) -> None:
super().__init__(x, y, width, height)
self.enabled = False
pad = 2
down_pad = 5
self.pad = pad
self.down_pad = down_pad
# 覆盖式
self.main_batch = batch or Batch()
self.main_group = group or Group()
def __contains__(self, pos: tuple[float, float]) -> bool:
return self._check_hit()
def on_mouse_press(self, x: int, y: int, buttons: int, modifiers: int) -> None:
if (x, y) in self:
...
class BaseButtonTheme: class BaseButtonTheme:
""" """
按钮的风格 按钮的风格
@ -83,9 +711,10 @@ class MinecraftWikiButtonTheme(BaseButtonTheme):
height: int, height: int,
batch: Batch, batch: Batch,
group: Group, group: Group,
theme: dict = None, theme: Optional[dict] = None,
): ):
super().__init__(x, y, width, height, batch, group) super().__init__(x, y, width, height, batch, group)
self.enable = False
self.batch = batch self.batch = batch
self.group = group self.group = group
a = (72, 73, 74, 255) a = (72, 73, 74, 255)

View File

@ -1,16 +1,3 @@
# -------------------------------
# Difficult Rocket
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
# All rights reserved
# -------------------------------
"""
writen by shenjackyuanjie
mail: 3695888@qq.com
github: @shenjackyuanjie
gitee: @shenjackyuanjie
"""
import functools import functools
import inspect import inspect
import threading import threading
@ -76,7 +63,7 @@ class FunctionThread(threading.Thread):
target=target, args=args, kwargs=kwargs, name=name, daemon=daemon target=target, args=args, kwargs=kwargs, name=name, daemon=daemon
) )
self.__return_value = self.__NONE self.__return_value = self.__NONE
self.__error = None self.__error: Optional[Exception] = None
def wrapped_target(*args_, **kwargs_): def wrapped_target(*args_, **kwargs_):
try: try:
@ -123,7 +110,7 @@ def new_thread(
arg: Optional[Union[str, Callable]] = None, arg: Optional[Union[str, Callable]] = None,
daemon: bool = False, daemon: bool = False,
log_thread: bool = True, log_thread: bool = True,
): ) -> Callable:
""" """
This is a one line solution to make your function executes in parallels. This is a one line solution to make your function executes in parallels.
When decorated with this decorator, functions will be executed in a new daemon thread When decorated with this decorator, functions will be executed in a new daemon thread
@ -178,7 +165,7 @@ def new_thread(
# bring the signature of the func to the wrap function # bring the signature of the func to the wrap function
# so inspect.getfullargspec(func) works correctly # so inspect.getfullargspec(func) works correctly
copy_signature(wrap, func) copy_signature(wrap, func)
wrap.original = func # access this field to get the original function wrap.original = func # access this field to get the original function # pyright: ignore reportAttributeAccessIssue
return wrap return wrap
# Directly use @new_thread without ending brackets case, e.g. @new_thread # Directly use @new_thread without ending brackets case, e.g. @new_thread

@ -1 +1 @@
Subproject commit f68bd5b57d2ece430ebbabb7b405eb4b821fb567 Subproject commit 60da39e4e8eac50dc58024545b298a7bc7e55d36

View File

@ -49,27 +49,21 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]] [[package]]
name = "bit-vec" name = "bit-vec"
version = "0.6.3" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bitflags"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.16.0" version = "1.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -135,7 +129,7 @@ checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]] [[package]]
name = "difficult_rocket_rs" name = "difficult_rocket_rs"
version = "0.4.1" version = "0.4.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"nalgebra", "nalgebra",
@ -153,9 +147,9 @@ checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
[[package]] [[package]]
name = "either" name = "either"
version = "1.12.0" version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
@ -169,9 +163,9 @@ dependencies = [
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.4.1" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]] [[package]]
name = "indoc" name = "indoc"
@ -191,21 +185,11 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "lock_api"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.21" version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]] [[package]]
name = "matrixmultiply" name = "matrixmultiply"
@ -234,9 +218,9 @@ dependencies = [
[[package]] [[package]]
name = "nalgebra" name = "nalgebra"
version = "0.32.6" version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5c17de023a86f59ed79891b2e5d5a94c705dbe904a5b5c9c952ea6221b03e4" checksum = "3c4b5f057b303842cf3262c27e465f4c303572e7f6b0648f60e16248ac3397f4"
dependencies = [ dependencies = [
"approx", "approx",
"matrixmultiply", "matrixmultiply",
@ -250,13 +234,23 @@ dependencies = [
[[package]] [[package]]
name = "nalgebra-macros" name = "nalgebra-macros"
version = "0.2.1" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 1.0.109", "syn",
]
[[package]]
name = "num-bigint"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
dependencies = [
"num-integer",
"num-traits",
] ]
[[package]] [[package]]
@ -276,7 +270,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.66", "syn",
] ]
[[package]] [[package]]
@ -294,6 +288,7 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [ dependencies = [
"num-bigint",
"num-integer", "num-integer",
"num-traits", "num-traits",
] ]
@ -316,56 +311,35 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]] [[package]]
name = "ordered-float" name = "ordered-float"
version = "4.2.0" version = "4.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" checksum = "19ff2cf528c6c03d9ed653d6c4ce1dc0582dc4af309790ad92f07c1cd551b0be"
dependencies = [ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "parking_lot"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets",
]
[[package]] [[package]]
name = "parry2d-f64" name = "parry2d-f64"
version = "0.15.1" version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "416b765a3db5f3e219fcc878d649ea6dc6b93490694be846c39c7398074f90d1" checksum = "83cb2f7d0e018b2fc6c3cecfc05c82a198b9087534f16d2ea2a5552c2ac0fc2b"
dependencies = [ dependencies = [
"approx", "approx",
"arrayvec", "arrayvec",
"bitflags 1.3.2", "bitflags",
"downcast-rs", "downcast-rs",
"either", "either",
"log", "log",
"nalgebra", "nalgebra",
"num-derive", "num-derive",
"num-traits", "num-traits",
"ordered-float",
"rustc-hash", "rustc-hash",
"simba", "simba",
"slab", "slab",
"smallvec", "smallvec",
"spade", "spade",
"thiserror",
] ]
[[package]] [[package]]
@ -376,30 +350,30 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]] [[package]]
name = "portable-atomic" name = "portable-atomic"
version = "1.6.0" version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.85" version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "pyo3" name = "pyo3"
version = "0.21.2" version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"indoc", "indoc",
"libc", "libc",
"memoffset", "memoffset",
"parking_lot", "once_cell",
"portable-atomic", "portable-atomic",
"pyo3-build-config", "pyo3-build-config",
"pyo3-ffi", "pyo3-ffi",
@ -409,9 +383,9 @@ dependencies = [
[[package]] [[package]]
name = "pyo3-build-config" name = "pyo3-build-config"
version = "0.21.2" version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"target-lexicon", "target-lexicon",
@ -419,9 +393,9 @@ dependencies = [
[[package]] [[package]]
name = "pyo3-ffi" name = "pyo3-ffi"
version = "0.21.2" version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6"
dependencies = [ dependencies = [
"libc", "libc",
"pyo3-build-config", "pyo3-build-config",
@ -429,34 +403,34 @@ dependencies = [
[[package]] [[package]]
name = "pyo3-macros" name = "pyo3-macros"
version = "0.21.2" version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"pyo3-macros-backend", "pyo3-macros-backend",
"quote", "quote",
"syn 2.0.66", "syn",
] ]
[[package]] [[package]]
name = "pyo3-macros-backend" name = "pyo3-macros-backend"
version = "0.21.2" version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
"pyo3-build-config", "pyo3-build-config",
"quote", "quote",
"syn 2.0.66", "syn",
] ]
[[package]] [[package]]
name = "quick-xml" name = "quick-xml"
version = "0.32.0" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc"
dependencies = [ dependencies = [
"memchr", "memchr",
"serde", "serde",
@ -473,14 +447,14 @@ dependencies = [
[[package]] [[package]]
name = "rapier2d-f64" name = "rapier2d-f64"
version = "0.20.0" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "569c367a5f266a20e4253d798d3b9115d07c7c085b7be3258de104af3557f38f" checksum = "6f63d275f0eea82fd0cb5266c9353408b08240db0e752607c0a981f4f9637eaf"
dependencies = [ dependencies = [
"approx", "approx",
"arrayvec", "arrayvec",
"bit-vec", "bit-vec",
"bitflags 1.3.2", "bitflags",
"crossbeam", "crossbeam",
"downcast-rs", "downcast-rs",
"log", "log",
@ -501,15 +475,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
[[package]]
name = "redox_syscall"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd"
dependencies = [
"bitflags 2.5.0",
]
[[package]] [[package]]
name = "robust" name = "robust"
version = "1.1.0" version = "1.1.0"
@ -518,9 +483,9 @@ checksum = "cbf4a6aa5f6d6888f39e980649f3ad6b666acdce1d78e95b8a2cb076e687ae30"
[[package]] [[package]]
name = "rustc-hash" name = "rustc-hash"
version = "1.1.0" version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
[[package]] [[package]]
name = "safe_arch" name = "safe_arch"
@ -531,37 +496,31 @@ dependencies = [
"bytemuck", "bytemuck",
] ]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.203" version = "1.0.204"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.203" version = "1.0.204"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.66", "syn",
] ]
[[package]] [[package]]
name = "simba" name = "simba"
version = "0.8.1" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" checksum = "b3a386a501cd104797982c15ae17aafe8b9261315b5d07e3ec803f2ea26be0fa"
dependencies = [ dependencies = [
"approx", "approx",
"num-complex", "num-complex",
@ -599,20 +558,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "2.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -621,28 +569,28 @@ dependencies = [
[[package]] [[package]]
name = "target-lexicon" name = "target-lexicon"
version = "0.12.14" version = "0.12.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.61" version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.61" version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.66", "syn",
] ]
[[package]] [[package]]
@ -677,94 +625,30 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "wide" name = "wide"
version = "0.7.24" version = "0.7.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a040b111774ab63a19ef46bbc149398ab372b4ccdcfd719e9814dbd7dfd76c8" checksum = "901e8597c777fa042e9e245bd56c0dc4418c5db3f845b6ff94fbac732c6a0692"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"safe_arch", "safe_arch",
] ]
[[package]]
name = "windows-targets"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]]
name = "windows_i686_gnu"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
[[package]]
name = "windows_i686_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.34" version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
dependencies = [ dependencies = [
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.7.34" version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.66", "syn",
] ]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "difficult_rocket_rs" name = "difficult_rocket_rs"
version = "0.4.1" version = "0.4.2"
edition = "2021" edition = "2021"
license-file = '../../LICENSE' license-file = '../../LICENSE'
authors = ["shenjackyuanjie <3695888@qq.com>"] authors = ["shenjackyuanjie <3695888@qq.com>"]
@ -24,10 +24,15 @@ opt-level = 2
[dependencies] [dependencies]
anyhow = "1.0" anyhow = "1.0"
quick-xml = { version = "0.32.0", features = ["serialize"] } quick-xml = { version = "0.36.1", features = ["serialize"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
nalgebra = "0.32" nalgebra = "0.33"
pyo3 = { version = "0.21.2", features = ["extension-module", "macros"] } pyo3 = { version = "0.22.2", features = [
rapier2d-f64 = { version = "0.20.0", features = ["simd-stable"] } "extension-module",
"macros",
"py-clone",
] }
rapier2d-f64 = { version = "0.22.0", features = ["simd-stable"] }
# 虽然但是, raiper在这里! # 虽然但是, raiper在这里!

View File

@ -283,6 +283,7 @@ pub struct PySR1Ship {
impl PySR1Ship { impl PySR1Ship {
#[new] #[new]
#[pyo3(text_signature = "(file_path = './assets/builtin/dock1.xml', part_list = None, ship_name = 'NewShip')")] #[pyo3(text_signature = "(file_path = './assets/builtin/dock1.xml', part_list = None, ship_name = 'NewShip')")]
#[pyo3(signature = (file_path, part_list=None, ship_name=None))]
fn new(file_path: String, part_list: Option<PySR1PartList>, ship_name: Option<String>) -> PyResult<Self> { fn new(file_path: String, part_list: Option<PySR1PartList>, ship_name: Option<String>) -> PyResult<Self> {
let ship = SR1Ship::from_file(file_path.clone(), Some(ship_name.unwrap_or("new ship".to_string()))); let ship = SR1Ship::from_file(file_path.clone(), Some(ship_name.unwrap_or("new ship".to_string())));
match ship { match ship {
@ -359,7 +360,9 @@ impl PySR1Ship {
fn get_mass(&self) -> f64 { fn get_mass(&self) -> f64 {
let mut mass = 0_f64; let mut mass = 0_f64;
for part_data in self.ship.parts.iter() { for part_data in self.ship.parts.iter() {
self.part_list.get_part_type(&part_data.part_type_id).map(|part_type| mass += part_type.mass); if let Some(part_type) = self.part_list.get_part_type(&part_data.part_type_id) {
mass += part_type.mass;
}
} }
mass mass
} }
@ -440,6 +443,7 @@ impl PySR1Ship {
.collect() .collect()
} }
#[pyo3(signature = (file_path, save_status=None))]
fn save(&self, file_path: String, save_status: Option<PySaveStatus>) -> PyResult<()> { fn save(&self, file_path: String, save_status: Option<PySaveStatus>) -> PyResult<()> {
println!("{:?}", save_status); println!("{:?}", save_status);
self.ship.save(file_path, &save_status.unwrap_or_default().status).unwrap(); self.ship.save(file_path, &save_status.unwrap_or_default().status).unwrap();

View File

@ -553,6 +553,7 @@ impl SR1PartDataAttr {
} }
self.guess_type() self.guess_type()
} }
#[allow(clippy::too_many_arguments)]
pub fn new( pub fn new(
fuel: Option<f64>, fuel: Option<f64>,
name: Option<String>, name: Option<String>,

View File

@ -124,7 +124,7 @@ impl Connections {
impl DisconnectedParts { impl DisconnectedParts {
pub fn as_sr1_vec(&self) -> Vec<(Vec<SR1PartData>, Vec<Connection>)> { pub fn as_sr1_vec(&self) -> Vec<(Vec<SR1PartData>, Vec<Connection>)> {
self.parts.iter().map(|x| x.into_sr_part()).collect() self.parts.iter().map(|x| x.as_sr_part()).collect()
} }
pub fn from_vec_sr1(parts_list: Vec<(Vec<SR1PartData>, Vec<Connection>)>) -> Self { pub fn from_vec_sr1(parts_list: Vec<(Vec<SR1PartData>, Vec<Connection>)>) -> Self {
DisconnectedParts { DisconnectedParts {
@ -192,7 +192,7 @@ pub struct DisconnectedPart {
} }
impl DisconnectedPart { impl DisconnectedPart {
pub fn into_sr_part(&self) -> (Vec<SR1PartData>, Vec<Connection>) { pub fn as_sr_part(&self) -> (Vec<SR1PartData>, Vec<Connection>) {
(self.parts.as_sr1_vec(), self.connects.as_vec()) (self.parts.as_sr1_vec(), self.connects.as_vec())
} }
@ -270,17 +270,11 @@ impl Connection {
} }
/// 是否为 Dock 类型 /// 是否为 Dock 类型
pub fn is_dock(&self) -> bool { pub fn is_dock(&self) -> bool {
match self { matches!(self, Connection::Dock { .. })
Connection::Dock { .. } => true,
_ => false,
}
} }
/// 是否为 Normal 类型 /// 是否为 Normal 类型
pub fn is_normal(&self) -> bool { pub fn is_normal(&self) -> bool {
match self { matches!(self, Connection::Normal { .. })
Connection::Normal { .. } => true,
_ => false,
}
} }
} }
@ -395,20 +389,21 @@ pub fn py_assert_ship(path: String) -> bool {
if e.name().as_ref() == b"Ship" { if e.name().as_ref() == b"Ship" {
// 再验证一下 version, liftedOff, touchingGround // 再验证一下 version, liftedOff, touchingGround
let mut founds = (false, false, false); let mut founds = (false, false, false);
let _ = e.attributes().map(|attr| match attr { let _ = e.attributes().map(|attr| {
Ok(attr) => match attr.value.as_ref() { if let Ok(attr) = attr {
b"version" => { match attr.value.as_ref() {
founds.0 = true; b"version" => {
founds.0 = true;
}
b"liftedOff" => {
founds.1 = true;
}
b"touchingGround" => {
founds.2 = true;
}
_ => (),
} }
b"liftedOff" => { }
founds.1 = true;
}
b"touchingGround" => {
founds.2 = true;
}
_ => (),
},
_ => (),
}); });
if !(founds.0 && founds.1 && founds.2) { if !(founds.0 && founds.1 && founds.2) {
println!( println!(

View File

@ -16,7 +16,7 @@ from Difficult_Rocket.api.types import Options, Version
from lib_not_dr import loggers from lib_not_dr import loggers
DR_rust_version = Version("0.4.1") # DR_mod 的 Rust 编写部分的兼容版本 DR_rust_version = Version("0.4.2") # DR_mod 的 Rust 编写部分的兼容版本
logger = loggers.config.get_logger_from_old("client.dr_game", "client") logger = loggers.config.get_logger_from_old("client.dr_game", "client")

View File

@ -4,16 +4,11 @@
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
from typing import Optional, Tuple
from pyglet.graphics import Batch, Group from pyglet.graphics import Batch, Group
from Difficult_Rocket.client import ClientWindow from Difficult_Rocket.client import ClientWindow
from Difficult_Rocket.api.screen import BaseScreen from Difficult_Rocket.api.screen import BaseScreen
# from Difficult_Rocket.main import Game # from Difficult_Rocket.main import Game
from Difficult_Rocket.gui.widget.button import (
PressTextButton,
MinecraftWikiButtonTheme,
)
from lib_not_dr import loggers from lib_not_dr import loggers
@ -21,6 +16,7 @@ from lib_not_dr import loggers
logger = loggers.config.get_logger_from_old("client.dr_game_layout", "client") logger = loggers.config.get_logger_from_old("client.dr_game_layout", "client")
class GameLayout(BaseScreen): class GameLayout(BaseScreen):
""" """
DR game 菜单 DR game 菜单

View File

@ -9,10 +9,14 @@ from pyglet.graphics import Batch, Group
from Difficult_Rocket.client import ClientWindow from Difficult_Rocket.client import ClientWindow
from Difficult_Rocket.api.screen import BaseScreen from Difficult_Rocket.api.screen import BaseScreen
# from Difficult_Rocket.main import Game # from Difficult_Rocket.main import Game
from Difficult_Rocket.gui.widget.button import ( from Difficult_Rocket.gui.widget.button import (
PressTextButton, PressTextButton,
MinecraftWikiButtonTheme, MinecraftWikiButtonTheme,
WikiButton,
WikiButtonShape,
WikiButtonStyles,
) )
from lib_not_dr import loggers from lib_not_dr import loggers
@ -23,6 +27,7 @@ from lib_not_dr import loggers
logger = loggers.config.get_logger_from_old("client.dr_game_menu", "client") logger = loggers.config.get_logger_from_old("client.dr_game_menu", "client")
class Menu(BaseScreen): class Menu(BaseScreen):
""" """
DR game 菜单 DR game 菜单
@ -115,14 +120,48 @@ class Menu(BaseScreen):
batch=self.main_batch, batch=self.main_batch,
group=self.main_group, group=self.main_group,
draw_theme=MinecraftWikiButtonTheme, draw_theme=MinecraftWikiButtonTheme,
dict_theme={"pop_out": True} dict_theme={"pop_out": True},
)
self.tester = WikiButton(
x=100,
y=150,
width=150,
height=30,
batch=self.main_batch,
group=self.main_group,
)
self.wiki_shape1 = WikiButtonShape(
x=100,
y=200,
width=150,
height=70,
pad=5,
down_pad=7,
batch=self.main_batch,
group=self.main_group,
)
self.wiki_shape2 = WikiButtonShape(
x=300,
y=200,
width=150,
height=70,
pad=5,
down_pad=7,
colors=WikiButtonStyles.wiki_press.value,
batch=self.main_batch,
group=self.main_group,
) )
def on_release(button: PressTextButton, x, y): def on_release(button: PressTextButton, x, y):
from .sr1_ship import SR1ShipEditor self.wiki_shape1.highlight = not self.wiki_shape1.highlight
main_window.remove_sub_screen("DR_game_menu") self.wiki_shape2.highlight = not self.wiki_shape2.highlight
main_window.add_sub_screen("SR1_ship", SR1ShipEditor) # self.tester.clockwise = not self.tester.clockwise
logger.info("added SR1_ship screen", tag="dr_game") # from .sr1_ship import SR1ShipEditor
# main_window.remove_sub_screen("DR_game_menu")
# main_window.add_sub_screen("SR1_ship", SR1ShipEditor)
# logger.info("added SR1_ship screen", tag="dr_game")
self.enter_ship_editor_button.set_handler("on_release", on_release) self.enter_ship_editor_button.set_handler("on_release", on_release)
# main_window.push_handlers(self.wiki_button1) # main_window.push_handlers(self.wiki_button1)
@ -132,5 +171,23 @@ class Menu(BaseScreen):
# main_window.push_handlers(self.button3) # main_window.push_handlers(self.button3)
main_window.push_handlers(self.enter_ship_editor_button) main_window.push_handlers(self.enter_ship_editor_button)
def on_draw(self, dt: float, window: ClientWindow): def on_mouse_press(
self, x: int, y: int, button: int, modifiers: int, window: ClientWindow
):
if (x, y) in self.wiki_shape1:
self.wiki_shape1.pop_out = not self.wiki_shape1.pop_out
if self.wiki_shape1.pop_out:
self.wiki_shape1.colors = WikiButtonStyles.game1_normal.value
else:
self.wiki_shape1.colors = WikiButtonStyles.game1_press.value
if (x, y) in self.wiki_shape2:
self.wiki_shape2.pop_out = not self.wiki_shape2.pop_out
def on_mouse_motion(self, x: int, y: int, dx: int, dy: int, window: ClientWindow):
self.wiki_shape1.highlight = (x, y) in self.wiki_shape1
self.wiki_shape2.highlight = (x, y) in self.wiki_shape2
# def on_draw(self, dt: float, window: ClientWindow): # TODO: wait for pyglet 2.1
def on_draw(self, window: ClientWindow):
self.main_batch.draw() self.main_batch.draw()

View File

@ -3,15 +3,12 @@
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com # Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
import os
import time import time
import random import random
import traceback import traceback
from pathlib import Path from pathlib import Path
from typing import List, Dict, Optional, Generator, Tuple from typing import List, Dict, Optional, Generator, Tuple
from tkinter import Tk
from tkinter import filedialog
from pyglet.gl import gl from pyglet.gl import gl
from pyglet.math import Mat4 from pyglet.math import Mat4
@ -23,7 +20,7 @@ from pyglet.shapes import Line, Box
# from pyglet.window import mouse # from pyglet.window import mouse
from . import DR_mod_runtime from . import DR_mod_runtime
from .types import SR1Textures, SR1Rotation from .types import SR1Textures
# Difficult Rocket # Difficult Rocket
from Difficult_Rocket import DR_status from Difficult_Rocket import DR_status
@ -34,12 +31,6 @@ from Difficult_Rocket.command.line import CommandText
from Difficult_Rocket.client.screen import BaseScreen from Difficult_Rocket.client.screen import BaseScreen
from Difficult_Rocket.api.camera import CenterGroupCamera, GroupCamera from Difficult_Rocket.api.camera import CenterGroupCamera, GroupCamera
from Difficult_Rocket.gui.widget.button import (
PressTextButton,
MinecraftWikiButtonTheme,
ButtonThemeOptions,
BaseButtonTheme,
)
from lib_not_dr import loggers from lib_not_dr import loggers
@ -100,8 +91,6 @@ class SR1ShipSelecter(BaseScreen):
if not file.is_file: if not file.is_file:
continue continue
# 尝试加载一下 # 尝试加载一下
class SR1ShipEditor(BaseScreen): class SR1ShipEditor(BaseScreen):
@ -531,8 +520,8 @@ class SR1ShipEditor(BaseScreen):
gl.glScissor(0, 0, self.window_pointer.width, self.window_pointer.height) gl.glScissor(0, 0, self.window_pointer.width, self.window_pointer.height)
gl.glDisable(gl.GL_SCISSOR_TEST) gl.glDisable(gl.GL_SCISSOR_TEST)
def on_draw(self, dt: float, window): # TODO: wait for pyglet 2.1 # def on_draw(self, dt: float, window): # TODO: wait for pyglet 2.1
# def on_draw(self, window: ClientWindow): def on_draw(self, window: ClientWindow):
if self.status.draw_call: if self.status.draw_call:
self.render_ship() self.render_ship()

View File

@ -58,7 +58,7 @@ msvc = "latest"
mingw64 = false mingw64 = false
standalone = true standalone = true
output-dir = "build/nuitka" output-dir = "build\\nuitka"
run = false run = false
# auto run after build # auto run after build
@ -75,9 +75,9 @@ macos-app-version = false # require script
file-description = 'Difficult Rocket a rocket game' file-description = 'Difficult Rocket a rocket game'
copyright = 'Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com' copyright = 'Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com'
windows-icon-from-ico = 'assets/textures/icon.png' windows-icon-from-ico = 'assets\textures\icon.png'
macos-app-icon = 'assets/textures/icon.png' macos-app-icon = 'assets\textures\icon.png'
linux-icon = 'assets/textures/icon.png' linux-icon = 'assets\textures\icon.png'
nofollow-import-to = [ nofollow-import-to = [
'objprint', 'objprint',
@ -94,8 +94,8 @@ nofollow-import-to = [
] ]
include-data-dir = [ include-data-dir = [
['./config', './config'], ['.\config', '.\config'],
['./assets', './assets'] ['.\assets', '.\assets']
] ]
include-package = ['Difficult_Rocket.api'] include-package = ['Difficult_Rocket.api']
# DR.api 没有直接 import, 所以需要手动添加 # DR.api 没有直接 import, 所以需要手动添加