feat: clean main.config

This commit is contained in:
shenjack 2022-12-22 10:54:28 +08:00
parent 7d1b445203
commit 9b3df4b739
7 changed files with 9 additions and 25 deletions

View File

@ -57,6 +57,7 @@ def crash_info_handler(info: str = None) -> str:
if not info: if not info:
info = traceback.format_exc().replace('<', '< ') info = traceback.format_exc().replace('<', '< ')
format_info = f"<pre>\n{info}</pre>\n" format_info = f"<pre>\n{info}</pre>\n"
format_info.replace('<module>', '< module>')
return format_info return format_info

View File

@ -34,7 +34,7 @@ class Game:
self.on_python_v = sys.version.split(' ')[0] self.on_python_v = sys.version.split(' ')[0]
self.start_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time())) self.start_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time()))
# lang_config # 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 DR_option.language = self.language
# logging config # logging config
log_config = tools.load_file('configs/logger.toml') log_config = tools.load_file('configs/logger.toml')

View File

@ -34,7 +34,7 @@ class Server:
# os.set # os.set
self.process_name = 'server process' self.process_name = 'server process'
# config # config
self.config = tools.load_file('configs/main.config') self.config = tools.load_file('configs/main.toml')
# self.dev = Dev # self.dev = Dev
# self.net_mode = net_mode # self.net_mode = net_mode
self.logger.info(tr.lang('server', 'setup.done')) self.logger.info(tr.lang('server', 'setup.done'))

View File

@ -52,6 +52,8 @@ def load_file(file_name: str, stack: Union[str, list, dict] = None, raise_error:
elif f_type == 'toml': elif f_type == 'toml':
with open(file_name, mode='r', encoding='utf-8') as file: with open(file_name, mode='r', encoding='utf-8') as file:
get_file = rtoml.load(file) get_file = rtoml.load(file)
if stack is not None:
get_file = get_file[stack]
elif f_type == 'json5': elif f_type == 'json5':
raise NoMoreJson5("我说什么也不用json5了喵的") raise NoMoreJson5("我说什么也不用json5了喵的")
except Exception as exp: 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
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): def get_At(name, in_xml, need_type=str):

View File

@ -75,7 +75,7 @@ class Translates:
def __str__(self): def __str__(self):
if self.final: if self.final:
return f'{self.final}.{".".join(self.get_list)}' return f'{self.value}.{".".join(self.get_list)}'
return str(self.value) return str(self.value)

View File

@ -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

View File

@ -11,6 +11,7 @@ style = "None"
width = 907 width = 907
height = 570 height = 570
visible = true visible = true
gui_scale = 1
caption = "Difficult Rocket {version}" caption = "Difficult Rocket {version}"
resizable = true resizable = true
full_screen = false full_screen = false
@ -18,3 +19,4 @@ full_screen = false
[window.default] [window.default]
width = 1024 width = 1024
height = 768 height = 768
gui_scale = 1