mods update
This commit is contained in:
parent
07dfc2b5e9
commit
79f0cfceaf
@ -109,13 +109,15 @@ class _DR_runtime(Options):
|
|||||||
DR 的运行时配置/状态
|
DR 的运行时配置/状态
|
||||||
"""
|
"""
|
||||||
name = 'DR Runtime'
|
name = 'DR Runtime'
|
||||||
# game status
|
# game version status
|
||||||
DR_version: Version = game_version
|
DR_version: Version = game_version # DR SDK 版本
|
||||||
Build_version: Version = build_version
|
Build_version: Version = build_version # DR 构建 版本
|
||||||
DR_Rust_version: Version = DR_rust_version
|
|
||||||
DR_Rust_get_version: Optional[Version] = None
|
DR_Rust_version: Version = DR_rust_version # 后面要去掉的 DR_rs 版本
|
||||||
API_version: Version = Api_version
|
DR_Rust_get_version: Optional[Version] = None # 后面也要去掉的 DR_rs 版本
|
||||||
DR_long_version: int = long_version
|
|
||||||
|
API_version: Version = Api_version # DR SDK API 版本
|
||||||
|
DR_long_version: int = long_version # DR SDK 内部协议版本 (不要问我为什么不用 Version,我也在考虑)
|
||||||
|
|
||||||
# run status
|
# run status
|
||||||
running: bool = False
|
running: bool = False
|
||||||
|
@ -37,13 +37,14 @@ 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
|
||||||
|
from Difficult_Rocket.api.screen import BaseScreen
|
||||||
from Difficult_Rocket.utils.new_thread import new_thread
|
from Difficult_Rocket.utils.new_thread import new_thread
|
||||||
from Difficult_Rocket.client.fps.fps_log import FpsLogger
|
from Difficult_Rocket.client.fps.fps_log import FpsLogger
|
||||||
from Difficult_Rocket.client.guis.widgets import InputBox
|
from Difficult_Rocket.client.guis.widgets import InputBox
|
||||||
from Difficult_Rocket.exception.language import LanguageNotFound
|
|
||||||
from Difficult_Rocket.exception.command import CommandError
|
from Difficult_Rocket.exception.command import CommandError
|
||||||
|
from Difficult_Rocket.exception.language import LanguageNotFound
|
||||||
from Difficult_Rocket.client.render.sr1_ship import SR1ShipRender
|
from Difficult_Rocket.client.render.sr1_ship import SR1ShipRender
|
||||||
from Difficult_Rocket.client.screen import BaseScreen, DRScreen, DRDEBUGScreen
|
from Difficult_Rocket.client.screen import DRScreen, DRDEBUGScreen
|
||||||
|
|
||||||
|
|
||||||
class ClientOption(Options):
|
class ClientOption(Options):
|
||||||
@ -248,6 +249,13 @@ class ClientWindow(Window):
|
|||||||
rtoml.dump(config_file, open('./configs/main.toml', 'w'))
|
rtoml.dump(config_file, open('./configs/main.toml', 'w'))
|
||||||
self.logger.info(tr().client.config.save.done())
|
self.logger.info(tr().client.config.save.done())
|
||||||
|
|
||||||
|
"""
|
||||||
|
client api
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_sub_screen(self, sub_screen: BaseScreen.__class__):
|
||||||
|
self.screen_list.append(sub_screen(self))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
draws and some event
|
draws and some event
|
||||||
"""
|
"""
|
||||||
|
@ -12,7 +12,7 @@ gitee: @shenjackyuanjie
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# system function
|
# system function
|
||||||
from typing import Tuple
|
from typing import Tuple, List
|
||||||
|
|
||||||
# from libs
|
# from libs
|
||||||
from MCDR.version import Version
|
from MCDR.version import Version
|
||||||
@ -24,7 +24,7 @@ from Difficult_Rocket import DR_runtime, Options
|
|||||||
"""
|
"""
|
||||||
mod系统参数
|
mod系统参数
|
||||||
"""
|
"""
|
||||||
MOD_loader_version = "0.0.1" # mod系统版本 版本号遵守semver2.0.0
|
MOD_loader_version = "0.1.0.0" # mod系统版本 版本号遵守 semver ++
|
||||||
semver_loader_version = Version(MOD_loader_version)
|
semver_loader_version = Version(MOD_loader_version)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -32,7 +32,13 @@ semver_loader_version = Version(MOD_loader_version)
|
|||||||
这里的只是范例,实际加载时会根据mod配置修改
|
这里的只是范例,实际加载时会根据mod配置修改
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
RequireVersion = Tuple[Version, Version]
|
||||||
|
# 第一个是最低兼容版本,第二个是最高兼容版本
|
||||||
|
# 例如: ("1.0.0", "1.1.0") 表示从1.0.0版本开始兼容,到1.1.0版本结束兼容
|
||||||
|
ForceRequire = bool
|
||||||
|
|
||||||
|
|
||||||
|
# TODO 完善中
|
||||||
class MODInfo(Serializable):
|
class MODInfo(Serializable):
|
||||||
"""
|
"""
|
||||||
加载mod时候的参数
|
加载mod时候的参数
|
||||||
@ -40,7 +46,6 @@ class MODInfo(Serializable):
|
|||||||
"""基本信息"""
|
"""基本信息"""
|
||||||
name: str # mod 名称
|
name: str # mod 名称
|
||||||
version: Version # mod 版本
|
version: Version # mod 版本
|
||||||
dependencies: list = [] # mod依赖
|
|
||||||
|
|
||||||
"""作者、描述"""
|
"""作者、描述"""
|
||||||
writer: str # 作者
|
writer: str # 作者
|
||||||
@ -48,26 +53,19 @@ class MODInfo(Serializable):
|
|||||||
description: str = "" # 描述 (务必简洁明了)
|
description: str = "" # 描述 (务必简洁明了)
|
||||||
info: str = "" # 其他信息 (可以很多很多)
|
info: str = "" # 其他信息 (可以很多很多)
|
||||||
|
|
||||||
"""版本兼容信息"""
|
"""版本相关信息"""
|
||||||
write_version: Version # mod编写版本
|
DR_version: RequireVersion = (DR_runtime.DR_version, DR_runtime.DR_version) # DR SDK 兼容版本
|
||||||
write_loader_version: Version # mod编写的加载器版本
|
DR_Api_version: RequireVersion = (DR_runtime.API_version, DR_runtime.API_version) # DR Api版本
|
||||||
compatible_version: Tuple[Version, Version] = (DR_runtime.DR_version, DR_runtime.DR_version) # mod兼容版本
|
Mod_Require_version: List[Tuple[str, ForceRequire, RequireVersion]] = [] # mod 依赖版本
|
||||||
# 第一个是最低兼容版本,第二个是最高兼容版本
|
|
||||||
# 例如: ("1.0.0", "1.1.0") 表示从1.0.0版本开始兼容,到1.1.0版本结束兼容
|
|
||||||
|
|
||||||
|
"""mod 状态"""
|
||||||
|
is_enable: bool = True # 是否启用
|
||||||
|
is_loaded: bool = False # 是否加载
|
||||||
|
|
||||||
class MODInfos(Options):
|
"""mod 配置"""
|
||||||
...
|
config: Options = Options() # mod 配置存储
|
||||||
|
|
||||||
|
|
||||||
MOD_info = MODInfo(
|
|
||||||
name="Difficult_Rocket",
|
|
||||||
version="0.0.1",
|
|
||||||
writer="shenjackyuanjie",
|
|
||||||
write_version=DR_runtime.DR_version,
|
|
||||||
write_loader_version=semver_loader_version
|
|
||||||
)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
一些重置用函数
|
一些重置用函数
|
||||||
"""
|
"""
|
||||||
|
70
docs/src/howto/game/readme.md
Normal file
70
docs/src/howto/game/readme.md
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# Difficult Rocket 游戏功能设计文档
|
||||||
|
|
||||||
|
> by shenjackyuanjie and BlueFunny_
|
||||||
|
|
||||||
|
`Difficult Rocket` 游戏本体功能由 `DR mod` 实现
|
||||||
|
|
||||||
|
## DR mod
|
||||||
|
|
||||||
|
- `DR mod` 包含以下几个部分
|
||||||
|
- `DR_mod`: Python 实现的主体
|
||||||
|
- `DR_rs`: DR_mod 的 Rust 扩展
|
||||||
|
|
||||||
|
- 命名空间
|
||||||
|
- 命名空间遵循本体原则 全拼
|
||||||
|
- `Difficult_Rocket_mod`
|
||||||
|
- `Difficult_Rocket_rs`
|
||||||
|
|
||||||
|
## DR_rs
|
||||||
|
|
||||||
|
> DR_rs 扩展为 DR mod 的 Rust 扩展
|
||||||
|
|
||||||
|
- 内容
|
||||||
|
- `simluation`
|
||||||
|
- 物理引擎交互
|
||||||
|
- `sr1_data`
|
||||||
|
- SR1 数据读取 格式转化
|
||||||
|
- `types`
|
||||||
|
- 主要的 Rust 数据格式定义
|
||||||
|
|
||||||
|
### `DR_rs` Rust 插件加载逻辑
|
||||||
|
|
||||||
|
- 加载模式
|
||||||
|
- 冷加载
|
||||||
|
- 游戏启动前扫描 Rust 扩展目录, 并加载所有的可识别后缀名扩展, 然后启动游戏
|
||||||
|
- 热加载
|
||||||
|
- 游戏进行中进行 `热加载` / `热卸载` / `热重载` 等操作
|
||||||
|
- **不推荐使用此方式, 因为这可能导致某些插件未正常加载导致异常**
|
||||||
|
- 使用此方式必须提供**明确的**初始化加载阶段, 否则将拒绝加载
|
||||||
|
- PS: 这个初始化加载阶段指扩展应在何时加载, 如启动时, 这个具体是看扩展都要修改哪些内容的
|
||||||
|
- 加载方法
|
||||||
|
- 利用 [本文](https://docs.rs/libloading/latest/libloading/) 中的方法加载 dll 扩展模组
|
||||||
|
- 模组应明确提供以下信息 (加 `*` 为可选内容)
|
||||||
|
- 模组名称
|
||||||
|
- 模组唯一可识别 ID
|
||||||
|
- 模组版本
|
||||||
|
- 模组作者
|
||||||
|
- 模组作者链接
|
||||||
|
- *模组描述 (限制字数在 x 以内)
|
||||||
|
- x 暂未确定
|
||||||
|
- 模组兼容游戏版本 (carte 版本表达式)
|
||||||
|
- 模组使用的 DR SDK 版本
|
||||||
|
- 此处应由软件自动生成
|
||||||
|
- 模组构建时的 DR SDK 版本
|
||||||
|
- 此处应由软件自动生成
|
||||||
|
- 模组使用的 DR SDK API 版本
|
||||||
|
- 模组使用的 DR SDK 内部协议版本
|
||||||
|
- *模组可选依赖 (包括版本)
|
||||||
|
- 模组必选依赖
|
||||||
|
|
||||||
|
- DR SDK版本 和 DR API 版本都需要写,都需要最高和最低,
|
||||||
|
- 然后······ 版本号是四位的格式
|
||||||
|
|
||||||
|
- 调用手段
|
||||||
|
- UI 调用
|
||||||
|
- 模组添加
|
||||||
|
- 软件内调用
|
||||||
|
- 加载时调用
|
||||||
|
- 我先睡了,老爹催了
|
||||||
|
|
||||||
|
|
@ -13,3 +13,13 @@
|
|||||||
- DR 内容兼容版本
|
- DR 内容兼容版本
|
||||||
- 需要的MOD版本号
|
- 需要的MOD版本号
|
||||||
-
|
-
|
||||||
|
|
||||||
|
草,你隔这呢,我还在隔壁readme呢,先来写readme
|
||||||
|
|
||||||
|
### DR_rs 扩展加载
|
||||||
|
|
||||||
|
- 发现 Mod 方式
|
||||||
|
- 在用户打开界面时进行扫描
|
||||||
|
- 用户手动添加 (UI请求)
|
||||||
|
- 加载方式
|
||||||
|
- 游戏启动前进行加载 (根据后缀名, 只有特定后缀名采用, 否则无视(方便实现备用))
|
@ -5,3 +5,21 @@
|
|||||||
* All rights reserved
|
* All rights reserved
|
||||||
* -------------------------------
|
* -------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO libloading
|
||||||
|
|
||||||
|
/// https://docs.rs/libloading/latest/libloading/
|
||||||
|
/// 插件加载
|
||||||
|
///
|
||||||
|
|
||||||
|
pub mod plugin_trait {
|
||||||
|
pub struct ModInfo {
|
||||||
|
pub name: String,
|
||||||
|
pub version: String
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait ModInfoTrait {
|
||||||
|
fn info() -> ModInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
5
mods/builtin/__init__.py
Normal file
5
mods/builtin/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -------------------------------
|
||||||
|
# Difficult Rocket
|
||||||
|
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
||||||
|
# All rights reserved
|
||||||
|
# -------------------------------
|
Loading…
Reference in New Issue
Block a user