-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_settings.py
157 lines (140 loc) · 6.75 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
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]
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] = "^2"
else:
change_set[i - 2] = "^1"
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] = "^2"
else:
change_set[i - 2] = "^1"
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] = "^2"
else:
change_set[i - 2] = "^1"
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])
print("Settings loaded successfully")
return change_set
except:
print("Error loading settings. Make sure settings.txt exists in Folder.")
def get_acc_settings_from_file():
throttle = -1
brake = -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 throttle != -1 and brake != -1:
print("ACC settings loaded successfully")
else:
print("ACC not set up yet. ACC unavailable.")
return throttle, brake, 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"]
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]
print("Controls loaded successfully")
return change_set
except:
print("Error loading control-settings. Make sure controls.txt exists in Folder.")
def write_settings(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".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.offseth,
settings.offsetw)
file_string = file_string.replace("^2", "on")
file_string = file_string.replace("^1", "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.")