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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: Validate XML
run: make validate

- name: Check translations
run: make check-translations

- name: Build catalog
run: make build

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ Thumbs.db
# Python
__pycache__/
*.pyc
.pytest_cache/
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build clean validate test all schemas schema-validate lint
.PHONY: build clean validate test all schemas schema-validate lint check-translations

DIST := dist
SRC := src
Expand All @@ -21,14 +21,17 @@ endif
uv run x4cat extract "$(X4_GAME_DIR)" -o $(SCHEMAS) -g '*.xsd'
@echo "Schemas extracted to $(SCHEMAS)/"

schema-validate:
uv run pytest tests/test_mod.py::TestSchema -q

lint:
ifndef X4_GAME_DIR
$(error X4_GAME_DIR not set — e.g. make lint X4_GAME_DIR="/path/to/X4 Foundations")
endif
uv run x4cat validate-diff "$(X4_GAME_DIR)" $(SRC)

schema-validate:
uv run pytest tests/test_mod.py::TestSchema -q
check-translations:
uv run x4cat validate-translations $(SRC)

validate:
uv run pytest tests/test_mod.py::TestValidate -q
Expand Down
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Proof of concept [X4: Foundations](https://wiki.egosoft.com/X4%20Foundations%20Wiki/Modding%20Support/) extension mod template.

Uses [x4cat](https://github.com/meethune/x4cat) to pack mod files into `.cat/.dat` catalogs and validate diff patches.
Uses [x4cat](https://github.com/meethune/x4cat) to pack mod files into `.cat/.dat` catalogs, generate and validate diff patches, and manage translations. See the [x4cat documentation](https://meethune.github.io/x4cat/) for full reference.

## Structure

Expand All @@ -13,6 +13,8 @@ src/ — Mod files (packed into catalog)
aiscripts/ — AI behavior scripts
libraries/ — Library XML diff patches
dist/ — Build output (do not commit)
base/ — Extracted base files for xmldiff workflow (do not commit)
modified/ — Modified files for xmldiff workflow (do not commit)
schemas/ — XSD schemas extracted from game (do not commit)
tests/ — Build validation tests
```
Expand Down Expand Up @@ -47,18 +49,33 @@ x4cat xmldiff --base ./base/libraries/wares.xml \
# 4. Validate your patches against the game
make lint X4_GAME_DIR="/path/to/X4 Foundations"

# 5. Build and test
# 5. Validate translations
make check-translations

# 6. Build and test
make all
```

Or use scaffolding to generate boilerplate:

```bash
# Scaffold a new ware
x4cat scaffold ware --id mymod_fuel --name "Super Fuel" --price-avg 500 -o src/

# Scaffold equipment by cloning an existing asset
x4cat scaffold equipment --id mymod_engine_macro --name "Fast Engine" \
--clone-from engine_arg_s_allround_01_mk1_macro -o src/
```

## Build

```bash
make all # validate, build, test
make build # pack src/ into dist/ext_01.cat + copy content.xml
make validate # XML well-formedness + structural checks
make test # full test suite (includes build verification)
make clean # remove dist/
make all # validate, build, test
make build # pack src/ into dist/ext_01.cat + copy content.xml
make validate # XML well-formedness + structural checks
make check-translations # validate text references against t/*.xml
make test # full test suite (includes build verification)
make clean # remove dist/
```

## Diff patch linting
Expand All @@ -70,8 +87,13 @@ the base game files they target:
make lint X4_GAME_DIR="/path/to/X4 Foundations"
```

Reports mismatches with file path, line number, and the failing XPath.
Skipped gracefully when no diff patches exist in `src/`.
## Conflict checking

Check your mod against another mod for overlapping diff patches:

```bash
x4cat check-conflicts src/ /path/to/other_mod/src/
```

## Schema validation

Expand Down
Empty file added src/libraries/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading