diff --git a/.gitignore b/.gitignore index ad60210d..12e51b61 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ _PackageInt .rollup.cache tsconfig.tsbuildinfo .vs -examples/aircraft/NavigationDataInterfaceAircraftProject.xml.user +example/aircraft/NavigationDataInterfaceAircraftProject.xml.user example/aircraft/PackageSources/html_ui/Pages/VCockpit/Instruments/Navigraph/NavigationDataInterfaceSample example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel/msfs_navigation_data_interface.wasm diff --git a/Dockerfile b/Dockerfile index 2e5578fe..1c938211 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,9 +22,8 @@ RUN cargo install --git https://github.com/navigraph/cargo-msfs # Cache bust arg to re-install both SDKs ARG CACHEBUST -# Install MSFS2020 and MSFS2024 SDK -RUN cargo-msfs install msfs2020 && \ - cargo-msfs install msfs2024 +# Install MSFS2020 SDK +RUN cargo-msfs install msfs2020 # Needed when running in CI/CD to avoid dubious ownership errors RUN git config --global --add safe.directory /workspace \ No newline at end of file diff --git a/README.md b/README.md index c8fae148..7d14bd0b 100644 --- a/README.md +++ b/README.md @@ -67,28 +67,40 @@ The navigation data interface will automatically use this database by default, m The default location for navigation data is `work/NavigationData`. -## Building the Sample Aircraft (MSFS2020) +## Building the Sample Aircraft > [!NOTE] -> This project is only meant to be tested in MSFS2020. We will add an example for MSFS2024 in the future. +> This project is meant to work in MSFS2020 and MSFS2024. > [!IMPORTANT] > Before building, make sure you have properly created and set an `.env` file in `example/gauge`! An example can be found in the `.env.example` file in that directory. Replace with your credentials. -1. Download and install [Bun](https://bun.sh/docs/installation) -2. Open this repository in a terminal -3. Run `bun i` the first time you build, in order to install dependencies -4. Change directory to [`example/gauge`](example/gauge/) using `cd example/gauge` -5. Run `bun run build` to build into the `PackageSources` folder of the aircraft sample (or `bun run dev` to build into the `Packages` folder of the aircraft and listen to changes in the source). -6. Make sure the WASM module is included in the [`panel`](example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel) folder! Look at either [Including in Your Aircraft](#including-in-your-aircraft) or [Building the WASM Module Yourself](#building-the-wasm-module-yourself) instructions -7. Open the `example/aircraft/NavigationDataInterfaceAircraftProject.xml` file in the simulator and build there +> [!IMPORTANT] +> Create a `.env` file in the root of this repository, containing a `SENTRY_URL` variable. Provide your own DSN, or leave it empty. + +1. Download and install [Bun](https://bun.sh/docs/installation). +2. Open this repository in a terminal. +3. Run `bun i` the first time you build, in order to install dependencies. +5. Run `bun run build:example`. This command will [build](#building-the-wasm-module-yourself) the wasm module, [build](#building-the-gauge-yourself) the gauge and [copy](#building-the-wasm-module-yourself) the module to the aircraft `panel` folder. +7. Open the `example/aircraft/NavigationDataInterfaceAircraftProject.xml` file in the simulator and build the package. ## Building the WASM Module Yourself -1. Create a `.env` file in the root of this repository, containing a `SENTRY_URL` variable. Provide your own DSN, or leave it empty. -2. Run `bun run build:wasm` at the root of the repository (requires Docker) - - This will take a while to download and build the first time, but subsequent runs will be quicker -3. The compiled WASM module will be copied to `dist/wasm`. There will be two folders - `2020` and `2024`, for each sim version +> [!IMPORTANT] +> Create a `.env` file in the root of this repository, containing a `SENTRY_URL` variable. Provide your own DSN, or leave it empty. + +1. Run `bun run build:wasm` at the root of the repository (requires Docker) + - This will take a while to download and build the first time, but subsequent runs will be quicker. + - The WASM module will be compatible for MSFS 2020 & 2024. +2. Run `bun run copy:wasm` command to copy the wasm module or do it manually by copying the wasm module in the aircraft `panel` folder. + +## Building the Gauge Yourself + +> [!IMPORTANT] +> Before building, make sure you have properly created and set an `.env` file in `example/gauge`! An example can be found in the `.env.example` file in that directory. Replace with your credentials. + +1. Change directory to [`example/gauge`](example/gauge/) using `cd example/gauge` +2. Run `bun run build` to build into the `PackageSources` folder of the aircraft sample (or `bun run dev` to build into the `Packages` folder of the aircraft and listen to changes in the source). ## Interfacing with the gauge manually diff --git a/example/aircraft/PackageDefinitions/navigraph-aircraft-navigation-data-interface-sample.xml b/example/aircraft/PackageDefinitions/navigraph-aircraft-navigation-data-interface-sample.xml index 3782bff0..f1cb5f5f 100644 --- a/example/aircraft/PackageDefinitions/navigraph-aircraft-navigation-data-interface-sample.xml +++ b/example/aircraft/PackageDefinitions/navigraph-aircraft-navigation-data-interface-sample.xml @@ -10,9 +10,10 @@ true true + CUSTOM_SIMOBJECTS - Copy + Copy false @@ -20,7 +21,7 @@ ContentInfo\navigraph-aircraft-navigation-data-interface-sample\ - Copy + Copy false @@ -28,7 +29,7 @@ Data\ - Copy + Copy false @@ -36,7 +37,7 @@ Navigraph\ - SimObject + SimObject false @@ -44,7 +45,7 @@ SimObjects\Airplanes\Navigraph_Navigation_Data_Interface_Aircraft\ - Copy + Copy false @@ -53,3 +54,4 @@ + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/model/GaugeAircraft_Interior.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/model/GaugeAircraft_Interior.xml index 18b5799e..9b109fde 100644 --- a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/model/GaugeAircraft_Interior.xml +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/model/GaugeAircraft_Interior.xml @@ -13,5 +13,15 @@ + + + + + + SCREEN + 1 + + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.01/GaugeAircraft_FUSELAGE_albd_000.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.01/GaugeAircraft_FUSELAGE_albd_000.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.01/GaugeAircraft_FUSELAGE_albd_000.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.01/GaugeAircraft_WINGS_albd_000.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.01/GaugeAircraft_WINGS_albd_000.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.01/GaugeAircraft_WINGS_albd_000.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.02/GaugeAircraft_FUSELAGE_albd_000.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.02/GaugeAircraft_FUSELAGE_albd_000.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.02/GaugeAircraft_FUSELAGE_albd_000.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.02/GaugeAircraft_WINGS_albd_000.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.02/GaugeAircraft_WINGS_albd_000.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.02/GaugeAircraft_WINGS_albd_000.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_ARMS_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_CAP_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_EYES_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HAIRCARDS_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEADSET_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_HEAD_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_JACKET_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture.base/Pilot_PANTS_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_COCKPIT_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_albd_000.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_albd_000.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_albd_000.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_FUSELAGE_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_GLASS_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_GLASS_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_GLASS_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LANDING_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_emis.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_emis.png.xml new file mode 100644 index 00000000..65076868 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_emis.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_EMISSIVE + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_LIGHTS_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_albd.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_albd.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_albd.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_PROP_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_albd_000.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_albd_000.png.xml new file mode 100644 index 00000000..3e95c043 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_albd_000.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_DECAL0 + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_comp.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_comp.png.xml new file mode 100644 index 00000000..11386931 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_comp.png.xml @@ -0,0 +1,5 @@ + + MTL_BITMAP_METAL_ROUGH_AO + true + + diff --git a/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_norm.png.xml b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_norm.png.xml new file mode 100644 index 00000000..1416d9d5 --- /dev/null +++ b/example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/texture/GaugeAircraft_WINGS_norm.png.xml @@ -0,0 +1,4 @@ + + MTL_BITMAP_NORMAL + + diff --git a/package.json b/package.json index c71f2cd2..e106e801 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ "lint": "bun run --filter \"*\" lint", "typecheck": "bun run --filter \"*\" typecheck", "build:wasm": "bun ./scripts/cargo-msfs.ts", - "build:wasm:2020": "bun ./scripts/cargo-msfs.ts --version 2020", - "build:wasm:2024": "bun ./scripts/cargo-msfs.ts --version 2024", + "build:gauge": "bun --cwd=\"./example/gauge\" run build", + "copy:wasm": "bun run ./scripts/copy-wasm-module.ts", + "build:example": "bun run build:wasm && bun run build:gauge && bun run copy:wasm", "package": "bestzip wasm.zip dist/wasm/*" }, "devDependencies": { diff --git a/scripts/cargo-msfs.ts b/scripts/cargo-msfs.ts index d196efac..25ebafab 100644 --- a/scripts/cargo-msfs.ts +++ b/scripts/cargo-msfs.ts @@ -1,11 +1,10 @@ import { $ } from "bun"; import { existsSync, mkdirSync, readFileSync, rmdirSync } from "node:fs"; import { dirname, join, normalize, resolve } from "node:path"; -import { parseArgs } from "util"; /// The type returned from the `cargo-msfs info -f` command interface InstalledSdkVersions { - versions: { sim: "Msfs2020" | "Msfs2024"; up_to_date: boolean; installed?: string; latest: string }[]; + versions: { sim: "Msfs2020"; up_to_date: boolean; installed?: string; latest: string }[]; } /// The docker image name @@ -37,23 +36,6 @@ function findWorkspaceRoot() { return null; } -// Determine which version(s) to build based on command line argument --version -const allowedVersions = ["2020", "2024"]; - -const { values } = parseArgs({ - args: Bun.argv, - options: { version: { type: "string" } }, - strict: true, - allowPositionals: true, -}); - -if (values.version && !allowedVersions.includes(values.version)) { - console.error(`Invalid version argument: ${values.version}. Allowed values are ${allowedVersions.join(", ")}`); - process.exit(1); -} - -const versionsToBuild = values.version ? [values.version] : allowedVersions; - // Get workspace root for docker commands const workspaceRoot = findWorkspaceRoot(); if (!workspaceRoot) { @@ -85,36 +67,30 @@ if (installedSdks.versions.some(v => !v.up_to_date)) { // Clear out dir const outDir = resolve(workspaceRoot, "dist/wasm"); + if (existsSync(outDir)) rmdirSync(outDir, { recursive: true }); // The work directory, relative to workspace root const relativeWorkdDir = process.cwd().replace(workspaceRoot, "").replaceAll("\\", "/"); -// Build the selected versions -await Promise.all( - versionsToBuild.map(async simVersion => { - console.info(`[*] Building for ${simVersion}`); - - // Create the subfolder - const simDir = join(outDir, simVersion); - const relativeSimDir = simDir.replace(workspaceRoot, "").replaceAll("\\", "/"); - mkdirSync(simDir, { recursive: true }); - - const color = simVersion === "2020" ? "\x1b[34m" : "\x1b[32m"; - - // Run cargo-msfs - await $`docker run \ - --rm -t \ - --name msfs-${simVersion}-wasm-builder \ - -v ${workspaceRoot}:/workspace \ - -w /workspace${relativeWorkdDir} \ - -e CARGO_TARGET_DIR=/workspace/targets/${simVersion} \ - ${IMAGE_NAME} \ - bash -c "cargo-msfs build msfs${simVersion} -i ./src/wasm -o ./${relativeSimDir}/msfs_navigation_data_interface.wasm \ - 1> >(sed \"s/^/[${color}${simVersion}\\x1b[0m]/\") \ - 2> >(sed \"s/^/[${color}${simVersion}\\x1b[0m]/\" >&2)"`.catch((err: { exitCode?: number; stderr?: Buffer }) => { - console.error(`[-] Error building for ${simVersion}: ${err.exitCode} ${err.stderr?.toString()}`); - process.exit(1); - }); - }), -); +console.info(`[*] Building for 2020`); + +// Create the subfolder +const simDir = join(outDir, "2020"); +const relativeSimDir = simDir.replace(workspaceRoot, "").replaceAll("\\", "/"); +mkdirSync(simDir, { recursive: true }); + +// Run cargo-msfs +await $`docker run \ + --rm -t \ + --name msfs-2020-wasm-builder \ + -v ${workspaceRoot}:/workspace \ + -w /workspace${relativeWorkdDir} \ + -e CARGO_TARGET_DIR=/workspace/targets/2020 \ + ${IMAGE_NAME} \ + bash -c "cargo-msfs build msfs2020 -i ./src/wasm -o ./${relativeSimDir}/msfs_navigation_data_interface.wasm \ +1> >(sed \"s/^/[\x1b[34m2020\\x1b[0m]/\") \ +2> >(sed \"s/^/[\x1b[34m2020\\x1b[0m]/\" >&2)"`.catch((err: { exitCode?: number; stderr?: Buffer }) => { + console.error(`[-] Error building for 2020: ${err.exitCode} ${err.stderr?.toString()}`); + process.exit(1); +}); diff --git a/scripts/copy-wasm-module.ts b/scripts/copy-wasm-module.ts new file mode 100644 index 00000000..ba82a5b9 --- /dev/null +++ b/scripts/copy-wasm-module.ts @@ -0,0 +1,3 @@ +import { $ } from "bun"; + +await $`cp dist/wasm/2020/msfs_navigation_data_interface.wasm example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel/msfs_navigation_data_interface.wasm`;