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,15 +11,12 @@ github: @shenjackyuanjie
gitee: @shenjackyuanjie
"""
from .api import *
from .guis import *
__version__ = '0.6.1'
__all__ = [
'new_thread',
'Delivery',
'load_file'
]
playing = False
if playing:
from .api import new_thread
@new_thread('think')
def think(some_thing_to_think):

View File

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

View File

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

View File

@ -26,10 +26,11 @@ if __name__ == '__main__': # been start will not run this
sys.path.append('/bin')
# Difficult_Rocket function
from .command import command
from .command import line
from .api.translate import tr
from .fps.fps_log import FpsLogger
from .api import tools, new_thread, translate
from .api.Exp import *
# libs function
local_lib = True
@ -112,7 +113,7 @@ class ClientWindow(pyglet.window.Window):
self.setup()
# 命令显示
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,
length=int(self.game_config['command']['show']),
batch=self.label_batch, group=self.command_group)
@ -168,7 +169,7 @@ class ClientWindow(pyglet.window.Window):
self.run_input = False
try:
self.on_command(get)
except:
except CommandError:
self.logger.error(traceback.format_exc())
self.logger.debug('read_input end')
@ -192,8 +193,7 @@ class ClientWindow(pyglet.window.Window):
def FPS_update(self, tick: Decimal):
now_FPS = pyglet.clock.get_fps()
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:>10.1f} {self.fps_log.max_fps:>5.1f} {self.fps_log.min_fps:>5.1f}'
self.fps_label.text = f'FPS: {now_FPS:>13.1f} {self.fps_log.max_fps:>5.1f} {self.fps_log.min_fps:>5.1f}'
def on_draw(self):
self.clear()
@ -211,7 +211,7 @@ class ClientWindow(pyglet.window.Window):
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))
if command == 'stop':
self.dispatch_event('on_close', 'command') # source = command
@ -226,7 +226,7 @@ class ClientWindow(pyglet.window.Window):
elif command == 'default':
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))
"""

View File

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