Skip to content

Instantly share code, notes, and snippets.

@Thesola10
Last active November 25, 2022 21:31
Show Gist options
  • Save Thesola10/caaf776545719a888b9542db2a1f3bcd to your computer and use it in GitHub Desktop.
Save Thesola10/caaf776545719a888b9542db2a1f3bcd to your computer and use it in GitHub Desktop.
Patch to build a Flatpak from Escaped Chasm game folder
diff --color -ruN Escaped_Chasm/io.itch.tuyoki.EscapedChasm.yaml Escaped_Chasm_New/io.itch.tuyoki.EscapedChasm.yaml
--- Escaped_Chasm/io.itch.tuyoki.EscapedChasm.yaml 1970-01-01 01:00:00.000000000 +0100
+++ Escaped_Chasm_New/io.itch.tuyoki.EscapedChasm.yaml 2020-08-07 18:58:58.059750271 +0200
@@ -0,0 +1,47 @@
+app-id: "io.itch.tuyoki.EscapedChasm"
+runtime: org.freedesktop.Platform
+runtime-version: '19.08'
+sdk: org.freedesktop.Sdk
+command: "/app/bin/EscapedChasm"
+
+finish-args:
+ - "--share=ipc"
+ - "--socket=x11"
+ - "--socket=wayland"
+ - "--socket=pulseaudio"
+ - "--device=dri"
+ - "--persist=save"
+
+sdk-extensions:
+ - 'org.freedesktop.Sdk.Extension.node12'
+
+add-extensions:
+ 'org.freedesktop.Platform.openh264':
+ directory: "lib"
+ version: '19.08'
+
+modules:
+ - name: "nodejs"
+ buildsystem: simple
+ build-commands:
+ - "/usr/lib/sdk/node12/install.sh"
+ - "mkdir -p /app/bin"
+ - "mv /app/node/bin/node /app/bin/node"
+ - name: "game"
+ buildsystem: simple
+ build-commands:
+ - "patch share/game/js/rpg_managers.js rpg_managers.js.patch"
+ - "ln -s fonts share/game/Fonts"
+ - "mkdir -p /app/lib"
+ - "cp -r share /app/"
+ - "install -D -m 755 share/run.sh /app/bin/EscapedChasm"
+ - "install -D share/game/icon/icon.png /app/share/icons/hicolor/128x128/apps/io.itch.tuyoki.EscapedChasm.png"
+ sources:
+ - type: dir
+ path: "static/linux"
+ dest: "share"
+ - type: dir
+ path: "www"
+ dest: "share/game"
+ - type: file
+ path: "rpg_managers.js.patch"
diff --color -ruN Escaped_Chasm/package.json Escaped_Chasm_New/package.json
--- Escaped_Chasm/package.json 2019-04-02 02:47:15.000000000 +0200
+++ Escaped_Chasm_New/package.json 2020-08-07 17:22:34.227900360 +0200
@@ -1,12 +1,18 @@
{
- "name": "Escaped Chasm",
+ "name": "escapedchasm",
"main": "www/index.html",
"js-flags": "--expose-gc",
"window": {
- "title": "",
+ "title": "Escaped Chasm",
"toolbar": false,
"width": 816,
"height": 624,
"icon": "www/icon/icon.png"
+ },
+ "dependencies": {
+ "nw": "^0.47.2"
+ },
+ "scripts": {
+ "start": "nw"
}
}
diff --color -ruN Escaped_Chasm/rpg_managers.js.patch Escaped_Chasm_New/rpg_managers.js.patch
--- Escaped_Chasm/rpg_managers.js.patch 1970-01-01 01:00:00.000000000 +0100
+++ Escaped_Chasm_New/rpg_managers.js.patch 2020-08-07 18:59:24.573259281 +0200
@@ -0,0 +1,11 @@
+--- www/js/rpg_managers.js 2020-08-07 18:54:46.931909235 +0200
++++ rpg_managers.js 2020-08-07 18:58:29.999573577 +0200
+@@ -755,7 +755,7 @@
+ StorageManager.localFileDirectoryPath = function() {
+ var path = require('path');
+
+- var base = path.dirname(process.mainModule.filename);
++ var base = require('os').homedir();
+ return path.join(base, 'save/');
+ };
+
diff --color -ruN Escaped_Chasm/static/linux/applications/io.itch.tuyoki.EscapedChasm.desktop Escaped_Chasm_New/static/linux/applications/io.itch.tuyoki.EscapedChasm.desktop
--- Escaped_Chasm/static/linux/applications/io.itch.tuyoki.EscapedChasm.desktop 1970-01-01 01:00:00.000000000 +0100
+++ Escaped_Chasm_New/static/linux/applications/io.itch.tuyoki.EscapedChasm.desktop 2020-08-07 17:22:48.018053783 +0200
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=Escaped Chasm
+Comment=A small little RPGmaker game about a lonely girl with a connection to another world that she sees in her dreams.
+Exec=/app/bin/EscapedChasm
+Icon=io.itch.tuyoki.EscapedChasm
+Categories=Game
+Type=Application
diff --color -ruN Escaped_Chasm/static/linux/metainfo/io.itch.tuyoki.EscapedChasm.metainfo.xml Escaped_Chasm_New/static/linux/metainfo/io.itch.tuyoki.EscapedChasm.metainfo.xml
--- Escaped_Chasm/static/linux/metainfo/io.itch.tuyoki.EscapedChasm.metainfo.xml 1970-01-01 01:00:00.000000000 +0100
+++ Escaped_Chasm_New/static/linux/metainfo/io.itch.tuyoki.EscapedChasm.metainfo.xml 2020-08-07 17:22:48.034720635 +0200
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<component type="desktop-application">
+ <name>Escaped Chasm</name>
+ <id>io.itch.tuyoki.EscapedChasm</id>
+ <launchable type="desktop-id">io.itch.tuyoki.EscapedChasm.desktop</launchable>
+ <metadata_license>CC0-1.0</metadata_license>
+ <project_license>LicenseRef-proprietary</project_license>
+ <summary>A small little RPGmaker game about a lonely girl with a connection to another world that she sees in her dreams.</summary>
+
+ <description>
+ <p>Tem here!!! It's my first time making an RPGmaker game!! Its my first time trying to put together my own project outside of an animated thing (though... I guess this is still sort of.. that..). I've always wanted to make an RPGMaker game, though I guess it isn't much of a game. Its around 15-20 minutes long (though I guess it could be longer if you try to get all the endings).</p>
+ <p>There's around 4 different endings you can get.</p>
+ <p>A small warning that one of the endings is a little creepy/unsettling.. But hopefully its not too much.</p>
+ </description>
+
+ <url type="homepage">https://tuyoki.itch.io/escaped-chasm</url>
+
+ <developer_name>Temmie Chang</developer_name>
+
+ <provides>
+ <binary>EscapedChasm</binary>
+ </provides>
+ <releases>
+ <release version="1.0" date="2019-04-02"/>
+ </releases>
+</component>
diff --color -ruN Escaped_Chasm/static/linux/run.sh Escaped_Chasm_New/static/linux/run.sh
--- Escaped_Chasm/static/linux/run.sh 1970-01-01 01:00:00.000000000 +0100
+++ Escaped_Chasm_New/static/linux/run.sh 2020-08-07 17:22:48.034720635 +0200
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec /app/share/game/node_modules/nw/bin/nw /app/share/game
diff --color -ruN Escaped_Chasm/www/package.json Escaped_Chasm_New/www/package.json
--- Escaped_Chasm/www/package.json 2018-10-25 21:09:51.000000000 +0200
+++ Escaped_Chasm_New/www/package.json 2020-08-07 17:22:27.527825334 +0200
@@ -1,12 +1,18 @@
{
- "name": "",
+ "name": "escapedchasm",
"main": "index.html",
"js-flags": "--expose-gc",
"window": {
- "title": "",
+ "title": "Escaped Chasm",
"toolbar": false,
"width": 816,
"height": 624,
"icon": "icon/icon.png"
+ },
+ "dependencies": {
+ "nw": "^0.47.2"
+ },
+ "scripts": {
+ "start": "nw"
}
}

Steps to build a flatpak from Escaped Chasm

Right, before you begin:

This diff applies to the Escaped_Chasm folder within the Escaped_Chasm_Contents folder, referred to as the "game folder" below. Yes, you can indeed apply a diff to an entire directory. Cool, huh?

Prerequisites

  • Escaped Chasm for Windows (whichever version)
  • Node.js and npm
  • Flatpak (duh) and flatpak-builder
  • From Flathub, org.freedesktop.Sdk and org.freedesktop.Sdk.Extension.node12

How to

  • Run dos2unix package.json in the game folder in order to apply the patch.
  • Run patch -p1 -ui chasm.patch in the game folder, usually Escaped_Chasm.
  • Run npm install in the www directory. We need the node_modules in there.
  • Run dos2unix www/js/rpg_managers.js to change the line endings in that file, we'll need to patch it. You'll get an error otherwise.
  • Then, run flatpak-builder build mybuilddir io.itch.tuyoki.EscapedChasm.yaml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment