-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from marianoag/CTB
Cease to Breathe fix
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" 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 | ||
import hashlib | ||
from protonfixes import util | ||
from protonfixes.logger import log | ||
|
||
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 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) |