Difficult-Rocket/Difficult_Rocket/__init__.py

103 lines
2.5 KiB
Python
Raw Normal View History

2021-09-08 23:38:34 +08:00
# -------------------------------
# Difficult Rocket
2023-01-20 14:08:12 +08:00
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
2021-09-08 23:38:34 +08:00
# All rights reserved
# -------------------------------
2023-06-22 13:34:14 +08:00
import time
import logging.config
from pathlib import Path
2023-06-10 18:08:40 +08:00
from Difficult_Rocket.api.types import Options, Version
2022-02-16 13:36:26 +08:00
2023-10-13 23:12:35 +08:00
sdk_version = Version("0.8.7.2") # SDK 版本
2023-09-17 22:21:45 +08:00
build_version = Version("2.2.0.0") # 编译文件版本(与游戏本体无关)
Api_version = Version("0.1.1.0") # API 版本
2023-07-01 00:25:41 +08:00
__version__ = sdk_version
2021-01-24 18:26:56 +08:00
__all__ = [
# __init__
'DR_status',
# folder
'api',
'client',
'server',
'command',
'crash',
'exception',
'mod',
'utils',
# file
'main',
'runtime',
]
class _DR_status(Options):
2022-08-12 21:07:36 +08:00
"""
DR 的特性开关 / 基本状态
2022-08-12 21:07:36 +08:00
"""
2022-11-20 17:46:02 +08:00
name = 'DR Option'
# run status
client_running: bool = False
server_running: bool = False
# feature switch
2023-01-24 23:59:07 +08:00
InputBox_use_TextEntry: bool = True
record_threads: bool = True
report_translate_not_found: bool = True
use_multiprocess: bool = False
use_cProfile: bool = False
use_local_logging: bool = False
2023-04-22 17:13:45 +08:00
2022-08-12 21:07:36 +08:00
# tests
2023-01-21 12:20:50 +08:00
playing: bool = False
debugging: bool = False
2023-04-30 00:48:42 +08:00
crash_report_test: bool = False
2022-08-12 21:07:36 +08:00
# game version status
2023-07-01 00:25:41 +08:00
DR_version: Version = sdk_version # DR SDK 版本
Build_version: Version = build_version # DR 构建 版本
API_version: Version = Api_version # DR SDK API 版本
# game options
default_language: str = 'zh-CN'
2022-12-22 10:54:46 +08:00
# window option
2023-01-19 22:29:43 +08:00
gui_scale: float = 1.0 # default 1.0 2.0 -> 2x 3 -> 3x
@property
def std_font_size(self) -> int:
2023-01-20 20:20:35 +08:00
return round(12 * self.gui_scale)
2022-12-22 10:54:46 +08:00
2022-08-12 21:07:36 +08:00
DR_status = _DR_status()
2022-08-12 21:07:36 +08:00
2023-06-22 13:34:14 +08:00
def load_logging():
2023-07-16 00:06:17 +08:00
with open('./config/logger.toml') as f:
2023-06-22 13:34:14 +08:00
import rtoml
logger_config = rtoml.load(f)
log_path = logger_config['handlers']['file']['filename']
log_path = f"logs/{log_path.format(time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time_ns() / 1000_000_000)))}"
if not Path('logs/').is_dir():
Path('logs/').mkdir()
logger_config['handlers']['file']['filename'] = log_path
logging.config.dictConfig(logger_config)
load_logging()
if DR_status.playing:
2023-05-28 01:03:46 +08:00
from Difficult_Rocket.utils.thread import new_thread
def think_it(something):
return something
2021-10-31 23:26:32 +08:00
@new_thread('think')
def think(some_thing_to_think):
gotcha = think_it(some_thing_to_think)
2023-06-22 13:34:14 +08:00
return gotcha