From 26d0a1e821749087b480cb5601a131becab6e33d Mon Sep 17 00:00:00 2001 From: shenjackyuanjie <3695888@qq.com> Date: Sat, 4 Dec 2021 02:11:46 +0800 Subject: [PATCH] 0.6.1 developing --- Difficult_Rocket.py | 7 +++++-- Difficult_Rocket/api/tools.py | 2 +- Difficult_Rocket/client.py | 7 ++----- Difficult_Rocket/command/line.py | 2 ++ Difficult_Rocket/guis/widgets.py | 1 + docs/update_logs.md | 14 ++++++++++++-- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Difficult_Rocket.py b/Difficult_Rocket.py index faa4bf4..4131f59 100644 --- a/Difficult_Rocket.py +++ b/Difficult_Rocket.py @@ -46,8 +46,11 @@ if __name__ == '__main__': try: from Difficult_Rocket import main game = main.Game() - cProfile.run('game.start()', sort='calls') - # game.start() + cprofile = False + if cprofile: + cProfile.run('game.start()', sort='calls') + else: + game.start() if DEBUGGING: raise TestError('debugging') except Exception as exp: diff --git a/Difficult_Rocket/api/tools.py b/Difficult_Rocket/api/tools.py index 1133a3b..918b9dd 100644 --- a/Difficult_Rocket/api/tools.py +++ b/Difficult_Rocket/api/tools.py @@ -45,7 +45,7 @@ file_error = {'FileNotFoundError': 'no {filetype} file was founded!:\n file name def load_file(file_name: str, stack=None) -> dict: f_type = file_name[file_name.rfind('.') + 1:] # 从最后一个.到末尾 (截取文件格式) try: - rd = '' + rd = NotImplementedError('解析失败,请检查文件类型/文件内容/文件是否存在!') if (f_type == 'json5') or (f_type == 'json'): try: with open(file_name, 'r', encoding='utf-8') as jf: # jf -> json file diff --git a/Difficult_Rocket/client.py b/Difficult_Rocket/client.py index a2628ca..a71bf39 100644 --- a/Difficult_Rocket/client.py +++ b/Difficult_Rocket/client.py @@ -38,6 +38,7 @@ from Difficult_Rocket.api import tools, new_thread local_lib = True if local_lib: from libs import pyglet + from libs.pyglet.window import Window from libs.pyglet.window import key, mouse else: import pyglet @@ -75,7 +76,7 @@ class Client: # TODO 写一下服务端启动相关,还是需要服务端啊 -class ClientWindow(pyglet.window.Window): +class ClientWindow(Window): def __init__(self, net_mode='local', *args, **kwargs): start_time = time.time_ns() @@ -258,10 +259,6 @@ class ClientWindow(pyglet.window.Window): key.MOD_CAPSLOCK | key.MOD_SCROLLLOCK)): self.dispatch_event('on_close') - if symbol == key.C and modifiers & key.MOD_CTRL: - self.dispatch_event('on_text_motion', key.MOTION_COPY) - if symbol == key.V and modifiers & key.MOD_CTRL: - self.dispatch_event('on_text_motion', key.MOTION_PASTE) self.logger.debug(tr.lang('window', 'key.press').format(key.symbol_string(symbol), key.modifiers_string(modifiers))) def on_key_release(self, symbol, modifiers) -> None: diff --git a/Difficult_Rocket/command/line.py b/Difficult_Rocket/command/line.py index b0f2b74..b093904 100644 --- a/Difficult_Rocket/command/line.py +++ b/Difficult_Rocket/command/line.py @@ -239,6 +239,8 @@ class CommandLine(widgets.WidgetBase): """ def on_text(self, text): + # 这里的大部分东西都会在最近被重写 + # TODO 重写成基于新的 InputBox 的解析 if self.editing: if text in ('\r', '\n'): # goto a new line if not self.text: diff --git a/Difficult_Rocket/guis/widgets.py b/Difficult_Rocket/guis/widgets.py index 11e2ec6..f7255e2 100644 --- a/Difficult_Rocket/guis/widgets.py +++ b/Difficult_Rocket/guis/widgets.py @@ -189,6 +189,7 @@ class InputBox(widgets.WidgetBase): def on_key_press(self, symbol, modifiers): # 在这加一个on_key_press纯属为了处理剪贴板操作 # (pyglet没有把ctrl+c和ctrl+v的事件绑定到on_text_motion上) + # TODO 正在给pyglet发PR if symbol == key.C and modifiers & key.MOD_CTRL: self.on_text_motion(key.MOTION_COPY) diff --git a/docs/update_logs.md b/docs/update_logs.md index 328f79a..8d2f723 100644 --- a/docs/update_logs.md +++ b/docs/update_logs.md @@ -15,7 +15,9 @@ - [![Readme-gitee](https://img.shields.io/badge/Readme-中文(点我!)-blue.svg?style=flat-square)](README-cn.md) - Using [SemVer 2.0.0](https://semver.org/) to manage version -## 202111 V 0.6.1 +## 202112 V 0.6.1 + +争取12月内发一个release ### Change @@ -26,7 +28,15 @@ - 重写了一遍` client.load_fonts()` - rewrite `client.load_fonts()` - 重写了 `tools.load_file()` 的错误处理和 `.config` 文件的解析方式 - - rewrite `tools.load_file()` error handling and `.config` file parsing mode + - 现在 `.config` 文件解析后会直接返回一个 `ConfigParser` 对象 + - 也就意味着不能再直接遍历 `.config` 文件返回的解析 ~~谁遍历.config文件啊~~ + - 同时也意味着可以直接用解析好的 `.config` 文件来修改 `.config` 文件 + - rewrite `tools.load_file()` error handling and `.config` file parsing method + - now `.config` file parsing after return `ConfigParser` object + - that means you can not directly traverse `.config` file return parsing ~~who traverse .config file~~ + - also means you can directly use parsed `.config` file to modify `.config` file +- 为 `pyglet` 添加 `Ctrl+C` 和 `Ctrl+V` 的快捷键解析 + - add `Ctrl+C` and `Ctrl+V` shortcut for `pyglet` ### Command