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
7 changed files with 79 additions and 172 deletions
Showing only changes of commit 0e7adcb3a0 - Show all commits

View File

@ -19,43 +19,21 @@ build_version = Version("2.1.0.0") # 编译文件版本(与游戏本体无关)
Api_version = Version("0.1.1.0") # API 版本
__version__ = game_version
long_version: int = 15
"""
long_version: 一个用于标记内部协议的整数
15: 完全移除 DR_rust 相关内容 解耦完成
14: BaseScreen 的每一个函数都添加了一个参数: window: "ClientWindow"
13: DR_runtime 添加 API_version
12: 去除 DR_runtime global_logger
logging 自己拿去
11: DR_option 添加 use_DR_rust
修复了一些拼写错误
10: DR_runtime 添加 DR_Rust_get_version
9 : DR_option 添加 pyglet_macosx_dev_test
8 : DR_runtime 添加 DR_rust_version
DR_option 添加 DR_rust_available
以后就有 DR_rust
7 : DR_option 添加 std_font_size
6 : 事实证明, 不如直接用int
5 : 添加 build_version 信息,用于标记编译文件版本,
游戏版本改为四位数终于有一个可以让我随便刷的版本号位数了
4 : translate 的字体常量位置改了一下,顺便调换顺序
3 : 就是试试改一下正好 compiler 要用
2 : longlong 好耶
1 : 我可算想起来还有这回事了 v0.6.4
"""
class _DR_option(Options):
class _DR_status(Options):
"""
DR 一般配置/状态
DR 的特性开关 / 基本状态
"""
name = 'DR Option'
# runtime options
# run status
client_running: bool = False
server_running: bool = False
# feature switch
InputBox_use_TextEntry: bool = True
record_threads: bool = True
report_translate_not_found: bool = True
use_multiprocess: bool = False
DR_rust_available: bool = False
use_cProfile: bool = False
use_local_logging: bool = False
@ -64,6 +42,16 @@ class _DR_option(Options):
debugging: bool = False
crash_report_test: bool = False
# game version status
DR_version: Version = game_version # DR SDK 版本
Build_version: Version = build_version # DR 构建 版本
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
gui_scale: float = 1.0 # default 1.0 2.0 -> 2x 3 -> 3x
@ -77,29 +65,14 @@ class _DR_runtime(Options):
DR 的运行时配置/状态
"""
name = 'DR Runtime'
# game version status
DR_version: Version = game_version # DR SDK 版本
Build_version: Version = build_version # DR 构建 版本
API_version: Version = Api_version # DR SDK API 版本
DR_long_version: int = long_version # DR SDK 内部协议版本 (不要问我为什么不用 Version我也在考虑
DR_Mod_List: List[Tuple[str, Version]] = [] # DR Mod 列表 (name, version)
# run status
running: bool = False
start_time_ns: Optional[int] = None
client_setup_cause_ns: Optional[int] = None
server_setup_cause_ns: Optional[int] = None
# game runtimes
# global_logger: logging.Logger
# game options
mod_path: str = './mods'
language: str = 'zh-CN'
default_language: str = 'zh-CN'
def load_file(self) -> bool:
with contextlib.suppress(FileNotFoundError):
with open('./configs/main.toml', 'r', encoding='utf-8') as f:
@ -141,10 +114,10 @@ class _DR_runtime(Options):
return mods
DR_option = _DR_option()
DR_status = _DR_status()
DR_runtime = _DR_runtime()
if DR_option.playing:
if DR_status.playing:
from Difficult_Rocket.utils.thread import new_thread
def think_it(something):

View File

@ -37,7 +37,7 @@ from Difficult_Rocket.api.types import Options
from Difficult_Rocket.utils.translate import tr
from Difficult_Rocket.utils.thread import new_thread
from Difficult_Rocket.crash import write_info_to_cache
from Difficult_Rocket import client, server, DR_option, DR_runtime
from Difficult_Rocket import client, server, DR_status, DR_runtime
class Console(Options):
@ -154,7 +154,7 @@ class Game(Options):
def start(self):
self.server.run()
if DR_option.use_multiprocess:
if DR_status.use_multiprocess:
try:
game_process = multiprocessing.Process(target=self.client.start, name='pyglet app')
game_process.start()

View File

@ -1,31 +0,0 @@
{
'language': 'zh-cn',
'textures': {
'back_ground_space': 'back_ground_space.png',
'planet': {
'earth_ground': 'earth_ground.png'
},
'flame': {
'liquid': 'liquid_engine_flame.png',
'solid': 'solid_engine_flame.png',
'ion': 'ion_engine_flame.png'
}
},
'basic_number': {
'G': [
6.67,
-11,
[
'N',
'm',
'm'
],
[
'kg',
'kg'
]
]
},
'default ship': [
]
}

View File

@ -1,49 +0,0 @@
{
/*
'part id': [
[
'part name', // part name can be reuse
'description', // 描述
], // about names and other
[ 'float', // mass
'bool', // hidden in part list
'bool', // hidden in mission (even thought that is not done yet)
'float' // buoyancy(浮力) in the water
], // about config
[ 'xxx.png', // texture file name
//可以为包含文件夹的 比如:./engine/xxx.png
[ 'float', // 贴图偏移量
'float' ] // 指的是部件的碰撞箱左上角到贴图左上角的距离
], // about texture
[ 'float',
'float' ],
// 碰撞箱大小 (暂时只支持方形碰撞箱)
// 坐标轴也是从左下开始
[
'特殊值(懒得写)'
]
],
*/
'test1': [
[
'test-1',
'一个测试用部件'
],
[
1.0,
false,
0.1
],
[
'parts/Beam.png',
[
0.0,
0.0
]
],
[
3.0,
2.0
]
]
}

View File

@ -1,17 +0,0 @@
{
'Solar System': {
'description': '',
'planets': {
'earth': {
'description': '',
'gravity': 9.81,
'radius': 63710000,
'map_color': [
103,
157,
255
]
}
}
}
}

View File

@ -1,27 +0,0 @@
[Runtime]
[Parts]
battery = "Battery.png"
beam = "Beam.png"
cover_bottom = "CoverBottom.png"
nose_cone = "NoseCone.png"
[Editor]
[[runtime]]
"toolbar.dark" = "ToolbarDark.png"
"toolbar.light" = "ToolbarLight.png"
"button_side.dark" = "ButtonDarkSide.png"
"button_side.light" = "ButtonLightSide.png"
[[toggle_button]]
stage = "ToolbarIconStaging.png"
add_part = "ToolbarIconAddPart.png"
menu = "ToolbarIconMenu.png"
[[push_button]]
zoom = "ToolbarIconZoom.png"
"zoom.in" = "ToolbarIconZoomIn.png"
"zoom.out" = "ToolbarIconZoomOut.png"
play = "ToolbarIconPlay.png"
rotate = "RotateButton.png"
trash_can = "TrashCan.png"

View File

@ -4,6 +4,64 @@
- 最新版本号
- DR sdk: 0.8.2.0
## DR sdk 0.8.3.0
### 添加
- `DR_status`
- 实际上就是 `DR_runtime`
- `DR_runtime` -> `DR_status`
- `client_running`
- 客户端是否在运行
- Is client running
- `server_running`
- 服务器是否在运行
- Is server running
### 移动
- `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`
### 删除
- `Diffiuclt_Rocket.long_version`
- 不再使用整数标记版本号 (反正 `Version` 有一个完整的版本号比较机制)
- No longer use integer to mark version number (since `Version` has a complete version comparison mechanism)
- `Difficult_Rocket.DR_rust_available`
- 似乎我忘记删掉这个 `DR_rs` 的耦合了
```python
long_version: int = 15
"""
long_version: 一个用于标记内部协议的整数
15: 完全移除 DR_rust 相关内容 解耦完成
14: BaseScreen 的每一个函数都添加了一个参数: window: "ClientWindow"
13: 为 DR_runtime 添加 API_version
12: 去除 DR_runtime 的 global_logger
要 logging 自己拿去(
11: 为 DR_option 添加 use_DR_rust
修复了一些拼写错误
10: 为 DR_runtime 添加 DR_Rust_get_version
9 : 为 DR_option 添加 pyglet_macosx_dev_test
8 : 为 DR_runtime 添加 DR_rust_version
为 DR_option 添加 DR_rust_available
以后就有 DR_rust 了
7 : 为 DR_option 添加 std_font_size
6 : 事实证明, 不如直接用int
5 : 添加 build_version 信息,用于标记编译文件版本,
游戏版本改为四位数,终于有一个可以让我随便刷的版本号位数了
4 : 把 translate 的字体常量位置改了一下,顺便调换顺序
3 : 就是试试改一下,正好 compiler 要用
2 : 哦,对 longlong 好耶!
1 : 我可算想起来还有这回事了 v0.6.4
"""
```
## DR sdk 0.8.2.0
### Fix