From e4bf4064911b462b435fab7b0e813d1726aaedaa Mon Sep 17 00:00:00 2001 From: marianoag <131562345+marianoag@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:28:02 -0300 Subject: [PATCH 1/3] Cease to Breathe fix Replace included nwjs(0.71) wich doesn't work with 0.86 Fix cursor hitbox (set frame=false in package.json) Updated from 0.85 that didn't display custom cursors. --- gamefixes-steam/1873170.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 gamefixes-steam/1873170.py diff --git a/gamefixes-steam/1873170.py b/gamefixes-steam/1873170.py new file mode 100644 index 00000000..c8884803 --- /dev/null +++ b/gamefixes-steam/1873170.py @@ -0,0 +1,28 @@ +""" Cease to Breathe +Replace included nwjs(0.71) wich doesn't work with 0.86 +Fix cursor hitbox (set frame=false in package.json) +Updated from 0.85 that didn't display custom cursors. +""" +#pylint: disable=C0103 + +import os +import glob +import shutil +import urllib.request +import zipfile +import subprocess +from protonfixes import util + +def main(): + util.replace_command('CTB.exe', 'nw.exe') + install_dir = glob.escape(util.get_game_install_path()) + if not os.path.isfile(os.path.join(install_dir, 'nw.exe')): + url = 'https://dl.nwjs.io/v0.86.0/nwjs-v0.86.0-win-x64.zip' + nwjs = os.path.basename(url) + urllib.request.urlretrieve (url, nwjs) + with zipfile.ZipFile(nwjs, 'r') as zip_ref: + zip_ref.extractall(install_dir) + nwjs = os.path.join(install_dir, nwjs.rsplit('.', 1)[0]) + shutil.copytree(nwjs, install_dir, dirs_exist_ok=True) + shutil.rmtree(nwjs) + subprocess.call([f"sed -i 's/\"frame\": true/\"frame\": false/' \"{install_dir}/package.json\""], shell=True) From c5e135f9569d4b83f92afe7b042ccce1d5d1b09f Mon Sep 17 00:00:00 2001 From: marianoag <131562345+marianoag@users.noreply.github.com> Date: Sun, 7 Apr 2024 09:57:43 -0300 Subject: [PATCH 2/3] checksum and warning if fails --- gamefixes-steam/1873170.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gamefixes-steam/1873170.py b/gamefixes-steam/1873170.py index c8884803..eb5771ad 100644 --- a/gamefixes-steam/1873170.py +++ b/gamefixes-steam/1873170.py @@ -11,7 +11,9 @@ import urllib.request import zipfile import subprocess +import hashlib from protonfixes import util +from protonfixes.logger import log def main(): util.replace_command('CTB.exe', 'nw.exe') @@ -19,10 +21,16 @@ def main(): if not os.path.isfile(os.path.join(install_dir, 'nw.exe')): url = 'https://dl.nwjs.io/v0.86.0/nwjs-v0.86.0-win-x64.zip' nwjs = os.path.basename(url) - urllib.request.urlretrieve (url, nwjs) - with zipfile.ZipFile(nwjs, 'r') as zip_ref: - zip_ref.extractall(install_dir) - nwjs = os.path.join(install_dir, nwjs.rsplit('.', 1)[0]) - shutil.copytree(nwjs, install_dir, dirs_exist_ok=True) - shutil.rmtree(nwjs) + urllib.request.urlretrieve(url, nwjs) + with open(nwjs, "rb") as f: + nwjs_sum = hashlib.sha256(f.read()).hexdigest() + urllib.request.urlretrieve(f"https://dl.nwjs.io/{nwjs.split('-', 2)[1]}/SHASUMS256.txt", 'SHASUMS256.txt') + if subprocess.check_output(f"grep -F '{nwjs}' ./SHASUMS256.txt", shell=True,universal_newlines=True)[:64] == nwjs_sum: + with zipfile.ZipFile(nwjs, 'r') as zip_ref: + zip_ref.extractall(install_dir) + nwjs = os.path.join(install_dir, nwjs.rsplit('.', 1)[0]) + shutil.copytree(nwjs, install_dir, dirs_exist_ok=True) + shutil.rmtree(nwjs) + else: + log(f"{nwjs} checksum doesn't match, fix not applied.") subprocess.call([f"sed -i 's/\"frame\": true/\"frame\": false/' \"{install_dir}/package.json\""], shell=True) From 0745e61f6727bfe929668e1c1e628c358d0cc1c5 Mon Sep 17 00:00:00 2001 From: marianoag <131562345+marianoag@users.noreply.github.com> Date: Sun, 7 Apr 2024 10:02:35 -0300 Subject: [PATCH 3/3] Trailing whitespace --- gamefixes-steam/1873170.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamefixes-steam/1873170.py b/gamefixes-steam/1873170.py index eb5771ad..dc8a121c 100644 --- a/gamefixes-steam/1873170.py +++ b/gamefixes-steam/1873170.py @@ -30,7 +30,7 @@ def main(): zip_ref.extractall(install_dir) nwjs = os.path.join(install_dir, nwjs.rsplit('.', 1)[0]) shutil.copytree(nwjs, install_dir, dirs_exist_ok=True) - shutil.rmtree(nwjs) + shutil.rmtree(nwjs) else: log(f"{nwjs} checksum doesn't match, fix not applied.") subprocess.call([f"sed -i 's/\"frame\": true/\"frame\": false/' \"{install_dir}/package.json\""], shell=True)