Feature/get named logger #29

Merged
shenjackyuanjie merged 4 commits from feature/get_named_logger into main 2023-06-17 00:09:26 +08:00
12 changed files with 30 additions and 28 deletions
Showing only changes of commit bf3e598369 - Show all commits

4
DR.py
View File

@ -52,7 +52,7 @@ def main() -> int:
from Difficult_Rocket.exception import TestError from Difficult_Rocket.exception import TestError
from Difficult_Rocket import crash from Difficult_Rocket import crash
from Difficult_Rocket import DR_option from Difficult_Rocket import DR_status
try: try:
from libs import pyglet # 导入pyglet from libs import pyglet # 导入pyglet
pyglet.resource.path = ['/textures/'] pyglet.resource.path = ['/textures/']
@ -72,7 +72,7 @@ def main() -> int:
cProfile.run('game.start()', sort='calls') # 使用 cprofile 启动 cProfile.run('game.start()', sort='calls') # 使用 cprofile 启动
else: else:
game.start() # 直接启动 game.start() # 直接启动
if DR_option.crash_report_test: if DR_status.crash_report_test:
raise TestError('debugging') # debug 嘛试试crash raise TestError('debugging') # debug 嘛试试crash
except Exception as exp: # 出毛病了 except Exception as exp: # 出毛病了
# 解析错误信息 # 解析错误信息

View File

@ -48,8 +48,6 @@ class _DR_status(Options):
API_version: Version = Api_version # DR SDK API 版本 API_version: Version = Api_version # DR SDK API 版本
# game options # game options
language: str = 'zh-CN'
mod_path: str = './mods'
default_language: str = 'zh-CN' default_language: str = 'zh-CN'
# window option # window option
@ -62,10 +60,12 @@ class _DR_status(Options):
class _DR_runtime(Options): class _DR_runtime(Options):
""" """
DR 的运行时配置/状态 DR 的运行时配置 / 状态
""" """
name = 'DR Runtime' name = 'DR Runtime'
language: str = 'zh-CN'
mod_path: str = './mods'
DR_Mod_List: List[Tuple[str, Version]] = [] # DR Mod 列表 (name, version) DR_Mod_List: List[Tuple[str, Version]] = [] # DR Mod 列表 (name, version)
# run status # run status

View File

@ -31,7 +31,7 @@ from pyglet.text.layout import IncrementalTextLayout
from Difficult_Rocket.api.types import FontData, Fonts from Difficult_Rocket.api.types import FontData, Fonts
# from Difficult_Rocket.client.guis.format import html # from Difficult_Rocket.client.guis.format import html
from Difficult_Rocket import DR_option from Difficult_Rocket import DR_status
__all__ = ['InputBox'] __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): class InputBox(widgets.TextEntry):
""" 自定义的输入框 """ """ 自定义的输入框 """
@ -134,7 +134,7 @@ if not DR_option.InputBox_use_TextEntry:
# dpi=font_dpi) # dpi=font_dpi)
# self.font_height = self.font.ascent - self.font.descent # self.font_height = self.font.ascent - self.font.descent
# self.out_bound = out_line # self.out_bound = out_line
# if DR_option.InputBox_use_TextEntry: # if DR_status.InputBox_use_TextEntry:
# # 基于IncrementalTextLayout的处理系统 # # 基于IncrementalTextLayout的处理系统
# self._doc = FormattedDocument(message) # self._doc = FormattedDocument(message)
# # self._doc.set_style() # # self._doc.set_style()

View File

@ -99,14 +99,14 @@ def write_cache(cache_stream, crash_info):
def write_info_to_cache(cache_stream): 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(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 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'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(markdown_line_handler(f'Running Dir: {Path(os.curdir).resolve()}', level=1))
cache_stream.write(f"\n{DR_runtime.as_markdown()}") cache_stream.write(f"\n{DR_runtime.as_markdown()}")
cache_stream.write(DR_configs) 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) cache_stream.write(Process_message)
for process in all_process: for process in all_process:
process: multiprocessing.Process process: multiprocessing.Process

View File

@ -22,7 +22,7 @@ if TYPE_CHECKING:
else: else:
Game = TypeVar("Game") Game = TypeVar("Game")
ClientWindow = TypeVar("ClientWindow") ClientWindow = TypeVar("ClientWindow")
from Difficult_Rocket import DR_runtime from Difficult_Rocket import DR_status
from Difficult_Rocket.api.types import Options, Version from Difficult_Rocket.api.types import Options, Version
RequireVersion = Tuple[Version, Version] RequireVersion = Tuple[Version, Version]
@ -47,8 +47,8 @@ class ModInfo(Options):
info: str = "" # 其他信息 (可以很多很多) info: str = "" # 其他信息 (可以很多很多)
"""版本相关信息""" """版本相关信息"""
DR_version: RequireVersion = (DR_runtime.DR_version, DR_runtime.DR_version) # DR SDK 兼容版本 DR_version: RequireVersion = (DR_status.DR_version, DR_status.DR_version) # DR SDK 兼容版本
DR_Api_version: RequireVersion = (DR_runtime.API_version, DR_runtime.API_version) # DR Api版本 DR_Api_version: RequireVersion = (DR_status.API_version, DR_status.API_version) # DR Api版本
Mod_Require_version: List[Tuple[str, ForceRequire, RequireVersion]] = [] # mod 依赖版本 Mod_Require_version: List[Tuple[str, ForceRequire, RequireVersion]] = [] # mod 依赖版本
"""mod 状态""" """mod 状态"""

View File

@ -11,7 +11,7 @@ from typing import List, Dict, Optional
from Difficult_Rocket.api.screen import BaseScreen from Difficult_Rocket.api.screen import BaseScreen
from Difficult_Rocket.api.types import Options, Version from Difficult_Rocket.api.types import Options, Version
from Difficult_Rocket.mod.api import ModInfo 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): class ModManager(Options):

View File

@ -17,7 +17,7 @@ import inspect
from dataclasses import dataclass from dataclasses import dataclass
from typing import Union, Tuple, Any, List, Dict, Hashable, Optional 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.utils import tools
from Difficult_Rocket.exception.language import (LanguageNotFound, from Difficult_Rocket.exception.language import (LanguageNotFound,
TranslateKeyNotFound) TranslateKeyNotFound)
@ -82,7 +82,7 @@ class Translates:
def _raise_no_value(self, e: Exception, item: key_type): def _raise_no_value(self, e: Exception, item: key_type):
if self._config.raise_error: if self._config.raise_error:
raise TranslateKeyNotFound(self._value, [x[1] for x in self._get_list]) from None 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() frame = inspect.currentframe()
if frame is not None: if frame is not None:
frame = frame.f_back.f_back 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.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.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.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()) self.translates_cache = Translates(value=self.translates, config=self.default_config.copy())

View File

@ -2,9 +2,15 @@
# DR game/DR rs 更新日志 # DR game/DR rs 更新日志
- 最新版本号 - 最新版本号
- DR game: 0.1.1.0 - DR game: 0.2.0.0
- DR rs: 0.2.10.1 - DR rs: 0.2.10.1
## DR game 0.2.0.0
### 适配
- 适配了 `DR_sdk` `0.8.3.0` 的修改
## DR game 0.1.1.0 ## DR game 0.1.1.0
### 添加 ### 添加

View File

@ -22,10 +22,9 @@
- `Difficult_Rocket.DR_runtime` - `Difficult_Rocket.DR_runtime`
- `DR_version` -> `DR_status.DR_version` - `DR_version` -> `DR_status.DR_version`
- `Build_version` -> `DR_status.Build_version`
- `API_version` -> `DR_status.API_version` - `API_version` -> `DR_status.API_version`
- `language` -> `DR_status.language` - `Build_version` -> `DR_status.Build_version`
- `mod_path` -> `DR_status.mod_path` - `default_language` -> `DR_status.default_language`
### 删除 ### 删除

View File

@ -1,3 +0,0 @@
python3.8 setup.py build
python3.9 setup.py build
python3.9 post_build.py

View File

@ -49,7 +49,7 @@ class DR_mod(ModInfo):
mod_id = "difficult_rocket_mod" mod_id = "difficult_rocket_mod"
name = "Difficult Rocket mod" name = "Difficult Rocket mod"
version = Version("0.1.0.0") version = Version("0.2.0.0")
writer = "shenjackyuanjie" writer = "shenjackyuanjie"
link = "shenjack.top" link = "shenjack.top"

View File

@ -27,7 +27,7 @@ from pyglet.graphics import Batch, Group
from . import DR_mod_runtime from . import DR_mod_runtime
# Difficult Rocket # Difficult Rocket
from Difficult_Rocket import DR_option from Difficult_Rocket import DR_status
from Difficult_Rocket.utils.translate import tr from Difficult_Rocket.utils.translate import tr
from Difficult_Rocket.api.types import Fonts, Options from Difficult_Rocket.api.types import Fonts, Options
from Difficult_Rocket.command.line import CommandText from Difficult_Rocket.command.line import CommandText
@ -124,7 +124,7 @@ class SR1ShipRender(BaseScreen):
self.part_box_batch = Batch() self.part_box_batch = Batch()
self.part_batch = Batch() self.part_batch = Batch()
self.part_group = Group() 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.微软等宽无线, 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')
@ -171,7 +171,7 @@ class SR1ShipRender(BaseScreen):
self.drawing = True self.drawing = True
for part_id, part in part_datas.items(): for part_id, part in part_datas.items():
# 下面就是调用 pyglet 去渲染的部分 # 下面就是调用 pyglet 去渲染的部分
# render_scale = DR_option.gui_scale # 这个是 DR 的缩放比例 可以调节的( # render_scale = DR_status.gui_scale # 这个是 DR 的缩放比例 可以调节的(
# 主要是 Windows 下有一个缩放系数嘛,我待会试试这玩意能不能获取(估计得 ctypes # 主要是 Windows 下有一个缩放系数嘛,我待会试试这玩意能不能获取(估计得 ctypes
# 在不缩放的情况下XML的1个单位长度对应60个像素 # 在不缩放的情况下XML的1个单位长度对应60个像素
render_x = part.x * 60 render_x = part.x * 60