Compare commits
171
Commits
830864aa8a
..
new
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cad41e456b | ||
|
|
65c4a9c051 | ||
|
|
3710924503 | ||
|
|
3948607b1e | ||
|
|
6c180372fe | ||
|
|
fed04b66b8 | ||
|
|
a4ca718070 | ||
|
|
8dbd3e1dd2 | ||
|
|
7a9a2b9832 | ||
|
|
e8757c33e3 | ||
|
|
b498a12458 | ||
|
|
c9f098693c | ||
|
|
7aeffac9fc | ||
|
|
37e7e95ace | ||
|
|
e3f56c4d12 | ||
|
|
3675ec634f | ||
|
|
d8273a225c | ||
|
|
c1c8174b27 | ||
|
|
5697f5c064 | ||
|
|
3ce16cf7f4 | ||
|
|
2abd5b0c3c | ||
|
|
4b29bf7a30 | ||
|
|
6f1bbe4f2f | ||
|
|
f64364f37d | ||
|
|
d16e0bbfbf | ||
|
|
70ae41bd29 | ||
|
|
abf6863044 | ||
|
|
4279bd9675 | ||
|
|
5910110b95 | ||
|
|
44594f7011 | ||
|
|
dbb5301ade | ||
|
|
74a4290be4 | ||
|
|
3ce892f846 | ||
|
|
68cebce04a | ||
|
|
1646e964b5 | ||
|
|
2ee97ad4ce | ||
|
|
109ddc9e1e | ||
|
|
804f8aa1fa | ||
|
|
49b97ba508 | ||
|
|
6c11d8165d | ||
|
|
93554b39ba | ||
|
|
6af0e9cf28 | ||
|
|
083deb8357 | ||
|
|
ffb375faeb | ||
|
|
b8cbd8ff6a | ||
|
|
c2bd761383 | ||
|
|
878e3438c8 | ||
|
|
3da65370e0 | ||
|
|
83e646cba9 | ||
|
|
0566166af4 | ||
|
|
ed0b8c3911 | ||
|
|
03d753a83f | ||
|
|
cf51ed1988 | ||
|
|
70f46e89d3 | ||
|
|
efd760fb2e | ||
|
|
f303d24f4a | ||
|
|
9688e88a7c | ||
|
|
c8a6325615 | ||
|
|
798db14bb5 | ||
|
|
178d78ef72 | ||
|
|
8139a0ea54 | ||
|
|
327c2bec70 | ||
|
|
fc0195d9f7 | ||
|
|
db42bca44b | ||
|
|
b3623c84a5 | ||
|
|
45c1f9004b | ||
|
|
845a395ff1 | ||
|
|
f63653c307 | ||
|
|
5b523c68a7 | ||
|
|
03efbe0681 | ||
|
|
cebd3d81e7 | ||
|
|
de53bebeb8 | ||
|
|
6ccaedd48f | ||
|
|
707856fcf2 | ||
|
|
3c3dc35e1d | ||
|
|
f9820bd226 | ||
|
|
fe2ef92ef3 | ||
|
|
9364768397 | ||
|
|
9c28d5a3b7 | ||
|
|
d5078b978c | ||
|
|
d49594d3fb | ||
|
|
619ce932f9 | ||
|
|
b564d0b1c1 | ||
|
|
fc1fc9f170 | ||
|
|
fd5bcfae90 | ||
|
|
3ee0a53688 | ||
|
|
62c081ecf2 | ||
|
|
d9beb647c1 | ||
|
|
f8f8a80a21 | ||
|
|
ac8023d50f | ||
|
|
769f2f5702 | ||
|
|
2f6839bcc4 | ||
|
|
d37109f5f7 | ||
|
|
15bd9fc43c | ||
|
|
8049e90853 | ||
|
|
e47a2c3e5c | ||
|
|
9512c22e1f | ||
|
|
8a77001016 | ||
|
|
9b0214ee55 | ||
|
|
7ad735552a | ||
|
|
ea35472ef8 | ||
|
|
50c5621d8a | ||
|
|
da275cfd52 | ||
|
|
0f4ee5d965 | ||
|
|
af8c0f5ccd | ||
|
|
8ea370a1d1 | ||
|
|
fcf0de72af | ||
|
|
320c5e6ce5 | ||
|
|
7a858cc424 | ||
|
|
c0292842a5 | ||
|
|
717902462b | ||
|
|
1d73b9d224 | ||
|
|
51f262efa0 | ||
|
|
a6e4e3f71f | ||
|
|
4387d223b9 | ||
|
|
00bfaf6360 | ||
|
|
709bd7be52 | ||
|
|
80f4348e21 | ||
|
|
e630827b34 | ||
|
|
106d9b0fc0 | ||
|
|
4a26f79945 | ||
|
|
1a199f6ce3 | ||
|
|
ec59e77867 | ||
|
|
cb28d2b611 | ||
|
|
27b6ddf5cb | ||
|
|
475c865e33 | ||
|
|
0b4ba062bb | ||
|
|
28f5e66662 | ||
|
|
e225a076f0 | ||
|
|
774c8ad0f8 | ||
|
|
52d1e7414d | ||
|
|
af4cb53e5f | ||
|
|
c019271e12 | ||
|
|
82ae2bce9d | ||
|
|
092e259a06 | ||
|
|
08b4bbfe91 | ||
|
|
560c51cf27 | ||
|
|
674f86b18a | ||
|
|
e3f10e0926 | ||
|
|
d7223d7387 | ||
|
|
45331c2a60 | ||
|
|
33f50a2c69 | ||
|
|
6c8e4d5cbd | ||
|
|
3b7215876a | ||
|
|
c74f5890bd | ||
|
|
fbd3c71ba7 | ||
|
|
128f9ab9d4 | ||
|
|
36fb359aa2 | ||
|
|
1bd73d69fe | ||
|
|
fb48285143 | ||
|
|
3de50b8370 | ||
|
|
e61cbe25b7 | ||
|
|
8395830be6 | ||
|
|
6e4ec2b9d8 | ||
|
|
f501bb8e28 | ||
|
|
d07cd3397d | ||
|
|
e008fb108a | ||
|
|
9aaffff7a8 | ||
|
|
7357b4a5df | ||
|
|
1ddc298a74 | ||
|
|
e2a9442aa6 | ||
|
|
aa0180571e | ||
|
|
7f7be39230 | ||
|
|
4d95415232 | ||
|
|
2cbd80a004 | ||
|
|
9abf8101da | ||
|
|
24badd06a5 | ||
|
|
7a03ef8eaf | ||
|
|
f3ea507313 | ||
|
|
4b0388a0e1 | ||
|
|
a84137b5ff |
No files matched your search
@@ -1,49 +0,0 @@
|
|||||||
name: Setup devkitPro
|
|
||||||
description: Install devkitPro with GameCube/Wii packages on an Ubuntu runner
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- name: Install apt dependencies
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y \
|
|
||||||
cmake \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-polib \
|
|
||||||
python3-pil \
|
|
||||||
python3-dotenv \
|
|
||||||
python3-pyqt5 \
|
|
||||||
python3-opengl \
|
|
||||||
xorriso
|
|
||||||
- name: Install devkitPro pacman
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
sudo ln -sf /proc/self/mounts /etc/mtab
|
|
||||||
wget https://apt.devkitpro.org/install-devkitpro-pacman \
|
|
||||||
-O /tmp/install-devkitpro-pacman
|
|
||||||
echo "=== installer script contents ==="
|
|
||||||
cat /tmp/install-devkitpro-pacman
|
|
||||||
echo "================================="
|
|
||||||
chmod +x /tmp/install-devkitpro-pacman
|
|
||||||
sudo /tmp/install-devkitpro-pacman
|
|
||||||
echo "DEVKITPRO=/opt/devkitpro" >> $GITHUB_ENV
|
|
||||||
echo "DEVKITPPC=/opt/devkitpro/devkitPPC" >> $GITHUB_ENV
|
|
||||||
echo "/opt/devkitpro/tools/bin" >> $GITHUB_PATH
|
|
||||||
echo "/opt/devkitpro/devkitPPC/bin" >> $GITHUB_PATH
|
|
||||||
- name: Install devkitPro GameCube/Wii packages
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
sudo dkp-pacman -S --needed --noconfirm \
|
|
||||||
gamecube-dev \
|
|
||||||
gamecube-sdl2 \
|
|
||||||
ppc-liblzma \
|
|
||||||
ppc-libzip \
|
|
||||||
libogc2 \
|
|
||||||
gamecube-tools \
|
|
||||||
ppc-libmad \
|
|
||||||
ppc-zlib-ng \
|
|
||||||
ppc-bzip2 \
|
|
||||||
ppc-zstd
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
name: Setup pspdev
|
|
||||||
description: Install the pspdev PSP toolchain on an Ubuntu runner
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- name: Install dependencies
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y cmake python3 python3-pip python3-dotenv
|
|
||||||
- name: Install pspdev toolchain
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
wget -q \
|
|
||||||
https://github.com/pspdev/pspdev/releases/latest/download/pspdev-ubuntu-latest-x86_64.tar.gz \
|
|
||||||
-O /tmp/pspdev.tar.gz
|
|
||||||
sudo tar -xzf /tmp/pspdev.tar.gz -C /usr/local
|
|
||||||
echo "PSPDEV=/usr/local/pspdev" >> $GITHUB_ENV
|
|
||||||
echo "/usr/local/pspdev/bin" >> $GITHUB_PATH
|
|
||||||
@@ -1,247 +0,0 @@
|
|||||||
name: Build Dusk
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
jobs:
|
|
||||||
build-linux:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y \
|
|
||||||
build-essential \
|
|
||||||
cmake \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-polib \
|
|
||||||
python3-pil \
|
|
||||||
libsdl2-dev \
|
|
||||||
libgl1-mesa-dev \
|
|
||||||
libzip-dev \
|
|
||||||
python3-dotenv \
|
|
||||||
python3-pyqt5 \
|
|
||||||
python3-opengl \
|
|
||||||
xz-utils \
|
|
||||||
liblzma-dev \
|
|
||||||
libbz2-dev \
|
|
||||||
zlib1g-dev \
|
|
||||||
git \
|
|
||||||
libssl-dev
|
|
||||||
- name: Build Linux
|
|
||||||
run: ./scripts/build-linux.sh
|
|
||||||
- name: Upload Linux binary
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: dusk-linux
|
|
||||||
path: build-linux/Dusk
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-psp:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Setup pspdev
|
|
||||||
uses: ./.github/actions/setup-pspdev
|
|
||||||
- name: Build PSP
|
|
||||||
run: ./scripts/build-psp.sh
|
|
||||||
- name: Move EBOOT.PBP to Dusk subfolder
|
|
||||||
run: |
|
|
||||||
mkdir -p ./git-artifcats/Dusk/PSP/GAME/Dusk
|
|
||||||
cp build-psp/EBOOT.PBP ./git-artifcats/Dusk/PSP/GAME/Dusk/EBOOT.PBP
|
|
||||||
- name: Upload PSP binary
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: dusk-psp
|
|
||||||
path: ./git-artifcats/Dusk
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-knulli:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: debian:trixie
|
|
||||||
steps:
|
|
||||||
- name: Install Node.js
|
|
||||||
run: apt-get update && apt-get install -y nodejs
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
dpkg --add-architecture arm64
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
crossbuild-essential-arm64 \
|
|
||||||
ca-certificates \
|
|
||||||
pkg-config \
|
|
||||||
cmake \
|
|
||||||
make \
|
|
||||||
ninja-build \
|
|
||||||
git \
|
|
||||||
file \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-polib \
|
|
||||||
python3-pil \
|
|
||||||
python3-dotenv \
|
|
||||||
python3-pyqt5 \
|
|
||||||
python3-opengl \
|
|
||||||
liblua5.4-dev:arm64 \
|
|
||||||
xz-utils:arm64 \
|
|
||||||
libbz2-dev:arm64 \
|
|
||||||
zlib1g-dev:arm64 \
|
|
||||||
libzip-dev:arm64 \
|
|
||||||
libssl-dev:arm64 \
|
|
||||||
libsdl2-dev:arm64 \
|
|
||||||
liblzma-dev:arm64 \
|
|
||||||
libopengl0:arm64 \
|
|
||||||
libgl1:arm64 \
|
|
||||||
libegl1:arm64 \
|
|
||||||
libgles2:arm64 \
|
|
||||||
libgl1-mesa-dev:arm64
|
|
||||||
- name: Build Knulli
|
|
||||||
run: ./scripts/build-knulli.sh
|
|
||||||
- name: Move output to Dusk subfolder
|
|
||||||
run: |
|
|
||||||
mkdir -p ./git-artifcats/Dusk
|
|
||||||
cp -r build-knulli/dusk ./git-artifcats/Dusk
|
|
||||||
- name: Upload Knulli binary
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: dusk-knulli
|
|
||||||
path: ./git-artifcats/Dusk
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-gamecube:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: ghcr.io/extremscorner/libogc2:latest
|
|
||||||
steps:
|
|
||||||
- name: Install Node.js
|
|
||||||
run: apt-get update && apt-get install -y nodejs
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install additional dependencies
|
|
||||||
run: |
|
|
||||||
apt-get install -y \
|
|
||||||
python3-pip python3-polib python3-pil \
|
|
||||||
python3-dotenv python3-pyqt5 python3-opengl
|
|
||||||
dkp-pacman -Syu --noconfirm
|
|
||||||
dkp-pacman -S --needed --noconfirm \
|
|
||||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
|
||||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
|
||||||
- name: Build GameCube
|
|
||||||
run: ./scripts/build-gamecube.sh
|
|
||||||
- name: Copy output files
|
|
||||||
run: |
|
|
||||||
mkdir -p ./git-artifcats/Dusk
|
|
||||||
cp build-gamecube/Dusk.dol ./git-artifcats/Dusk/Dusk.dol
|
|
||||||
cp build-gamecube/dusk.dsk ./git-artifcats/Dusk/dusk.dsk
|
|
||||||
- name: Upload GameCube binary
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: dusk-gamecube
|
|
||||||
path: ./git-artifcats/Dusk
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-gamecube-iso:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: ghcr.io/extremscorner/libogc2:latest
|
|
||||||
steps:
|
|
||||||
- name: Install Node.js
|
|
||||||
run: apt-get update && apt-get install -y nodejs
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install additional dependencies
|
|
||||||
run: |
|
|
||||||
apt-get install -y \
|
|
||||||
python3-pip python3-polib python3-pil \
|
|
||||||
python3-dotenv python3-pyqt5 python3-opengl xorriso
|
|
||||||
dkp-pacman -Syu --noconfirm
|
|
||||||
dkp-pacman -S --needed --noconfirm \
|
|
||||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
|
||||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
|
||||||
- name: Build GameCube ISO
|
|
||||||
run: ./scripts/build-gamecube-iso.sh
|
|
||||||
- name: Copy output files
|
|
||||||
run: |
|
|
||||||
mkdir -p ./git-artifcats/Dusk
|
|
||||||
cp build-gamecube-iso/Dusk-NTSC-J.iso ./git-artifcats/Dusk/Dusk-NTSC-J.iso
|
|
||||||
cp build-gamecube-iso/Dusk-NTSC-U.iso ./git-artifcats/Dusk/Dusk-NTSC-U.iso
|
|
||||||
cp build-gamecube-iso/Dusk-PAL.iso ./git-artifcats/Dusk/Dusk-PAL.iso
|
|
||||||
- name: Upload GameCube ISO
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: dusk-gamecube-iso
|
|
||||||
path: ./git-artifcats/Dusk
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-wii:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: ghcr.io/extremscorner/libogc2:latest
|
|
||||||
steps:
|
|
||||||
- name: Install Node.js
|
|
||||||
run: apt-get update && apt-get install -y nodejs
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install additional dependencies
|
|
||||||
run: |
|
|
||||||
apt-get install -y \
|
|
||||||
python3-pip python3-polib python3-pil \
|
|
||||||
python3-dotenv python3-pyqt5 python3-opengl
|
|
||||||
dkp-pacman -Syu --noconfirm
|
|
||||||
dkp-pacman -S --needed --noconfirm \
|
|
||||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
|
||||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
|
||||||
- name: Build Wii
|
|
||||||
run: ./scripts/build-wii.sh
|
|
||||||
- name: Copy output files
|
|
||||||
run: |
|
|
||||||
mkdir -p ./git-artifcats/Dusk/apps/Dusk
|
|
||||||
cp build-wii/boot.dol ./git-artifcats/Dusk/apps/Dusk/boot.dol
|
|
||||||
cp build-wii/dusk.dsk ./git-artifcats/Dusk/apps/Dusk/dusk.dsk
|
|
||||||
cp build-wii/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
|
|
||||||
- name: Upload Wii binary
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: dusk-wii
|
|
||||||
path: ./git-artifcats/Dusk
|
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
build-wii-iso:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: ghcr.io/extremscorner/libogc2:latest
|
|
||||||
steps:
|
|
||||||
- name: Install Node.js
|
|
||||||
run: apt-get update && apt-get install -y nodejs
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install additional dependencies
|
|
||||||
run: |
|
|
||||||
apt-get install -y \
|
|
||||||
python3-pip python3-polib python3-pil \
|
|
||||||
python3-dotenv python3-pyqt5 python3-opengl xorriso
|
|
||||||
dkp-pacman -Syu --noconfirm
|
|
||||||
dkp-pacman -S --needed --noconfirm \
|
|
||||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
|
||||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
|
||||||
- name: Build Wii ISO
|
|
||||||
run: ./scripts/build-wii-iso.sh
|
|
||||||
- name: Copy output files
|
|
||||||
run: |
|
|
||||||
mkdir -p ./git-artifcats/Dusk
|
|
||||||
cp build-wii-iso/Dusk-NTSC-J.iso ./git-artifcats/Dusk/Dusk-NTSC-J.iso
|
|
||||||
cp build-wii-iso/Dusk-NTSC-U.iso ./git-artifcats/Dusk/Dusk-NTSC-U.iso
|
|
||||||
cp build-wii-iso/Dusk-PAL.iso ./git-artifcats/Dusk/Dusk-PAL.iso
|
|
||||||
- name: Upload Wii ISO
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: dusk-wii-iso
|
|
||||||
path: ./git-artifcats/Dusk
|
|
||||||
if-no-files-found: error
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
name: Test Dusk
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
jobs:
|
|
||||||
run-tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y \
|
|
||||||
build-essential \
|
|
||||||
cmake \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-polib \
|
|
||||||
python3-pil \
|
|
||||||
libsdl2-dev \
|
|
||||||
libgl1-mesa-dev \
|
|
||||||
libzip-dev \
|
|
||||||
python3-dotenv \
|
|
||||||
python3-pyqt5 \
|
|
||||||
python3-opengl \
|
|
||||||
xz-utils \
|
|
||||||
liblzma-dev \
|
|
||||||
libbz2-dev \
|
|
||||||
zlib1g-dev \
|
|
||||||
git \
|
|
||||||
libssl-dev
|
|
||||||
- name: Run tests
|
|
||||||
run: ./scripts/test-linux.sh
|
|
||||||
|
|
||||||
# Emulator smoke tests: boot the built disc/EBOOT for a fixed window and
|
|
||||||
# confirm the emulator doesn't crash. Not yet verified against a real
|
|
||||||
# runner (no CI run has exercised these) -- continue-on-error so a
|
|
||||||
# flaky/broken emulator step doesn't block the required Linux test job.
|
|
||||||
run-tests-gamecube-dolphin:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
continue-on-error: true
|
|
||||||
container:
|
|
||||||
image: ghcr.io/extremscorner/libogc2:latest
|
|
||||||
steps:
|
|
||||||
- name: Install Node.js
|
|
||||||
run: apt-get update && apt-get install -y nodejs
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install additional dependencies
|
|
||||||
run: |
|
|
||||||
apt-get install -y \
|
|
||||||
python3-pip python3-polib python3-pil \
|
|
||||||
python3-dotenv python3-pyqt5 python3-opengl xorriso \
|
|
||||||
dolphin-emu xvfb
|
|
||||||
dkp-pacman -Syu --noconfirm
|
|
||||||
dkp-pacman -S --needed --noconfirm \
|
|
||||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
|
||||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
|
||||||
- name: Build GameCube ISO and boot it in Dolphin
|
|
||||||
run: ./scripts/test-gamecube-dolphin.sh
|
|
||||||
|
|
||||||
run-tests-wii-dolphin:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
continue-on-error: true
|
|
||||||
container:
|
|
||||||
image: ghcr.io/extremscorner/libogc2:latest
|
|
||||||
steps:
|
|
||||||
- name: Install Node.js
|
|
||||||
run: apt-get update && apt-get install -y nodejs
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Install additional dependencies
|
|
||||||
run: |
|
|
||||||
apt-get install -y \
|
|
||||||
python3-pip python3-polib python3-pil \
|
|
||||||
python3-dotenv python3-pyqt5 python3-opengl xorriso \
|
|
||||||
dolphin-emu xvfb
|
|
||||||
dkp-pacman -Syu --noconfirm
|
|
||||||
dkp-pacman -S --needed --noconfirm \
|
|
||||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
|
||||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
|
||||||
- name: Build Wii ISO and boot it in Dolphin
|
|
||||||
run: ./scripts/test-wii-dolphin.sh
|
|
||||||
|
|
||||||
run-tests-psp-ppsspp:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
continue-on-error: true
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Setup pspdev
|
|
||||||
uses: ./.github/actions/setup-pspdev
|
|
||||||
- name: Install PPSSPPHeadless build dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y git cmake ninja-build libsdl2-dev zlib1g-dev
|
|
||||||
- name: Build PPSSPPHeadless
|
|
||||||
run: |
|
|
||||||
git clone --recursive --depth 1 https://github.com/hrydgard/ppsspp.git /tmp/ppsspp
|
|
||||||
cmake -S /tmp/ppsspp -B /tmp/ppsspp/build -DCMAKE_BUILD_TYPE=Release
|
|
||||||
cmake --build /tmp/ppsspp/build --target PPSSPPHeadless -- -j$(nproc)
|
|
||||||
echo "PPSSPP_HEADLESS_BIN=/tmp/ppsspp/build/PPSSPPHeadless" >> "$GITHUB_ENV"
|
|
||||||
- name: Build PSP EBOOT and boot it in PPSSPPHeadless
|
|
||||||
run: ./scripts/test-psp-ppsspp.sh
|
|
||||||
+2
-1
@@ -106,4 +106,5 @@ yarn.lock
|
|||||||
/build*
|
/build*
|
||||||
/assets/test
|
/assets/test
|
||||||
/tools_old
|
/tools_old
|
||||||
/assets/test.png
|
/assets/test.png
|
||||||
|
/assets/audio/boa.mp3
|
||||||
+61
-104
@@ -1,141 +1,98 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
# Copyright (c) 2026 Dominic Masters
|
||||||
#
|
#
|
||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Setup
|
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
|
||||||
cmake_policy(SET CMP0079 NEW)
|
|
||||||
# set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
|
|
||||||
|
|
||||||
option(DUSK_BUILD_TESTS "Enable tests" OFF)
|
# Directories
|
||||||
option(DUSK_NETWORKING "Enable networking support" ON)
|
|
||||||
|
|
||||||
set(DUSK_GAME_NAME "Dusk" CACHE STRING "Game display name")
|
|
||||||
set(DUSK_GAME_AUTHOR "YourWishes" CACHE STRING "Game author / coder")
|
|
||||||
set(DUSK_GAME_SHORT_DESCRIPTION "Dusk game" CACHE STRING "One-line description")
|
|
||||||
set(DUSK_GAME_LONG_DESCRIPTION "No description yet." CACHE STRING "Full description")
|
|
||||||
|
|
||||||
# Prep cache
|
|
||||||
set(DUSK_CACHE_TARGET "dusk-target")
|
|
||||||
|
|
||||||
# Build variables
|
|
||||||
set(DUSK_ROOT_DIR "${CMAKE_SOURCE_DIR}")
|
set(DUSK_ROOT_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
set(DUSK_BUILD_DIR "${CMAKE_BINARY_DIR}")
|
|
||||||
set(DUSK_SOURCES_DIR "${DUSK_ROOT_DIR}/src")
|
set(DUSK_SOURCES_DIR "${DUSK_ROOT_DIR}/src")
|
||||||
set(DUSK_TEST_DIR "${DUSK_ROOT_DIR}/test")
|
|
||||||
set(DUSK_TEMP_DIR "${DUSK_BUILD_DIR}/temp")
|
|
||||||
set(DUSK_TOOLS_DIR "${DUSK_ROOT_DIR}/tools")
|
|
||||||
set(DUSK_DATA_DIR "${DUSK_ROOT_DIR}/data")
|
|
||||||
set(DUSK_ASSETS_DIR "${DUSK_ROOT_DIR}/assets")
|
set(DUSK_ASSETS_DIR "${DUSK_ROOT_DIR}/assets")
|
||||||
set(DUSK_BUILT_ASSETS_DIR "${DUSK_BUILD_DIR}/built_assets" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
set(DUSK_BUILT_ASSETS_DIR "${CMAKE_BINARY_DIR}/assets")
|
||||||
set(DUSK_GENERATED_HEADERS_DIR "${DUSK_BUILD_DIR}/generated")
|
set(DUSK_GENERATED_HEADERS_DIR "${CMAKE_BINARY_DIR}/generated")
|
||||||
set(DUSK_BUILD_BINARY ${DUSK_BUILD_DIR}/Dusk CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
||||||
set(DUSK_ASSETS "" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
||||||
set(DUSK_LIBRARY_TARGET_NAME "DuskCore" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
||||||
set(DUSK_BINARY_TARGET_NAME "Dusk" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
||||||
set(DUSK_ASSETS_ZIP "${DUSK_BUILD_DIR}/dusk.dsk" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
||||||
|
|
||||||
if(NOT DEFINED DUSK_TARGET_SYSTEM)
|
|
||||||
set(DUSK_TARGET_SYSTEM "linux")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Create directories
|
|
||||||
file(MAKE_DIRECTORY ${DUSK_GENERATED_HEADERS_DIR})
|
file(MAKE_DIRECTORY ${DUSK_GENERATED_HEADERS_DIR})
|
||||||
file(MAKE_DIRECTORY ${DUSK_TEMP_DIR})
|
|
||||||
file(MAKE_DIRECTORY ${DUSK_BUILT_ASSETS_DIR})
|
|
||||||
|
|
||||||
# Required build packages
|
project(DuskCore VERSION 1.0.0 LANGUAGES C)
|
||||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
|
||||||
|
|
||||||
# Init Project.
|
# Work out the target platform unless one was given explicitly.
|
||||||
project(${DUSK_LIBRARY_TARGET_NAME}
|
include(${DUSK_ROOT_DIR}/cmake/determineplatform.cmake)
|
||||||
VERSION 1.0.0
|
|
||||||
LANGUAGES C
|
# Platform defaults and definitions (sets DUSK_DEFAULT_* and
|
||||||
|
# DUSK_PLATFORM_DIRS / DUSK_PLATFORM_DEFINITIONS).
|
||||||
|
set(DUSK_TARGET_FILE
|
||||||
|
"${DUSK_ROOT_DIR}/cmake/${DUSK_TARGET_SYSTEM}/target.cmake"
|
||||||
)
|
)
|
||||||
|
if(NOT EXISTS "${DUSK_TARGET_FILE}")
|
||||||
|
message(FATAL_ERROR "Unknown DUSK_TARGET_SYSTEM: ${DUSK_TARGET_SYSTEM}")
|
||||||
|
endif()
|
||||||
|
include("${DUSK_TARGET_FILE}")
|
||||||
|
|
||||||
# Either, create library and binary separately (used for tests), or make them
|
# All options and their defaults.
|
||||||
# one in the same so all code is in the binary only.
|
include(${DUSK_ROOT_DIR}/cmake/option.cmake)
|
||||||
# Binary Executable
|
|
||||||
add_executable(${DUSK_BINARY_TARGET_NAME} ${DUSK_SOURCES_DIR}/dusk/null.c)
|
# Targets. Tests split the code into a library plus the binary, otherwise all
|
||||||
|
# code is compiled straight into the binary.
|
||||||
|
set(DUSK_BINARY_TARGET_NAME "Dusk")
|
||||||
|
add_executable(${DUSK_BINARY_TARGET_NAME})
|
||||||
|
|
||||||
if(DUSK_BUILD_TESTS)
|
if(DUSK_BUILD_TESTS)
|
||||||
# MainLibrary
|
set(DUSK_LIBRARY_TARGET_NAME "DuskCore")
|
||||||
add_library(${DUSK_LIBRARY_TARGET_NAME} STATIC)
|
add_library(${DUSK_LIBRARY_TARGET_NAME} STATIC)
|
||||||
|
target_link_libraries(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||||
# Link library to binary
|
${DUSK_LIBRARY_TARGET_NAME}
|
||||||
target_link_libraries(${DUSK_BINARY_TARGET_NAME}
|
|
||||||
PUBLIC
|
|
||||||
${DUSK_LIBRARY_TARGET_NAME}
|
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
set(DUSK_LIBRARY_TARGET_NAME "${DUSK_BINARY_TARGET_NAME}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
set(DUSK_LIBRARY_TARGET_NAME "${DUSK_BINARY_TARGET_NAME}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT DEFINED DUSK_VERSION)
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
string(TIMESTAMP DUSK_VERSION "debug-%y%m%d%H%M%S")
|
DUSK_TARGET_SYSTEM="${DUSK_TARGET_SYSTEM}"
|
||||||
endif()
|
DUSK_GAME_NAME="${DUSK_GAME_NAME}"
|
||||||
|
DUSK_GAME_AUTHOR="${DUSK_GAME_AUTHOR}"
|
||||||
# Definitions
|
DUSK_VERSION="${DUSK_VERSION}"
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME}
|
|
||||||
PUBLIC
|
|
||||||
DUSK_TARGET_SYSTEM="${DUSK_TARGET_SYSTEM}"
|
|
||||||
DUSK_GAME_NAME="${DUSK_GAME_NAME}"
|
|
||||||
DUSK_GAME_AUTHOR="${DUSK_GAME_AUTHOR}"
|
|
||||||
DUSK_GAME_SHORT_DESCRIPTION="${DUSK_GAME_SHORT_DESCRIPTION}"
|
|
||||||
DUSK_GAME_LONG_DESCRIPTION="${DUSK_GAME_LONG_DESCRIPTION}"
|
|
||||||
DUSK_VERSION="${DUSK_VERSION}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(DUSK_NETWORKING)
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
${DUSK_PLATFORM_DEFINITIONS}
|
||||||
DUSK_NETWORKING
|
)
|
||||||
)
|
foreach(OPT ASSERTIONS_FAKED BACKTRACE TRACK_MEMORY NETWORK)
|
||||||
|
if(DUSK_${OPT})
|
||||||
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC DUSK_${OPT})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(DUSK_BACKTRACE)
|
||||||
|
target_link_options(${DUSK_LIBRARY_TARGET_NAME} PUBLIC -rdynamic)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Toolchains
|
# Tools (run during the build to generate headers)
|
||||||
include(cmake/targets/${DUSK_TARGET_SYSTEM}.cmake)
|
|
||||||
|
|
||||||
# Add tools
|
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
|
|
||||||
# Include generated headers from tools.
|
|
||||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
${DUSK_GENERATED_HEADERS_DIR}
|
${DUSK_GENERATED_HEADERS_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add main code
|
# Core engine code
|
||||||
add_subdirectory(${DUSK_SOURCES_DIR})
|
add_subdirectory(${DUSK_SOURCES_DIR}/dusk)
|
||||||
|
|
||||||
# Include generated headers
|
# Assets, copied into <build>/assets
|
||||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
include(${DUSK_ROOT_DIR}/cmake/asset/asset.cmake)
|
||||||
${DUSK_GENERATED_HEADERS_DIR}
|
# Separate binary dir, so <build>/assets only contains built assets.
|
||||||
)
|
add_subdirectory(${DUSK_ROOT_DIR}/assets ${CMAKE_BINARY_DIR}/assets_cmake)
|
||||||
|
dusk_assets_finalize(DuskAssets)
|
||||||
|
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DuskAssets)
|
||||||
|
|
||||||
|
# Game code
|
||||||
|
add_subdirectory(${DUSK_SOURCES_DIR}/${DUSK_GAME})
|
||||||
|
|
||||||
|
# Platform code
|
||||||
|
foreach(DIR ${DUSK_PLATFORM_DIRS})
|
||||||
|
add_subdirectory(${DUSK_SOURCES_DIR}/${DIR})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# Handle tests
|
|
||||||
if(DUSK_BUILD_TESTS)
|
if(DUSK_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build assets
|
|
||||||
# Deliberately not CONFIGURE_DEPENDS: that reruns the full CMake configure
|
|
||||||
# step (which invalidates generated headers and forces a huge rebuild) on
|
|
||||||
# every single asset edit. Re-run cmake manually when assets are added or
|
|
||||||
# removed.
|
|
||||||
file(GLOB_RECURSE DUSK_ASSET_FILES "${DUSK_ASSETS_DIR}/*")
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT "${DUSK_ASSETS_ZIP}"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${DUSK_ASSETS_DIR}"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E rm -f "${DUSK_ASSETS_ZIP}"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E tar "cf" "${DUSK_ASSETS_ZIP}" --format=zip -- .
|
|
||||||
WORKING_DIRECTORY "${DUSK_ASSETS_DIR}"
|
|
||||||
DEPENDS ${DUSK_ASSET_FILES}
|
|
||||||
VERBATIM
|
|
||||||
)
|
|
||||||
add_custom_target(DUSK_ASSETS_BUILT DEPENDS "${DUSK_ASSETS_ZIP}")
|
|
||||||
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DUSK_ASSETS_BUILT)
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# Dusk
|
|
||||||
RPG Game Project, small and able to run on a PSP.
|
|
||||||
|
|
||||||
# Building
|
|
||||||
Each build target has different requirements. You can take a look at the git
|
|
||||||
workflow to see how the builds are done for each target. In addition, for
|
|
||||||
accessing the editor and building the game on your host system, install the
|
|
||||||
following packages, depending on your system;
|
|
||||||
|
|
||||||
Fedora;
|
|
||||||
```
|
|
||||||
sudo dnf install git make gcc cmake python python-polib python3-pillow python3-dotenv python3-numpy python-qt5 python3-pyopengl SDL2-devel zlib-devel libzip-devel bzip2-devel openssl-devel lzma-sdk-devel xz xz-devel lua-devel
|
|
||||||
```
|
|
||||||
|
|
||||||
Ubuntu;
|
|
||||||
```
|
|
||||||
sudo apt-get install git build-essential gcc python python-polib python3-pillow python3-dotenv python3-numpy python3-pyqt5 python3-opengl
|
|
||||||
```
|
|
||||||
|
|
||||||
Arch Linux;
|
|
||||||
```
|
|
||||||
sudo pacman -S git base-devel gcc python python-polib python-pillow python-dotenv python-numpy python-pyqt5 python-opengl
|
|
||||||
```
|
|
||||||
@@ -2,3 +2,5 @@
|
|||||||
#
|
#
|
||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
add_asset(cube.obj)
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Unit cube, centered on the origin, with per face normals and UVs.
|
||||||
|
o Cube
|
||||||
|
|
||||||
|
v -0.5 -0.5 -0.5
|
||||||
|
v 0.5 -0.5 -0.5
|
||||||
|
v 0.5 0.5 -0.5
|
||||||
|
v -0.5 0.5 -0.5
|
||||||
|
v -0.5 -0.5 0.5
|
||||||
|
v 0.5 -0.5 0.5
|
||||||
|
v 0.5 0.5 0.5
|
||||||
|
v -0.5 0.5 0.5
|
||||||
|
|
||||||
|
vt 0.0 0.0
|
||||||
|
vt 1.0 0.0
|
||||||
|
vt 1.0 1.0
|
||||||
|
vt 0.0 1.0
|
||||||
|
|
||||||
|
vn 0.0 0.0 -1.0
|
||||||
|
vn 0.0 0.0 1.0
|
||||||
|
vn -1.0 0.0 0.0
|
||||||
|
vn 1.0 0.0 0.0
|
||||||
|
vn 0.0 -1.0 0.0
|
||||||
|
vn 0.0 1.0 0.0
|
||||||
|
|
||||||
|
# Back (-Z)
|
||||||
|
f 2/1/1 1/2/1 4/3/1
|
||||||
|
f 2/1/1 4/3/1 3/4/1
|
||||||
|
# Front (+Z)
|
||||||
|
f 5/1/2 6/2/2 7/3/2
|
||||||
|
f 5/1/2 7/3/2 8/4/2
|
||||||
|
# Left (-X)
|
||||||
|
f 1/1/3 5/2/3 8/3/3
|
||||||
|
f 1/1/3 8/3/3 4/4/3
|
||||||
|
# Right (+X)
|
||||||
|
f 6/1/4 2/2/4 3/3/4
|
||||||
|
f 6/1/4 3/3/4 7/4/4
|
||||||
|
# Bottom (-Y)
|
||||||
|
f 1/1/5 2/2/5 6/3/5
|
||||||
|
f 1/1/5 6/3/5 5/4/5
|
||||||
|
# Top (+Y)
|
||||||
|
f 8/1/6 7/2/6 3/3/6
|
||||||
|
f 8/1/6 3/3/6 4/4/6
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: ExampleApp 1.0\n"
|
|
||||||
"Language: en\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
|
||||||
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n==2 ? 1 : (n<7 ? 2 : 3));\n"
|
|
||||||
|
|
||||||
#: ui/menu.c:10
|
|
||||||
msgid "ui.title"
|
|
||||||
msgstr ""
|
|
||||||
"Welcome"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.general"
|
|
||||||
msgstr "General"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.input"
|
|
||||||
msgstr "Input"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.display"
|
|
||||||
msgstr "Display"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.audio"
|
|
||||||
msgstr "Audio"
|
|
||||||
|
|
||||||
msgid "ui.settings.input.deadzone"
|
|
||||||
msgstr "Deadzone"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
|
||||||
msgid "ui.settings.general.language"
|
|
||||||
msgstr "Language"
|
|
||||||
|
|
||||||
msgid "ui.settings.general.language_detail"
|
|
||||||
msgstr "Takes effect after restarting the application."
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.apply"
|
|
||||||
msgstr "Apply"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/uiconfirm.c
|
|
||||||
msgid "ui.confirm.discard_changes"
|
|
||||||
msgstr "Discard unsaved changes?"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.characters"
|
|
||||||
msgstr "Characters"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.items"
|
|
||||||
msgstr "Items"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.settings"
|
|
||||||
msgstr "Settings"
|
|
||||||
|
|
||||||
msgid "item.potion.name"
|
|
||||||
msgstr "Potion"
|
|
||||||
|
|
||||||
msgid "item.potato.name"
|
|
||||||
msgstr "Potato"
|
|
||||||
|
|
||||||
msgid "item.apple.name"
|
|
||||||
msgstr "Apple"
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: ExampleApp 1.0\n"
|
|
||||||
"Language: es\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
|
||||||
"Plural-Forms: nplurals=2; plural=(n==1 ? 0 : 1);\n"
|
|
||||||
|
|
||||||
#: ui/menu.c:10
|
|
||||||
msgid "ui.title"
|
|
||||||
msgstr ""
|
|
||||||
"Bienvenido"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.general"
|
|
||||||
msgstr "General"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.input"
|
|
||||||
msgstr "Entrada"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.display"
|
|
||||||
msgstr "Pantalla"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.audio"
|
|
||||||
msgstr "Audio"
|
|
||||||
|
|
||||||
msgid "ui.settings.input.deadzone"
|
|
||||||
msgstr "Deadzone"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
|
||||||
msgid "ui.settings.general.language"
|
|
||||||
msgstr "Idioma"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
|
||||||
msgid "ui.settings.general.language_detail"
|
|
||||||
msgstr "Se aplica después de reiniciar la aplicación."
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.apply"
|
|
||||||
msgstr "Aplicar"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/uiconfirm.c
|
|
||||||
msgid "ui.confirm.discard_changes"
|
|
||||||
msgstr "¿Descartar los cambios no guardados?"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.characters"
|
|
||||||
msgstr "Personajes"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.items"
|
|
||||||
msgstr "Objetos"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.settings"
|
|
||||||
msgstr "Configuración"
|
|
||||||
|
|
||||||
#: src/dusk/rpg/item/item.json
|
|
||||||
msgid "item.potion.name"
|
|
||||||
msgstr "Poción"
|
|
||||||
|
|
||||||
#: src/dusk/rpg/item/item.json
|
|
||||||
msgid "item.potato.name"
|
|
||||||
msgstr "Papa"
|
|
||||||
|
|
||||||
#: src/dusk/rpg/item/item.json
|
|
||||||
msgid "item.apple.name"
|
|
||||||
msgstr "Manzana"
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: ExampleApp 1.0\n"
|
|
||||||
"Language: ja\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
|
||||||
"Plural-Forms: nplurals=1; plural=(0);\n"
|
|
||||||
|
|
||||||
#: ui/menu.c:10
|
|
||||||
msgid "ui.title"
|
|
||||||
msgstr ""
|
|
||||||
"歓迎"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.general"
|
|
||||||
msgstr "一般"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.input"
|
|
||||||
msgstr "入力"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.display"
|
|
||||||
msgstr "表示"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.tabs.audio"
|
|
||||||
msgstr "オーディオ"
|
|
||||||
|
|
||||||
msgid "ui.settings.input.deadzone"
|
|
||||||
msgstr "デッドゾーン"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
|
||||||
msgid "ui.settings.general.language"
|
|
||||||
msgstr "言語"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
|
||||||
msgid "ui.settings.general.language_detail"
|
|
||||||
msgstr "アプリケーションを再起動すると適用されます。"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/settings/uisettings.c
|
|
||||||
msgid "ui.settings.apply"
|
|
||||||
msgstr "適用"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/uiconfirm.c
|
|
||||||
msgid "ui.confirm.discard_changes"
|
|
||||||
msgstr "未保存の変更を破棄しますか?"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.characters"
|
|
||||||
msgstr "キャラクター"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.items"
|
|
||||||
msgstr "アイテム"
|
|
||||||
|
|
||||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
|
||||||
msgid "ui.game_menu.settings"
|
|
||||||
msgstr "設定"
|
|
||||||
|
|
||||||
#: src/dusk/rpg/item/item.json
|
|
||||||
msgid "item.potion.name"
|
|
||||||
msgstr "ポーション"
|
|
||||||
|
|
||||||
#: src/dusk/rpg/item/item.json
|
|
||||||
msgid "item.potato.name"
|
|
||||||
msgstr "ジャガイモ"
|
|
||||||
|
|
||||||
#: src/dusk/rpg/item/item.json
|
|
||||||
msgid "item.apple.name"
|
|
||||||
msgstr "リンゴ"
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
class Player extends Entity {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.position = this.add(POSITION);
|
|
||||||
this.position.setLocalPosition(0.0, 2.0, 0.0);
|
|
||||||
|
|
||||||
this.physics = this.add(PHYSICS);
|
|
||||||
this.physics.setShape(PHYSICS_SHAPE_CAPSULE, 0.5, 0.5);
|
|
||||||
|
|
||||||
this.renderable = this.add(RENDERABLE);
|
|
||||||
this.renderable.setMesh(0, MESH_CAPSULE);
|
|
||||||
this.renderable.setColor(0, 0, 255, 255);
|
|
||||||
|
|
||||||
this.add(PLAYER);
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Player;
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
var CAMERA_OFFSET_ANGLE = 0.0;
|
|
||||||
var CAMERA_OFFSET_RADIUS = 18.0;
|
|
||||||
var CAMERA_OFFSET_HEIGHT = 10.0;
|
|
||||||
|
|
||||||
class PlayerCamera extends Entity {
|
|
||||||
constructor(target) {
|
|
||||||
super();
|
|
||||||
this.target = target;
|
|
||||||
|
|
||||||
this.position = this.add(POSITION);
|
|
||||||
this.add(CAMERA);
|
|
||||||
|
|
||||||
this.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
update() {
|
|
||||||
var targetPosition = this.target.position.getLocalPosition();
|
|
||||||
|
|
||||||
var eyeX = (
|
|
||||||
targetPosition.x + Math.cos(CAMERA_OFFSET_ANGLE) * CAMERA_OFFSET_RADIUS
|
|
||||||
);
|
|
||||||
var eyeY = (
|
|
||||||
targetPosition.y + CAMERA_OFFSET_HEIGHT
|
|
||||||
);
|
|
||||||
var eyeZ = (
|
|
||||||
targetPosition.z + Math.sin(CAMERA_OFFSET_ANGLE) * CAMERA_OFFSET_RADIUS
|
|
||||||
);
|
|
||||||
|
|
||||||
this.position.lookAt(
|
|
||||||
eyeX, eyeY, eyeZ,
|
|
||||||
targetPosition.x, targetPosition.y, targetPosition.z,
|
|
||||||
0.0, 1.0, 0.0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose() {
|
|
||||||
this.target = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = PlayerCamera;
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
class TestPlane extends Entity {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.position = this.add(POSITION);
|
|
||||||
this.position.setLocalPosition(-10.0, 0.0, -10.0);
|
|
||||||
this.position.setLocalScale(20.0, 1.0, 20.0);
|
|
||||||
|
|
||||||
this.physics = this.add(PHYSICS);
|
|
||||||
this.physics.setBodyType(PHYSICS_BODY_STATIC);
|
|
||||||
this.physics.setShape(PHYSICS_SHAPE_PLANE, 0.0, 1.0, 0.0, 0.0);
|
|
||||||
|
|
||||||
this.renderable = this.add(RENDERABLE);
|
|
||||||
this.renderable.setMesh(0, MESH_PLANE);
|
|
||||||
this.renderable.setColor(128, 128, 128, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = TestPlane;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
var OverworldScene = require('./overworldscene.js');
|
|
||||||
|
|
||||||
Scene.set(new OverworldScene());
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
var Player = require('./Player.js');
|
|
||||||
var PlayerCamera = require('./PlayerCamera.js');
|
|
||||||
var TestPlane = require('./TestPlane.js');
|
|
||||||
|
|
||||||
class OverworldScene {
|
|
||||||
constructor() {
|
|
||||||
this.time = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
init() {
|
|
||||||
this.player = new Player();
|
|
||||||
this.plane = new TestPlane();
|
|
||||||
this.camera = new PlayerCamera(this.player);
|
|
||||||
}
|
|
||||||
|
|
||||||
update() {
|
|
||||||
this.camera.update();
|
|
||||||
|
|
||||||
this.time += Time.delta;
|
|
||||||
if(this.time > 3.0) {
|
|
||||||
Scene.set(new OverworldScene());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose() {
|
|
||||||
this.camera.dispose();
|
|
||||||
this.player.dispose();
|
|
||||||
this.plane.dispose();
|
|
||||||
|
|
||||||
this.camera = null;
|
|
||||||
this.player = null;
|
|
||||||
this.plane = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = OverworldScene;
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Asset building. Include this from the root CMakeLists.txt.
|
||||||
|
#
|
||||||
|
# Assets are registered with add_asset() and built by dusk_assets_finalize().
|
||||||
|
# Each asset is dispatched on its file extension to a handler function named
|
||||||
|
# dusk_asset_<extension> (e.g. dusk_asset_obj), defined in its own file in this
|
||||||
|
# directory. Extensions without a handler fall back to a plain copy.
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/copy.cmake)
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/obj.cmake)
|
||||||
|
|
||||||
|
# Registers an asset to be built into the project. The path is relative to the
|
||||||
|
# calling CMakeLists.txt, and is kept relative to the root assets directory in
|
||||||
|
# the output, so assets/models/a.obj ends up at <build>/assets/models/a.obj.
|
||||||
|
#
|
||||||
|
# This only records the asset. The build rules are created by
|
||||||
|
# dusk_assets_finalize() from the root CMakeLists.txt, because a custom command
|
||||||
|
# output can only be used by targets in the directory it was defined in.
|
||||||
|
function(add_asset ASSET_PATH)
|
||||||
|
set(ASSET_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/${ASSET_PATH}")
|
||||||
|
if(NOT EXISTS "${ASSET_SOURCE}")
|
||||||
|
message(FATAL_ERROR "add_asset: ${ASSET_SOURCE} does not exist")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_property(GLOBAL APPEND PROPERTY DUSK_ASSET_SOURCES "${ASSET_SOURCE}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Determines the lowercase extension of an asset, without the leading dot.
|
||||||
|
function(dusk_asset_extension ASSET_SOURCE OUT_VAR)
|
||||||
|
get_filename_component(ASSET_EXT "${ASSET_SOURCE}" LAST_EXT)
|
||||||
|
string(TOLOWER "${ASSET_EXT}" ASSET_EXT)
|
||||||
|
string(REGEX REPLACE "^\\." "" ASSET_EXT "${ASSET_EXT}")
|
||||||
|
set(${OUT_VAR} "${ASSET_EXT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Creates the TARGET_NAME target, which builds every asset registered with
|
||||||
|
# add_asset(). Call once from the root CMakeLists.txt after adding the assets.
|
||||||
|
function(dusk_assets_finalize TARGET_NAME)
|
||||||
|
get_property(ASSET_SOURCES GLOBAL PROPERTY DUSK_ASSET_SOURCES)
|
||||||
|
|
||||||
|
set(ASSET_OUTPUTS "")
|
||||||
|
foreach(ASSET_SOURCE IN LISTS ASSET_SOURCES)
|
||||||
|
file(RELATIVE_PATH ASSET_RELATIVE "${DUSK_ASSETS_DIR}" "${ASSET_SOURCE}")
|
||||||
|
dusk_asset_extension("${ASSET_SOURCE}" ASSET_EXT)
|
||||||
|
|
||||||
|
# Dispatch on the extension, falling back to a plain copy.
|
||||||
|
set(ASSET_OUTPUT "")
|
||||||
|
if(COMMAND dusk_asset_${ASSET_EXT})
|
||||||
|
cmake_language(CALL dusk_asset_${ASSET_EXT}
|
||||||
|
"${ASSET_SOURCE}" "${ASSET_RELATIVE}" ASSET_OUTPUT
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "Asset ${ASSET_RELATIVE}: no handler for '.${ASSET_EXT}', copying")
|
||||||
|
dusk_asset_copy("${ASSET_SOURCE}" "${ASSET_RELATIVE}" ASSET_OUTPUT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND ASSET_OUTPUTS "${ASSET_OUTPUT}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_target(${TARGET_NAME} ALL DEPENDS ${ASSET_OUTPUTS})
|
||||||
|
endfunction()
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Handler that copies an asset into the built assets directory as is. Every
|
||||||
|
# handler has the signature (SOURCE RELATIVE OUT_VAR) and must set OUT_VAR, in
|
||||||
|
# the caller's scope, to the file it produces.
|
||||||
|
function(dusk_asset_copy ASSET_SOURCE ASSET_RELATIVE OUT_VAR)
|
||||||
|
set(ASSET_OUTPUT "${DUSK_BUILT_ASSETS_DIR}/${ASSET_RELATIVE}")
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${ASSET_OUTPUT}"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${ASSET_SOURCE}" "${ASSET_OUTPUT}"
|
||||||
|
DEPENDS "${ASSET_SOURCE}"
|
||||||
|
COMMENT "Copying asset ${ASSET_RELATIVE}"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
set(${OUT_VAR} "${ASSET_OUTPUT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Handler for .obj (Wavefront mesh) assets. Currently just copies the file.
|
||||||
|
function(dusk_asset_obj ASSET_SOURCE ASSET_RELATIVE OUT_VAR)
|
||||||
|
dusk_asset_copy("${ASSET_SOURCE}" "${ASSET_RELATIVE}" ASSET_OUTPUT)
|
||||||
|
set(${OUT_VAR} "${ASSET_OUTPUT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Determines DUSK_TARGET_SYSTEM when it was not explicitly provided with
|
||||||
|
# -DDUSK_TARGET_SYSTEM=<target>. Must be included after project() so that the
|
||||||
|
# compiler and CMAKE_SYSTEM_NAME are known.
|
||||||
|
#
|
||||||
|
# Console toolchains all cross compile as "Generic", so they are recognised by
|
||||||
|
# the compiler they configure.
|
||||||
|
|
||||||
|
if(DUSK_TARGET_SYSTEM)
|
||||||
|
message(STATUS "Dusk target: ${DUSK_TARGET_SYSTEM} (explicit)")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER MATCHES "psp-")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "psp")
|
||||||
|
elseif(CMAKE_C_COMPILER MATCHES "arm-vita-eabi")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "vita")
|
||||||
|
elseif(CMAKE_C_COMPILER MATCHES "powerpc-eabi")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "dolphin")
|
||||||
|
elseif(CMAKE_C_COMPILER MATCHES "ps2")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "ps2")
|
||||||
|
elseif(CMAKE_C_COMPILER MATCHES "sh-elf")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "dreamcast")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "windows")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "linux")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Could not determine the target platform (system: ${CMAKE_SYSTEM_NAME}, "
|
||||||
|
"compiler: ${CMAKE_C_COMPILER}). Pass -DDUSK_TARGET_SYSTEM=<target>."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(DUSK_TARGET_SYSTEM "${DUSK_DETECTED_SYSTEM}" CACHE STRING
|
||||||
|
"Target platform" FORCE
|
||||||
|
)
|
||||||
|
set_property(CACHE DUSK_TARGET_SYSTEM PROPERTY STRINGS
|
||||||
|
linux windows psp dolphin vita ps2 dreamcast
|
||||||
|
)
|
||||||
|
message(STATUS "Dusk target: ${DUSK_TARGET_SYSTEM} (detected)")
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the dolphin target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskdolphin)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_BIG
|
||||||
|
DUSK_DOLPHIN
|
||||||
|
DUSK_THREAD_PTHREAD
|
||||||
|
)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the dreamcast target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskdreamcast)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_DREAMCAST
|
||||||
|
)
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the linux target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS dusklinux dusksdl3 duskvulkan)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE ON)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY ON)
|
||||||
|
|
||||||
|
# Linux runs on both endiannesses, so detect it from the target compiler.
|
||||||
|
include(TestBigEndian)
|
||||||
|
test_big_endian(DUSK_IS_BIG_ENDIAN)
|
||||||
|
if(DUSK_IS_BIG_ENDIAN)
|
||||||
|
set(DUSK_ENDIAN_DEFINITION DUSK_PLATFORM_ENDIAN_BIG)
|
||||||
|
else()
|
||||||
|
set(DUSK_ENDIAN_DEFINITION DUSK_PLATFORM_ENDIAN_LITTLE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
${DUSK_ENDIAN_DEFINITION}
|
||||||
|
DUSK_LINUX
|
||||||
|
DUSK_THREAD_PTHREAD
|
||||||
|
DUSK_TIME_DYNAMIC
|
||||||
|
)
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
cglm
|
|
||||||
# GIT_REPOSITORY https://git.wish.moe/YourWishes/cglm.git
|
|
||||||
GIT_REPOSITORY https://github.com/recp/cglm.git
|
|
||||||
GIT_TAG v0.9.6
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_MakeAvailable(cglm)
|
|
||||||
set(cglm_FOUND ON)
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
cmocka
|
|
||||||
GIT_REPOSITORY https://gitlab.com/cmocka/cmocka.git
|
|
||||||
GIT_TAG cmocka-2.0.1
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_MakeAvailable(cmocka)
|
|
||||||
set(cmocka_FOUND ON)
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
# Turn things off we don't need
|
|
||||||
set(JERRY_CMDLINE OFF CACHE BOOL "" FORCE)
|
|
||||||
set(JERRY_EXT ON CACHE BOOL "" FORCE)
|
|
||||||
set(JERRY_DEBUGGER OFF CACHE BOOL "" FORCE)
|
|
||||||
set(JERRY_BUILTIN_DATE OFF CACHE BOOL "" FORCE)
|
|
||||||
set(ENABLE_LTO OFF CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
# Fetch Jerry
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
jerryscript
|
|
||||||
GIT_REPOSITORY https://git.wish.moe/YourWishes/jerryscript
|
|
||||||
GIT_TAG float32-fix
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(jerryscript)
|
|
||||||
|
|
||||||
# Mark found
|
|
||||||
set(jerryscript_FOUND ON)
|
|
||||||
|
|
||||||
# Define targets
|
|
||||||
if(TARGET jerryscript-core)
|
|
||||||
set(JERRY_CORE_TARGET jerryscript-core)
|
|
||||||
elseif(TARGET jerry-core)
|
|
||||||
set(JERRY_CORE_TARGET jerry-core)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(TARGET jerryscript-ext)
|
|
||||||
set(JERRY_EXT_TARGET jerryscript-ext)
|
|
||||||
elseif(TARGET jerry-ext)
|
|
||||||
set(JERRY_EXT_TARGET jerry-ext)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(TARGET jerryscript-port-default)
|
|
||||||
set(JERRY_PORT_TARGET jerryscript-port-default)
|
|
||||||
elseif(TARGET jerry-port-default)
|
|
||||||
set(JERRY_PORT_TARGET jerry-port-default)
|
|
||||||
elseif(TARGET jerryscript-port)
|
|
||||||
set(JERRY_PORT_TARGET jerryscript-port)
|
|
||||||
elseif(TARGET jerry-port)
|
|
||||||
set(JERRY_PORT_TARGET jerry-port)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT JERRY_CORE_TARGET)
|
|
||||||
message(FATAL_ERROR "JerryScript core target not found")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT JERRY_EXT_TARGET)
|
|
||||||
message(FATAL_ERROR "JerryScript ext target not found")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT JERRY_PORT_TARGET)
|
|
||||||
message(FATAL_ERROR "JerryScript port target not found")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(tgt IN ITEMS
|
|
||||||
${JERRY_CORE_TARGET}
|
|
||||||
${JERRY_EXT_TARGET}
|
|
||||||
${JERRY_PORT_TARGET}
|
|
||||||
)
|
|
||||||
if(TARGET ${tgt})
|
|
||||||
set_property(TARGET ${tgt} PROPERTY INTERPROCEDURAL_OPTIMIZATION OFF)
|
|
||||||
target_compile_definitions(${JERRY_CORE_TARGET} PRIVATE
|
|
||||||
JERRY_NUMBER_TYPE_FLOAT64=0
|
|
||||||
JERRY_BUILTIN_DATE=0
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Export include dirs through the targets
|
|
||||||
target_include_directories(${JERRY_CORE_TARGET} INTERFACE
|
|
||||||
${jerryscript_SOURCE_DIR}/jerry-core/include
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(${JERRY_EXT_TARGET} INTERFACE
|
|
||||||
${jerryscript_SOURCE_DIR}/jerry-ext/include
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(${JERRY_PORT_TARGET} INTERFACE
|
|
||||||
${jerryscript_SOURCE_DIR}/jerry-port/default/include
|
|
||||||
)
|
|
||||||
|
|
||||||
# Suppress JerryScript-only warning
|
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
|
|
||||||
target_compile_options(${JERRY_CORE_TARGET} PRIVATE
|
|
||||||
-Wno-error
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(jerryscript::core ALIAS ${JERRY_CORE_TARGET})
|
|
||||||
add_library(jerryscript::ext ALIAS ${JERRY_EXT_TARGET})
|
|
||||||
add_library(jerryscript::port ALIAS ${JERRY_PORT_TARGET})
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
find_package(ZLIB REQUIRED)
|
|
||||||
|
|
||||||
find_path(LIBZIP_INCLUDE_DIR NAMES zip.h)
|
|
||||||
mark_as_advanced(LIBZIP_INCLUDE_DIR)
|
|
||||||
|
|
||||||
find_library(LIBZIP_LIBRARY NAMES zip)
|
|
||||||
mark_as_advanced(LIBZIP_LIBRARY)
|
|
||||||
|
|
||||||
get_filename_component(_libzip_libdir ${LIBZIP_LIBRARY} DIRECTORY)
|
|
||||||
find_file(_libzip_pkgcfg libzip.pc
|
|
||||||
HINTS ${_libzip_libdir} ${LIBZIP_INCLUDE_DIR}/..
|
|
||||||
PATH_SUFFIXES pkgconfig lib/pkgconfig libdata/pkgconfig
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(
|
|
||||||
LIBZIP
|
|
||||||
REQUIRED_VARS
|
|
||||||
LIBZIP_LIBRARY
|
|
||||||
LIBZIP_INCLUDE_DIR
|
|
||||||
_libzip_pkgcfg
|
|
||||||
)
|
|
||||||
|
|
||||||
if(LIBZIP_FOUND)
|
|
||||||
if(NOT TARGET libzip::zip)
|
|
||||||
add_library(libzip::zip UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(libzip::zip
|
|
||||||
PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${LIBZIP_INCLUDE_DIR}
|
|
||||||
INTERFACE_LINK_LIBRARIES ZLIB::ZLIB
|
|
||||||
IMPORTED_LOCATION ${LIBZIP_LIBRARY}
|
|
||||||
)
|
|
||||||
# (Ab)use the (always) installed pkgconfig file to check if BZip2 is required
|
|
||||||
file(STRINGS ${_libzip_pkgcfg} _have_extra_libs REGEX Libs)
|
|
||||||
if(_have_extra_libs MATCHES "-lbz2")
|
|
||||||
find_package(BZip2 REQUIRED)
|
|
||||||
set_property(TARGET libzip::zip APPEND PROPERTY INTERFACE_LINK_LIBRARIES BZip2::BZip2)
|
|
||||||
endif()
|
|
||||||
if(_have_extra_libs MATCHES "-lcrypto")
|
|
||||||
find_package(OpenSSL REQUIRED)
|
|
||||||
set_property(TARGET libzip::zip APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
|
|
||||||
endif()
|
|
||||||
if(_have_extra_libs MATCHES "-lgnutls")
|
|
||||||
find_package(GnuTLS REQUIRED)
|
|
||||||
set_property(TARGET libzip::zip APPEND PROPERTY INTERFACE_LINK_LIBRARIES GnuTLS::GnuTLS)
|
|
||||||
endif()
|
|
||||||
if(_have_extra_libs MATCHES "-lnettle")
|
|
||||||
find_package(Nettle REQUIRED)
|
|
||||||
set_property(TARGET libzip::zip APPEND PROPERTY INTERFACE_LINK_LIBRARIES Nettle::Nettle)
|
|
||||||
endif()
|
|
||||||
if(_have_extra_libs MATCHES "-llzma")
|
|
||||||
find_package(LibLZMA REQUIRED)
|
|
||||||
set_property(TARGET libzip::zip APPEND PROPERTY INTERFACE_LINK_LIBRARIES LibLZMA::LibLZMA)
|
|
||||||
endif()
|
|
||||||
if(_have_extra_libs MATCHES "-lz")
|
|
||||||
find_package(ZLIB REQUIRED)
|
|
||||||
set_property(TARGET libzip::zip APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
stb
|
|
||||||
GIT_REPOSITORY https://github.com/nothings/stb.git
|
|
||||||
)
|
|
||||||
|
|
||||||
# Fetch stb if not already done
|
|
||||||
FetchContent_MakeAvailable(stb)
|
|
||||||
|
|
||||||
# Find the stb_image.h header
|
|
||||||
set(STB_INCLUDE_DIR "${stb_SOURCE_DIR}")
|
|
||||||
set(STB_IMAGE_HEADER "${stb_SOURCE_DIR}/stb_image.h")
|
|
||||||
|
|
||||||
if(EXISTS "${STB_IMAGE_HEADER}")
|
|
||||||
add_library(stb_image INTERFACE)
|
|
||||||
target_include_directories(stb_image INTERFACE "${STB_INCLUDE_DIR}")
|
|
||||||
set(STB_IMAGE_FOUND TRUE)
|
|
||||||
else()
|
|
||||||
set(STB_IMAGE_FOUND FALSE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Standard CMake variables
|
|
||||||
set(STB_IMAGE_INCLUDE_DIRS "${STB_INCLUDE_DIR}")
|
|
||||||
set(STB_IMAGE_LIBRARIES stb_image)
|
|
||||||
|
|
||||||
mark_as_advanced(STB_IMAGE_INCLUDE_DIRS STB_IMAGE_LIBRARIES STB_IMAGE_FOUND)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
include(FetchContent)
|
|
||||||
|
|
||||||
if(NOT TARGET yyjson)
|
|
||||||
FetchContent_Declare(
|
|
||||||
yyjson
|
|
||||||
GIT_REPOSITORY https://github.com/ibireme/yyjson.git
|
|
||||||
GIT_TAG 0.12.0
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(yyjson)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Provide an imported target if not already available
|
|
||||||
if(NOT TARGET yyjson::yyjson)
|
|
||||||
add_library(yyjson::yyjson ALIAS yyjson)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Mark yyjson as found for find_package compatibility
|
|
||||||
set(yyjson_FOUND TRUE)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
find_package(cmocka REQUIRED)
|
|
||||||
|
|
||||||
# Function to create a test executable from a single .c file
|
|
||||||
function(dusktest TEST_C_FILE)
|
|
||||||
# Create target name from file name
|
|
||||||
get_filename_component(TEST_NAME ${TEST_C_FILE} NAME_WE)
|
|
||||||
|
|
||||||
# Create the executable target
|
|
||||||
add_executable(${TEST_NAME})
|
|
||||||
|
|
||||||
# Setup some compiler definitions.
|
|
||||||
target_compile_definitions(${TEST_NAME} PRIVATE
|
|
||||||
DUSK_TEST_ASSERT=1
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add the test file
|
|
||||||
target_sources(${TEST_NAME} PRIVATE ${TEST_C_FILE})
|
|
||||||
|
|
||||||
# Add sources, both common and test-specific
|
|
||||||
target_include_directories(${TEST_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR} ${DUSK_TEST_DIR})
|
|
||||||
|
|
||||||
# Link against DuskCore and cmocka
|
|
||||||
target_link_libraries(${TEST_NAME} PUBLIC ${DUSK_LIBRARY_TARGET_NAME} cmocka)
|
|
||||||
|
|
||||||
# Add as a CTest
|
|
||||||
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
|
|
||||||
endfunction()
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# All user facing CMake options and their defaults. Included by the root
|
||||||
|
# CMakeLists.txt after the platform's target.cmake, which supplies the
|
||||||
|
# DUSK_DEFAULT_* values used below. DUSK_TARGET_SYSTEM itself is declared by
|
||||||
|
# determineplatform.cmake.
|
||||||
|
|
||||||
|
# General
|
||||||
|
option(DUSK_BUILD_TESTS "Enable tests." OFF)
|
||||||
|
option(DUSK_NETWORK "Enable network support." ON)
|
||||||
|
|
||||||
|
# Game metadata
|
||||||
|
set(DUSK_GAME "duskexample" CACHE STRING
|
||||||
|
"Directory under src/ containing the game to build (provides game/game.c)."
|
||||||
|
)
|
||||||
|
set(DUSK_GAME_NAME "Dusk" CACHE STRING "Game display name.")
|
||||||
|
set(DUSK_GAME_AUTHOR "YourWishes" CACHE STRING "Game author / coder.")
|
||||||
|
if(NOT DEFINED DUSK_VERSION)
|
||||||
|
string(TIMESTAMP DUSK_VERSION "debug-%y%m%d%H%M%S")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Platform dependent defaults
|
||||||
|
option(DUSK_ASSERTIONS_FAKED
|
||||||
|
"Compile assertions out (they do nothing)."
|
||||||
|
${DUSK_DEFAULT_ASSERTIONS_FAKED}
|
||||||
|
)
|
||||||
|
option(DUSK_BACKTRACE
|
||||||
|
"Log a stack trace on assertion failure."
|
||||||
|
${DUSK_DEFAULT_BACKTRACE}
|
||||||
|
)
|
||||||
|
option(DUSK_TRACK_MEMORY
|
||||||
|
"Track memoryAllocate() call sites to help find memory leaks."
|
||||||
|
${DUSK_DEFAULT_TRACK_MEMORY}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Tests mock assertions, so they can never be faked.
|
||||||
|
if(DUSK_BUILD_TESTS AND DUSK_ASSERTIONS_FAKED)
|
||||||
|
message(STATUS "DUSK_BUILD_TESTS: forcing DUSK_ASSERTIONS_FAKED off")
|
||||||
|
set(DUSK_ASSERTIONS_FAKED OFF CACHE BOOL "" FORCE)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the ps2 target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskps2)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_PS2
|
||||||
|
)
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the psp target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskpsp)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_PSP
|
||||||
|
DUSK_THREAD_PTHREAD
|
||||||
|
)
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
# Build type: DOL (SD/USB via libfat) or ISO (DVD disc via libogc DVD driver)
|
|
||||||
set(DUSK_DOLPHIN_BUILD_TYPE "DOL" CACHE STRING "Dolphin asset source: DOL (SD/USB) or ISO (DVD disc)")
|
|
||||||
set_property(CACHE DUSK_DOLPHIN_BUILD_TYPE PROPERTY STRINGS "DOL" "ISO")
|
|
||||||
|
|
||||||
# Numeric tokens so #if DUSK_DOLPHIN_BUILD_TYPE == DOL works in C.
|
|
||||||
# DUSK_DOLPHIN_BUILD_TYPE is passed without quotes so it expands to the identifier.
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_DOLPHIN
|
|
||||||
DUSK_INPUT_GAMEPAD
|
|
||||||
# DUSK_DISPLAY_WIDTH=640
|
|
||||||
# DUSK_DISPLAY_HEIGHT=480
|
|
||||||
DUSK_DISPLAY_WIDTH=320
|
|
||||||
DUSK_DISPLAY_HEIGHT=240
|
|
||||||
DUSK_DISPLAY_OVERSCAN=16
|
|
||||||
DUSK_THREAD_PTHREAD
|
|
||||||
DOL=1
|
|
||||||
ISO=2
|
|
||||||
DUSK_DOLPHIN_BUILD_TYPE=${DUSK_DOLPHIN_BUILD_TYPE}
|
|
||||||
# GameCube/Wii PowerPC is always big-endian; declare it at compile time
|
|
||||||
# like every other target instead of relying on endian.h's runtime probe.
|
|
||||||
DUSK_PLATFORM_ENDIAN_BIG
|
|
||||||
)
|
|
||||||
|
|
||||||
# Custom compiler flags
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
|
|
||||||
|
|
||||||
# Disable all warnings
|
|
||||||
target_compile_options(${DUSK_LIBRARY_TARGET_NAME} PRIVATE -w)
|
|
||||||
|
|
||||||
# cglm: fetched at source level via Findcglm.cmake (FetchContent, headers only)
|
|
||||||
find_package(cglm REQUIRED)
|
|
||||||
|
|
||||||
# Pre-create ZLIB::ZLIB so any downstream cmake module that resolves it
|
|
||||||
# (FindZLIB, pkg-config IMPORTED_TARGET Requires processing) gets plain -lz
|
|
||||||
# rather than an unresolvable IMPORTED target that the PPC linker rejects.
|
|
||||||
if(NOT TARGET ZLIB::ZLIB)
|
|
||||||
add_library(ZLIB::ZLIB INTERFACE IMPORTED GLOBAL)
|
|
||||||
set_target_properties(ZLIB::ZLIB PROPERTIES INTERFACE_LINK_LIBRARIES "z")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Mark libzip as found so src/dusk/CMakeLists.txt skips Findlibzip.cmake.
|
|
||||||
# Findlibzip.cmake calls find_package(ZLIB) which can recreate a broken
|
|
||||||
# ZLIB::ZLIB IMPORTED target, bypassing the shim above.
|
|
||||||
set(libzip_FOUND TRUE CACHE BOOL "libzip found (devkitpro portlibs)" FORCE)
|
|
||||||
|
|
||||||
# Locate zip.h in the devkitpro sysroot (respects CMAKE_FIND_ROOT_PATH).
|
|
||||||
find_path(_dusk_zip_inc NAMES zip.h)
|
|
||||||
if(_dusk_zip_inc)
|
|
||||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PRIVATE "${_dusk_zip_inc}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Link libraries.
|
|
||||||
# zip/z/lzma use target_link_options (raw flags) to bypass cmake target
|
|
||||||
# resolution - pkg-config-generated targets for these carry ZLIB::ZLIB in
|
|
||||||
# INTERFACE_LINK_LIBRARIES which breaks the PPC link step.
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
|
||||||
cglm
|
|
||||||
m
|
|
||||||
zip
|
|
||||||
bz2
|
|
||||||
zstd
|
|
||||||
z
|
|
||||||
lzma
|
|
||||||
)
|
|
||||||
|
|
||||||
if(DUSK_DOLPHIN_BUILD_TYPE STREQUAL "ISO")
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC DUSK_DOLPHIN_BUILD_ISO)
|
|
||||||
else()
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE fat)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Postbuild: ELF -> DOL
|
|
||||||
set(DUSK_BINARY_TARGET_NAME_DOL "${DUSK_BUILD_DIR}/Dusk.dol")
|
|
||||||
add_custom_command(TARGET ${DUSK_BINARY_TARGET_NAME} POST_BUILD
|
|
||||||
COMMAND elf2dol
|
|
||||||
"$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>"
|
|
||||||
"${DUSK_BINARY_TARGET_NAME_DOL}"
|
|
||||||
COMMENT "Generating ${DUSK_BINARY_TARGET_NAME_DOL} from ${DUSK_BINARY_TARGET_NAME}"
|
|
||||||
)
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
include(cmake/targets/dolphin.cmake)
|
|
||||||
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_GAMECUBE
|
|
||||||
)
|
|
||||||
|
|
||||||
# Link libraries
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
|
||||||
bba
|
|
||||||
)
|
|
||||||
|
|
||||||
# ISO post-build: produce NTSC-J, NTSC-U and PAL disc images
|
|
||||||
if(DUSK_DOLPHIN_BUILD_TYPE STREQUAL "ISO")
|
|
||||||
add_custom_command(TARGET ${DUSK_BINARY_TARGET_NAME} POST_BUILD
|
|
||||||
COMMAND ${Python3_EXECUTABLE}
|
|
||||||
"${CMAKE_SOURCE_DIR}/tools/makedolphiniso.py"
|
|
||||||
"GCN"
|
|
||||||
"${DUSK_BINARY_TARGET_NAME_DOL}"
|
|
||||||
"${DUSK_ASSETS_ZIP}"
|
|
||||||
"${DUSK_GAME_NAME}"
|
|
||||||
"${DUSK_BUILD_DIR}"
|
|
||||||
COMMENT "Building GameCube ISO images (NTSC-J, NTSC-U, PAL)"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
# Find link platform-specific libraries
|
|
||||||
set(OpenGL_GL_PREFERENCE LEGACY)
|
|
||||||
find_package(SDL2 REQUIRED)
|
|
||||||
find_library(EGL_LIB EGL REQUIRED)
|
|
||||||
find_library(GL_LIB GL REQUIRED)
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
|
|
||||||
# Setup endianess at compile time to optimize.
|
|
||||||
include(TestBigEndian)
|
|
||||||
test_big_endian(IS_BIG_ENDIAN)
|
|
||||||
if(IS_BIG_ENDIAN)
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_PLATFORM_ENDIAN_BIG
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_PLATFORM_ENDIAN_LITTLE
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Link required libraries.
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
|
||||||
SDL2
|
|
||||||
pthread
|
|
||||||
OpenGL::GLES2
|
|
||||||
${GL_LIB}
|
|
||||||
${EGL_LIB}
|
|
||||||
m
|
|
||||||
)
|
|
||||||
|
|
||||||
# Define platform-specific macros.
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_SDL2
|
|
||||||
DUSK_OPENGL
|
|
||||||
DUSK_OPENGL_ES
|
|
||||||
DUSK_LINUX
|
|
||||||
DUSK_KNULLI
|
|
||||||
DUSK_DISPLAY_SIZE_DYNAMIC
|
|
||||||
DUSK_DISPLAY_WIDTH_DEFAULT=640
|
|
||||||
DUSK_DISPLAY_HEIGHT_DEFAULT=480
|
|
||||||
DUSK_DISPLAY_SCREEN_HEIGHT=240
|
|
||||||
DUSK_INPUT_KEYBOARD
|
|
||||||
DUSK_INPUT_POINTER
|
|
||||||
DUSK_INPUT_GAMEPAD
|
|
||||||
DUSK_TIME_DYNAMIC
|
|
||||||
)
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
# Find link platform-specific libraries
|
|
||||||
find_package(SDL2 REQUIRED)
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
# find_package(CURL REQUIRED)
|
|
||||||
|
|
||||||
# Setup endianess at compile time to optimize.
|
|
||||||
include(TestBigEndian)
|
|
||||||
test_big_endian(IS_BIG_ENDIAN)
|
|
||||||
if(IS_BIG_ENDIAN)
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_PLATFORM_ENDIAN_BIG
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_PLATFORM_ENDIAN_LITTLE
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Link required libraries.
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
SDL2
|
|
||||||
pthread
|
|
||||||
OpenGL::GL
|
|
||||||
GL
|
|
||||||
m
|
|
||||||
# CURL::libcurl
|
|
||||||
)
|
|
||||||
|
|
||||||
set(DUSK_BACKTRACE ON CACHE BOOL "Enable backtrace support for assert failures.")
|
|
||||||
|
|
||||||
# Define platform-specific macros.
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_SDL2
|
|
||||||
DUSK_OPENGL
|
|
||||||
# DUSK_OPENGL_LEGACY
|
|
||||||
DUSK_LINUX
|
|
||||||
DUSK_DISPLAY_SIZE_DYNAMIC
|
|
||||||
DUSK_DISPLAY_WIDTH_DEFAULT=854
|
|
||||||
DUSK_DISPLAY_HEIGHT_DEFAULT=480
|
|
||||||
DUSK_DISPLAY_SCREEN_HEIGHT=240
|
|
||||||
DUSK_INPUT_KEYBOARD
|
|
||||||
DUSK_INPUT_POINTER
|
|
||||||
DUSK_INPUT_GAMEPAD
|
|
||||||
DUSK_TIME_DYNAMIC
|
|
||||||
DUSK_NETWORK_IPV6
|
|
||||||
DUSK_THREAD_PTHREAD
|
|
||||||
)
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
|
||||||
set(CMAKE_RANLIB "$ENV{PSPDEV}/bin/psp-ranlib" CACHE FILEPATH "" FORCE)
|
|
||||||
set(CMAKE_C_COMPILER_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
|
||||||
set(CMAKE_C_COMPILER_RANLIB "$ENV{PSPDEV}/bin/psp-ranlib" CACHE FILEPATH "" FORCE)
|
|
||||||
set(CMAKE_C_ARCHIVE_CREATE "$ENV{PSPDEV}/bin/psp-ar qc <TARGET> <LINK_FLAGS> <OBJECTS>")
|
|
||||||
set(CMAKE_C_ARCHIVE_APPEND "$ENV{PSPDEV}/bin/psp-ar q <TARGET> <LINK_FLAGS> <OBJECTS>")
|
|
||||||
set(CMAKE_C_ARCHIVE_FINISH "$ENV{PSPDEV}/bin/psp-ranlib <TARGET>")
|
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF CACHE BOOL "" FORCE)
|
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_C OFF CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
find_package(SDL2 REQUIRED)
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
target_link_libraries(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
|
||||||
${SDL2_LIBRARIES}
|
|
||||||
SDL2
|
|
||||||
pthread
|
|
||||||
OpenGL::GL
|
|
||||||
zip
|
|
||||||
bz2
|
|
||||||
z
|
|
||||||
mbedtls
|
|
||||||
mbedcrypto
|
|
||||||
lzma
|
|
||||||
m
|
|
||||||
|
|
||||||
pspdebug
|
|
||||||
pspdisplay
|
|
||||||
pspge
|
|
||||||
pspctrl
|
|
||||||
pspgu
|
|
||||||
pspaudio
|
|
||||||
pspaudiolib
|
|
||||||
psputility
|
|
||||||
pspvfpu
|
|
||||||
pspvram
|
|
||||||
psphprm
|
|
||||||
pspnet
|
|
||||||
pspnet_inet
|
|
||||||
pspnet_apctl
|
|
||||||
psphttp
|
|
||||||
pspssl
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(${DUSK_BINARY_TARGET_NAME} PRIVATE
|
|
||||||
${SDL2_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_SDL2
|
|
||||||
DUSK_OPENGL
|
|
||||||
DUSK_PSP
|
|
||||||
DUSK_INPUT_GAMEPAD
|
|
||||||
DUSK_PLATFORM_ENDIAN_LITTLE
|
|
||||||
DUSK_OPENGL_LEGACY
|
|
||||||
DUSK_DISPLAY_WIDTH=480
|
|
||||||
DUSK_DISPLAY_HEIGHT=272
|
|
||||||
DUSK_THREAD_PTHREAD
|
|
||||||
DUSK_DISPLAY_OVERSCAN=6
|
|
||||||
)
|
|
||||||
|
|
||||||
# Postbuild, create .pbp file for PSP.
|
|
||||||
create_pbp_file(
|
|
||||||
TARGET "${DUSK_BINARY_TARGET_NAME}"
|
|
||||||
ICON_PATH NULL
|
|
||||||
BACKGROUND_PATH NULL
|
|
||||||
PREVIEW_PATH NULL
|
|
||||||
TITLE "${DUSK_BINARY_TARGET_NAME}"
|
|
||||||
PSAR_PATH ${DUSK_ASSETS_ZIP}
|
|
||||||
VERSION 01.00
|
|
||||||
)
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
include(cmake/targets/dolphin.cmake)
|
|
||||||
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_WII
|
|
||||||
)
|
|
||||||
|
|
||||||
# Generate Homebrew Channel meta.xml from project identity variables
|
|
||||||
string(TIMESTAMP DUSK_BUILD_DATE "%Y%m%d000000" UTC)
|
|
||||||
configure_file(
|
|
||||||
"${CMAKE_SOURCE_DIR}/docker/dolphin/meta.xml.in"
|
|
||||||
"${DUSK_BUILD_DIR}/meta.xml"
|
|
||||||
@ONLY
|
|
||||||
)
|
|
||||||
|
|
||||||
# ISO post-build: produce NTSC-J, NTSC-U and PAL disc images
|
|
||||||
if(DUSK_DOLPHIN_BUILD_TYPE STREQUAL "ISO")
|
|
||||||
add_custom_command(TARGET ${DUSK_BINARY_TARGET_NAME} POST_BUILD
|
|
||||||
COMMAND ${Python3_EXECUTABLE}
|
|
||||||
"${CMAKE_SOURCE_DIR}/tools/makedolphiniso.py"
|
|
||||||
"WII"
|
|
||||||
"${DUSK_BINARY_TARGET_NAME_DOL}"
|
|
||||||
"${DUSK_ASSETS_ZIP}"
|
|
||||||
"${DUSK_GAME_NAME}"
|
|
||||||
"${DUSK_BUILD_DIR}"
|
|
||||||
COMMENT "Building Wii ISO images (NTSC-J, NTSC-U, PAL)"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
set(CMAKE_SYSTEM_NAME Linux)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
|
||||||
|
|
||||||
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
|
||||||
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
|
|
||||||
set(CMAKE_ASM_COMPILER aarch64-linux-gnu-gcc)
|
|
||||||
|
|
||||||
set(CMAKE_SYSROOT /)
|
|
||||||
set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu)
|
|
||||||
set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-gnu)
|
|
||||||
|
|
||||||
set(CMAKE_FIND_ROOT_PATH
|
|
||||||
/usr/aarch64-linux-gnu
|
|
||||||
/usr/lib/aarch64-linux-gnu
|
|
||||||
/usr/include/aarch64-linux-gnu
|
|
||||||
)
|
|
||||||
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|
||||||
|
|
||||||
set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig")
|
|
||||||
set(ENV{PKG_CONFIG_PATH} "/usr/lib/aarch64-linux-gnu/pkgconfig")
|
|
||||||
|
|
||||||
set(CMAKE_PREFIX_PATH "/usr/aarch64-linux-gnu;/usr/lib/aarch64-linux-gnu")
|
|
||||||
|
|
||||||
# Optional: helps some Find modules
|
|
||||||
set(SDL2_DIR "/usr/lib/aarch64-linux-gnu/cmake/SDL2" CACHE PATH "")
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the vita target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskvita)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_VITA
|
||||||
|
DUSK_THREAD_PTHREAD
|
||||||
|
)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the windows target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskwindows dusksdl3 duskvulkan)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY ON)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_WINDOWS
|
||||||
|
)
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
FROM ghcr.io/extremscorner/libogc2
|
|
||||||
WORKDIR /workdir
|
|
||||||
RUN apt update && \
|
|
||||||
dkp-pacman -Syu --noconfirm && \
|
|
||||||
apt install -y python3 python3-pip python3-polib python3-pil python3-dotenv python3-pyqt5 python3-opengl xorriso dolphin-emu xvfb && \
|
|
||||||
dkp-pacman -S --needed --noconfirm gamecube-sdl2 ppc-liblzma ppc-libzip libogc2 gamecube-tools ppc-libmad ppc-zlib-ng ppc-liblzma ppc-bzip2 ppc-zstd
|
|
||||||
VOLUME ["/workdir"]
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
FROM ghcr.io/extremscorner/libogc2
|
|
||||||
WORKDIR /workdir
|
|
||||||
RUN apt update && \
|
|
||||||
dkp-pacman -Syu --noconfirm && \
|
|
||||||
apt install -y python3 python3-pip python3-polib python3-pil python3-dotenv python3-pyqt5 python3-opengl xorriso && \
|
|
||||||
dkp-pacman -S --needed --noconfirm gamecube-sdl2 ppc-liblzma ppc-libzip libogc2 gamecube-tools ppc-libmad ppc-zlib-ng ppc-liblzma ppc-bzip2 ppc-zstd
|
|
||||||
VOLUME ["/workdir"]
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
||||||
<app version="1">
|
|
||||||
<name>@DUSK_GAME_NAME@</name>
|
|
||||||
<version>@PROJECT_VERSION@</version>
|
|
||||||
<release_date>@DUSK_BUILD_DATE@</release_date>
|
|
||||||
<coder>@DUSK_GAME_AUTHOR@</coder>
|
|
||||||
<short_description>@DUSK_GAME_SHORT_DESCRIPTION@</short_description>
|
|
||||||
<long_description>@DUSK_GAME_LONG_DESCRIPTION@</long_description>
|
|
||||||
<ahb_access/>
|
|
||||||
</app>
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
FROM debian:trixie
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
WORKDIR /workdir
|
|
||||||
RUN dpkg --add-architecture arm64 && \
|
|
||||||
apt-get update && \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
crossbuild-essential-arm64 \
|
|
||||||
ca-certificates \
|
|
||||||
pkg-config \
|
|
||||||
cmake \
|
|
||||||
make \
|
|
||||||
ninja-build \
|
|
||||||
git \
|
|
||||||
file \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-polib \
|
|
||||||
python3-pil \
|
|
||||||
python3-dotenv \
|
|
||||||
python3-pyqt5 \
|
|
||||||
python3-opengl \
|
|
||||||
liblua5.4-dev:arm64 \
|
|
||||||
xz-utils:arm64 \
|
|
||||||
libbz2-dev:arm64 \
|
|
||||||
zlib1g-dev:arm64 \
|
|
||||||
libzip-dev:arm64 \
|
|
||||||
libssl-dev:arm64 \
|
|
||||||
libsdl2-dev:arm64 \
|
|
||||||
liblzma-dev:arm64 \
|
|
||||||
libopengl0:arm64 \
|
|
||||||
libgl1:arm64 \
|
|
||||||
libegl1:arm64 \
|
|
||||||
libgles2:arm64 \
|
|
||||||
libgl1-mesa-dev:arm64 && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
+3
-22
@@ -1,24 +1,5 @@
|
|||||||
FROM ubuntu:latest
|
FROM ubuntu:latest
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
WORKDIR /workdir
|
WORKDIR /workdir
|
||||||
RUN apt-get update
|
COPY scripts/linux/install.sh /tmp/install.sh
|
||||||
RUN apt-get install -y \
|
RUN chmod +x /tmp/install.sh && /tmp/install.sh && rm /tmp/install.sh
|
||||||
build-essential \
|
|
||||||
cmake \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-polib \
|
|
||||||
python3-pil \
|
|
||||||
libsdl2-dev \
|
|
||||||
libgl1-mesa-dev \
|
|
||||||
libzip-dev \
|
|
||||||
python3-dotenv \
|
|
||||||
python3-pyqt5 \
|
|
||||||
python3-opengl \
|
|
||||||
xz-utils \
|
|
||||||
liblzma-dev \
|
|
||||||
libbz2-dev \
|
|
||||||
zlib1g-dev \
|
|
||||||
libzip-dev \
|
|
||||||
libbz2-dev \
|
|
||||||
git \
|
|
||||||
libssl-dev
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
FROM pspdev/pspdev:latest
|
|
||||||
WORKDIR /workdir
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
python3 \
|
|
||||||
py3-pip \
|
|
||||||
py3-dotenv \
|
|
||||||
git \
|
|
||||||
cmake \
|
|
||||||
make \
|
|
||||||
g++ \
|
|
||||||
sdl2-dev \
|
|
||||||
zlib-dev \
|
|
||||||
linux-headers
|
|
||||||
|
|
||||||
# PPSSPP has no Alpine/Linux distro package -- build the "PPSSPPHeadless"
|
|
||||||
# target (the CLI/no-window build PPSSPP's own CI uses for automated runs)
|
|
||||||
# from source instead. The target name and exact CMake options have moved
|
|
||||||
# around across PPSSPP versions -- if this breaks, check
|
|
||||||
# https://github.com/hrydgard/ppsspp's CMakeLists.txt for the current name.
|
|
||||||
RUN git clone --recursive --depth 1 \
|
|
||||||
https://github.com/hrydgard/ppsspp.git /opt/ppsspp && \
|
|
||||||
cd /opt/ppsspp && \
|
|
||||||
cmake -B build -DCMAKE_BUILD_TYPE=Release && \
|
|
||||||
cmake --build build --target PPSSPPHeadless -- -j$(nproc) && \
|
|
||||||
cp build/PPSSPPHeadless /usr/local/bin/PPSSPPHeadless && \
|
|
||||||
rm -rf /opt/ppsspp
|
|
||||||
|
|
||||||
VOLUME ["/workdir"]
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
FROM pspdev/pspdev:latest
|
FROM pspdev/pspdev:latest
|
||||||
WORKDIR /workdir
|
WORKDIR /workdir
|
||||||
RUN apk add --no-cache \
|
COPY scripts/psp/install.sh /tmp/install.sh
|
||||||
python3 \
|
RUN chmod +x /tmp/install.sh && /tmp/install.sh && rm /tmp/install.sh
|
||||||
py3-pip \
|
VOLUME ["/workdir"]
|
||||||
py3-dotenv
|
|
||||||
VOLUME ["/workdir"]
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
FROM vitasdk/vitasdk:latest
|
|
||||||
WORKDIR /workdir
|
|
||||||
|
|
||||||
# Install vitaGL and its dependencies (vitashark, SceShaccCg) via vdpm
|
|
||||||
RUN which vdpm
|
|
||||||
|
|
||||||
# Install Python (needed for Dusk code generation tools)
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
python3 \
|
|
||||||
py3-pip \
|
|
||||||
py3-dotenv
|
|
||||||
|
|
||||||
VOLUME ["/workdir"]
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// ChunkTerrain - JS port of the terrain-quad generation performed by
|
|
||||||
// tools/asset/chunk/__main__.py (build_terrain_verts / _tile_quad /
|
|
||||||
// _RAMP_CORNERS) so the editor's 3D preview can show the same geometry the
|
|
||||||
// Python compiler will bake into the chunk's terrain mesh, without waiting
|
|
||||||
// for a compile pass. Vertex layout matches DMF: interleaved [u, v, x, y, z].
|
|
||||||
|
|
||||||
const ChunkTerrain = (() => {
|
|
||||||
const CHUNK_WIDTH = 16;
|
|
||||||
const CHUNK_HEIGHT = 16;
|
|
||||||
const CHUNK_DEPTH = 4;
|
|
||||||
const TILE_COUNT = CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH;
|
|
||||||
|
|
||||||
// World-space Z distance of one Z-layer/story, in world-float space.
|
|
||||||
// Must match WORLD_LAYER_HEIGHT in src/dusk/rpg/overworld/worldpos.h.
|
|
||||||
const WORLD_LAYER_HEIGHT = Math.SQRT1_2;
|
|
||||||
|
|
||||||
const TILE_SHAPE_NULL = 0;
|
|
||||||
const TILE_SHAPE_GROUND = 1;
|
|
||||||
const TILE_SHAPE_RAMP_NORTH = 2;
|
|
||||||
const TILE_SHAPE_RAMP_EAST = 3;
|
|
||||||
const TILE_SHAPE_RAMP_SOUTH = 4;
|
|
||||||
const TILE_SHAPE_RAMP_WEST = 5;
|
|
||||||
const TILE_SHAPE_RAMP_NORTHEAST = 6;
|
|
||||||
const TILE_SHAPE_RAMP_NORTHWEST = 7;
|
|
||||||
const TILE_SHAPE_RAMP_SOUTHEAST = 8;
|
|
||||||
const TILE_SHAPE_RAMP_SOUTHWEST = 9;
|
|
||||||
const TILE_SHAPE_RAMP_NORTHEAST_INNER = 10;
|
|
||||||
const TILE_SHAPE_RAMP_NORTHWEST_INNER = 11;
|
|
||||||
const TILE_SHAPE_RAMP_SOUTHEAST_INNER = 12;
|
|
||||||
const TILE_SHAPE_RAMP_SOUTHWEST_INNER = 13;
|
|
||||||
|
|
||||||
// Per-shape corner heights as [sw, se, ne, nw] offsets from tile base Z.
|
|
||||||
// NORTH=+Y, EAST=+X. Cardinal ramps: low face at 0, high face at 1.
|
|
||||||
// Diagonal outer-corner ramps: only the named corner raised, rest at 0.
|
|
||||||
// Diagonal inner-corner ramps: only the corner opposite the named one is
|
|
||||||
// lowered to 0, the rest (including the named corner) stay raised at 1.
|
|
||||||
const RAMP_CORNERS = {
|
|
||||||
[TILE_SHAPE_GROUND]: [0.0, 0.0, 0.0, 0.0],
|
|
||||||
[TILE_SHAPE_RAMP_NORTH]: [0.0, 0.0, 1.0, 1.0],
|
|
||||||
[TILE_SHAPE_RAMP_SOUTH]: [1.0, 1.0, 0.0, 0.0],
|
|
||||||
[TILE_SHAPE_RAMP_EAST]: [0.0, 1.0, 1.0, 0.0],
|
|
||||||
[TILE_SHAPE_RAMP_WEST]: [1.0, 0.0, 0.0, 1.0],
|
|
||||||
[TILE_SHAPE_RAMP_NORTHEAST]: [0.0, 0.0, 1.0, 0.0],
|
|
||||||
[TILE_SHAPE_RAMP_NORTHWEST]: [0.0, 0.0, 0.0, 1.0],
|
|
||||||
[TILE_SHAPE_RAMP_SOUTHEAST]: [0.0, 1.0, 0.0, 0.0],
|
|
||||||
[TILE_SHAPE_RAMP_SOUTHWEST]: [1.0, 0.0, 0.0, 0.0],
|
|
||||||
[TILE_SHAPE_RAMP_NORTHEAST_INNER]: [0.0, 1.0, 1.0, 1.0],
|
|
||||||
[TILE_SHAPE_RAMP_NORTHWEST_INNER]: [1.0, 0.0, 1.0, 1.0],
|
|
||||||
[TILE_SHAPE_RAMP_SOUTHEAST_INNER]: [1.0, 1.0, 1.0, 0.0],
|
|
||||||
[TILE_SHAPE_RAMP_SOUTHWEST_INNER]: [1.0, 1.0, 0.0, 1.0],
|
|
||||||
};
|
|
||||||
|
|
||||||
function tileIndex(x, y, z) {
|
|
||||||
return x + y * CHUNK_WIDTH + z * CHUNK_WIDTH * CHUNK_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Six vertices (2 CCW triangles) for a quad with per-corner Z heights.
|
|
||||||
// Corner order: SW=(fx,fy), SE=(fx+1,fy), NE=(fx+1,fy+1), NW=(fx,fy+1).
|
|
||||||
function pushTileQuad(out, u0, u1, v0, v1, fx, fy, swZ, seZ, neZ, nwZ) {
|
|
||||||
out.push(
|
|
||||||
u0, v0, fx, fy, swZ,
|
|
||||||
u1, v0, fx + 1, fy, seZ,
|
|
||||||
u1, v1, fx + 1, fy + 1, neZ,
|
|
||||||
u0, v0, fx, fy, swZ,
|
|
||||||
u1, v1, fx + 1, fy + 1, neZ,
|
|
||||||
u0, v1, fx, fy + 1, nwZ,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate terrain quads for every non-null tile in a flat tiles array
|
|
||||||
// (length TILE_COUNT, indexed via tileIndex). Returns a Float32Array of
|
|
||||||
// interleaved [u, v, x, y, z] vertices, matching DMF.VERTEX_FLOATS.
|
|
||||||
function buildTerrainVerts(tiles) {
|
|
||||||
const out = [];
|
|
||||||
for(let z = 0; z < CHUNK_DEPTH; z++) {
|
|
||||||
for(let y = 0; y < CHUNK_HEIGHT; y++) {
|
|
||||||
for(let x = 0; x < CHUNK_WIDTH; x++) {
|
|
||||||
const type = tiles[tileIndex(x, y, z)] || TILE_SHAPE_NULL;
|
|
||||||
const corners = RAMP_CORNERS[type];
|
|
||||||
if(!corners) continue;
|
|
||||||
|
|
||||||
const u0 = x / CHUNK_WIDTH;
|
|
||||||
const u1 = (x + 1) / CHUNK_WIDTH;
|
|
||||||
const v0 = y / CHUNK_HEIGHT;
|
|
||||||
const v1 = (y + 1) / CHUNK_HEIGHT;
|
|
||||||
const [sw, se, ne, nw] = corners;
|
|
||||||
|
|
||||||
pushTileQuad(
|
|
||||||
out, u0, u1, v0, v1, x, y,
|
|
||||||
(z + sw) * WORLD_LAYER_HEIGHT,
|
|
||||||
(z + se) * WORLD_LAYER_HEIGHT,
|
|
||||||
(z + ne) * WORLD_LAYER_HEIGHT,
|
|
||||||
(z + nw) * WORLD_LAYER_HEIGHT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new Float32Array(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Four edges (SW-SE, SE-NE, NE-NW, NW-SW) of a tile's quad as line
|
|
||||||
// segments, lifted slightly above the terrain surface to avoid
|
|
||||||
// z-fighting - same corner-height convention as pushTileQuad().
|
|
||||||
function pushTileGridLines(out, fx, fy, swZ, seZ, neZ, nwZ) {
|
|
||||||
const eps = 0.01;
|
|
||||||
const sw = [fx, fy, swZ + eps];
|
|
||||||
const se = [fx + 1, fy, seZ + eps];
|
|
||||||
const ne = [fx + 1, fy + 1, neZ + eps];
|
|
||||||
const nw = [fx, fy + 1, nwZ + eps];
|
|
||||||
const edges = [sw, se, se, ne, ne, nw, nw, sw];
|
|
||||||
for(const [x, y, z] of edges) out.push(0, 0, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate grid-outline line segments for every non-null tile, following
|
|
||||||
// the same per-corner heights as buildTerrainVerts() so lines hug ramps
|
|
||||||
// instead of cutting through them. Returns a Float32Array of interleaved
|
|
||||||
// [u, v, x, y, z] vertices meant to be drawn with gl.LINES (pairs).
|
|
||||||
function buildGridLines(tiles) {
|
|
||||||
const out = [];
|
|
||||||
for(let z = 0; z < CHUNK_DEPTH; z++) {
|
|
||||||
for(let y = 0; y < CHUNK_HEIGHT; y++) {
|
|
||||||
for(let x = 0; x < CHUNK_WIDTH; x++) {
|
|
||||||
const type = tiles[tileIndex(x, y, z)] || TILE_SHAPE_NULL;
|
|
||||||
const corners = RAMP_CORNERS[type];
|
|
||||||
if(!corners) continue;
|
|
||||||
|
|
||||||
const [sw, se, ne, nw] = corners;
|
|
||||||
pushTileGridLines(
|
|
||||||
out, x, y,
|
|
||||||
(z + sw) * WORLD_LAYER_HEIGHT,
|
|
||||||
(z + se) * WORLD_LAYER_HEIGHT,
|
|
||||||
(z + ne) * WORLD_LAYER_HEIGHT,
|
|
||||||
(z + nw) * WORLD_LAYER_HEIGHT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new Float32Array(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.freeze({
|
|
||||||
CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH, TILE_COUNT, WORLD_LAYER_HEIGHT,
|
|
||||||
TILE_SHAPE_NULL, TILE_SHAPE_GROUND,
|
|
||||||
TILE_SHAPE_RAMP_NORTH, TILE_SHAPE_RAMP_EAST,
|
|
||||||
TILE_SHAPE_RAMP_SOUTH, TILE_SHAPE_RAMP_WEST,
|
|
||||||
TILE_SHAPE_RAMP_NORTHEAST, TILE_SHAPE_RAMP_NORTHWEST,
|
|
||||||
TILE_SHAPE_RAMP_SOUTHEAST, TILE_SHAPE_RAMP_SOUTHWEST,
|
|
||||||
TILE_SHAPE_RAMP_NORTHEAST_INNER, TILE_SHAPE_RAMP_NORTHWEST_INNER,
|
|
||||||
TILE_SHAPE_RAMP_SOUTHEAST_INNER, TILE_SHAPE_RAMP_SOUTHWEST_INNER,
|
|
||||||
RAMP_CORNERS, tileIndex, buildTerrainVerts, buildGridLines,
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// DMF - Dusk Mesh Format
|
|
||||||
//
|
|
||||||
// Header (12 bytes):
|
|
||||||
// [0-3] "DMF\0" magic
|
|
||||||
// [4-7] uint32 version (little-endian)
|
|
||||||
// [8-11] uint32 vertCount (little-endian)
|
|
||||||
//
|
|
||||||
// Followed by vertCount vertices, each 20 bytes:
|
|
||||||
// [0-7] float32[2] uv (little-endian)
|
|
||||||
// [8-19] float32[3] pos (little-endian)
|
|
||||||
|
|
||||||
const DMF = (() => {
|
|
||||||
const MAGIC = [0x44, 0x4d, 0x46, 0x00]; // "DMF\0"
|
|
||||||
const VERSION = 1;
|
|
||||||
const HEADER_SIZE = 12;
|
|
||||||
const VERTEX_FLOATS = 5; // uv[2] + pos[3]
|
|
||||||
const VERTEX_SIZE = VERTEX_FLOATS * 4;
|
|
||||||
|
|
||||||
// Decode a DMF ArrayBuffer into { version, vertexCount, floats }, where
|
|
||||||
// floats is a Float32Array of tightly interleaved [u, v, x, y, z] per
|
|
||||||
// vertex - ready to hand straight to gl.bufferData().
|
|
||||||
function decode(buffer) {
|
|
||||||
const bytes = new Uint8Array(buffer);
|
|
||||||
const view = new DataView(buffer);
|
|
||||||
|
|
||||||
if(bytes.length < HEADER_SIZE) throw new Error("File too small to be a valid DMF");
|
|
||||||
if(
|
|
||||||
bytes[0] !== MAGIC[0] || bytes[1] !== MAGIC[1] ||
|
|
||||||
bytes[2] !== MAGIC[2] || bytes[3] !== MAGIC[3]
|
|
||||||
) {
|
|
||||||
throw new Error("Invalid DMF magic bytes - not a DMF file");
|
|
||||||
}
|
|
||||||
|
|
||||||
const version = view.getUint32(4, true);
|
|
||||||
if(version !== VERSION) {
|
|
||||||
throw new Error(`Unsupported DMF version: ${version}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const vertexCount = view.getUint32(8, true);
|
|
||||||
const expected = HEADER_SIZE + vertexCount * VERTEX_SIZE;
|
|
||||||
if(bytes.length < expected) {
|
|
||||||
throw new Error(`DMF vertex data truncated (expected ${expected} bytes, got ${bytes.length})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const floats = new Float32Array(vertexCount * VERTEX_FLOATS);
|
|
||||||
for(let i = 0; i < floats.length; i++) {
|
|
||||||
floats[i] = view.getFloat32(HEADER_SIZE + i * 4, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return { version, vertexCount, floats };
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.freeze({
|
|
||||||
decode,
|
|
||||||
VERSION, HEADER_SIZE, VERTEX_FLOATS, VERTEX_SIZE,
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>Dusk Map Editor</h1>
|
|
||||||
<p class="text-muted">Browse and edit project assets.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
<link rel="stylesheet" href="/map/map.css">
|
|
||||||
|
|
||||||
<div class="row g-3">
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="d-flex flex-wrap align-items-end gap-2 mb-2">
|
|
||||||
<div>
|
|
||||||
<label class="form-label mb-0">X</label>
|
|
||||||
<input type="number" id="coordX" class="form-control form-control-sm" style="width:5rem" value="0">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="form-label mb-0">Y</label>
|
|
||||||
<input type="number" id="coordY" class="form-control form-control-sm" style="width:5rem" value="0">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="form-label mb-0">Z</label>
|
|
||||||
<input type="number" id="coordZ" class="form-control form-control-sm" style="width:5rem" value="0">
|
|
||||||
</div>
|
|
||||||
<button id="btnLoad" type="button" class="btn btn-sm btn-secondary">Load</button>
|
|
||||||
|
|
||||||
<div class="dropdown">
|
|
||||||
<button
|
|
||||||
class="btn btn-sm btn-outline-secondary dropdown-toggle"
|
|
||||||
type="button" data-bs-toggle="dropdown"
|
|
||||||
>Browse</button>
|
|
||||||
<ul class="dropdown-menu" id="chunkBrowseList"></ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dpad" title="Navigate to the neighboring chunk">
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary dpad-n" id="navN" title="North (+Y)">N</button>
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary dpad-w" id="navW" title="West (-X)">W</button>
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary dpad-e" id="navE" title="East (+X)">E</button>
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary dpad-s" id="navS" title="South (-Y)">S</button>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex flex-column gap-1">
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="navUp" title="Up (+Z)">Up</button>
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="navDown" title="Down (-Z)">Down</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="btnSave" type="button" class="btn btn-sm btn-primary ms-auto">
|
|
||||||
Save & Compile
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div id="statusLine" class="small text-muted mb-2"> </div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12 col-lg-6">
|
|
||||||
<div class="d-flex align-items-center gap-2 mb-2">
|
|
||||||
<label class="form-label mb-0">Z-Level</label>
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="zLevelDown">-</button>
|
|
||||||
<input type="range" id="zLevel" class="form-range" style="width:150px" min="0" max="3" value="0">
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="zLevelUp">+</button>
|
|
||||||
<span id="zLevelLabel">0</span>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex gap-3">
|
|
||||||
<div id="toolPalette" class="tile-palette"></div>
|
|
||||||
<div id="tilePalette" class="tile-palette"></div>
|
|
||||||
<canvas id="gridCanvas" class="border tile-grid" width="512" height="512"></canvas>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h5 class="mt-3">Meshes</h5>
|
|
||||||
<ul id="meshList" class="list-group mb-2"></ul>
|
|
||||||
<div class="d-flex gap-2 align-items-end flex-wrap">
|
|
||||||
<div style="min-width:220px">
|
|
||||||
<label class="form-label mb-0">Model</label>
|
|
||||||
<select id="meshPicker" class="form-select form-select-sm"></select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="form-label mb-0">X</label>
|
|
||||||
<input id="meshX" type="number" class="form-control form-control-sm" style="width:5rem" value="0">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="form-label mb-0">Y</label>
|
|
||||||
<input id="meshY" type="number" class="form-control form-control-sm" style="width:5rem" value="0">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="form-label mb-0">Z</label>
|
|
||||||
<input id="meshZ" type="number" class="form-control form-control-sm" style="width:5rem" value="0">
|
|
||||||
</div>
|
|
||||||
<button id="btnAddMesh" type="button" class="btn btn-sm btn-outline-primary">Add</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12 col-lg-6">
|
|
||||||
<p class="small text-muted mb-2">Preview (scroll to zoom)</p>
|
|
||||||
<canvas id="previewCanvas" class="border" width="512" height="512"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="/common/dmf.js"></script>
|
|
||||||
<script src="/common/chunkterrain.js"></script>
|
|
||||||
<script src="/map/renderer.js"></script>
|
|
||||||
<script src="/map/map.js"></script>
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/* Copyright (c) 2026 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
.tile-palette {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 6px;
|
|
||||||
max-height: 600px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tile-swatch {
|
|
||||||
position: relative;
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 2px solid transparent;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tile-swatch.active {
|
|
||||||
border-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tile-swatch-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dpad {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, 2rem);
|
|
||||||
grid-template-rows: repeat(3, 2rem);
|
|
||||||
grid-template-areas:
|
|
||||||
". n ."
|
|
||||||
"w . e"
|
|
||||||
". s .";
|
|
||||||
gap: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dpad-n { grid-area: n; }
|
|
||||||
.dpad-w { grid-area: w; }
|
|
||||||
.dpad-e { grid-area: e; }
|
|
||||||
.dpad-s { grid-area: s; }
|
|
||||||
.dpad button { padding: 0; }
|
|
||||||
|
|
||||||
.tile-grid {
|
|
||||||
image-rendering: pixelated;
|
|
||||||
cursor: crosshair;
|
|
||||||
touch-action: none;
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#previewCanvas {
|
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 1 / 1;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
@@ -1,918 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
(() => {
|
|
||||||
const SHAPES = [
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_NULL, name: "Erase", color: "#20232a" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_GROUND, name: "Ground", color: "#4caf50" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTH, name: "Ramp North", color: "#2196f3" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_EAST, name: "Ramp East", color: "#03a9f4" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTH, name: "Ramp South", color: "#00bcd4" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_WEST, name: "Ramp West", color: "#009688" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST, name: "Ramp NE", color: "#ff9800" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST, name: "Ramp NW", color: "#ff5722" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST, name: "Ramp SE", color: "#9c27b0" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST, name: "Ramp SW", color: "#e91e63" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST_INNER, name: "Ramp NE Inner", color: "#795548" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST_INNER, name: "Ramp NW Inner", color: "#607d8b" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST_INNER, name: "Ramp SE Inner", color: "#8bc34a" },
|
|
||||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST_INNER, name: "Ramp SW Inner", color: "#ffc107" },
|
|
||||||
];
|
|
||||||
const SHAPE_COLORS = Object.fromEntries(SHAPES.map((s) => [s.type, s.color]));
|
|
||||||
|
|
||||||
// Arrow direction per ramp, in canvas/screen space: north is up (dy < 0),
|
|
||||||
// east is right (dx > 0) - matches renderGrid()'s north-is-up convention.
|
|
||||||
const SHAPE_DIRECTIONS = {
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTH]: { dx: 0, dy: -1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTH]: { dx: 0, dy: 1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_EAST]: { dx: 1, dy: 0 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_WEST]: { dx: -1, dy: 0 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST]: { dx: 1, dy: -1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST]: { dx: -1, dy: -1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST]: { dx: 1, dy: 1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST]: { dx: -1, dy: 1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST_INNER]: { dx: 1, dy: -1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST_INNER]: { dx: -1, dy: -1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST_INNER]: { dx: 1, dy: 1 },
|
|
||||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST_INNER]: { dx: -1, dy: 1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
const INNER_CORNER_SHAPES = new Set([
|
|
||||||
ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST_INNER,
|
|
||||||
ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST_INNER,
|
|
||||||
ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST_INNER,
|
|
||||||
ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST_INNER,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Draws a single-headed arrow from (tailX, tailY) to (tipX, tipY).
|
|
||||||
function drawArrowSegment(ctx, tailX, tailY, tipX, tipY, size) {
|
|
||||||
ctx.strokeStyle = "#ffffff";
|
|
||||||
ctx.fillStyle = "#ffffff";
|
|
||||||
ctx.lineWidth = Math.max(1, size * 0.08);
|
|
||||||
ctx.lineCap = "round";
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(tailX, tailY);
|
|
||||||
ctx.lineTo(tipX, tipY);
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
const headLen = size * 0.18;
|
|
||||||
const angle = Math.atan2(tipY - tailY, tipX - tailX);
|
|
||||||
const leftAngle = angle + Math.PI * 0.8;
|
|
||||||
const rightAngle = angle - Math.PI * 0.8;
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(tipX, tipY);
|
|
||||||
ctx.lineTo(tipX + Math.cos(leftAngle) * headLen, tipY + Math.sin(leftAngle) * headLen);
|
|
||||||
ctx.lineTo(tipX + Math.cos(rightAngle) * headLen, tipY + Math.sin(rightAngle) * headLen);
|
|
||||||
ctx.closePath();
|
|
||||||
ctx.fill();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draws an arrow centered at (cx, cy) pointing toward the ramp's high
|
|
||||||
// side, so ramp direction is visible at a glance on both the palette
|
|
||||||
// swatches and the tile grid. Used for cardinal ramps and outer-corner
|
|
||||||
// ramps (a single raised corner).
|
|
||||||
function drawArrow(ctx, cx, cy, size, dx, dy) {
|
|
||||||
const mag = Math.hypot(dx, dy) || 1;
|
|
||||||
const ux = dx / mag, uy = dy / mag;
|
|
||||||
const len = size * 0.32;
|
|
||||||
drawArrowSegment(ctx, cx - ux * len, cy - uy * len, cx + ux * len, cy + uy * len, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draws a plain right-angle bracket - two line segments meeting at 90
|
|
||||||
// degrees at the tile's corner, one running along each of the two edges
|
|
||||||
// adjacent to it - so inner-corner ramps (three corners raised, one
|
|
||||||
// dropped) read as "the adjacent sides meeting in a 90-degree corner",
|
|
||||||
// distinct from the single diagonal arrow used for outer-corner ramps.
|
|
||||||
function drawCornerBracket(ctx, cx, cy, size, dx, dy) {
|
|
||||||
const cornerDist = size * 0.42;
|
|
||||||
const armLen = size * 0.34;
|
|
||||||
const cornerX = cx + dx * cornerDist;
|
|
||||||
const cornerY = cy + dy * cornerDist;
|
|
||||||
|
|
||||||
ctx.strokeStyle = "#ffffff";
|
|
||||||
ctx.lineWidth = Math.max(1, size * 0.08);
|
|
||||||
ctx.lineCap = "round";
|
|
||||||
ctx.lineJoin = "round";
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(cornerX - dx * armLen, cornerY);
|
|
||||||
ctx.lineTo(cornerX, cornerY);
|
|
||||||
ctx.lineTo(cornerX, cornerY - dy * armLen);
|
|
||||||
ctx.stroke();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draws the direction icon for a ramp tile `type` in a `size`x`size` area
|
|
||||||
// centered at (cx, cy): a diagonal arrow for cardinal/outer-corner ramps,
|
|
||||||
// or a right-angle bracket for inner-corner ramps. No-op for shapes with
|
|
||||||
// no direction (ground, erase).
|
|
||||||
function drawShapeIcon(ctx, cx, cy, size, type) {
|
|
||||||
const dir = SHAPE_DIRECTIONS[type];
|
|
||||||
if(!dir) return;
|
|
||||||
if(INNER_CORNER_SHAPES.has(type)) {
|
|
||||||
drawCornerBracket(ctx, cx, cy, size, dir.dx, dir.dy);
|
|
||||||
} else {
|
|
||||||
drawArrow(ctx, cx, cy, size, dir.dx, dir.dy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draws a small pencil icon centered in a `size`x`size` canvas.
|
|
||||||
function drawPencilIcon(ctx, size) {
|
|
||||||
ctx.save();
|
|
||||||
ctx.translate(size / 2, size / 2);
|
|
||||||
ctx.rotate(-Math.PI / 4);
|
|
||||||
|
|
||||||
const shaftW = size * 0.18;
|
|
||||||
const shaftH = size * 0.62;
|
|
||||||
|
|
||||||
ctx.fillStyle = "#e0e0e0";
|
|
||||||
ctx.fillRect(-shaftW / 2, shaftH * 0.28, shaftW, shaftH * 0.22);
|
|
||||||
|
|
||||||
ctx.fillStyle = "#f0c419";
|
|
||||||
ctx.fillRect(-shaftW / 2, -shaftH * 0.5, shaftW, shaftH * 0.78);
|
|
||||||
|
|
||||||
ctx.fillStyle = "#8d6e63";
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(-shaftW / 2, -shaftH * 0.5);
|
|
||||||
ctx.lineTo(shaftW / 2, -shaftH * 0.5);
|
|
||||||
ctx.lineTo(0, -shaftH * 0.5 - shaftW);
|
|
||||||
ctx.closePath();
|
|
||||||
ctx.fill();
|
|
||||||
|
|
||||||
ctx.restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draws a small paint bucket icon centered in a `size`x`size` canvas.
|
|
||||||
function drawBucketIcon(ctx, size) {
|
|
||||||
ctx.save();
|
|
||||||
ctx.translate(size / 2, size / 2);
|
|
||||||
|
|
||||||
const w = size * 0.5, h = size * 0.34;
|
|
||||||
|
|
||||||
ctx.strokeStyle = "#e0e0e0";
|
|
||||||
ctx.lineWidth = Math.max(1, size * 0.06);
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(0, -h * 0.4, w * 0.4, Math.PI, 0);
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
ctx.fillStyle = "#03a9f4";
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(-w / 2, -h * 0.2);
|
|
||||||
ctx.lineTo(w / 2, -h * 0.2);
|
|
||||||
ctx.lineTo(w * 0.32, h * 0.6);
|
|
||||||
ctx.lineTo(-w * 0.32, h * 0.6);
|
|
||||||
ctx.closePath();
|
|
||||||
ctx.fill();
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(-w * 0.55, h * 0.75, size * 0.06, 0, Math.PI * 2);
|
|
||||||
ctx.fill();
|
|
||||||
|
|
||||||
ctx.restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
const TOOLS = [
|
|
||||||
{ id: "pencil", name: "Pencil", draw: drawPencilIcon },
|
|
||||||
{ id: "bucket", name: "Paint Bucket", draw: drawBucketIcon },
|
|
||||||
];
|
|
||||||
|
|
||||||
let coord = { x: 0, y: 0, z: 0 };
|
|
||||||
let tiles = new Int32Array(ChunkTerrain.TILE_COUNT);
|
|
||||||
let meshes = [];
|
|
||||||
let chunkExists = false;
|
|
||||||
let currentZLevel = 0;
|
|
||||||
let selectedShape = ChunkTerrain.TILE_SHAPE_GROUND;
|
|
||||||
let zoomWorldH = 20;
|
|
||||||
let dirty = false;
|
|
||||||
let hoverTile = null;
|
|
||||||
let activeTool = "pencil";
|
|
||||||
|
|
||||||
let mapRenderer = null;
|
|
||||||
let terrainMesh = null;
|
|
||||||
let gridLinesMesh = null;
|
|
||||||
let terrainTexturePromise = null;
|
|
||||||
let modelIndex = null;
|
|
||||||
let neighborChunks = [];
|
|
||||||
const modelCache = new Map();
|
|
||||||
|
|
||||||
const UNDO_LIMIT = 100;
|
|
||||||
let undoStack = [];
|
|
||||||
|
|
||||||
function markDirty() {
|
|
||||||
dirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function snapshotState() {
|
|
||||||
return {
|
|
||||||
tiles: tiles.slice(),
|
|
||||||
meshes: meshes.map((m) => ({ file: m.file, pos: m.pos.slice() })),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function pushUndo() {
|
|
||||||
undoStack.push(snapshotState());
|
|
||||||
if(undoStack.length > UNDO_LIMIT) undoStack.shift();
|
|
||||||
}
|
|
||||||
|
|
||||||
function undo() {
|
|
||||||
if(!undoStack.length) return;
|
|
||||||
const snap = undoStack.pop();
|
|
||||||
tiles = snap.tiles;
|
|
||||||
meshes = snap.meshes;
|
|
||||||
dirty = true;
|
|
||||||
renderGrid();
|
|
||||||
renderMeshList();
|
|
||||||
renderPreview();
|
|
||||||
updateStatus("Undid last change.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if it's OK to proceed (no unsaved changes, or the user
|
|
||||||
// confirmed discarding them).
|
|
||||||
function confirmDiscardIfDirty() {
|
|
||||||
if(!dirty) return true;
|
|
||||||
return window.confirm("You have unsaved changes to this chunk. Discard them?");
|
|
||||||
}
|
|
||||||
|
|
||||||
function statusLine() {
|
|
||||||
return document.getElementById("statusLine");
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateStatus(msg, isError) {
|
|
||||||
const el = statusLine();
|
|
||||||
el.textContent = msg;
|
|
||||||
el.classList.toggle("text-danger", !!isError);
|
|
||||||
el.classList.toggle("text-muted", !isError);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiReadJson(path) {
|
|
||||||
const res = await fetch(`/api/read?path=${encodeURIComponent(path)}`);
|
|
||||||
const data = await res.json();
|
|
||||||
return { ok: res.ok, data };
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiWrite(path, content) {
|
|
||||||
return fetch(`/api/write?path=${encodeURIComponent(path)}`, {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({ content }),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiDelete(path) {
|
|
||||||
return fetch(`/api/delete?path=${encodeURIComponent(path)}`, { method: "POST" });
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiCompileChunk(x, y, z) {
|
|
||||||
const res = await fetch(`/api/compile-chunk?x=${x}&y=${y}&z=${z}`, { method: "POST" });
|
|
||||||
return res.json();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiLs(path) {
|
|
||||||
const res = await fetch(`/api/ls?path=${encodeURIComponent(path)}`);
|
|
||||||
return res.json();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiFind(path, ext) {
|
|
||||||
const res = await fetch(`/api/find?path=${encodeURIComponent(path)}&ext=${encodeURIComponent(ext)}`);
|
|
||||||
return res.json();
|
|
||||||
}
|
|
||||||
|
|
||||||
function base64ToBuffer(base64) {
|
|
||||||
const bytes = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
|
||||||
return bytes.buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadImageTexture(assetPath) {
|
|
||||||
const { ok, data } = await apiReadJson(assetPath);
|
|
||||||
if(!ok || data.error) return null;
|
|
||||||
const blob = new Blob([base64ToBuffer(data.content)], { type: "image/png" });
|
|
||||||
const bitmap = await createImageBitmap(blob);
|
|
||||||
return mapRenderer.createTextureFromImage(bitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function readDmfVertices(assetPath) {
|
|
||||||
const { ok, data } = await apiReadJson(assetPath);
|
|
||||||
if(!ok || data.error) throw new Error(`Failed to read ${assetPath}`);
|
|
||||||
return DMF.decode(base64ToBuffer(data.content)).floats;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function ensureModelIndex() {
|
|
||||||
if(modelIndex) return modelIndex;
|
|
||||||
const res = await apiFind("assets/models", ".json");
|
|
||||||
modelIndex = new Map();
|
|
||||||
for(const file of res.files || []) {
|
|
||||||
const base = file.split("/").pop().replace(/\.json$/, "");
|
|
||||||
modelIndex.set(base, file);
|
|
||||||
}
|
|
||||||
return modelIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scales a mesh's stored [x, y, z] offset for preview, matching the
|
|
||||||
// Z scaling mapChunkLoaded() applies at runtime (chunk.meshOffsets[m][2]
|
|
||||||
// * WORLD_LAYER_HEIGHT) - x/y stay 1:1 since only Z is height-scaled.
|
|
||||||
function scaledMeshOffset(pos) {
|
|
||||||
return [pos[0], pos[1], pos[2] * ChunkTerrain.WORLD_LAYER_HEIGHT];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolves a chunk mesh entry's bare filename (e.g. "house_5_3.dmf") to
|
|
||||||
// its model JSON by basename, mirroring find_model() in
|
|
||||||
// tools/asset/chunk/__main__.py - the chunk JSON only ever stores a bare
|
|
||||||
// filename, not a path.
|
|
||||||
async function resolveModelForMeshFile(file) {
|
|
||||||
await ensureModelIndex();
|
|
||||||
const base = file.replace(/\.[^.]+$/, "");
|
|
||||||
const rel = modelIndex.get(base);
|
|
||||||
if(!rel) return null;
|
|
||||||
|
|
||||||
const modelPath = `assets/models/${rel}`;
|
|
||||||
if(modelCache.has(modelPath)) return modelCache.get(modelPath);
|
|
||||||
|
|
||||||
const promise = (async () => {
|
|
||||||
const { ok, data } = await apiReadJson(modelPath);
|
|
||||||
if(!ok || data.error) throw new Error(`Failed to read model ${modelPath}`);
|
|
||||||
const modelDef = JSON.parse(data.content);
|
|
||||||
const meshFloats = await readDmfVertices(`assets/${modelDef.mesh}`);
|
|
||||||
const mesh = mapRenderer.createMesh(meshFloats);
|
|
||||||
const texture = modelDef.texture ? await loadImageTexture(`assets/${modelDef.texture}`) : null;
|
|
||||||
const colorBytes = modelDef.color || [255, 255, 255, 255];
|
|
||||||
const color = colorBytes.map((c) => c / 255);
|
|
||||||
return { mesh, texture, color };
|
|
||||||
})();
|
|
||||||
modelCache.set(modelPath, promise);
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
function chunkPaths(x, y, z) {
|
|
||||||
return {
|
|
||||||
raw: `assetsraw/chunks/chunk_${x}_${y}_${z}.json`,
|
|
||||||
dcf: `assets/chunks/${x}_${y}_${z}.dcf`,
|
|
||||||
terrainDmf: `assets/meshes/chunks/chunk_${x}_${y}_${z}_0.dmf`,
|
|
||||||
terrainModel: `assets/models/chunks/chunk_${x}_${y}_${z}_0.json`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loads the 8 same-Z neighbors around `coord` (read-only, for context in
|
|
||||||
// the 3D preview) and pre-builds their render data so renderPreview()
|
|
||||||
// doesn't have to rebuild GL buffers on every paint stroke.
|
|
||||||
async function loadNeighborChunks() {
|
|
||||||
const offsets = [];
|
|
||||||
for(let dy = -1; dy <= 1; dy++) {
|
|
||||||
for(let dx = -1; dx <= 1; dx++) {
|
|
||||||
if(dx || dy) offsets.push({ dx, dy });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const results = await Promise.all(offsets.map(async ({ dx, dy }) => {
|
|
||||||
const nx = coord.x + dx, ny = coord.y + dy, nz = coord.z;
|
|
||||||
const { ok, data } = await apiReadJson(chunkPaths(nx, ny, nz).raw);
|
|
||||||
if(!ok || data.error) return null;
|
|
||||||
|
|
||||||
const json = JSON.parse(data.content);
|
|
||||||
const neighborTiles = new Int32Array(ChunkTerrain.TILE_COUNT);
|
|
||||||
for(const t of json.tiles || []) {
|
|
||||||
const [tx, ty, tz] = t.pos;
|
|
||||||
neighborTiles[ChunkTerrain.tileIndex(tx, ty, tz)] = t.type;
|
|
||||||
}
|
|
||||||
const neighborMeshes = (json.meshes || []).map((m) => ({ file: m.file, pos: m.pos || [0, 0, 0] }));
|
|
||||||
|
|
||||||
const floats = ChunkTerrain.buildTerrainVerts(neighborTiles);
|
|
||||||
const terrain = floats.length ? { mesh: mapRenderer.createMesh(floats) } : null;
|
|
||||||
|
|
||||||
const models = [];
|
|
||||||
for(const m of neighborMeshes) {
|
|
||||||
try {
|
|
||||||
const resolved = await resolveModelForMeshFile(m.file);
|
|
||||||
if(resolved) models.push({ ...resolved, offset: scaledMeshOffset(m.pos) });
|
|
||||||
} catch(e) {
|
|
||||||
console.warn("Failed to load neighbor mesh preview", m.file, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
offset: [dx * ChunkTerrain.CHUNK_WIDTH, dy * ChunkTerrain.CHUNK_HEIGHT, 0],
|
|
||||||
terrain,
|
|
||||||
models,
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
|
|
||||||
neighborChunks = results.filter(Boolean);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadChunk(x, y, z) {
|
|
||||||
coord = { x, y, z };
|
|
||||||
tiles = new Int32Array(ChunkTerrain.TILE_COUNT);
|
|
||||||
meshes = [];
|
|
||||||
chunkExists = false;
|
|
||||||
|
|
||||||
const { ok, data } = await apiReadJson(chunkPaths(x, y, z).raw);
|
|
||||||
if(ok && !data.error) {
|
|
||||||
chunkExists = true;
|
|
||||||
const json = JSON.parse(data.content);
|
|
||||||
for(const t of json.tiles || []) {
|
|
||||||
const [tx, ty, tz] = t.pos;
|
|
||||||
tiles[ChunkTerrain.tileIndex(tx, ty, tz)] = t.type;
|
|
||||||
}
|
|
||||||
meshes = (json.meshes || []).map((m) => ({ file: m.file, pos: m.pos || [0, 0, 0] }));
|
|
||||||
}
|
|
||||||
|
|
||||||
await loadNeighborChunks();
|
|
||||||
dirty = false;
|
|
||||||
undoStack = [];
|
|
||||||
|
|
||||||
renderGrid();
|
|
||||||
renderMeshList();
|
|
||||||
renderPreview();
|
|
||||||
updateStatus(chunkExists
|
|
||||||
? `Loaded chunk_${x}_${y}_${z}.json`
|
|
||||||
: `New (empty) chunk at ${x}, ${y}, ${z} - paint a tile and save to create it.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveChunk() {
|
|
||||||
const tilesArr = [];
|
|
||||||
for(let z = 0; z < ChunkTerrain.CHUNK_DEPTH; z++) {
|
|
||||||
for(let y = 0; y < ChunkTerrain.CHUNK_HEIGHT; y++) {
|
|
||||||
for(let x = 0; x < ChunkTerrain.CHUNK_WIDTH; x++) {
|
|
||||||
const type = tiles[ChunkTerrain.tileIndex(x, y, z)];
|
|
||||||
if(type && type !== ChunkTerrain.TILE_SHAPE_NULL) {
|
|
||||||
tilesArr.push({ pos: [x, y, z], type, tile: 0 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const paths = chunkPaths(coord.x, coord.y, coord.z);
|
|
||||||
|
|
||||||
if(tilesArr.length === 0 && meshes.length === 0) {
|
|
||||||
await Promise.all(Object.values(paths).map((p) => apiDelete(p)));
|
|
||||||
chunkExists = false;
|
|
||||||
dirty = false;
|
|
||||||
updateStatus(`Chunk ${coord.x}, ${coord.y}, ${coord.z} is empty - deleted.`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const json = { tiles: tilesArr, meshes: meshes.map((m) => ({ file: m.file, pos: m.pos })) };
|
|
||||||
await apiWrite(paths.raw, JSON.stringify(json, null, 2));
|
|
||||||
chunkExists = true;
|
|
||||||
dirty = false;
|
|
||||||
updateStatus("Saved. Compiling...");
|
|
||||||
|
|
||||||
const result = await apiCompileChunk(coord.x, coord.y, coord.z);
|
|
||||||
if(result.ok) {
|
|
||||||
updateStatus(`Compiled OK.\n${result.stdout}`);
|
|
||||||
} else {
|
|
||||||
updateStatus(`Compile FAILED (code ${result.returncode}):\n${result.stderr}`, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildPalette() {
|
|
||||||
const el = document.getElementById("tilePalette");
|
|
||||||
el.innerHTML = "";
|
|
||||||
for(const s of SHAPES) {
|
|
||||||
const btn = document.createElement("button");
|
|
||||||
btn.type = "button";
|
|
||||||
btn.className = "tile-swatch" + (s.type === selectedShape ? " active" : "");
|
|
||||||
btn.style.background = s.color;
|
|
||||||
btn.title = s.name;
|
|
||||||
btn.addEventListener("click", () => {
|
|
||||||
selectedShape = s.type;
|
|
||||||
buildPalette();
|
|
||||||
});
|
|
||||||
|
|
||||||
if(SHAPE_DIRECTIONS[s.type]) {
|
|
||||||
const icon = document.createElement("canvas");
|
|
||||||
icon.width = 32;
|
|
||||||
icon.height = 32;
|
|
||||||
icon.className = "tile-swatch-icon";
|
|
||||||
drawShapeIcon(icon.getContext("2d"), 16, 16, 32, s.type);
|
|
||||||
btn.appendChild(icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
el.appendChild(btn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildToolPalette() {
|
|
||||||
const el = document.getElementById("toolPalette");
|
|
||||||
el.innerHTML = "";
|
|
||||||
for(const tool of TOOLS) {
|
|
||||||
const btn = document.createElement("button");
|
|
||||||
btn.type = "button";
|
|
||||||
btn.className = "tile-swatch" + (tool.id === activeTool ? " active" : "");
|
|
||||||
btn.style.background = "#2a2d33";
|
|
||||||
btn.title = tool.name;
|
|
||||||
btn.addEventListener("click", () => {
|
|
||||||
activeTool = tool.id;
|
|
||||||
buildToolPalette();
|
|
||||||
});
|
|
||||||
|
|
||||||
const icon = document.createElement("canvas");
|
|
||||||
icon.width = 32;
|
|
||||||
icon.height = 32;
|
|
||||||
icon.className = "tile-swatch-icon";
|
|
||||||
tool.draw(icon.getContext("2d"), 32);
|
|
||||||
btn.appendChild(icon);
|
|
||||||
|
|
||||||
el.appendChild(btn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function canvasToTile(e, canvas) {
|
|
||||||
const rect = canvas.getBoundingClientRect();
|
|
||||||
const cell = canvas.width / ChunkTerrain.CHUNK_WIDTH;
|
|
||||||
const px = (e.clientX - rect.left) * (canvas.width / rect.width);
|
|
||||||
const py = (e.clientY - rect.top) * (canvas.height / rect.height);
|
|
||||||
const x = Math.floor(px / cell);
|
|
||||||
const yFromTop = Math.floor(py / cell);
|
|
||||||
const y = ChunkTerrain.CHUNK_HEIGHT - 1 - yFromTop;
|
|
||||||
if(x < 0 || x >= ChunkTerrain.CHUNK_WIDTH || y < 0 || y >= ChunkTerrain.CHUNK_HEIGHT) return null;
|
|
||||||
return { x, y };
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderGrid() {
|
|
||||||
const canvas = document.getElementById("gridCanvas");
|
|
||||||
const ctx = canvas.getContext("2d");
|
|
||||||
const cell = canvas.width / ChunkTerrain.CHUNK_WIDTH;
|
|
||||||
|
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
||||||
for(let y = 0; y < ChunkTerrain.CHUNK_HEIGHT; y++) {
|
|
||||||
for(let x = 0; x < ChunkTerrain.CHUNK_WIDTH; x++) {
|
|
||||||
const type = tiles[ChunkTerrain.tileIndex(x, y, currentZLevel)];
|
|
||||||
const sy = (ChunkTerrain.CHUNK_HEIGHT - 1 - y) * cell;
|
|
||||||
ctx.fillStyle = SHAPE_COLORS[type] || "#15171b";
|
|
||||||
ctx.fillRect(x * cell, sy, cell, cell);
|
|
||||||
ctx.strokeStyle = "rgba(255, 255, 255, 0.25)";
|
|
||||||
ctx.strokeRect(x * cell, sy, cell, cell);
|
|
||||||
|
|
||||||
drawShapeIcon(ctx, x * cell + cell / 2, sy + cell / 2, cell, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.fillStyle = "#ffffff";
|
|
||||||
for(const m of meshes) {
|
|
||||||
const [mx, my, mz] = m.pos;
|
|
||||||
if(Math.round(mz) !== currentZLevel) continue;
|
|
||||||
const sy = (ChunkTerrain.CHUNK_HEIGHT - 1 - my) * cell;
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(mx * cell + cell / 2, sy + cell / 2, cell * 0.3, 0, Math.PI * 2);
|
|
||||||
ctx.fill();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hoverTile) {
|
|
||||||
const sy = (ChunkTerrain.CHUNK_HEIGHT - 1 - hoverTile.y) * cell;
|
|
||||||
ctx.strokeStyle = "#ffeb3b";
|
|
||||||
ctx.lineWidth = 2;
|
|
||||||
ctx.strokeRect(hoverTile.x * cell + 1, sy + 1, cell - 2, cell - 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function hitTestMesh(e, canvas) {
|
|
||||||
const rect = canvas.getBoundingClientRect();
|
|
||||||
const cell = canvas.width / ChunkTerrain.CHUNK_WIDTH;
|
|
||||||
const px = (e.clientX - rect.left) * (canvas.width / rect.width);
|
|
||||||
const py = (e.clientY - rect.top) * (canvas.height / rect.height);
|
|
||||||
|
|
||||||
let closest = -1;
|
|
||||||
let closestDist = cell * 0.5;
|
|
||||||
meshes.forEach((m, i) => {
|
|
||||||
const [mx, my, mz] = m.pos;
|
|
||||||
if(Math.round(mz) !== currentZLevel) return;
|
|
||||||
const cx = mx * cell + cell / 2;
|
|
||||||
const cy = (ChunkTerrain.CHUNK_HEIGHT - 1 - my) * cell + cell / 2;
|
|
||||||
const dist = Math.hypot(px - cx, py - cy);
|
|
||||||
if(dist < closestDist) { closestDist = dist; closest = i; }
|
|
||||||
});
|
|
||||||
return closest;
|
|
||||||
}
|
|
||||||
|
|
||||||
function moveMeshTo(e, index) {
|
|
||||||
const canvas = document.getElementById("gridCanvas");
|
|
||||||
const t = canvasToTile(e, canvas);
|
|
||||||
if(!t) return;
|
|
||||||
meshes[index].pos[0] = t.x;
|
|
||||||
meshes[index].pos[1] = t.y;
|
|
||||||
markDirty();
|
|
||||||
renderGrid();
|
|
||||||
renderMeshList();
|
|
||||||
renderPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
function paintAt(e) {
|
|
||||||
const canvas = document.getElementById("gridCanvas");
|
|
||||||
const t = canvasToTile(e, canvas);
|
|
||||||
if(!t) return;
|
|
||||||
tiles[ChunkTerrain.tileIndex(t.x, t.y, currentZLevel)] = selectedShape;
|
|
||||||
markDirty();
|
|
||||||
renderGrid();
|
|
||||||
renderPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4-connected flood fill of same-type tiles at the current Z-level,
|
|
||||||
// starting from (startX, startY), replacing them with selectedShape.
|
|
||||||
function floodFill(startX, startY) {
|
|
||||||
const targetType = tiles[ChunkTerrain.tileIndex(startX, startY, currentZLevel)];
|
|
||||||
if(targetType === selectedShape) return;
|
|
||||||
|
|
||||||
const stack = [[startX, startY]];
|
|
||||||
const visited = new Set();
|
|
||||||
while(stack.length) {
|
|
||||||
const [x, y] = stack.pop();
|
|
||||||
const key = `${x},${y}`;
|
|
||||||
if(visited.has(key)) continue;
|
|
||||||
if(x < 0 || x >= ChunkTerrain.CHUNK_WIDTH || y < 0 || y >= ChunkTerrain.CHUNK_HEIGHT) continue;
|
|
||||||
visited.add(key);
|
|
||||||
|
|
||||||
const idx = ChunkTerrain.tileIndex(x, y, currentZLevel);
|
|
||||||
if(tiles[idx] !== targetType) continue;
|
|
||||||
tiles[idx] = selectedShape;
|
|
||||||
stack.push([x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillAt(e) {
|
|
||||||
const canvas = document.getElementById("gridCanvas");
|
|
||||||
const t = canvasToTile(e, canvas);
|
|
||||||
if(!t) return;
|
|
||||||
pushUndo();
|
|
||||||
floodFill(t.x, t.y);
|
|
||||||
markDirty();
|
|
||||||
renderGrid();
|
|
||||||
renderPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
function rebuildTerrainMesh() {
|
|
||||||
const floats = ChunkTerrain.buildTerrainVerts(tiles);
|
|
||||||
terrainMesh = floats.length ? mapRenderer.createMesh(floats) : null;
|
|
||||||
|
|
||||||
const lineFloats = ChunkTerrain.buildGridLines(tiles);
|
|
||||||
gridLinesMesh = lineFloats.length ? mapRenderer.createMesh(lineFloats) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keeps the preview canvas's backing-store resolution matched to its
|
|
||||||
// actual displayed CSS size (times devicePixelRatio) - the canvas
|
|
||||||
// otherwise stays at its fixed width/height attributes (512x512) while
|
|
||||||
// CSS stretches it to fill the column, which upscales and blurs the
|
|
||||||
// WebGL output on wider or high-DPI screens.
|
|
||||||
function resizePreviewCanvas() {
|
|
||||||
const canvas = document.getElementById("previewCanvas");
|
|
||||||
const dpr = window.devicePixelRatio || 1;
|
|
||||||
const displayWidth = Math.max(1, Math.round(canvas.clientWidth * dpr));
|
|
||||||
const displayHeight = Math.max(1, Math.round(canvas.clientHeight * dpr));
|
|
||||||
if(canvas.width !== displayWidth || canvas.height !== displayHeight) {
|
|
||||||
canvas.width = displayWidth;
|
|
||||||
canvas.height = displayHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function renderPreview() {
|
|
||||||
if(!mapRenderer) return;
|
|
||||||
resizePreviewCanvas();
|
|
||||||
rebuildTerrainMesh();
|
|
||||||
|
|
||||||
const models = [];
|
|
||||||
for(const m of meshes) {
|
|
||||||
try {
|
|
||||||
const resolved = await resolveModelForMeshFile(m.file);
|
|
||||||
if(resolved) models.push({ ...resolved, offset: scaledMeshOffset(m.pos) });
|
|
||||||
} catch(e) {
|
|
||||||
console.warn("Failed to load mesh preview", m.file, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let terrainTexture = null;
|
|
||||||
if(terrainMesh || neighborChunks.some((n) => n.terrain)) {
|
|
||||||
if(!terrainTexturePromise) terrainTexturePromise = loadImageTexture("assets/tiles.png");
|
|
||||||
terrainTexture = await terrainTexturePromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
const neighbors = neighborChunks.map((n) => ({
|
|
||||||
offset: n.offset,
|
|
||||||
terrain: n.terrain ? { mesh: n.terrain.mesh, texture: terrainTexture } : null,
|
|
||||||
models: n.models,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const zLevelHeight = currentZLevel * ChunkTerrain.WORLD_LAYER_HEIGHT;
|
|
||||||
mapRenderer.render({
|
|
||||||
target: [ChunkTerrain.CHUNK_WIDTH / 2, ChunkTerrain.CHUNK_HEIGHT / 2, zLevelHeight],
|
|
||||||
worldH: zoomWorldH,
|
|
||||||
terrain: terrainMesh ? { mesh: terrainMesh, texture: terrainTexture } : null,
|
|
||||||
gridLines: gridLinesMesh ? { mesh: gridLinesMesh } : null,
|
|
||||||
models,
|
|
||||||
neighbors,
|
|
||||||
highlight: hoverTile ? { x: hoverTile.x, y: hoverTile.y, z: zLevelHeight } : null,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderMeshList() {
|
|
||||||
const ul = document.getElementById("meshList");
|
|
||||||
ul.innerHTML = "";
|
|
||||||
meshes.forEach((m, i) => {
|
|
||||||
const li = document.createElement("li");
|
|
||||||
li.className = "list-group-item d-flex align-items-center gap-2 flex-wrap";
|
|
||||||
|
|
||||||
const label = document.createElement("span");
|
|
||||||
label.className = "me-auto";
|
|
||||||
label.textContent = m.file;
|
|
||||||
li.appendChild(label);
|
|
||||||
|
|
||||||
["X", "Y", "Z"].forEach((axis, axisIndex) => {
|
|
||||||
const input = document.createElement("input");
|
|
||||||
input.type = "number";
|
|
||||||
input.className = "form-control form-control-sm";
|
|
||||||
input.style.width = "5rem";
|
|
||||||
input.title = axis;
|
|
||||||
input.value = m.pos[axisIndex];
|
|
||||||
input.addEventListener("change", () => {
|
|
||||||
pushUndo();
|
|
||||||
m.pos[axisIndex] = parseFloat(input.value) || 0;
|
|
||||||
markDirty();
|
|
||||||
renderGrid();
|
|
||||||
renderPreview();
|
|
||||||
});
|
|
||||||
li.appendChild(input);
|
|
||||||
});
|
|
||||||
|
|
||||||
const btn = document.createElement("button");
|
|
||||||
btn.type = "button";
|
|
||||||
btn.className = "btn btn-sm btn-outline-danger";
|
|
||||||
btn.textContent = "Remove";
|
|
||||||
btn.addEventListener("click", () => {
|
|
||||||
pushUndo();
|
|
||||||
meshes.splice(i, 1);
|
|
||||||
markDirty();
|
|
||||||
renderMeshList();
|
|
||||||
renderGrid();
|
|
||||||
renderPreview();
|
|
||||||
});
|
|
||||||
|
|
||||||
li.appendChild(btn);
|
|
||||||
ul.appendChild(li);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function buildMeshPicker() {
|
|
||||||
await ensureModelIndex();
|
|
||||||
const select = document.getElementById("meshPicker");
|
|
||||||
select.innerHTML = "";
|
|
||||||
for(const [base, rel] of [...modelIndex.entries()].sort()) {
|
|
||||||
const opt = document.createElement("option");
|
|
||||||
opt.value = base;
|
|
||||||
opt.textContent = rel;
|
|
||||||
select.appendChild(opt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function buildChunkBrowseList() {
|
|
||||||
const list = document.getElementById("chunkBrowseList");
|
|
||||||
list.innerHTML = "";
|
|
||||||
const res = await apiLs("assetsraw/chunks");
|
|
||||||
for(const entry of res.entries || []) {
|
|
||||||
const m = entry.name.match(/^chunk_(-?\d+)_(-?\d+)_(-?\d+)\.json$/);
|
|
||||||
if(!m) continue;
|
|
||||||
const [, x, y, z] = m;
|
|
||||||
|
|
||||||
const li = document.createElement("li");
|
|
||||||
const a = document.createElement("a");
|
|
||||||
a.className = "dropdown-item";
|
|
||||||
a.href = "#";
|
|
||||||
a.textContent = `${x}, ${y}, ${z}`;
|
|
||||||
a.addEventListener("click", (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
goToChunk(parseInt(x, 10), parseInt(y, 10), parseInt(z, 10));
|
|
||||||
});
|
|
||||||
|
|
||||||
li.appendChild(a);
|
|
||||||
list.appendChild(li);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCoordInputs(x, y, z) {
|
|
||||||
document.getElementById("coordX").value = x;
|
|
||||||
document.getElementById("coordY").value = y;
|
|
||||||
document.getElementById("coordZ").value = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
function goToChunk(x, y, z) {
|
|
||||||
if(!confirmDiscardIfDirty()) return;
|
|
||||||
setCoordInputs(x, y, z);
|
|
||||||
loadChunk(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
function bindEvents() {
|
|
||||||
const gridCanvas = document.getElementById("gridCanvas");
|
|
||||||
let painting = false;
|
|
||||||
let draggingMeshIndex = -1;
|
|
||||||
|
|
||||||
gridCanvas.addEventListener("mousedown", (e) => {
|
|
||||||
if(activeTool === "bucket") {
|
|
||||||
fillAt(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hit = hitTestMesh(e, gridCanvas);
|
|
||||||
pushUndo();
|
|
||||||
if(hit !== -1) {
|
|
||||||
draggingMeshIndex = hit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
painting = true;
|
|
||||||
paintAt(e);
|
|
||||||
});
|
|
||||||
window.addEventListener("mouseup", () => { painting = false; draggingMeshIndex = -1; });
|
|
||||||
gridCanvas.addEventListener("mousemove", (e) => {
|
|
||||||
hoverTile = canvasToTile(e, gridCanvas);
|
|
||||||
if(draggingMeshIndex !== -1) { moveMeshTo(e, draggingMeshIndex); return; }
|
|
||||||
if(painting) { paintAt(e); return; }
|
|
||||||
renderGrid();
|
|
||||||
renderPreview();
|
|
||||||
});
|
|
||||||
gridCanvas.addEventListener("mouseleave", () => {
|
|
||||||
hoverTile = null;
|
|
||||||
renderGrid();
|
|
||||||
renderPreview();
|
|
||||||
});
|
|
||||||
|
|
||||||
function setZLevel(z) {
|
|
||||||
currentZLevel = Math.max(0, Math.min(ChunkTerrain.CHUNK_DEPTH - 1, z));
|
|
||||||
document.getElementById("zLevel").value = currentZLevel;
|
|
||||||
document.getElementById("zLevelLabel").textContent = currentZLevel;
|
|
||||||
renderGrid();
|
|
||||||
renderPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("zLevel").addEventListener("input", (e) => {
|
|
||||||
setZLevel(parseInt(e.target.value, 10));
|
|
||||||
});
|
|
||||||
document.getElementById("zLevelDown").addEventListener("click", () => setZLevel(currentZLevel - 1));
|
|
||||||
document.getElementById("zLevelUp").addEventListener("click", () => setZLevel(currentZLevel + 1));
|
|
||||||
|
|
||||||
document.getElementById("btnLoad").addEventListener("click", () => {
|
|
||||||
const x = parseInt(document.getElementById("coordX").value, 10) || 0;
|
|
||||||
const y = parseInt(document.getElementById("coordY").value, 10) || 0;
|
|
||||||
const z = parseInt(document.getElementById("coordZ").value, 10) || 0;
|
|
||||||
goToChunk(x, y, z);
|
|
||||||
});
|
|
||||||
|
|
||||||
// NORTH=+Y, EAST=+X (matches tile-shape convention used by the tile
|
|
||||||
// grid and tools/asset/chunk/__main__.py).
|
|
||||||
document.getElementById("navN").addEventListener("click", () => goToChunk(coord.x, coord.y + 1, coord.z));
|
|
||||||
document.getElementById("navS").addEventListener("click", () => goToChunk(coord.x, coord.y - 1, coord.z));
|
|
||||||
document.getElementById("navE").addEventListener("click", () => goToChunk(coord.x + 1, coord.y, coord.z));
|
|
||||||
document.getElementById("navW").addEventListener("click", () => goToChunk(coord.x - 1, coord.y, coord.z));
|
|
||||||
document.getElementById("navUp").addEventListener("click", () => goToChunk(coord.x, coord.y, coord.z + 1));
|
|
||||||
document.getElementById("navDown").addEventListener("click", () => goToChunk(coord.x, coord.y, coord.z - 1));
|
|
||||||
|
|
||||||
function runSave() {
|
|
||||||
saveChunk().catch((e) => updateStatus(`Save failed: ${e.message}`, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("btnSave").addEventListener("click", runSave);
|
|
||||||
|
|
||||||
document.getElementById("btnAddMesh").addEventListener("click", () => {
|
|
||||||
const base = document.getElementById("meshPicker").value;
|
|
||||||
if(!base) return;
|
|
||||||
const pos = [
|
|
||||||
parseFloat(document.getElementById("meshX").value) || 0,
|
|
||||||
parseFloat(document.getElementById("meshY").value) || 0,
|
|
||||||
parseFloat(document.getElementById("meshZ").value) || 0,
|
|
||||||
];
|
|
||||||
pushUndo();
|
|
||||||
meshes.push({ file: `${base}.dmf`, pos });
|
|
||||||
markDirty();
|
|
||||||
renderMeshList();
|
|
||||||
renderGrid();
|
|
||||||
renderPreview();
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById("previewCanvas").addEventListener("wheel", (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
zoomWorldH = Math.min(60, Math.max(4, zoomWorldH + Math.sign(e.deltaY)));
|
|
||||||
renderPreview();
|
|
||||||
}, { passive: false });
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => renderPreview());
|
|
||||||
|
|
||||||
window.addEventListener("keydown", (e) => {
|
|
||||||
if(!(e.ctrlKey || e.metaKey)) return;
|
|
||||||
const key = e.key.toLowerCase();
|
|
||||||
if(key === "z") {
|
|
||||||
e.preventDefault();
|
|
||||||
undo();
|
|
||||||
} else if(key === "s") {
|
|
||||||
e.preventDefault();
|
|
||||||
runSave();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", async () => {
|
|
||||||
buildPalette();
|
|
||||||
buildToolPalette();
|
|
||||||
mapRenderer = MapRenderer.create(document.getElementById("previewCanvas"));
|
|
||||||
bindEvents();
|
|
||||||
await Promise.all([buildChunkBrowseList(), buildMeshPicker()]);
|
|
||||||
await loadChunk(coord.x, coord.y, coord.z);
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// MapRenderer - a minimal, dependency-free WebGL renderer for the chunk
|
|
||||||
// preview pane. The camera formula is ported 1:1 from
|
|
||||||
// src/dusk/scene/overworld/sceneoverworld.c (lines 62-81) so the preview
|
|
||||||
// approximates the game's own fixed-angle 3rd-person camera: the eye sits
|
|
||||||
// worldH units "behind" the target along Y and a proportional distance
|
|
||||||
// "above" along Z, always looking at the target, up = (0, 1, 0).
|
|
||||||
//
|
|
||||||
// The material model mirrors SHADER_UNLIT: a texture sampler multiplied by
|
|
||||||
// a flat RGBA tint, with a 1x1 white fallback texture standing in for
|
|
||||||
// untextured models.
|
|
||||||
|
|
||||||
const MapRenderer = (() => {
|
|
||||||
const VERT_SRC = `
|
|
||||||
attribute vec2 aUV;
|
|
||||||
attribute vec3 aPos;
|
|
||||||
uniform mat4 uModel;
|
|
||||||
uniform mat4 uView;
|
|
||||||
uniform mat4 uProjection;
|
|
||||||
varying vec2 vUV;
|
|
||||||
void main() {
|
|
||||||
vUV = aUV;
|
|
||||||
gl_Position = uProjection * uView * uModel * vec4(aPos, 1.0);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const FRAG_SRC = `
|
|
||||||
precision mediump float;
|
|
||||||
varying vec2 vUV;
|
|
||||||
uniform sampler2D uTexture;
|
|
||||||
uniform vec4 uColor;
|
|
||||||
void main() {
|
|
||||||
gl_FragColor = texture2D(uTexture, vUV) * uColor;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
function mat4Identity(out) {
|
|
||||||
out.fill(0);
|
|
||||||
out[0] = out[5] = out[10] = out[15] = 1;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mat4Translation(out, v) {
|
|
||||||
mat4Identity(out);
|
|
||||||
out[12] = v[0];
|
|
||||||
out[13] = v[1];
|
|
||||||
out[14] = v[2];
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mat4Perspective(out, fovy, aspect, near, far) {
|
|
||||||
const f = 1.0 / Math.tan(fovy / 2);
|
|
||||||
out.fill(0);
|
|
||||||
out[0] = f / aspect;
|
|
||||||
out[5] = f;
|
|
||||||
out[10] = (far + near) / (near - far);
|
|
||||||
out[11] = -1;
|
|
||||||
out[14] = (2 * far * near) / (near - far);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
function vec3Sub(a, b) {
|
|
||||||
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
||||||
}
|
|
||||||
|
|
||||||
function vec3Cross(a, b) {
|
|
||||||
return [
|
|
||||||
a[1] * b[2] - a[2] * b[1],
|
|
||||||
a[2] * b[0] - a[0] * b[2],
|
|
||||||
a[0] * b[1] - a[1] * b[0],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
function vec3Normalize(a) {
|
|
||||||
const len = Math.hypot(a[0], a[1], a[2]) || 1;
|
|
||||||
return [a[0] / len, a[1] / len, a[2] / len];
|
|
||||||
}
|
|
||||||
|
|
||||||
function mat4LookAt(out, eye, center, up) {
|
|
||||||
const zAxis = vec3Normalize(vec3Sub(eye, center));
|
|
||||||
const xAxis = vec3Normalize(vec3Cross(up, zAxis));
|
|
||||||
const yAxis = vec3Cross(zAxis, xAxis);
|
|
||||||
|
|
||||||
out[0] = xAxis[0]; out[1] = yAxis[0]; out[2] = zAxis[0]; out[3] = 0;
|
|
||||||
out[4] = xAxis[1]; out[5] = yAxis[1]; out[6] = zAxis[1]; out[7] = 0;
|
|
||||||
out[8] = xAxis[2]; out[9] = yAxis[2]; out[10] = zAxis[2]; out[11] = 0;
|
|
||||||
out[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]);
|
|
||||||
out[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]);
|
|
||||||
out[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]);
|
|
||||||
out[15] = 1;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ported from sceneoverworld.c:62-81. Returns { eye, view }.
|
|
||||||
function computeCamera(target, worldH) {
|
|
||||||
const fov = Math.PI / 4; // glm_rad(45.0f)
|
|
||||||
const zDist = (worldH * 0.5) / Math.tan(fov * 0.5);
|
|
||||||
const offset = -worldH;
|
|
||||||
|
|
||||||
const eye = [target[0], target[1] + offset, target[2] + zDist];
|
|
||||||
const view = mat4LookAt(new Float32Array(16), eye, target, [0, 1, 0]);
|
|
||||||
return { eye, view, fov };
|
|
||||||
}
|
|
||||||
|
|
||||||
function compileShader(gl, type, src) {
|
|
||||||
const shader = gl.createShader(type);
|
|
||||||
gl.shaderSource(shader, src);
|
|
||||||
gl.compileShader(shader);
|
|
||||||
if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
||||||
const info = gl.getShaderInfoLog(shader);
|
|
||||||
gl.deleteShader(shader);
|
|
||||||
throw new Error(`Shader compile failed: ${info}`);
|
|
||||||
}
|
|
||||||
return shader;
|
|
||||||
}
|
|
||||||
|
|
||||||
function create(canvas) {
|
|
||||||
const gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
|
||||||
if(!gl) throw new Error("WebGL is not available in this browser");
|
|
||||||
|
|
||||||
const program = gl.createProgram();
|
|
||||||
gl.attachShader(program, compileShader(gl, gl.VERTEX_SHADER, VERT_SRC));
|
|
||||||
gl.attachShader(program, compileShader(gl, gl.FRAGMENT_SHADER, FRAG_SRC));
|
|
||||||
gl.linkProgram(program);
|
|
||||||
if(!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
||||||
throw new Error(`Program link failed: ${gl.getProgramInfoLog(program)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const attribs = {
|
|
||||||
aUV: gl.getAttribLocation(program, "aUV"),
|
|
||||||
aPos: gl.getAttribLocation(program, "aPos"),
|
|
||||||
};
|
|
||||||
const uniforms = {
|
|
||||||
uModel: gl.getUniformLocation(program, "uModel"),
|
|
||||||
uView: gl.getUniformLocation(program, "uView"),
|
|
||||||
uProjection: gl.getUniformLocation(program, "uProjection"),
|
|
||||||
uTexture: gl.getUniformLocation(program, "uTexture"),
|
|
||||||
uColor: gl.getUniformLocation(program, "uColor"),
|
|
||||||
};
|
|
||||||
|
|
||||||
const whiteTexture = gl.createTexture();
|
|
||||||
gl.bindTexture(gl.TEXTURE_2D, whiteTexture);
|
|
||||||
gl.texImage2D(
|
|
||||||
gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,
|
|
||||||
new Uint8Array([255, 255, 255, 255]),
|
|
||||||
);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
||||||
|
|
||||||
gl.enable(gl.DEPTH_TEST);
|
|
||||||
gl.enable(gl.BLEND);
|
|
||||||
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
||||||
// Terrain/mesh winding isn't guaranteed consistent relative to this
|
|
||||||
// preview's fixed camera angle, so backface culling stays off - this
|
|
||||||
// is an authoring preview, not a performance-sensitive renderer, and
|
|
||||||
// an invisible mesh is a worse failure mode than a visible backface.
|
|
||||||
|
|
||||||
// Uploads interleaved [u, v, x, y, z] float data (DMF/terrain layout)
|
|
||||||
// into a GL buffer. Returns { buffer, vertexCount }.
|
|
||||||
function createMesh(floats) {
|
|
||||||
const buffer = gl.createBuffer();
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
||||||
gl.bufferData(gl.ARRAY_BUFFER, floats, gl.STATIC_DRAW);
|
|
||||||
return { buffer, vertexCount: floats.length / 5 };
|
|
||||||
}
|
|
||||||
|
|
||||||
function createTextureFromImage(image) {
|
|
||||||
const texture = gl.createTexture();
|
|
||||||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
||||||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
||||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
||||||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawMesh(mesh, model, texture, color, depthWrite, mode) {
|
|
||||||
gl.depthMask(depthWrite !== false);
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer);
|
|
||||||
gl.enableVertexAttribArray(attribs.aUV);
|
|
||||||
gl.vertexAttribPointer(attribs.aUV, 2, gl.FLOAT, false, 20, 0);
|
|
||||||
gl.enableVertexAttribArray(attribs.aPos);
|
|
||||||
gl.vertexAttribPointer(attribs.aPos, 3, gl.FLOAT, false, 20, 8);
|
|
||||||
|
|
||||||
gl.uniformMatrix4fv(uniforms.uModel, false, model);
|
|
||||||
gl.uniform4f(uniforms.uColor, color[0], color[1], color[2], color[3]);
|
|
||||||
|
|
||||||
gl.activeTexture(gl.TEXTURE0);
|
|
||||||
gl.bindTexture(gl.TEXTURE_2D, texture || whiteTexture);
|
|
||||||
gl.uniform1i(uniforms.uTexture, 0);
|
|
||||||
|
|
||||||
gl.drawArrays(mode || gl.TRIANGLES, 0, mesh.vertexCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builds a 4-vertex outline of the tile at (x, y, z), lifted slightly
|
|
||||||
// to avoid z-fighting with the terrain surface beneath it.
|
|
||||||
function buildHighlightMesh(x, y, z) {
|
|
||||||
const eps = 0.02;
|
|
||||||
return createMesh(new Float32Array([
|
|
||||||
0, 0, x, y, z + eps,
|
|
||||||
0, 0, x + 1, y, z + eps,
|
|
||||||
0, 0, x + 1, y + 1, z + eps,
|
|
||||||
0, 0, x, y + 1, z + eps,
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Neighboring chunks are drawn dimmer and semi-transparent, so they
|
|
||||||
// read as context rather than part of the chunk being edited.
|
|
||||||
const NEIGHBOR_ALPHA = 0.35;
|
|
||||||
const NEIGHBOR_DARKEN = 0.5;
|
|
||||||
|
|
||||||
// scene = {
|
|
||||||
// target: [x, y, z], worldH: number,
|
|
||||||
// terrain: { mesh, texture } | null,
|
|
||||||
// gridLines: { mesh } | null,
|
|
||||||
// models: [{ mesh, texture, color: [r,g,b,a in 0..1], offset: [x,y,z] }],
|
|
||||||
// neighbors: [{
|
|
||||||
// offset: [x,y,z],
|
|
||||||
// terrain: { mesh, texture } | null,
|
|
||||||
// models: [{ mesh, texture, color, offset }],
|
|
||||||
// }],
|
|
||||||
// highlight: { x, y, z } | null,
|
|
||||||
// }
|
|
||||||
function render(scene) {
|
|
||||||
const width = canvas.width, height = canvas.height;
|
|
||||||
gl.viewport(0, 0, width, height);
|
|
||||||
gl.clearColor(0.16, 0.18, 0.22, 1);
|
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
||||||
gl.useProgram(program);
|
|
||||||
gl.depthMask(true);
|
|
||||||
|
|
||||||
const { view, fov } = computeCamera(scene.target, scene.worldH);
|
|
||||||
const projection = mat4Perspective(new Float32Array(16), fov, width / height, 0.1, 1000);
|
|
||||||
gl.uniformMatrix4fv(uniforms.uProjection, false, projection);
|
|
||||||
gl.uniformMatrix4fv(uniforms.uView, false, view);
|
|
||||||
|
|
||||||
const identity = mat4Identity(new Float32Array(16));
|
|
||||||
|
|
||||||
if(scene.terrain) {
|
|
||||||
drawMesh(scene.terrain.mesh, identity, scene.terrain.texture, [1, 1, 1, 1], true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(scene.gridLines) {
|
|
||||||
drawMesh(scene.gridLines.mesh, identity, null, [0, 0, 0, 0.35], false, gl.LINES);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(const model of scene.models) {
|
|
||||||
const modelMatrix = mat4Translation(new Float32Array(16), model.offset);
|
|
||||||
drawMesh(model.mesh, modelMatrix, model.texture, model.color, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(const neighbor of scene.neighbors || []) {
|
|
||||||
if(neighbor.terrain) {
|
|
||||||
const modelMatrix = mat4Translation(new Float32Array(16), neighbor.offset);
|
|
||||||
drawMesh(
|
|
||||||
neighbor.terrain.mesh, modelMatrix, neighbor.terrain.texture,
|
|
||||||
[NEIGHBOR_DARKEN, NEIGHBOR_DARKEN, NEIGHBOR_DARKEN, NEIGHBOR_ALPHA], false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(const model of neighbor.models) {
|
|
||||||
const worldOffset = [
|
|
||||||
neighbor.offset[0] + model.offset[0],
|
|
||||||
neighbor.offset[1] + model.offset[1],
|
|
||||||
neighbor.offset[2] + model.offset[2],
|
|
||||||
];
|
|
||||||
const modelMatrix = mat4Translation(new Float32Array(16), worldOffset);
|
|
||||||
const color = [
|
|
||||||
model.color[0] * NEIGHBOR_DARKEN,
|
|
||||||
model.color[1] * NEIGHBOR_DARKEN,
|
|
||||||
model.color[2] * NEIGHBOR_DARKEN,
|
|
||||||
model.color[3] * NEIGHBOR_ALPHA,
|
|
||||||
];
|
|
||||||
drawMesh(model.mesh, modelMatrix, model.texture, color, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(scene.highlight) {
|
|
||||||
const { x, y, z } = scene.highlight;
|
|
||||||
const highlightMesh = buildHighlightMesh(x, y, z);
|
|
||||||
drawMesh(highlightMesh, identity, null, [1, 0.92, 0.23, 1], false, gl.LINE_LOOP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { gl, createMesh, createTextureFromImage, render };
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.freeze({ create, computeCamera });
|
|
||||||
})();
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Dusk Map Editor</title>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<nav class="navbar navbar-expand navbar-dark bg-dark">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="/">Dusk Map Editor</a>
|
|
||||||
<ul class="navbar-nav flex-row">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="/map">Map Editor</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div id="editor" class="container-fluid py-3"></div>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,295 +0,0 @@
|
|||||||
"""
|
|
||||||
Map Editor HTTP Server
|
|
||||||
|
|
||||||
Serves editor/client/public/ as static files with smart routing:
|
|
||||||
/ -> index.html
|
|
||||||
/page -> page.html or page/index.html
|
|
||||||
/index -> index.html
|
|
||||||
|
|
||||||
API endpoints (all paths relative to project root):
|
|
||||||
GET /api/ls?path=<dir> directory listing
|
|
||||||
GET /api/read?path=<file> file contents
|
|
||||||
GET /api/find?path=<dir>&ext=<.json> recursive file listing by extension
|
|
||||||
POST /api/write?path=<file> write file (JSON body: {"content":"..."})
|
|
||||||
POST /api/mkdir?path=<dir> create directory
|
|
||||||
POST /api/delete?path=<file> delete a file
|
|
||||||
POST /api/compile-chunk?x=&y=&z= recompile a chunk JSON to .dcf
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
import json
|
|
||||||
import mimetypes
|
|
||||||
import subprocess
|
|
||||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
||||||
from urllib.parse import urlparse, parse_qs, unquote
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
CHUNK_COORD_RE = re.compile(r"^-?\d+$")
|
|
||||||
|
|
||||||
PORT = 3000
|
|
||||||
SCRIPT_DIR = Path(__file__).parent.resolve()
|
|
||||||
PUBLIC_DIR = SCRIPT_DIR.parent / "client" / "public"
|
|
||||||
PROJECT_ROOT = SCRIPT_DIR.parent.parent.resolve()
|
|
||||||
|
|
||||||
|
|
||||||
class Handler(BaseHTTPRequestHandler):
|
|
||||||
def do_GET(self):
|
|
||||||
parsed = urlparse(self.path)
|
|
||||||
path = unquote(parsed.path)
|
|
||||||
if path.startswith("/api/"):
|
|
||||||
params = parse_qs(parsed.query)
|
|
||||||
if path == "/api/ls":
|
|
||||||
self.api_ls(params)
|
|
||||||
elif path == "/api/read":
|
|
||||||
self.api_read(params)
|
|
||||||
elif path == "/api/find":
|
|
||||||
self.api_find(params)
|
|
||||||
else:
|
|
||||||
self.send_error(404)
|
|
||||||
else:
|
|
||||||
self.serve_static(path)
|
|
||||||
|
|
||||||
def do_POST(self):
|
|
||||||
parsed = urlparse(self.path)
|
|
||||||
params = parse_qs(parsed.query)
|
|
||||||
if parsed.path == "/api/write":
|
|
||||||
self.api_write(params)
|
|
||||||
elif parsed.path == "/api/mkdir":
|
|
||||||
self.api_mkdir(params)
|
|
||||||
elif parsed.path == "/api/delete":
|
|
||||||
self.api_delete(params)
|
|
||||||
elif parsed.path == "/api/compile-chunk":
|
|
||||||
self.api_compile_chunk(params)
|
|
||||||
else:
|
|
||||||
self.send_error(404)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# Helpers
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
|
|
||||||
def resolve_project_path(self, rel):
|
|
||||||
rel = rel.lstrip("/")
|
|
||||||
target = (PROJECT_ROOT / rel).resolve()
|
|
||||||
if not str(target).startswith(str(PROJECT_ROOT)):
|
|
||||||
return None
|
|
||||||
return target
|
|
||||||
|
|
||||||
def send_json(self, data, code=200):
|
|
||||||
body = json.dumps(data, indent=2).encode("utf-8")
|
|
||||||
self.send_response(code)
|
|
||||||
self.send_header("Content-Type", "application/json")
|
|
||||||
self.send_header("Content-Length", len(body))
|
|
||||||
self.end_headers()
|
|
||||||
self.wfile.write(body)
|
|
||||||
|
|
||||||
def read_body(self):
|
|
||||||
length = int(self.headers.get("Content-Length", 0))
|
|
||||||
return self.rfile.read(length)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# API handlers
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
|
|
||||||
def api_ls(self, params):
|
|
||||||
rel = params.get("path", [""])[0]
|
|
||||||
target = self.resolve_project_path(rel)
|
|
||||||
if target is None:
|
|
||||||
self.send_json({"error": "invalid path"}, 400)
|
|
||||||
return
|
|
||||||
if not target.exists():
|
|
||||||
self.send_json({"error": "path not found"}, 404)
|
|
||||||
return
|
|
||||||
if not target.is_dir():
|
|
||||||
self.send_json({"error": "not a directory"}, 400)
|
|
||||||
return
|
|
||||||
|
|
||||||
entries = []
|
|
||||||
for entry in sorted(target.iterdir(), key=lambda e: (e.is_file(), e.name)):
|
|
||||||
entries.append({
|
|
||||||
"name": entry.name,
|
|
||||||
"type": "dir" if entry.is_dir() else "file",
|
|
||||||
"size": entry.stat().st_size if entry.is_file() else None,
|
|
||||||
})
|
|
||||||
self.send_json({
|
|
||||||
"path": str(target.relative_to(PROJECT_ROOT)),
|
|
||||||
"entries": entries,
|
|
||||||
})
|
|
||||||
|
|
||||||
def api_read(self, params):
|
|
||||||
rel = params.get("path", [""])[0]
|
|
||||||
target = self.resolve_project_path(rel)
|
|
||||||
if target is None:
|
|
||||||
self.send_json({"error": "invalid path"}, 400)
|
|
||||||
return
|
|
||||||
if not target.exists():
|
|
||||||
self.send_json({"error": "file not found"}, 404)
|
|
||||||
return
|
|
||||||
if not target.is_file():
|
|
||||||
self.send_json({"error": "not a file"}, 400)
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
content = target.read_text(encoding="utf-8")
|
|
||||||
self.send_json({
|
|
||||||
"path": str(target.relative_to(PROJECT_ROOT)),
|
|
||||||
"content": content,
|
|
||||||
})
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
import base64
|
|
||||||
content = base64.b64encode(target.read_bytes()).decode("ascii")
|
|
||||||
self.send_json({
|
|
||||||
"path": str(target.relative_to(PROJECT_ROOT)),
|
|
||||||
"content": content,
|
|
||||||
"encoding": "base64",
|
|
||||||
})
|
|
||||||
|
|
||||||
def api_write(self, params):
|
|
||||||
rel = params.get("path", [""])[0]
|
|
||||||
target = self.resolve_project_path(rel)
|
|
||||||
if target is None:
|
|
||||||
self.send_json({"error": "invalid path"}, 400)
|
|
||||||
return
|
|
||||||
|
|
||||||
body = self.read_body()
|
|
||||||
try:
|
|
||||||
data = json.loads(body)
|
|
||||||
content = data.get("content", "")
|
|
||||||
except (json.JSONDecodeError, UnicodeDecodeError):
|
|
||||||
content = body.decode("utf-8")
|
|
||||||
|
|
||||||
target.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
target.write_text(content, encoding="utf-8")
|
|
||||||
self.send_json({"ok": True, "path": str(target.relative_to(PROJECT_ROOT))})
|
|
||||||
|
|
||||||
def api_mkdir(self, params):
|
|
||||||
rel = params.get("path", [""])[0]
|
|
||||||
target = self.resolve_project_path(rel)
|
|
||||||
if target is None:
|
|
||||||
self.send_json({"error": "invalid path"}, 400)
|
|
||||||
return
|
|
||||||
target.mkdir(parents=True, exist_ok=True)
|
|
||||||
self.send_json({"ok": True, "path": str(target.relative_to(PROJECT_ROOT))})
|
|
||||||
|
|
||||||
def api_delete(self, params):
|
|
||||||
rel = params.get("path", [""])[0]
|
|
||||||
target = self.resolve_project_path(rel)
|
|
||||||
if target is None:
|
|
||||||
self.send_json({"error": "invalid path"}, 400)
|
|
||||||
return
|
|
||||||
if target.is_file():
|
|
||||||
target.unlink()
|
|
||||||
self.send_json({"ok": True, "path": str(target.relative_to(PROJECT_ROOT))})
|
|
||||||
|
|
||||||
def api_find(self, params):
|
|
||||||
rel = params.get("path", [""])[0]
|
|
||||||
ext = params.get("ext", [""])[0]
|
|
||||||
target = self.resolve_project_path(rel)
|
|
||||||
if target is None:
|
|
||||||
self.send_json({"error": "invalid path"}, 400)
|
|
||||||
return
|
|
||||||
if not target.is_dir():
|
|
||||||
self.send_json({"error": "not a directory"}, 400)
|
|
||||||
return
|
|
||||||
|
|
||||||
pattern = f"*{ext}" if ext else "*"
|
|
||||||
paths = sorted(
|
|
||||||
str(p.relative_to(target)).replace(os.sep, "/")
|
|
||||||
for p in target.rglob(pattern)
|
|
||||||
if p.is_file()
|
|
||||||
)
|
|
||||||
self.send_json({"path": str(target.relative_to(PROJECT_ROOT)), "files": paths})
|
|
||||||
|
|
||||||
def api_compile_chunk(self, params):
|
|
||||||
x = params.get("x", [""])[0]
|
|
||||||
y = params.get("y", [""])[0]
|
|
||||||
z = params.get("z", [""])[0]
|
|
||||||
if not (CHUNK_COORD_RE.match(x) and CHUNK_COORD_RE.match(y) and CHUNK_COORD_RE.match(z)):
|
|
||||||
self.send_json({"error": "invalid chunk coordinates"}, 400)
|
|
||||||
return
|
|
||||||
|
|
||||||
json_path = PROJECT_ROOT / "assetsraw" / "chunks" / f"chunk_{x}_{y}_{z}.json"
|
|
||||||
if not json_path.is_file():
|
|
||||||
self.send_json({"error": "chunk json not found"}, 404)
|
|
||||||
return
|
|
||||||
|
|
||||||
result = subprocess.run(
|
|
||||||
[sys.executable, "-m", "tools.asset.chunk", str(json_path)],
|
|
||||||
cwd=str(PROJECT_ROOT),
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
self.send_json({
|
|
||||||
"ok": result.returncode == 0,
|
|
||||||
"returncode": result.returncode,
|
|
||||||
"stdout": result.stdout,
|
|
||||||
"stderr": result.stderr,
|
|
||||||
})
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# Static file serving
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
|
|
||||||
def serve_static(self, path):
|
|
||||||
clean = path.lstrip("/")
|
|
||||||
candidates = []
|
|
||||||
|
|
||||||
if clean == "" or clean == "index" or clean == "index.html":
|
|
||||||
candidates = ["index.html"]
|
|
||||||
else:
|
|
||||||
candidates.append(clean)
|
|
||||||
if "." not in Path(clean).name:
|
|
||||||
candidates.append(clean + ".html")
|
|
||||||
candidates.append(clean + "/index.html")
|
|
||||||
|
|
||||||
for candidate in candidates:
|
|
||||||
file_path = PUBLIC_DIR / candidate
|
|
||||||
if file_path.is_file():
|
|
||||||
self.serve_file(file_path)
|
|
||||||
return
|
|
||||||
|
|
||||||
self.send_error(404)
|
|
||||||
|
|
||||||
def serve_file(self, file_path):
|
|
||||||
mime, _ = mimetypes.guess_type(str(file_path))
|
|
||||||
mime = mime or "application/octet-stream"
|
|
||||||
|
|
||||||
template = PUBLIC_DIR / "template.html"
|
|
||||||
if (
|
|
||||||
mime == "text/html"
|
|
||||||
and file_path.name != "template.html"
|
|
||||||
and template.is_file()
|
|
||||||
):
|
|
||||||
fragment = file_path.read_text(encoding="utf-8")
|
|
||||||
shell = template.read_text(encoding="utf-8")
|
|
||||||
marker = shell.find('id="editor"')
|
|
||||||
if marker == -1:
|
|
||||||
content = shell.encode("utf-8")
|
|
||||||
else:
|
|
||||||
tag_end = shell.index(">", marker) + 1
|
|
||||||
close_idx = shell.index("</div>", tag_end)
|
|
||||||
content = (shell[:tag_end] + fragment + shell[close_idx:]).encode("utf-8")
|
|
||||||
else:
|
|
||||||
content = file_path.read_bytes()
|
|
||||||
|
|
||||||
self.send_response(200)
|
|
||||||
self.send_header("Content-Type", mime)
|
|
||||||
self.send_header("Content-Length", len(content))
|
|
||||||
self.end_headers()
|
|
||||||
self.wfile.write(content)
|
|
||||||
|
|
||||||
def log_message(self, fmt, *args):
|
|
||||||
print(f" {self.address_string()} {fmt % args}")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
print(f"Map Editor")
|
|
||||||
print(f" http://localhost:{PORT}")
|
|
||||||
print(f" public : {PUBLIC_DIR}")
|
|
||||||
print(f" project: {PROJECT_ROOT}")
|
|
||||||
server = HTTPServer(("", PORT), Handler)
|
|
||||||
try:
|
|
||||||
server.serve_forever()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print("\nStopped.")
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
python3 server/server.py
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-dolphin -f docker/dolphin/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/build-gamecube.sh"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-dolphin -f docker/dolphin/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/build-gamecube-iso.sh"
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if [ -z "$DEVKITPRO" ]; then
|
|
||||||
echo "DEVKITPRO environment variable is not set. Please set it to the path of your DEVKITPRO installation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p build-gamecube-iso
|
|
||||||
cmake -S. -Bbuild-gamecube-iso \
|
|
||||||
-DDUSK_TARGET_SYSTEM=gamecube \
|
|
||||||
-DDUSK_DOLPHIN_BUILD_TYPE=ISO \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/GameCube.cmake"
|
|
||||||
cd build-gamecube-iso
|
|
||||||
make -j$(nproc) VERBOSE=1
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if [ -z "$DEVKITPRO" ]; then
|
|
||||||
echo "DEVKITPRO environment variable is not set. Please set it to the path of your DEVKITPRO installation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p build-gamecube
|
|
||||||
cmake -S. -Bbuild-gamecube \
|
|
||||||
-DDUSK_TARGET_SYSTEM=gamecube \
|
|
||||||
-DDUSK_DOLPHIN_BUILD_TYPE=DOL \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/GameCube.cmake" \
|
|
||||||
-DDKP_OGC_PLATFORM_LIBRARY=libogc2
|
|
||||||
cd build-gamecube
|
|
||||||
make -j$(nproc) VERBOSE=1
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-knulli -f docker/knulli/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-knulli /bin/bash -c "./scripts/build-knulli.sh"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cmake -S . -B build-knulli -G Ninja \
|
|
||||||
-DDUSK_BUILD_TESTS=ON \
|
|
||||||
-DDUSK_TARGET_SYSTEM=knulli \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE=./cmake/toolchains/aarch64-linux-gnu.cmake \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
|
||||||
cmake --build build-knulli -- -j$(nproc)
|
|
||||||
|
|
||||||
# Copy necessary libs out
|
|
||||||
mkdir -p ./build-knulli/dusk
|
|
||||||
cp ./build-knulli/Dusk ./build-knulli/dusk/Dusk
|
|
||||||
cp ./build-knulli/dusk.dsk ./build-knulli/dusk/dusk.dsk
|
|
||||||
echo '#!/bin/bash' > build-knulli/dusk/Dusk.sh
|
|
||||||
echo 'cd "$(dirname "$(readlink -f "$0")")"' >> build-knulli/dusk/Dusk.sh
|
|
||||||
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(dirname "$(readlink -f "$0")")' >> build-knulli/dusk/Dusk.sh
|
|
||||||
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/gl4es' >> build-knulli/dusk/Dusk.sh
|
|
||||||
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib' >> build-knulli/dusk/Dusk.sh
|
|
||||||
echo '$(dirname "$(readlink -f "$0")")/Dusk' >> build-knulli/dusk/Dusk.sh
|
|
||||||
chmod +x build-knulli/dusk/Dusk.sh
|
|
||||||
cp /usr/lib/aarch64-linux-gnu/liblua5.4.so.0 build-knulli/dusk/
|
|
||||||
# cp /usr/lib/aarch64-linux-gnu/libSDL2-2.0.so.0 build-knulli/dusk/
|
|
||||||
# cp /usr/lib/aarch64-linux-gnu/libGL.so.1 build-knulli/dusk/
|
|
||||||
# cp /usr/lib/aarch64-linux-gnu/libEGL.so.1 build-knulli/dusk/
|
|
||||||
# cp /usr/lib/aarch64-linux-gnu/libGLESv2.so.2 build-knulli/dusk/
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cmake -S . -B build-linux -DDUSK_BUILD_TESTS=ON -DDUSK_TARGET_SYSTEM=linux
|
|
||||||
cmake --build build-linux -- -j$(nproc)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if [ -z "$PSPDEV" ]; then
|
|
||||||
echo "PSPDEV environment variable is not set. Please set it to the path of your PSP development environment."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p build-psp
|
|
||||||
cd build-psp
|
|
||||||
psp-cmake -DDUSK_TARGET_SYSTEM=psp -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake -DBUILD_PRX=1 .. CMAKE_BUILD_TYPE=Release
|
|
||||||
make -j$(nproc)
|
|
||||||
# psp-cmake -DDUSK_TARGET_SYSTEM=psp -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake -DBUILD_PRX=1 -DCMAKE_BUILD_TYPE=Debug ..
|
|
||||||
# make
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-vita -f docker/vita/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-vita /bin/bash -c "./scripts/build-vita.sh"
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if [ -z "$VITASDK" ]; then
|
|
||||||
echo "VITASDK environment variable is not set. Please set it to the path of your VitaSDK installation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p build-vita
|
|
||||||
cd build-vita
|
|
||||||
cmake \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE=$VITASDK/share/vita.toolchain.cmake \
|
|
||||||
-DDUSK_TARGET_SYSTEM=vita \
|
|
||||||
..
|
|
||||||
make -j$(nproc)
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-dolphin -f docker/dolphin/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/build-wii.sh"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-dolphin -f docker/dolphin/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/build-wii-iso.sh"
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if [ -z "$DEVKITPRO" ]; then
|
|
||||||
echo "DEVKITPRO environment variable is not set. Please set it to the path of your DEVKITPRO installation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p build-wii-iso
|
|
||||||
cmake -S. -Bbuild-wii-iso \
|
|
||||||
-DDUSK_TARGET_SYSTEM=wii \
|
|
||||||
-DDUSK_DOLPHIN_BUILD_TYPE=ISO \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake"
|
|
||||||
cd build-wii-iso
|
|
||||||
make -j$(nproc) VERBOSE=1
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
if [ -z "$DEVKITPRO" ]; then
|
|
||||||
echo "DEVKITPRO environment variable is not set. Please set it to the path of your DEVKITPRO installation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p build-wii
|
|
||||||
cmake -S. -Bbuild-wii \
|
|
||||||
-DDUSK_TARGET_SYSTEM=wii \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake" \
|
|
||||||
-DDUSK_DOLPHIN_BUILD_TYPE=DOL
|
|
||||||
cd build-wii
|
|
||||||
make -j$(nproc) VERBOSE=1
|
|
||||||
mv Dusk.dol boot.dol
|
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
docker build -t dusk-linux -f docker/linux/Dockerfile .
|
||||||
|
docker run --rm -v "$(pwd):/workdir" dusk-linux /bin/bash -c "./scripts/linux/build.sh"
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
cmake -S . -B build-linux -DDUSK_TARGET_SYSTEM=linux
|
||||||
|
cmake --build build-linux -- -j"$(nproc)"
|
||||||
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Installs the packages required to build and test Dusk on Linux.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SUDO=""
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
SUDO="sudo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
|
$SUDO apt-get update
|
||||||
|
$SUDO apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
cmake \
|
||||||
|
git \
|
||||||
|
python3 \
|
||||||
|
python3-pip \
|
||||||
|
python3-polib \
|
||||||
|
python3-pil \
|
||||||
|
python3-dotenv \
|
||||||
|
python3-numpy \
|
||||||
|
libsdl3-dev \
|
||||||
|
libvulkan-dev \
|
||||||
|
libzip-dev \
|
||||||
|
libbz2-dev \
|
||||||
|
liblzma-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libssl-dev \
|
||||||
|
xz-utils
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
$SUDO dnf install -y \
|
||||||
|
git make gcc cmake python python-polib python3-pillow python3-dotenv \
|
||||||
|
python3-numpy SDL2-devel mesa-libGL-devel zlib-devel libzip-devel \
|
||||||
|
bzip2-devel openssl-devel xz xz-devel
|
||||||
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
|
$SUDO pacman -Sy --noconfirm --needed \
|
||||||
|
base-devel git cmake python python-polib python-pillow python-dotenv \
|
||||||
|
python-numpy sdl2 mesa libzip bzip2 openssl xz zlib
|
||||||
|
else
|
||||||
|
echo "Unsupported package manager; install dependencies manually." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
docker build -t dusk-linux -f docker/linux/Dockerfile .
|
docker build -t dusk-linux -f docker/linux/Dockerfile .
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-linux /bin/bash -c "./scripts/build-linux.sh"
|
docker run --rm -v "$(pwd):/workdir" dusk-linux /bin/bash -c "./scripts/linux/test.sh"
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
rm -rf build-tests
|
||||||
|
cmake -S . -B build-tests -DDUSK_BUILD_TESTS=ON -DDUSK_TARGET_SYSTEM=linux
|
||||||
|
cmake --build build-tests -- -j"$(nproc)"
|
||||||
|
ctest --output-on-failure --test-dir build-tests
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
docker build -t dusk-psp -f docker/psp/Dockerfile .
|
docker build -t dusk-psp -f docker/psp/Dockerfile .
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-psp /bin/bash -c "./scripts/build-psp.sh"
|
docker run --rm -v "$(pwd):/workdir" dusk-psp /bin/bash -c "./scripts/psp/build.sh"
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
if [ -z "$PSPDEV" ]; then
|
||||||
|
echo "PSPDEV environment variable is not set." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
psp-cmake -S . -B build-psp \
|
||||||
|
-DDUSK_TARGET_SYSTEM=psp \
|
||||||
|
-DBUILD_PRX=1 \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build-psp -- -j"$(nproc)"
|
||||||
Executable
+30
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Installs the packages required to build Dusk for the PSP. The PSP toolchain
|
||||||
|
# itself (pspdev) must already be installed; the pspdev/pspdev docker image
|
||||||
|
# provides it.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SUDO=""
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
SUDO="sudo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v apk >/dev/null 2>&1; then
|
||||||
|
$SUDO apk add --no-cache git cmake make python3 py3-pip py3-dotenv
|
||||||
|
elif command -v apt-get >/dev/null 2>&1; then
|
||||||
|
$SUDO apt-get update
|
||||||
|
$SUDO apt-get install -y git cmake make python3 python3-pip python3-dotenv
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
$SUDO dnf install -y git cmake make python python3-dotenv
|
||||||
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
|
$SUDO pacman -Sy --noconfirm --needed git cmake make python python-dotenv
|
||||||
|
else
|
||||||
|
echo "Unsupported package manager; install dependencies manually." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$PSPDEV" ] || ! command -v psp-cmake >/dev/null 2>&1; then
|
||||||
|
echo "pspdev toolchain not found. Install it from https://pspdev.github.io/" >&2
|
||||||
|
echo "and set PSPDEV, or use scripts/psp/build-docker.sh." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-dolphin-test -f docker/dolphin-test/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin-test /bin/bash -c "./scripts/test-gamecube-dolphin.sh"
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -z "$DEVKITPRO" ]; then
|
|
||||||
echo "DEVKITPRO environment variable is not set. Please set it to the path of your DEVKITPRO installation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
DOLPHIN_BIN="${DOLPHIN_BIN:-dolphin-emu}"
|
|
||||||
if ! command -v "$DOLPHIN_BIN" >/dev/null 2>&1; then
|
|
||||||
echo "$DOLPHIN_BIN not found. Install Dolphin Emulator (e.g. 'apt install dolphin-emu')"
|
|
||||||
echo "or set DOLPHIN_BIN to its path."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if ! command -v xvfb-run >/dev/null 2>&1; then
|
|
||||||
echo "xvfb-run not found. Install it (e.g. 'apt install xvfb') -- Dolphin's"
|
|
||||||
echo "Qt frontend needs a display even in batch mode."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
./scripts/build-gamecube-iso.sh
|
|
||||||
|
|
||||||
DUSK_TEST_DOLPHIN_SECONDS="${DUSK_TEST_DOLPHIN_SECONDS:-20}"
|
|
||||||
ISO="build-gamecube-iso/Dusk-NTSC-U.iso"
|
|
||||||
|
|
||||||
echo "Booting $ISO in Dolphin for up to ${DUSK_TEST_DOLPHIN_SECONDS}s (batch mode, headless via Xvfb)..."
|
|
||||||
|
|
||||||
# Dolphin's batch mode (-b -e) runs the disc until told to stop -- there's
|
|
||||||
# no "the game exited cleanly" signal to wait for, so we bound it with
|
|
||||||
# timeout and treat "still running when the clock ran out" as success.
|
|
||||||
set +e
|
|
||||||
xvfb-run -a timeout "${DUSK_TEST_DOLPHIN_SECONDS}" "$DOLPHIN_BIN" -b -e "$ISO"
|
|
||||||
status=$?
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# timeout returns 124 when it had to kill Dolphin after the duration
|
|
||||||
# elapsed -- that means the disc booted and kept running, the expected
|
|
||||||
# smoke-test-passed outcome, not a failure. Any other non-zero status
|
|
||||||
# means Dolphin crashed or refused to boot the disc.
|
|
||||||
if [ "$status" -ne 0 ] && [ "$status" -ne 124 ]; then
|
|
||||||
echo "Dolphin exited with unexpected status $status -- treating as a failure."
|
|
||||||
exit "$status"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "GameCube smoke test passed (Dolphin ran $ISO for ${DUSK_TEST_DOLPHIN_SECONDS}s without crashing)."
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-linux -f docker/linux/Dockerfile .
|
|
||||||
docker run \
|
|
||||||
--rm \
|
|
||||||
-v "${GITHUB_WORKSPACE}:/workdir" \
|
|
||||||
dusk-linux \
|
|
||||||
/bin/bash -c "./scripts/test-linux.sh"
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
rm -rf build-tests
|
|
||||||
cmake -S . -B build-tests -DDUSK_BUILD_TESTS=ON -DDUSK_TARGET_SYSTEM=linux
|
|
||||||
cmake --build build-tests -- -j$(nproc)
|
|
||||||
ctest --output-on-failure --test-dir build-tests
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-psp-test -f docker/psp-test/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-psp-test /bin/bash -c "./scripts/test-psp-ppsspp.sh"
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -z "$PSPDEV" ]; then
|
|
||||||
echo "PSPDEV environment variable is not set. Please set it to the path of your PSP development environment."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# PPSSPP doesn't ship a standard Linux package -- build its "PPSSPPHeadless"
|
|
||||||
# target from source (https://github.com/hrydgard/ppsspp) and either put it
|
|
||||||
# on PATH or point PPSSPP_HEADLESS_BIN at it. See docker/psp-test/Dockerfile
|
|
||||||
# for a from-scratch build.
|
|
||||||
PPSSPP_HEADLESS_BIN="${PPSSPP_HEADLESS_BIN:-PPSSPPHeadless}"
|
|
||||||
if ! command -v "$PPSSPP_HEADLESS_BIN" >/dev/null 2>&1; then
|
|
||||||
echo "$PPSSPP_HEADLESS_BIN not found. Build PPSSPP's 'PPSSPPHeadless' target"
|
|
||||||
echo "from source or set PPSSPP_HEADLESS_BIN to its path."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
./scripts/build-psp.sh
|
|
||||||
|
|
||||||
DUSK_TEST_PPSSPP_SECONDS="${DUSK_TEST_PPSSPP_SECONDS:-20}"
|
|
||||||
EBOOT="build-psp/EBOOT.PBP"
|
|
||||||
|
|
||||||
echo "Booting $EBOOT in PPSSPPHeadless (timeout ${DUSK_TEST_PPSSPP_SECONDS}s)..."
|
|
||||||
|
|
||||||
# PPSSPPHeadless is purpose-built for automated/CI runs -- it renders
|
|
||||||
# without a window and is expected to exit on its own once --timeout
|
|
||||||
# elapses, unlike Dolphin's batch mode which has to be killed externally.
|
|
||||||
# Check `"$PPSSPP_HEADLESS_BIN" --help` if these flags don't match your
|
|
||||||
# PPSSPP checkout -- the headless CLI has changed across versions.
|
|
||||||
set +e
|
|
||||||
"$PPSSPP_HEADLESS_BIN" --timeout="${DUSK_TEST_PPSSPP_SECONDS}" "$EBOOT"
|
|
||||||
status=$?
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ "$status" -ne 0 ]; then
|
|
||||||
echo "PPSSPPHeadless exited with status $status"
|
|
||||||
exit "$status"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "PSP smoke test passed (PPSSPPHeadless ran EBOOT.PBP for ${DUSK_TEST_PPSSPP_SECONDS}s without crashing)."
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
docker build -t dusk-dolphin-test -f docker/dolphin-test/Dockerfile .
|
|
||||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin-test /bin/bash -c "./scripts/test-wii-dolphin.sh"
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -z "$DEVKITPRO" ]; then
|
|
||||||
echo "DEVKITPRO environment variable is not set. Please set it to the path of your DEVKITPRO installation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
DOLPHIN_BIN="${DOLPHIN_BIN:-dolphin-emu}"
|
|
||||||
if ! command -v "$DOLPHIN_BIN" >/dev/null 2>&1; then
|
|
||||||
echo "$DOLPHIN_BIN not found. Install Dolphin Emulator (e.g. 'apt install dolphin-emu')"
|
|
||||||
echo "or set DOLPHIN_BIN to its path."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if ! command -v xvfb-run >/dev/null 2>&1; then
|
|
||||||
echo "xvfb-run not found. Install it (e.g. 'apt install xvfb') -- Dolphin's"
|
|
||||||
echo "Qt frontend needs a display even in batch mode."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
./scripts/build-wii-iso.sh
|
|
||||||
|
|
||||||
DUSK_TEST_DOLPHIN_SECONDS="${DUSK_TEST_DOLPHIN_SECONDS:-20}"
|
|
||||||
ISO="build-wii-iso/Dusk-NTSC-U.iso"
|
|
||||||
|
|
||||||
echo "Booting $ISO in Dolphin for up to ${DUSK_TEST_DOLPHIN_SECONDS}s (batch mode, headless via Xvfb)..."
|
|
||||||
|
|
||||||
# Dolphin's batch mode (-b -e) runs the disc until told to stop -- there's
|
|
||||||
# no "the game exited cleanly" signal to wait for, so we bound it with
|
|
||||||
# timeout and treat "still running when the clock ran out" as success.
|
|
||||||
set +e
|
|
||||||
xvfb-run -a timeout "${DUSK_TEST_DOLPHIN_SECONDS}" "$DOLPHIN_BIN" -b -e "$ISO"
|
|
||||||
status=$?
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# timeout returns 124 when it had to kill Dolphin after the duration
|
|
||||||
# elapsed -- that means the disc booted and kept running, the expected
|
|
||||||
# smoke-test-passed outcome, not a failure. Any other non-zero status
|
|
||||||
# means Dolphin crashed or refused to boot the disc.
|
|
||||||
if [ "$status" -ne 0 ] && [ "$status" -ne 124 ]; then
|
|
||||||
echo "Dolphin exited with unexpected status $status -- treating as a failure."
|
|
||||||
exit "$status"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Wii smoke test passed (Dolphin ran $ISO for ${DUSK_TEST_DOLPHIN_SECONDS}s without crashing)."
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
add_subdirectory(dusk)
|
|
||||||
if(DUSK_NETWORKING)
|
|
||||||
add_subdirectory(dusknetwork)
|
|
||||||
endif()
|
|
||||||
add_subdirectory(duskrpg)
|
|
||||||
|
|
||||||
if(DUSK_TARGET_SYSTEM STREQUAL "linux" OR DUSK_TARGET_SYSTEM STREQUAL "knulli")
|
|
||||||
add_subdirectory(dusklinux)
|
|
||||||
add_subdirectory(dusksdl2)
|
|
||||||
add_subdirectory(duskgl)
|
|
||||||
|
|
||||||
elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
|
||||||
add_subdirectory(duskpsp)
|
|
||||||
add_subdirectory(dusksdl2)
|
|
||||||
add_subdirectory(duskgl)
|
|
||||||
|
|
||||||
elseif(DUSK_TARGET_SYSTEM STREQUAL "wii" OR DUSK_TARGET_SYSTEM STREQUAL "gamecube")
|
|
||||||
add_subdirectory(duskdolphin)
|
|
||||||
|
|
||||||
endif()
|
|
||||||
+9
-72
@@ -1,85 +1,22 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
# Copyright (c) 2026 Dominic Masters
|
||||||
#
|
#
|
||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Required Libraries
|
# Headers are included relative to this directory (e.g. "util/string.h").
|
||||||
if(NOT cglm_FOUND)
|
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
find_package(cglm REQUIRED)
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC cglm)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT libzip_FOUND)
|
|
||||||
find_package(libzip REQUIRED)
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC zip)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT stb_image_FOUND)
|
|
||||||
find_package(stb REQUIRED)
|
|
||||||
if(STB_IMAGE_FOUND)
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC stb_image)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "stb_image not found. Please ensure stb is correctly fetched.")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT yyjson_FOUND)
|
|
||||||
find_package(yyjson REQUIRED)
|
|
||||||
if(yyjson_FOUND)
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC yyjson::yyjson)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "yyjson not found. Please ensure yyjson is correctly fetched.")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT jerryscript_FOUND)
|
|
||||||
find_package(jerryscript REQUIRED)
|
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
||||||
jerryscript::core
|
|
||||||
jerryscript::ext
|
|
||||||
jerryscript::port
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DUSK_BACKTRACE)
|
|
||||||
target_link_options(${DUSK_LIBRARY_TARGET_NAME} PUBLIC -rdynamic)
|
|
||||||
target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
|
||||||
DUSK_BACKTRACE
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Includes
|
|
||||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME}
|
|
||||||
PUBLIC
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Main Binary Source
|
# Modules
|
||||||
target_sources(${DUSK_BINARY_TARGET_NAME}
|
|
||||||
PUBLIC
|
|
||||||
main.c
|
|
||||||
)
|
|
||||||
|
|
||||||
# Subdirs
|
|
||||||
add_subdirectory(animation)
|
|
||||||
add_subdirectory(event)
|
|
||||||
add_subdirectory(assert)
|
|
||||||
add_subdirectory(asset)
|
add_subdirectory(asset)
|
||||||
|
add_subdirectory(assert)
|
||||||
add_subdirectory(console)
|
add_subdirectory(console)
|
||||||
add_subdirectory(display)
|
add_subdirectory(display)
|
||||||
add_subdirectory(entity)
|
|
||||||
add_subdirectory(log)
|
|
||||||
add_subdirectory(engine)
|
add_subdirectory(engine)
|
||||||
add_subdirectory(error)
|
add_subdirectory(error)
|
||||||
add_subdirectory(game)
|
add_subdirectory(perf)
|
||||||
add_subdirectory(input)
|
add_subdirectory(resource)
|
||||||
add_subdirectory(locale)
|
|
||||||
add_subdirectory(scene)
|
|
||||||
add_subdirectory(system)
|
|
||||||
add_subdirectory(time)
|
add_subdirectory(time)
|
||||||
add_subdirectory(ui)
|
add_subdirectory(thread)
|
||||||
add_subdirectory(physics)
|
|
||||||
add_subdirectory(save)
|
|
||||||
add_subdirectory(script)
|
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
add_subdirectory(thread)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
|
||||||
PUBLIC
|
|
||||||
easing.c
|
|
||||||
keyframe.c
|
|
||||||
keyframeset.c
|
|
||||||
animation.c
|
|
||||||
)
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
#include "animation.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "util/math.h"
|
|
||||||
#include "time/time.h"
|
|
||||||
|
|
||||||
void animationInit(
|
|
||||||
animation_t *anim,
|
|
||||||
keyframe_t **tracks,
|
|
||||||
uint16_t *trackCounts,
|
|
||||||
uint16_t trackCount
|
|
||||||
) {
|
|
||||||
assertNotNull(anim, "Animation pointer cannot be null.");
|
|
||||||
|
|
||||||
keyframeSetInit(
|
|
||||||
&anim->keyframes, tracks, trackCounts, NULL, NULL, trackCount, NULL
|
|
||||||
);
|
|
||||||
anim->time = 0.0f;
|
|
||||||
anim->speed = 1.0f;
|
|
||||||
anim->loop = false;
|
|
||||||
anim->playing = false;
|
|
||||||
anim->eventTime = 0.0f;
|
|
||||||
anim->eventCallback = NULL;
|
|
||||||
anim->eventUser = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void animationUpdate(animation_t *anim) {
|
|
||||||
assertNotNull(anim, "Animation pointer cannot be null.");
|
|
||||||
if(!anim->playing) return;
|
|
||||||
|
|
||||||
float_t duration = keyframeSetGetDuration(&anim->keyframes);
|
|
||||||
float_t prevTime = anim->time;
|
|
||||||
anim->time += TIME.delta * anim->speed;
|
|
||||||
|
|
||||||
// Loops that overshoot duration wrap back into [0, duration) -- an event
|
|
||||||
// near the end must still be checked across that wrap, as two segments:
|
|
||||||
// (prevTime, duration] then [0, newTime].
|
|
||||||
bool_t wrapped = anim->loop && duration > 0.0f && anim->time >= duration;
|
|
||||||
|
|
||||||
if(anim->loop) {
|
|
||||||
if(duration > 0.0f) anim->time = mathModFloat(anim->time, duration);
|
|
||||||
} else if(anim->time >= duration) {
|
|
||||||
anim->time = duration;
|
|
||||||
anim->playing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!anim->eventCallback) return;
|
|
||||||
|
|
||||||
bool_t crossed = wrapped
|
|
||||||
? (prevTime < anim->eventTime || anim->time >= anim->eventTime)
|
|
||||||
: (prevTime < anim->eventTime && anim->time >= anim->eventTime);
|
|
||||||
if(crossed) anim->eventCallback(anim, anim->eventUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
void animationSetEvent(
|
|
||||||
animation_t *anim,
|
|
||||||
const float_t time,
|
|
||||||
const animationeventcallback_t callback,
|
|
||||||
void *user
|
|
||||||
) {
|
|
||||||
assertNotNull(anim, "Animation pointer cannot be null.");
|
|
||||||
anim->eventTime = time;
|
|
||||||
anim->eventCallback = callback;
|
|
||||||
anim->eventUser = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t animationGetValue(animation_t *anim, const uint16_t trackIndex) {
|
|
||||||
assertNotNull(anim, "Animation pointer cannot be null.");
|
|
||||||
return keyframeSetGetValue(&anim->keyframes, trackIndex, anim->time);
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "keyframeset.h"
|
|
||||||
|
|
||||||
typedef struct animation_t animation_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback fired once when animationUpdate() advances time past
|
|
||||||
* eventTime (see animationSetEvent()).
|
|
||||||
*
|
|
||||||
* @param anim The animation whose event fired.
|
|
||||||
* @param user The user pointer passed to animationSetEvent().
|
|
||||||
*/
|
|
||||||
typedef void (*animationeventcallback_t)(animation_t *anim, void *user);
|
|
||||||
|
|
||||||
typedef struct animation_t {
|
|
||||||
/** The animation's tracks/channels and their raw keyframe data. */
|
|
||||||
keyframeset_t keyframes;
|
|
||||||
|
|
||||||
/** Current playback position, in seconds. */
|
|
||||||
float_t time;
|
|
||||||
|
|
||||||
/** Playback rate multiplier; 1.0 = normal speed. */
|
|
||||||
float_t speed;
|
|
||||||
|
|
||||||
/** True if animationUpdate() should wrap time back to 0 on reaching the
|
|
||||||
* final keyframe, rather than holding there and clearing playing. */
|
|
||||||
bool_t loop;
|
|
||||||
|
|
||||||
/** True while animationUpdate() should advance time each call. */
|
|
||||||
bool_t playing;
|
|
||||||
|
|
||||||
/** Time (seconds) at which eventCallback fires; see animationSetEvent(). */
|
|
||||||
float_t eventTime;
|
|
||||||
/** Callback fired once when time advances past eventTime, or NULL. */
|
|
||||||
animationeventcallback_t eventCallback;
|
|
||||||
/** User pointer passed to eventCallback unchanged. */
|
|
||||||
void *eventUser;
|
|
||||||
} animation_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes an animation: time 0, speed 1.0, not looping, not playing.
|
|
||||||
* See keyframeSetInit() -- tracks/trackCounts and the keyframe_t arrays
|
|
||||||
* they point to are not copied, and must outlive this animation.
|
|
||||||
*
|
|
||||||
* @param anim The animation to initialize.
|
|
||||||
* @param tracks Array of trackCount keyframe_t arrays.
|
|
||||||
* @param trackCounts Array of trackCount keyframe counts, matching tracks.
|
|
||||||
* @param trackCount The number of tracks/channels in this animation.
|
|
||||||
*/
|
|
||||||
void animationInit(
|
|
||||||
animation_t *anim,
|
|
||||||
keyframe_t **tracks,
|
|
||||||
uint16_t *trackCounts,
|
|
||||||
uint16_t trackCount
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Advances an animation's time by TIME.delta * speed. No-op if not
|
|
||||||
* playing. Duration is the latest of every track's final keyframe time
|
|
||||||
* (see keyframeSetGetDuration()). If loop is set, time wraps back into
|
|
||||||
* [0, duration) on reaching it; otherwise time is clamped there and
|
|
||||||
* playing is cleared.
|
|
||||||
*
|
|
||||||
* If eventCallback is set, it fires once when this call advances time
|
|
||||||
* from at or before eventTime to after it (checked across the loop wrap
|
|
||||||
* point too, so an event near the end of a looping animation still fires
|
|
||||||
* every loop).
|
|
||||||
*
|
|
||||||
* @param anim The animation to update.
|
|
||||||
*/
|
|
||||||
void animationUpdate(animation_t *anim);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets (or clears, with callback NULL) the single time-triggered event
|
|
||||||
* fired by animationUpdate().
|
|
||||||
*
|
|
||||||
* @param anim The animation to set the event on.
|
|
||||||
* @param time The time, in seconds, at which callback fires.
|
|
||||||
* @param callback The callback to invoke, or NULL to clear any event.
|
|
||||||
* @param user Arbitrary pointer forwarded to callback unchanged.
|
|
||||||
*/
|
|
||||||
void animationSetEvent(
|
|
||||||
animation_t *anim,
|
|
||||||
const float_t time,
|
|
||||||
const animationeventcallback_t callback,
|
|
||||||
void *user
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of one of the animation's tracks at its current
|
|
||||||
* playback time.
|
|
||||||
*
|
|
||||||
* @param anim The animation to get the value from.
|
|
||||||
* @param trackIndex The track to evaluate, in [0, trackCount).
|
|
||||||
* @return The interpolated value of that track at the current time.
|
|
||||||
*/
|
|
||||||
float_t animationGetValue(animation_t *anim, const uint16_t trackIndex);
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
#include "easing.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "util/math.h"
|
|
||||||
|
|
||||||
const easingfn_t EASING_FUNCTIONS[EASING_COUNT] = {
|
|
||||||
easingLinear,
|
|
||||||
easingInSine,
|
|
||||||
easingOutSine,
|
|
||||||
easingInOutSine,
|
|
||||||
easingInQuad,
|
|
||||||
easingOutQuad,
|
|
||||||
easingInOutQuad,
|
|
||||||
easingInCubic,
|
|
||||||
easingOutCubic,
|
|
||||||
easingInOutCubic,
|
|
||||||
easingInQuart,
|
|
||||||
easingOutQuart,
|
|
||||||
easingInOutQuart,
|
|
||||||
easingInBack,
|
|
||||||
easingOutBack,
|
|
||||||
easingInOutBack,
|
|
||||||
};
|
|
||||||
|
|
||||||
float_t easingApply(const easingtype_t type, const float_t t) {
|
|
||||||
assertTrue(type < EASING_COUNT, "Invalid easing type");
|
|
||||||
return EASING_FUNCTIONS[type](t);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingLinear(const float_t t) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInSine(const float_t t) {
|
|
||||||
return 1.0f - cosf(t * MATH_PI * 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingOutSine(const float_t t) {
|
|
||||||
return sinf(t * MATH_PI * 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInOutSine(const float_t t) {
|
|
||||||
return -(cosf(MATH_PI * t) - 1.0f) * 0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInQuad(const float_t t) {
|
|
||||||
return t * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingOutQuad(const float_t t) {
|
|
||||||
float_t u = 1.0f - t;
|
|
||||||
return 1.0f - u * u;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInOutQuad(const float_t t) {
|
|
||||||
if(t < 0.5f) return 2.0f * t * t;
|
|
||||||
float_t u = -2.0f * t + 2.0f;
|
|
||||||
return 1.0f - u * u * 0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInCubic(const float_t t) {
|
|
||||||
return t * t * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingOutCubic(const float_t t) {
|
|
||||||
float_t u = 1.0f - t;
|
|
||||||
return 1.0f - u * u * u;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInOutCubic(const float_t t) {
|
|
||||||
if(t < 0.5f) return 4.0f * t * t * t;
|
|
||||||
float_t u = -2.0f * t + 2.0f;
|
|
||||||
return 1.0f - u * u * u * 0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInQuart(const float_t t) {
|
|
||||||
return t * t * t * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingOutQuart(const float_t t) {
|
|
||||||
float_t u = 1.0f - t;
|
|
||||||
return 1.0f - u * u * u * u;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInOutQuart(const float_t t) {
|
|
||||||
if(t < 0.5f) return 8.0f * t * t * t * t;
|
|
||||||
float_t u = -2.0f * t + 2.0f;
|
|
||||||
return 1.0f - u * u * u * u * 0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInBack(const float_t t) {
|
|
||||||
return EASING_C3 * t * t * t - EASING_C1 * t * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingOutBack(const float_t t) {
|
|
||||||
float_t u = t - 1.0f;
|
|
||||||
return 1.0f + EASING_C3 * u * u * u + EASING_C1 * u * u;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t easingInOutBack(const float_t t) {
|
|
||||||
if(t < 0.5f) {
|
|
||||||
float_t u = 2.0f * t;
|
|
||||||
return u * u * ((EASING_C2 + 1.0f) * u - EASING_C2) * 0.5f;
|
|
||||||
}
|
|
||||||
float_t u = 2.0f * t - 2.0f;
|
|
||||||
return (u * u * ((EASING_C2 + 1.0f) * u + EASING_C2) + 2.0f) * 0.5f;
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dusk.h"
|
|
||||||
|
|
||||||
#define EASING_PI 3.14159265358979323846f
|
|
||||||
#define EASING_C1 1.70158f
|
|
||||||
#define EASING_C2 (EASING_C1 * 1.525f)
|
|
||||||
#define EASING_C3 (EASING_C1 + 1.0f)
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
EASING_LINEAR,
|
|
||||||
EASING_IN_SINE,
|
|
||||||
EASING_OUT_SINE,
|
|
||||||
EASING_IN_OUT_SINE,
|
|
||||||
EASING_IN_QUAD,
|
|
||||||
EASING_OUT_QUAD,
|
|
||||||
EASING_IN_OUT_QUAD,
|
|
||||||
EASING_IN_CUBIC,
|
|
||||||
EASING_OUT_CUBIC,
|
|
||||||
EASING_IN_OUT_CUBIC,
|
|
||||||
EASING_IN_QUART,
|
|
||||||
EASING_OUT_QUART,
|
|
||||||
EASING_IN_OUT_QUART,
|
|
||||||
EASING_IN_BACK,
|
|
||||||
EASING_OUT_BACK,
|
|
||||||
EASING_IN_OUT_BACK,
|
|
||||||
|
|
||||||
EASING_COUNT
|
|
||||||
} easingtype_t;
|
|
||||||
|
|
||||||
typedef float_t (*easingfn_t)(const float_t t);
|
|
||||||
|
|
||||||
extern const easingfn_t EASING_FUNCTIONS[EASING_COUNT];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies the specified easing function to t.
|
|
||||||
*
|
|
||||||
* @param type The easing type to apply.
|
|
||||||
* @param t The input time, in the range [0, 1].
|
|
||||||
* @return The eased value, in the range [0, 1].
|
|
||||||
*/
|
|
||||||
float_t easingApply(const easingtype_t type, const float_t t);
|
|
||||||
|
|
||||||
float_t easingLinear(const float_t t);
|
|
||||||
float_t easingInSine(const float_t t);
|
|
||||||
float_t easingOutSine(const float_t t);
|
|
||||||
float_t easingInOutSine(const float_t t);
|
|
||||||
float_t easingInQuad(const float_t t);
|
|
||||||
float_t easingOutQuad(const float_t t);
|
|
||||||
float_t easingInOutQuad(const float_t t);
|
|
||||||
float_t easingInCubic(const float_t t);
|
|
||||||
float_t easingOutCubic(const float_t t);
|
|
||||||
float_t easingInOutCubic(const float_t t);
|
|
||||||
float_t easingInQuart(const float_t t);
|
|
||||||
float_t easingOutQuart(const float_t t);
|
|
||||||
float_t easingInOutQuart(const float_t t);
|
|
||||||
float_t easingInBack(const float_t t);
|
|
||||||
float_t easingOutBack(const float_t t);
|
|
||||||
float_t easingInOutBack(const float_t t);
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
#include "keyframe.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "util/math.h"
|
|
||||||
|
|
||||||
float_t keyframeGetValue(
|
|
||||||
keyframe_t *keyframes,
|
|
||||||
const uint16_t keyframeCount,
|
|
||||||
const float_t time
|
|
||||||
) {
|
|
||||||
assertNotNull(keyframes, "Keyframes pointer cannot be null.");
|
|
||||||
assertTrue(keyframeCount > 0, "Keyframe count must be more than 0.");
|
|
||||||
assertTrue(time >= 0, "Time must be non-negative.");
|
|
||||||
|
|
||||||
keyframe_t *first = keyframes;
|
|
||||||
keyframe_t *last = keyframes + keyframeCount - 1;
|
|
||||||
|
|
||||||
// Clamp to the boundary keyframes' values directly rather than
|
|
||||||
// interpolating -- start == end at either boundary would otherwise
|
|
||||||
// divide by zero.
|
|
||||||
if(time <= first->time) return first->value;
|
|
||||||
if(time >= last->time) return last->value;
|
|
||||||
|
|
||||||
keyframe_t *start = first;
|
|
||||||
keyframe_t *end;
|
|
||||||
keyframe_t *current = first;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if(current->time > time) {
|
|
||||||
end = current;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
start = current;
|
|
||||||
current++;
|
|
||||||
} while(true);
|
|
||||||
|
|
||||||
float_t t = (time - start->time) / (end->time - start->time);
|
|
||||||
return mathLerp(start->value, end->value, easingApply(start->easing, t));
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// Copyright (c) 2026 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "easing.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
float_t time;
|
|
||||||
float_t value;
|
|
||||||
easingtype_t easing;
|
|
||||||
} keyframe_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the eased, interpolated value of a keyframe array at a given time.
|
|
||||||
*
|
|
||||||
* @param keyframes The keyframes to evaluate, ascending by time.
|
|
||||||
* @param keyframeCount The number of keyframes.
|
|
||||||
* @param time The time at which to get the value, in seconds.
|
|
||||||
* @return The interpolated value at the given time.
|
|
||||||
*/
|
|
||||||
float_t keyframeGetValue(
|
|
||||||
keyframe_t *keyframes,
|
|
||||||
const uint16_t keyframeCount,
|
|
||||||
const float_t time
|
|
||||||
);
|
|
||||||
Loaded 100 of 884 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user