Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,12 @@ if(BETTERSPRAY_BUILD_TESTS)
enable_testing()
include(cmake/Tests.cmake)
endif()

# The aggregate solution owns its single LaunchGame target.
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
option(METAHOOKSV_ENABLE_LAUNCH_GAME "Add the Visual Studio build/deploy/debug target" OFF)
if(METAHOOKSV_ENABLE_LAUNCH_GAME)
include(cmake/LaunchGame.cmake)
metahooksv_add_launch_game()
endif()
endif()
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,21 @@ description `!Spray`; see [Features](docs/en/features.md).
- [gamedata](docs/en/gamedata.md)
- [CI/CD](docs/en/ci-cd.md)

## F5 debugging (optional)

Install MetaHook and enable this plugin in the game's `plugins.lst` first. Configure a standalone Visual Studio Win32 solution:

```powershell
cmake -S . -B build/launch -G "Visual Studio 17 2022" -A Win32 -DMETAHOOKSV_ENABLE_LAUNCH_GAME=ON
```

Open the solution, select **LaunchGame** and press **F5**. **DeployGame** builds this plugin and its dependencies, stages Install, and copies plugin DLLs/PDBs/resources before the native debugger starts the existing game launcher. Root launchers/runtime files and plugin lists remain unchanged. Set VS to build before running and **Do not launch** on build errors; stop the game before redeploying. Ordinary builds do not deploy.

`METAHOOKSV_GAME_DIRECTORY` defaults to Steam discovery; `METAHOOKSV_GAME_APPID` defaults to `225840`. Set `METAHOOKSV_GAME_MOD` for a custom mod and `METAHOOKSV_GAME_ARGUMENTS` for extra arguments. Debug and Release are supported.

The shared module uses `METAHOOKSV_LAUNCH_GAME_MODULE_DIR`, the surrounding MetaHookSv checkout, or a pinned source archive. Without Installer sources, it downloads the self-contained CLI from GitHub `latest` (no .NET required); `METAHOOKSV_INSTALLER_RELEASE` selects a fixed tag, and `METAHOOKSV_INSTALLER_CLI_EXECUTABLE` supplies an offline EXE. Plugin mode requires v20261004c or later. Valid caches under `build/launch/launch-game/installer/<release>` are reused without update checks; select another tag or clear that private cache to upgrade. `GH_TOKEN`/`GITHUB_TOKEN` may be supplied through the environment if GitHub API rate limits prevent the first download. The feature defaults OFF and performs no extra downloads when disabled.

## License

BetterSpray is available under the MIT License; see `LICENSE`. Bundled third-party
sources keep their own license files.
sources keep their own license files.
16 changes: 15 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ BetterSpray 是喷漆增强插件,支持将WAD喷漆替换成透明通道的
- [gamedata](docs/zh-CN/gamedata.md)
- [自动化构建与发布](docs/zh-CN/ci-cd.md)

## F5 调试(可选)

先安装 MetaHook,并在游戏的 `plugins.lst` 中启用本插件,然后配置独立的 Visual Studio Win32 解决方案:

```powershell
cmake -S . -B build/launch -G "Visual Studio 17 2022" -A Win32 -DMETAHOOKSV_ENABLE_LAUNCH_GAME=ON
```

打开解决方案,选择 **LaunchGame** 后按 **F5**。**DeployGame** 编译本插件及依赖,暂存 Install,再复制插件 DLL、PDB 和资源,最后由原生调试器启动已有游戏 launcher。不会修改根目录启动器/运行库或插件列表。VS 应开启运行前构建,并将构建失败策略设为 **不启动**;重新部署前请退出游戏。普通构建不会部署。

`METAHOOKSV_GAME_DIRECTORY` 默认通过 Steam 自动查找,`METAHOOKSV_GAME_APPID` 默认为 `225840`。自定义 mod 使用 `METAHOOKSV_GAME_MOD`,附加参数使用 `METAHOOKSV_GAME_ARGUMENTS`;支持 Debug 和 Release。

共享模块依次从 `METAHOOKSV_LAUNCH_GAME_MODULE_DIR`、所在 MetaHookSv 聚合仓库或固定提交的源码包获取。缺少 Installer 源码时自动下载 GitHub `latest` 的自包含 CLI,无需安装 .NET;可用 `METAHOOKSV_INSTALLER_RELEASE` 固定 tag,或用 `METAHOOKSV_INSTALLER_CLI_EXECUTABLE` 指定离线 EXE。插件模式要求 v20261004c 或之后版本。`build/launch/launch-game/installer/<release>` 下的有效缓存直接复用,不自动升级;切换 tag 或清理该私有缓存后重新下载。首次下载若触发 GitHub API 限流,可通过环境变量 `GH_TOKEN`/`GITHUB_TOKEN` 提供凭据。功能默认 OFF,关闭时不新增下载。

## License

BetterSpray 采用 MIT License,见 `LICENSE`。随附的第三方源码保留各自的许可证文件。
BetterSpray 采用 MIT License,见 `LICENSE`。随附的第三方源码保留各自的许可证文件。
24 changes: 24 additions & 0 deletions cmake/LaunchGame.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Shared implementation: explicit override, surrounding aggregator, pinned archive.
set(METAHOOKSV_LAUNCH_GAME_MODULE_DIR "" CACHE PATH "Directory containing the shared LaunchGame.cmake module")
if(METAHOOKSV_LAUNCH_GAME_MODULE_DIR)
set(_launch_module_dir "${METAHOOKSV_LAUNCH_GAME_MODULE_DIR}")
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../../cmake/LaunchGame.cmake")
get_filename_component(_launch_module_dir "${CMAKE_CURRENT_LIST_DIR}/../../../cmake" ABSOLUTE)
else()
include(FetchContent)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
FetchContent_Declare(metahooksv_launch_module
URL https://github.com/hzqst/MetaHookSv/archive/5fec6043b590ce10cbdfd6d5416c7274be531117.tar.gz
TLS_VERIFY ON
# Populate only the modules; never configure the aggregate native project.
SOURCE_SUBDIR cmake)
FetchContent_MakeAvailable(metahooksv_launch_module)
set(_launch_module_dir "${metahooksv_launch_module_SOURCE_DIR}/cmake")
endif()
if(NOT EXISTS "${_launch_module_dir}/LaunchGame.cmake")
message(FATAL_ERROR "METAHOOKSV_LAUNCH_GAME_MODULE_DIR must contain LaunchGame.cmake: ${_launch_module_dir}")
endif()
include("${_launch_module_dir}/LaunchGame.cmake")
unset(_launch_module_dir)