This commit is contained in:
shenjack 2022-07-01 13:59:08 +08:00
parent bd88ec8684
commit bddc16a650
4 changed files with 61 additions and 14 deletions

View File

@ -13,9 +13,7 @@ gitee: @shenjackyuanjie
# system function # system function
import os import os
import sys
import time import time
import ctypes
import logging import logging
import traceback import traceback
@ -28,8 +26,8 @@ from Difficult_Rocket.utils.translate import tr
from Difficult_Rocket.guis.widgets import InputBox from Difficult_Rocket.guis.widgets import InputBox
# from Difficult_Rocket.client.screen import DRScreen # from Difficult_Rocket.client.screen import DRScreen
from Difficult_Rocket.utils import tools, translate 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.client.fps.fps_log import FpsLogger
from Difficult_Rocket.exception.command import CommandError
from libs import pyglet from libs import pyglet
from libs.pyglet.window import Window from libs.pyglet.window import Window
@ -248,6 +246,9 @@ class ClientWindow(Window):
keyboard and mouse input keyboard and mouse input
""" """
def activate(self):
super().activate()
def on_mouse_motion(self, x, y, dx, dy) -> None: def on_mouse_motion(self, x, y, dx, dy) -> None:
pass pass

View File

@ -11,17 +11,38 @@ github: @shenjackyuanjie
gitee: @shenjackyuanjie gitee: @shenjackyuanjie
""" """
import inspect
import objprint
from typing import Union from typing import Union
from Difficult_Rocket.exception.language import * from Difficult_Rocket.exception.language import *
from Difficult_Rocket.utils import tools from Difficult_Rocket.utils import tools
""" """
这部分代码使用了中文编程why 这部分代码使用了中文编程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: class Lang:
""" """
用于创建一个对应语言的翻译类 用于创建一个对应语言的翻译类
@ -70,9 +91,15 @@ class Lang:
self.翻译结果 = tools.load_file(f'configs/lang/{language}.toml') self.翻译结果 = tools.load_file(f'configs/lang/{language}.toml')
self.语言 = language self.语言 = language
except FileNotFoundError: 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]: 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: try:
结果 = self.翻译结果 结果 = self.翻译结果
for 选项 in args: for 选项 in args:
@ -87,7 +114,7 @@ class Lang:
except KeyError: except KeyError:
if self.直接返回原始数据: if self.直接返回原始数据:
return args 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]: def 翻译(self, *args) -> Union[int, str, list, dict]:
return self.lang(args) return self.lang(args)

20
try/mod checks/mixin.py Normal file
View File

@ -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

View File

@ -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. # Difficult Rocket
# Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. # All rights reserved
# Vestibulum commodo. Ut rhoncus gravida arcu. # -------------------------------
""" """
writen by shenjackyuanjie writen by shenjackyuanjie
mail: 3695888@qq.com mail: 3695888@qq.com
@ -11,9 +10,9 @@ github: @shenjackyuanjie
gitee: @shenjackyuanjie gitee: @shenjackyuanjie
""" """
import decorators import mixin
@decorators.mod_game.mix_tick('maybe?') @mixin.mix_tick('maybe?')
def mixed(game: decorators.MainGame): def mixed(game):
game.speed -= 1 game.speed -= 1