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
|
2023-12-13 09:43:29 +08:00
|
|
|
# import logging.config
|
2023-06-22 13:34:14 +08:00
|
|
|
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-12-02 10:39:00 +08:00
|
|
|
sdk_version = Version("0.8.7.3") # SDK 版本
|
2023-08-27 01:52:45 +08:00
|
|
|
build_version = Version("2.2.0.0") # 编译文件版本(与游戏本体无关)
|
2023-12-03 18:16:57 +08:00
|
|
|
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
|
|
|
|
2023-06-16 23:23:19 +08:00
|
|
|
|
2023-06-17 00:47:00 +08:00
|
|
|
__all__ = [
|
|
|
|
# __init__
|
2023-12-03 16:54:07 +08:00
|
|
|
"DR_status",
|
2023-06-17 00:47:00 +08:00
|
|
|
# folder
|
2023-12-03 16:54:07 +08:00
|
|
|
"api",
|
2023-12-13 09:43:29 +08:00
|
|
|
"data",
|
2023-12-03 16:54:07 +08:00
|
|
|
"client",
|
|
|
|
"command",
|
|
|
|
"crash",
|
|
|
|
"exception",
|
2023-12-13 09:43:29 +08:00
|
|
|
"server",
|
2023-12-03 16:54:07 +08:00
|
|
|
"mod",
|
|
|
|
"utils",
|
2023-06-17 00:47:00 +08:00
|
|
|
# file
|
2023-12-03 16:54:07 +08:00
|
|
|
"main",
|
|
|
|
"runtime",
|
2023-12-03 18:16:57 +08:00
|
|
|
"sdk_version",
|
|
|
|
"build_version",
|
|
|
|
"api_version",
|
2023-06-17 00:47:00 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-12-13 09:43:29 +08:00
|
|
|
class _DRStatus(Options):
|
2022-08-12 21:07:36 +08:00
|
|
|
"""
|
2023-06-16 23:23:19 +08:00
|
|
|
DR 的特性开关 / 基本状态
|
2022-08-12 21:07:36 +08:00
|
|
|
"""
|
2023-12-03 16:54:07 +08:00
|
|
|
|
|
|
|
name = "DR Option"
|
2023-06-16 23:23:19 +08:00
|
|
|
# run status
|
|
|
|
client_running: bool = False
|
|
|
|
server_running: bool = False
|
|
|
|
|
|
|
|
# feature switch
|
2023-12-03 16:54:07 +08:00
|
|
|
InputBox_use_TextEntry: bool = True
|
|
|
|
record_threads: bool = True
|
2023-01-24 23:59:07 +08:00
|
|
|
report_translate_not_found: bool = True
|
2023-12-03 16:54:07 +08:00
|
|
|
use_multiprocess: bool = False
|
|
|
|
use_cProfile: bool = False
|
|
|
|
use_local_logging: bool = False
|
|
|
|
|
2022-08-12 21:07:36 +08:00
|
|
|
# tests
|
2023-12-03 16:54:07 +08:00
|
|
|
playing: bool = False
|
|
|
|
debugging: bool = False
|
|
|
|
crash_report_test: bool = False
|
2022-08-12 21:07:36 +08:00
|
|
|
|
2023-06-16 23:23:19 +08:00
|
|
|
# game version status
|
2023-07-01 00:25:41 +08:00
|
|
|
DR_version: Version = sdk_version # DR SDK 版本
|
2023-06-16 23:23:19 +08:00
|
|
|
Build_version: Version = build_version # DR 构建 版本
|
2023-12-03 18:16:57 +08:00
|
|
|
API_version: Version = api_version # DR SDK API 版本
|
2023-06-16 23:23:19 +08:00
|
|
|
|
|
|
|
# game options
|
2023-12-03 16:54:07 +08:00
|
|
|
default_language: str = "zh-CN"
|
2023-06-16 23:23:19 +08:00
|
|
|
|
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
|
|
|
|
2023-12-13 09:43:29 +08:00
|
|
|
DR_status = _DRStatus()
|
2022-08-12 21:07:36 +08:00
|
|
|
|
2023-06-22 13:34:14 +08:00
|
|
|
|
|
|
|
def load_logging():
|
2023-12-13 09:43:29 +08:00
|
|
|
# with open("./config/logger.toml") as f:
|
|
|
|
# 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)
|
|
|
|
log_config_path = Path("./config/lndl-logger.toml")
|
|
|
|
|
|
|
|
import rtoml
|
|
|
|
|
|
|
|
if not log_config_path.is_file():
|
|
|
|
# 生成默认配置文件
|
|
|
|
from Difficult_Rocket.data import log_config
|
|
|
|
log_config_path.write_text(log_config.default_config)
|
|
|
|
logger_config = rtoml.loads(log_config.default_config)
|
|
|
|
else:
|
|
|
|
# 读取配置文件
|
|
|
|
with open(log_config_path, encoding='utf-8') as f:
|
|
|
|
logger_config = rtoml.load(f)
|
|
|
|
# 输入 lndl 进行配置
|
|
|
|
from lib_not_dr.loggers.config import read_config
|
|
|
|
read_config(logger_config)
|
2023-06-22 13:34:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
load_logging()
|
|
|
|
|
|
|
|
|
2023-06-16 23:23:19 +08:00
|
|
|
if DR_status.playing:
|
2023-05-28 01:03:46 +08:00
|
|
|
from Difficult_Rocket.utils.thread import new_thread
|
|
|
|
|
2022-06-21 10:17:13 +08:00
|
|
|
def think_it(something):
|
|
|
|
return something
|
|
|
|
|
2023-12-03 16:54:07 +08:00
|
|
|
@new_thread("think")
|
2021-10-31 23:26:32 +08:00
|
|
|
def think(some_thing_to_think):
|
2022-06-21 10:17:13 +08:00
|
|
|
gotcha = think_it(some_thing_to_think)
|
2023-12-03 16:54:07 +08:00
|
|
|
return gotcha
|