|
| 1 | +# Contributing to RitsuLib |
| 2 | + |
| 3 | +[中文](CONTRIBUTING.zh.md) |
| 4 | + |
| 5 | +Bug reports, fixes, reusable APIs, documentation, and translations are all welcome. Keep each contribution focused on |
| 6 | +a single clear problem or use case. |
| 7 | + |
| 8 | +## Issues and feature requests |
| 9 | + |
| 10 | +Search existing issues first, then use the repository's issue templates. For bugs, include the game and RitsuLib versions, relevant mods, reproduction steps, expected behavior, and logs. |
| 11 | +Runtime logs are in `logs/godot.log` under the game's user data directory: |
| 12 | + |
| 13 | +- Windows: `%AppData%\SlayTheSpire2\logs\godot.log` |
| 14 | +- macOS: `~/Library/Application Support/SlayTheSpire2/logs/godot.log` |
| 15 | +- Linux: `~/.local/share/SlayTheSpire2/logs/godot.log` |
| 16 | + |
| 17 | +Remove sensitive information before sharing them. |
| 18 | + |
| 19 | +Before adding an API or making substantial changes, describe the consuming mod's needs and discuss the proposed |
| 20 | +behavior with maintainers. |
| 21 | + |
| 22 | +## Development setup |
| 23 | + |
| 24 | +You'll need: |
| 25 | + |
| 26 | +- a .NET SDK supporting `net9.0`; |
| 27 | +- Node.js and npm, for the bundled log viewer; |
| 28 | +- game assemblies matching the API target. |
| 29 | + |
| 30 | +Open `STS2-RitsuLib.sln` in Rider (or Visual Studio with ReSharper) to use the repository's formatting and |
| 31 | +inspections. |
| 32 | + |
| 33 | +The project finds local game installations automatically. To point it at specific paths, create a `local.props` based |
| 34 | +on [local.props.template](local.props.template): |
| 35 | + |
| 36 | +- `Sts2Dir`: game installation directory for local testing. |
| 37 | +- `Sts2ApiSignatureRoot`: optional root for versioned API signatures. Each `<root>/<Sts2ApiCompat>/` folder must contain |
| 38 | + `sts2.dll`, `0Harmony.dll`, and `SmartFormat.dll`. Omit this property to reference the installed game. |
| 39 | + |
| 40 | +Close the game, then run the following from the repository root: |
| 41 | + |
| 42 | +```powershell |
| 43 | +dotnet build STS2-RitsuLib.sln |
| 44 | +``` |
| 45 | + |
| 46 | +The default build generates the manifest, builds the viewer, and installs RitsuLib into |
| 47 | +`<Sts2Dir>/mods/STS2-RitsuLib/`, replacing an existing variant pack with the local single-API build. RitsuLib is a |
| 48 | +DLL-only mod and does not require PCK export. |
| 49 | + |
| 50 | +## Code and API design |
| 51 | + |
| 52 | +Follow [.editorconfig](.editorconfig) and the surrounding code. Keep identifiers and implementation comments in |
| 53 | +English, and use localization for translated UI text. Implement game behavior through mod-owned code, patches, and |
| 54 | +resources; treat game files and recovered source as read-only references. |
| 55 | + |
| 56 | +Public and protected APIs are long-term compatibility commitments. Add APIs for concrete consumer needs and preserve |
| 57 | +existing source and binary compatibility. Provide English and Chinese XML documentation covering usage, inputs, |
| 58 | +outputs, and any lifecycle or ownership requirements. |
| 59 | + |
| 60 | +Validate inputs and define failure behavior. For shared APIs, account for multiple mods, repeated calls, and resource |
| 61 | +lifetime. Make registration conflicts and callback ordering explicit. |
| 62 | + |
| 63 | +## Validation |
| 64 | + |
| 65 | +Format changed C# files with the repository-configured ReSharper formatter and resolve all inspection findings. |
| 66 | +Verify the build, verify the affected behavior in the game, and check the logs. For public API changes, also build and |
| 67 | +test a consuming mod. Bug fixes should cover the original reproduction and relevant edge cases. |
| 68 | + |
| 69 | +Changes affecting game API compatibility or package/manifest generation require sequential builds of all |
| 70 | +`RitsuLibCompatTargets` declared in [STS2-RitsuLib.csproj](STS2-RitsuLib.csproj). Select each target with |
| 71 | +`/p:Sts2ApiCompat=<version>` and provide matching reference assemblies. Only the latest API target installs into the |
| 72 | +game directory. |
| 73 | + |
| 74 | +For documentation changes, check links, examples, and consistency between languages. For documentation-site changes, |
| 75 | +use the tool versions in [docs/package.json](docs/package.json) and [the docs workflow](.github/workflows/gh-pages.yml), |
| 76 | +then run from `docs/`: |
| 77 | + |
| 78 | +```powershell |
| 79 | +pnpm install --frozen-lockfile |
| 80 | +pnpm build |
| 81 | +``` |
| 82 | + |
| 83 | +Preview the affected pages to check layout and navigation. |
| 84 | + |
| 85 | +## Pull requests |
| 86 | + |
| 87 | +Prefer `dev` as the PR merge target (base branch), unless maintainers specify another target. |
| 88 | + |
| 89 | +Use [the PR template](.github/PULL_REQUEST_TEMPLATE.md) to explain the problem, the resulting behavior, and validation. |
| 90 | +Include examples or screenshots where they help reviewers. State which game/API versions were tested and be honest |
| 91 | +about checks you haven't finished. |
| 92 | + |
| 93 | +Keep changes focused and update the corresponding English and Chinese documentation together. Leave local |
| 94 | +configuration, game binaries, and generated output out of the diff. Coordinate version and release metadata changes |
| 95 | +with maintainers. |
0 commit comments