-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy path__init__.py
More file actions
121 lines (95 loc) · 3.24 KB
/
__init__.py
File metadata and controls
121 lines (95 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"""Starts the protonfix module and runs fixes after pre-flight-checks"""
import os
import sys
import traceback
from typing import Callable
from . import fix
from .logger import log
from .upscalers import setup_upscalers
from .utilities import (
setup_frame_rate,
setup_local_shader_cache,
setup_mount_drives,
winetricks,
)
from .zenity import ZenityWaitDialog
sys.path.insert(
0,
f'{os.path.dirname(os.path.realpath(__file__))}/_vendor', # noqa: PTH120
)
bin_dir: str = f'{os.path.dirname(os.path.realpath(__file__))}/files/bin'
i386_lib_dir: str = (
f'{os.path.dirname(os.path.realpath(__file__))}/files/lib/i386-linux-gnu'
)
x86_64_lib_dir: str = (
f'{os.path.dirname(os.path.realpath(__file__))}/files/lib/x86_64-linux-gnu'
)
aarch64_lib_dir: str = (
f'{os.path.dirname(os.path.realpath(__file__))}/files/lib/aarch64-linux-gnu'
)
# This is needed for protonfixes
os.environ['PROTON_DLL_COPY'] = '*'
def check_conditions() -> bool:
"""Determine, if the actual game was executed and protonfixes isn't deactivated.
Returns:
bool: True, if the fix should be executed.
"""
return (
len(sys.argv) >= 1
and 'STEAM_COMPAT_DATA_PATH' in os.environ
and 'PROTONFIXES_DISABLE' not in os.environ
and 'waitforexitandrun' in sys.argv[1]
)
def check_iscriptevaluator() -> bool:
"""Determine, if we were invoked while running "iscriptevaluator.exe".
Returns:
bool: True, if we were invoked while running "iscriptevaluator.exe".
"""
return len(sys.argv) >= 3 and 'iscriptevaluator.exe' in sys.argv[2]
def execute_early() -> None:
"""Execute the early part of protonfixes"""
if check_iscriptevaluator():
log.debug('Skipping fix execution. We are running "iscriptevaluator.exe".')
elif not check_conditions():
log.warn('Skipping fix execution. We are probably running a unit test.')
else:
fix.early()
execute_early()
def setup(
env: dict,
bin_path_var: str,
lib_path_var: str,
func: Callable[[dict, str, str, str], None],
) -> None:
"""Setup PATH and LD_LIBRARY_PATH to include protonfixes's binary and library paths"""
func(env, bin_path_var, bin_dir, ':')
func(env, lib_path_var, f'{x86_64_lib_dir}:{aarch64_lib_dir}:{i386_lib_dir}', ':')
def execute() -> None:
"""Execute protonfixes"""
if check_iscriptevaluator():
log.debug('Skipping fix execution. We are running "iscriptevaluator.exe".')
elif not check_conditions():
log.warn('Skipping fix execution. We are probably running a unit test.')
else:
dialog = None
if os.environ.get('UMU_ID', '') != 'winetricks-gui':
dialog = ZenityWaitDialog('Installing Game-Specific fixes, please wait...')
try:
if isinstance(dialog, ZenityWaitDialog):
dialog.start()
fix.main()
except Exception:
sys.stderr.write('ProtonFixes ' + traceback.format_exc())
sys.stderr.flush()
finally:
if isinstance(dialog, ZenityWaitDialog):
dialog.stop()
__all__ = [
'setup',
'execute',
'setup_frame_rate',
'setup_local_shader_cache',
'setup_mount_drives',
'setup_upscalers',
'winetricks',
]