diff --git a/Difficult_Rocket/client/__init__.py b/Difficult_Rocket/client/__init__.py index 1636a19..ab694ac 100644 --- a/Difficult_Rocket/client/__init__.py +++ b/Difficult_Rocket/client/__init__.py @@ -269,20 +269,20 @@ class ClientWindow(Window): @_call_screen_after def on_command(self, command: line.CommandText): self.logger.info(tr.lang('window', 'command.text').format(command)) - if command.match('stop'): + if command.re_match('stop'): # self.dispatch_event('on_exit') pyglet.app.platform_event_loop.stop() self.dispatch_event('on_close', 'command') # source = command - elif command.match('fps'): - if command.match('log'): + elif command.re_match('fps'): + if command.re_match('log'): self.logger.debug(self.fps_log.fps_list) - elif command.match('max'): + elif command.re_match('max'): self.logger.info(self.fps_log.max_fps) self.command.push_line(self.fps_log.max_fps, block_line=True) - elif command.match('min'): + elif command.re_match('min'): self.logger.info(self.fps_log.min_fps) self.command.push_line(self.fps_log.min_fps, block_line=True) - elif command.match('default'): + elif command.re_match('default'): self.set_size(int(self.main_config['window_default']['width']), int(self.main_config['window_default']['height'])) self.command_tree.parse(command.plain_command) diff --git a/Difficult_Rocket/client/render/sr1_ship.py b/Difficult_Rocket/client/render/sr1_ship.py index 2a4bd4c..1fbb85d 100644 --- a/Difficult_Rocket/client/render/sr1_ship.py +++ b/Difficult_Rocket/client/render/sr1_ship.py @@ -226,17 +226,17 @@ class SR1ShipRender(BaseScreen): # print(f'{self.scale=} {self.dx=} {self.dy=} {x=} {y=} {scroll_x=} {scroll_y=} {1 - (0.5 ** scroll_y)=}') def on_command(self, command: CommandText): - if command.match('render'): + if command.re_match('render'): # self.render_ship() self.need_draw = True print('应该渲染飞船的') - elif command.match('sr1'): - if command.match('delta'): + elif command.re_match('sr1'): + if command.re_match('delta'): SR1ShipRender_Option.debug_d_pos = not SR1ShipRender_Option.debug_mouse_d_pos self.debug_line.visible = SR1ShipRender_Option.debug_d_pos self.debug_d_pos_label.visible = SR1ShipRender_Option.debug_d_pos - elif command.match('mouse'): - if command.match('delta'): + elif command.re_match('mouse'): + if command.re_match('delta'): SR1ShipRender_Option.debug_mouse_pos = not SR1ShipRender_Option.debug_mouse_pos self.debug_mouse_line.visible = SR1ShipRender_Option.debug_mouse_pos self.debug_mouse_label.visible = SR1ShipRender_Option.debug_mouse_pos diff --git a/Difficult_Rocket/command/api.py b/Difficult_Rocket/command/api.py index f272cf7..96586da 100644 --- a/Difficult_Rocket/command/api.py +++ b/Difficult_Rocket/command/api.py @@ -49,18 +49,19 @@ class CommandText: else: return False - def match(self, text: str) -> bool: + def re_match(self, text: str) -> bool: finding = re.match(text, self.text) if finding: # 如果找到了 try: next_find = self.text[finding.span()[1]] # 这里try因为可能匹配到的是字符串末尾 + # 20230122 我现在也不知道为啥这么写了 + # 果然使用正则表达式就是让一个问题变成两个问题 except IndexError: - next_find = ' ' - # 直接过滤掉 - if next_find == ' ': self.text = self.text[finding.span()[1] + 1:] return True + if next_find == ' ': + return True # 将匹配到的字符串,和最后一个匹配字符后面的字符删除(相当暴力的操作) return False else: diff --git a/docs/src/update_logs.md b/docs/src/update_logs.md index 09ad46b..1cfd9a8 100644 --- a/docs/src/update_logs.md +++ b/docs/src/update_logs.md @@ -4,11 +4,13 @@ - 也就意味着以后的更新日志是中文记录+`copilot`翻译的(当然,也有可能是`Easy Translate`翻译的) - Thanks `Github copilot` for translate (lazy yes!) - Means the update logs will lodge in Chinese and translated by `copilot` +- 可惜啊,github copilot 收费了 + ## Readme First! ##### most badge can be clicked and jump [![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/) -![Generic badge](https://img.shields.io/badge/Version-0.6.5-yellow.svg) +![Generic badge](https://img.shields.io/badge/Version-0.6.5.0-yellow.svg) - [![Readme-github](https://img.shields.io/badge/Readme-Github-blue.svg?style=flat-square&logo=Github)](https://github.com/shenjackyuanjie/Difficult-Rocket) - [![Readme-gitee](https://img.shields.io/badge/Readme-Gitee-blue.svg?style=flat-square&logo=Gitee)](https://gitee.com/shenjackyuanjie/Difficult-Rocket) @@ -19,9 +21,51 @@ ### 抱歉,我撒谎了( +0.6 还得来几个版本号 + ### Add - 现在将文件拖拽至屏幕内可以渲染默认船只/渲染拖拽上来的解析成功的第一艘船 +- 可以使用类似 SR1 的方式拖拽界面 + +### 命令行 + +- `stop` + - 关闭游戏 +- `fps` + - `log` + - 输出 fps 信息 + - `min` + - 输出 最近 5s 的最小 fps + - `max` + - 输出 最近 5s 的最大 fps +- `default` + - 将窗口大小恢复成默认 +- `render` + - 渲染 默认船只 +- `sr1` + - 下面的选项都是 DEBUG 用,不保证以后继续保留 + - `delta` + - 渲染 SR1 渲染的偏移量 + - `mouse` + - 渲染 SR1 渲染的鼠标偏移量 + - `delta` + - 渲染 SR1 渲染的鼠标前进偏移量 + +### 优化(代码层面) + +- 改掉了 `CommandText` 里的离谱代码 +- 优化了 `tools.load_file` 的逻辑(其实是几个版本之前的改动 +- `CommandText.match` -> `CommandText.re_match` +- 感谢 @caffe 的 pyglet `macosx` 分支 +- 暂未实装 + - `Translates` 的优化 + - 以后多语言用起来会更方便 + - `Tr` 的优化 + - 跟 `Translates` 配套 + - `Difficult_Rocket_rs` + - DR 的 Rust 优化 + - 基于 `pyo3` ## 20221124 V 0.6.4