ddm: 3.0.2 -> 4.0.0

- Game is now served as an asar file, and tries to make a directory for an image cache in the store
  - Unpack the asar file so we can patch code
  - Apply patch to generate image cache under ~/.cache/ddm/images,and read everything else from store
This commit is contained in:
OPNA2608
2025-03-16 20:04:34 +01:00
parent 6ff6446488
commit 7ee41dfbc5
2 changed files with 72 additions and 4 deletions
@@ -0,0 +1,58 @@
From 3b1bcc92389e8468cd3790dfd223cb653b5f753f Mon Sep 17 00:00:00 2001
From: OPNA2608 <opna2608@protonmail.com>
Date: Sun, 16 Mar 2025 19:56:39 +0100
Subject: [PATCH] Make findPath & its calls behave well with store
- images is a cache of downloaded card images.
put that into ~/.cache/ddm/images and allow it to be created.
- campaigns, cubes & constructed are user-downloaded files that set up possible game styles.
create & populate them for the game, and tell it to not try to create them on its own.
---
index.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/index.js b/index.js
index 738bfca..3ac32e8 100755
--- a/index.js
+++ b/index.js
@@ -75,16 +75,16 @@ app.on('ready', () => {
const isDir = fs.statSync(fullPath).isDirectory();
if (containsDanger(fullPath)) throw new Error ("Dangerous files detected");
if (isDir) return fullPath;
- } catch (err) { throw new Error("Bad path Error 1", err); }
+ } catch (err) { throw new Error(`Bad path Error 1: ${err.message}`, err); }
else try { //dev
- const fullPath = path.join(__dirname, folderName);
+ const fullPath = path.join(allowFolderCreation ? (process.env.HOME + "/.cache/ddm") : __dirname, folderName);
if (!fs.existsSync(fullPath) && allowFolderCreation) fs.mkdirSync(fullPath, {recursive: true});
const isDir = fs.statSync(fullPath).isDirectory();
console.log(fullPath)
if (containsDanger(fullPath)) throw new Error (`DDM refused entry to path: ${fullPath}`);
if (isDir) return fullPath;
- } catch (err) { throw new Error("Bad path Error 2", err); }
+ } catch (err) { throw new Error(`Bad path Error 2: ${err.message}`, err); }
}
@@ -108,7 +108,7 @@ app.on('ready', () => {
try {
if (!["campaigns", "cubes", "constructed"].includes(folderName)) throw new Error(`bad folder name ${folderName}`);
- const folderPath = findPath(folderName, true);
+ const folderPath = findPath(folderName, false);
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath);
const files = fs.readdirSync(folderPath);
if (folderName === "campaigns" ) return files.filter(file => fs.statSync (path.join(folderPath, file)).isDirectory());
@@ -127,7 +127,7 @@ app.on('ready', () => {
ipcMain.handle('open-local-folder', async (event, folderName) => {
if (!["campaigns", "cubes", "constructed"].includes(folderName)) throw new Error(`bad folder name ${constructed}`);
- const folderPath = findPath(folderName, true);
+ const folderPath = findPath(folderName, false);
try { shell.openPath(folderPath); }
catch (error) { console.error(error); }
});
--
2.48.1
+14 -4
View File
@@ -2,6 +2,7 @@
stdenvNoCC,
lib,
requireFile,
asar,
copyDesktopItems,
electron,
makeDesktopItem,
@@ -10,21 +11,23 @@
campaigns ? [ ],
cubes ? [ ],
constructed ? [ ],
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "ddm";
version = "3.0.2";
version = "4.0.0";
src = requireFile {
name = "DungeonDuelMonsters-linux-x64.zip";
hash = "sha256-APIFQC5k6J0K5Q/e5poW8wKGL67NUbqKTJL4Ohd1K18=";
hash = "sha256-Ycy5Cbd4NR/TptVnl5wV154uA0JU0UzIRHTAi/xm0cs=";
url = "https://mikaygo.itch.io/ddm";
};
strictDeps = true;
nativeBuildInputs = [
asar
copyDesktopItems
makeWrapper
unzip
@@ -39,14 +42,18 @@ stdenvNoCC.mkDerivation (finalAttrs: {
mkdir -p $out/{bin,share/icons/hicolor/512x512/apps,share/ddm}
mv -t $out/share/ddm/ ./resources/app/*
asar extract ./resources/app.asar $out/share/ddm/
patch -d $out/share/ddm/ -p1 < ${./0001-Make-findPath-its-calls-behave-well-with-store.patch}
ln -s $out/share/ddm/icon.png $out/share/icons/hicolor/512x512/apps/ddm.png
makeWrapper ${lib.getExe electron} $out/bin/ddm \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
--add-flags "$out/share/ddm"
# Install externally-downloaded campaign packs & cube lists
# Install externally-downloaded campaign packs and cube & constructed lists
mkdir $out/share/ddm/{campaigns,cubes,constructed}
''
+ lib.concatMapStringsSep "\n" (campaignZip: ''
unzip "${campaignZip}" -d $out/share/ddm/campaigns/
@@ -54,6 +61,9 @@ stdenvNoCC.mkDerivation (finalAttrs: {
+ lib.concatMapStringsSep "\n" (cubeFile: ''
cp "${cubeFile}" $out/share/ddm/cubes/
'') cubes
+ lib.concatMapStringsSep "\n" (constructedFile: ''
cp "${constructedFile}" $out/share/ddm/constructed/
'') constructed
+ ''
runHook postInstall