gogogo
anti 996!
This commit is contained in:
parent
2d142b0ce3
commit
aa7d359cf6
@ -11,8 +11,9 @@ github: @shenjackyuanjie
|
|||||||
gitee: @shenjackyuanjie
|
gitee: @shenjackyuanjie
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import traceback
|
||||||
from dataclasses import dataclass
|
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
|
# from Difficult Rocket
|
||||||
|
|
||||||
@ -67,10 +68,23 @@ class Options:
|
|||||||
setattr(self, option, value)
|
setattr(self, option, value)
|
||||||
if hasattr(self, 'init'):
|
if hasattr(self, 'init'):
|
||||||
self.init(**kwargs)
|
self.init(**kwargs)
|
||||||
|
if hasattr(self, 'load_file'):
|
||||||
|
try:
|
||||||
|
self.load_file()
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
self.flush_option()
|
self.flush_option()
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
def init(self, **kwargs) -> None:
|
def init(self, **kwargs) -> None:
|
||||||
...
|
""" 如果子类定义了这个函数,则会在 __init__ 之后调用这个函数 """
|
||||||
|
|
||||||
|
def load_file(self) -> bool:
|
||||||
|
"""
|
||||||
|
如果子类定义了这个函数,则会在 __init__ 和 init 之后再调用这个函数
|
||||||
|
|
||||||
|
请注意,这个函数请尽量使用 try 包裹住可能出现错误的部分
|
||||||
|
否则会在控制台输出你的报错"""
|
||||||
|
|
||||||
def option(self) -> Dict[str, Any]:
|
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
|
raise OptionNotFound(f'Option {option} is not found in {self.name}') from None
|
||||||
return values
|
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]:
|
def flush_option(self) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
刷新缓存 options 的内容
|
刷新缓存 options 的内容
|
||||||
|
@ -25,12 +25,13 @@ from decimal import Decimal
|
|||||||
import rtoml
|
import rtoml
|
||||||
import pyglet
|
import pyglet
|
||||||
# from pyglet import gl
|
# from pyglet import gl
|
||||||
from pyglet.gl import glClearColor
|
# from pyglet.gl import glClearColor
|
||||||
# from pyglet.libs.win32 import _user32
|
# from pyglet.libs.win32 import _user32
|
||||||
from pyglet.window import Window
|
from pyglet.window import Window
|
||||||
from pyglet.window import key, mouse
|
from pyglet.window import key, mouse
|
||||||
|
|
||||||
# Difficult_Rocket function
|
# Difficult_Rocket function
|
||||||
|
from Difficult_Rocket.api.types import Options
|
||||||
from Difficult_Rocket.command import line, tree
|
from Difficult_Rocket.command import line, tree
|
||||||
from Difficult_Rocket.utils.translate import tr
|
from Difficult_Rocket.utils.translate import tr
|
||||||
from Difficult_Rocket import DR_runtime, DR_option
|
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
|
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:
|
class Client:
|
||||||
def __init__(self, net_mode='local'):
|
def __init__(self, net_mode='local'):
|
||||||
start_time = time.time_ns()
|
start_time = time.time_ns()
|
||||||
|
@ -260,3 +260,9 @@ class SR1ShipRender(BaseScreen):
|
|||||||
break
|
break
|
||||||
self.render_ship()
|
self.render_ship()
|
||||||
print(paths)
|
print(paths)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
from objprint import op
|
||||||
|
|
||||||
|
op(SR1ShipRender_Option)
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
- [discord](https://discord.gg/kWzw2JrG6M)
|
- [discord](https://discord.gg/kWzw2JrG6M)
|
||||||
- [kook](https://kook.top/sRPjFG)
|
- [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/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/编写于_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)
|
[![Generic badge](https://img.shields.io/badge/编写于_Pyglet_版本-2.0.2.1-blue.svg)](https://pyglet.org)
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
- [discord](https://discord.gg/kWzw2JrG6M)
|
- [discord](https://discord.gg/kWzw2JrG6M)
|
||||||
- [kook](https://kook.top/sRPjFG)
|
- [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/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_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)
|
[![Generic badge](https://img.shields.io/badge/Write_with_Pyglet-2.0.2.1-blue.svg)](https://pyglet.org)
|
||||||
|
@ -197,3 +197,14 @@ class VersionRequirement:
|
|||||||
|
|
||||||
class VersionParsingError(ValueError):
|
class VersionParsingError(ValueError):
|
||||||
pass
|
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)
|
||||||
|
@ -3,26 +3,26 @@
|
|||||||
# DR build (by nuitka)
|
# DR build (by nuitka)
|
||||||
|
|
||||||
# for phy simulation
|
# for phy simulation
|
||||||
pymunk
|
pymunk >= 6.4.0
|
||||||
|
|
||||||
# for images
|
# for images
|
||||||
pillow
|
pillow >= 9.4.0
|
||||||
|
|
||||||
# for sys info
|
# for sys info
|
||||||
psutil
|
psutil >= 5.9.4
|
||||||
|
|
||||||
# for files
|
# for files
|
||||||
rtoml
|
rtoml >= 0.9.0
|
||||||
tomlkit
|
tomlkit >= 0.11.6
|
||||||
defusedxml
|
defusedxml >= 0.7.1
|
||||||
|
|
||||||
# for report error
|
# for report error
|
||||||
objprint
|
objprint >= 0.2.2
|
||||||
|
|
||||||
# for compile
|
# for compile
|
||||||
nuitka
|
nuitka >= 1.3.8
|
||||||
ordered-set
|
ordered-set >= 4.1.0
|
||||||
imageio
|
imageio >= 2.25.0
|
||||||
setuptools
|
wheel >= 0.38.4
|
||||||
wheel
|
setuptools >= 66.1.1
|
||||||
setuptools-rust
|
setuptools-rust >= 1.5.2
|
||||||
|
@ -4,27 +4,27 @@
|
|||||||
# DR contributing
|
# DR contributing
|
||||||
|
|
||||||
# for phy simulation
|
# for phy simulation
|
||||||
pymunk
|
pymunk >= 6.4.0
|
||||||
|
|
||||||
# for images
|
# for images
|
||||||
pillow
|
pillow >= 9.4.0
|
||||||
|
|
||||||
# for sys info
|
# for sys info
|
||||||
psutil
|
psutil >= 5.9.4
|
||||||
|
|
||||||
# for files
|
# for files
|
||||||
rtoml
|
rtoml >= 0.9.0
|
||||||
tomlkit
|
tomlkit >= 0.11.6
|
||||||
defusedxml
|
defusedxml >= 0.7.1
|
||||||
|
|
||||||
# for debug
|
# for debug
|
||||||
objprint
|
objprint >= 0.2.2
|
||||||
viztracer
|
viztracer >= 0.15.6
|
||||||
|
|
||||||
# for compile
|
# for compile
|
||||||
nuitka
|
nuitka >= 1.3.8
|
||||||
ordered-set
|
ordered-set >= 4.1.0
|
||||||
imageio
|
imageio >= 2.25.0
|
||||||
wheel
|
wheel >= 0.38.4
|
||||||
setuptools
|
setuptools >= 66.1.1
|
||||||
setuptools-rust
|
setuptools-rust >= 1.5.2
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
# DR basic running from source
|
# DR basic running from source
|
||||||
|
|
||||||
# for phy simulation
|
# for phy simulation
|
||||||
pymunk
|
pymunk >= 6.4.0
|
||||||
|
|
||||||
# for images
|
# for images
|
||||||
pillow
|
pillow >= 9.4.0
|
||||||
|
|
||||||
# for sys info
|
# for sys info
|
||||||
psutil
|
psutil >= 5.9.4
|
||||||
|
|
||||||
# for files
|
# for files
|
||||||
rtoml
|
rtoml >= 0.9.0
|
||||||
tomlkit
|
tomlkit >= 0.11.6
|
||||||
defusedxml
|
defusedxml >= 0.7.1
|
||||||
|
|
||||||
# for report error
|
# for report error
|
||||||
objprint
|
objprint >= 0.2.2
|
||||||
|
Loading…
Reference in New Issue
Block a user