Add apotris

This commit is contained in:
Artemis Tosini 2024-06-06 01:20:58 +00:00
parent 4ff4e7b859
commit 4dc6a6a61a
Signed by: artemist
GPG key ID: ADFFE553DCBB831E
3 changed files with 131 additions and 0 deletions

View file

@ -54,6 +54,7 @@
) )
// { // {
overlays.default = final: prev: { overlays.default = final: prev: {
apotris = final.callPackage ./packages/apotris { };
attic = final.callPackage ./packages/attic { }; attic = final.callPackage ./packages/attic { };
attic-client = final.attic.override { clientOnly = true; }; attic-client = final.attic.override { clientOnly = true; };
cups-dymo-patched = final.callPackage ./packages/cups-dymo { }; cups-dymo-patched = final.callPackage ./packages/cups-dymo { };

View file

@ -0,0 +1,78 @@
{
lib,
stdenv,
fetchFromGitea,
cmake,
meson,
ninja,
pkg-config,
python3,
xxd,
SDL2,
SDL2_mixer,
libX11,
libXScrnSaver,
libXcursor,
libXext,
libXfixes,
libXi,
libXrandr,
libogg,
libopus,
zlib,
}:
stdenv.mkDerivation rec {
pname = "apotris";
version = "4.0.2";
src = fetchFromGitea {
domain = "gitea.com";
owner = "akouzoukos";
repo = pname;
fetchSubmodules = true;
rev = "v${version}";
hash = "sha256-w9uv7A1UIn82ORyyvT8dxWHUK9chVfJ191bnI53sANU=";
};
patches = [ ./paths.patch ];
nativeBuildInputs = [
meson
cmake
ninja
pkg-config
python3
xxd
];
buildInputs = [
SDL2
SDL2_mixer
libX11
libXScrnSaver
libXcursor
libXext
libXfixes
libXi
libXrandr
libogg
libopus
zlib
];
postPatch = ''
patchShebangs --build tools
substituteAllInPlace source/liba_window.cpp
'';
meta = with lib; {
description = "Multiplatform open-source block stacking game";
mainProgram = "Apotris";
homepage = "https://apotris.com";
license = licenses.agpl3Only;
maintainers = with maintainers; [ artemist ];
platforms = platforms.unix;
};
}

View file

@ -0,0 +1,52 @@
diff --git a/source/liba_window.cpp b/source/liba_window.cpp
index 5c05b92..b3dfacf 100644
--- a/source/liba_window.cpp
+++ b/source/liba_window.cpp
@@ -6,6 +6,7 @@
#include <iostream>
#include <dirent.h>
#include <cstdio>
+#include <cstdlib>
#include "def.h"
@@ -85,7 +86,7 @@ void windowInit(){
refreshWindowSize();
- loadAudio("");
+ loadAudio("@out@/");
nanotime_step_init(&stepper, (uint64_t) (NANOTIME_NSEC_PER_SEC / FPS_TARGET), nanotime_now_max(),nanotime_now,nanotime_sleep);
@@ -334,9 +335,20 @@ void toggleRendering(bool r){
void initRumble(){};
+static std::string savePath() {
+ char *home;
+ if((home = getenv("XDG_DATA_HOME")) != NULL) {
+ return std::string(home) + "/Apotris.sav";
+ }
+ if((home = getenv("HOME")) != NULL) {
+ return std::string(home) + "/.local/share/Apotris.sav";
+ }
+ return "Apotris.sav";
+}
+
void loadSavefile(){
- std::ifstream input("Apotris.sav",std::ios::binary | std::ios::in);
+ std::ifstream input(savePath(),std::ios::binary | std::ios::in);
if(savefile == nullptr)
savefile = new Save();
@@ -355,7 +367,7 @@ void loadSavefile(){
void saveSavefile(){
- std::ofstream output("Apotris.sav",std::ios::binary | std::ios::out);
+ std::ofstream output(savePath(),std::ios::binary | std::ios::out);
char * dst = (char * ) savefile;