From bf3e59836946dbb17a1c201551785d9d3b1837f3 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 16 Jun 2023 23:36:24 +0800 Subject: [PATCH] a lot --- DR.py | 4 ++-- Difficult_Rocket/__init__.py | 6 +++--- Difficult_Rocket/client/guis/widgets.py | 6 +++--- Difficult_Rocket/crash/__init__.py | 4 ++-- Difficult_Rocket/mod/api/__init__.py | 6 +++--- Difficult_Rocket/mod/loader/__init__.py | 2 +- Difficult_Rocket/utils/translate.py | 6 +++--- docs/src/change_log/dr_game.md | 8 +++++++- docs/src/change_log/dr_sdk.md | 5 ++--- mods/dr_game/Difficult_Rocket_rs/src/mac-build.ps1 | 3 --- mods/dr_game/__init__.py | 2 +- mods/dr_game/sr1_ship.py | 6 +++--- 12 files changed, 30 insertions(+), 28 deletions(-) delete mode 100644 mods/dr_game/Difficult_Rocket_rs/src/mac-build.ps1 diff --git a/DR.py b/DR.py index 9c5addc..4a235cf 100644 --- a/DR.py +++ b/DR.py @@ -52,7 +52,7 @@ def main() -> int: from Difficult_Rocket.exception import TestError from Difficult_Rocket import crash - from Difficult_Rocket import DR_option + from Difficult_Rocket import DR_status try: from libs import pyglet # 导入pyglet pyglet.resource.path = ['/textures/'] @@ -72,7 +72,7 @@ def main() -> int: cProfile.run('game.start()', sort='calls') # 使用 cprofile 启动 else: game.start() # 直接启动 - if DR_option.crash_report_test: + if DR_status.crash_report_test: raise TestError('debugging') # debug 嘛,试试crash except Exception as exp: # 出毛病了 # 解析错误信息 diff --git a/Difficult_Rocket/__init__.py b/Difficult_Rocket/__init__.py index 201f00a..ee92659 100644 --- a/Difficult_Rocket/__init__.py +++ b/Difficult_Rocket/__init__.py @@ -48,8 +48,6 @@ class _DR_status(Options): API_version: Version = Api_version # DR SDK API 版本 # game options - language: str = 'zh-CN' - mod_path: str = './mods' default_language: str = 'zh-CN' # window option @@ -62,10 +60,12 @@ class _DR_status(Options): class _DR_runtime(Options): """ - DR 的运行时配置/状态 + DR 的运行时配置 / 状态 """ name = 'DR Runtime' + language: str = 'zh-CN' + mod_path: str = './mods' DR_Mod_List: List[Tuple[str, Version]] = [] # DR Mod 列表 (name, version) # run status diff --git a/Difficult_Rocket/client/guis/widgets.py b/Difficult_Rocket/client/guis/widgets.py index 343453b..c1ab651 100644 --- a/Difficult_Rocket/client/guis/widgets.py +++ b/Difficult_Rocket/client/guis/widgets.py @@ -31,7 +31,7 @@ from pyglet.text.layout import IncrementalTextLayout from Difficult_Rocket.api.types import FontData, Fonts # from Difficult_Rocket.client.guis.format import html -from Difficult_Rocket import DR_option +from Difficult_Rocket import DR_status __all__ = ['InputBox'] @@ -59,7 +59,7 @@ class TextButton(widgets.WidgetBase): ... -if not DR_option.InputBox_use_TextEntry: +if not DR_status.InputBox_use_TextEntry: class InputBox(widgets.TextEntry): """ 自定义的输入框 """ @@ -134,7 +134,7 @@ if not DR_option.InputBox_use_TextEntry: # dpi=font_dpi) # self.font_height = self.font.ascent - self.font.descent # self.out_bound = out_line - # if DR_option.InputBox_use_TextEntry: + # if DR_status.InputBox_use_TextEntry: # # 基于IncrementalTextLayout的处理系统 # self._doc = FormattedDocument(message) # # self._doc.set_style() diff --git a/Difficult_Rocket/crash/__init__.py b/Difficult_Rocket/crash/__init__.py index e7a8316..daad3ae 100644 --- a/Difficult_Rocket/crash/__init__.py +++ b/Difficult_Rocket/crash/__init__.py @@ -99,14 +99,14 @@ def write_cache(cache_stream, crash_info): def write_info_to_cache(cache_stream): # 运行状态信息 - from Difficult_Rocket import DR_option, DR_runtime + from Difficult_Rocket import DR_status, DR_runtime cache_stream.write(Run_message) cache_stream.write(markdown_line_handler(f'DR Version: {Difficult_Rocket.game_version}', level=1)) cache_stream.write(markdown_line_handler(f'DR language: {DR_runtime.language}', level=1)) cache_stream.write(markdown_line_handler(f'Running Dir: {Path(os.curdir).resolve()}', level=1)) cache_stream.write(f"\n{DR_runtime.as_markdown()}") cache_stream.write(DR_configs) - cache_stream.write(f"\n{DR_option.as_markdown()}") + cache_stream.write(f"\n{DR_status.as_markdown()}") cache_stream.write(Process_message) for process in all_process: process: multiprocessing.Process diff --git a/Difficult_Rocket/mod/api/__init__.py b/Difficult_Rocket/mod/api/__init__.py index 4ebc331..02192ee 100644 --- a/Difficult_Rocket/mod/api/__init__.py +++ b/Difficult_Rocket/mod/api/__init__.py @@ -22,7 +22,7 @@ if TYPE_CHECKING: else: Game = TypeVar("Game") ClientWindow = TypeVar("ClientWindow") -from Difficult_Rocket import DR_runtime +from Difficult_Rocket import DR_status from Difficult_Rocket.api.types import Options, Version RequireVersion = Tuple[Version, Version] @@ -47,8 +47,8 @@ class ModInfo(Options): info: str = "" # 其他信息 (可以很多很多) """版本相关信息""" - DR_version: RequireVersion = (DR_runtime.DR_version, DR_runtime.DR_version) # DR SDK 兼容版本 - DR_Api_version: RequireVersion = (DR_runtime.API_version, DR_runtime.API_version) # DR Api版本 + DR_version: RequireVersion = (DR_status.DR_version, DR_status.DR_version) # DR SDK 兼容版本 + DR_Api_version: RequireVersion = (DR_status.API_version, DR_status.API_version) # DR Api版本 Mod_Require_version: List[Tuple[str, ForceRequire, RequireVersion]] = [] # mod 依赖版本 """mod 状态""" diff --git a/Difficult_Rocket/mod/loader/__init__.py b/Difficult_Rocket/mod/loader/__init__.py index 58d54c4..c44d821 100644 --- a/Difficult_Rocket/mod/loader/__init__.py +++ b/Difficult_Rocket/mod/loader/__init__.py @@ -11,7 +11,7 @@ from typing import List, Dict, Optional from Difficult_Rocket.api.screen import BaseScreen from Difficult_Rocket.api.types import Options, Version from Difficult_Rocket.mod.api import ModInfo -# from Difficult_Rocket import DR_option, DR_runtime +# from Difficult_Rocket import DR_status, DR_runtime class ModManager(Options): diff --git a/Difficult_Rocket/utils/translate.py b/Difficult_Rocket/utils/translate.py index 63f5de1..e7ffaa6 100644 --- a/Difficult_Rocket/utils/translate.py +++ b/Difficult_Rocket/utils/translate.py @@ -17,7 +17,7 @@ import inspect from dataclasses import dataclass from typing import Union, Tuple, Any, List, Dict, Hashable, Optional -from Difficult_Rocket import DR_runtime, DR_option +from Difficult_Rocket import DR_runtime, DR_status from Difficult_Rocket.utils import tools from Difficult_Rocket.exception.language import (LanguageNotFound, TranslateKeyNotFound) @@ -82,7 +82,7 @@ class Translates: def _raise_no_value(self, e: Exception, item: key_type): if self._config.raise_error: raise TranslateKeyNotFound(self._value, [x[1] for x in self._get_list]) from None - elif DR_option.report_translate_not_found: + elif DR_status.report_translate_not_found: frame = inspect.currentframe() if frame is not None: frame = frame.f_back.f_back @@ -160,7 +160,7 @@ class Tr: """ self.language_name = language if language is not None else DR_runtime.language self.translates: Dict[str, Union[str, Dict]] = tools.load_file(f'configs/lang/{self.language_name}.toml') - self.default_translate: Dict = tools.load_file(f'configs/lang/{DR_runtime.default_language}.toml') + self.default_translate: Dict = tools.load_file(f'configs/lang/{DR_status.default_language}.toml') self.default_config = config.set('source', self) if config is not None else TranslateConfig(source=self) self.translates_cache = Translates(value=self.translates, config=self.default_config.copy()) diff --git a/docs/src/change_log/dr_game.md b/docs/src/change_log/dr_game.md index 5b9b8fd..94a7ada 100644 --- a/docs/src/change_log/dr_game.md +++ b/docs/src/change_log/dr_game.md @@ -2,9 +2,15 @@ # DR game/DR rs 更新日志 - 最新版本号 - - DR game: 0.1.1.0 + - DR game: 0.2.0.0 - DR rs: 0.2.10.1 +## DR game 0.2.0.0 + +### 适配 + +- 适配了 `DR_sdk` `0.8.3.0` 的修改 + ## DR game 0.1.1.0 ### 添加 diff --git a/docs/src/change_log/dr_sdk.md b/docs/src/change_log/dr_sdk.md index e391237..0f9a752 100644 --- a/docs/src/change_log/dr_sdk.md +++ b/docs/src/change_log/dr_sdk.md @@ -22,10 +22,9 @@ - `Difficult_Rocket.DR_runtime` - `DR_version` -> `DR_status.DR_version` - - `Build_version` -> `DR_status.Build_version` - `API_version` -> `DR_status.API_version` - - `language` -> `DR_status.language` - - `mod_path` -> `DR_status.mod_path` + - `Build_version` -> `DR_status.Build_version` + - `default_language` -> `DR_status.default_language` ### 删除 diff --git a/mods/dr_game/Difficult_Rocket_rs/src/mac-build.ps1 b/mods/dr_game/Difficult_Rocket_rs/src/mac-build.ps1 deleted file mode 100644 index f7e1730..0000000 --- a/mods/dr_game/Difficult_Rocket_rs/src/mac-build.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -python3.8 setup.py build -python3.9 setup.py build -python3.9 post_build.py diff --git a/mods/dr_game/__init__.py b/mods/dr_game/__init__.py index 3b247a6..3fd777a 100644 --- a/mods/dr_game/__init__.py +++ b/mods/dr_game/__init__.py @@ -49,7 +49,7 @@ class DR_mod(ModInfo): mod_id = "difficult_rocket_mod" name = "Difficult Rocket mod" - version = Version("0.1.0.0") + version = Version("0.2.0.0") writer = "shenjackyuanjie" link = "shenjack.top" diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index 746c05b..2019883 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -27,7 +27,7 @@ from pyglet.graphics import Batch, Group from . import DR_mod_runtime # Difficult Rocket -from Difficult_Rocket import DR_option +from Difficult_Rocket import DR_status from Difficult_Rocket.utils.translate import tr from Difficult_Rocket.api.types import Fonts, Options from Difficult_Rocket.command.line import CommandText @@ -124,7 +124,7 @@ class SR1ShipRender(BaseScreen): self.part_box_batch = Batch() self.part_batch = Batch() self.part_group = Group() - self.debug_label = Label(x=20, y=main_window.height - 20, font_size=DR_option.std_font_size, + self.debug_label = Label(x=20, y=main_window.height - 20, font_size=DR_status.std_font_size, text='SR1 render!', font_name=Fonts.微软等宽无线, width=main_window.width - 20, height=20, anchor_x='left', anchor_y='top') @@ -171,7 +171,7 @@ class SR1ShipRender(BaseScreen): self.drawing = True for part_id, part in part_datas.items(): # 下面就是调用 pyglet 去渲染的部分 - # render_scale = DR_option.gui_scale # 这个是 DR 的缩放比例 可以调节的( + # render_scale = DR_status.gui_scale # 这个是 DR 的缩放比例 可以调节的( # 主要是 Windows 下有一个缩放系数嘛,我待会试试这玩意能不能获取(估计得 ctypes # 在不缩放的情况下,XML的1个单位长度对应60个像素 render_x = part.x * 60