feat(build): 程序图标使用原版素材 logo + 安装器运行/快捷方式选项
- scripts/make_icon.ps1:素材包 pack.png → go-winres 生成 icon.syso (嵌入 exe 图标与版本信息);窗口图标运行时 SetWindowIcon - 安装.bat:桌面快捷方式 [Y/n](默认 Y)、安装后立即运行 [Y/n](默认 Y) - build.ps1 在 syso 缺失时自动生成图标
This commit is contained in:
BIN
cmd/client/icon.png
Normal file
BIN
cmd/client/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
cmd/client/icon.syso
Normal file
BIN
cmd/client/icon.syso
Normal file
Binary file not shown.
25
cmd/client/winres.json
Normal file
25
cmd/client/winres.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"RT_GROUP_ICON": {
|
||||
"APP": {
|
||||
"0001": ["icon.png"]
|
||||
}
|
||||
},
|
||||
"RT_VERSION": {
|
||||
"#1": {
|
||||
"0000": {
|
||||
"fixed": {
|
||||
"file_version": "0.1.0.0",
|
||||
"product_version": "0.1.0.0"
|
||||
},
|
||||
"info": {
|
||||
"0409": {
|
||||
"ProductName": "年糕历险记",
|
||||
"FileDescription": "年糕历险记(NianGao Adventure)",
|
||||
"CompanyName": "NianGao Dev",
|
||||
"OriginalFilename": "mc-client.exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,11 @@ if (-not $Release) { $tags = "$tags dev" }
|
||||
Push-Location $root
|
||||
try {
|
||||
New-Item -ItemType Directory -Force -Path bin | Out-Null
|
||||
# exe 图标(原版素材 logo):缺失时自动生成 .syso(make_icon.ps1)
|
||||
if (-not (Test-Path (Join-Path $root "cmd\client\icon.syso"))) {
|
||||
& (Join-Path $PSScriptRoot "make_icon.ps1")
|
||||
if ($LASTEXITCODE -ne 0) { throw "图标生成失败(make_icon.ps1)" }
|
||||
}
|
||||
go build -tags $tags -trimpath -ldflags "-s -w" -o bin/mc-client.exe ./cmd/client
|
||||
go build -trimpath -ldflags "-s -w" -o bin/mc-server.exe ./cmd/server
|
||||
|
||||
|
||||
@@ -21,13 +21,30 @@ if not exist "!INSTALL_DIR!" mkdir "!INSTALL_DIR!"
|
||||
echo 复制游戏文件...
|
||||
xcopy /e /i /y "%~dp0*" "!INSTALL_DIR!\" >nul 2>&1
|
||||
|
||||
echo 创建桌面快捷方式...
|
||||
powershell -NoProfile -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut([Environment]::GetFolderPath('Desktop') + '\年糕历险记.lnk'); $s.TargetPath = '!INSTALL_DIR!\mc-client.exe'; $s.WorkingDirectory = '!INSTALL_DIR!'; $s.Save()"
|
||||
rem 选项 1:创建桌面快捷方式(默认选中 Y)
|
||||
set "MAKE_LNK=Y"
|
||||
set /p "MAKE_LNK=是否创建桌面快捷方式 [Y/n](默认 Y):"
|
||||
if /i "!MAKE_LNK!"=="" set "MAKE_LNK=Y"
|
||||
if /i "!MAKE_LNK!"=="y" (
|
||||
echo 创建桌面快捷方式...
|
||||
powershell -NoProfile -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut([Environment]::GetFolderPath('Desktop') + '\年糕历险记.lnk'); $s.TargetPath = '!INSTALL_DIR!\mc-client.exe'; $s.WorkingDirectory = '!INSTALL_DIR!'; $s.IconLocation = '!INSTALL_DIR!\mc-client.exe,0'; $s.Save()"
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ============================================
|
||||
echo 安装完成!桌面已创建「年糕历险记」快捷方式。
|
||||
echo 安装完成!
|
||||
echo 游戏存档保存在安装目录 worlds\ 下。
|
||||
echo 按任意键退出...
|
||||
echo ============================================
|
||||
|
||||
rem 选项 2:安装完成后是否立即运行(默认选中 Y)
|
||||
set "RUN_NOW=Y"
|
||||
set /p "RUN_NOW=是否立即运行游戏 [Y/n](默认 Y):"
|
||||
if /i "!RUN_NOW!"=="" set "RUN_NOW=Y"
|
||||
if /i "!RUN_NOW!"=="y" (
|
||||
echo 正在启动游戏...
|
||||
start "" /D "!INSTALL_DIR!" "!INSTALL_DIR!\mc-client.exe"
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 按任意键退出...
|
||||
pause >nul
|
||||
|
||||
28
scripts/make_icon.ps1
Normal file
28
scripts/make_icon.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
# 年糕历险记 —— 程序图标生成(构建与发布.md §8:exe/窗口使用原版素材 logo)
|
||||
# 用法:pwsh -File scripts/make_icon.ps1
|
||||
# 流程:素材包 pack.png → cmd/client/icon.png → go-winres 生成 cmd/client/icon.syso
|
||||
# (资源目录树格式,Go 链接器自动嵌入 exe;资源管理器/任务栏/快捷方式显示图标)。
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = Split-Path $PSScriptRoot -Parent
|
||||
|
||||
# 1) 定位素材包 pack.png(原版 logo,高优先级包在前)→ 复制为 icon.png
|
||||
$png = $null
|
||||
foreach ($dir in Get-ChildItem (Join-Path $root "resourcepacks") -Directory -ErrorAction SilentlyContinue) {
|
||||
$cand = Join-Path $dir.FullName "pack.png"
|
||||
if (Test-Path $cand) { $png = $cand; break }
|
||||
}
|
||||
if (-not $png) { throw "未找到素材包 pack.png(resourcepacks/*/pack.png)" }
|
||||
Copy-Item $png (Join-Path $root "cmd\client\icon.png") -Force
|
||||
Write-Host "== 图标来源:$png =="
|
||||
|
||||
# 2) go-winres 生成 .syso(多尺寸图标组 + 版本资源;winres.json 引用 icon.png)
|
||||
$env:GOCACHE = Join-Path $root ".gocache"
|
||||
Push-Location (Join-Path $root "cmd\client")
|
||||
try {
|
||||
go run github.com/tc-hib/go-winres@latest make --in winres.json --out icon --arch amd64 --no-suffix
|
||||
if ($LASTEXITCODE -ne 0) { throw "go-winres 生成失败" }
|
||||
Move-Item -Force (Join-Path (Get-Location) "icon") (Join-Path (Get-Location) "icon.syso")
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
Write-Host "== 图标资源已嵌入:cmd/client/icon.syso =="
|
||||
@@ -33,7 +33,8 @@ Copy-Item (Join-Path $PSScriptRoot "installer\安装.bat") (Join-Path $stage "
|
||||
年糕历险记 v$Version
|
||||
====================
|
||||
|
||||
安装:双击 安装.bat(选择安装目录,自动创建桌面快捷方式)。
|
||||
安装:双击 安装.bat(选择安装目录,可选创建桌面快捷方式,默认创建;
|
||||
安装完成后可选立即运行游戏,默认运行)。
|
||||
卸载:删除安装目录即可(存档保存在安装目录 worlds/ 下)。
|
||||
|
||||
素材包/光影包:解压到 mods/ 目录(原生 Minecraft 资源包格式直接支持)。
|
||||
|
||||
@@ -77,9 +77,10 @@ mc-v1.2.0/
|
||||
|
||||
- 产品名称:**年糕历险记**(安装包文件名 `年糕历险记-Setup-v<版本>`;产品、快捷方式、卸载项同名)。
|
||||
- **两条交付路径**:
|
||||
1. **便携安装包(当前交付)**:`pwsh scripts/make_installer.ps1` 生成 `dist/年糕历险记-Setup-v<版本>.zip`,解压后运行 `安装.bat`——全中文交互(选择安装目录、复制文件、创建桌面快捷方式「年糕历险记」)。
|
||||
1. **便携安装包(当前交付)**:`pwsh scripts/make_installer.ps1` 生成 `dist/年糕历险记-Setup-v<版本>.zip`,解压后运行 `安装.bat`——全中文交互(选择安装目录、复制文件、可选创建桌面快捷方式「年糕历险记」默认选中、安装完成后可选立即运行游戏默认选中)。
|
||||
2. **NSIS 正式安装器(发布时)**:`scripts/installer.nsi`(简体中文界面、开始菜单、卸载器),需发布环境安装 NSIS 3:`makensis /DVERSION=<版本> scripts/installer.nsi`。
|
||||
- 安装内容:`mc-client.exe`、`mc-server.exe`、`config/`、`mods/`(README)、`resourcepacks/`(默认素材包)。
|
||||
- **程序图标(exe/窗口/快捷方式)**:使用素材包原版 logo(`resourcepacks/*/pack.png`)。`scripts/make_icon.ps1` 生成 `cmd/client/icon.syso`(go-winres 资源目录树格式,Go 链接器自动嵌入 exe 图标与版本信息);窗口图标运行时读取 pack.png 经 `render.SetWindowIcon` 设置。`build.ps1` 在 syso 缺失时自动调用 make_icon.ps1。
|
||||
- 中文要求:安装脚本全中文;游戏内 `lang/zh_cn.json` 随安装包提供;缺失翻译键回退 en_us。
|
||||
- 存档位置:安装目录 `worlds/`(便携式;NSIS 版卸载时保留存档)。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user