From 66ddae3556371045332884440d7a1a0ad0a70c9c Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Sep 2018 18:26:39 +0200 Subject: games/humblebundle: Add Trine 2 Had this lying around for a while already, so just adding for completeness. I've tested whether the game still works. Signed-off-by: aszlig --- pkgs/games/humblebundle/default.nix | 1 + pkgs/games/humblebundle/trine2.nix | 97 +++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 pkgs/games/humblebundle/trine2.nix (limited to 'pkgs/games/humblebundle') diff --git a/pkgs/games/humblebundle/default.nix b/pkgs/games/humblebundle/default.nix index 4a0792c4..77069bb7 100644 --- a/pkgs/games/humblebundle/default.nix +++ b/pkgs/games/humblebundle/default.nix @@ -31,6 +31,7 @@ let spaz = callPackage ./spaz.nix {}; starbound = callPackage ./starbound.nix {}; swordsandsoldiers = callPackage ./swordsandsoldiers.nix {}; + trine2 = callPackage_i686 ./trine2.nix {}; unepic = callPackage ./unepic.nix {}; }; in with lib; { diff --git a/pkgs/games/humblebundle/trine2.nix b/pkgs/games/humblebundle/trine2.nix new file mode 100644 index 00000000..a6cef22d --- /dev/null +++ b/pkgs/games/humblebundle/trine2.nix @@ -0,0 +1,97 @@ +{ buildGame, fetchHumbleBundle, makeWrapper, runCommandCC, writeText +, coreutils, openal, libvorbis, libGLU, SDL2, freetype, alsaLib +}: + +buildGame rec { + name = "trine2-${version}"; + version = "2.01"; + + src = fetchHumbleBundle { + machineName = "trine2complete_linux"; + suffix = "zip"; + md5 = "82049b65c1bce6841335935bc05139c8"; + }; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ openal libvorbis libGLU freetype alsaLib ]; + + patchPhase = '' + patchelf --replace-needed libSDL-1.3.so.0 libSDL.so \ + bin/trine2_linux_32bit + patchelf --replace-needed libPhysXLoader.so.1 libPhysXLoader.so \ + bin/trine2_linux_32bit + ''; + + getResolutionArgs = runCommandCC "get-resolution-args" { + buildInputs = [ SDL2 ]; + src = writeText "get-resolution-args.c" '' + #include + + int main(void) + { + int width = 0, height = 0; + SDL_DisplayMode current; + + SDL_Init(SDL_INIT_VIDEO); + + int displays = SDL_GetNumVideoDisplays(); + + for (int i = 0; i < displays; ++i) { + if (SDL_GetCurrentDisplayMode(i, ¤t) != 0) + goto err; + + if (current.w * current.h > width * height) { + width = current.w; + height = current.h; + } + } + + if (width == 0 && height == 0) + goto err; + + SDL_Quit(); + printf("-RenderingModule:DetectedFullscreenWidth=%d\n", width); + printf("-RenderingModule:DetectedFullscreenHeight=%d\n", height); + return EXIT_SUCCESS; + + err: + fputs("Unable to get current display mode.\n", stderr); + SDL_Quit(); + return EXIT_FAILURE; + } + ''; + } "gcc -Wall $(sdl2-config --cflags --libs) -o \"$out\" \"$src\""; + + installPhase = '' + for name in Cg CgGL PhysXCooking PhysXCore PhysXLoader; do + install -vD "lib/lib32/lib$name.so" "$out/libexec/trine2/lib$name.so" + done + + install -vD lib/lib32/libSDL-1.3.so.0 "$out/libexec/trine2/libSDL.so" + + mkdir -p "$out/share/trine2" + cp -rvt "$out/share/trine2" *.fbq trine2.png data + + install -vD bin/trine2_linux_32bit "$out/libexec/trine2/trine2" + + rtDataPath="\''${XDG_DATA_HOME:-\$HOME/.local/share}" + makeWrapper "$out/libexec/trine2/trine2" "$out/bin/trine2" \ + --run "cd '$out/share/trine2'" \ + --run '${coreutils}/bin/ln -s "'"$rtDataPath"'" "$HOME/.frozenbyte"' \ + --prefix LD_LIBRARY_PATH : "$out/libexec/trine2" \ + --add-flags "\$($getResolutionArgs)" + + mkdir -p "$out/share/applications" + cat > "$out/share/applications/trine2.desktop" <