Compare commits
7 Commits
565d568e44
...
98106ccd08
Author | SHA1 | Date | |
---|---|---|---|
98106ccd08 | |||
10b89a1919 | |||
226f8aacbe | |||
9d367b2256 | |||
70f2a30b88 | |||
5e6fee7353 | |||
d844e0ce0a |
@ -10,7 +10,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from Difficult_Rocket.api.types import Options, Version
|
from Difficult_Rocket.api.types import Options, Version
|
||||||
|
|
||||||
sdk_version = Version("0.8.5.1") # SDK 版本
|
sdk_version = Version("0.8.5.2") # SDK 版本
|
||||||
build_version = Version("2.1.2.0") # 编译文件版本(与游戏本体无关)
|
build_version = Version("2.1.2.0") # 编译文件版本(与游戏本体无关)
|
||||||
Api_version = Version("0.1.1.0") # API 版本
|
Api_version = Version("0.1.1.0") # API 版本
|
||||||
__version__ = sdk_version
|
__version__ = sdk_version
|
||||||
|
@ -349,10 +349,8 @@ class ClientWindow(Window):
|
|||||||
@_call_back(new_command)
|
@_call_back(new_command)
|
||||||
@_call_screen_after
|
@_call_screen_after
|
||||||
def on_command(self, command: line.CommandText):
|
def on_command(self, command: line.CommandText):
|
||||||
command.text = command.text.rstrip('\n')
|
command.text = command.text.rstrip('\n').rstrip(' ').strip('/')
|
||||||
command.text = command.text.rstrip(' ')
|
|
||||||
self.logger.info(tr().window.command.text().format(f"|{command.text}|"))
|
self.logger.info(tr().window.command.text().format(f"|{command.text}|"))
|
||||||
command.find('/')
|
|
||||||
if command.find('stop'):
|
if command.find('stop'):
|
||||||
self.logger.info("command stop!")
|
self.logger.info("command stop!")
|
||||||
# HUGE THANKS to Discord @nokiyasos for this fix!
|
# HUGE THANKS to Discord @nokiyasos for this fix!
|
||||||
@ -379,6 +377,7 @@ class ClientWindow(Window):
|
|||||||
self.save_info()
|
self.save_info()
|
||||||
elif command.find('mods'):
|
elif command.find('mods'):
|
||||||
if command.find('list'):
|
if command.find('list'):
|
||||||
|
self.logger.info(tr().mod.list())
|
||||||
for mod in self.game.mod_manager.loaded_mod_modules.values():
|
for mod in self.game.mod_manager.loaded_mod_modules.values():
|
||||||
self.logger.info(f"mod: {mod.name} id: {mod.mod_id} version: {mod.version}")
|
self.logger.info(f"mod: {mod.name} id: {mod.mod_id} version: {mod.version}")
|
||||||
elif command.find('reload'):
|
elif command.find('reload'):
|
||||||
|
@ -22,6 +22,7 @@ logger.logfile_datefmt = "Log file date format : "
|
|||||||
game_start.at = "Game MainThread start at: {}"
|
game_start.at = "Game MainThread start at: {}"
|
||||||
|
|
||||||
[mod]
|
[mod]
|
||||||
|
list = "Mod list: "
|
||||||
find.finded = "Mod founded: {}"
|
find.finded = "Mod founded: {}"
|
||||||
load.start = "Loading Mod in path {}"
|
load.start = "Loading Mod in path {}"
|
||||||
load.use_time = "Mod loading has used: {} second"
|
load.use_time = "Mod loading has used: {} second"
|
||||||
|
@ -22,6 +22,7 @@ logger.logfile_datefmt = "日志文件日期格式:"
|
|||||||
game_start.at = "游戏主线程开始于:"
|
game_start.at = "游戏主线程开始于:"
|
||||||
|
|
||||||
[mod]
|
[mod]
|
||||||
|
list = "Mod 列表: "
|
||||||
find.finded = "找到 Mod: {}"
|
find.finded = "找到 Mod: {}"
|
||||||
load.start = "开始加载路径 {} 下的 Mod"
|
load.start = "开始加载路径 {} 下的 Mod"
|
||||||
load.use_time = "Mod 加载消耗时间: {} 秒"
|
load.use_time = "Mod 加载消耗时间: {} 秒"
|
||||||
|
@ -7,8 +7,8 @@ fonts_folder = "libs/fonts"
|
|||||||
|
|
||||||
[window]
|
[window]
|
||||||
style = "None"
|
style = "None"
|
||||||
width = 1265
|
width = 1301
|
||||||
height = 759
|
height = 984
|
||||||
visible = true
|
visible = true
|
||||||
gui_scale = 1
|
gui_scale = 1
|
||||||
caption = "Difficult Rocket v{DR_version}"
|
caption = "Difficult Rocket v{DR_version}"
|
||||||
|
@ -2,9 +2,14 @@
|
|||||||
# DR game/DR rs 更新日志
|
# DR game/DR rs 更新日志
|
||||||
|
|
||||||
- 最新版本号
|
- 最新版本号
|
||||||
- DR game: 0.3.1.1
|
- DR game: 0.3.1.3
|
||||||
- DR rs: 0.2.15.2
|
- DR rs: 0.2.15.2
|
||||||
|
|
||||||
|
## DR game 0.3.1.2 / 0.3.1.3
|
||||||
|
|
||||||
|
- 加回了显示 delta 的那根线
|
||||||
|
- Add back the line that displays delta
|
||||||
|
|
||||||
## DR rs 0.2.15.2
|
## DR rs 0.2.15.2
|
||||||
|
|
||||||
### Add
|
### Add
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
# DR SDK 更新日志
|
# DR SDK 更新日志
|
||||||
|
|
||||||
- 最新版本号
|
- 最新版本号
|
||||||
- DR sdk: 0.8.5.1
|
- DR sdk: 0.8.5.2
|
||||||
|
|
||||||
## DR sdk 0.8.5.2
|
## DR sdk 0.8.5.2
|
||||||
|
|
||||||
### Fix
|
### Fix
|
||||||
|
|
||||||
- `crash` 引用了已经重命名的 `Difficult_Rocket.game_version` (`Difficult_Rocket.sdk_version`)
|
- `crash` 引用了已经重命名的 `Difficult_Rocket.game_version` (`Difficult_Rocket.sdk_version`)
|
||||||
|
- `Difficult_Rocket.api.types`
|
||||||
|
- `VersionRequirement`
|
||||||
|
- `VersionParsingError`
|
||||||
|
|
||||||
## DR sdk 0.8.5.1
|
## DR sdk 0.8.5.1
|
||||||
|
|
||||||
|
@ -78,6 +78,12 @@ class CocoaScreen(Screen):
|
|||||||
self.height = mode.height
|
self.height = mode.height
|
||||||
|
|
||||||
def restore_mode(self):
|
def restore_mode(self):
|
||||||
|
match_attrs = ['width', 'height', 'depth', 'rate']
|
||||||
|
current_mode = self.get_mode()
|
||||||
|
if all(getattr(current_mode, attr) == getattr(self._default_mode, attr) for
|
||||||
|
attr in match_attrs):
|
||||||
|
# Already in default mode
|
||||||
|
return
|
||||||
quartz.CGDisplaySetDisplayMode(self._cg_display_id, self._default_mode.cgmode, None)
|
quartz.CGDisplaySetDisplayMode(self._cg_display_id, self._default_mode.cgmode, None)
|
||||||
quartz.CGDisplayRelease(self._cg_display_id)
|
quartz.CGDisplayRelease(self._cg_display_id)
|
||||||
|
|
||||||
|
@ -1327,7 +1327,7 @@ class BorderedRectangle(ShapeBase):
|
|||||||
as a tuple of 3 or 4 ints in the range of 0-255. RGB
|
as a tuple of 3 or 4 ints in the range of 0-255. RGB
|
||||||
colors will be treated as having an opacity of 255.
|
colors will be treated as having an opacity of 255.
|
||||||
`border_color` : (int, int, int, int)
|
`border_color` : (int, int, int, int)
|
||||||
The RGB or RGBA fill color of the rectangle, specified
|
The RGB or RGBA fill color of the border, specified
|
||||||
as a tuple of 3 or 4 ints in the range of 0-255. RGB
|
as a tuple of 3 or 4 ints in the range of 0-255. RGB
|
||||||
colors will be treated as having an opacity of 255.
|
colors will be treated as having an opacity of 255.
|
||||||
|
|
||||||
@ -1410,6 +1410,19 @@ class BorderedRectangle(ShapeBase):
|
|||||||
self._vertex_list.position[:] = (ix1, iy1, ix2, iy1, ix2, iy2, ix1, iy2,
|
self._vertex_list.position[:] = (ix1, iy1, ix2, iy1, ix2, iy2, ix1, iy2,
|
||||||
bx1, by1, bx2, by1, bx2, by2, bx1, by2)
|
bx1, by1, bx2, by1, bx2, by2, bx1, by2)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def border(self):
|
||||||
|
"""The border width of the rectangle.
|
||||||
|
|
||||||
|
:return: float
|
||||||
|
"""
|
||||||
|
return self._border
|
||||||
|
|
||||||
|
@border.setter
|
||||||
|
def border(self, width):
|
||||||
|
self._border = width
|
||||||
|
self._update_vertices()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def width(self):
|
def width(self):
|
||||||
"""The width of the rectangle.
|
"""The width of the rectangle.
|
||||||
|
@ -681,6 +681,21 @@ class BaseWindow(with_metaclass(_WindowMetaclass, EventDispatcher)):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError('abstract')
|
raise NotImplementedError('abstract')
|
||||||
|
|
||||||
|
def draw(self, dt: float):
|
||||||
|
"""Redraw the Window contents.
|
||||||
|
|
||||||
|
This method will first call the :py:meth:`~pyglet.window.Window.`switch_to`
|
||||||
|
method to make the GL context current. It then dispatches the
|
||||||
|
:py:meth:`~pyglet.window.Window.on_draw` and
|
||||||
|
:py:meth:`~pyglet.window.Window.on_refresh`
|
||||||
|
events. Finally, it calls the :py:meth:`~pyglet.window.Window.flip`
|
||||||
|
method to swap the front and back OpenGL buffers.
|
||||||
|
"""
|
||||||
|
self.switch_to()
|
||||||
|
self.dispatch_event('on_draw')
|
||||||
|
self.dispatch_event('on_refresh', dt)
|
||||||
|
self.flip()
|
||||||
|
|
||||||
def draw_mouse_cursor(self):
|
def draw_mouse_cursor(self):
|
||||||
"""Draw the custom mouse cursor.
|
"""Draw the custom mouse cursor.
|
||||||
|
|
||||||
@ -1411,15 +1426,13 @@ class BaseWindow(with_metaclass(_WindowMetaclass, EventDispatcher)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def on_draw(self):
|
def on_draw(self):
|
||||||
"""The window contents must be redrawn.
|
"""The window contents should be redrawn.
|
||||||
|
|
||||||
The `EventLoop` will dispatch this event when the window
|
The `EventLoop` will dispatch this event when the `draw`
|
||||||
should be redrawn. This will happen during idle time after
|
method has been called. The window will already have the
|
||||||
any window events and after any scheduled functions were called.
|
GL context, so there is no need to call `switch_to`. The window's
|
||||||
|
`flip` method will be called immediately after this event,
|
||||||
The window will already have the GL context, so there is no
|
so your event handler should not.
|
||||||
need to call `switch_to`. The window's `flip` method will
|
|
||||||
be called after this event, so your event handler should not.
|
|
||||||
|
|
||||||
You should make no assumptions about the window contents when
|
You should make no assumptions about the window contents when
|
||||||
this event is triggered; a resize or expose event may have
|
this event is triggered; a resize or expose event may have
|
||||||
@ -1601,11 +1614,11 @@ class BaseWindow(with_metaclass(_WindowMetaclass, EventDispatcher)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def on_mouse_leave(self, x, y):
|
def on_mouse_leave(self, x, y):
|
||||||
"""The mouse was moved outside of the window.
|
"""The mouse was moved outside the window.
|
||||||
|
|
||||||
This event will not be triggered if the mouse is currently being
|
This event will not be triggered if the mouse is currently being
|
||||||
dragged. Note that the coordinates of the mouse pointer will be
|
dragged. Note that the coordinates of the mouse pointer will be
|
||||||
outside of the window rectangle.
|
outside the window rectangle.
|
||||||
|
|
||||||
:Parameters:
|
:Parameters:
|
||||||
`x` : int
|
`x` : int
|
||||||
@ -1632,14 +1645,13 @@ class BaseWindow(with_metaclass(_WindowMetaclass, EventDispatcher)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def on_refresh(self, dt):
|
def on_refresh(self, dt):
|
||||||
"""The window contents must be redrawn.
|
"""The window contents should be redrawn.
|
||||||
|
|
||||||
The `EventLoop` will dispatch this event when the window
|
The `EventLoop` will dispatch this event when the `draw`
|
||||||
should be redrawn.
|
method has been called. The window will already have the
|
||||||
|
GL context, so there is no need to call `switch_to`. The window's
|
||||||
The window will already have the GL context, so there is no
|
`flip` method will be called immediately after this event, so your
|
||||||
need to call `switch_to`. The window's `flip` method will
|
event handler should not.
|
||||||
be called after this event, so your event handler should not.
|
|
||||||
|
|
||||||
You should make no assumptions about the window contents when
|
You should make no assumptions about the window contents when
|
||||||
this event is triggered; a resize or expose event may have
|
this event is triggered; a resize or expose event may have
|
||||||
|
@ -11,9 +11,9 @@ import logging
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from xml.etree.ElementTree import Element
|
|
||||||
from typing import List, TYPE_CHECKING, Union, Dict, Optional, Generator, Tuple
|
|
||||||
from defusedxml.ElementTree import parse
|
from defusedxml.ElementTree import parse
|
||||||
|
from xml.etree.ElementTree import Element, ElementTree
|
||||||
|
from typing import List, TYPE_CHECKING, Union, Dict, Optional, Generator, Tuple
|
||||||
|
|
||||||
from pyglet.math import Vec4
|
from pyglet.math import Vec4
|
||||||
from pyglet.text import Label
|
from pyglet.text import Label
|
||||||
@ -43,6 +43,7 @@ if DR_mod_runtime.use_DR_rust:
|
|||||||
SR1Ship_rs)
|
SR1Ship_rs)
|
||||||
|
|
||||||
logger = logging.getLogger('client.dr_game_sr1_ship')
|
logger = logging.getLogger('client.dr_game_sr1_ship')
|
||||||
|
logger.level = logging.DEBUG
|
||||||
sr_tr = Tr(lang_path=Path(__file__).parent / 'lang')
|
sr_tr = Tr(lang_path=Path(__file__).parent / 'lang')
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ def get_sr1_part(part_xml: Element) -> Optional[SR1PartData]:
|
|||||||
flip_y=part_flip_y, explode=part_explode, textures=part_textures)
|
flip_y=part_flip_y, explode=part_explode, textures=part_textures)
|
||||||
|
|
||||||
|
|
||||||
class _SR1ShipRender_Option(Options):
|
class SR1ShipRender_Option(Options):
|
||||||
# debug option
|
# debug option
|
||||||
debug_d_pos: bool = False
|
debug_d_pos: bool = False
|
||||||
debug_mouse_pos: bool = False
|
debug_mouse_pos: bool = False
|
||||||
@ -85,45 +86,51 @@ class SR1ShipRender(BaseScreen):
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
main_window: "ClientWindow"):
|
main_window: "ClientWindow"):
|
||||||
super().__init__(main_window)
|
super().__init__(main_window)
|
||||||
|
self.logger = logger
|
||||||
logger.info(sr_tr().mod.info.setup.start())
|
logger.info(sr_tr().mod.info.setup.start())
|
||||||
load_start_time = time.time_ns()
|
load_start_time = time.time_ns()
|
||||||
self.rendered = False
|
self.rendered = False
|
||||||
self.focus = True
|
self.focus = True
|
||||||
self.need_draw = False
|
self.need_draw = False
|
||||||
self.drawing = False
|
self.drawing = False
|
||||||
self.gen_draw: Optional[Generator] = None
|
|
||||||
self.need_update_parts = False
|
self.need_update_parts = False
|
||||||
self.render_option = _SR1ShipRender_Option()
|
self.render_option = SR1ShipRender_Option()
|
||||||
self.dx = 0
|
self.dx = 0
|
||||||
self.dy = 0
|
self.dy = 0
|
||||||
self.debug_mouse_delta_line = Line(main_window.width / 2, main_window.height / 2,
|
|
||||||
main_window.width / 2, main_window.height / 2,
|
|
||||||
width=2, color=(200, 200, 10, 255))
|
|
||||||
self.debug_mouse_delta_line.visible = self.render_option.debug_mouse_d_pos
|
|
||||||
self.debug_d_pos_label = Label('debug label NODATA', font_name=Fonts.微软等宽无线,
|
|
||||||
x=main_window.width / 2, y=main_window.height / 2)
|
|
||||||
self.debug_d_pos_label.visible = self.render_option.debug_d_pos
|
|
||||||
self.textures: Union[SR1Textures, None] = None
|
|
||||||
# self.xml_name = 'configs/dock1.xml'
|
|
||||||
# self.xml_doc: ElementTree = parse('configs/dock1.xml')
|
|
||||||
# self.xml_root: ElementTree.Element = self.xml_doc.getroot()
|
|
||||||
self.load_xml('configs/dock1.xml')
|
|
||||||
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)
|
||||||
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,
|
||||||
text='SR1 render!', font_name=Fonts.微软等宽无线,
|
text='SR1 render!', font_name=Fonts.微软等宽无线,
|
||||||
width=main_window.width - 20, height=20,
|
width=main_window.width - 20, height=20,
|
||||||
anchor_x='left', anchor_y='top')
|
anchor_x='left', anchor_y='top',
|
||||||
|
batch=self.main_batch, group=Group(5, parent=self.part_group))
|
||||||
|
self.render_d_line = Line(0, 0, 0, 0, width=5, color=(200, 200, 10, 255),
|
||||||
|
batch=self.main_batch, group=Group(5, parent=self.part_group))
|
||||||
|
self.render_d_line.visible = self.render_option.debug_mouse_d_pos
|
||||||
|
self.render_d_label = Label('debug label NODATA', font_name=Fonts.微软等宽无线,
|
||||||
|
x=main_window.width / 2, y=main_window.height / 2)
|
||||||
|
self.render_d_label.visible = self.render_option.debug_d_pos
|
||||||
|
|
||||||
|
# Optional data
|
||||||
|
self.gen_draw: Optional[Generator] = None
|
||||||
|
self.textures: Union[SR1Textures, None] = None
|
||||||
|
self.xml_name: Optional[str] = None
|
||||||
|
self.xml_doc: Optional[ElementTree] = None
|
||||||
|
self.xml_root: Optional[Element] = None
|
||||||
|
self.rust_ship: Optional[SR1Ship_rs] = None
|
||||||
|
|
||||||
|
# List/Dict data
|
||||||
self.part_data: Dict[int, SR1PartData] = {}
|
self.part_data: Dict[int, SR1PartData] = {}
|
||||||
self.parts_sprite: Dict[int, Sprite] = {}
|
self.parts_sprite: Dict[int, Sprite] = {}
|
||||||
self.part_box_dict: Dict[int, Rectangle] = {}
|
self.part_box_dict: Dict[int, Rectangle] = {}
|
||||||
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] = []
|
||||||
|
|
||||||
|
self.load_xml('configs/dock1.xml')
|
||||||
|
|
||||||
load_end_time = time.time_ns()
|
load_end_time = time.time_ns()
|
||||||
logger.info(sr_tr().mod.info.setup.use_time().format(
|
logger.info(sr_tr().mod.info.setup.use_time().format((load_end_time - load_start_time) / 1000000000))
|
||||||
(load_end_time - load_start_time) / 1000000000))
|
self.camera = CenterCamera(main_window, min_zoom=(1 / 2) ** 10, max_zoom=10)
|
||||||
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('configs/PartList.xml', 'default_part_list')
|
self.part_list_rs = SR1PartList_rs('configs/PartList.xml', 'default_part_list')
|
||||||
@ -181,7 +188,8 @@ class SR1ShipRender(BaseScreen):
|
|||||||
# 线框
|
# 线框
|
||||||
part_line_box = []
|
part_line_box = []
|
||||||
width = 4
|
width = 4
|
||||||
color = (random.randrange(0, 255), random.randrange(0, 255), random.randrange(0, 255), random.randrange(100, 200))
|
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,
|
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,
|
x2=part_debug_box[0][0] * 30, y2=part_debug_box[1][1] * 30,
|
||||||
batch=self.main_batch, width=width, color=color, group=line_box_group))
|
batch=self.main_batch, width=width, color=color, group=line_box_group))
|
||||||
@ -256,15 +264,13 @@ class SR1ShipRender(BaseScreen):
|
|||||||
len(self.part_data), f'{full_mass}kg' if DR_mod_runtime.use_DR_rust else sr_tr().game.require_DR_rs()))
|
len(self.part_data), f'{full_mass}kg' if DR_mod_runtime.use_DR_rust else sr_tr().game.require_DR_rs()))
|
||||||
self.rendered = True
|
self.rendered = True
|
||||||
|
|
||||||
def update_parts(self) -> bool:
|
|
||||||
if not self.rendered:
|
|
||||||
return False
|
|
||||||
self.debug_d_pos_label.text = f'x: {self.camera.dx} y: {self.camera.dy}'
|
|
||||||
self.debug_d_pos_label.position = self.camera.dx + (self.window_pointer.width / 2), self.camera.dy + (
|
|
||||||
self.window_pointer.height / 2) + 10, 0
|
|
||||||
self.need_update_parts = False
|
|
||||||
|
|
||||||
def draw_batch(self, window: "ClientWindow"):
|
def draw_batch(self, window: "ClientWindow"):
|
||||||
|
if self.rendered:
|
||||||
|
self.render_d_label.text = f'x: {self.camera.dx} y: {self.camera.dy}'
|
||||||
|
self.render_d_label.position = self.camera.dx + (self.window_pointer.width / 2), self.camera.dy + (
|
||||||
|
self.window_pointer.height / 2) + 10, 0 # 0 for z
|
||||||
|
self.render_d_line.x2 = self.camera.dx
|
||||||
|
self.render_d_line.y2 = self.camera.dy
|
||||||
with self.camera:
|
with self.camera:
|
||||||
# glViewport(int(self.camera.dx), int(self.camera.dy), window.width // 2, window.height // 2)
|
# glViewport(int(self.camera.dx), int(self.camera.dy), window.width // 2, window.height // 2)
|
||||||
self.main_batch.draw()
|
self.main_batch.draw()
|
||||||
@ -279,23 +285,16 @@ class SR1ShipRender(BaseScreen):
|
|||||||
next(self.gen_draw)
|
next(self.gen_draw)
|
||||||
except GeneratorExit:
|
except GeneratorExit:
|
||||||
self.drawing = False
|
self.drawing = False
|
||||||
logger.info(sr_tr().sr1.ship.ship.render.done())
|
self.logger.info(sr_tr().sr1.ship.ship.render.done())
|
||||||
|
|
||||||
if self.need_update_parts:
|
|
||||||
self.update_parts()
|
|
||||||
self.need_update_parts = False
|
|
||||||
|
|
||||||
self.debug_label.draw()
|
self.debug_label.draw()
|
||||||
|
|
||||||
if self.render_option.debug_mouse_d_pos:
|
|
||||||
self.debug_mouse_delta_line.draw()
|
|
||||||
|
|
||||||
def on_resize(self, width: int, height: int, window: "ClientWindow"):
|
def on_resize(self, width: int, height: int, window: "ClientWindow"):
|
||||||
self.debug_label.y = height - 100
|
self.debug_label.y = height - 100
|
||||||
if not self.rendered:
|
if not self.rendered:
|
||||||
return
|
return
|
||||||
self.debug_mouse_delta_line.y = height / 2
|
self.render_d_line.x2 = width // 2
|
||||||
self.update_parts()
|
self.render_d_line.y2 = height // 2
|
||||||
self.render_option.draw_size = (width, height)
|
self.render_option.draw_size = (width, height)
|
||||||
|
|
||||||
def on_mouse_scroll(self, x: int, y: int, scroll_x: int, scroll_y: int, window: "ClientWindow"):
|
def on_mouse_scroll(self, x: int, y: int, scroll_x: int, scroll_y: int, window: "ClientWindow"):
|
||||||
@ -323,13 +322,9 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.camera.dx += mouse_dx_d
|
self.camera.dx += mouse_dx_d
|
||||||
self.camera.dy += mouse_dy_d
|
self.camera.dy += mouse_dy_d
|
||||||
|
|
||||||
self.debug_mouse_delta_line.x2 = (mouse_dx - self.camera.dx) * (1 - (0.5 ** scroll_y)) + (
|
|
||||||
window.width / 2)
|
|
||||||
self.debug_mouse_delta_line.y2 = (mouse_dy - self.camera.dy) * (1 - (0.5 ** scroll_y)) + (
|
|
||||||
window.height / 2)
|
|
||||||
self.need_update_parts = True
|
|
||||||
|
|
||||||
def on_command(self, command: CommandText, window: "ClientWindow"):
|
def on_command(self, command: CommandText, window: "ClientWindow"):
|
||||||
|
self.logger.info(f'command: {command}')
|
||||||
if command.find('render'):
|
if command.find('render'):
|
||||||
if command.find('reset'):
|
if command.find('reset'):
|
||||||
self.camera.zoom = 1
|
self.camera.zoom = 1
|
||||||
@ -340,10 +335,10 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.need_draw = True
|
self.need_draw = True
|
||||||
print('应该渲染飞船的')
|
print('应该渲染飞船的')
|
||||||
elif command.find('debug'):
|
elif command.find('debug'):
|
||||||
if command.find('mouse'):
|
if command.find('delta'):
|
||||||
self.debug_mouse_delta_line.visible = not self.debug_mouse_delta_line.visible
|
self.render_d_line.visible = not self.render_d_line.visible
|
||||||
self.render_option.debug_mouse_d_pos = self.debug_mouse_delta_line.visible
|
self.render_option.debug_mouse_d_pos = self.render_d_line.visible
|
||||||
logger.debug(f'sr1 mouse {self.render_option.debug_mouse_d_pos}')
|
self.logger.info(f'sr1 mouse {self.render_option.debug_mouse_d_pos}')
|
||||||
elif command.find('ship'):
|
elif command.find('ship'):
|
||||||
if self.rendered:
|
if self.rendered:
|
||||||
for index, sprite in self.parts_sprite.items():
|
for index, sprite in self.parts_sprite.items():
|
||||||
@ -393,7 +388,9 @@ class SR1ShipRender(BaseScreen):
|
|||||||
pil_image.transpose(Image.FLIP_TOP_BOTTOM)
|
pil_image.transpose(Image.FLIP_TOP_BOTTOM)
|
||||||
if self.part_data[part].flip_x:
|
if self.part_data[part].flip_x:
|
||||||
pil_image.transpose(Image.FLIP_LEFT_RIGHT)
|
pil_image.transpose(Image.FLIP_LEFT_RIGHT)
|
||||||
img.paste(pil_image, (int(self.part_data[part].x * 60 + img_center[0]), int(-self.part_data[part].y * 60 + img_center[1])), pil_image)
|
img.paste(pil_image, (
|
||||||
|
int(self.part_data[part].x * 60 + img_center[0]), int(-self.part_data[part].y * 60 + img_center[1])),
|
||||||
|
pil_image)
|
||||||
img.save(f'test{time.time()}.png', 'PNG')
|
img.save(f'test{time.time()}.png', 'PNG')
|
||||||
|
|
||||||
elif command.find('test'):
|
elif command.find('test'):
|
||||||
@ -425,4 +422,4 @@ class SR1ShipRender(BaseScreen):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from objprint import op
|
from objprint import op
|
||||||
|
|
||||||
op(_SR1ShipRender_Option())
|
op(SR1ShipRender_Option())
|
||||||
|
Loading…
Reference in New Issue
Block a user