From 9b3df4b7397307c0245a7f30c29aa4ce742c54a7 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Thu, 22 Dec 2022 10:54:28 +0800 Subject: [PATCH] feat: clean main.config --- Difficult_Rocket/crash/crash.py | 1 + Difficult_Rocket/main.py | 2 +- Difficult_Rocket/server/__init__.py | 2 +- Difficult_Rocket/utils/tools.py | 4 +++- Difficult_Rocket/utils/translate.py | 2 +- configs/main.config | 21 --------------------- configs/main.toml | 2 ++ 7 files changed, 9 insertions(+), 25 deletions(-) delete mode 100644 configs/main.config diff --git a/Difficult_Rocket/crash/crash.py b/Difficult_Rocket/crash/crash.py index a144058..2176444 100644 --- a/Difficult_Rocket/crash/crash.py +++ b/Difficult_Rocket/crash/crash.py @@ -57,6 +57,7 @@ def crash_info_handler(info: str = None) -> str: if not info: info = traceback.format_exc().replace('<', '< ') format_info = f"
\n{info}
\n" + format_info.replace('', '< module>') return format_info diff --git a/Difficult_Rocket/main.py b/Difficult_Rocket/main.py index 60722fb..c68bba0 100644 --- a/Difficult_Rocket/main.py +++ b/Difficult_Rocket/main.py @@ -34,7 +34,7 @@ class Game: self.on_python_v = sys.version.split(' ')[0] self.start_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time())) # lang_config - self.language = tools.load_file('configs/main.config', 'runtime')['language'] + self.language = tools.load_file('configs/main.toml', 'runtime')['language'] DR_option.language = self.language # logging config log_config = tools.load_file('configs/logger.toml') diff --git a/Difficult_Rocket/server/__init__.py b/Difficult_Rocket/server/__init__.py index ff3b3ed..f21f6eb 100644 --- a/Difficult_Rocket/server/__init__.py +++ b/Difficult_Rocket/server/__init__.py @@ -34,7 +34,7 @@ class Server: # os.set self.process_name = 'server process' # config - self.config = tools.load_file('configs/main.config') + self.config = tools.load_file('configs/main.toml') # self.dev = Dev # self.net_mode = net_mode self.logger.info(tr.lang('server', 'setup.done')) diff --git a/Difficult_Rocket/utils/tools.py b/Difficult_Rocket/utils/tools.py index 624d059..ce37967 100644 --- a/Difficult_Rocket/utils/tools.py +++ b/Difficult_Rocket/utils/tools.py @@ -52,6 +52,8 @@ def load_file(file_name: str, stack: Union[str, list, dict] = None, raise_error: elif f_type == 'toml': with open(file_name, mode='r', encoding='utf-8') as file: get_file = rtoml.load(file) + if stack is not None: + get_file = get_file[stack] elif f_type == 'json5': raise NoMoreJson5("我说什么也不用json5了!喵的") except Exception as exp: @@ -66,7 +68,7 @@ def load_file(file_name: str, stack: Union[str, list, dict] = None, raise_error: # main config -main_config_file = load_file('./configs/main.config') +main_config_file = load_file('./configs/main.toml') def get_At(name, in_xml, need_type=str): diff --git a/Difficult_Rocket/utils/translate.py b/Difficult_Rocket/utils/translate.py index c977e1c..76d5ce3 100644 --- a/Difficult_Rocket/utils/translate.py +++ b/Difficult_Rocket/utils/translate.py @@ -75,7 +75,7 @@ class Translates: def __str__(self): if self.final: - return f'{self.final}.{".".join(self.get_list)}' + return f'{self.value}.{".".join(self.get_list)}' return str(self.value) diff --git a/configs/main.config b/configs/main.config deleted file mode 100644 index 8f97ad9..0000000 --- a/configs/main.config +++ /dev/null @@ -1,21 +0,0 @@ -[runtime] -fps = 60 -version = 0.6.4 -language = zh-CN -date_fmt = %%Y-%%m-%%d %%H-%%M-%%S -write_py_v = 3.8.10 -fonts_folder = libs/fonts - -[window] -style = None -width = 1300 -height = 931 -visible = true -caption = Difficult Rocket {version} -resizable = true -full_screen = false - -[window_default] -width = 1024 -height = 768 - diff --git a/configs/main.toml b/configs/main.toml index aefcbf9..f7ca655 100644 --- a/configs/main.toml +++ b/configs/main.toml @@ -11,6 +11,7 @@ style = "None" width = 907 height = 570 visible = true +gui_scale = 1 caption = "Difficult Rocket {version}" resizable = true full_screen = false @@ -18,3 +19,4 @@ full_screen = false [window.default] width = 1024 height = 768 +gui_scale = 1