X-Plane addon: Add X-World Europe

master
Michael Raitza 2022-10-09 17:40:33 +02:00
parent dc8c79519a
commit 64a92fe1b6
4 changed files with 112 additions and 4 deletions

View File

@ -9,7 +9,7 @@ let
xPlaneEnv = callPackage ./x-plane { xplanePathStr = "/home/games/xplane";
addons = [ headshake beautifulRoads samBasic samGlobalTrees flyWithLua vividSky airportEnvHD betterLights extendedNightLights toLissA321 ]; };
xPlane12Env = callPackage ./x-plane { xplanePathStr = "/home/games/xplane12"; name = "x-plane12-env";
addons = [ x-world-vegetation ]; };
addons = [ x-world-vegetation x-world-europe ]; };
xPlaneSDK = callPackage ./x-plane/sdk.nix {};
ortho4xp = callPackage ./x-plane/ortho4XPWrapper.nix { orthoPathStr = "/home/games/ortho4xp"; };
@ -29,6 +29,7 @@ let
# X-Plane 12
x-world-vegetation = callPackage ./x-plane/simHeaven/x-world-vegetation.nix {};
x-world-europe = callPackage ./x-plane/simHeaven/x-world-europe.nix {};
pdfchain = callPackage ./pdfchain { };
prism = callPackage ./prism.nix {};

View File

@ -1,9 +1,9 @@
{ stdenv, requireFile, unzip, p7zip }:
{ pname
, version
, fname
, sha256
, forumlink
, fname ? null
, sha256 ? null
, forumlink ? null
, passthru ? {}
, ... }@args:

View File

@ -0,0 +1,94 @@
{ stdenv
, lib
, mkXPlaneAddon
, impureSrcPath ? "/home/games/xplane-scenery/simHeaven_X-World_Europe"
# Disable to improve frame rate
, enableDetails ? true
# dito
, enableExtras ? true
# Replace scenery objects with null-objects that are covered by ortho scenery
, useOrtho ? true
# Replace default tiles for regions with poor OSM data quality (e.g. remote forests not showing)
# example: [ "+38+001" "+71-009" ]
, replaceTiles ? [ ]
}:
let
inherit (lib) concatStringsSep optional;
dirName = "simHeaven_X-World_Europe";
linkDirs = concatStringsSep " " ([
"${dirName}-0-exclusions"
"${dirName}-1-vfr"
"${dirName}-2-regions"
"${dirName}-5-footprints"
"${dirName}-6-scenery"
"${dirName}-7-forests"
"${dirName}-8-network" ]
++ optional enableDetails "${dirName}-3-details"
++ optional enableExtras "${dirName}-4-extras");
tiles = concatStringsSep " " replaceTiles;
in mkXPlaneAddon {
pname = "x-world-europe";
version = "1.1";
src = "";
buildCommand = ''
mkdir -p "$out"
touch "$out/installed"
'';
passthru = {
build = "";
prepare = ''
test -d "${impureSrcPath}"
for f in ${linkDirs} ; do
mkdir "$XPLANEPATH/Custom Scenery/$f"
for j in "${impureSrcPath}/$f"/* ; do
ln -s "$j" "$XPLANEPATH/Custom Scenery/$f/$(basename "$j")"
done
done
if [ "${toString useOrtho}" = 1 ]; then
f="$XPLANEPATH/Custom Scenery/${dirName}-6-scenery/library.txt"
rm "$f"
ln -s "${impureSrcPath}/${dirName}-6-scenery/library - orthos.txt" "$f"
fi
# In case we want to replace some tiles, link every tile indivdually
if [ -n "${tiles}" ]; then
rm "$XPLANEPATH/Custom Scenery/${dirName}-7-forests/Earth nav data"
for f in "${impureSrcPath}/${dirName}-7-forests/Earth nav data"/* ; do
mkdir -p "$XPLANEPATH/Custom Scenery/${dirName}-7-forests/Earth nav data/$(basename "$f")"
for k in "$f"/* ; do
ln -s "$k" "$XPLANEPATH/Custom Scenery/${dirName}-7-forests/Earth nav data/$(basename "$f")"
done
done
for f in ${tiles} ; do
# bash-ism, transform +HH+LLL -> +H0+LL0
d=''${f:0:2}0''${f:3:3}0
s="${impureSrcPath}/${dirName}-7-forests/Earth nav data - osm+autogen/$d/$f.dsf"
t="$XPLANEPATH/Custom Scenery/${dirName}-7-forests/Earth nav data/$d/$f.dsf"
if [ -e "$s" ]; then
rm "$t"
ln -s "$s" "$t"
else
printf "Warning: Replacement tile not found %s\n" "$f" >&2
fi
done
fi
# Update scenery_packs.ini
(
cd "$XPLANEPATH"
k=
sed -i -e '/^SCENERY_PACK Custom Scenery\/${dirName}-.*$/d' 'Custom Scenery/scenery_packs.ini'
sed -i -e "/^SCENERY_PACK Custom Scenery\/simHeaven_X-World_Vegetation_Library/i\
$(for f in ${linkDirs} ; do
printf "''${k}SCENERY_PACK Custom Scenery/%s/" "$f"
k='\\n'
done)" 'Custom Scenery/scenery_packs.ini'
)
'';
revert = ''
for f in ${linkDirs} ; do
rm -r "$XPLANEPATH/Custom Scenery/$f"
done
'';
};
}

View File

@ -28,6 +28,19 @@ mkXPlaneAddon {
ln -s "$f" "${addonPath}/$(basename "$f")"
done
ln -s "$XPLANEPATH/Resources/default scenery/1200 forests" "${addonPath}/1200 forests"
(
cd "$XPLANEPATH"
if grep -q -E 'Custom Scenery/yOrtho4XP_Overlays' 'Custom Scenery/scenery_packs.ini' ; then
sed -i -e '/^SCENERY_PACK Custom Scenery\/${dirName}\/$/d' 'Custom Scenery/scenery_packs.ini'
sed -i -e "/^SCENERY_PACK Custom Scenery\/yOrtho4XP_Overlays/i\
SCENERY_PACK Custom Scenery\/${dirName}/" 'Custom Scenery/scenery_packs.ini'
else
sed -i -e '/^SCENERY_PACK Custom Scenery\/${dirName}\/$/d' 'Custom Scenery/scenery_packs.ini'
sed -i -e '$a\
SCENERY_PACK Custom Scenery\/${dirName}/' 'Custom Scenery/scenery_packs.ini'
fi
)
'';
revert = ''
if [ -d "${addonPath}" ]; then