commit about v 0.5.2
release comming(no DEMO)
This commit is contained in:
parent
fd769140e1
commit
fccc161148
@ -2,11 +2,11 @@
|
||||
writen by shenjackyuanjie
|
||||
mail: 3695888@qq.com
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
import threading
|
||||
import multiprocessing
|
||||
|
||||
# TODO 默认位置配置文件+可自定义工作路径
|
||||
|
||||
@ -33,6 +33,8 @@ if __name__ == '__main__':
|
||||
|
||||
DEBUGGING = False
|
||||
from Difficult_Rocket.api.Exp import *
|
||||
# multiprocessing.set_start_method('fork', True)
|
||||
print(multiprocessing.get_start_method())
|
||||
try:
|
||||
from Difficult_Rocket import crash
|
||||
from Difficult_Rocket import main
|
||||
@ -55,4 +57,5 @@ if __name__ == '__main__':
|
||||
else:
|
||||
crash.record_thread = False
|
||||
print(crash.all_thread)
|
||||
print(crash.all_process)
|
||||
sys.exit(1)
|
||||
|
@ -1,38 +0,0 @@
|
||||
# -------------------------------
|
||||
# Difficult Rocket
|
||||
# Copyright © 2021 by shenjackyuanjie
|
||||
# All rights reserved
|
||||
# -------------------------------
|
||||
|
||||
"""
|
||||
writen by shenjackyuanjie
|
||||
mail: 3695888@qq.com
|
||||
github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
|
||||
import threading
|
||||
|
||||
|
||||
class Orbit_demo(threading.Thread):
|
||||
|
||||
def __init__(self, threadID, delivery_class):
|
||||
# father class __init__()
|
||||
threading.Thread.__init__(self)
|
||||
# dic
|
||||
self.ship_info = {'mass': [1, 5, ['kg'], []], 'force': []}
|
||||
self.planet_system = {'Solar System': {'planets': {
|
||||
'smearth': {'description': '', 'gravity': 9.81, 'radius': 63710000, 'map_color': [103, 157, 255]}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.this_planet_info = {}
|
||||
self.back_ground_element = {}
|
||||
self.back_ground_image = ''
|
||||
|
||||
def main(self):
|
||||
print('ha ?')
|
||||
|
||||
def orbit_math(self):
|
||||
pass
|
@ -23,27 +23,15 @@ class Error(Exception):
|
||||
|
||||
|
||||
class TexturesError(Error):
|
||||
"""材质相关error 包含info和textures"""
|
||||
|
||||
def __init__(self, info, textures):
|
||||
self.info = info
|
||||
self.textures = textures
|
||||
|
||||
def __str__(self):
|
||||
return '{}{}'.format(self.info, self.textures)
|
||||
"""材质相关 error"""
|
||||
pass
|
||||
|
||||
|
||||
class LanguageError(Error):
|
||||
"""lang文件相关error 包含info和language"""
|
||||
|
||||
def __init__(self, info, language):
|
||||
self.info = info
|
||||
self.lang = language
|
||||
|
||||
def __str__(self):
|
||||
return '{}{}'.format(self.info, self.lang)
|
||||
"""lang 文件相关 error"""
|
||||
pass
|
||||
|
||||
|
||||
class TestError(Error):
|
||||
"""就像名字一样 用于测试的error"""
|
||||
"""就像名字一样 用于测试的 error"""
|
||||
pass
|
||||
|
@ -4,6 +4,7 @@ import threading
|
||||
import time
|
||||
from typing import Optional, Callable
|
||||
from Difficult_Rocket.api import thread
|
||||
from Difficult_Rocket import crash
|
||||
|
||||
"""
|
||||
This part of code come from MCDReforged(https://github.com/Fallen_Breath/MCDReforged)
|
||||
@ -22,9 +23,10 @@ def new_thread(thread_name: Optional[str or Callable] = None):
|
||||
def wrapper(func):
|
||||
@functools.wraps(func) # to preserve the origin function information
|
||||
def wrap(*args, **kwargs):
|
||||
thread_ = thread.Threads(target=func, args=args, kwargs=kwargs, name=thread_name)
|
||||
thread_ = threading.Thread(target=func, args=args, kwargs=kwargs, name=thread_name)
|
||||
thread_.setDaemon(False)
|
||||
thread_.start()
|
||||
crash.all_thread.append(thread_)
|
||||
return thread
|
||||
|
||||
# bring the signature of the func to the wrap function
|
||||
@ -40,15 +42,3 @@ def new_thread(thread_name: Optional[str or Callable] = None):
|
||||
return wrapper(this_is_a_function)
|
||||
# Use @on_new_thread with ending brackets case
|
||||
return wrapper
|
||||
|
||||
|
||||
@new_thread()
|
||||
def a(name):
|
||||
print('ah')
|
||||
print(name)
|
||||
time.sleep(2)
|
||||
print('done')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
a('shenjack')
|
||||
|
@ -17,7 +17,8 @@ from Difficult_Rocket import crash
|
||||
|
||||
|
||||
class Threads(threading.Thread):
|
||||
def run(self) -> None:
|
||||
def run(self):
|
||||
if crash.record_thread:
|
||||
crash.all_thread.append(self)
|
||||
super(Threads, self).run()
|
||||
super().run()
|
||||
|
||||
|
@ -12,14 +12,14 @@ gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
|
||||
import configparser
|
||||
import decimal
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import math
|
||||
import decimal
|
||||
import logging
|
||||
import traceback
|
||||
import configparser
|
||||
from xml.dom.minidom import parse
|
||||
|
||||
import semver
|
||||
@ -28,10 +28,8 @@ if __name__ == '__main__': # been start will not run this
|
||||
sys.path.append('/bin/libs')
|
||||
sys.path.append('/bin')
|
||||
|
||||
import json5
|
||||
import importlib
|
||||
from libs import json5
|
||||
|
||||
configs = importlib.import_module('configs')
|
||||
# logger
|
||||
tools_logger = logging.getLogger('part-tools')
|
||||
"""
|
||||
@ -99,7 +97,6 @@ def config(file_name: str, stack=None) -> dict:
|
||||
|
||||
# main config
|
||||
main_config_file = config('./configs/main.config')
|
||||
Version = semver.VersionInfo.parse(str(main_config_file['runtime']['version']))
|
||||
|
||||
|
||||
def get_At(name, in_xml, need_type=str):
|
||||
|
@ -11,23 +11,65 @@ github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
from typing import List
|
||||
|
||||
from Difficult_Rocket.api import tools
|
||||
from Difficult_Rocket.api.Exp import *
|
||||
|
||||
|
||||
class Lang:
|
||||
"""
|
||||
用于创建一个对应语言的翻译类
|
||||
感谢Fallen的MCDR提供idea
|
||||
https://github.com/Fallen-Breath/MCDReforged
|
||||
可以用
|
||||
lang['language'] = 'abc' 或
|
||||
lang['lang'] = 'abc'
|
||||
的方式直接更改并刷新翻译
|
||||
"""
|
||||
|
||||
def __init__(self, language: str):
|
||||
self.语言 = language
|
||||
self.翻译结果 = {}
|
||||
def __init__(self, language: str = 'zh-CN'):
|
||||
self.language = language
|
||||
self.翻译结果 = tools.config(f'configs/lang/{language}.json5')
|
||||
self.默认翻译 = tools.config('configs/lang/zh-CN.json5')
|
||||
|
||||
def __str__(self):
|
||||
return self.语言
|
||||
def __str__(self) -> str:
|
||||
return self.language
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self.翻译结果[item]
|
||||
try:
|
||||
return self.翻译结果[item]
|
||||
except KeyError:
|
||||
return self.默认翻译[item]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
pass
|
||||
if key == 'language' or key == 'lang':
|
||||
try:
|
||||
self.翻译结果 = tools.config(f'configs/lang/{value}.json5')
|
||||
self.language = value
|
||||
except FileNotFoundError:
|
||||
raise LanguageError(f'{value}\'s language json5 file not found')
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
def set_language(self, language):
|
||||
try:
|
||||
self.翻译结果 = tools.config(f'configs/lang/{language}.json5')
|
||||
self.language = language
|
||||
except FileNotFoundError:
|
||||
raise LanguageError(f'{language}\'s language json5 file not found')
|
||||
|
||||
|
||||
try:
|
||||
tr = Lang('zh-CN')
|
||||
except FileNotFoundError:
|
||||
import os
|
||||
|
||||
os.chdir('..')
|
||||
os.chdir('..')
|
||||
tr = Lang('zh-CN')
|
||||
|
||||
|
||||
def test():
|
||||
print(tr)
|
||||
assert tr.language == 'zh-CN'
|
||||
|
@ -11,11 +11,18 @@ github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
import configparser
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import logging
|
||||
import traceback
|
||||
import threading
|
||||
import configparser
|
||||
import multiprocessing
|
||||
|
||||
from multiprocessing import Pipe
|
||||
from multiprocessing.connection import Connection
|
||||
|
||||
if __name__ == '__main__': # been start will not run this
|
||||
sys.path.append('/bin/libs')
|
||||
@ -23,19 +30,16 @@ if __name__ == '__main__': # been start will not run this
|
||||
|
||||
import pyglet
|
||||
from pyglet.window import key, mouse
|
||||
from Difficult_Rocket import crash
|
||||
from Difficult_Rocket.api.Exp import *
|
||||
from Difficult_Rocket.drag_sprite import DragSprite
|
||||
from Difficult_Rocket.crash import create_crash_report
|
||||
from Difficult_Rocket.api import tools, config, new_thread
|
||||
from Difficult_Rocket.api import tools, config, new_thread, thread
|
||||
|
||||
|
||||
class Client:
|
||||
def __init__(self, dev_dic=None, dev_list=None, net_mode='local'):
|
||||
def __init__(self, net_mode='local'):
|
||||
# logging
|
||||
self.logger = logging.getLogger('client')
|
||||
# share memory
|
||||
self.dev_list = dev_list
|
||||
self.dev_dic = dev_dic
|
||||
# config
|
||||
self.config = tools.config('configs/main.config')
|
||||
# lang
|
||||
@ -47,9 +51,7 @@ class Client:
|
||||
self.view = 'space'
|
||||
self.net_mode = net_mode
|
||||
self.caption = tools.name_handler(self.config['window']['caption'], {'version': self.config['runtime']['version']})
|
||||
self.window = ClientWindow(dev_dic=self.dev_dic,
|
||||
dev_list=self.dev_list,
|
||||
net_mode=self.net_mode,
|
||||
self.window = ClientWindow(net_mode=self.net_mode,
|
||||
width=int(self.config['window']['width']),
|
||||
height=int(self.config['window']['height']),
|
||||
fullscreen=tools.format_bool(self.config['window']['full_screen']),
|
||||
@ -57,12 +59,14 @@ class Client:
|
||||
resizable=tools.format_bool(self.config['window']['resizable']),
|
||||
visible=tools.format_bool(self.config['window']['visible']))
|
||||
|
||||
def start(self):
|
||||
self.window.start_game() # 游戏启动
|
||||
# TODO 写一下服务端启动相关,还是需要服务端啊
|
||||
|
||||
|
||||
class ClientWindow(pyglet.window.Window):
|
||||
|
||||
def __init__(self, dev_dic=None, dev_list=None, net_mode='local', *args, **kwargs):
|
||||
def __init__(self, net_mode='local', *args, **kwargs):
|
||||
self.times = [time.time()]
|
||||
super().__init__(*args, **kwargs)
|
||||
"""
|
||||
@ -74,10 +78,12 @@ class ClientWindow(pyglet.window.Window):
|
||||
# logging
|
||||
self.logger = logging.getLogger('client')
|
||||
# share memory
|
||||
self.dev_list = dev_list
|
||||
self.dev_dic = dev_dic
|
||||
# self.dev_list = dev_list
|
||||
# self.dev_dic = dev_dic
|
||||
# value
|
||||
self.net_mode = net_mode
|
||||
self.run_input = False
|
||||
self.pipeA_, self.pipeB_ = Pipe()
|
||||
# configs
|
||||
pyglet.resource.path = ['textures']
|
||||
pyglet.resource.reindex()
|
||||
@ -117,7 +123,7 @@ class ClientWindow(pyglet.window.Window):
|
||||
self.environment['parts'] = config('configs/sys_value/parts.json5')
|
||||
try:
|
||||
self.load_textures()
|
||||
except Exp.TexturesError:
|
||||
except TexturesError:
|
||||
raise
|
||||
|
||||
@new_thread('client_load_textures')
|
||||
@ -133,7 +139,24 @@ class ClientWindow(pyglet.window.Window):
|
||||
self.textures['test'] = DragSprite(10, 20, image, batch=self.label_batch, drag_by_all=False, drag_out_window=True)
|
||||
self.load_environment()
|
||||
|
||||
# draws
|
||||
def start_game(self) -> None:
|
||||
self.run_input = True
|
||||
# self.input_line = threading.Thread(target=self.read_input, name='client_read_line', daemon=True)
|
||||
# self.input_line.start()
|
||||
pyglet.app.run()
|
||||
|
||||
def read_input(self):
|
||||
self.logger.debug('read_input start')
|
||||
while self.run_input:
|
||||
get = input('<<<')
|
||||
self.logger.info(get)
|
||||
if get == 'stop':
|
||||
self.run_input = False
|
||||
self.logger.debug('read_input end')
|
||||
|
||||
"""
|
||||
draws and some event
|
||||
"""
|
||||
|
||||
def update(self, tick: float):
|
||||
self.FPS_update(tick)
|
||||
@ -151,10 +174,6 @@ class ClientWindow(pyglet.window.Window):
|
||||
self.min_fps = [self.FPS, time.time()]
|
||||
self.info_label.text = 'FPS: {:.1f} {:.1f} ({:.1f}/{:.1f}) | MSPF: {:.5f} '.format(now_FPS, 1 / tick, self.max_fps[0], self.min_fps[0], tick)
|
||||
|
||||
"""
|
||||
window draw and event
|
||||
"""
|
||||
|
||||
def on_draw(self):
|
||||
self.clear()
|
||||
self.draw_batch()
|
||||
@ -185,6 +204,7 @@ class ClientWindow(pyglet.window.Window):
|
||||
self.logger.debug(self.lang['mouse.press'].format([x, y], self.lang['mouse.left']))
|
||||
elif button == mouse.RIGHT:
|
||||
self.logger.debug(self.lang['mouse.press'].format([x, y], self.lang['mouse.right']))
|
||||
self.textures['test']._sprite.rotation = random.randint(0, 360)
|
||||
self.textures['test'].on_mouse_press(x, y, button, modifiers)
|
||||
|
||||
def on_mouse_release(self, x, y, button, modifiers) -> None:
|
||||
@ -201,6 +221,8 @@ class ClientWindow(pyglet.window.Window):
|
||||
pass
|
||||
|
||||
def on_close(self) -> None:
|
||||
self.run_input = False
|
||||
# self.input_line.join()
|
||||
config_file = configparser.ConfigParser()
|
||||
config_file.read('configs/main.config')
|
||||
config_file['window']['width'] = str(self.width)
|
||||
|
@ -17,6 +17,7 @@ import time
|
||||
import platform
|
||||
import traceback
|
||||
import threading
|
||||
import multiprocessing
|
||||
from typing import Optional
|
||||
|
||||
# import psutil
|
||||
@ -31,6 +32,9 @@ Head_message = """# ----- Difficult Rocket Crash Report -----
|
||||
## Traceback
|
||||
"""
|
||||
|
||||
Process_message = """## Process info
|
||||
"""
|
||||
|
||||
Thread_message = """## Thread info
|
||||
"""
|
||||
|
||||
@ -42,6 +46,7 @@ System_message = """## System info
|
||||
|
||||
|
||||
all_thread = [threading.main_thread()]
|
||||
all_process = [multiprocessing.current_process()]
|
||||
record_thread = True
|
||||
|
||||
|
||||
@ -66,11 +71,18 @@ def create_crash_report(info: str = None) -> None:
|
||||
os.mkdir('./crash_report')
|
||||
date_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time()))
|
||||
filename = 'crash-{}.md'.format(date_time)
|
||||
with open('./crash_report/{}'.format(filename), 'w+') as crash_file:
|
||||
with open('./crash_report/{}'.format(filename), 'w+', encoding='utf-8') as crash_file:
|
||||
# 开头信息
|
||||
crash_file.write(Head_message)
|
||||
# 崩溃信息
|
||||
crash_file.write(crash_info)
|
||||
# 多进程信息
|
||||
crash_file.write(Process_message)
|
||||
for process in all_process:
|
||||
process: multiprocessing.Process
|
||||
crash_file.write(markdown_line_handler(f'{process.name}', code=True))
|
||||
crash_file.write(markdown_line_handler(f'Ident: {process.ident}', level=2))
|
||||
crash_file.write(markdown_line_handler(f'Running: {process.is_alive()}', level=2))
|
||||
# 运行线程信息
|
||||
crash_file.write(Thread_message)
|
||||
for thread in all_thread:
|
||||
|
@ -12,10 +12,12 @@ gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import logging
|
||||
import logging.config
|
||||
import multiprocessing
|
||||
from multiprocessing import Manager as share
|
||||
|
||||
if __name__ == '__main__': # been start will not run this
|
||||
@ -23,8 +25,9 @@ if __name__ == '__main__': # been start will not run this
|
||||
sys.path.append('/bin')
|
||||
|
||||
from Difficult_Rocket import client, server
|
||||
from Difficult_Rocket.api import tools, thread, translate
|
||||
from Difficult_Rocket.api.translate import tr
|
||||
from libs import pyglet
|
||||
from Difficult_Rocket.api import tools
|
||||
|
||||
|
||||
class Game:
|
||||
@ -33,72 +36,49 @@ class Game:
|
||||
self.on_python_v_info = sys.version_info
|
||||
self.on_python_v = sys.version.split(' ')[0]
|
||||
self.start_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time()))
|
||||
# share memory
|
||||
self.dicts = share().dict()
|
||||
self.lists = share().list()
|
||||
# lang_config
|
||||
self.language = tools.config('configs/sys_value/basic_config.json5')
|
||||
self.language = self.language['language']
|
||||
self.lang = tools.config('configs/lang/%s.json5' % self.language, 'main')
|
||||
# logger
|
||||
self.log_config = tools.config('configs/logging.json5', 'file')
|
||||
self.log_filename = tools.name_handler(self.log_config['filename']['main'],
|
||||
{'{date}': self.log_config['date_fmt']})
|
||||
self.root_logger_fmt = logging.Formatter(self.log_config['fmt'], self.log_config['date_fmt'])
|
||||
self.root_logger_stream_handler = logging.StreamHandler()
|
||||
self.root_logger_stream_handler.setFormatter(self.root_logger_fmt)
|
||||
self.root_logger_stream_handler.setLevel(tools.log_level(self.log_config['level']))
|
||||
try:
|
||||
self.root_logger_file_handler = logging.FileHandler('logs/' + self.log_filename, encoding='utf-8')
|
||||
except FileNotFoundError:
|
||||
os.mkdir('./logs')
|
||||
self.root_logger_file_handler = logging.FileHandler('logs/' + self.log_filename, encoding='utf-8')
|
||||
self.root_logger_file_handler.setFormatter(self.root_logger_fmt)
|
||||
self.root_logger_file_handler.setLevel(tools.log_level(self.log_config['level']))
|
||||
# root logger setup
|
||||
logging.getLogger().setLevel(tools.log_level(self.log_config['level']))
|
||||
logging.getLogger().addHandler(self.root_logger_stream_handler)
|
||||
logging.getLogger().addHandler(self.root_logger_file_handler)
|
||||
# create logger
|
||||
self.main_logger = logging.getLogger('main')
|
||||
# output info
|
||||
self.main_logger.info(self.lang['logger.created'])
|
||||
self.main_logger.info(self.lang['logger.main_done'])
|
||||
self.log_configs()
|
||||
translate.tr.set_language(self.language)
|
||||
# logging config
|
||||
log_config = tools.config('configs/logger.json5')
|
||||
file_name = log_config['handlers']['file']['filename']
|
||||
del log_config['handlers']['file']['datefmt']
|
||||
log_config['handlers']['file']['filename'] = file_name.format(self.start_time)
|
||||
logging.config.dictConfig(log_config)
|
||||
self.logger = logging.getLogger('main')
|
||||
# version check
|
||||
self.python_version_check()
|
||||
self.setup()
|
||||
|
||||
def setup(self) -> None:
|
||||
self.client = client.Client(self.lists, self.dicts, net_mode='local')
|
||||
self.server = server.Server(self.lists, self.dicts, net_mode='local')
|
||||
|
||||
def log_configs(self) -> None:
|
||||
self.main_logger.info('%s %s' % (self.lang['logger.language'], self.lang['lang.language']))
|
||||
self.main_logger.info('%s %s' % (self.lang['game_start.at'], self.start_time))
|
||||
self.main_logger.debug('%s %s' % (self.lang['logger.logfile_name'], self.log_filename))
|
||||
self.main_logger.debug('%s %s' % (self.lang['logger.logfile_level'], self.log_config['level']))
|
||||
self.main_logger.debug('%s %s' % (self.lang['logger.logfile_fmt'], self.log_config['fmt']))
|
||||
self.main_logger.debug('%s %s' % (self.lang['logger.logfile_datefmt'], self.log_config['date_fmt']))
|
||||
self.client = client.Client(net_mode='local')
|
||||
self.server = server.Server(net_mode='local')
|
||||
|
||||
def python_version_check(self) -> None: # best 3.8+ and write at 3.8.10
|
||||
self.main_logger.info('%s %s' % (self.lang['version.now_on'], self.on_python_v))
|
||||
self.logger.info('%s %s' % (tr['main']['version.now_on'], self.on_python_v))
|
||||
if self.on_python_v_info[0] == 2:
|
||||
self.main_logger.critical('%s' % self.lang['version.need3+'])
|
||||
raise SystemError('%s' % self.lang['version.need3+'])
|
||||
self.logger.critical('%s' % tr['main']['version.need3+'])
|
||||
raise SystemError('%s' % tr['main']['version.need3+'])
|
||||
elif self.on_python_v_info[1] < 8:
|
||||
warning = tools.name_handler(self.lang['version.best3.8+'])
|
||||
self.main_logger.warning(warning)
|
||||
warning = tools.name_handler(tr['main']['version.best3.8+'])
|
||||
self.logger.warning(warning)
|
||||
|
||||
# @new_thread('main')
|
||||
def _start(self) -> int:
|
||||
def _start(self):
|
||||
self.server.run()
|
||||
try:
|
||||
pyglet.app.run()
|
||||
except:
|
||||
return -1
|
||||
threaded = False
|
||||
if threaded:
|
||||
try:
|
||||
game_process = multiprocessing.Process(target=self.client.start(), name='pyglet app')
|
||||
game_process.start()
|
||||
game_process.join()
|
||||
except:
|
||||
return -1
|
||||
else:
|
||||
return 1
|
||||
else:
|
||||
return 1
|
||||
self.client.start()
|
||||
|
||||
def start(self) -> None:
|
||||
self._start()
|
||||
|
@ -29,7 +29,7 @@ from api.new_thread import new_thread
|
||||
|
||||
|
||||
class Server:
|
||||
def __init__(self, dev_list, dev_dic, net_mode='local', Dev: Delivery = Delivery):
|
||||
def __init__(self, net_mode='local', Dev: Delivery = Delivery):
|
||||
# father class __init__()
|
||||
# mp.Process.__init__(self)
|
||||
# logging
|
||||
@ -43,12 +43,8 @@ class Server:
|
||||
self.net_mode = net_mode
|
||||
# lang
|
||||
self.lang = tools.config('configs/lang/%s.json5' % self.config['runtime']['language'], 'server')
|
||||
# share memory
|
||||
self.dev_list = dev_list
|
||||
self.dev_dic = dev_dic
|
||||
self.logger.info('%s' % self.lang['setup.done'])
|
||||
|
||||
@new_thread('Server')
|
||||
def run(self):
|
||||
self.logger.info(self.lang['os.pid_is'].format(os.getpid(), os.getppid()))
|
||||
self.logger.debug(self)
|
||||
|
@ -18,14 +18,16 @@
|
||||
'os.pid_is': 'Client is using PID',
|
||||
'button.been_press': 'The button is pressed, the current state of the button is:',
|
||||
'mouse.press_at': 'mouse was click at {} button is: {}',
|
||||
'mouse.release': 'mouse release at {} button is: {}',
|
||||
'mouse.right': 'right button',
|
||||
'mouse.left': 'left button'
|
||||
},
|
||||
'server': {
|
||||
'setup.done': 'server load complete ',
|
||||
'os.pid_is': 'Client is using PID: {} PPID: {}'
|
||||
}
|
||||
},
|
||||
'language': 'English'
|
||||
}
|
||||
/*
|
||||
感谢@小咔er 帮我lazy的翻译
|
||||
*/
|
||||
*/
|
||||
|
@ -25,5 +25,6 @@
|
||||
'server': {
|
||||
'setup.done': '服务端载入完成',
|
||||
'os.pid_is': '服务端 PID: {} PPID: {}'
|
||||
}
|
||||
}
|
||||
},
|
||||
'language': '简体中文'
|
||||
}
|
||||
|
53
configs/logger.json5
Normal file
53
configs/logger.json5
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
'version': 1,
|
||||
'formatters': {
|
||||
'file': { // file 跟 root 的输出格式一致
|
||||
'class': 'logging.Formatter',
|
||||
'format': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s',
|
||||
'datefmt': '%Y-%m-%d %H-%M-%S'
|
||||
},
|
||||
'client': {
|
||||
'class': 'logging.Formatter',
|
||||
'format': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s',
|
||||
'datefmt': '%Y-%m-%d %H-%M-%S'
|
||||
},
|
||||
'server': {
|
||||
'class': 'logging.Formatter',
|
||||
'format': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s',
|
||||
'datefmt': '%Y-%m-%d %H-%M-%S'
|
||||
}
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'file',
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
'file': {
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': '{} DR.log',
|
||||
'datefmt': '%Y-%m-%d %H-%M-%S',
|
||||
'encoding': 'utf-8',
|
||||
'formatter': 'file',
|
||||
'mode': 'w'
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'client': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console', 'file']
|
||||
},
|
||||
'server': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console', 'file']
|
||||
},
|
||||
'main': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console', 'file']
|
||||
}
|
||||
},
|
||||
'root': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console', 'file']
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
[runtime]
|
||||
fps = 60
|
||||
version = 0.5.0
|
||||
version = 0.5.2
|
||||
language = zh-CN
|
||||
date_fmt = %%Y-%%m-%%d %%H-%%M-%%S
|
||||
write_py_v = 3.8.10
|
||||
|
||||
[window]
|
||||
style = None
|
||||
width = 849
|
||||
height = 697
|
||||
width = 1024
|
||||
height = 768
|
||||
visible = true
|
||||
caption = Difficult Rocket {version}
|
||||
resizable = true
|
||||
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
'map far': 100
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
# Difficult Rocket Update Logs
|
||||
|
||||
## Readme
|
||||
|
||||
##### most badge can be clicked and jump
|
||||
[](https://Semver.org/)
|
||||

|
||||
|
||||
@ -16,13 +16,39 @@
|
||||
|
||||
- now bin folder use the name `Difficult_Rocket`
|
||||
- now test files no longer have `_test_` prefix
|
||||
- now will always use local `pyglet` # may change
|
||||
- now fitting `pypy3.10`
|
||||
- now will always use local `pyglet`
|
||||
- may change later
|
||||
- fitting `pypy3.10` (well······ not success (because OpenGL, blame it))
|
||||
- now `crash-report` have more information
|
||||
- now when pressed, the sprite will rotate randomly
|
||||
- now `pyglet.app.run()` use multiprocess
|
||||
|
||||
### Add
|
||||
|
||||
- `"mods support"` will done in 1.0.0
|
||||
- ~~`"mods support"` will done in 1.0.0~~(maybe. just maybe)
|
||||
- now you can use `DEBUGGING` to test or check game run stats
|
||||
- when `True` it will always make a crash report
|
||||
- now `Difficult_Rocket.api.translate.Lang` can be used to auto translate text in `configs/lang/xxx.json5`
|
||||
- you can use `translate.tr[xxx]` to use translated info
|
||||
- and use `.format` to format info's `{}`
|
||||
- if translate is not found, `Lang` will try to find translate in default language translate
|
||||
- (witch was `zh-CN`)
|
||||
- `crash` now have more information about multiprocess
|
||||
- add some unused read_input in `client`
|
||||
|
||||
### DEBUG
|
||||
|
||||
- now version on the window will be `0.5.2`
|
||||
|
||||
### Delete
|
||||
|
||||
- now `client.Client` and `server.Server` only use `net_mode` option
|
||||
- `api.new_thread` have no more extra line of testing
|
||||
|
||||
### Translate
|
||||
|
||||
- add `mouse.release` and `language` to en-us
|
||||
- add `language` to `zh-CN`
|
||||
|
||||
## 20210902 V 0.5.1
|
||||
|
||||
|
@ -11,6 +11,7 @@ github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
# import folders
|
||||
|
||||
# import in this folder
|
||||
"""
|
||||
this is a test of modding in Difficult Rocket
|
||||
just a test
|
||||
"""
|
Loading…
Reference in New Issue
Block a user