anti 996!
This commit is contained in:
沈瑗杰 2023-01-23 13:54:05 +08:00
parent 2d142b0ce3
commit aa7d359cf6
9 changed files with 92 additions and 38 deletions

View File

@ -11,8 +11,9 @@ github: @shenjackyuanjie
gitee: @shenjackyuanjie
"""
import traceback
from dataclasses import dataclass
from typing import get_type_hints, Type, List, Union, Dict, Any, Callable, Tuple, Optional
from typing import get_type_hints, Type, List, Union, Dict, Any, Callable, Tuple, Optional, TYPE_CHECKING
# from Difficult Rocket
@ -67,10 +68,23 @@ class Options:
setattr(self, option, value)
if hasattr(self, 'init'):
self.init(**kwargs)
if hasattr(self, 'load_file'):
try:
self.load_file()
except:
traceback.print_exc()
self.flush_option()
def init(self, **kwargs) -> None:
...
if TYPE_CHECKING:
def init(self, **kwargs) -> None:
""" 如果子类定义了这个函数,则会在 __init__ 之后调用这个函数 """
def load_file(self) -> bool:
"""
如果子类定义了这个函数则会在 __init__ init 之后再调用这个函数
请注意这个函数请尽量使用 try 包裹住可能出现错误的部分
否则会在控制台输出你的报错"""
def option(self) -> Dict[str, Any]:
"""
@ -98,6 +112,11 @@ class Options:
raise OptionNotFound(f'Option {option} is not found in {self.name}') from None
return values
def format(self, text: str) -> str:
cache_option = self.flush_option()
for option in cache_option:
text.replace(f'\{{option}\}')
def flush_option(self) -> Dict[str, Any]:
"""
刷新缓存 options 的内容

View File

@ -25,12 +25,13 @@ from decimal import Decimal
import rtoml
import pyglet
# from pyglet import gl
from pyglet.gl import glClearColor
# from pyglet.gl import glClearColor
# from pyglet.libs.win32 import _user32
from pyglet.window import Window
from pyglet.window import key, mouse
# Difficult_Rocket function
from Difficult_Rocket.api.types import Options
from Difficult_Rocket.command import line, tree
from Difficult_Rocket.utils.translate import tr
from Difficult_Rocket import DR_runtime, DR_option
@ -43,6 +44,21 @@ from Difficult_Rocket.client.render.sr1_ship import SR1ShipRender
from Difficult_Rocket.client.screen import BaseScreen, DRScreen, DRDEBUGScreen
class ClientOption(Options):
fps: int = 60
width: int = 1024
height: int = 768
file_drop: bool = True
fullscreen: bool = False
resizeable: bool = True
visible: bool = True
gui_scale: float = 1.0
caption: str = "Difficult Rocket {version}"
def load_file(self) -> None:
...
class Client:
def __init__(self, net_mode='local'):
start_time = time.time_ns()

View File

@ -260,3 +260,9 @@ class SR1ShipRender(BaseScreen):
break
self.render_ship()
print(paths)
if __name__ == '__main__':
from objprint import op
op(SR1ShipRender_Option)

View File

@ -9,6 +9,7 @@
- [discord](https://discord.gg/kWzw2JrG6M)
- [kook](https://kook.top/sRPjFG)
<a href="https://996.icu"><img src="https://img.shields.io/badge/link-996.icu-red.svg" alt="996.icu" /></a>
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
[![Generic badge](https://img.shields.io/badge/编写于_Python_版本-3.8.10-blue.svg)](https://Python.org)
[![Generic badge](https://img.shields.io/badge/编写于_Pyglet_版本-2.0.2.1-blue.svg)](https://pyglet.org)

View File

@ -9,6 +9,7 @@
- [discord](https://discord.gg/kWzw2JrG6M)
- [kook](https://kook.top/sRPjFG)
<a href="https://996.icu"><img src="https://img.shields.io/badge/link-996.icu-red.svg" alt="996.icu" /></a>
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
[![Generic badge](https://img.shields.io/badge/Write_with_Python-3.8.10-blue.svg)](https://Python.org)
[![Generic badge](https://img.shields.io/badge/Write_with_Pyglet-2.0.2.1-blue.svg)](https://pyglet.org)

View File

@ -197,3 +197,14 @@ class VersionRequirement:
class VersionParsingError(ValueError):
pass
if __name__ == '__main__':
from objprint import op
test_list = ['1.1.1',
'1.0',
'1.11.1.11.1']
for a_test in test_list:
version_a = Version(a_test)
op(version_a)

View File

@ -3,26 +3,26 @@
# DR build (by nuitka)
# for phy simulation
pymunk
pymunk >= 6.4.0
# for images
pillow
pillow >= 9.4.0
# for sys info
psutil
psutil >= 5.9.4
# for files
rtoml
tomlkit
defusedxml
rtoml >= 0.9.0
tomlkit >= 0.11.6
defusedxml >= 0.7.1
# for report error
objprint
objprint >= 0.2.2
# for compile
nuitka
ordered-set
imageio
setuptools
wheel
setuptools-rust
nuitka >= 1.3.8
ordered-set >= 4.1.0
imageio >= 2.25.0
wheel >= 0.38.4
setuptools >= 66.1.1
setuptools-rust >= 1.5.2

View File

@ -4,27 +4,27 @@
# DR contributing
# for phy simulation
pymunk
pymunk >= 6.4.0
# for images
pillow
pillow >= 9.4.0
# for sys info
psutil
psutil >= 5.9.4
# for files
rtoml
tomlkit
defusedxml
rtoml >= 0.9.0
tomlkit >= 0.11.6
defusedxml >= 0.7.1
# for debug
objprint
viztracer
objprint >= 0.2.2
viztracer >= 0.15.6
# for compile
nuitka
ordered-set
imageio
wheel
setuptools
setuptools-rust
nuitka >= 1.3.8
ordered-set >= 4.1.0
imageio >= 2.25.0
wheel >= 0.38.4
setuptools >= 66.1.1
setuptools-rust >= 1.5.2

View File

@ -2,18 +2,18 @@
# DR basic running from source
# for phy simulation
pymunk
pymunk >= 6.4.0
# for images
pillow
pillow >= 9.4.0
# for sys info
psutil
psutil >= 5.9.4
# for files
rtoml
tomlkit
defusedxml
rtoml >= 0.9.0
tomlkit >= 0.11.6
defusedxml >= 0.7.1
# for report error
objprint
objprint >= 0.2.2