shenjack
f9eeafe322
readme update 看起来更像 Dear ImGui 一些(looks more like Dear ImGui and some intersting feature to the button remove debug 确认一下action 404 修改 writing theme looks good better? a ? alpha=255 not 256 looks better try new pyglet first 看起来好一些 sync pyglet 水一手 这波必须得水一手了,要不然commit太少了(确信 丢点正经东西上去 顺手继承一下Options 补充docs 坏了,忘记水commit了( 至少我能早睡了( 这里还能水一点来着( 试试再说 reee 保证能跑( 同步lib not dr 的修改 忘记带上 None了 还是加上一个额外的判断参数吧 刷点commit也不错 先更新一下依赖版本 水commit啦 理论可行,实践开始! 构建参数喜加一 reeeee 更新一下 pyproject 的依赖 fix typing looks better 水一个( 测试? sync pyglet to master A | Try use rust-cache looks good? what? C | sync pyglet A | 添加了一个 Button Draw Theme A | Magic Number (确信) A | 尽量不继承Options sync pyglet A | Add theme A | Add more Theme information Enhance | Theme sync pyglet Add | add unifont Enhance | use os.walk in font loading Enhance | Use i18n in font loading Enhance | doc sync pyglet Add | add 3.12 build option to build_rs Fix | Button position have a z sync pyglet A | Logger.py 启动! sync pyglet Changed | Bump pyo3 to 0.20.0 add logger.py update logger! Add | more logger! Add | lib-not-dr some lib-not-dr
95 lines
3.2 KiB
Python
95 lines
3.2 KiB
Python
# -------------------------------
|
|
# Difficult Rocket
|
|
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
|
# All rights reserved
|
|
# -------------------------------
|
|
|
|
"""
|
|
writen by shenjackyuanjie
|
|
mail: 3695888@qq.com
|
|
github: @shenjackyuanjie
|
|
gitee: @shenjackyuanjie
|
|
"""
|
|
|
|
# system function
|
|
import warnings
|
|
from typing import Tuple, List, Optional, TypeVar, TYPE_CHECKING
|
|
|
|
# from DR
|
|
if TYPE_CHECKING:
|
|
from Difficult_Rocket.main import Game
|
|
from Difficult_Rocket.client import ClientWindow
|
|
else:
|
|
Game = TypeVar("Game")
|
|
ClientWindow = TypeVar("ClientWindow")
|
|
from Difficult_Rocket import DR_status
|
|
from Difficult_Rocket.api.types import Options, Version
|
|
|
|
RequireVersion = Tuple[Version, Version]
|
|
# 第一个是最低兼容版本,第二个是最高兼容版本
|
|
# 例如: ("1.0.0", "1.1.0") 表示从1.0.0版本开始兼容,到1.1.0版本结束兼容
|
|
ForceRequire = bool
|
|
|
|
|
|
class ModInfo(Options):
|
|
"""
|
|
加载mod时候的参数
|
|
"""
|
|
"""基本信息"""
|
|
mod_id: str # mod id
|
|
name: str # mod 名称
|
|
version: Version # mod 版本
|
|
|
|
"""作者、描述"""
|
|
writer: str # 作者
|
|
link: str = "" # 作者链接
|
|
description: str = "" # 描述 (务必简洁明了)
|
|
info: str = "" # 其他信息 (可以很多很多)
|
|
|
|
"""版本相关信息"""
|
|
DR_version: RequireVersion = (DR_status.DR_version, DR_status.DR_version) # DR SDK 兼容版本
|
|
DR_Api_version: RequireVersion = (DR_status.API_version, DR_status.API_version) # DR Api版本
|
|
Mod_Require_version: List[Tuple[str, ForceRequire, RequireVersion]] = [] # mod 依赖版本
|
|
|
|
"""mod 状态"""
|
|
is_enable: bool = True # 是否启用
|
|
is_loaded: bool = False # 是否加载
|
|
|
|
"""mod 配置"""
|
|
config: Options = Options() # mod 配置存储
|
|
old_mod: Optional["ModInfo"] = None # 旧的mod实例
|
|
|
|
def __init__(self, **kwargs):
|
|
if not self.DR_version[0] <= DR_status.DR_version <= self.DR_version[1]:
|
|
warnings.warn(f"mod {self.mod_id} version {self.version} is not support by DR {DR_status.DR_version}\n"
|
|
f"DR {self.DR_version} is required")
|
|
if not self.DR_Api_version[0] <= DR_status.API_version <= self.DR_Api_version[1]:
|
|
warnings.warn(f"mod {self.mod_id} version {self.version} is not support by DR {DR_status.API_version}\n"
|
|
f"DR {self.DR_Api_version} is required")
|
|
super().__init__(**kwargs)
|
|
|
|
def on_load(self, game: Game, old_self: Optional["ModInfo"] = None) -> bool:
|
|
""" 加载时调用 """
|
|
return True
|
|
|
|
def on_client_start(self, game: Game, client: ClientWindow):
|
|
""" 客户端启动时调用 """
|
|
print(f'Mod {self.mod_id} client start')
|
|
|
|
def on_client_stop(self, game: Game, client: ClientWindow, source: str = 'window'):
|
|
""" 客户端停止时调用 """
|
|
print(f'Mod {self.mod_id} client stop')
|
|
|
|
def on_server_start(self, game: Game):
|
|
""" 服务器启动时调用 """
|
|
print(f'Mod {self.mod_id} server start')
|
|
|
|
def on_server_stop(self, game: Game):
|
|
""" 服务器停止时调用 """
|
|
print(f'Mod {self.mod_id} server stop')
|
|
|
|
def on_unload(self, game: Game):
|
|
""" 卸载时调用 """
|
|
print(f'Mod {self.mod_id} unloaded')
|
|
|