Update build and API versions

This commit is contained in:
shenjack 2023-12-16 22:24:44 +08:00
parent 3fffd3b301
commit c9968bb284
Signed by: shenjack
GPG Key ID: 7B1134A979775551
5 changed files with 22 additions and 141 deletions

View File

@ -1,114 +0,0 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
paths:
- "docs/**"
- ".github/workflows/page.yml"
- "**README**"
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
# Single deploy job since we're just deploying
deploy:
if: ${{!startsWith(github.event.ref, 'refs/tags/') && contains(github.event.head_commit.message, '[page skip]') == false }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: 安装 mdbook
uses: extractions/setup-mdbook@v1
- name: Install mdBook
shell: pwsh
run: |
# 设置变量
$urls = @(
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-i18n',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-theme',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-cmdrun',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-pagetoc',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-footnote',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-external-links',
'https://github.com/plantuml/plantuml/releases/download/v1.2023.4/plantuml-1.2023.4.jar'
)
# 下载文件
foreach ($url in $urls) {
Invoke-WebRequest -Uri $url -OutFile "$($url.Split('/')[-1])"
}
# 将目录路径添加到 $PATH 中
$PWD >> $env:GITHUB_PATH
ls $PWD
# - name: Setup mdbook-theme latest
# run: |
# curl -s https://api.github.com/repos/zjp-CN/mdbook-theme/releases/latest \
# | grep browser_download_url \
# | grep mdbook-theme_linux \
# | cut -d '"' -f 4 \
# | wget -qi -
# tar -xvzf mdbook-theme_linux.tar.gz
# echo $PWD >> $GITHUB_PATH
- name: 安装 python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: 安装 dsm api
shell: pwsh
run: |
pip install synology-api>=0.5.1
- name: build mdbook
shell: pwsh
run: |
# cp docs/theme .
cd docs
mdbook build
cd ..
# Copy-Item docs/book/README-en.html docs/book/html/README-en.html
Copy-Item index.html docs/book/index.html
Get-ChildItem -Recurse -Path .\docs\book* | ?{$_.PsIsContainer -eq $false} | Get-FileHash -Algorithm MD5 >> .\docs\md5.txt
- name: 上传到 github pages
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: './docs/book'
- name: 部署到 github pages
id: deployment
uses: actions/deploy-pages@v1
- name: 上传到 DSM
env:
DSM_TOKEN: ${{ secrets.DSM_TOKEN }}
shell: pwsh
run: |
python .github/workflows/dsm.py -X utf8

View File

@ -9,8 +9,8 @@ from pathlib import Path
from Difficult_Rocket.api.types import Options, Version
sdk_version = Version("0.9.0.0") # SDK 版本
build_version = Version("2.2.0.0") # 编译文件版本(与游戏本体无关)
api_version = Version("0.1.2.0") # API 版本
build_version = Version("3.0.0.0") # 编译文件版本(与游戏本体无关)
api_version = Version("0.1.2.1") # API 版本
__version__ = sdk_version
__all__ = [

View File

@ -61,7 +61,7 @@ class ClientOption(Options):
caption: str = "Difficult Rocket v{DR_version}"
def load_file(self) -> None:
file: dict = tools.load_file("./config/main.toml")
file = DR_runtime.main_config
self.fps = int(file["runtime"]["fps"])
self.width = int(file["window"]["width"])
self.height = int(file["window"]["height"])
@ -126,7 +126,6 @@ class Client:
return f"<Client {self.process_name} {self.process_pid}>"
@new_thread("pyglet load fonts")
def pyglet_load_fonts_folder(folder) -> None:
"""
递归加载字体文件夹
@ -210,7 +209,7 @@ def _call_screen_after(func: Callable) -> Callable:
traceback.print_exc()
return result
warped.__signature__ = inspect.signature(func)
warped.__signature__ = inspect.signature(func) # type: ignore
return warped
@ -237,7 +236,7 @@ def _call_screen_before(func: Callable) -> Callable:
result = func(self, *args, **kwargs)
return result
warped.__signature__ = inspect.signature(func)
warped.__signature__ = inspect.signature(func) # type: ignore
return warped
@ -260,10 +259,9 @@ class ClientWindow(Window):
self.run_input = False
self.command_list: List[str] = []
# config
self.main_config = tools.load_file("./config/main.toml")
self.game_config = tools.load_file("./config/game.config")
# FPS
self.FPS = Decimal(int(self.main_config["runtime"]["fps"]))
self.FPS = Decimal(int(DR_runtime.main_config["runtime"]["fps"]))
self.SPF = Decimal("1") / self.FPS
self.fps_log = FpsLogger(stable_fps=int(self.FPS))
# batch
@ -305,7 +303,7 @@ class ClientWindow(Window):
self.game.dispatch_mod_event("on_client_start", game=self.game, client=self)
def load_fonts(self) -> None:
fonts_folder_path = self.main_config["runtime"]["fonts_folder"]
fonts_folder_path = DR_runtime.main_config["runtime"]["fonts_folder"]
# 加载字体路径
# 淦,还写了个递归来处理
pyglet_load_fonts_folder(fonts_folder_path)
@ -314,10 +312,7 @@ class ClientWindow(Window):
self.set_icon(pyglet.image.load("assets/textures/icon.png"))
try:
pyglet.clock.schedule_interval(self.draw_call, float(self.SPF))
# pyglet.clock.schedule(self.draw_call)
pyglet.app.run(None)
# TODO: wait for pyglet 2.1
# pyglet.app.run(float(self.SPF))
except KeyboardInterrupt:
self.logger.warn(
"==========client stop. KeyboardInterrupt info==========", tag="starter"
@ -333,7 +328,7 @@ class ClientWindow(Window):
@new_thread("window save_info")
def save_info(self):
self.logger.info(tr().client.config.save.start())
config_file: dict = tools.load_file("./config/main.toml")
config_file = DR_runtime.main_config
config_file["window"]["width"] = self.width
config_file["window"]["height"] = self.height
config_file["runtime"]["language"] = DR_runtime.language
@ -366,15 +361,12 @@ class ClientWindow(Window):
self.on_draw(dt)
self.flip()
@_call_screen_after
def on_draw(self, dt: float): # TODO: wait for pyglet 2.1
# def on_draw(self):
def on_draw(self, dt: float):
while (command := self.game.console.get_command()) is not None:
self.on_command(line.CommandText(command))
self.clear()
self.draw_update(dt) # TODO: wait for pyglet 2.1
# self.draw_update(float(self.SPF))
self.draw_update(dt)
self.draw_batch()
@_call_screen_after
@ -432,8 +424,8 @@ class ClientWindow(Window):
# self.command.push_line(self.fps_log.min_fps, block_line=True)
elif command.find("default"):
self.set_size(
int(self.main_config["window_default"]["width"]),
int(self.main_config["window_default"]["height"]),
int(DR_runtime.main_config["window_default"]["width"]),
int(DR_runtime.main_config["window_default"]["height"]),
)
elif command.find("lang"):
try:

View File

@ -17,16 +17,18 @@ from Difficult_Rocket.api.types import Options, Version
__all__ = ["DR_runtime"]
class _DR_runtime(Options):
class _DRRuntime(Options):
"""
DR 的运行时配置 / 状态
"""
name = "DR Runtime"
running: bool = False
language: str = "zh-CN"
mod_path: str = "./mods"
DR_Mod_List: List[Tuple[str, Version]] = [] # DR Mod 列表 (name, version)
main_config: dict = {} # main.toml
# run status
start_time_ns: Optional[int] = None
@ -41,6 +43,7 @@ class _DR_runtime(Options):
config_file = rtoml.load(f)
self.language = config_file["runtime"]["language"]
self.mod_path = config_file["game"]["mods"]["path"]
self.main_config = config_file
return True
return False
@ -77,4 +80,4 @@ class _DR_runtime(Options):
return mods
DR_runtime = _DR_runtime()
DR_runtime = _DRRuntime()

View File

@ -13,11 +13,11 @@
![demo](docs/src/demo.png)
<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.8-blue.svg)](https://pyglet.org)
[![Generic badge](https://img.shields.io/badge/Python-_3.8_|_3.9_|_3.10_|_3.11_-blue.svg)](https://Python.org)
[![996.icu](https://img.shields.io/badge/996.icu-996.icu-red.svg)](https://996.icu)
[![semver](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
[![python-3.8.10](https://img.shields.io/badge/编写于_Python_版本-3.8.10-blue.svg)](https://Python.org)
[![pyglet-2.x](https://img.shields.io/badge/编写于_Pyglet_版本-2.x-blue.svg)](https://pyglet.org)
[![support python 3.8~12](https://img.shields.io/badge/Python-_3.8_~_3.12_-blue.svg)](https://Python.org)
## 版本