0.6.1 developing

This commit is contained in:
shenjackyuanjie 2021-10-31 23:26:32 +08:00
parent 2eeda7ef53
commit 01b0d7c70f
5 changed files with 33 additions and 29 deletions

View File

@ -11,17 +11,14 @@ github: @shenjackyuanjie
gitee: @shenjackyuanjie gitee: @shenjackyuanjie
""" """
from .api import * __version__ = '0.6.1'
from .guis import *
__all__ = [ playing = False
'new_thread',
'Delivery',
'load_file'
]
if playing:
from .api import new_thread
@new_thread('think') @new_thread('think')
def think(some_thing_to_think): def think(some_thing_to_think):
gotcha = 'think_result' gotcha = 'think_result'
return gotcha return gotcha

View File

@ -13,6 +13,7 @@ gitee: @shenjackyuanjie
__all__ = ['TexturesError', __all__ = ['TexturesError',
'LanguageError', 'LanguageError',
'CommandError',
'TestError'] 'TestError']
@ -26,6 +27,11 @@ class TexturesError(Error):
pass pass
class CommandError(Error):
"""命令解析相关 error"""
pass
class LanguageError(Error): class LanguageError(Error):
"""lang 文件相关 error""" """lang 文件相关 error"""
pass pass

View File

@ -1,8 +1,9 @@
import functools import functools
import inspect import inspect
import threading import threading
from typing import Optional, Callable
from Difficult_Rocket import crash from Difficult_Rocket import crash
from typing import Optional, Callable
""" """
This part of code come from MCDReforged(https://github.com/Fallen-Breath/MCDReforged) This part of code come from MCDReforged(https://github.com/Fallen-Breath/MCDReforged)
@ -57,10 +58,7 @@ class FunctionThread(threading.Thread):
super().join(timeout) super().join(timeout)
def start(self) -> None: def start(self) -> None:
try:
super().start() super().start()
except:
raise

View File

@ -26,10 +26,11 @@ if __name__ == '__main__': # been start will not run this
sys.path.append('/bin') sys.path.append('/bin')
# Difficult_Rocket function # Difficult_Rocket function
from .command import command from .command import line
from .api.translate import tr from .api.translate import tr
from .fps.fps_log import FpsLogger from .fps.fps_log import FpsLogger
from .api import tools, new_thread, translate from .api import tools, new_thread, translate
from .api.Exp import *
# libs function # libs function
local_lib = True local_lib = True
@ -112,7 +113,7 @@ class ClientWindow(pyglet.window.Window):
self.setup() self.setup()
# 命令显示 # 命令显示
self.command_group = pyglet.graphics.Group(0) self.command_group = pyglet.graphics.Group(0)
self.command = command.CommandLine(x=50, y=30, # 实例化 self.command = line.CommandLine(x=50, y=30, # 实例化
width=self.width - 100, height=40, width=self.width - 100, height=40,
length=int(self.game_config['command']['show']), length=int(self.game_config['command']['show']),
batch=self.label_batch, group=self.command_group) batch=self.label_batch, group=self.command_group)
@ -168,7 +169,7 @@ class ClientWindow(pyglet.window.Window):
self.run_input = False self.run_input = False
try: try:
self.on_command(get) self.on_command(get)
except: except CommandError:
self.logger.error(traceback.format_exc()) self.logger.error(traceback.format_exc())
self.logger.debug('read_input end') self.logger.debug('read_input end')
@ -192,8 +193,7 @@ class ClientWindow(pyglet.window.Window):
def FPS_update(self, tick: Decimal): def FPS_update(self, tick: Decimal):
now_FPS = pyglet.clock.get_fps() now_FPS = pyglet.clock.get_fps()
self.fps_log.update_tick(tick) self.fps_log.update_tick(tick)
# self.fps_label.text = 'FPS: {:5.1f} {:.1f} ({:.1f}/{:.1f}) | MSPF: {:.5f} '.format(now_FPS, 1 / tick, self.fps_log.max_fps, self.fps_log.min_fps, tick) self.fps_label.text = f'FPS: {now_FPS:>13.1f} {self.fps_log.max_fps:>5.1f} {self.fps_log.min_fps:>5.1f}'
self.fps_label.text = f'FPS: {now_FPS:>10.1f} {self.fps_log.max_fps:>5.1f} {self.fps_log.min_fps:>5.1f}'
def on_draw(self): def on_draw(self):
self.clear() self.clear()
@ -211,7 +211,7 @@ class ClientWindow(pyglet.window.Window):
command line event command line event
""" """
def on_command(self, command: command.CommandLine.text): def on_command(self, command: line.CommandLine.text):
self.logger.info(tr.lang('window', 'command.text').format(command)) self.logger.info(tr.lang('window', 'command.text').format(command))
if command == 'stop': if command == 'stop':
self.dispatch_event('on_close', 'command') # source = command self.dispatch_event('on_close', 'command') # source = command
@ -226,7 +226,7 @@ class ClientWindow(pyglet.window.Window):
elif command == 'default': elif command == 'default':
self.set_size(int(self.config_file['window_default']['width']), int(self.config_file['window_default']['height'])) self.set_size(int(self.config_file['window_default']['width']), int(self.config_file['window_default']['height']))
def on_message(self, message: command.CommandLine.text): def on_message(self, message: line.CommandLine.text):
self.logger.info(tr.lang('window', 'message.text').format(message)) self.logger.info(tr.lang('window', 'message.text').format(message))
""" """

View File

@ -17,8 +17,7 @@ from typing import Union
from decimal import Decimal from decimal import Decimal
# from DR # from DR
from ..api import translate from Difficult_Rocket.api import translate, new_thread
from ..api.new_thread import new_thread
# from libs.pyglet # from libs.pyglet
from libs import pyglet from libs import pyglet
@ -48,7 +47,7 @@ class CommandLine(widgets.WidgetBase):
# normal values # normal values
self.length = length self.length = length
self.command_list = ['' for line in range(length)] self._command_list = ['' for line in range(length)]
self._command_text = command_text self._command_text = command_text
self._text_position = 0 self._text_position = 0
self._command_view = 0 self._command_view = 0
@ -176,6 +175,10 @@ class CommandLine(widgets.WidgetBase):
if not self.editing: # 如果不在编辑再隐藏 if not self.editing: # 如果不在编辑再隐藏
self._label[0].visible = False self._label[0].visible = False
@property
def command_list(self):
return self._command_list
""" """
events events
""" """