From bddc16a650daa8ccdd5f1bb0f69138b887932916 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 1 Jul 2022 13:59:08 +0800 Subject: [PATCH] ing --- Difficult_Rocket/client/__init__.py | 7 ++++--- Difficult_Rocket/utils/translate.py | 31 +++++++++++++++++++++++++++-- try/mod checks/mixin.py | 20 +++++++++++++++++++ try/mod checks/mod_tick_check.py | 17 ++++++++-------- 4 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 try/mod checks/mixin.py diff --git a/Difficult_Rocket/client/__init__.py b/Difficult_Rocket/client/__init__.py index bd44a94..058bca3 100644 --- a/Difficult_Rocket/client/__init__.py +++ b/Difficult_Rocket/client/__init__.py @@ -13,9 +13,7 @@ gitee: @shenjackyuanjie # system function import os -import sys import time -import ctypes import logging import traceback @@ -28,8 +26,8 @@ from Difficult_Rocket.utils.translate import tr from Difficult_Rocket.guis.widgets import InputBox # from Difficult_Rocket.client.screen import DRScreen from Difficult_Rocket.utils import tools, translate -from Difficult_Rocket.exception.command import CommandError from Difficult_Rocket.client.fps.fps_log import FpsLogger +from Difficult_Rocket.exception.command import CommandError from libs import pyglet from libs.pyglet.window import Window @@ -248,6 +246,9 @@ class ClientWindow(Window): keyboard and mouse input """ + def activate(self): + super().activate() + def on_mouse_motion(self, x, y, dx, dy) -> None: pass diff --git a/Difficult_Rocket/utils/translate.py b/Difficult_Rocket/utils/translate.py index 8ae9af8..ebfe434 100644 --- a/Difficult_Rocket/utils/translate.py +++ b/Difficult_Rocket/utils/translate.py @@ -11,17 +11,38 @@ github: @shenjackyuanjie gitee: @shenjackyuanjie """ +import inspect +import objprint + from typing import Union from Difficult_Rocket.exception.language import * from Difficult_Rocket.utils import tools + """ 这部分代码使用了中文编程,why? 你觉得呢? """ +class Tr: + """ + 我不装了,我就复刻tr + """ + def __init__(self): + self.frame = inspect.currentframe() + objprint.objprint(self.frame, + honor_existing=False, + depth=1) + + objprint.objprint(self.frame.f_back, + honor_existing=False, + depth=1) + + + + class Lang: """ 用于创建一个对应语言的翻译类 @@ -70,9 +91,15 @@ class Lang: self.翻译结果 = tools.load_file(f'configs/lang/{language}.toml') self.语言 = language except FileNotFoundError: - raise TranslateKeyNotFoundError(f'{language}\'s language toml file not found') + raise TranslateKeyNotFound(f'{language}\'s language toml file not found') def lang(self, *args) -> Union[int, str, list, dict]: + frame = inspect.currentframe() + print("调用当前log的函数名:", frame.f_back.f_code.co_name) + # print("调用当前log的文件名:", frame.f_back.f_code.co_filename) + objprint.objprint(frame.f_back.f_code, + honor_existing=False, + depth=2) try: 结果 = self.翻译结果 for 选项 in args: @@ -87,7 +114,7 @@ class Lang: except KeyError: if self.直接返回原始数据: return args - raise TranslateKeyNotFoundError(f'there\'s no key {args} in both {self.语言} and zh-CN') + raise TranslateKeyNotFound(f'there\'s no key {args} in both {self.语言} and zh-CN') def 翻译(self, *args) -> Union[int, str, list, dict]: return self.lang(args) diff --git a/try/mod checks/mixin.py b/try/mod checks/mixin.py new file mode 100644 index 0000000..d70cb95 --- /dev/null +++ b/try/mod checks/mixin.py @@ -0,0 +1,20 @@ +# ------------------------------- +# Difficult Rocket +# Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com +# All rights reserved +# ------------------------------- + +from typing import Callable + +func_list = [] + + +def mix_tick(func: Callable) -> Callable: + func_list.append(func) + + def wrapped(game) -> None: + func() + return None + + return wrapped + diff --git a/try/mod checks/mod_tick_check.py b/try/mod checks/mod_tick_check.py index 8710272..a2c3d64 100644 --- a/try/mod checks/mod_tick_check.py +++ b/try/mod checks/mod_tick_check.py @@ -1,9 +1,8 @@ -# Copyright (c) 2021. Lorem ipsum dolor sit amet, consectetur adipiscing elit. -# Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. -# Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. -# Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. -# Vestibulum commodo. Ut rhoncus gravida arcu. - +# ------------------------------- +# Difficult Rocket +# Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com +# All rights reserved +# ------------------------------- """ writen by shenjackyuanjie mail: 3695888@qq.com @@ -11,9 +10,9 @@ github: @shenjackyuanjie gitee: @shenjackyuanjie """ -import decorators +import mixin -@decorators.mod_game.mix_tick('maybe?') -def mixed(game: decorators.MainGame): +@mixin.mix_tick('maybe?') +def mixed(game): game.speed -= 1