-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_settings.py
223 lines (200 loc) · 9.78 KB
/
get_settings.py
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
def get_settings_from_file():
change_set = ["^2", "^2", "^2", "^2", "^2", "^2", "^2", "^2", "^2", "^2", "medium", "^2", "normal", "^2", "^1",
"1920x1080", "0", "avg", "metric", "0", "0", "^2", "^2", "de", "^2", "^2", "^2", "^2", "^2", "^2", 0,
"^2", "^2"]
try:
with open("settings.txt") as fp:
for i, line in enumerate(fp):
if 2 <= i <= 11:
line = line.split()
if str(line[0]) == "on":
change_set[i - 2] = True
else:
change_set[i - 2] = False
if i == 12:
line = line.split()
change_set[i - 2] = str(line[0])
if i == 13:
line = line.split()
if str(line[0]) == "on":
change_set[i - 2] = True
else:
change_set[i - 2] = False
if i == 14:
line = line.split()
change_set[i - 2] = str(line[0])
if i == 15 or i == 16:
line = line.split()
if str(line[0]) == "on":
change_set[i - 2] = True
else:
change_set[i - 2] = False
if i == 17:
line = line.split()
line = line[0].split("x")
change_set[i - 2] = str(line[0]) + "x" + str(line[1])
if i == 18:
line = line.split()
change_set[i - 2] = int(line[0])
if i == 19:
line = line.split()
change_set[i - 2] = str(line[0])
if i == 20:
line = line.split()
change_set[i - 2] = str(line[0])
if i == 21:
line = line.split()
change_set[i - 2] = int(line[0])
if i == 22:
line = line.split()
change_set[i - 2] = int(line[0])
if i == 23 or i == 24:
line = line.split()
if str(line[0]) == "on":
change_set[i - 2] = True
else:
change_set[i - 2] = False
if i == 25:
line = line.split()
change_set[i - 2] = str(line[0])
if i == 26 or i == 27 or i == 28 or i == 29 or i == 30 or i == 31:
line = line.split()
if str(line[0]) == "on":
change_set[i - 2] = True
else:
change_set[i - 2] = False
if i == 32:
line = line.split()
change_set[i - 2] = int(line[0])
if i == 33 or i == 34:
line = line.split()
if str(line[0]) == "on":
change_set[i - 2] = True
else:
change_set[i - 2] = False
print("Settings loaded successfully")
return change_set
except Exception as e:
print(e)
print("Error loading settings. Make sure settings.txt exists in Folder.")
# SETUP ACC AXIS FROM MENU!
def get_acc_settings_from_file():
throttle = -1
brake = -1
steer = -1
joy = -1
try:
with open("acc_settings.txt") as fp:
for i, line in enumerate(fp):
if i == 1:
line = line.split()
throttle = int(line[0])
if i == 2:
line = line.split()
brake = int(line[0])
if i == 3:
line = line.split()
joy = int(line[0])
if i == 4:
line = line.split()
steer = int(line[0])
if throttle != -1 and brake != -1:
print("ACC settings loaded successfully")
else:
print("ACC not set up yet. ACC unavailable.")
return throttle, brake, steer, joy
except:
print("Error loading ACC settings. ACC unavailable settings.txt exists in Folder.")
def get_controls_from_file():
change_set = ["s", "x", "i", "2", "3", "1", "6", "down", "up", "q", "m", "k", "13"]
try:
with open("controls.txt") as fp:
for i, line in enumerate(fp):
if 1 <= i <= 10:
line = line.split()
change_set[i - 1] = line[0]
elif 12 <= i <= 14:
line = line.split()
change_set[i - 2] = line[0]
print("Controls loaded successfully")
return change_set
except Exception as e:
print(e)
print("Error loading control-settings. Make sure controls.txt exists in Folder.")
def write_settings(game_obj):
settings = game_obj.settings
file_string = "Important: Only change the letter in the at the beginning. Do not rearrange this layout. \n" \
'Assistance-Default-Settings ("on", or "off". Space necessary between setting and "<--"):\n' \
"{} <-- Head-up display\n" \
"{} <-- Forward collision warning\n" \
"{} <-- Blind spot warning\n" \
"{} <-- Cross traffic warning\n" \
"{} <-- Light assist\n" \
"{} <-- Park assist\n" \
"{} <-- Emergency assist\n" \
"{} <-- Lane assist\n" \
"{} <-- Cop aid system\n" \
"{} <-- Automatic Emergency Braking\n" \
"{} <-- Collision Warning Distance (early, medium, late)\n" \
"{} <-- Automatic Gearbox (when sequential Gearbox is set in LFS)\n" \
"{} <-- Lane departure warning intensity (early, normal, reduced)\n" \
"{} <-- Head-up display with images\n" \
"{} <-- stability control\n" \
"{} <-- Monitor resolution\n" \
"{} <-- warning sound (change in menu, when program is active)\n" \
"{} <-- Trip-computer mode\n" \
"{} <-- unit\n" \
"{} <-- HUD height offset\n" \
"{} <-- HUD width offset\n" \
"{} <-- automatic indicator turnoff\n" \
"{} <-- park emergency brake\n" \
"{} <-- language\n" \
"{} <-- audible parking aid\n" \
"{} <-- visual parking aid\n" \
"{} <-- side collision prevention\n" \
"{} <-- Indicator Sounds\n" \
"{} <-- Adaptive Brake Lights\n" \
"{} <-- Adaptive Brake Lights Style\n" \
"{} <-- Mode (0 = all on, 1 = all off, 2 = cop, 3 = race)\n" \
"{} <-- Stall-Protection\n" \
"{} <-- Realistic Clutch".format(settings.head_up_display,
settings.forward_collision_warning,
settings.blind_spot_warning,
settings.cross_traffic_warning,
settings.light_assist,
settings.park_distance_control,
settings.emergency_assist,
settings.lane_assist,
settings.cop_aid_system,
settings.automatic_emergency_braking,
settings.collision_warning_distance,
settings.automatic_gearbox,
settings.lane_dep_intensity,
settings.image_hud,
settings.PSC,
settings.resolution,
settings.collision_warning_sound,
settings.bc,
settings.unit,
settings.offset_h,
settings.offset_w,
settings.automatic_indicator_turnoff,
settings.park_emergency_brake,
settings.language,
settings.audible_parking_aid,
settings.visual_parking_aid,
settings.side_collision_prevention,
settings.indicator_sound,
settings.adaptive_brake_light,
settings.adaptive_brake_light_style,
settings.pact_mode,
settings.stall_protection,
settings.realistic_clutch)
file_string = file_string.replace("True", "on")
file_string = file_string.replace("False", "off")
try:
with open('settings.txt', 'w') as file:
file.write(file_string)
print("Settings saved successfully")
except:
print("An Error has Occurred during saving. Make sure settings.txt exists.")