Skip to content

Commit

Permalink
fixes C0103 and C0116
Browse files Browse the repository at this point in the history
  • Loading branch information
marianoag authored Apr 15, 2024
1 parent b532011 commit 7ec2fd8
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions gamefixes-steam/1137300.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
UW support: RoseTheFlower/SherlockHolmesCOUltrawide
UW support: PhantomGamers/shco-wsf
"""
#pylint: disable=C0103

import os
import sys
Expand Down Expand Up @@ -31,12 +30,14 @@ def _get_pid(procname: str) -> int:
return procpid

def get_pid(procname: str, untilfound: bool=False) -> int:
"""Get pid for processes launched afer the game that run in Proton (checks for Windows path)"""
while True:
pid = _get_pid(procname)
if pid is not None or not untilfound:
return pid

def install_xdotool(path_to_exe: str):
"""Copy xdotool (and libxdo.so.3) to executable's directory"""
if not os.path.isfile(os.path.join(path_to_exe, 'busybox_AR')):
url = 'https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox_AR'
hashsum = '49061d5037e33742e90d2eb94aa3d8e12305ac5df5d380a3d31d50d7c026a40b'
Expand Down Expand Up @@ -85,6 +86,7 @@ def install_xdotool(path_to_exe: str):
os.remove(file)

def load_trainer(trainer: str):
"""Load trainer after game launches, minimizes it, and kills it when game closes"""
path_to_exe = os.path.dirname(trainer)
if not os.path.isfile(os.path.join(path_to_exe, 'xdotool')):
install_xdotool(path_to_exe)
Expand Down Expand Up @@ -117,20 +119,21 @@ def load_trainer(trainer: str):
break

def main():
"""Only applies fix for UW display. Checks for UW fix zip or extracted files, if none found download one"""
screen_width,screen_height = util.get_resolution()
#Checks for UW in case there's an UW fix present but display is not.
#eg. the monitor changed or the files were moved from a PC to a SteamDeck
if screen_width/(screen_height/9) > 21:
install_dir = glob.escape(util.get_game_install_path())
bin_path = 'SH9/Binaries/Win64'
path_to_exe = os.path.join(install_dir, bin_path)
UW_file = os.path.join(path_to_exe, 'Sherlock Holmes CO Ultrawide.exe')
UW_zip = os.path.join(install_dir,'Sherlock.Holmes.CO.Ultrawide.zip')
UW2_file = os.path.join(path_to_exe, 'SUWSF.asi')
UW2_zip = os.path.join(install_dir, 'SHCO-WSF.zip')
uw_file = os.path.join(path_to_exe, 'Sherlock Holmes CO Ultrawide.exe')
uw_zip = os.path.join(install_dir,'Sherlock.Holmes.CO.Ultrawide.zip')
uw2_file = os.path.join(path_to_exe, 'SUWSF.asi')
uw2_zip = os.path.join(install_dir, 'SHCO-WSF.zip')
#Previously it didn't download anything, only checked if an UW fix was present.
#added download since now it checks for UW display.
if not ((os.path.isfile(UW_zip) or os.path.isfile(UW_file)) or (os.path.isfile(UW2_zip) or os.path.isfile(UW2_file))):
if not ((os.path.isfile(uw_zip) or os.path.isfile(uw_file)) or (os.path.isfile(uw2_zip) or os.path.isfile(uw2_file))):
url = 'https://github.com/RoseTheFlower/SherlockHolmesCOUltrawide/releases/download/v1.0/Sherlock.Holmes.CO.Ultrawide.zip'
hashsum = '9142cfb7e64b95243e9f5df9f3aae19304128c5def51d9c1b292d23c02321eee'
file = os.path.join(path_to_exe, os.path.basename(url))
Expand All @@ -139,13 +142,13 @@ def main():
file_sum = hashlib.sha256(f.read()).hexdigest()
if hashsum != file_sum:
os.remove(file)
if os.path.isfile(UW_zip) or os.path.isfile(UW_file):
if not os.path.isfile(UW_file):
with zipfile.ZipFile(UW_zip, 'r') as zip_ref:
zip_ref.extract(os.path.basename(UW_file), path_to_exe)
threading.Thread(target=load_trainer, args=[UW_file]).start()
elif os.path.isfile(UW2_zip) or os.path.isfile(UW2_file):
if not os.path.isfile(UW2_file):
with zipfile.ZipFile(UW2_zip, 'r') as zip_ref:
if os.path.isfile(uw_zip) or os.path.isfile(uw_file):
if not os.path.isfile(uw_file):
with zipfile.ZipFile(uw_zip, 'r') as zip_ref:
zip_ref.extract(os.path.basename(uw_file), path_to_exe)
threading.Thread(target=load_trainer, args=[uw_file]).start()
elif os.path.isfile(uw2_zip) or os.path.isfile(uw2_file):
if not os.path.isfile(uw2_file):
with zipfile.ZipFile(uw2_zip, 'r') as zip_ref:
zip_ref.extractall()
util.winedll_override('dsound', 'n')

0 comments on commit 7ec2fd8

Please sign in to comment.