diff --git a/.github/workflows/ci-win7.yml b/.github/workflows/ci-win7.yml
new file mode 100644
index 0000000..1ce6e37
--- /dev/null
+++ b/.github/workflows/ci-win7.yml
@@ -0,0 +1,38 @@
+name: CI Windows 7
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+
+concurrency:
+ group: ci-win7-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ tui:
+ name: terminal version (win7 target tests, build, import check)
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
+ with:
+ persist-credentials: false
+ # dtolnay/rust-toolchain; keep the toolchain in step with tools/win7.mjs.
+ - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87
+ with:
+ toolchain: nightly-2026-11-17
+ components: rust-src, llvm-tools
+ - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
+ - uses: actions/setup-node@v4
+ - run: npm run check:win7
+ - run: npm run build:win7 -- --out .
+ - name: Upload Windows 7 build
+ # v4
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: windows7-tui
+ path: dw4-crown-mod-*-windows7-x86_64.zip
+ if-no-files-found: error
diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml
new file mode 100644
index 0000000..1c23fd2
--- /dev/null
+++ b/.github/workflows/release-win7.yml
@@ -0,0 +1,50 @@
+name: Release Windows 7
+
+on:
+ workflow_call:
+ inputs:
+ release_tag:
+ required: true
+ type: string
+
+permissions:
+ # Build-only reusable workflow; the caller publishes every platform together.
+ contents: read
+
+jobs:
+ build:
+ name: Build Windows 7 terminal version (zip)
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
+ with:
+ persist-credentials: false
+ # dtolnay/rust-toolchain; keep the toolchain in step with tools/win7.mjs.
+ - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87
+ with:
+ toolchain: nightly-2026-11-17
+ components: rust-src, llvm-tools
+ - uses: actions/setup-node@v4
+ - name: Prepare version-checked release notes
+ shell: pwsh
+ env:
+ RELEASE_TAG: ${{ inputs.release_tag }}
+ run: node tools/release-notes.mjs --tag "$env:RELEASE_TAG" --output release-notes.md
+ - name: Verify application source matches the release tag
+ shell: pwsh
+ env:
+ RELEASE_TAG: ${{ inputs.release_tag }}
+ run: |
+ git fetch --depth 1 origin "refs/tags/$env:RELEASE_TAG"
+ if ($LASTEXITCODE -ne 0) { throw "Release tag was not found" }
+ git diff --exit-code FETCH_HEAD -- crates src public Cargo.toml Cargo.lock package.json package-lock.json
+ if ($LASTEXITCODE -ne 0) { throw "Application source differs from the release tag" }
+ - name: Build, check imports and package (zip)
+ run: npm run build:win7 -- --out .
+ - name: Upload Windows 7 assets
+ # v4
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: win7-assets
+ path: dw4-crown-mod-*-windows7-x86_64.zip
+ if-no-files-found: error
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a10cd5b..961bed4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -26,9 +26,13 @@ jobs:
uses: ./.github/workflows/release-linux.yml
with:
release_tag: ${{ inputs.tag || github.ref_name }}
+ win7:
+ uses: ./.github/workflows/release-win7.yml
+ with:
+ release_tag: ${{ inputs.tag || github.ref_name }}
publish:
name: Publish complete release
- needs: [windows, linux]
+ needs: [windows, linux, win7]
runs-on: ubuntu-latest
permissions:
contents: write
@@ -54,6 +58,7 @@ jobs:
for file in \
"dw4-crown-mod-${RELEASE_TAG}-windows-x86_64.zip" \
"dw4-crown-mod-${version}-windows-x86_64.msi" \
+ "dw4-crown-mod-${RELEASE_TAG}-windows7-x86_64.zip" \
"dw4-crown-mod-${RELEASE_TAG}-linux-x86_64.AppImage" \
"dw4-crown-mod-${RELEASE_TAG}-linux-x86_64.deb" \
"dw4-crown-mod-${RELEASE_TAG}-linux-x86_64.tar.gz"; do
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14b04e6..2e05244 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## v0.21.0
+
+- Added a terminal version for **Windows 7 and later** (`dw4-crown-mod-v0.21.0-windows7-x86_64.zip`): the same patcher in a console window, for PCs that can't run the desktop app. Unzip it, then double-click `dw4-crown-mod-tui.exe` or drag your disc image onto it. It has every option, and it can load and save the same settings files as the desktop app.
+
## v0.20.0
- Random bosses now also shuffles the repeat boss fights (Blossomon in Abyss of Grief, SkullGreymon in Grief Wasteland, ShogunGekomon in Mangrove Forest) and the Quest 1, 4, 7 and 8 bosses. Only the four world bosses stay fixed.
diff --git a/Cargo.lock b/Cargo.lock
index c962b85..61f500d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,6 +2,12 @@
# It is not intended for manual editing.
version = 4
+[[package]]
+name = "allocator-api2"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
+
[[package]]
name = "bitflags"
version = "2.13.2"
@@ -17,6 +23,21 @@ dependencies = [
"generic-array",
]
+[[package]]
+name = "cassowary"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
+
+[[package]]
+name = "castaway"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
+dependencies = [
+ "rustversion",
+]
+
[[package]]
name = "cc"
version = "1.8.0"
@@ -35,6 +56,20 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
+[[package]]
+name = "compact_str"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fd622ebbb56a5b2ccb651b32b911cdeb2a9b4b11776b2473bf26a26a286244e"
+dependencies = [
+ "castaway",
+ "cfg-if",
+ "itoa",
+ "rustversion",
+ "ryu",
+ "static_assertions",
+]
+
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -44,6 +79,31 @@ dependencies = [
"libc",
]
+[[package]]
+name = "crossterm"
+version = "0.28.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
+dependencies = [
+ "bitflags",
+ "crossterm_winapi",
+ "mio",
+ "parking_lot",
+ "rustix 0.38.44",
+ "signal-hook",
+ "signal-hook-mio",
+ "winapi",
+]
+
+[[package]]
+name = "crossterm_winapi"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
+dependencies = [
+ "winapi",
+]
+
[[package]]
name = "crypto-common"
version = "0.1.7"
@@ -54,6 +114,40 @@ dependencies = [
"typenum",
]
+[[package]]
+name = "darling"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"
+dependencies = [
+ "darling_core",
+ "darling_macro",
+]
+
+[[package]]
+name = "darling_core"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"
+dependencies = [
+ "ident_case",
+ "proc-macro2",
+ "quote",
+ "strsim",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "darling_macro"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
+dependencies = [
+ "darling_core",
+ "quote",
+ "syn 3.0.6",
+]
+
[[package]]
name = "digest"
version = "0.10.7"
@@ -66,7 +160,7 @@ dependencies = [
[[package]]
name = "dw4vhp-core"
-version = "0.20.0"
+version = "0.21.0"
dependencies = [
"fs4",
"getrandom",
@@ -81,6 +175,27 @@ dependencies = [
"zstd",
]
+[[package]]
+name = "dw4vhp-tui"
+version = "0.21.0"
+dependencies = [
+ "dw4vhp-core",
+ "getrandom",
+ "ratatui",
+]
+
+[[package]]
+name = "either"
+version = "1.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
+
+[[package]]
+name = "equivalent"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
+
[[package]]
name = "errno"
version = "0.3.14"
@@ -88,7 +203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -103,14 +218,20 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
+[[package]]
+name = "foldhash"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
+
[[package]]
name = "fs4"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e72ed92b67c146290f88e9c89d60ca163ea417a446f61ffd7b72df3e7f1dfd5"
dependencies = [
- "rustix",
- "windows-sys",
+ "rustix 1.1.5",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -134,6 +255,60 @@ dependencies = [
"r-efi",
]
+[[package]]
+name = "hashbrown"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
+dependencies = [
+ "allocator-api2",
+ "equivalent",
+ "foldhash",
+]
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "ident_case"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
+
+[[package]]
+name = "indoc"
+version = "2.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
+dependencies = [
+ "rustversion",
+]
+
+[[package]]
+name = "instability"
+version = "0.3.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20"
+dependencies = [
+ "darling",
+ "indoc",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "itertools"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
+dependencies = [
+ "either",
+]
+
[[package]]
name = "itoa"
version = "1.0.18"
@@ -156,12 +331,42 @@ version = "0.2.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
+
[[package]]
name = "linux-raw-sys"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
+[[package]]
+name = "lock_api"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
+dependencies = [
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
+
+[[package]]
+name = "lru"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
+dependencies = [
+ "hashbrown",
+]
+
[[package]]
name = "md-5"
version = "0.10.6"
@@ -187,12 +392,53 @@ dependencies = [
"libc",
]
+[[package]]
+name = "mio"
+version = "1.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"
+dependencies = [
+ "libc",
+ "log",
+ "wasi",
+ "windows-sys 0.61.2",
+]
+
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+[[package]]
+name = "parking_lot"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-link",
+]
+
+[[package]]
+name = "paste"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+
[[package]]
name = "pkg-config"
version = "0.3.34"
@@ -223,6 +469,49 @@ version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+[[package]]
+name = "ratatui"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
+dependencies = [
+ "bitflags",
+ "cassowary",
+ "compact_str",
+ "crossterm",
+ "indoc",
+ "instability",
+ "itertools",
+ "lru",
+ "paste",
+ "strum",
+ "unicode-segmentation",
+ "unicode-truncate",
+ "unicode-width 0.2.0",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.5.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "rustix"
+version = "0.38.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys 0.4.15",
+ "windows-sys 0.59.0",
+]
+
[[package]]
name = "rustix"
version = "1.1.5"
@@ -232,10 +521,28 @@ dependencies = [
"bitflags",
"errno",
"libc",
- "linux-raw-sys",
- "windows-sys",
+ "linux-raw-sys 0.12.1",
+ "windows-sys 0.61.2",
]
+[[package]]
+name = "rustversion"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
+
+[[package]]
+name = "ryu"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
[[package]]
name = "serde"
version = "1.0.229"
@@ -263,7 +570,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 3.0.6",
]
[[package]]
@@ -296,6 +603,88 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+[[package]]
+name = "signal-hook"
+version = "0.3.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
+dependencies = [
+ "libc",
+ "signal-hook-registry",
+]
+
+[[package]]
+name = "signal-hook-mio"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc"
+dependencies = [
+ "libc",
+ "mio",
+ "signal-hook",
+]
+
+[[package]]
+name = "signal-hook-registry"
+version = "1.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
+dependencies = [
+ "errno",
+ "libc",
+]
+
+[[package]]
+name = "smallvec"
+version = "1.16.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46"
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "strum"
+version = "0.26.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
+dependencies = [
+ "strum_macros",
+]
+
+[[package]]
+name = "strum_macros"
+version = "0.26.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
[[package]]
name = "syn"
version = "3.0.6"
@@ -316,8 +705,8 @@ dependencies = [
"fastrand",
"getrandom",
"once_cell",
- "rustix",
- "windows-sys",
+ "rustix 1.1.5",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -337,7 +726,7 @@ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 3.0.6",
]
[[package]]
@@ -352,18 +741,84 @@ version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
+[[package]]
+name = "unicode-segmentation"
+version = "1.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
+
+[[package]]
+name = "unicode-truncate"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
+dependencies = [
+ "itertools",
+ "unicode-segmentation",
+ "unicode-width 0.1.14",
+]
+
+[[package]]
+name = "unicode-width"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
+
+[[package]]
+name = "unicode-width"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
+
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+[[package]]
+name = "wasi"
+version = "0.11.1+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+[[package]]
+name = "windows-sys"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
+dependencies = [
+ "windows-targets",
+]
+
[[package]]
name = "windows-sys"
version = "0.61.2"
@@ -373,6 +828,70 @@ dependencies = [
"windows-link",
]
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
[[package]]
name = "zmij"
version = "1.0.23"
diff --git a/Cargo.toml b/Cargo.toml
index 520938f..3ee3e1e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
-members = ["crates/dw4vhp-core"]
+members = ["crates/dw4vhp-core", "crates/dw4vhp-tui"]
# webkit2gtk-4.1 is not available in every build environment, and a member that
# cannot compile would break the whole workspace gate. CI (or a developer host)
# builds this crate in a job that installs the system dependencies.
diff --git a/README.md b/README.md
index 33a53c5..0d31a15 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,12 @@
# Digimon World 4 Crown Mod & Enemy Randomiser
DW4 Crown Mod is a mod patcher and seeded enemy randomiser for **Digimon World 4**
-on **PlayStation 2 (PS2)** and **GameCube**, available for **Windows and Linux**.
+on **PlayStation 2 (PS2)** and **GameCube**, available for **Windows and Linux**,
+with a terminal version for **Windows 7**.
[](https://github.com/crashbashash/DW4_Crown_Mod/actions/workflows/ci-linux.yml)
[](https://github.com/crashbashash/DW4_Crown_Mod/actions/workflows/ci-windows.yml)
+[](https://github.com/crashbashash/DW4_Crown_Mod/actions/workflows/ci-win7.yml)
[](https://github.com/crashbashash/DW4_Crown_Mod/actions/workflows/release.yml)
@@ -17,7 +19,7 @@ Open the app and choose your own copy of the game to create a new, modded copy.
## Quick start
-1. [Download the app](#download) for Windows or Linux.
+1. [Download the app](#download) for Windows or Linux. On Windows 7, use the [terminal version](#windows-7).
2. Open it and choose your game disc image (`.iso`, or `.ciso` / `.rvz` for GameCube).
3. Select at least one option in Settings (grouped into Gameplay, Balance, Cosmetics and Bugfixes tabs). Choose **Random enemies** alone for the original balance, or enable **Crown Mod** for stronger enemies and increased rewards. Under Random enemies, optionally enable **Random bosses** on any supported PS2 or GameCube disc; every boss except the four world bosses is shuffled.
4. Click **Patch ISO**.
@@ -82,7 +84,8 @@ The same randomiser seed reproduces enemy choices within the same rules version.
The app detects your release automatically. Existing Crown Mod images can be
updated; unsupported or unrecognised images are refused.
-- Windows or Linux. Nothing else to install.
+- Windows 10 or later, or Linux, for the app; 64-bit Windows 7 SP1 or later for the
+ [terminal version](#windows-7). Nothing else to install.
- About **2.2 GB** of free disk space for the new file (more for `.ciso` and `.rvz`, which are unpacked while patching). The app shows the exact amount.
## Download
@@ -90,10 +93,26 @@ The same randomiser seed reproduces enemy choices within the same rules version.
Get the latest version from the **Releases** page of this project:
- **Windows:** `.msi` installer or a plain `.zip`
+- **Windows 7:** `-windows7-x86_64.zip`, the [terminal version](#windows-7)
- **Linux:** `.AppImage`, `.deb`, or a plain download
The downloads are unsigned, so Windows may show a warning the first time you run it.
+### Windows 7
+
+The desktop app needs Windows 10 or later. The Windows 7 download is the same
+patcher in a console window, with every option and the same settings files.
+
+1. Unzip it, then double-click `dw4-crown-mod-tui.exe`, or drag your disc image onto it.
+2. Type or paste the path to your disc image and press **Enter**. You can also drag
+ the file onto the window, or right-click in it and choose **Paste**.
+3. Move with the arrow keys, turn options on or off with **Space**, and press
+ **Enter** to continue. **L** and **S** load and save a settings file.
+4. Check the output name and press **Enter** to patch.
+
+The terminal version patches clean discs only. To update an existing Crown Mod
+image, patch your original disc again.
+
## Updating the app
The app checks for newer versions at startup and shows their release notes before
diff --git a/crates/dw4vhp-core/Cargo.toml b/crates/dw4vhp-core/Cargo.toml
index 708e4da..1ed6651 100644
--- a/crates/dw4vhp-core/Cargo.toml
+++ b/crates/dw4vhp-core/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "dw4vhp-core"
-version = "0.20.0"
+version = "0.21.0"
edition = "2021"
license = "GPL-3.0-or-later"
description = "Engine for the Digimon World 4 Crown Mod ISO patcher"
diff --git a/crates/dw4vhp-core/src/crown/random/boss.rs b/crates/dw4vhp-core/src/crown/random/boss.rs
index eb5e2f5..7d67ee0 100644
--- a/crates/dw4vhp-core/src/crown/random/boss.rs
+++ b/crates/dw4vhp-core/src/crown/random/boss.rs
@@ -818,10 +818,12 @@ impl Randomiser {
arena.entry,
arena.generators.join(",")
));
- eprintln!(
- "BOSS IMAGE tier {difficulty} {}: {} -> {to}",
- arena.entry, arena.model
- );
+ if std::env::var_os("DW4_RANDOM_LOG").is_some() {
+ eprintln!(
+ "BOSS IMAGE tier {difficulty} {}: {} -> {to}",
+ arena.entry, arena.model
+ );
+ }
bosses.push(json!({"stage": arena.entry, "area": arena.name, "generators": arena.generators,
"original": arena.model, "boss": to, "changed": changed, "patrols": slot.patrols, "patrolFloors": arena.floors}));
tick();
diff --git a/crates/dw4vhp-core/src/error.rs b/crates/dw4vhp-core/src/error.rs
index 733afdc..25c7c36 100644
--- a/crates/dw4vhp-core/src/error.rs
+++ b/crates/dw4vhp-core/src/error.rs
@@ -90,3 +90,16 @@ pub enum Error {
}
pub type Result = std::result::Result;
+
+impl Error {
+ /// The player-facing notice when a chosen disc image is refused.
+ pub fn disc_notice(&self) -> String {
+ match self {
+ Error::AlreadyModded { .. } => "This disc is already modded. Choose a clean, original disc image.".into(),
+ Error::AlreadyCrownMod { version } => format!("This disc is already Crown Mod v{version}. Choose a clean, original disc image."),
+ Error::NotThisDisc | Error::FileNotFound { .. } | Error::ElfNotFound => "This file is not a supported disc image, or it is incomplete. Choose a clean Digimon World 4 or Digimon World X disc from a supported release.".into(),
+ Error::WrongRevision { .. } | Error::CrownData(_) => "This disc image is not a supported original revision. Choose a clean, original copy of a supported release.".into(),
+ _ => self.to_string(),
+ }
+ }
+}
diff --git a/crates/dw4vhp-core/src/lib.rs b/crates/dw4vhp-core/src/lib.rs
index aec7725..49b60c2 100644
--- a/crates/dw4vhp-core/src/lib.rs
+++ b/crates/dw4vhp-core/src/lib.rs
@@ -11,6 +11,7 @@ mod gc_memory;
pub mod gcm;
pub mod iso9660;
pub mod layout;
+pub mod naming;
pub mod options;
pub mod patch;
pub mod plan;
@@ -21,6 +22,7 @@ pub mod region;
pub mod release;
pub mod rowgroup;
pub mod serial;
+pub mod settings;
pub mod signature;
pub mod table;
pub mod testkit;
diff --git a/crates/dw4vhp-core/src/naming.rs b/crates/dw4vhp-core/src/naming.rs
new file mode 100644
index 0000000..feccfaa
--- /dev/null
+++ b/crates/dw4vhp-core/src/naming.rs
@@ -0,0 +1,76 @@
+//! The output name a disc image suggests.
+use crate::container::{detect, Format};
+use std::path::{Path, PathBuf};
+
+/// The marker a patched image's name carries.
+pub const OUTPUT_MARKER: &str = " [CrownMod]";
+
+/// Same directory, stem plus the marker and optional enemy seed
+/// (`game [CrownMod] [Seed 1234].iso`), so the default never targets the input.
+/// Compressed containers keep their format; plain GameCube .gcm keeps its suffix too.
+pub fn default_output(input: &Path, seed: Option) -> PathBuf {
+ let mut name = input
+ .file_stem()
+ .map(|s| s.to_os_string())
+ .unwrap_or_default();
+ name.push(OUTPUT_MARKER);
+ if let Some(seed) = seed {
+ name.push(format!(" [Seed {seed}]"));
+ }
+ let format = detect(input).unwrap_or(Format::Raw);
+ let extension = match format {
+ Format::Raw
+ if input
+ .extension()
+ .is_some_and(|ext| ext.eq_ignore_ascii_case("gcm")) =>
+ {
+ "gcm"
+ }
+ _ => format.extension(),
+ };
+ name.push(format!(".{extension}"));
+ input.with_file_name(name)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn suggested_output_preserves_the_source_container_and_plain_gcm_suffix() {
+ let dir = tempfile::tempdir().unwrap();
+ for (name, magic, suffix) in [
+ ("game.iso", b"raw!", "iso"),
+ ("game.gcm", b"raw!", "gcm"),
+ ("game.GCM", b"raw!", "gcm"),
+ ("game.ciso", b"CISO", "ciso"),
+ ("game.rvz", b"RVZ\x01", "rvz"),
+ // The output suffix follows the bytes when an input is misnamed.
+ ("compressed.iso", b"RVZ\x01", "rvz"),
+ ] {
+ let input = dir.path().join(name);
+ std::fs::write(&input, magic).unwrap();
+ let output = default_output(&input, None);
+ assert_eq!(output.parent(), Some(dir.path()));
+ assert_eq!(output.extension().unwrap(), suffix);
+ assert!(output
+ .file_stem()
+ .unwrap()
+ .to_str()
+ .unwrap()
+ .ends_with(OUTPUT_MARKER));
+ assert_ne!(output, input);
+ }
+ }
+
+ #[test]
+ fn suggested_output_names_the_enemy_seed_after_the_marker() {
+ let dir = tempfile::tempdir().unwrap();
+ let input = dir.path().join("game.iso");
+ std::fs::write(&input, b"raw!").unwrap();
+ assert_eq!(
+ default_output(&input, Some(1234)),
+ dir.path().join("game [CrownMod] [Seed 1234].iso")
+ );
+ }
+}
diff --git a/crates/dw4vhp-core/src/settings.rs b/crates/dw4vhp-core/src/settings.rs
new file mode 100644
index 0000000..0dc5fd2
--- /dev/null
+++ b/crates/dw4vhp-core/src/settings.rs
@@ -0,0 +1,137 @@
+//! Portable settings files: patch options only, never disc or output paths.
+use crate::options::PatchSelection;
+use serde::{Deserialize, Serialize};
+use std::io::Read;
+use std::path::Path;
+
+const FORMAT: &str = "dw4-crown-mod-settings";
+const VERSION: u32 = 1;
+const MAX_BYTES: u64 = 64 * 1024;
+
+#[derive(Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+struct SettingsFile {
+ format: String,
+ version: u32,
+ settings: PatchSelection,
+}
+
+fn validate(settings: PatchSelection) -> Result {
+ if settings.crown_drops && !settings.crown_mod {
+ return Err("Match drops to crowns requires Crown Mod.".into());
+ }
+ if settings.random_bosses && !settings.random_enemies {
+ return Err("Random bosses requires Random enemies.".into());
+ }
+ if settings.random_enemies && settings.enemy_seed.is_none() {
+ return Err("Random enemies requires a valid seed.".into());
+ }
+ Ok(settings)
+}
+
+/// The settings file text for `settings`, refusing dependent options without their parent.
+pub fn encode(settings: PatchSelection) -> Result {
+ let file = SettingsFile {
+ format: FORMAT.into(),
+ version: VERSION,
+ settings: validate(settings)?,
+ };
+ serde_json::to_string_pretty(&file)
+ .map(|json| json + "\n")
+ .map_err(|error| format!("Unable to encode settings: {error}"))
+}
+
+/// Reads and validates a settings file, with player-facing error messages.
+pub fn read(path: &Path) -> Result {
+ let mut bytes = Vec::new();
+ std::fs::File::open(path)
+ .and_then(|file| file.take(MAX_BYTES + 1).read_to_end(&mut bytes))
+ .map_err(|_| "Unable to read the settings file.".to_string())?;
+ if bytes.len() as u64 > MAX_BYTES {
+ return Err("The settings file is too large.".into());
+ }
+ let file: SettingsFile = serde_json::from_slice(&bytes)
+ .map_err(|_| "Invalid settings file. Choose a Crown Mod settings JSON file.".to_string())?;
+ if file.format != FORMAT {
+ return Err("This is not a Crown Mod settings file.".into());
+ }
+ if file.version != VERSION {
+ return Err(
+ "This settings file uses an unsupported version. Update Crown Mod and try again."
+ .into(),
+ );
+ }
+ validate(file.settings)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use serde_json::json;
+
+ #[test]
+ fn settings_round_trip_preserves_all_options_and_seed_without_paths() {
+ let selection = PatchSelection {
+ crown_mod: true,
+ crown_drops: true,
+ four_player_spawns: true,
+ random_crown_colours: true,
+ random_enemies: true,
+ random_bosses: true,
+ enemy_seed: Some(u32::MAX),
+ solo_buttons: true,
+ fix_death_softlock: true,
+ };
+ let encoded = encode(selection).unwrap();
+ let value: serde_json::Value = serde_json::from_str(&encoded).unwrap();
+ assert_eq!(
+ value,
+ json!({"format": FORMAT, "version": VERSION, "settings": selection})
+ );
+ let dir = tempfile::tempdir().unwrap();
+ let path = dir.path().join("settings.json");
+ std::fs::write(&path, encoded).unwrap();
+ assert_eq!(read(&path).unwrap(), selection);
+ assert!(encode(PatchSelection::default()).is_ok());
+ }
+
+ #[test]
+ fn bad_imports_are_rejected_including_paths_and_invalid_dependencies() {
+ let dir = tempfile::tempdir().unwrap();
+ let path = dir.path().join("settings.json");
+ for value in [
+ json!({"format": FORMAT, "version": 2, "settings": {}}),
+ json!({"format": "another-app", "version": 1, "settings": {}}),
+ json!({"format": FORMAT, "version": 1, "settings": {"crownMod": "true"}}),
+ json!({"format": FORMAT, "version": 1, "settings": {"enemySeed": 4294967296u64}}),
+ json!({"format": FORMAT, "version": 1, "settings": {"randomEnemies": true}}),
+ json!({"format": FORMAT, "version": 1, "settings": {"randomBosses": true}}),
+ json!({"format": FORMAT, "version": 1, "settings": {"crownDrops": true}}),
+ json!({"format": FORMAT, "version": 1, "settings": {"inputPath": "game.iso"}}),
+ json!({"format": FORMAT, "version": 1, "settings": {}, "outputPath": "out.iso"}),
+ ] {
+ std::fs::write(&path, value.to_string()).unwrap();
+ assert!(read(&path).is_err(), "{value}");
+ }
+ std::fs::write(&path, "not json").unwrap();
+ assert!(read(&path).is_err());
+ std::fs::write(&path, vec![b' '; MAX_BYTES as usize + 1]).unwrap();
+ assert!(read(&path).unwrap_err().contains("too large"));
+ }
+
+ #[test]
+ fn older_settings_leave_bosses_disabled() {
+ let dir = tempfile::tempdir().unwrap();
+ let path = dir.path().join("settings.json");
+ std::fs::write(
+ &path,
+ json!({"format": FORMAT, "version": 1,
+ "settings": {"randomEnemies": true, "enemySeed": 1520}})
+ .to_string(),
+ )
+ .unwrap();
+ let settings = read(&path).unwrap();
+ assert!(settings.random_enemies);
+ assert!(!settings.random_bosses);
+ }
+}
diff --git a/crates/dw4vhp-tauri/Cargo.lock b/crates/dw4vhp-tauri/Cargo.lock
index bda1d5b..24d7bfc 100644
--- a/crates/dw4vhp-tauri/Cargo.lock
+++ b/crates/dw4vhp-tauri/Cargo.lock
@@ -939,7 +939,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
[[package]]
name = "dw4vhp-core"
-version = "0.20.0"
+version = "0.21.0"
dependencies = [
"fs4",
"getrandom 0.4.3",
@@ -956,7 +956,7 @@ dependencies = [
[[package]]
name = "dw4vhp-tauri"
-version = "0.20.0"
+version = "0.21.0"
dependencies = [
"dw4vhp-core",
"reqwest",
diff --git a/crates/dw4vhp-tauri/Cargo.toml b/crates/dw4vhp-tauri/Cargo.toml
index 5f002af..0328d18 100644
--- a/crates/dw4vhp-tauri/Cargo.toml
+++ b/crates/dw4vhp-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "dw4vhp-tauri"
-version = "0.20.0"
+version = "0.21.0"
edition = "2021"
license = "GPL-3.0-or-later"
description = "Desktop shell for the Digimon World 4 Crown Mod ISO patcher"
diff --git a/crates/dw4vhp-tauri/src/commands.rs b/crates/dw4vhp-tauri/src/commands.rs
index 8068a18..ecaf584 100644
--- a/crates/dw4vhp-tauri/src/commands.rs
+++ b/crates/dw4vhp-tauri/src/commands.rs
@@ -19,9 +19,6 @@ use serde::Serialize;
use std::sync::atomic::Ordering;
use tauri::{AppHandle, Emitter, Manager};
-/// The marker a patched image's name carries (old `form::OUTPUT_SUFFIX`).
-const OUTPUT_MARKER: &str = " [CrownMod]";
-
#[derive(Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DiscStatusPayload {
@@ -200,31 +197,12 @@ pub async fn choose_output(window: tauri::Window, default_name: String) -> Optio
.flatten()
}
-/// The output name an input suggests: same directory, stem plus the marker
-/// (old `form::default_output_path`), so the default never targets the input.
+/// The output name an input suggests; see [`dw4vhp_core::naming::default_output`].
#[tauri::command]
pub fn default_output(input: String) -> String {
- let input = std::path::Path::new(&input);
- let mut name = input
- .file_stem()
- .map(|s| s.to_os_string())
- .unwrap_or_default();
- name.push(OUTPUT_MARKER);
- // Compressed containers keep their format; plain GameCube .gcm keeps its suffix too.
- let format =
- dw4vhp_core::container::detect(input).unwrap_or(dw4vhp_core::container::Format::Raw);
- let extension = match format {
- dw4vhp_core::container::Format::Raw
- if input
- .extension()
- .is_some_and(|ext| ext.eq_ignore_ascii_case("gcm")) =>
- {
- "gcm"
- }
- _ => format.extension(),
- };
- name.push(format!(".{extension}"));
- input.with_file_name(name).display().to_string()
+ dw4vhp_core::naming::default_output(std::path::Path::new(&input), None)
+ .display()
+ .to_string()
}
/// Checks whether patching needs the user's overwrite confirmation.
@@ -251,7 +229,9 @@ fn verdict(result: &Result) -> DiscStatusPayload {
),
reason: None,
mod_metadata: None,
- disc_info: report.release.map(|release| disc_info(release, false, None)),
+ disc_info: report
+ .release
+ .map(|release| disc_info(release, false, None)),
size: report.size,
output_size: report.output_size,
copies: Some(report.copies),
@@ -265,14 +245,12 @@ fn verdict(result: &Result) -> DiscStatusPayload {
| Error::CrownData(_) => "refused",
_ => "unknown",
},
- reason: matches!(error, Error::AlreadyModded { .. } | Error::AlreadyCrownMod { .. }).then_some("already-modded"),
- text: match error {
- Error::AlreadyModded { .. } => "This disc is already modded. Choose a clean, original disc image.".into(),
- Error::AlreadyCrownMod { version } => format!("This disc is already Crown Mod v{version}. Choose a clean, original disc image."),
- Error::NotThisDisc | Error::FileNotFound { .. } | Error::ElfNotFound => "This file is not a supported disc image, or it is incomplete. Choose a clean Digimon World 4 or Digimon World X disc from a supported release.".into(),
- Error::WrongRevision { .. } | Error::CrownData(_) => "This disc image is not a supported original revision. Choose a clean, original copy of a supported release.".into(),
- _ => error.to_string(),
- },
+ reason: matches!(
+ error,
+ Error::AlreadyModded { .. } | Error::AlreadyCrownMod { .. }
+ )
+ .then_some("already-modded"),
+ text: error.disc_notice(),
mod_metadata: None,
disc_info: None,
size: 0,
@@ -561,33 +539,6 @@ fn phase_name(phase: dw4vhp_core::writer::Phase) -> &'static str {
#[cfg(test)]
mod tests {
use super::*;
- #[test]
- fn suggested_output_preserves_the_source_container_and_plain_gcm_suffix() {
- let dir = tempfile::tempdir().unwrap();
- for (name, magic, suffix) in [
- ("game.iso", b"raw!", "iso"),
- ("game.gcm", b"raw!", "gcm"),
- ("game.GCM", b"raw!", "gcm"),
- ("game.ciso", b"CISO", "ciso"),
- ("game.rvz", b"RVZ\x01", "rvz"),
- // The output suffix follows the bytes when an input is misnamed.
- ("compressed.iso", b"RVZ\x01", "rvz"),
- ] {
- let input = dir.path().join(name);
- std::fs::write(&input, magic).unwrap();
- let output = std::path::PathBuf::from(default_output(input.display().to_string()));
- assert_eq!(output.parent(), Some(dir.path()));
- assert_eq!(output.extension().unwrap(), suffix);
- assert!(output
- .file_stem()
- .unwrap()
- .to_str()
- .unwrap()
- .ends_with(OUTPUT_MARKER));
- assert_ne!(output, input);
- }
- }
-
#[test]
fn an_updated_image_name_follows_its_new_seed() {
use std::path::{Path, PathBuf};
diff --git a/crates/dw4vhp-tauri/src/settings.rs b/crates/dw4vhp-tauri/src/settings.rs
index b639cf2..60a053e 100644
--- a/crates/dw4vhp-tauri/src/settings.rs
+++ b/crates/dw4vhp-tauri/src/settings.rs
@@ -1,68 +1,8 @@
-//! Portable settings contain patch options only, never disc or output paths.
+//! Settings file dialogs; the file format lives in `dw4vhp_core::settings`.
use dw4vhp_core::options::PatchSelection;
-use serde::{Deserialize, Serialize};
-use std::io::Read;
-use std::path::Path;
+use dw4vhp_core::settings::{encode, read};
use tauri_plugin_dialog::DialogExt;
-const FORMAT: &str = "dw4-crown-mod-settings";
-const VERSION: u32 = 1;
-const MAX_BYTES: u64 = 64 * 1024;
-
-#[derive(Serialize, Deserialize)]
-#[serde(deny_unknown_fields)]
-struct SettingsFile {
- format: String,
- version: u32,
- settings: PatchSelection,
-}
-
-fn validate(settings: PatchSelection) -> Result {
- if settings.crown_drops && !settings.crown_mod {
- return Err("Match drops to crowns requires Crown Mod.".into());
- }
- if settings.random_bosses && !settings.random_enemies {
- return Err("Random bosses requires Random enemies.".into());
- }
- if settings.random_enemies && settings.enemy_seed.is_none() {
- return Err("Random enemies requires a valid seed.".into());
- }
- Ok(settings)
-}
-
-fn encode(settings: PatchSelection) -> Result {
- let file = SettingsFile {
- format: FORMAT.into(),
- version: VERSION,
- settings: validate(settings)?,
- };
- serde_json::to_string_pretty(&file)
- .map(|json| json + "\n")
- .map_err(|error| format!("Unable to encode settings: {error}"))
-}
-
-fn read(path: &Path) -> Result {
- let mut bytes = Vec::new();
- std::fs::File::open(path)
- .and_then(|file| file.take(MAX_BYTES + 1).read_to_end(&mut bytes))
- .map_err(|_| "Unable to read the settings file.".to_string())?;
- if bytes.len() as u64 > MAX_BYTES {
- return Err("The settings file is too large.".into());
- }
- let file: SettingsFile = serde_json::from_slice(&bytes)
- .map_err(|_| "Invalid settings file. Choose a Crown Mod settings JSON file.".to_string())?;
- if file.format != FORMAT {
- return Err("This is not a Crown Mod settings file.".into());
- }
- if file.version != VERSION {
- return Err(
- "This settings file uses an unsupported version. Update Crown Mod and try again."
- .into(),
- );
- }
- validate(file.settings)
-}
-
#[tauri::command]
pub async fn import_settings(window: tauri::Window) -> Result