feat(v0.1.1): 周期表五大分区 / 分区与单格改色 / 全屏视线跟随 / 窗口图标 / 跨平台打包
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
target: win
|
||||
command: npx electron-builder --win zip --x64 --publish never
|
||||
- os: ubuntu-latest
|
||||
target: linux
|
||||
command: npx electron-builder --linux AppImage deb --x64 --publish never
|
||||
- os: macos-latest
|
||||
target: mac
|
||||
command: npx electron-builder --mac dmg zip --x64 --arm64 --publish never
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build renderer + main
|
||||
run: npm run build
|
||||
|
||||
- name: Package
|
||||
run: ${{ matrix.command }}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: SodiumPet-${{ matrix.target }}
|
||||
path: |
|
||||
release/*.zip
|
||||
release/*.AppImage
|
||||
release/*.deb
|
||||
release/*.dmg
|
||||
if-no-files-found: warn
|
||||
|
||||
publish:
|
||||
needs: build
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Attach to release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: artifacts/**/*
|
||||
fail_on_unmatched_files: false
|
||||
generate_release_notes: true
|
||||
@@ -25,9 +25,9 @@
|
||||
> ⚠️ **不要点仓库右上角的 "Code → Download ZIP"**:那是**源代码**,里面没有 exe(`out/`、`release/` 都不入库)。要能直接运行的版本,请从 **Releases** 下载。
|
||||
|
||||
- **GitHub(推荐)**:<https://github.com/Tian-XiaRi/SodiumPet/releases/latest>
|
||||
- 下载 `SodiumPet-0.1.0-win64.zip`(约 171MB)→ 解压 → 双击里面的 `SodiumPet.exe`
|
||||
- 下载 `SodiumPet-0.1.1-win64.zip` → 解压 → 双击里面的 `SodiumPet.exe`
|
||||
- **Gitee 国内镜像**:<https://gitee.com/TianXiaRi/sodium-pet/releases>
|
||||
- 下载 `SodiumPet-0.1.0-win64.7z.001` 和 `.002` **两个分卷**(单个附件限 100MB)→ 放在同一个文件夹 → 用 [7-Zip](https://www.7-zip.org/) 右键 `.001` → 解压 → 双击 `SodiumPet.exe`
|
||||
- 下载 `SodiumPet-0.1.1-win64.7z.001` 和 `.002` **两个分卷**(单个附件限 100MB)→ 放在同一个文件夹 → 用 [7-Zip](https://www.7-zip.org/) 右键 `.001` → 解压 → 双击 `SodiumPet.exe`
|
||||
|
||||
运行环境:Windows 10/11 x64。首次启动若弹出 SmartScreen「Windows 已保护你的电脑」,点「更多信息 → 仍要运行」(未做代码签名,正常现象)。
|
||||
|
||||
@@ -113,3 +113,25 @@ assets/stickers 表情包(可用于底栏图标/应用图标)
|
||||
|
||||
MIT(第三方资源除外,详见 NOTICE)
|
||||
|
||||
|
||||
## 跨平台构建
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
npm run dist:win # Windows:release/SodiumPet-0.1.1-win.zip
|
||||
npm run dist:linux # Linux:AppImage + deb(需在 Linux 上执行)
|
||||
npm run dist:mac # macOS:dmg + zip(需在 macOS 上执行)
|
||||
```
|
||||
|
||||
打 tag(如 `v0.1.1`)推送到 GitHub 会触发 `.github/workflows/release.yml`,自动构建三平台产物并附到 Release。
|
||||
|
||||
> Linux 桌面(尤其 Wayland 透明窗口、KWin 全局光标)建议优先使用社区移植版:
|
||||
> <https://git.hinomori-minori.com/deepseek/SodiumPet>
|
||||
|
||||
## 版本目录约定
|
||||
|
||||
- 源码/开发版:`E:\SodiumPet\WorkPlace\v<版本号>\`
|
||||
- 已发布归档:`E:\SodiumPet\WorkPlace\v<版本号>\`(不再改动)
|
||||
- 新版本新建 `v0.1.2`、`v0.2.0` 这样的文件夹,遵循语义化版本
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
@@ -1,5 +1,36 @@
|
||||
# 变更记录
|
||||
|
||||
## v0.1.1(周期表分区 / 全屏视线 / 跨平台 / 窗口图标)
|
||||
|
||||
**周期表分区订正**
|
||||
- 采用教科书五大分区:s / p / d / **ds** / f(此前 s/p/d/f 把 ds 区(Cu、Ag、Au、Zn、Cd、Hg 等)算进了 d 区,颜色也不对)
|
||||
- 标准配色照教材插图:s 红、p 绿、d 黄、ds 青、f 粉;等级预览与编辑器共用同一套逻辑
|
||||
- 图例同步为 5 项,自定义分区也会出现在图例里
|
||||
|
||||
**编辑器:分区 / 单格改色**
|
||||
- 新增「按分区改色」:改一个格子,同分区所有格子一起变
|
||||
- 新增「单格改色」:只改一个格子,优先级最高
|
||||
- 新增「新建分区」:自定义分区名与颜色,单格面板里可把任意元素归入该分区
|
||||
- 「清除本格颜色 / 清除全部单格」;切换预设会清空单格与分区覆盖
|
||||
|
||||
**全屏视线跟随**
|
||||
- 主进程 33ms 轮询屏幕光标,跨窗口 / 跨显示器都生效(此前 50ms 且混用窗口内坐标)
|
||||
- 渲染层去掉 pointermove 局部覆盖,统一由全局轮询驱动
|
||||
- 偏转映射改为「方向永远跟随,距离影响幅度」,光标在屏幕边缘也不会锁死
|
||||
|
||||
**跨平台**
|
||||
- 数据目录平台自适应:Windows 保持 `E:\SodiumPet` 优先,Linux/macOS 用系统数据目录
|
||||
- 点击穿透 `forward` 选项仅在 Windows/macOS 使用(Linux 不传)
|
||||
- electron-builder 增加 Linux(AppImage/deb)与 macOS(dmg/zip)目标;新增 `.github/workflows/release.yml` 三平台自动构建
|
||||
- 新增 `assets/icon.png`(512×512,用于 Linux/macOS 图标)
|
||||
|
||||
**界面**
|
||||
- 所有窗口(面板 / 详情 / 编辑器 / 资料库 / 音乐 / 歌词 / 对话条)的图标改为表情包,任务栏不再是一排默认 Electron 图标
|
||||
|
||||
**其他**
|
||||
- 版本工作目录迁到 `E:\SodiumPet\WorkPlace\v0.1.0`(归档)与 `v0.1.1`(当前开发版)
|
||||
- 移除含本机窗口信息的截图,并在 `.gitignore` 忽略 `docs/shot-*.png`
|
||||
|
||||
## M42(修复:商店 / 互动 / 统计索引丢失)
|
||||
|
||||
- 根因:启动时应用 MOD 的代码把 ITEMS / JOBS 当作基线数组,随后又 length = 0 清空同一引用,导致物品与活动被自己清空
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# SodiumPet v0.1.1
|
||||
|
||||
> 小钠 · 化学元素拟人 Live2D 桌宠
|
||||
> GitHub:<https://github.com/Tian-XiaRi/SodiumPet> · Gitee 镜像:<https://gitee.com/TianXiaRi/sodium-pet>
|
||||
> Linux 社区移植:<https://git.hinomori-minori.com/deepseek/SodiumPet>
|
||||
|
||||
## 这个版本改了什么
|
||||
|
||||
**周期表分区订正(重点)**
|
||||
- 按教科书五大分区重新划分:**s / p / d / ds / f**
|
||||
- 此前把 ds 区(Cu、Ag、Au、Zn、Cd、Hg、Rg、Cn)误算进 d 区,颜色也不对
|
||||
- 标准配色照教材:s 红、p 绿、d 黄、ds 青、f 粉;详细面板「等级预览」与编辑器完全一致
|
||||
|
||||
**编辑器:分区改色 / 单格改色**
|
||||
- 「按分区改色」:改一个格子,整个区一起变
|
||||
- 「单格改色」:只改这一个元素,优先级最高
|
||||
- 「新建分区」:自定义分区名称与颜色,可把任意元素归入该区
|
||||
- 切换预设会清空单格与分区覆盖,避免残留
|
||||
|
||||
**全屏视线跟随**
|
||||
- 主进程 33ms 轮询屏幕光标:光标在桌面任何位置、任何显示器上,小钠都会看过去
|
||||
- 方向永远跟随,距离只影响偏转幅度,屏幕边缘不再锁死
|
||||
|
||||
**窗口图标**
|
||||
- 面板 / 详情 / 编辑器 / 资料库 / 音乐 / 歌词 / 对话条分别使用表情包图标,任务栏不再是一排默认图标
|
||||
|
||||
**跨平台**
|
||||
- 新增 Linux(AppImage / deb)与 macOS(dmg / zip)打包配置与 GitHub Actions 三平台构建
|
||||
- 数据目录、点击穿透、图标路径按平台自适应
|
||||
|
||||
## 下载
|
||||
|
||||
### Windows(本页附件)
|
||||
|
||||
- **SodiumPet-0.1.1-win64.zip** —— 解压后双击 `SodiumPet.exe`
|
||||
- 国内镜像(Gitee 发行版,两个分卷都要下):<https://gitee.com/TianXiaRi/sodium-pet/releases>
|
||||
|
||||
> ⚠️ 不要用仓库首页 "Code → Download ZIP",那是源码,没有 exe。
|
||||
|
||||
### Linux / macOS
|
||||
|
||||
本仓库已提供打包配置与 CI,产物由 GitHub Actions 在三平台构建(`Release` 工作流)。
|
||||
Linux 桌面适配(Wayland 透明窗口、KWin 光标桥接等)建议优先使用社区移植版:
|
||||
<https://git.hinomori-minori.com/deepseek/SodiumPet>
|
||||
|
||||
## 首次运行
|
||||
|
||||
- SmartScreen 提示 → 「更多信息 → 仍要运行」(未签名,正常)
|
||||
- 数据目录:exe 同级的 `data/`(Windows 默认优先用 `E:\SodiumPet`),Linux/macOS 用系统数据目录
|
||||
- 系统要求:Windows 10/11 x64;Linux 需 X11 或 XWayland;macOS 10.15+
|
||||
|
||||
## 已知问题
|
||||
|
||||
- 未做代码签名,杀软/SmartScreen 可能提示
|
||||
- 全屏独占游戏会遮挡桌宠
|
||||
- Linux 下 Wayland 原生会话对透明置顶窗口支持有限,建议 X11 / XWayland
|
||||
- 托盘图标在少数精简系统上可能不显示
|
||||
|
||||
## 许可
|
||||
|
||||
MIT。角色立绘与表情包版权归原作者,二次分发请保留署名。
|
||||
+57
-19
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "xiaona-pet",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"private": true,
|
||||
"description": "小钠 · 化学元素拟人桌宠(Electron)",
|
||||
"description": "小钠 · 化学元素拟人 Live2D 桌宠(Windows / Linux / macOS)",
|
||||
"main": "out/main/index.js",
|
||||
"scripts": {
|
||||
"build:main": "tsc -p tsconfig.main.json",
|
||||
@@ -10,8 +10,10 @@
|
||||
"build": "npm run build:main && npm run build:renderer",
|
||||
"start": "electron .",
|
||||
"dev": "node scripts/dev.mjs",
|
||||
"dist": "electron-builder --win portable --x64",
|
||||
"pack": "electron-builder --win dir --x64"
|
||||
"pack": "electron-builder --win dir --x64",
|
||||
"dist:win": "electron-builder --win zip --x64",
|
||||
"dist:linux": "electron-builder --linux AppImage deb --x64",
|
||||
"dist:mac": "electron-builder --mac dmg zip --x64 --arm64"
|
||||
},
|
||||
"dependencies": {
|
||||
"live2dcubismcore": "^1.0.2",
|
||||
@@ -46,21 +48,6 @@
|
||||
"package.json"
|
||||
],
|
||||
"asar": true,
|
||||
"win": {
|
||||
"target": [
|
||||
{
|
||||
"target": "portable",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"icon": "assets/stickers/1.0.png",
|
||||
"signAndEditExecutable": false
|
||||
},
|
||||
"portable": {
|
||||
"artifactName": "SodiumPet--portable.exe"
|
||||
},
|
||||
"extraResources": [
|
||||
{
|
||||
"from": "assets/skins",
|
||||
@@ -74,6 +61,57 @@
|
||||
"from": "assets/stickers",
|
||||
"to": "stickers"
|
||||
}
|
||||
],
|
||||
"win": {
|
||||
"target": [
|
||||
{
|
||||
"target": "zip",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"icon": "assets/app.ico",
|
||||
"signAndEditExecutable": false
|
||||
},
|
||||
"linux": {
|
||||
"target": [
|
||||
{
|
||||
"target": "AppImage",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "deb",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"icon": "assets/icon.png",
|
||||
"category": "Utility",
|
||||
"maintainer": "Tian_XiaRi"
|
||||
},
|
||||
"mac": {
|
||||
"target": [
|
||||
{
|
||||
"target": "dmg",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "zip",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"icon": "assets/icon.png",
|
||||
"category": "public.app-category.entertainment"
|
||||
}
|
||||
}
|
||||
}
|
||||
+68
-18
@@ -35,11 +35,13 @@ import { chatEffect, suggestions } from '../shared/dialogue'
|
||||
// 默认把「软件主体」放到 E:\SodiumPet,只有 Windows 临时/GPU 缓存留在 C 盘。
|
||||
// 沙箱里写不进去时,逐级回退,保证开发时也能跑。
|
||||
function resolveHome(): string {
|
||||
const isWin = process.platform === 'win32'
|
||||
const candidates = [
|
||||
process.env.SODIUM_PET_HOME,
|
||||
'E:\\SodiumPet',
|
||||
path.dirname(app.getPath('exe')),
|
||||
// Windows 上沿用之前的固定目录;其他平台用系统标准数据目录
|
||||
isWin ? 'E:\\SodiumPet' : '',
|
||||
path.join(app.getPath('appData'), 'SodiumPet'),
|
||||
isWin ? path.dirname(app.getPath('exe')) : '',
|
||||
path.join(app.getAppPath(), '.devdata')
|
||||
].filter(Boolean) as string[]
|
||||
|
||||
@@ -317,6 +319,16 @@ function buildTrayIcon(): NativeImage {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 主窗口
|
||||
function stickerIcon(name: string, size = 64): NativeImage | undefined {
|
||||
try {
|
||||
const p = path.join(bundledDir('stickers'), name)
|
||||
if (fs.existsSync(p)) return nativeImage.createFromPath(p).resize({ width: size, height: size })
|
||||
} catch {
|
||||
/* 忽略 */
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
function appIcon(): NativeImage | undefined {
|
||||
try {
|
||||
const p = path.join(bundledDir('stickers'), '1.0.png')
|
||||
@@ -332,7 +344,7 @@ function createWindow(): void {
|
||||
const width = 190
|
||||
const height = 450
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
mainWindow = new BrowserWindow({ icon: stickerIcon('1.0.png'),
|
||||
width,
|
||||
height,
|
||||
x: Math.round(workArea.x + workArea.width - width - 24),
|
||||
@@ -379,6 +391,18 @@ function createWindow(): void {
|
||||
mainWindow.setAlwaysOnTop(true, 'screen-saver')
|
||||
}, 15000)
|
||||
|
||||
if (process.env.PET_CAPTURE_PET) {
|
||||
setTimeout(() => {
|
||||
void mainWindow?.webContents.capturePage().then((img) => {
|
||||
try {
|
||||
fs.writeFileSync(process.env.PET_CAPTURE_PET as string, img.toPNG())
|
||||
} catch {
|
||||
/* 忽略 */
|
||||
}
|
||||
})
|
||||
}, 7000)
|
||||
}
|
||||
|
||||
// 调试:把窗口内容截一张(不受窗口是否被遮挡影响)
|
||||
if (process.env.PET_CAPTURE_ONCE) {
|
||||
setTimeout(() => {
|
||||
@@ -493,8 +517,12 @@ function createWindow(): void {
|
||||
setTimeout(() => {
|
||||
void (async () => {
|
||||
if (!editorWindow) return
|
||||
const tabLabels = await editorWindow.webContents.executeJavaScript(
|
||||
"JSON.stringify([...document.querySelectorAll('.detail-tabs .set-tab')].map(b => b.textContent.trim()))"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'editor-tabs.txt'), String(tabLabels))
|
||||
await editorWindow.webContents.executeJavaScript(
|
||||
"[...document.querySelectorAll('.detail-tabs .set-tab')].find(b => b.textContent === '界面')?.click()"
|
||||
"(() => { const bs = [...document.querySelectorAll('.detail-tabs .set-tab')]; const t = bs.find(b => b.textContent.trim() === '等级') || bs[2]; t && t.click(); return !!t })()"
|
||||
)
|
||||
await new Promise((r) => setTimeout(r, 400))
|
||||
const txt = await editorWindow.webContents.executeJavaScript(
|
||||
@@ -505,6 +533,12 @@ function createWindow(): void {
|
||||
"document.querySelectorAll('.sticker-cell').length"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'stickers.txt'), String(stickerCount))
|
||||
const catCount = await editorWindow.webContents.executeJavaScript(
|
||||
"JSON.stringify({ cells: document.querySelectorAll('.ped-cell').length, zones: document.querySelectorAll('.color-row').length, colors: [0,4,25,28,56,117].map(i => getComputedStyle(document.querySelectorAll('.ped-cell')[i]).backgroundColor) })"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'ped-stats.txt'), String(catCount))
|
||||
const shot = await editorWindow.webContents.capturePage()
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'editor.png'), shot.toPNG())
|
||||
})()
|
||||
}, 9000)
|
||||
setTimeout(() => {
|
||||
@@ -521,6 +555,15 @@ function createWindow(): void {
|
||||
await detailWindow.webContents.executeJavaScript(
|
||||
"[...document.querySelectorAll('.level-mode .set-tab')].find(b => b.textContent.includes('化学'))?.click()"
|
||||
)
|
||||
await new Promise((r) => setTimeout(r, 300))
|
||||
{
|
||||
const shot = await detailWindow.webContents.capturePage()
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'detail.png'), shot.toPNG())
|
||||
const leg = await detailWindow.webContents.executeJavaScript(
|
||||
"JSON.stringify([...document.querySelectorAll('.legend-item')].map(x => x.innerText.trim()))"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'legend.txt'), String(leg))
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 400))
|
||||
|
||||
const online = await detailWindow.webContents.executeJavaScript(
|
||||
@@ -677,7 +720,10 @@ function applyConfig(cfg: PetConfig): void {
|
||||
})
|
||||
console.log('[config] bounds', mainWindow.getBounds(), 'dpr', screen.getPrimaryDisplay().scaleFactor)
|
||||
mainWindow.setAlwaysOnTop(cfg.topmost, 'screen-saver')
|
||||
mainWindow.setIgnoreMouseEvents(cfg.clickThrough, { forward: true })
|
||||
mainWindow.setIgnoreMouseEvents(
|
||||
cfg.clickThrough,
|
||||
process.platform === 'linux' ? undefined : { forward: true }
|
||||
)
|
||||
for (const w of BrowserWindow.getAllWindows()) {
|
||||
if (!w.isDestroyed()) w.webContents.send('pet:config:update', cfg)
|
||||
}
|
||||
@@ -693,7 +739,7 @@ let currentBubble: { text: string; duration: number; at: number } | null = null
|
||||
|
||||
function createBubbleWindow(): void {
|
||||
if (bubbleWindow && !bubbleWindow.isDestroyed()) return
|
||||
bubbleWindow = new BrowserWindow({
|
||||
bubbleWindow = new BrowserWindow({ icon: stickerIcon('2.0.png'),
|
||||
width: 440,
|
||||
height: 96,
|
||||
show: false,
|
||||
@@ -1042,7 +1088,7 @@ let lyricWindow: BrowserWindow | null = null
|
||||
|
||||
function createMenuWindow(): void {
|
||||
if (menuWindow && !menuWindow.isDestroyed()) return
|
||||
menuWindow = new BrowserWindow({
|
||||
menuWindow = new BrowserWindow({ icon: stickerIcon('3.0.png'),
|
||||
width: 400,
|
||||
height: 380,
|
||||
show: false,
|
||||
@@ -1191,7 +1237,7 @@ function createMusicWindow(): void {
|
||||
musicWindow.focus()
|
||||
return
|
||||
}
|
||||
musicWindow = new BrowserWindow({
|
||||
musicWindow = new BrowserWindow({ icon: stickerIcon('20.0.png'),
|
||||
width: 880,
|
||||
height: 600,
|
||||
minWidth: 700,
|
||||
@@ -1219,7 +1265,7 @@ function createMusicWindow(): void {
|
||||
|
||||
function createLyricWindow(): void {
|
||||
if (lyricWindow && !lyricWindow.isDestroyed()) return
|
||||
lyricWindow = new BrowserWindow({
|
||||
lyricWindow = new BrowserWindow({ icon: stickerIcon('9.0.png'),
|
||||
width: 560,
|
||||
height: 110,
|
||||
show: true,
|
||||
@@ -1252,7 +1298,7 @@ function createEditorWindow(): void {
|
||||
editorWindow.focus()
|
||||
return
|
||||
}
|
||||
editorWindow = new BrowserWindow({
|
||||
editorWindow = new BrowserWindow({ icon: stickerIcon('23.1.png'),
|
||||
width: 780,
|
||||
height: 560,
|
||||
minWidth: 640,
|
||||
@@ -1283,7 +1329,7 @@ function createDetailWindow(): void {
|
||||
detailWindow.focus()
|
||||
return
|
||||
}
|
||||
detailWindow = new BrowserWindow({
|
||||
detailWindow = new BrowserWindow({ icon: stickerIcon('4.0.png'),
|
||||
width: 720,
|
||||
height: 520,
|
||||
minWidth: 520,
|
||||
@@ -1314,7 +1360,7 @@ function createStorageWindow(): void {
|
||||
storageWindow.focus()
|
||||
return
|
||||
}
|
||||
storageWindow = new BrowserWindow({
|
||||
storageWindow = new BrowserWindow({ icon: stickerIcon('16.0.png'),
|
||||
width: 780,
|
||||
height: 660,
|
||||
minWidth: 560,
|
||||
@@ -1508,7 +1554,7 @@ let chatExpanded = false
|
||||
|
||||
function createChatBar(): void {
|
||||
if (chatBar && !chatBar.isDestroyed()) return
|
||||
chatBar = new BrowserWindow({
|
||||
chatBar = new BrowserWindow({ icon: stickerIcon('8.0.png'),
|
||||
width: 420,
|
||||
height: 54,
|
||||
show: false,
|
||||
@@ -1565,7 +1611,7 @@ function createPanel(tab?: string, arg?: string): void {
|
||||
return
|
||||
}
|
||||
|
||||
panelWindow = new BrowserWindow({
|
||||
panelWindow = new BrowserWindow({ icon: stickerIcon('5.0.png'),
|
||||
width: 640,
|
||||
height: 430,
|
||||
show: false,
|
||||
@@ -2334,17 +2380,21 @@ if (!gotLock) {
|
||||
}
|
||||
}, 3000)
|
||||
|
||||
// 全屏视线跟随:主进程按 50ms 轮询光标位置,发给宠物窗口
|
||||
// 全屏视线跟随:主进程按 33ms 轮询光标(屏幕坐标,跨窗口 / 跨显示器都有效)
|
||||
setInterval(() => {
|
||||
const cfgNow = store.getConfig()
|
||||
if (!cfgNow.eyeFollow || !mainWindow || !mainWindow.isVisible()) return
|
||||
const forceLook = !!process.env.PET_FORCE_EYE_FOLLOW
|
||||
if (!(cfgNow.eyeFollow || forceLook) || !mainWindow || mainWindow.isDestroyed()) return
|
||||
if (mainWindow.isMinimized()) return
|
||||
const p = screen.getCursorScreenPoint()
|
||||
const b = mainWindow.getBounds()
|
||||
mainWindow.webContents.send('pet:look', {
|
||||
x: p.x - b.x + cfgNow.cropLeft,
|
||||
y: p.y - b.y + cfgNow.cropTop
|
||||
y: p.y - b.y + cfgNow.cropTop,
|
||||
// 光标是否在窗口内(渲染层可用于复位/弱化)
|
||||
inside: p.x >= b.x && p.x <= b.x + b.width && p.y >= b.y && p.y <= b.y + b.height
|
||||
})
|
||||
}, 50)
|
||||
}, 33)
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
|
||||
@@ -64,7 +64,7 @@ export interface PetBridge {
|
||||
getWs: () => Promise<Array<{ name: string; size: number }>>
|
||||
getProfiles: () => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
|
||||
delProfile: (id: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
|
||||
onLook: (cb: (p: { x: number; y: number }) => void) => () => void
|
||||
onLook: (cb: (p: { x: number; y: number; inside?: boolean }) => void) => () => void
|
||||
onSkins: (cb: (list: Array<{ id: string; name: string; active: boolean }>) => void) => () => void
|
||||
createProfile: (name: string, skinId: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
|
||||
renameProfile: (id: string, name: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
|
||||
|
||||
@@ -165,9 +165,6 @@ export default function App(): React.ReactElement {
|
||||
d.moved = true
|
||||
document.getElementById('root')?.classList.add('dragging')
|
||||
}
|
||||
if (cfg.eyeFollow) {
|
||||
adapterRef.current?.lookAt?.(e.clientX + cfg.cropLeft, e.clientY + cfg.cropTop)
|
||||
}
|
||||
}
|
||||
|
||||
function endDrag(): void {
|
||||
|
||||
@@ -67,7 +67,7 @@ export interface PetApi {
|
||||
renameSkin: (id: string, name: string) => Promise<Array<{ id: string; name: string; active: boolean }>>
|
||||
delProfile: (id: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
|
||||
switchProfile: (id: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
|
||||
onLook: (cb: (p: { x: number; y: number }) => void) => () => void
|
||||
onLook: (cb: (p: { x: number; y: number; inside?: boolean }) => void) => () => void
|
||||
onSkins: (cb: (list: Array<{ id: string; name: string; active: boolean }>) => void) => () => void
|
||||
getSkins: () => Promise<Array<{ id: string; name: string; active: boolean }>>
|
||||
importSkin: () => Promise<Array<{ id: string; name: string; active: boolean }>>
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
levelLabelWrapped,
|
||||
MAX_LEVEL,
|
||||
periodicCellColor,
|
||||
periodicZoneList,
|
||||
PERIODIC_PRESETS,
|
||||
type PeriodicPreset,
|
||||
type PeriodicStyle
|
||||
@@ -437,17 +438,10 @@ export default function Detail(): React.ReactElement {
|
||||
</div>
|
||||
|
||||
<div className="periodic-legend">
|
||||
{periodic.scheme === 'category'
|
||||
? (Object.keys(ELEMENT_CATEGORY_LABEL) as Array<keyof typeof ELEMENT_CATEGORY_LABEL>).map((k) => (
|
||||
<span key={k} className="legend-item">
|
||||
<i style={{ background: periodic.colors?.[k] ?? CATEGORY_COLORS[k] }} />
|
||||
{ELEMENT_CATEGORY_LABEL[k]}
|
||||
</span>
|
||||
))
|
||||
: (['s', 'p', 'd', 'f'] as const).map((b) => (
|
||||
<span key={b} className="legend-item">
|
||||
<i style={{ background: periodic.colors?.[b] ?? ({s:'#ffd54a',p:'#6fc8ff',d:'#8ef0b0',f:'#cf9bff'} as Record<string,string>)[b] }} />
|
||||
{b} 区
|
||||
{periodicZoneList(periodic).map((z) => (
|
||||
<span key={z.id} className="legend-item">
|
||||
<i style={{ background: z.color }} />
|
||||
{z.label}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,11 @@ import {
|
||||
elementName,
|
||||
MAX_LEVEL,
|
||||
periodicCellColor,
|
||||
periodicKeyOf,
|
||||
periodicZoneList,
|
||||
defaultZoneOf,
|
||||
ZONE_LABEL,
|
||||
ZONE_COLORS,
|
||||
PERIODIC_PRESETS,
|
||||
type PeriodicStyle
|
||||
} from '../../../shared/elements'
|
||||
@@ -52,6 +57,8 @@ export default function Editor(): React.ReactElement {
|
||||
})
|
||||
const [presetName, setPresetName] = useState('')
|
||||
const [customDirty, setCustomDirty] = useState(false)
|
||||
const [pedMode, setPedMode] = useState<'zone' | 'cell'>('zone')
|
||||
const [pedKey, setPedKey] = useState('s')
|
||||
const [tabIcons, setTabIcons] = useState<Record<string, string>>({})
|
||||
const [uiTab, setUiTab] = useState('feed')
|
||||
|
||||
@@ -217,6 +224,31 @@ export default function Editor(): React.ReactElement {
|
||||
setDraft(null)
|
||||
}
|
||||
|
||||
function newZone(): void {
|
||||
const used = new Set(Object.keys(periodic.colors ?? {}))
|
||||
for (const k of Object.keys(periodic.zoneNames ?? {})) used.add(k)
|
||||
let n = 1
|
||||
while (used.has('z' + n)) n++
|
||||
const id = 'z' + n
|
||||
const next: PeriodicStyle = {
|
||||
...periodic,
|
||||
colors: { ...(periodic.colors ?? {}), [id]: '#9aa7bd' },
|
||||
zoneNames: { ...(periodic.zoneNames ?? {}), [id]: '自定义 ' + n }
|
||||
}
|
||||
setPeriodic(next)
|
||||
setPedMode('zone')
|
||||
setPedKey(id)
|
||||
setCustomDirty(true)
|
||||
}
|
||||
|
||||
const pedZoneRows = periodicZoneList(periodic)
|
||||
const pedSelZ = pedMode === 'cell' ? Number(pedKey) : 0
|
||||
const pedZoneNow =
|
||||
periodic.zoneNames?.[pedKey] ??
|
||||
(periodic.scheme === 'category'
|
||||
? ELEMENT_CATEGORY_LABEL[pedKey as keyof typeof ELEMENT_CATEGORY_LABEL] ?? pedKey
|
||||
: ZONE_LABEL[pedKey as keyof typeof ZONE_LABEL] ?? pedKey)
|
||||
|
||||
return (
|
||||
<div className="editor">
|
||||
<header className="editor-head">
|
||||
@@ -513,7 +545,14 @@ export default function Editor(): React.ReactElement {
|
||||
if (v === '__custom') return
|
||||
const preset = PERIODIC_PRESETS.find((x) => x.id === v)
|
||||
if (preset) {
|
||||
setPeriodic({ ...periodic, scheme: preset.scheme, colors: { ...preset.colors } })
|
||||
setPeriodic({
|
||||
scheme: preset.scheme,
|
||||
colors: { ...preset.colors },
|
||||
cellColors: {},
|
||||
zoneOverrides: {},
|
||||
zoneNames: {},
|
||||
bg: periodic.bg
|
||||
})
|
||||
setCustomDirty(false)
|
||||
}
|
||||
}}
|
||||
@@ -526,87 +565,157 @@ export default function Editor(): React.ReactElement {
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<p className="tips">点下面的格子或图例就能改颜色;改完会变成「自定义」,另存命名后才会保留。</p>
|
||||
<p className="tips">按分区改色会同时改掉整个区;单格改色只影响一个元素。改完会变成「自定义」,另存命名后才会保留。</p>
|
||||
|
||||
<div className="ped-mode">
|
||||
<button
|
||||
className={'chip' + (pedMode === 'zone' ? ' on' : '')}
|
||||
onClick={() => setPedMode('zone')}
|
||||
>
|
||||
按分区改色
|
||||
</button>
|
||||
<button
|
||||
className={'chip' + (pedMode === 'cell' ? ' on' : '')}
|
||||
onClick={() => setPedMode('cell')}
|
||||
>
|
||||
单格改色
|
||||
</button>
|
||||
<span className="tips">按分区:整区同色;单格:只改一个格子。</span>
|
||||
</div>
|
||||
|
||||
<div className="periodic-editor" style={{ background: periodic.bg ?? '#0e1420' }}>
|
||||
{ELEMENTS.map((el) => {
|
||||
const [row, col] = ELEMENT_GRID_POS[el.z - 1] ?? [1, 1]
|
||||
const category =
|
||||
periodic.scheme === 'category' ? undefined : el.block
|
||||
const key = periodic.scheme === 'category' ? undefined : el.block
|
||||
const key = periodicKeyOf(el, periodic)
|
||||
const colorFor = periodicCellColor(el, periodic)
|
||||
const colorKey =
|
||||
periodic.scheme === 'category'
|
||||
? Object.entries(CATEGORY_COLORS).find(([, v]) => v === colorFor)?.[0] ?? ''
|
||||
: String(key ?? '')
|
||||
const active = pedMode === 'zone' ? key === pedKey : String(el.z) === pedKey
|
||||
return (
|
||||
<label
|
||||
key={el.z}
|
||||
className={'ped-cell' + (lvKind === 'chemistry' && lvKey === el.z ? ' on' : '')}
|
||||
className={'ped-cell' + (active ? ' on' : '')}
|
||||
style={{ gridRow: row, gridColumn: col, background: colorFor }}
|
||||
title={el.z + ' ' + elementName(el.z) + ' ' + el.symbol}
|
||||
title={el.z + ' ' + elementName(el.z) + ' · ' + key}
|
||||
onClick={() => {
|
||||
setPedKey(pedMode === 'zone' ? key : String(el.z))
|
||||
setLvKind('chemistry')
|
||||
setLvKey(el.z)
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="color"
|
||||
className="ped-color"
|
||||
value={colorFor}
|
||||
onClick={(ev) => ev.stopPropagation()}
|
||||
onChange={(ev) => {
|
||||
const nextColors = { ...(periodic.colors ?? {}) }
|
||||
if (periodic.scheme === 'category' && colorKey) {
|
||||
nextColors[colorKey] = ev.target.value
|
||||
} else {
|
||||
nextColors[String(key ?? '')] = ev.target.value
|
||||
}
|
||||
setPeriodic({ ...periodic, colors: nextColors })
|
||||
setCustomDirty(true)
|
||||
if (pedMode === 'zone') {
|
||||
setPeriodic({
|
||||
...periodic,
|
||||
colors: { ...(periodic.colors ?? {}), [key]: ev.target.value }
|
||||
})
|
||||
} else {
|
||||
setPeriodic({
|
||||
...periodic,
|
||||
cellColors: { ...(periodic.cellColors ?? {}), [el.z]: ev.target.value }
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<span className="ped-z">{el.z}</span>
|
||||
<span className="ped-sym">{el.symbol}</span>
|
||||
<span
|
||||
className="ped-pick"
|
||||
onClick={(ev) => {
|
||||
ev.preventDefault()
|
||||
setLvKind('chemistry')
|
||||
setLvKey(el.z)
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="ped-current">
|
||||
<span>
|
||||
当前{pedMode === 'zone' ? '分区' : '格子'}:
|
||||
<b>{pedMode === 'zone' ? pedZoneNow : pedKey + ' ' + elementName(Number(pedKey))}</b>
|
||||
</span>
|
||||
{pedMode === 'cell' && (
|
||||
<>
|
||||
<span className="muted">所属分区</span>
|
||||
<select
|
||||
className="text-input ped-small"
|
||||
value={periodic.zoneOverrides?.[pedSelZ] ?? ''}
|
||||
onChange={(ev) => {
|
||||
const v = ev.target.value
|
||||
const nextOverrides = { ...(periodic.zoneOverrides ?? {}) }
|
||||
if (!v) delete nextOverrides[pedSelZ]
|
||||
else nextOverrides[pedSelZ] = v
|
||||
setPeriodic({ ...periodic, zoneOverrides: nextOverrides })
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value="">
|
||||
默认({ZONE_LABEL[defaultZoneOf(pedSelZ)] ?? defaultZoneOf(pedSelZ)})
|
||||
</option>
|
||||
{pedZoneRows.map((z) => (
|
||||
<option key={z.id} value={z.id}>
|
||||
{z.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button
|
||||
className="mini"
|
||||
onClick={() => {
|
||||
const nextCells = { ...(periodic.cellColors ?? {}) }
|
||||
delete nextCells[pedSelZ]
|
||||
setPeriodic({ ...periodic, cellColors: nextCells })
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
>
|
||||
清除本格颜色
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<button className="mini" onClick={newZone}>
|
||||
新建分区
|
||||
</button>
|
||||
<button
|
||||
className="mini"
|
||||
onClick={() => {
|
||||
setPeriodic({ ...periodic, cellColors: {} })
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
>
|
||||
清除全部单格
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="periodic-colors">
|
||||
{(periodic.scheme === 'category'
|
||||
? (Object.keys(ELEMENT_CATEGORY_LABEL) as Array<keyof typeof ELEMENT_CATEGORY_LABEL>).map(
|
||||
(k) => ({
|
||||
key: k as string,
|
||||
label: ELEMENT_CATEGORY_LABEL[k],
|
||||
fallback: CATEGORY_COLORS[k]
|
||||
})
|
||||
)
|
||||
: (['s', 'p', 'd', 'f'] as const).map((b) => ({
|
||||
key: b as string,
|
||||
label: b + ' 区',
|
||||
fallback: ({ s: '#ffd54a', p: '#6fc8ff', d: '#8ef0b0', f: '#cf9bff' } as Record<
|
||||
string,
|
||||
string
|
||||
>)[b]
|
||||
}))
|
||||
).map((row) => (
|
||||
<label key={row.key} className="color-row">
|
||||
{pedZoneRows.map((row) => (
|
||||
<label key={row.id} className="color-row">
|
||||
<input
|
||||
type="color"
|
||||
value={periodic.colors?.[row.key] ?? row.fallback}
|
||||
value={row.color}
|
||||
onChange={(e) => {
|
||||
setPeriodic({
|
||||
...periodic,
|
||||
colors: { ...(periodic.colors ?? {}), [row.key]: e.target.value }
|
||||
colors: { ...(periodic.colors ?? {}), [row.id]: e.target.value }
|
||||
})
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
/>
|
||||
<span>{row.label}</span>
|
||||
<span>
|
||||
{row.label}({row.count})
|
||||
</span>
|
||||
{!['s', 'p', 'd', 'ds', 'f'].includes(row.id) &&
|
||||
!Object.keys(ELEMENT_CATEGORY_LABEL).includes(row.id) && (
|
||||
<input
|
||||
className="text-input ped-name"
|
||||
value={periodic.zoneNames?.[row.id] ?? ''}
|
||||
placeholder="分区名"
|
||||
onChange={(e) => {
|
||||
setPeriodic({
|
||||
...periodic,
|
||||
zoneNames: { ...(periodic.zoneNames ?? {}), [row.id]: e.target.value }
|
||||
})
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
html,
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
margin: 0;
|
||||
@@ -358,3 +358,54 @@ body,
|
||||
[data-theme='day'] .sticker-cell {
|
||||
border-color: #cfd8e6;
|
||||
}
|
||||
|
||||
/* 周期表分区 / 单格改色工具条 */
|
||||
.ped-mode {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin: 8px 0 6px;
|
||||
}
|
||||
.ped-mode .chip {
|
||||
padding: 4px 12px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(120, 150, 200, 0.35);
|
||||
background: rgba(30, 42, 62, 0.7);
|
||||
color: #cfd9e8;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
.ped-mode .chip.on {
|
||||
background: #3d7ff0;
|
||||
border-color: #3d7ff0;
|
||||
color: #fff;
|
||||
}
|
||||
.ped-current {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin: 8px 0;
|
||||
font-size: 12px;
|
||||
color: #cfd9e8;
|
||||
}
|
||||
.ped-current b {
|
||||
color: #ffe08a;
|
||||
margin: 0 4px;
|
||||
}
|
||||
.ped-small {
|
||||
width: 120px !important;
|
||||
padding: 3px 6px !important;
|
||||
font-size: 12px;
|
||||
}
|
||||
.ped-name {
|
||||
width: 96px !important;
|
||||
padding: 3px 6px !important;
|
||||
font-size: 12px;
|
||||
}
|
||||
.color-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
@@ -265,19 +265,22 @@ export class Live2DAdapter implements AvatarAdapter {
|
||||
}
|
||||
return
|
||||
}
|
||||
// 以脸的位置为中心,把目标限制在一个锥形范围内,鼠标很远时也不会锁死
|
||||
// 以脸的位置为中心:方向永远跟随光标,距离只影响偏转幅度
|
||||
// 这样光标跑到屏幕另一头也能转,不会在窗口边缘就"锁死"
|
||||
const s = this.model.scale.x || 1
|
||||
const cx = this.model.x + (this.baseSize.w / 2) * s
|
||||
const cy = this.model.y + (this.baseSize.h * 0.45) * s
|
||||
let dx = x - cx
|
||||
let dy = y - cy
|
||||
const dx = x - cx
|
||||
const dy = y - cy
|
||||
const dist = Math.hypot(dx, dy)
|
||||
const R = 260
|
||||
if (dist > R) {
|
||||
dx = (dx / dist) * R
|
||||
dy = (dy / dist) * R
|
||||
if (dist < 0.5) {
|
||||
this.model?.focus(cx, cy)
|
||||
return
|
||||
}
|
||||
this.model?.focus(cx + dx, cy + dy)
|
||||
// 620 约等于"一个窗口外两三屏"的距离;超出后只保留最大偏转
|
||||
const eased = Math.min(1, Math.pow(dist / 620, 0.6))
|
||||
const R = 80 + 340 * eased
|
||||
this.model?.focus(cx + (dx / dist) * R, cy + (dy / dist) * R)
|
||||
} catch {
|
||||
/* 某些模型没有视线参数,忽略 */
|
||||
}
|
||||
|
||||
+123
-13
@@ -1,4 +1,4 @@
|
||||
/** 元素周期表:等级 1~118 对应元素的基态电子排布 */
|
||||
/** 元素周期表:等级 1~118 对应元素的基态电子排布 */
|
||||
|
||||
const SUBSHELLS: Array<[number, string, number]> = [
|
||||
[1, 's', 2],
|
||||
@@ -268,33 +268,143 @@ export function categoryOf(z: number): ElementCategory {
|
||||
return 'transition'
|
||||
}
|
||||
|
||||
/** 周期表配色方案:block = 按能级块,category = 按元素分类 */
|
||||
// ---------------------------------------------------------------- 周期表分区
|
||||
// 按教科书五大分区:s / p / d / ds / f(与化学教材一致)
|
||||
export type ElementZone = 's' | 'p' | 'd' | 'ds' | 'f'
|
||||
|
||||
export const ZONE_LABEL: Record<ElementZone, string> = {
|
||||
s: 's 区',
|
||||
p: 'p 区',
|
||||
d: 'd 区',
|
||||
ds: 'ds 区',
|
||||
f: 'f 区'
|
||||
}
|
||||
|
||||
/** 五大分区的标准配色(参照教材插图) */
|
||||
export const ZONE_COLORS: Record<ElementZone, string> = {
|
||||
s: '#e8352b',
|
||||
p: '#8bd24b',
|
||||
d: '#f6d64b',
|
||||
ds: '#8fe0ea',
|
||||
f: '#f3b9e7'
|
||||
}
|
||||
|
||||
const ZONE_SOFT: Record<ElementZone, string> = {
|
||||
s: '#f6b3ae',
|
||||
p: '#cfe8ab',
|
||||
d: '#fbeab0',
|
||||
ds: '#c9f1f5',
|
||||
f: '#f9d9f2'
|
||||
}
|
||||
|
||||
const DS_ELEMENTS = [29, 30, 47, 48, 79, 80, 111, 112]
|
||||
const S_ELEMENTS = [1, 2, 3, 4, 11, 12, 19, 20, 37, 38, 55, 56, 87, 88]
|
||||
|
||||
export function defaultZoneOf(z: number): ElementZone {
|
||||
if ((z >= 57 && z <= 71) || (z >= 89 && z <= 103)) return 'f'
|
||||
if (S_ELEMENTS.includes(z)) return 's'
|
||||
if (DS_ELEMENTS.includes(z)) return 'ds'
|
||||
// 过渡金属(去掉 ds 的 11、12 族)
|
||||
if ((z >= 21 && z <= 28) || (z >= 39 && z <= 46) || (z >= 72 && z <= 78) || (z >= 104 && z <= 110)) {
|
||||
return 'd'
|
||||
}
|
||||
return 'p'
|
||||
}
|
||||
|
||||
export const ZONE_MEMBERS: Record<ElementZone, number[]> = {
|
||||
s: S_ELEMENTS,
|
||||
ds: DS_ELEMENTS,
|
||||
d: ELEMENTS.filter((e) => defaultZoneOf(e.z) === 'd').map((e) => e.z),
|
||||
f: ELEMENTS.filter((e) => defaultZoneOf(e.z) === 'f').map((e) => e.z),
|
||||
p: ELEMENTS.filter((e) => defaultZoneOf(e.z) === 'p').map((e) => e.z)
|
||||
}
|
||||
|
||||
/** 周期表配色方案:block = 按 s/p/d/ds/f 分区,category = 按元素分类 */
|
||||
export type PeriodicScheme = 'block' | 'category'
|
||||
|
||||
export interface PeriodicStyle {
|
||||
scheme: PeriodicScheme
|
||||
/** 自定义颜色覆盖:block 用 s/p/d/f,category 用分类 key */
|
||||
/** 分区 / 分类颜色:block 用 s/p/d/ds/f(也可自定义分区 id),category 用分类 key */
|
||||
colors?: Record<string, string>
|
||||
/** 单格覆盖:元素序号 -> 颜色(最高优先级) */
|
||||
cellColors?: Record<number, string>
|
||||
/** 自定义分区归属:元素序号 -> 分区 id */
|
||||
zoneOverrides?: Record<number, string>
|
||||
/** 自定义分区名:分区 id -> 名称 */
|
||||
zoneNames?: Record<string, string>
|
||||
/** 底图背景色 */
|
||||
bg?: string
|
||||
}
|
||||
|
||||
export const DEFAULT_PERIODIC_STYLE: PeriodicStyle = {
|
||||
scheme: 'block',
|
||||
colors: {},
|
||||
colors: { ...ZONE_COLORS },
|
||||
cellColors: {},
|
||||
zoneOverrides: {},
|
||||
zoneNames: {},
|
||||
bg: '#0e1420'
|
||||
}
|
||||
|
||||
export function periodicCellColor(
|
||||
el: { z: number; block: string },
|
||||
/** 取元素所属分区 / 分类 key(自定义归属优先) */
|
||||
export function periodicKeyOf(
|
||||
el: { z: number },
|
||||
style: PeriodicStyle
|
||||
): string {
|
||||
const custom = style.colors ?? {}
|
||||
const over = style.zoneOverrides?.[el.z]
|
||||
if (over) return over
|
||||
if (style.scheme === 'category') return categoryOf(el.z)
|
||||
return defaultZoneOf(el.z)
|
||||
}
|
||||
|
||||
export function periodicCellColor(
|
||||
el: { z: number },
|
||||
style: PeriodicStyle
|
||||
): string {
|
||||
const single = style.cellColors?.[el.z]
|
||||
if (single) return single
|
||||
const key = periodicKeyOf(el, style)
|
||||
const colors = style.colors ?? {}
|
||||
if (style.scheme === 'category') {
|
||||
const cat = categoryOf(el.z)
|
||||
return custom[cat] ?? CATEGORY_COLORS[cat]
|
||||
return colors[key] ?? CATEGORY_COLORS[cat as ElementCategory] ?? '#8b98ad'
|
||||
}
|
||||
return custom[el.block] ?? BLOCK_COLOR[el.block] ?? '#8b98ad'
|
||||
return colors[key] ?? ZONE_COLORS[key as ElementZone] ?? '#8b98ad'
|
||||
}
|
||||
|
||||
/** 编辑器用:列出当前方案里的所有分区(含自定义分区) */
|
||||
export function periodicZoneList(
|
||||
style: PeriodicStyle
|
||||
): Array<{ id: string; label: string; color: string; count: number }> {
|
||||
const counts = new Map<string, number>()
|
||||
for (const el of ELEMENTS) {
|
||||
const k = periodicKeyOf(el, style)
|
||||
counts.set(k, (counts.get(k) ?? 0) + 1)
|
||||
}
|
||||
const ids = new Set<string>(Object.keys(style.colors ?? {}))
|
||||
for (const k of counts.keys()) ids.add(k)
|
||||
const order: string[] =
|
||||
style.scheme === 'category'
|
||||
? (Object.keys(ELEMENT_CATEGORY_LABEL) as string[])
|
||||
: ['s', 'p', 'd', 'ds', 'f']
|
||||
const sorted = [...ids].sort((a, b) => {
|
||||
const ia = order.indexOf(a)
|
||||
const ib = order.indexOf(b)
|
||||
return (ia < 0 ? 99 : ia) - (ib < 0 ? 99 : ib) || a.localeCompare(b)
|
||||
})
|
||||
return sorted.map((id) => ({
|
||||
id,
|
||||
label:
|
||||
style.zoneNames?.[id] ??
|
||||
(style.scheme === 'category'
|
||||
? ELEMENT_CATEGORY_LABEL[id as ElementCategory] ?? id
|
||||
: ZONE_LABEL[id as ElementZone] ?? id),
|
||||
color:
|
||||
style.colors?.[id] ??
|
||||
(style.scheme === 'category'
|
||||
? CATEGORY_COLORS[id as ElementCategory] ?? '#8b98ad'
|
||||
: ZONE_COLORS[id as ElementZone] ?? '#8b98ad'),
|
||||
count: counts.get(id) ?? 0
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -321,15 +431,15 @@ const SOFT_CATEGORY: Record<string, string> = {
|
||||
export const PERIODIC_PRESETS: PeriodicPreset[] = [
|
||||
{
|
||||
id: 'spdf',
|
||||
name: '能级块 · 标准',
|
||||
name: '五大分区 · 标准',
|
||||
scheme: 'block',
|
||||
colors: { s: '#ffd54a', p: '#6fc8ff', d: '#8ef0b0', f: '#cf9bff' }
|
||||
colors: { ...ZONE_COLORS }
|
||||
},
|
||||
{
|
||||
id: 'spdf-soft',
|
||||
name: '能级块 · 柔和',
|
||||
name: '五大分区 · 柔和',
|
||||
scheme: 'block',
|
||||
colors: { s: '#ffe9a8', p: '#bfe4ff', d: '#cdf3dd', f: '#e6cbff' }
|
||||
colors: { ...ZONE_SOFT }
|
||||
},
|
||||
{
|
||||
id: 'category',
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
const fs = require('fs')
|
||||
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/main/index.ts'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
|
||||
function rep(from, to, label) {
|
||||
if (!c.includes(from)) {
|
||||
console.log('MISS:', label)
|
||||
return
|
||||
}
|
||||
c = c.replace(from, to)
|
||||
console.log('ok:', label)
|
||||
}
|
||||
|
||||
// 编辑器:切到「等级」页 + 截图
|
||||
rep(
|
||||
` await editorWindow.webContents.executeJavaScript(
|
||||
"[...document.querySelectorAll('.detail-tabs .set-tab')].find(b => b.textContent === '界面')?.click()"
|
||||
)`,
|
||||
` await editorWindow.webContents.executeJavaScript(
|
||||
"[...document.querySelectorAll('.detail-tabs .set-tab')].find(b => b.textContent === '等级')?.click()"
|
||||
)`,
|
||||
'editor tab level'
|
||||
)
|
||||
rep(
|
||||
` const stickerCount = await editorWindow.webContents.executeJavaScript(
|
||||
"document.querySelectorAll('.sticker-cell').length"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'stickers.txt'), String(stickerCount))`,
|
||||
` const stickerCount = await editorWindow.webContents.executeJavaScript(
|
||||
"document.querySelectorAll('.sticker-cell').length"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'stickers.txt'), String(stickerCount))
|
||||
const catCount = await editorWindow.webContents.executeJavaScript(
|
||||
"JSON.stringify({ cells: document.querySelectorAll('.ped-cell').length, zones: document.querySelectorAll('.color-row').length, s: getComputedStyle(document.querySelector('.ped-cell')).backgroundColor })"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'ped-stats.txt'), String(catCount))
|
||||
const shot = await editorWindow.webContents.capturePage()
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'editor.png'), shot.toPNG())`,
|
||||
'editor capture'
|
||||
)
|
||||
|
||||
// 详情:等级预览截图(放在现有 dump 之后)
|
||||
rep(
|
||||
` await detailWindow.webContents.executeJavaScript(
|
||||
"[...document.querySelectorAll('.level-mode .set-tab')].find(b => b.textContent.includes('化学'))?.click()"
|
||||
)`,
|
||||
` await detailWindow.webContents.executeJavaScript(
|
||||
"[...document.querySelectorAll('.level-mode .set-tab')].find(b => b.textContent.includes('化学'))?.click()"
|
||||
)
|
||||
await new Promise((r) => setTimeout(r, 300))
|
||||
{
|
||||
const shot = await detailWindow.webContents.capturePage()
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'detail.png'), shot.toPNG())
|
||||
const leg = await detailWindow.webContents.executeJavaScript(
|
||||
"JSON.stringify([...document.querySelectorAll('.legend-item')].map(x => x.innerText.trim()))"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'legend.txt'), String(leg))
|
||||
}`,
|
||||
'detail capture'
|
||||
)
|
||||
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
@@ -0,0 +1,21 @@
|
||||
const fs = require('fs')
|
||||
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/main/index.ts'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
|
||||
const from = ` await editorWindow.webContents.executeJavaScript(
|
||||
"[...document.querySelectorAll('.detail-tabs .set-tab')].find(b => b.textContent === '等级')?.click()"
|
||||
)`
|
||||
const to = ` const tabLabels = await editorWindow.webContents.executeJavaScript(
|
||||
"JSON.stringify([...document.querySelectorAll('.detail-tabs .set-tab')].map(b => b.textContent.trim()))"
|
||||
)
|
||||
fs.writeFileSync(path.join(HOME, 'data', 'editor-tabs.txt'), String(tabLabels))
|
||||
await editorWindow.webContents.executeJavaScript(
|
||||
"(() => { const bs = [...document.querySelectorAll('.detail-tabs .set-tab')]; const t = bs.find(b => b.textContent.trim() === '等级') || bs[2]; t && t.click(); return !!t })()"
|
||||
)`
|
||||
if (!c.includes(from)) {
|
||||
console.log('MISS editor click')
|
||||
process.exit(1)
|
||||
}
|
||||
c = c.replace(from, to)
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
console.log('patched editor tab click')
|
||||
@@ -0,0 +1,36 @@
|
||||
const fs = require('fs')
|
||||
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/renderer/src/detail/Detail.tsx'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
|
||||
const startMark = ' <div className="periodic-legend">'
|
||||
const start = c.indexOf(startMark)
|
||||
if (start < 0) {
|
||||
console.log('legend not found')
|
||||
process.exit(1)
|
||||
}
|
||||
const end = c.indexOf(' </div>', start)
|
||||
if (end < 0) {
|
||||
console.log('legend end not found')
|
||||
process.exit(1)
|
||||
}
|
||||
const oldBlock = c.slice(start, end + ' </div>'.length)
|
||||
|
||||
const newBlock = [
|
||||
' <div className="periodic-legend">',
|
||||
' {periodicZoneList(periodic).map((z) => (',
|
||||
' <span key={z.id} className="legend-item">',
|
||||
' <i style={{ background: z.color }} />',
|
||||
' {z.label}',
|
||||
' </span>',
|
||||
' ))}',
|
||||
' </div>'
|
||||
].join('\n')
|
||||
|
||||
c = c.replace(oldBlock, newBlock)
|
||||
if (!c.includes('periodicZoneList(periodic)')) {
|
||||
console.log('replace failed')
|
||||
process.exit(1)
|
||||
}
|
||||
c = c.replace(' periodicCellColor,', ' periodicCellColor,\n periodicZoneList,')
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
console.log('detail legend patched')
|
||||
@@ -0,0 +1,235 @@
|
||||
const fs = require('fs')
|
||||
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/renderer/src/editor/Editor.tsx'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
|
||||
// 1) imports
|
||||
c = c.replace(
|
||||
" periodicCellColor,\n PERIODIC_PRESETS,",
|
||||
" periodicCellColor,\n periodicKeyOf,\n periodicZoneList,\n defaultZoneOf,\n ZONE_LABEL,\n ZONE_COLORS,\n PERIODIC_PRESETS,"
|
||||
)
|
||||
|
||||
// 2) state
|
||||
c = c.replace(
|
||||
" const [customDirty, setCustomDirty] = useState(false)",
|
||||
" const [customDirty, setCustomDirty] = useState(false)\n const [pedMode, setPedMode] = useState<'zone' | 'cell'>('zone')\n const [pedKey, setPedKey] = useState('s')"
|
||||
)
|
||||
|
||||
// 3) helpers —— 插在 return 之前
|
||||
const helperAnchor = " return (\n <div className=\"editor\""
|
||||
const helpers = ` function newZone(): void {
|
||||
const used = new Set(Object.keys(periodic.colors ?? {}))
|
||||
for (const k of Object.keys(periodic.zoneNames ?? {})) used.add(k)
|
||||
let n = 1
|
||||
while (used.has('z' + n)) n++
|
||||
const id = 'z' + n
|
||||
const next: PeriodicStyle = {
|
||||
...periodic,
|
||||
colors: { ...(periodic.colors ?? {}), [id]: '#9aa7bd' },
|
||||
zoneNames: { ...(periodic.zoneNames ?? {}), [id]: '自定义 ' + n }
|
||||
}
|
||||
setPeriodic(next)
|
||||
setPedMode('zone')
|
||||
setPedKey(id)
|
||||
setCustomDirty(true)
|
||||
}
|
||||
|
||||
const pedZoneRows = periodicZoneList(periodic)
|
||||
const pedSelZ = pedMode === 'cell' ? Number(pedKey) : 0
|
||||
const pedZoneNow =
|
||||
periodic.zoneNames?.[pedKey] ??
|
||||
(periodic.scheme === 'category'
|
||||
? ELEMENT_CATEGORY_LABEL[pedKey as keyof typeof ELEMENT_CATEGORY_LABEL] ?? pedKey
|
||||
: ZONE_LABEL[pedKey as keyof typeof ZONE_LABEL] ?? pedKey)
|
||||
|
||||
return (
|
||||
<div className="editor"`
|
||||
c = c.replace(helperAnchor, helpers)
|
||||
|
||||
// 4) 周期表编辑区整体替换
|
||||
const startMark = ' <div className="periodic-editor" style={{ background: periodic.bg ?? \'#0e1420\' }}>'
|
||||
const start = c.indexOf(startMark)
|
||||
if (start < 0) {
|
||||
console.log('periodic editor block not found')
|
||||
process.exit(1)
|
||||
}
|
||||
const endMark = ' <div className="field">\n <span>底图背景</span>'
|
||||
const end = c.indexOf(endMark, start)
|
||||
if (end < 0) {
|
||||
console.log('end marker not found')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const block = ` <div className="ped-mode">
|
||||
<button
|
||||
className={'chip' + (pedMode === 'zone' ? ' on' : '')}
|
||||
onClick={() => setPedMode('zone')}
|
||||
>
|
||||
按分区改色
|
||||
</button>
|
||||
<button
|
||||
className={'chip' + (pedMode === 'cell' ? ' on' : '')}
|
||||
onClick={() => setPedMode('cell')}
|
||||
>
|
||||
单格改色
|
||||
</button>
|
||||
<span className="tips">按分区:整区同色;单格:只改一个格子。</span>
|
||||
</div>
|
||||
|
||||
<div className="periodic-editor" style={{ background: periodic.bg ?? '#0e1420' }}>
|
||||
{ELEMENTS.map((el) => {
|
||||
const [row, col] = ELEMENT_GRID_POS[el.z - 1] ?? [1, 1]
|
||||
const key = periodicKeyOf(el, periodic)
|
||||
const colorFor = periodicCellColor(el, periodic)
|
||||
const active = pedMode === 'zone' ? key === pedKey : String(el.z) === pedKey
|
||||
return (
|
||||
<label
|
||||
key={el.z}
|
||||
className={'ped-cell' + (active ? ' on' : '')}
|
||||
style={{ gridRow: row, gridColumn: col, background: colorFor }}
|
||||
title={el.z + ' ' + elementName(el.z) + ' · ' + key}
|
||||
onClick={() => {
|
||||
setPedKey(pedMode === 'zone' ? key : String(el.z))
|
||||
setLvKind('chemistry')
|
||||
setLvKey(el.z)
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="color"
|
||||
className="ped-color"
|
||||
value={colorFor}
|
||||
onClick={(ev) => ev.stopPropagation()}
|
||||
onChange={(ev) => {
|
||||
setCustomDirty(true)
|
||||
if (pedMode === 'zone') {
|
||||
setPeriodic({
|
||||
...periodic,
|
||||
colors: { ...(periodic.colors ?? {}), [key]: ev.target.value }
|
||||
})
|
||||
} else {
|
||||
setPeriodic({
|
||||
...periodic,
|
||||
cellColors: { ...(periodic.cellColors ?? {}), [el.z]: ev.target.value }
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<span className="ped-z">{el.z}</span>
|
||||
<span className="ped-sym">{el.symbol}</span>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="ped-current">
|
||||
<span>
|
||||
当前{pedMode === 'zone' ? '分区' : '格子'}:
|
||||
<b>{pedMode === 'zone' ? pedZoneNow : pedKey + ' ' + elementName(Number(pedKey))}</b>
|
||||
</span>
|
||||
{pedMode === 'cell' && (
|
||||
<>
|
||||
<span className="muted">所属分区</span>
|
||||
<select
|
||||
className="text-input ped-small"
|
||||
value={periodic.zoneOverrides?.[pedSelZ] ?? ''}
|
||||
onChange={(ev) => {
|
||||
const v = ev.target.value
|
||||
const nextOverrides = { ...(periodic.zoneOverrides ?? {}) }
|
||||
if (!v) delete nextOverrides[pedSelZ]
|
||||
else nextOverrides[pedSelZ] = v
|
||||
setPeriodic({ ...periodic, zoneOverrides: nextOverrides })
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value="">
|
||||
默认({ZONE_LABEL[defaultZoneOf(pedSelZ)] ?? defaultZoneOf(pedSelZ)})
|
||||
</option>
|
||||
{pedZoneRows.map((z) => (
|
||||
<option key={z.id} value={z.id}>
|
||||
{z.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button
|
||||
className="mini"
|
||||
onClick={() => {
|
||||
const nextCells = { ...(periodic.cellColors ?? {}) }
|
||||
delete nextCells[pedSelZ]
|
||||
setPeriodic({ ...periodic, cellColors: nextCells })
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
>
|
||||
清除本格颜色
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<button className="mini" onClick={newZone}>
|
||||
新建分区
|
||||
</button>
|
||||
<button
|
||||
className="mini"
|
||||
onClick={() => {
|
||||
setPeriodic({ ...periodic, cellColors: {} })
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
>
|
||||
清除全部单格
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="periodic-colors">
|
||||
{pedZoneRows.map((row) => (
|
||||
<label key={row.id} className="color-row">
|
||||
<input
|
||||
type="color"
|
||||
value={row.color}
|
||||
onChange={(e) => {
|
||||
setPeriodic({
|
||||
...periodic,
|
||||
colors: { ...(periodic.colors ?? {}), [row.id]: e.target.value }
|
||||
})
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
/>
|
||||
<span>
|
||||
{row.label}({row.count})
|
||||
</span>
|
||||
{!['s', 'p', 'd', 'ds', 'f'].includes(row.id) &&
|
||||
!Object.keys(ELEMENT_CATEGORY_LABEL).includes(row.id) && (
|
||||
<input
|
||||
className="text-input ped-name"
|
||||
value={periodic.zoneNames?.[row.id] ?? ''}
|
||||
placeholder="分区名"
|
||||
onChange={(e) => {
|
||||
setPeriodic({
|
||||
...periodic,
|
||||
zoneNames: { ...(periodic.zoneNames ?? {}), [row.id]: e.target.value }
|
||||
})
|
||||
setCustomDirty(true)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
|
||||
`
|
||||
c = c.slice(0, start) + block + c.slice(end)
|
||||
|
||||
// 5) 预设应用时清掉单格/归属覆盖;匹配时也比对覆盖是否为空
|
||||
c = c.replace(
|
||||
" setPeriodic({ ...periodic, scheme: preset.scheme, colors: { ...preset.colors } })",
|
||||
" setPeriodic({\n scheme: preset.scheme,\n colors: { ...preset.colors },\n cellColors: {},\n zoneOverrides: {},\n zoneNames: {},\n bg: periodic.bg\n })"
|
||||
)
|
||||
c = c.replace(
|
||||
" ps.scheme === periodic.scheme &&\n JSON.stringify(ps.colors) === JSON.stringify(periodic.colors ?? {})",
|
||||
" ps.scheme === periodic.scheme &&\n JSON.stringify(ps.colors) === JSON.stringify(periodic.colors ?? {}) &&\n Object.keys(periodic.cellColors ?? {}).length === 0 &&\n Object.keys(periodic.zoneOverrides ?? {}).length === 0"
|
||||
)
|
||||
|
||||
// 6) 提示文案
|
||||
c = c.replace(
|
||||
'<p className="tips">点下面的格子或图例就能改颜色;改完会变成「自定义」,另存命名后才会保留。</p>',
|
||||
'<p className="tips">按分区改色会同时改掉整个区;单格改色只影响一个元素。改完会变成「自定义」,另存命名后才会保留。</p>'
|
||||
)
|
||||
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
console.log('editor patched')
|
||||
@@ -0,0 +1,15 @@
|
||||
const fs = require('fs')
|
||||
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/main/index.ts'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
const from = ` const cfgNow = store.getConfig()
|
||||
if (!cfgNow.eyeFollow || !mainWindow || mainWindow.isDestroyed()) return`
|
||||
const to = ` const cfgNow = store.getConfig()
|
||||
const forceLook = !!process.env.PET_FORCE_EYE_FOLLOW
|
||||
if (!(cfgNow.eyeFollow || forceLook) || !mainWindow || mainWindow.isDestroyed()) return`
|
||||
if (!c.includes(from)) {
|
||||
console.log('MISS force look')
|
||||
process.exit(1)
|
||||
}
|
||||
c = c.replace(from, to)
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
console.log('force look debug added')
|
||||
@@ -0,0 +1,73 @@
|
||||
const fs = require('fs')
|
||||
const base = 'E:/SodiumPet/WorkPlace/v0.1.1/src/'
|
||||
function rep(file, from, to, label) {
|
||||
const p = base + file
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
if (!c.includes(from)) {
|
||||
console.log('MISS:', label)
|
||||
return
|
||||
}
|
||||
c = c.replace(from, to)
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
console.log('ok:', label)
|
||||
}
|
||||
|
||||
// 1) 适配器:全屏方向映射(远距离保持方向,近距离更灵敏)
|
||||
rep(
|
||||
'renderer/src/pet/adapters/live2d.ts',
|
||||
` // 以脸的位置为中心,把目标限制在一个锥形范围内,鼠标很远时也不会锁死
|
||||
const s = this.model.scale.x || 1
|
||||
const cx = this.model.x + (this.baseSize.w / 2) * s
|
||||
const cy = this.model.y + (this.baseSize.h * 0.45) * s
|
||||
let dx = x - cx
|
||||
let dy = y - cy
|
||||
const dist = Math.hypot(dx, dy)
|
||||
const R = 260
|
||||
if (dist > R) {
|
||||
dx = (dx / dist) * R
|
||||
dy = (dy / dist) * R
|
||||
}
|
||||
this.model?.focus(cx + dx, cy + dy)`,
|
||||
` // 以脸的位置为中心:方向永远跟随光标,距离只影响偏转幅度
|
||||
// 这样光标跑到屏幕另一头也能转,不会在窗口边缘就"锁死"
|
||||
const s = this.model.scale.x || 1
|
||||
const cx = this.model.x + (this.baseSize.w / 2) * s
|
||||
const cy = this.model.y + (this.baseSize.h * 0.45) * s
|
||||
const dx = x - cx
|
||||
const dy = y - cy
|
||||
const dist = Math.hypot(dx, dy)
|
||||
if (dist < 0.5) {
|
||||
this.model?.focus(cx, cy)
|
||||
return
|
||||
}
|
||||
// 620 约等于"一个窗口外两三屏"的距离;超出后只保留最大偏转
|
||||
const eased = Math.min(1, Math.pow(dist / 620, 0.6))
|
||||
const R = 80 + 340 * eased
|
||||
this.model?.focus(cx + (dx / dist) * R, cy + (dy / dist) * R)`,
|
||||
'adapter lookAt range'
|
||||
)
|
||||
|
||||
// 2) 渲染层:去掉局部 pointermove 覆盖,统一交给主进程全局轮询
|
||||
rep(
|
||||
'renderer/src/App.tsx',
|
||||
` if (cfg.eyeFollow) {
|
||||
adapterRef.current?.lookAt?.(e.clientX + cfg.cropLeft, e.clientY + cfg.cropTop)
|
||||
}
|
||||
`,
|
||||
'',
|
||||
'remove local pointer eye-follow'
|
||||
)
|
||||
|
||||
// 3) preload / api 类型补 inside
|
||||
rep(
|
||||
'preload/index.ts',
|
||||
' onLook: (cb: (p: { x: number; y: number }) => void) => () => void',
|
||||
' onLook: (cb: (p: { x: number; y: number; inside?: boolean }) => void) => () => void',
|
||||
'preload onLook type'
|
||||
)
|
||||
rep(
|
||||
'renderer/src/api.ts',
|
||||
' onLook: (cb: (p: { x: number; y: number }) => void) => () => void',
|
||||
' onLook: (cb: (p: { x: number; y: number; inside?: boolean }) => void) => () => void',
|
||||
'api onLook type'
|
||||
)
|
||||
@@ -0,0 +1,93 @@
|
||||
const fs = require('fs')
|
||||
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/main/index.ts'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
|
||||
function rep(from, to, label) {
|
||||
if (!c.includes(from)) {
|
||||
console.log('MISS:', label)
|
||||
return
|
||||
}
|
||||
c = c.replace(from, to)
|
||||
console.log('ok:', label)
|
||||
}
|
||||
|
||||
// 1) 数据目录:平台自适应
|
||||
rep(
|
||||
` const candidates = [
|
||||
process.env.SODIUM_PET_HOME,
|
||||
'E:\\\\SodiumPet',
|
||||
path.dirname(app.getPath('exe')),
|
||||
path.join(app.getPath('appData'), 'SodiumPet'),
|
||||
path.join(app.getAppPath(), '.devdata')
|
||||
].filter(Boolean) as string[]`,
|
||||
` const isWin = process.platform === 'win32'
|
||||
const candidates = [
|
||||
process.env.SODIUM_PET_HOME,
|
||||
// Windows 上沿用之前的固定目录;其他平台用系统标准数据目录
|
||||
isWin ? 'E:\\\\SodiumPet' : '',
|
||||
path.join(app.getPath('appData'), 'SodiumPet'),
|
||||
isWin ? path.dirname(app.getPath('exe')) : '',
|
||||
path.join(app.getAppPath(), '.devdata')
|
||||
].filter(Boolean) as string[]`,
|
||||
'resolveHome platform'
|
||||
)
|
||||
|
||||
// 2) 点击穿透:forward 仅 Windows / macOS 支持
|
||||
rep(
|
||||
" mainWindow.setIgnoreMouseEvents(cfg.clickThrough, { forward: true })",
|
||||
" mainWindow.setIgnoreMouseEvents(\n cfg.clickThrough,\n process.platform === 'linux' ? undefined : { forward: true }\n )",
|
||||
'clickThrough forward'
|
||||
)
|
||||
|
||||
// 3) 全屏视线跟随:33ms,窗口不可见也照常计算(多屏 / 其他窗口上方同样生效)
|
||||
rep(
|
||||
` // 全屏视线跟随:主进程按 50ms 轮询光标位置,发给宠物窗口
|
||||
setInterval(() => {
|
||||
const cfgNow = store.getConfig()
|
||||
if (!cfgNow.eyeFollow || !mainWindow || !mainWindow.isVisible()) return
|
||||
const p = screen.getCursorScreenPoint()
|
||||
const b = mainWindow.getBounds()
|
||||
mainWindow.webContents.send('pet:look', {
|
||||
x: p.x - b.x + cfgNow.cropLeft,
|
||||
y: p.y - b.y + cfgNow.cropTop
|
||||
})
|
||||
}, 50)`,
|
||||
` // 全屏视线跟随:主进程按 33ms 轮询光标(屏幕坐标,跨窗口 / 跨显示器都有效)
|
||||
setInterval(() => {
|
||||
const cfgNow = store.getConfig()
|
||||
if (!cfgNow.eyeFollow || !mainWindow || mainWindow.isDestroyed()) return
|
||||
if (mainWindow.isMinimized()) return
|
||||
const p = screen.getCursorScreenPoint()
|
||||
const b = mainWindow.getBounds()
|
||||
mainWindow.webContents.send('pet:look', {
|
||||
x: p.x - b.x + cfgNow.cropLeft,
|
||||
y: p.y - b.y + cfgNow.cropTop,
|
||||
// 光标是否在窗口内(渲染层可用于复位/弱化)
|
||||
inside: p.x >= b.x && p.x <= b.x + b.width && p.y >= b.y && p.y <= b.y + b.height
|
||||
})
|
||||
}, 33)`,
|
||||
'global cursor polling'
|
||||
)
|
||||
|
||||
// 4) 窗口截图探针(调试用,设置 PET_CAPTURE_PET 才生效)
|
||||
rep(
|
||||
` // 调试:把窗口内容截一张(不受窗口是否被遮挡影响)
|
||||
if (process.env.PET_CAPTURE_ONCE) {`,
|
||||
` if (process.env.PET_CAPTURE_PET) {
|
||||
setTimeout(() => {
|
||||
void mainWindow?.webContents.capturePage().then((img) => {
|
||||
try {
|
||||
fs.writeFileSync(process.env.PET_CAPTURE_PET as string, img.toPNG())
|
||||
} catch {
|
||||
/* 忽略 */
|
||||
}
|
||||
})
|
||||
}, 7000)
|
||||
}
|
||||
|
||||
// 调试:把窗口内容截一张(不受窗口是否被遮挡影响)
|
||||
if (process.env.PET_CAPTURE_ONCE) {`,
|
||||
'pet capture probe'
|
||||
)
|
||||
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
@@ -0,0 +1,14 @@
|
||||
const fs = require('fs')
|
||||
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/main/index.ts'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
const from =
|
||||
"JSON.stringify({ cells: document.querySelectorAll('.ped-cell').length, zones: document.querySelectorAll('.color-row').length, s: getComputedStyle(document.querySelector('.ped-cell')).backgroundColor })"
|
||||
const to =
|
||||
"JSON.stringify({ cells: document.querySelectorAll('.ped-cell').length, zones: document.querySelectorAll('.color-row').length, colors: [0,4,25,28,56,117].map(i => getComputedStyle(document.querySelectorAll('.ped-cell')[i]).backgroundColor) })"
|
||||
if (!c.includes(from)) {
|
||||
console.log('MISS stats')
|
||||
process.exit(1)
|
||||
}
|
||||
c = c.replace(from, to)
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
console.log('stats patched')
|
||||
@@ -0,0 +1,45 @@
|
||||
const fs = require('fs')
|
||||
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/main/index.ts'
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
|
||||
// 1) helper:取表情包作为窗口图标
|
||||
const anchor = 'function appIcon(): NativeImage | undefined {'
|
||||
if (!c.includes(anchor)) {
|
||||
console.log('MISS appIcon')
|
||||
process.exit(1)
|
||||
}
|
||||
const helper = `function stickerIcon(name: string, size = 64): NativeImage | undefined {
|
||||
try {
|
||||
const p = path.join(bundledDir('stickers'), name)
|
||||
if (fs.existsSync(p)) return nativeImage.createFromPath(p).resize({ width: size, height: size })
|
||||
} catch {
|
||||
/* 忽略 */
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
function appIcon(): NativeImage | undefined {`
|
||||
c = c.replace(anchor, helper)
|
||||
|
||||
// 2) 按出现顺序给每个窗口分配表情包图标
|
||||
const mapping = [
|
||||
'1.0.png', // 主窗口(桌宠)
|
||||
'2.0.png', // 气泡
|
||||
'3.0.png', // 右键底栏
|
||||
'20.0.png', // 音乐
|
||||
'9.0.png', // 歌词浮窗
|
||||
'23.1.png', // 编辑器
|
||||
'4.0.png', // 详细面板
|
||||
'16.0.png', // 资料库
|
||||
'8.0.png', // 对话条
|
||||
'5.0.png' // 面板
|
||||
]
|
||||
let idx = 0
|
||||
c = c.replace(/= new BrowserWindow\(\{/g, (m) => {
|
||||
const file = mapping[idx] ?? '1.0.png'
|
||||
idx++
|
||||
return `${m} icon: stickerIcon('${file}'),`
|
||||
})
|
||||
console.log('windows iconified:', idx)
|
||||
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
@@ -0,0 +1,207 @@
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import imageio_ffmpeg
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
FFMPEG = imageio_ffmpeg.get_ffmpeg_exe()
|
||||
SRC = r"D:\软件\剪映\video\QQ20261201-165342-HD.mp4"
|
||||
OUT = r"C:\Users\ASUS\Documents\deepseek-harness\default-workspace\desktop-pet\video-plan"
|
||||
TMP = os.path.join(OUT, "tmp")
|
||||
os.makedirs(TMP, exist_ok=True)
|
||||
|
||||
W, H = 1920, 1200
|
||||
FPS = 60
|
||||
FONT = r"C:\Windows\Fonts\msyhbd.ttc"
|
||||
FONT_R = r"C:\Windows\Fonts\msyh.ttc"
|
||||
|
||||
# (in, out, speed) 秒 —— 按 剪辑方案.md / 裁剪清单.csv
|
||||
SEGMENTS = [
|
||||
(52, 66, 1.0),
|
||||
(70, 86, 1.0),
|
||||
(90, 110, 1.5),
|
||||
(112, 138, 1.5),
|
||||
(142, 170, 1.5),
|
||||
(172, 200, 1.5),
|
||||
(204, 250, 1.8),
|
||||
(252, 290, 1.5),
|
||||
(292, 330, 2.0),
|
||||
(332, 370, 2.0),
|
||||
(372, 400, 2.0),
|
||||
(580, 610, 2.0),
|
||||
(675, 700, 2.0),
|
||||
(720, 750, 2.0),
|
||||
(820, 860, 1.5),
|
||||
(862, 890, 1.0),
|
||||
(910, 940, 2.0),
|
||||
(965, 1000, 1.5),
|
||||
(1020, 1050, 1.5),
|
||||
(1065, 1080, 1.0),
|
||||
]
|
||||
|
||||
|
||||
def run(args: list) -> None:
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if p.returncode != 0:
|
||||
print("FAILED:", " ".join(args)[:400])
|
||||
print(p.stdout.decode("utf-8", "ignore")[-3000:])
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def make_card(name: str, title: str, sub: str, foot: str = "") -> str:
|
||||
img = Image.new("RGB", (W, H), (12, 16, 24))
|
||||
d = ImageDraw.Draw(img)
|
||||
# 渐变
|
||||
for y in range(H):
|
||||
k = y / H
|
||||
d.line([(0, y), (W, y)], fill=(int(10 + 18 * k), int(14 + 20 * k), int(22 + 30 * k)))
|
||||
f1 = ImageFont.truetype(FONT, 108)
|
||||
f2 = ImageFont.truetype(FONT_R, 46)
|
||||
f3 = ImageFont.truetype(FONT_R, 34)
|
||||
tw = d.textlength(title, font=f1)
|
||||
d.text(((W - tw) / 2, 380), title, font=f1, fill=(255, 240, 200))
|
||||
if sub:
|
||||
sw = d.textlength(sub, font=f2)
|
||||
d.text(((W - sw) / 2, 540), sub, font=f2, fill=(190, 205, 225))
|
||||
if foot:
|
||||
fw = d.textlength(foot, font=f3)
|
||||
d.text(((W - fw) / 2, 640), foot, font=f3, fill=(120, 170, 220))
|
||||
path = os.path.join(TMP, name)
|
||||
img.save(path)
|
||||
return path
|
||||
|
||||
|
||||
def main() -> None:
|
||||
title = make_card("card_title.png", "小钠 · 化学元素拟人桌宠", "Live2D · 经济任务 · 音乐 · AI 对话 · MOD")
|
||||
end = make_card(
|
||||
"card_end.png",
|
||||
"开源 · 免费 · Windows",
|
||||
"一个会饿、会累、会被氧化的桌面伙伴",
|
||||
"github.com/Tian-XiaRi/SodiumPet",
|
||||
)
|
||||
|
||||
parts = []
|
||||
# 片头 5s
|
||||
p0 = os.path.join(TMP, "p00.mp4")
|
||||
run([
|
||||
FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-loop", "1", "-t", "5", "-i", title,
|
||||
"-vf", f"scale={W}:{H},format=yuv420p,fps={FPS}",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "20", "-an", p0,
|
||||
])
|
||||
parts.append(p0)
|
||||
|
||||
# 各段裁切 + 变速
|
||||
for i, (a, b, sp) in enumerate(SEGMENTS, start=1):
|
||||
out = os.path.join(TMP, f"p{i:02d}.mp4")
|
||||
pts = f"setpts=(PTS-STARTPTS)/{sp}" if sp != 1.0 else "setpts=PTS-STARTPTS"
|
||||
run([
|
||||
FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-ss", str(a), "-to", str(b), "-i", SRC,
|
||||
"-vf", f"scale={W}:{H}:flags=lanczos,{pts},fps={FPS},format=yuv420p",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", out,
|
||||
])
|
||||
parts.append(out)
|
||||
print("segment", i, "done", flush=True)
|
||||
|
||||
# 片尾 6s
|
||||
pe = os.path.join(TMP, "p99.mp4")
|
||||
run([
|
||||
FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-loop", "1", "-t", "6", "-i", end,
|
||||
"-vf", f"scale={W}:{H},format=yuv420p,fps={FPS}",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "20", "-an", pe,
|
||||
])
|
||||
parts.append(pe)
|
||||
|
||||
# 拼接
|
||||
lst = os.path.join(TMP, "list.txt")
|
||||
with open(lst, "w", encoding="utf-8") as f:
|
||||
for p in parts:
|
||||
f.write("file '" + p.replace("\\", "/") + "'\n")
|
||||
rough = os.path.join(OUT, "小钠介绍_粗剪.mp4")
|
||||
run([
|
||||
FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-f", "concat", "-safe", "0", "-i", lst,
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21",
|
||||
"-vf", f"fps={FPS},fade=t=in:st=0:d=0.6,fade=t=out:st=999:d=1",
|
||||
"-an", rough,
|
||||
])
|
||||
print("rough done:", rough, flush=True)
|
||||
|
||||
# 字幕 ASS
|
||||
subs = [
|
||||
(0.5, 5.5, "小钠 · 化学元素拟人桌宠"),
|
||||
(6.0, 11.0, "钠(Na)的拟人,住在你的 Windows 桌面上"),
|
||||
(11.2, 16.5, "会饿、会累、会被氧化,也会自己打工赚钱"),
|
||||
(17.0, 21.0, "点一下就是摸头"),
|
||||
(21.2, 26.0, "右键弹出底栏:投喂 / 面板 / 互动 / 商店 / 图库 / 设置"),
|
||||
(26.2, 31.0, "六条状态,全部是化学化的写法"),
|
||||
(31.2, 37.0, "饱食度 · 石蜡油 · 电子数 · 氧化度 · 心情 · 亲和度"),
|
||||
(37.2, 42.0, "任务解锁等级跨度很大,倍率可以自己调"),
|
||||
(42.2, 47.0, "越肝越赚,但状态掉得也越快"),
|
||||
(47.2, 52.0, "商店里有每日特价和每日礼包"),
|
||||
(52.2, 57.0, "也可以导入自己的 Live2D 模型"),
|
||||
(57.2, 62.0, "切过去就是普通桌宠的文案与图标"),
|
||||
(62.2, 67.0, "详细面板:每一件物品的使用记录"),
|
||||
(67.2, 71.0, "没做过的也显示 0,方便查漏"),
|
||||
(71.2, 77.0, "等级 = 元素周期表"),
|
||||
(77.2, 82.0, "118 个元素、电子排布、每个元素一句特征"),
|
||||
(82.2, 87.0, "编辑器:改名字、改图标、改价格、改解锁等级"),
|
||||
(87.2, 92.0, "化学风与普通风各存一份,互不覆盖"),
|
||||
(92.2, 97.0, "周期表配色可以点格子取色,另存自己的方案"),
|
||||
(97.2, 102.0, "MOD 用 JSON 就能加物品和活动"),
|
||||
(102.2, 107.0, "AI 对话:任意 OpenAI 兼容接口"),
|
||||
(107.2, 112.0, "流式回复、识图、联网搜索、知识库注入"),
|
||||
(112.2, 117.0, "🎲 预设对话会按状态掷骰子:状态好更容易加成"),
|
||||
(117.2, 122.0, "状态差更容易翻车——她真的会记仇"),
|
||||
(122.2, 127.0, "照片、文件、知识库文档,统一在资料库管理"),
|
||||
(127.2, 132.0, "本地音乐 + 歌词浮窗,切存档不影响歌单"),
|
||||
(132.2, 137.0, "开源 · 免费 · Windows 桌面宠物"),
|
||||
(137.2, 143.0, "github.com/Tian-XiaRi/SodiumPet"),
|
||||
(143.2, 148.0, "谢谢观看"),
|
||||
]
|
||||
|
||||
def ts(t: float) -> str:
|
||||
h = int(t // 3600)
|
||||
m = int(t % 3600 // 60)
|
||||
s = t % 60
|
||||
return f"{h}:{m:02d}:{s:05.2f}"
|
||||
|
||||
ass = [
|
||||
"[Script Info]",
|
||||
"ScriptType: v4.00+",
|
||||
f"PlayResX: {W}",
|
||||
f"PlayResY: {H}",
|
||||
"WrapStyle: 0",
|
||||
"ScaledBorderAndShadow: yes",
|
||||
"",
|
||||
"[V4+ Styles]",
|
||||
"Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding",
|
||||
"Style: Caption,Microsoft YaHei,58,&H00F5F0E8,&H00F5F0E8,&H00000000,&H64000000,-1,0,0,0,100,100,0,0,1,3,1,2,120,120,90,1",
|
||||
"",
|
||||
"[Events]",
|
||||
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
||||
]
|
||||
for a, b, text in subs:
|
||||
ass.append(f"Dialogue: 0,{ts(a)},{ts(b)},Caption,,0,0,0,,{text}")
|
||||
ass_path = os.path.join(OUT, "字幕_成片.ass")
|
||||
with open(ass_path, "w", encoding="utf-8-sig") as f:
|
||||
f.write("\n".join(ass))
|
||||
|
||||
# 烧字幕(需要转义路径)
|
||||
esc = ass_path.replace("\\", "/").replace(":", "\\:")
|
||||
final = os.path.join(OUT, "小钠介绍_字幕版.mp4")
|
||||
run([
|
||||
FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-i", rough,
|
||||
"-vf", f"subtitles='{esc}'",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", final,
|
||||
])
|
||||
print("final done:", final, flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,211 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import imageio_ffmpeg
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
FFMPEG = imageio_ffmpeg.get_ffmpeg_exe()
|
||||
SRC = r"D:\软件\剪映\video\QQ20261201-165342-HD.mp4"
|
||||
OUT = r"C:\Users\ASUS\Documents\deepseek-harness\default-workspace\desktop-pet\video-plan"
|
||||
TMP = os.path.join(OUT, "tmp")
|
||||
os.makedirs(TMP, exist_ok=True)
|
||||
|
||||
W, H = 1920, 1200
|
||||
FPS = 60
|
||||
FONT = r"C:\Windows\Fonts\msyhbd.ttc"
|
||||
FONT_R = r"C:\Windows\Fonts\msyh.ttc"
|
||||
|
||||
TITLE_DUR = 5
|
||||
END_DUR = 6
|
||||
|
||||
# (源入点秒, 源出点秒, 速度) —— 出点按目标时长反推
|
||||
SEGMENTS = [
|
||||
(52, 58, 1.0), # 1 桌宠出现
|
||||
(70, 76, 1.0), # 2 右键菜单
|
||||
(90, 104, 1.5), # 3 状态页
|
||||
(112, 130, 1.5), # 4 互动
|
||||
(142, 166, 1.5), # 5 商店
|
||||
(172, 196, 1.5), # 6 换模型
|
||||
(204, 246, 1.8), # 7 详细
|
||||
(252, 288, 1.5), # 8 等级预览
|
||||
(292, 330, 2.0), # 9 编辑器物品
|
||||
(332, 370, 2.0), # 10 编辑器配色
|
||||
(372, 400, 2.0), # 11 设置/MOD
|
||||
(580, 610, 2.0), # 12 编辑器补拍
|
||||
(675, 700, 2.0), # 13 DeepSeek 用量
|
||||
(720, 748, 2.0), # 14 API 文档
|
||||
(820, 858, 1.5), # 15 对话
|
||||
(862, 890, 1.0), # 16 数值反馈
|
||||
(910, 938, 2.0), # 17 世界观
|
||||
(965, 998, 1.5), # 18 资料库
|
||||
(1020, 1050, 1.5), # 19 音乐/图库
|
||||
(1065, 1080, 1.0), # 20 桌面全景
|
||||
]
|
||||
|
||||
# 字幕:(所属片段序号或 'title'/'end', 片段内起, 片段内止, 文本)
|
||||
SUBS = [
|
||||
("title", 0.4, 4.6, "小钠 · 化学元素拟人桌宠"),
|
||||
(1, 0.3, 5.6, "钠(Na)的拟人,住在你的 Windows 桌面上"),
|
||||
(2, 0.2, 3.4, "右键弹出底栏:投喂 / 面板 / 互动 / 商店 / 图库 / 设置"),
|
||||
(3, 0.3, 4.3, "六条状态,全部是化学化的写法"),
|
||||
(3, 4.4, 8.4, "饱食度 · 石蜡油 · 电子数 · 氧化度 · 心情 · 亲和度"),
|
||||
(4, 0.3, 5.3, "任务解锁等级跨度很大,倍率可以自己调"),
|
||||
(4, 5.4, 11.0, "越肝越赚,但状态掉得也越快"),
|
||||
(5, 0.3, 5.3, "商店里有每日特价和每日礼包"),
|
||||
(6, 0.3, 5.3, "也可以导入自己的 Live2D 模型"),
|
||||
(6, 5.4, 10.6, "切过去就是普通桌宠的文案与图标"),
|
||||
(7, 0.3, 5.3, "详细面板:每一件物品的使用记录"),
|
||||
(7, 5.4, 11.3, "没做过的也显示 0,方便查漏"),
|
||||
(7, 11.4, 17.3, "成就、日志、生日,都在这一页"),
|
||||
(8, 0.3, 5.3, "等级 = 元素周期表"),
|
||||
(8, 5.4, 11.0, "118 个元素、电子排布、每个元素一句特征"),
|
||||
(8, 11.1, 16.0, "超 118 级后从 1H 重新循环"),
|
||||
(9, 0.3, 6.3, "编辑器:改名字、改图标、改价格、改解锁等级"),
|
||||
(9, 6.4, 12.0, "化学风与普通风各存一份,互不覆盖"),
|
||||
(10, 0.3, 6.3, "周期表配色可以点格子取色"),
|
||||
(10, 6.4, 12.6, "改完变「自定义」,另存命名后才会保留"),
|
||||
(11, 0.3, 5.3, "MOD 用 JSON 就能加物品和活动"),
|
||||
(11, 5.4, 10.6, "设置里还有存档、生日、歌词浮窗"),
|
||||
(12, 0.3, 5.3, "每个等级都能自己写描述"),
|
||||
(12, 5.4, 10.6, "点格子右上角就能选中该元素"),
|
||||
(13, 0.3, 5.3, "接上任意 OpenAI 兼容接口"),
|
||||
(13, 5.4, 10.3, "这里是 DeepSeek 的用量页"),
|
||||
(14, 0.3, 5.3, "官方文档也写明兼容 OpenAI SDK"),
|
||||
(14, 5.4, 10.3, "所以填 baseURL 和模型名就能用"),
|
||||
(15, 0.3, 6.3, "对话支持流式输出"),
|
||||
(15, 6.4, 14.6, "还有 🎲 预设对话:点一下直接掷骰子"),
|
||||
(16, 0.3, 6.3, "状态好更容易加成,状态差更容易翻车"),
|
||||
(16, 6.4, 13.6, "反馈会显示具体数值"),
|
||||
(17, 0.3, 6.3, "知识库来自你拖进来的文档"),
|
||||
(17, 6.4, 13.6, "聊天时会自动检索注入"),
|
||||
(18, 0.3, 6.3, "照片、文件、知识库,统一在资料库管理"),
|
||||
(18, 6.4, 13.0, "独立的拖拽区,方便整理"),
|
||||
(19, 0.3, 6.3, "本地音乐 + 歌词浮窗"),
|
||||
(19, 6.4, 12.6, "切存档不影响歌单"),
|
||||
("end", 0.3, 3.4, "开源 · 免费 · Windows 桌面宠物"),
|
||||
("end", 3.5, 5.7, "github.com/Tian-XiaRi/SodiumPet"),
|
||||
]
|
||||
|
||||
|
||||
def run(args):
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if p.returncode != 0:
|
||||
print("FAILED:", " ".join(args)[:400])
|
||||
print(p.stdout.decode("utf-8", "ignore")[-3000:])
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def make_card(name, title, sub, foot=""):
|
||||
img = Image.new("RGB", (W, H), (12, 16, 24))
|
||||
d = ImageDraw.Draw(img)
|
||||
for y in range(H):
|
||||
k = y / H
|
||||
d.line([(0, y), (W, y)], fill=(int(10 + 18 * k), int(14 + 20 * k), int(22 + 30 * k)))
|
||||
f1 = ImageFont.truetype(FONT, 104)
|
||||
f2 = ImageFont.truetype(FONT_R, 44)
|
||||
f3 = ImageFont.truetype(FONT_R, 32)
|
||||
tw = d.textlength(title, font=f1)
|
||||
d.text(((W - tw) / 2, 380), title, font=f1, fill=(255, 240, 200))
|
||||
if sub:
|
||||
sw = d.textlength(sub, font=f2)
|
||||
d.text(((W - sw) / 2, 540), sub, font=f2, fill=(190, 205, 225))
|
||||
if foot:
|
||||
fw = d.textlength(foot, font=f3)
|
||||
d.text(((W - fw) / 2, 640), foot, font=f3, fill=(120, 170, 220))
|
||||
path = os.path.join(TMP, name)
|
||||
img.save(path)
|
||||
return path
|
||||
|
||||
|
||||
def main():
|
||||
title = make_card("card_title.png", "小钠 · 化学元素拟人桌宠", "Live2D · 经济任务 · 音乐 · AI 对话 · MOD")
|
||||
end = make_card(
|
||||
"card_end.png",
|
||||
"开源 · 免费 · Windows",
|
||||
"一个会饿、会累、会被氧化的桌面伙伴",
|
||||
"github.com/Tian-XiaRi/SodiumPet",
|
||||
)
|
||||
|
||||
parts = []
|
||||
starts = {} # 片段序号 -> 成片起点
|
||||
t = 0.0
|
||||
|
||||
p0 = os.path.join(TMP, "p00.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-loop", "1", "-t", str(TITLE_DUR), "-i", title,
|
||||
"-vf", f"scale={W}:{H},format=yuv420p,fps={FPS}",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "20", "-an", p0])
|
||||
parts.append(p0)
|
||||
starts["title"] = 0.0
|
||||
t += TITLE_DUR
|
||||
|
||||
for i, (a, b, sp) in enumerate(SEGMENTS, start=1):
|
||||
out = os.path.join(TMP, f"p{i:02d}.mp4")
|
||||
dur = (b - a) / sp
|
||||
pts = f"setpts=(PTS-STARTPTS)/{sp}" if sp != 1.0 else "setpts=PTS-STARTPTS"
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-ss", str(a), "-to", str(b), "-i", SRC,
|
||||
"-vf", f"scale={W}:{H}:flags=lanczos,{pts},fps={FPS},format=yuv420p",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", out])
|
||||
parts.append(out)
|
||||
starts[i] = t
|
||||
t += dur
|
||||
print(f"segment {i} dur={dur:.2f} start={starts[i]:.2f}", flush=True)
|
||||
|
||||
pe = os.path.join(TMP, "p99.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-loop", "1", "-t", str(END_DUR), "-i", end,
|
||||
"-vf", f"scale={W}:{H},format=yuv420p,fps={FPS}",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "20", "-an", pe])
|
||||
parts.append(pe)
|
||||
starts["end"] = t
|
||||
t += END_DUR
|
||||
total = t
|
||||
print("total", total, flush=True)
|
||||
|
||||
lst = os.path.join(TMP, "list.txt")
|
||||
with open(lst, "w", encoding="utf-8") as f:
|
||||
for p in parts:
|
||||
f.write("file '" + p.replace("\\", "/") + "'\n")
|
||||
rough = os.path.join(OUT, "小钠介绍_粗剪.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-f", "concat", "-safe", "0", "-i", lst,
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21",
|
||||
"-vf", f"fps={FPS},fade=t=in:st=0:d=0.5",
|
||||
"-an", rough])
|
||||
print("rough done", flush=True)
|
||||
|
||||
def ts(x):
|
||||
h = int(x // 3600)
|
||||
m = int(x % 3600 // 60)
|
||||
s = x % 60
|
||||
return f"{h}:{m:02d}:{s:05.2f}"
|
||||
|
||||
ass = [
|
||||
"[Script Info]", "ScriptType: v4.00+",
|
||||
f"PlayResX: {W}", f"PlayResY: {H}",
|
||||
"WrapStyle: 0", "ScaledBorderAndShadow: yes", "",
|
||||
"[V4+ Styles]",
|
||||
"Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding",
|
||||
"Style: Caption,Microsoft YaHei,56,&H00F5F0E8,&H00F5F0E8,&H00000000,&H64000000,-1,0,0,0,100,100,0,0,1,3,1,2,120,120,80,1",
|
||||
"", "[Events]",
|
||||
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
||||
]
|
||||
for seg, s0, s1, text in SUBS:
|
||||
base = starts.get(seg, 0.0)
|
||||
ass.append(f"Dialogue: 0,{ts(base + s0)},{ts(base + s1)},Caption,,0,0,0,,{text}")
|
||||
ass_path = os.path.join(OUT, "字幕_成片.ass")
|
||||
with open(ass_path, "w", encoding="utf-8-sig") as f:
|
||||
f.write("\n".join(ass))
|
||||
|
||||
esc = ass_path.replace("\\", "/").replace(":", "\\:")
|
||||
final = os.path.join(OUT, "小钠介绍_字幕版.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-i", rough, "-vf", f"subtitles='{esc}'",
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", final])
|
||||
print("final done", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,214 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import imageio_ffmpeg
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
FFMPEG = imageio_ffmpeg.get_ffmpeg_exe()
|
||||
SRC = r"D:\软件\剪映\video\QQ20261201-165342-HD.mp4"
|
||||
OUT = r"C:\Users\ASUS\Documents\deepseek-harness\default-workspace\desktop-pet\video-plan"
|
||||
TMP = os.path.join(OUT, "tmp")
|
||||
os.makedirs(TMP, exist_ok=True)
|
||||
|
||||
W, H = 1920, 1200
|
||||
FPS = 60
|
||||
FONT = r"C:\Windows\Fonts\msyhbd.ttc"
|
||||
FONT_R = r"C:\Windows\Fonts\msyh.ttc"
|
||||
|
||||
TITLE_DUR = 5.0
|
||||
END_DUR = 6.0
|
||||
|
||||
# (源起点, 目标时长, 速度)
|
||||
SEGMENTS = [
|
||||
(52, 5, 1.0),
|
||||
(70, 6, 1.0),
|
||||
(90, 6, 1.5),
|
||||
(112, 8, 1.5),
|
||||
(142, 8, 1.5),
|
||||
(172, 6, 1.5),
|
||||
(204, 10, 1.8),
|
||||
(252, 8, 1.5),
|
||||
(292, 8, 2.0),
|
||||
(332, 8, 2.0),
|
||||
(372, 6, 2.0),
|
||||
(580, 6, 2.0),
|
||||
(675, 5, 2.0),
|
||||
(720, 5, 2.0),
|
||||
(820, 8, 1.5),
|
||||
(862, 4, 1.0),
|
||||
(910, 5, 2.0),
|
||||
(965, 6, 1.5),
|
||||
(1020, 6, 1.5),
|
||||
(1065, 8, 1.0),
|
||||
]
|
||||
|
||||
SUBS = [
|
||||
("title", 0.4, 4.6, "小钠 · 化学元素拟人桌宠"),
|
||||
(1, 0.3, 4.6, "钠(Na)的拟人,住在你的 Windows 桌面上"),
|
||||
(2, 0.2, 5.6, "右键弹出底栏:投喂 / 面板 / 互动 / 商店 / 图库 / 设置"),
|
||||
(3, 0.2, 2.9, "六条状态,全部是化学化的写法"),
|
||||
(3, 3.0, 5.8, "饱食度 · 石蜡油 · 电子数 · 氧化度"),
|
||||
(4, 0.2, 3.9, "任务解锁等级跨度很大,倍率可以自己调"),
|
||||
(4, 4.0, 7.8, "越肝越赚,但状态掉得也越快"),
|
||||
(5, 0.2, 3.9, "商店里有每日特价和每日礼包"),
|
||||
(5, 4.0, 7.8, "还有每日礼包"),
|
||||
(6, 0.2, 2.9, "也可以导入自己的 Live2D 模型"),
|
||||
(6, 3.0, 5.8, "切过去就是普通桌宠的文案"),
|
||||
(7, 0.2, 4.9, "详细面板:每一件物品的使用记录"),
|
||||
(7, 5.0, 9.8, "没做过的也显示 0;成就、日志、生日都在这里"),
|
||||
(8, 0.2, 3.9, "等级 = 元素周期表"),
|
||||
(8, 4.0, 7.8, "118 个元素、电子排布、每个元素一句特征"),
|
||||
(9, 0.2, 3.9, "编辑器:改名字、图标、价格、解锁等级"),
|
||||
(9, 4.0, 7.8, "化学风与普通风各存一份"),
|
||||
(10, 0.2, 3.9, "周期表配色可以点格子取色"),
|
||||
(10, 4.0, 7.8, "改完变「自定义」,另存命名后才会保留"),
|
||||
(11, 0.2, 2.9, "MOD 用 JSON 就能加物品和活动"),
|
||||
(11, 3.0, 5.8, "设置里还有存档、生日、歌词浮窗"),
|
||||
(12, 0.2, 2.9, "每个等级都能自己写描述"),
|
||||
(12, 3.0, 5.8, "点格子右上角就能选中该元素"),
|
||||
(13, 0.2, 2.4, "接上任意 OpenAI 兼容接口"),
|
||||
(13, 2.5, 4.8, "这里是 DeepSeek 的用量页"),
|
||||
(14, 0.2, 2.4, "官方文档也写明兼容 OpenAI SDK"),
|
||||
(14, 2.5, 4.8, "填 baseURL 和模型名就能用"),
|
||||
(15, 0.2, 3.9, "对话支持流式输出"),
|
||||
(15, 4.0, 7.8, "还有 🎲 预设对话:点一下直接掷骰子"),
|
||||
(16, 0.2, 3.8, "状态好更容易加成,状态差更容易翻车"),
|
||||
(17, 0.2, 2.4, "知识库来自你拖进来的文档"),
|
||||
(17, 2.5, 4.8, "聊天时会自动检索注入"),
|
||||
(18, 0.2, 2.9, "照片、文件、知识库,统一在资料库管理"),
|
||||
(18, 3.0, 5.8, "独立的拖拽区,方便整理"),
|
||||
(19, 0.2, 2.9, "本地音乐 + 歌词浮窗"),
|
||||
(19, 3.0, 5.8, "切存档不影响歌单"),
|
||||
("end", 0.3, 3.4, "开源 · 免费 · Windows 桌面宠物"),
|
||||
("end", 3.5, 5.7, "github.com/Tian-XiaRi/SodiumPet"),
|
||||
]
|
||||
|
||||
|
||||
def run(args):
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if p.returncode != 0:
|
||||
print("FAILED:", " ".join(args)[:400])
|
||||
print(p.stdout.decode("utf-8", "ignore")[-3000:])
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def make_card(name, title, sub, foot=""):
|
||||
img = Image.new("RGB", (W, H), (12, 16, 24))
|
||||
d = ImageDraw.Draw(img)
|
||||
for y in range(H):
|
||||
k = y / H
|
||||
d.line([(0, y), (W, y)], fill=(int(10 + 18 * k), int(14 + 20 * k), int(22 + 30 * k)))
|
||||
f1 = ImageFont.truetype(FONT, 104)
|
||||
f2 = ImageFont.truetype(FONT_R, 44)
|
||||
f3 = ImageFont.truetype(FONT_R, 32)
|
||||
tw = d.textlength(title, font=f1)
|
||||
d.text(((W - tw) / 2, 380), title, font=f1, fill=(255, 240, 200))
|
||||
if sub:
|
||||
sw = d.textlength(sub, font=f2)
|
||||
d.text(((W - sw) / 2, 545), sub, font=f2, fill=(190, 205, 225))
|
||||
if foot:
|
||||
fw = d.textlength(foot, font=f3)
|
||||
d.text(((W - fw) / 2, 645), foot, font=f3, fill=(120, 170, 220))
|
||||
path = os.path.join(TMP, name)
|
||||
img.save(path)
|
||||
return path
|
||||
|
||||
|
||||
def main():
|
||||
title = make_card("card_title.png", "小钠 · 化学元素拟人桌宠", "Live2D · 经济任务 · 音乐 · AI 对话 · MOD")
|
||||
end = make_card(
|
||||
"card_end.png",
|
||||
"开源 · 免费 · Windows",
|
||||
"一个会饿、会累、会被氧化的桌面伙伴",
|
||||
"github.com/Tian-XiaRi/SodiumPet",
|
||||
)
|
||||
|
||||
parts = []
|
||||
starts = {}
|
||||
durs = {}
|
||||
t = 0.0
|
||||
|
||||
p0 = os.path.join(TMP, "p00.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-loop", "1", "-t", str(TITLE_DUR), "-i", title,
|
||||
"-vf", "scale=%d:%d,format=yuv420p,fps=%d" % (W, H, FPS),
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "20", "-an", p0])
|
||||
parts.append(p0)
|
||||
starts["title"] = 0.0
|
||||
durs["title"] = TITLE_DUR
|
||||
t += TITLE_DUR
|
||||
|
||||
for i, (a, target, sp) in enumerate(SEGMENTS, start=1):
|
||||
b = min(1148.0, a + target * sp)
|
||||
dur = (b - a) / sp
|
||||
out = os.path.join(TMP, "p%02d.mp4" % i)
|
||||
pts = "setpts=(PTS-STARTPTS)/%s" % sp if sp != 1.0 else "setpts=PTS-STARTPTS"
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-ss", str(a), "-to", str(b), "-i", SRC,
|
||||
"-vf", "scale=%d:%d:flags=lanczos,%s,fps=%d,format=yuv420p" % (W, H, pts, FPS),
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", out])
|
||||
parts.append(out)
|
||||
starts[i] = t
|
||||
durs[i] = dur
|
||||
t += dur
|
||||
print("segment %d src=[%s,%s] dur=%.2f start=%.2f" % (i, a, round(b, 2), dur, starts[i]), flush=True)
|
||||
|
||||
pe = os.path.join(TMP, "p99.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-loop", "1", "-t", str(END_DUR), "-i", end,
|
||||
"-vf", "scale=%d:%d,format=yuv420p,fps=%d" % (W, H, FPS),
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "20", "-an", pe])
|
||||
parts.append(pe)
|
||||
starts["end"] = t
|
||||
durs["end"] = END_DUR
|
||||
t += END_DUR
|
||||
print("total %.1fs" % t, flush=True)
|
||||
|
||||
lst = os.path.join(TMP, "list.txt")
|
||||
with open(lst, "w", encoding="utf-8") as f:
|
||||
for p in parts:
|
||||
f.write("file '%s'\n" % p.replace("\\", "/"))
|
||||
rough = os.path.join(OUT, "小钠介绍_粗剪.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-f", "concat", "-safe", "0", "-i", lst,
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21",
|
||||
"-vf", "fps=%d,fade=t=in:st=0:d=0.4" % FPS,
|
||||
"-an", rough])
|
||||
print("rough done", flush=True)
|
||||
|
||||
def ts(x):
|
||||
h = int(x // 3600)
|
||||
m = int(x % 3600 // 60)
|
||||
s = x % 60
|
||||
return "%d:%02d:%05.2f" % (h, m, s)
|
||||
|
||||
ass = [
|
||||
"[Script Info]", "ScriptType: v4.00+",
|
||||
"PlayResX: %d" % W, "PlayResY: %d" % H,
|
||||
"WrapStyle: 0", "ScaledBorderAndShadow: yes", "",
|
||||
"[V4+ Styles]",
|
||||
"Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding",
|
||||
"Style: Caption,Microsoft YaHei,56,&H00F5F0E8,&H00F5F0E8,&H00000000,&H64000000,-1,0,0,0,100,100,0,0,1,3,1,2,120,120,80,1",
|
||||
"", "[Events]",
|
||||
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
||||
]
|
||||
for seg, s0, s1, text in SUBS:
|
||||
base = starts.get(seg, 0.0)
|
||||
limit = durs.get(seg, 99.0)
|
||||
s1 = min(s1, max(s0 + 0.6, limit - 0.1))
|
||||
ass.append("Dialogue: 0,%s,%s,Caption,,0,0,0,,%s" % (ts(base + s0), ts(base + s1), text))
|
||||
ass_path = os.path.join(OUT, "字幕_成片.ass")
|
||||
with open(ass_path, "w", encoding="utf-8-sig") as f:
|
||||
f.write("\n".join(ass))
|
||||
|
||||
esc = ass_path.replace("\\", "/").replace(":", "\\:")
|
||||
final = os.path.join(OUT, "小钠介绍_字幕版.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-i", rough, "-vf", "subtitles='%s'" % esc,
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", final])
|
||||
print("final done", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,185 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import imageio_ffmpeg
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
FFMPEG = imageio_ffmpeg.get_ffmpeg_exe()
|
||||
SRC = r"D:\软件\剪映\video\QQ20261201-165342-HD.mp4"
|
||||
OUT = r"C:\Users\ASUS\Documents\deepseek-harness\default-workspace\desktop-pet\video-plan"
|
||||
TMP = os.path.join(OUT, "tmp4")
|
||||
os.makedirs(TMP, exist_ok=True)
|
||||
|
||||
W, H = 1920, 1200
|
||||
FPS = 60
|
||||
FONT = r"C:\Windows\Fonts\msyhbd.ttc"
|
||||
FONT_R = r"C:\Windows\Fonts\msyh.ttc"
|
||||
TITLE_DUR, END_DUR = 5.0, 6.0
|
||||
|
||||
# (源入点, 源出点) —— 已按 20 秒一格的抽样帧定位
|
||||
SEGMENTS = [
|
||||
(60, 65),
|
||||
(340, 346),
|
||||
(100, 106),
|
||||
(418, 426),
|
||||
(445, 453),
|
||||
(236, 242),
|
||||
(498, 508),
|
||||
(524, 532),
|
||||
(585, 593),
|
||||
(642, 650),
|
||||
(706, 712),
|
||||
(660, 665),
|
||||
(778, 783),
|
||||
(798, 803),
|
||||
(850, 858),
|
||||
(932, 936),
|
||||
(838, 843),
|
||||
(1020, 1026),
|
||||
(1114, 1120),
|
||||
(758, 766),
|
||||
]
|
||||
|
||||
SUBS = [
|
||||
("title", 0.4, 4.6, "小钠 · 化学元素拟人桌宠"),
|
||||
(1, 0.3, 4.6, "她叫小钠,钠(Na)的拟人"),
|
||||
(2, 0.3, 5.6, "右键弹出底栏,所有功能都在这里"),
|
||||
(3, 0.3, 5.6, "六条状态全是化学化的写法"),
|
||||
(4, 0.3, 7.6, "任务解锁等级跨度大,倍率可以自己调"),
|
||||
(5, 0.3, 7.6, "商店有每日特价和每日礼包"),
|
||||
(6, 0.3, 5.6, "也能导入自己的 Live2D 模型"),
|
||||
(7, 0.3, 5.0, "详细面板:物品使用记录、成就、日志"),
|
||||
(7, 5.1, 9.6, "没做过的也显示 0,方便查漏"),
|
||||
(8, 0.3, 3.9, "等级 = 元素周期表"),
|
||||
(8, 4.0, 7.6, "118 个元素,每个元素一句特征"),
|
||||
(9, 0.3, 7.6, "编辑器:改名字、图标、价格、解锁等级"),
|
||||
(10, 0.3, 7.6, "周期表配色点格子取色,可另存成方案"),
|
||||
(11, 0.3, 5.6, "设置里有存档、MOD、生日、歌词浮窗"),
|
||||
(12, 0.3, 4.6, "每个等级都能自己写描述"),
|
||||
(13, 0.3, 4.6, "接上任意 OpenAI 兼容接口"),
|
||||
(14, 0.3, 4.6, "兼容 OpenAI SDK,填 baseURL 就能用"),
|
||||
(15, 0.3, 3.9, "对话支持流式输出"),
|
||||
(15, 4.0, 7.6, "还有 🎲 预设对话,点一下掷骰子"),
|
||||
(16, 0.3, 3.6, "状态好更容易加成,状态差更容易翻车"),
|
||||
(17, 0.3, 4.6, "知识库来自你拖进来的文档"),
|
||||
(18, 0.3, 5.6, "照片、文件、知识库统一管理"),
|
||||
(19, 0.3, 5.6, "独立的资料库窗口,方便整理"),
|
||||
(20, 0.3, 5.0, "开源、免费 · github.com/Tian-XiaRi/SodiumPet"),
|
||||
("end", 0.3, 5.6, "谢谢观看 · 欢迎 star"),
|
||||
]
|
||||
|
||||
|
||||
def run(args):
|
||||
p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if p.returncode != 0:
|
||||
print("FAILED:", " ".join(args)[:300])
|
||||
print(p.stdout.decode("utf-8", "ignore")[-2000:])
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def make_card(name, title, sub, foot=""):
|
||||
img = Image.new("RGB", (W, H), (12, 16, 24))
|
||||
d = ImageDraw.Draw(img)
|
||||
for y in range(H):
|
||||
k = y / H
|
||||
d.line([(0, y), (W, y)], fill=(int(10 + 18 * k), int(14 + 20 * k), int(22 + 30 * k)))
|
||||
f1 = ImageFont.truetype(FONT, 104)
|
||||
f2 = ImageFont.truetype(FONT_R, 44)
|
||||
f3 = ImageFont.truetype(FONT_R, 32)
|
||||
tw = d.textlength(title, font=f1)
|
||||
d.text(((W - tw) / 2, 380), title, font=f1, fill=(255, 240, 200))
|
||||
if sub:
|
||||
sw = d.textlength(sub, font=f2)
|
||||
d.text(((W - sw) / 2, 545), sub, font=f2, fill=(190, 205, 225))
|
||||
if foot:
|
||||
fw = d.textlength(foot, font=f3)
|
||||
d.text(((W - fw) / 2, 645), foot, font=f3, fill=(120, 170, 220))
|
||||
p = os.path.join(TMP, name)
|
||||
img.save(p)
|
||||
return p
|
||||
|
||||
|
||||
def main():
|
||||
title = make_card("card_title.png", "小钠 · 化学元素拟人桌宠", "Live2D · 经济任务 · 音乐 · AI 对话 · MOD")
|
||||
end = make_card(
|
||||
"card_end.png",
|
||||
"开源 · 免费 · Windows",
|
||||
"一个会饿、会累、会被氧化的桌面伙伴",
|
||||
"github.com/Tian-XiaRi/SodiumPet",
|
||||
)
|
||||
|
||||
parts, starts, durs, t = [], {}, {}, 0.0
|
||||
p0 = os.path.join(TMP, "p00.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-loop", "1", "-t", str(TITLE_DUR), "-i", title,
|
||||
"-vf", "scale=%d:%d,format=yuv420p,fps=%d" % (W, H, FPS),
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "20", "-an", p0])
|
||||
parts.append(p0)
|
||||
starts["title"], durs["title"] = 0.0, TITLE_DUR
|
||||
t += TITLE_DUR
|
||||
|
||||
for i, (a, b) in enumerate(SEGMENTS, start=1):
|
||||
dur = b - a
|
||||
out = os.path.join(TMP, "p%02d.mp4" % i)
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-ss", str(a), "-to", str(b), "-i", SRC,
|
||||
"-vf", "scale=%d:%d:flags=lanczos,fps=%d,format=yuv420p" % (W, H, FPS),
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", out])
|
||||
parts.append(out)
|
||||
starts[i] = t
|
||||
durs[i] = dur
|
||||
t += dur
|
||||
print("seg %02d src=[%s,%s] @%.2f" % (i, a, b, starts[i]), flush=True)
|
||||
|
||||
pe = os.path.join(TMP, "p99.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-loop", "1", "-t", str(END_DUR), "-i", end,
|
||||
"-vf", "scale=%d:%d,format=yuv420p,fps=%d" % (W, H, FPS),
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "20", "-an", pe])
|
||||
parts.append(pe)
|
||||
starts["end"], durs["end"] = t, END_DUR
|
||||
t += END_DUR
|
||||
print("total %.1f" % t, flush=True)
|
||||
|
||||
lst = os.path.join(TMP, "list.txt")
|
||||
with open(lst, "w", encoding="utf-8") as f:
|
||||
for p in parts:
|
||||
f.write("file '%s'\n" % p.replace("\\", "/"))
|
||||
rough = os.path.join(OUT, "小钠介绍_粗剪.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-f", "concat", "-safe", "0", "-i", lst,
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21",
|
||||
"-vf", "fps=%d,fade=t=in:st=0:d=0.4" % FPS, "-an", rough])
|
||||
|
||||
def ts(x):
|
||||
return "%d:%02d:%05.2f" % (int(x // 3600), int(x % 3600 // 60), x % 60)
|
||||
|
||||
ass = [
|
||||
"[Script Info]", "ScriptType: v4.00+",
|
||||
"PlayResX: %d" % W, "PlayResY: %d" % H,
|
||||
"WrapStyle: 0", "ScaledBorderAndShadow: yes", "",
|
||||
"[V4+ Styles]",
|
||||
"Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding",
|
||||
"Style: Caption,Microsoft YaHei,56,&H00F5F0E8,&H00F5F0E8,&H00000000,&H64000000,-1,0,0,0,100,100,0,0,1,3,1,2,120,120,80,1",
|
||||
"", "[Events]",
|
||||
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
||||
]
|
||||
for seg, s0, s1, text in SUBS:
|
||||
base = starts.get(seg, 0.0)
|
||||
s1 = min(s1, max(s0 + 0.6, durs.get(seg, 99) - 0.1))
|
||||
ass.append("Dialogue: 0,%s,%s,Caption,,0,0,0,,%s" % (ts(base + s0), ts(base + s1), text))
|
||||
ass_path = os.path.join(OUT, "字幕_成片.ass")
|
||||
with open(ass_path, "w", encoding="utf-8-sig") as f:
|
||||
f.write("\n".join(ass))
|
||||
|
||||
esc = ass_path.replace("\\", "/").replace(":", "\\:")
|
||||
final = os.path.join(OUT, "小钠介绍_字幕版.mp4")
|
||||
run([FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-i", rough, "-vf", "subtitles='%s'" % esc,
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", final])
|
||||
print("final done", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,103 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import imageio_ffmpeg
|
||||
|
||||
FFMPEG = imageio_ffmpeg.get_ffmpeg_exe()
|
||||
OUT = r"C:\Users\ASUS\Documents\deepseek-harness\default-workspace\desktop-pet\video-plan"
|
||||
ROUGH = os.path.join(OUT, "小钠介绍_粗剪.mp4")
|
||||
W, H = 1920, 1200
|
||||
|
||||
# 片段起点(秒)——与 build_video4.py 输出一致
|
||||
STARTS = [1, 6, 12, 18, 26, 34, 42, 48, 58, 63, 71, 79, 84, 89, 94, 99, 107, 111, 116, 123, 129]
|
||||
TITLE_END = 5.0
|
||||
END_START = 136.0
|
||||
|
||||
CAPS = [
|
||||
("装好后,她就住在你的桌面上了", 5.0),
|
||||
("右键弹出底栏:投喂 / 面板 / 互动 / 商店 / 图库 / 设置", 6.0),
|
||||
("六条状态:饱食度 · 石蜡油 · 电子数 · 氧化度 · 心情 · 亲和度", 6.0),
|
||||
("详细面板里能看到每一件物品的使用次数", 8.0),
|
||||
("状态、皮肤、存档都能在设置里换", 8.0),
|
||||
("没做过的统计也显示 0,方便查漏", 6.0),
|
||||
("统计 / 总结 / 生日 / 日志 / 等级预览,一共五页", 10.0),
|
||||
("等级 = 元素周期表,118 个元素", 8.0),
|
||||
("每个元素一句特征,点一下还能联网补资料", 8.0),
|
||||
("编辑器:改等级描述、周期表配色", 8.0),
|
||||
("设置里还有存档、MOD、生日、歌词浮窗", 6.0),
|
||||
("文件拖给她就会进文件袋", 5.0),
|
||||
("配色可以点格子取色,另存成自己的方案", 5.0),
|
||||
("接上任意 OpenAI 兼容接口", 5.0),
|
||||
("填 baseURL 和模型名就能用", 8.0),
|
||||
("知识库来自你拖进来的文档", 4.0),
|
||||
("对话支持流式输出与 🎲 预设掷骰子", 8.0),
|
||||
("官方文档写明兼容 OpenAI SDK", 5.0),
|
||||
("素材、照片、文件统一管理", 6.0),
|
||||
("独立资料库窗口:照片 / 文件 / 知识库", 6.0),
|
||||
("设置里能改缩放、主题、主色和裁剪", 7.0),
|
||||
]
|
||||
|
||||
|
||||
def ts(x: float) -> str:
|
||||
return "%d:%02d:%05.2f" % (int(x // 3600), int(x % 3600 // 60), x % 60)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
lines = [
|
||||
"[Script Info]", "ScriptType: v4.00+",
|
||||
"PlayResX: %d" % W, "PlayResY: %d" % H,
|
||||
"WrapStyle: 0", "ScaledBorderAndShadow: yes", "",
|
||||
"[V4+ Styles]",
|
||||
"Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding",
|
||||
"Style: Caption,Microsoft YaHei,56,&H00F5F0E8,&H00F5F0E8,&H00000000,&H64000000,-1,0,0,0,100,100,0,0,1,3,1,2,120,120,80,1",
|
||||
"", "[Events]",
|
||||
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
||||
]
|
||||
# 片头
|
||||
lines.append("Dialogue: 0,%s,%s,Caption,,0,0,0,,小钠 · 化学元素拟人桌宠" % (ts(0.4), ts(4.6)))
|
||||
srt = []
|
||||
srt.append((0.4, 4.6, "小钠 · 化学元素拟人桌宠"))
|
||||
for i, (text, dur) in enumerate(CAPS):
|
||||
st = STARTS[i] + 0.2
|
||||
en = STARTS[i] + max(2.0, dur - 0.2)
|
||||
if i + 1 < len(STARTS):
|
||||
en = min(en, STARTS[i + 1] - 0.1)
|
||||
lines.append("Dialogue: 0,%s,%s,Caption,,0,0,0,,%s" % (ts(st), ts(en), text))
|
||||
srt.append((st, en, text))
|
||||
lines.append("Dialogue: 0,%s,%s,Caption,,0,0,0,,谢谢观看 · 欢迎 star" % (ts(END_START + 0.4), ts(END_START + 5.5)))
|
||||
srt.append((END_START + 0.4, END_START + 5.5, "谢谢观看 · 欢迎 star"))
|
||||
|
||||
ass_path = os.path.join(OUT, "字幕_成片.ass")
|
||||
with open(ass_path, "w", encoding="utf-8-sig") as f:
|
||||
f.write("\n".join(lines))
|
||||
|
||||
# 同步生成 SRT(给剪映导入用)
|
||||
def srt_ts(x: float) -> str:
|
||||
h = int(x // 3600)
|
||||
m = int(x % 3600 // 60)
|
||||
s = x % 60
|
||||
return "%02d:%02d:%02d,%03d" % (h, m, int(s), int((s - int(s)) * 1000))
|
||||
|
||||
blocks = []
|
||||
for i, (a, b, text) in enumerate(srt, start=1):
|
||||
blocks.append("%d\n%s --> %s\n%s\n" % (i, srt_ts(a), srt_ts(b), text))
|
||||
with open(os.path.join(OUT, "字幕.srt"), "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(blocks))
|
||||
|
||||
esc = ass_path.replace("\\", "/").replace(":", "\\:")
|
||||
final = os.path.join(OUT, "小钠介绍_字幕版.mp4")
|
||||
p = subprocess.run(
|
||||
[FFMPEG, "-y", "-hide_banner", "-loglevel", "error",
|
||||
"-i", ROUGH, "-vf", "subtitles='%s'" % esc,
|
||||
"-c:v", "libx264", "-preset", "veryfast", "-crf", "21", "-an", final],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
)
|
||||
if p.returncode != 0:
|
||||
print(p.stdout.decode("utf-8", "ignore")[-2000:])
|
||||
sys.exit(1)
|
||||
print("subtitle burn done")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 539 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 594 KiB |
@@ -0,0 +1,149 @@
|
||||
# 《小钠 · 化学元素拟人桌宠》介绍视频 · 剪辑方案 v1
|
||||
|
||||
素材:`D:\软件\剪映\video\QQ20261201-165342-HD.mp4`
|
||||
规格:19:08,2556×1596(16:10),59.43fps,含音轨(48kHz 立体声,原片应无解说)
|
||||
目标成片:**约 3 分钟**,16:10 画布(1920×1200),保留桌面「竖着的桌宠 + 面板」原始构图
|
||||
|
||||
---
|
||||
|
||||
## 一、先做 3 件事(开工前)
|
||||
|
||||
1. **新建项目**:剪映 → 开始创作 → 比例选「16:10」(或 1920×1200 自定义),帧率 60。
|
||||
2. **导入素材**:把原片拖进媒体区,再拖到主轨。
|
||||
3. **加辅助线**:播放器右下角「画质/网格」打开安全区,画面右下方是桌宠,面板在中间偏左——字幕统一放**底部居中**,避开人物脚下。
|
||||
|
||||
---
|
||||
|
||||
## 二、粗剪顺序(原片 → 成片)
|
||||
|
||||
> 时间点来自抽样帧,允许 ±3 秒;到点前后留 2 秒余量再切。
|
||||
|
||||
| # | 原片区间 | 画面内容 | 处理 | 成片时长 |
|
||||
|---|---|---|---|---|
|
||||
| 1 | 00:52–01:06 | 桌宠出现在桌面(Windows 警告已关掉之后) | 1× | 5s |
|
||||
| 2 | 01:10–01:26 | 右键菜单 + 底部工具栏 | 1× | 6s |
|
||||
| 3 | 01:30–01:50 | 面板:状态页(六条状态) | 1.5× | 6s |
|
||||
| 4 | 01:52–02:18 | 互动页(任务列表 + 倍率) | 1.5× | 8s |
|
||||
| 5 | 02:22–02:50 | 商店 + 每日特价 | 1.5× | 8s |
|
||||
| 6 | 02:52–03:20 | 切换到「藿藿」模型(皮肤切换) | 1.5× | 6s |
|
||||
| 7 | 03:24–04:10 | 详细窗口:统计面板 / 统计总结 | 1.8× | 10s |
|
||||
| 8 | 04:12–04:50 | 等级预览:周期表 + 元素特征 | 1.5× | 8s |
|
||||
| 9 | 04:52–05:30 | 编辑器:改物品图标 / 等级描述 | 2× | 8s |
|
||||
| 10 | 05:32–06:10 | 编辑器:周期表配色方案 | 2× | 8s |
|
||||
| 11 | 06:12–06:40 | 设置:MOD / 档案 / 生日 | 2× | 6s |
|
||||
| 12 | 09:40–10:10 | 编辑器周期表(补拍,确认配色) | 2× | 6s |
|
||||
| 13 | 11:15–11:40 | DeepSeek 用量页(API 已接通) | 2× | 5s |
|
||||
| 14 | 12:00–12:30 | API 文档(说明兼容 OpenAI) | 2× | 5s |
|
||||
| 15 | 13:40–14:20 | 对话:输入 → 流式回复 / 预设 🎲 | 1.5× | 8s |
|
||||
| 16 | 14:22–14:50 | 对话反馈:「🎲 心情 +4」 | 1× | 4s |
|
||||
| 17 | 15:10–15:40 | 世界观/人设文档(知识库来源) | 2× | 5s |
|
||||
| 18 | 16:05–16:40 | 资料库:照片 / 文件袋 / 知识库 | 1.5× | 6s |
|
||||
| 19 | 17:00–17:30 | 音乐播放器 + 歌词浮窗(若原片有) | 1.5× | 6s |
|
||||
| 20 | 结尾 | 桌面全景静帧 | — | 8s |
|
||||
|
||||
**合计**:约 135 秒画面 + 片头 6 秒 + 片尾 12 秒 ≈ **2 分 35 秒**。想更短就把 #7、#14、#17 压到 3 秒或用 2.5× 变速。
|
||||
|
||||
---
|
||||
|
||||
## 三、段落设计(含文案)
|
||||
|
||||
### 0. 片头 0:00–0:06
|
||||
- 画面:桌宠静帧(选一张 720p 截图),轻微缓慢推近(关键帧缩放 100→108)
|
||||
- 字幕大标题:**小钠 · 化学元素拟人桌宠**(思源黑体 Bold,字号 72,白字 + 20% 黑描边)
|
||||
- 副标题小字:Live2D · 经济任务 · 音乐 · AI 对话 · MOD
|
||||
- 音效:轻「叮」
|
||||
|
||||
### 1. 定位 0:06–0:20
|
||||
- 画面:#1 + #2,右下角出现「桌宠在桌面」的字幕
|
||||
- 文案:「她叫小钠,钠(Na)的拟人,住在你的 Windows 桌面上。」
|
||||
- 文案:「会饿、会累、会被氧化,也会自己打工赚钱。」
|
||||
|
||||
### 2. 互动 0:20–0:40
|
||||
- 画面:#2 右键菜单、摸头气泡、拖动
|
||||
- 文案:「点一下摸头,右下角就是她的工具栏。」
|
||||
- 加圆形高亮(形状+描边动画)指向气泡和工具栏
|
||||
|
||||
### 3. 面板 0:40–1:05
|
||||
- 画面:#3 状态页 → #4 互动 → #5 商店
|
||||
- 文案:「六条状态都是化学化的写法:饱食度、石蜡油、电子数、氧化度……」
|
||||
- 文案:「任务解锁等级跨度很大,倍率可以自己调,越肝越赚。」
|
||||
|
||||
### 4. 模型 1:05–1:20
|
||||
- 画面:#6 切到藿藿
|
||||
- 文案:「也可以导入自己的 Live2D 模型——切过去就是普通桌宠的文案。」
|
||||
- 打字机效果打出「自动校准:92% 窗口高度」
|
||||
|
||||
### 5. 深度系统 1:20–1:50
|
||||
- 画面:#7 统计 → #8 等级预览(周期表特写)
|
||||
- 文案:「详细面板里能看到每一件物品的使用记录,没做过的也显示 0。」
|
||||
- 文案:「等级 = 元素周期表:118 个元素、电子排布、元素特征文案。」
|
||||
|
||||
### 6. 编辑器 / MOD 1:50–2:15
|
||||
- 画面:#9 #10 #11
|
||||
- 文案:「编辑器可以直接改名字、图标、价格、解锁等级——两种文本风格各改一份。」
|
||||
- 文案:「周期表配色可以点格子取色,另存成自己的方案。」
|
||||
|
||||
### 7. AI 对话 2:15–2:35
|
||||
- 画面:#13 #15 #16
|
||||
- 文案:「接上任意 OpenAI 兼容接口(这里是 DeepSeek),支持流式回复、识图、联网。」
|
||||
- 文案:「🎲 预设对话会按状态掷骰子:状态好更容易加成,状态差更容易翻车。」
|
||||
|
||||
### 8. 资料库 / 音乐 2:35–2:50
|
||||
- 画面:#18 #19
|
||||
- 文案:「照片、拖进来的文件、知识库文档,统一在资料库里管。」
|
||||
- 文案:「本地音乐 + 歌词浮窗,切存档不影响歌单。」
|
||||
|
||||
### 9. 片尾 2:50–3:00
|
||||
- 画面:桌面全景(#20),加暗角
|
||||
- 大字:**开源 / 免费 / Windows**
|
||||
- 小字:`github.com/Tian-XiaRi/SodiumPet`
|
||||
- 右下角二维码(GitHub 仓库二维码,可用草料生成)
|
||||
- 音效:淡出
|
||||
|
||||
---
|
||||
|
||||
## 四、剪映里的具体操作
|
||||
|
||||
1. **切点**:时间轴定位 → `Ctrl+B` 分割 → 选中多余段 `Delete`。
|
||||
2. **变速**:选中片段 → 右键「变速/常规变速」→ 看面板时用 1.5~2×,对话流式回复保持 1×(节奏感)。
|
||||
3. **画面聚焦**:面板较小时,选中片段 → 「画面」→ 缩放 115~130%,配合关键帧做缓慢推近;或加「蒙版-矩形」把重点区域框出来。
|
||||
4. **高亮**:素材库搜「圆形/箭头/光标点击」,叠加到画中画,对准被点击的按钮。
|
||||
5. **字幕**:
|
||||
- 直接「文本 → 智能字幕 → 识别字幕」会把你原片里的环境声识别乱,建议**导入我给的 `字幕.srt`**(文本 → 本地字幕 → 导入)。
|
||||
- 样式:思源黑体 Medium,字号 42,白字,描边黑色 15%,底部居中,**开启「底部安全区」**避免压到桌宠脚。
|
||||
6. **BGM**:剪映素材库搜「科技 轻快」「8bit」,音量降到 -18dB(原片音频几乎没内容,静音或保留极低环境声)。
|
||||
7. **转场**:只用「叠化」或「推移」,每个 0.3s 以内;不要花哨。
|
||||
8. **片尾二维码**:百度搜「草料二维码」→ 输入仓库地址 → 生成 → 下载 → 放右下角。
|
||||
9. **导出**:1080p / 60fps / 建议码率「较高」,格式 MP4(H.264)。要发 B 站可选 4K 上传(剪映会放大,不必强求)。
|
||||
|
||||
---
|
||||
|
||||
## 五、让 Agent 帮到哪一步
|
||||
|
||||
| 环节 | Agent 能做 | Agent 做不到 |
|
||||
|---|---|---|
|
||||
| 看素材、找可用片段 | ✅ 抽帧生成总览图、给切点表 | 不能替代你的审美做终剪 |
|
||||
| 写文案/字幕 | ✅ 生成 SRT、逐段解说词 | — |
|
||||
| 节奏建议 | ✅ 按成片时长反推每段秒数 | 无法实时预览 |
|
||||
| 操作剪映 | ❌ 不能点 GUI | — |
|
||||
| 生成剪映草稿 | ✅ 可行(pyJianYingDraft 生成 draft 文件放进 JianyingPro Drafts) | 需要你在剪映里重新链接媒体 |
|
||||
|
||||
> 如果你愿意试「自动生成剪映草稿」:我可以装 `pyJianYingDraft`,按上表自动排轨、加字幕、加转场,生成一个草稿工程,你打开剪映 → 草稿列表就能看到。缺点是素材路径要固定、部分特效不支持。要做我就开工。
|
||||
|
||||
---
|
||||
|
||||
## 六、附带文件
|
||||
|
||||
- 字幕.srt:成片字幕(约 3 分钟),剪映里「文本 → 本地字幕 → 导入」直接用
|
||||
- 裁剪清单.csv:20 个切点的原片入出点与成片时间,可对照着切
|
||||
- sheet_1.png / sheet_2.png:原片总览图
|
||||
|
||||
> 注意:本次抽样帧里**没有看到音乐播放器/歌词浮窗**的画面。如果原片里确实没有,建议单独录 10 秒补拍,或把第 19 段替换成「图库大窗口」的镜头。
|
||||
|
||||
## 七、素材参考图
|
||||
|
||||
- `video-plan/sheet_1.png`:0–9.6 分钟,每格间隔 48 秒(从左到右、从上到下)
|
||||
- `video-plan/sheet_2.png`:9.6–19 分钟,同样 48 秒一格
|
||||
|
||||
对照这两张总览图,可以直接找到上面表格里的区间。
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
1
|
||||
00:00:00,400 --> 00:00:04,599
|
||||
小钠 · 化学元素拟人桌宠
|
||||
|
||||
2
|
||||
00:00:01,199 --> 00:00:05,799
|
||||
装好后,她就住在你的桌面上了
|
||||
|
||||
3
|
||||
00:00:06,200 --> 00:00:11,800
|
||||
右键弹出底栏:投喂 / 面板 / 互动 / 商店 / 图库 / 设置
|
||||
|
||||
4
|
||||
00:00:12,199 --> 00:00:17,800
|
||||
六条状态:饱食度 · 石蜡油 · 电子数 · 氧化度 · 心情 · 亲和度
|
||||
|
||||
5
|
||||
00:00:18,199 --> 00:00:25,800
|
||||
详细面板里能看到每一件物品的使用次数
|
||||
|
||||
6
|
||||
00:00:26,199 --> 00:00:33,799
|
||||
状态、皮肤、存档都能在设置里换
|
||||
|
||||
7
|
||||
00:00:34,200 --> 00:00:39,799
|
||||
没做过的统计也显示 0,方便查漏
|
||||
|
||||
8
|
||||
00:00:42,200 --> 00:00:47,899
|
||||
统计 / 总结 / 生日 / 日志 / 等级预览,一共五页
|
||||
|
||||
9
|
||||
00:00:48,200 --> 00:00:55,799
|
||||
等级 = 元素周期表,118 个元素
|
||||
|
||||
10
|
||||
00:00:58,200 --> 00:01:02,899
|
||||
每个元素一句特征,点一下还能联网补资料
|
||||
|
||||
11
|
||||
00:01:03,200 --> 00:01:10,799
|
||||
编辑器:改等级描述、周期表配色
|
||||
|
||||
12
|
||||
00:01:11,200 --> 00:01:16,799
|
||||
设置里还有存档、MOD、生日、歌词浮窗
|
||||
|
||||
13
|
||||
00:01:19,200 --> 00:01:23,799
|
||||
文件拖给她就会进文件袋
|
||||
|
||||
14
|
||||
00:01:24,200 --> 00:01:28,799
|
||||
配色可以点格子取色,另存成自己的方案
|
||||
|
||||
15
|
||||
00:01:29,200 --> 00:01:33,799
|
||||
接上任意 OpenAI 兼容接口
|
||||
|
||||
16
|
||||
00:01:34,200 --> 00:01:38,900
|
||||
填 baseURL 和模型名就能用
|
||||
|
||||
17
|
||||
00:01:39,200 --> 00:01:42,799
|
||||
知识库来自你拖进来的文档
|
||||
|
||||
18
|
||||
00:01:47,200 --> 00:01:50,900
|
||||
对话支持流式输出与 🎲 预设掷骰子
|
||||
|
||||
19
|
||||
00:01:51,200 --> 00:01:55,799
|
||||
官方文档写明兼容 OpenAI SDK
|
||||
|
||||
20
|
||||
00:01:56,200 --> 00:02:01,799
|
||||
素材、照片、文件统一管理
|
||||
|
||||
21
|
||||
00:02:03,200 --> 00:02:08,800
|
||||
独立资料库窗口:照片 / 文件 / 知识库
|
||||
|
||||
22
|
||||
00:02:09,199 --> 00:02:15,800
|
||||
设置里能改缩放、主题、主色和裁剪
|
||||
|
||||
23
|
||||
00:02:16,400 --> 00:02:21,500
|
||||
谢谢观看 · 欢迎 star
|
||||
@@ -0,0 +1,36 @@
|
||||
[Script Info]
|
||||
ScriptType: v4.00+
|
||||
PlayResX: 1920
|
||||
PlayResY: 1200
|
||||
WrapStyle: 0
|
||||
ScaledBorderAndShadow: yes
|
||||
|
||||
[V4+ Styles]
|
||||
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
|
||||
Style: Caption,Microsoft YaHei,56,&H00F5F0E8,&H00F5F0E8,&H00000000,&H64000000,-1,0,0,0,100,100,0,0,1,3,1,2,120,120,80,1
|
||||
|
||||
[Events]
|
||||
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
Dialogue: 0,0:00:00.40,0:00:04.60,Caption,,0,0,0,,小钠 · 化学元素拟人桌宠
|
||||
Dialogue: 0,0:00:01.20,0:00:05.80,Caption,,0,0,0,,装好后,她就住在你的桌面上了
|
||||
Dialogue: 0,0:00:06.20,0:00:11.80,Caption,,0,0,0,,右键弹出底栏:投喂 / 面板 / 互动 / 商店 / 图库 / 设置
|
||||
Dialogue: 0,0:00:12.20,0:00:17.80,Caption,,0,0,0,,六条状态:饱食度 · 石蜡油 · 电子数 · 氧化度 · 心情 · 亲和度
|
||||
Dialogue: 0,0:00:18.20,0:00:25.80,Caption,,0,0,0,,详细面板里能看到每一件物品的使用次数
|
||||
Dialogue: 0,0:00:26.20,0:00:33.80,Caption,,0,0,0,,状态、皮肤、存档都能在设置里换
|
||||
Dialogue: 0,0:00:34.20,0:00:39.80,Caption,,0,0,0,,没做过的统计也显示 0,方便查漏
|
||||
Dialogue: 0,0:00:42.20,0:00:47.90,Caption,,0,0,0,,统计 / 总结 / 生日 / 日志 / 等级预览,一共五页
|
||||
Dialogue: 0,0:00:48.20,0:00:55.80,Caption,,0,0,0,,等级 = 元素周期表,118 个元素
|
||||
Dialogue: 0,0:00:58.20,0:01:02.90,Caption,,0,0,0,,每个元素一句特征,点一下还能联网补资料
|
||||
Dialogue: 0,0:01:03.20,0:01:10.80,Caption,,0,0,0,,编辑器:改等级描述、周期表配色
|
||||
Dialogue: 0,0:01:11.20,0:01:16.80,Caption,,0,0,0,,设置里还有存档、MOD、生日、歌词浮窗
|
||||
Dialogue: 0,0:01:19.20,0:01:23.80,Caption,,0,0,0,,文件拖给她就会进文件袋
|
||||
Dialogue: 0,0:01:24.20,0:01:28.80,Caption,,0,0,0,,配色可以点格子取色,另存成自己的方案
|
||||
Dialogue: 0,0:01:29.20,0:01:33.80,Caption,,0,0,0,,接上任意 OpenAI 兼容接口
|
||||
Dialogue: 0,0:01:34.20,0:01:38.90,Caption,,0,0,0,,填 baseURL 和模型名就能用
|
||||
Dialogue: 0,0:01:39.20,0:01:42.80,Caption,,0,0,0,,知识库来自你拖进来的文档
|
||||
Dialogue: 0,0:01:47.20,0:01:50.90,Caption,,0,0,0,,对话支持流式输出与 🎲 预设掷骰子
|
||||
Dialogue: 0,0:01:51.20,0:01:55.80,Caption,,0,0,0,,官方文档写明兼容 OpenAI SDK
|
||||
Dialogue: 0,0:01:56.20,0:02:01.80,Caption,,0,0,0,,素材、照片、文件统一管理
|
||||
Dialogue: 0,0:02:03.20,0:02:08.80,Caption,,0,0,0,,独立资料库窗口:照片 / 文件 / 知识库
|
||||
Dialogue: 0,0:02:09.20,0:02:15.80,Caption,,0,0,0,,设置里能改缩放、主题、主色和裁剪
|
||||
Dialogue: 0,0:02:16.40,0:02:21.50,Caption,,0,0,0,,谢谢观看 · 欢迎 star
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
序号,原片入点,原片出点,成片入点,处理,说明
|
||||
1,00:52,01:06,00:00,1x,桌宠出现在桌面
|
||||
2,01:10,01:26,00:06,1x,右键菜单 + 底栏
|
||||
3,01:30,01:50,00:20,1.5x,状态页
|
||||
4,01:52,02:18,00:31,1.5x,互动页 + 倍率
|
||||
5,02:22,02:50,00:45,1.5x,商店 + 每日特价
|
||||
6,02:52,03:20,00:58,1.5x,切到藿藿模型
|
||||
7,03:24,04:10,01:06,1.8x,详细:统计面板
|
||||
8,04:12,04:50,01:20,1.5x,等级预览周期表
|
||||
9,04:52,05:30,01:33,2x,编辑器:物品/等级
|
||||
10,05:32,06:10,01:50,2x,编辑器:周期表配色
|
||||
11,06:12,06:40,02:02,2x,设置:MOD/档案
|
||||
12,09:40,10:10,02:10,2x,编辑器补拍
|
||||
13,11:15,11:40,02:16,2x,DeepSeek 用量
|
||||
14,12:00,12:30,02:22,2x,API 文档
|
||||
15,13:40,14:20,02:29,1.5x,对话流式 + 🎲
|
||||
16,14:22,14:50,02:35,1x,数值反馈
|
||||
17,15:10,15:40,02:41,2x,世界观文档
|
||||
18,16:05,16:40,02:47,1.5x,资料库
|
||||
19,17:00,17:30,02:53,1.5x,音乐/歌词浮窗
|
||||
20,17:45,18:00,02:58,1x,桌宠静帧/片尾
|
||||
|
Reference in New Issue
Block a user