-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgaps-overlay-screen.js
356 lines (309 loc) · 9.17 KB
/
gaps-overlay-screen.js
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/**
* gaps-overlay screen elements functions
*/
/**
* main window functions
*/
function mainWindowVisible() {
const inMenu = $prop("TyrePressureFrontLeft") === 0;
const solo = $prop("OpponentsCount") <= 1;
if (!solo) {
if (!inMenu) {
return true;
}
if ($prop("GameRawData.Graphics.IsSetupMenuVisible") === 1) {
return false;
}
const playerCarID = $prop("DataCorePlugin.GameRawData.Graphics.PlayerCarID");
const focusedCarID = $prop("DataCorePlugin.GameRawData.Realtime.FocusedCarIndex");
return focusedCarID !== playerCarID;
}
return false;
}
/**
* position box functions
*/
function positionBoxVisible(LBposition) {
return true;
}
function positionBoxBackground(LBposition) {
return DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Car.Class.Color");
}
function positionBoxTextColor(LBposition) {
const _carClass = DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Car.Class");
switch (_carClass) {
case "GT2":
case "CUP17":
case "ST15":
return "Black";
case "GT3":
case "GT4":
case "CUP21":
case "ST21":
case "CHL":
case "TCX":
return "White";
default:
return "Black";
}
}
function positionBoxText(LBposition) {
return driver_Position(LBposition);
}
/**
* car number box functions
*/
function carNumberBoxVisible(LBposition) {
return true;
}
function carNumberBoxBackground(LBposition) {
return DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Team.CupCategory.Color");
}
function carNumberBoxTextColor(LBposition) {
return DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Team.CupCategory.TextColor");
}
function carNumberBoxText(LBposition) {
return driver_CarNumber(LBposition);
}
/**
* car logo box functions
*/
function carLogoBoxVisible(LBposition) {
return true;
}
function carLogoBoxBackground(LBposition) {
return "Black";
}
function carLogoBoxImage(LBposition) {
const carManufacturer = DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Car.Manufacturer");
return carManufacturer === null ? null : carManufacturer.toLowerCase().replace(/\d/, "").replace(" ", "-");
}
/**
* name box functions
*/
function nameBoxVisible(LBposition) {
return true;
}
function nameBoxBackground(LBposition) {
return "Transparent";
}
function nameBoxTextColor(LBposition) {
if ($prop("SessionTypeName") == "RACE") {
var driverLap = driver_RelativeLapNr(LBposition);
if (driverLap < 0) {
return "Cyan";
} else if (driverLap > 0) {
return "Orange";
}
}
return "White";
}
function nameBoxText(LBposition) {
return driver_Name(LBposition);
}
/**
* best lap box functions
*/
function bestLapBoxVisible(LBposition) {
if (driver_BestLapTime(LBposition) === null) {
return false;
}
return true;
}
function bestLapBoxBackground(LBposition) {
if (driver_HasBestLap(LBposition)) {
return "Purple";
}
if (
DynLeaderboardsPluginProp(leaderBoardName, LBposition, "IsFocused") === 1 ||
$prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY"
) {
return "DeepSkyBlue";
}
return gapBackgroundColor(driver_BestLapDelta(LBposition), "DeepSkyBlue");
}
function bestLapBoxTextColor(LBposition) {
return gapTextColor(bestLapBoxBackground(LBposition));
}
function bestLapBoxText(LBposition, mode) {
const _delta = driver_BestLapDelta(LBposition);
if (
$prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY" ||
_delta === null ||
Math.abs(_delta) >= 60 ||
DynLeaderboardsPluginProp(leaderBoardName, LBposition, "IsFocused") === 1 ||
focused_BestToBestDelta() >= 30 ||
mode === "time"
) {
return secToTimeStr(driver_BestLapTime(LBposition));
}
return format(_delta, "0.0", true);
}
/**
* last lap box functions
*/
function lastLapBoxVisible(LBposition) {
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
if (driver_BestLapDelta(LBposition) === null) {
return false;
}
return true;
}
if (driver_LastLapTime(LBposition) === null) {
return false;
}
return true;
}
function lastLapBoxBackground(LBposition) {
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
return gapBackgroundColor(driver_BestLapDelta(LBposition), "DeepSkyBlue");
}
const _lastIsPB = driver_LastLapTime(LBposition) === driver_BestLapTime(LBposition);
if (_lastIsPB && driver_HasBestLap(LBposition)) {
return "Purple";
}
if (DynLeaderboardsPluginProp(leaderBoardName, LBposition, "IsFocused") === 1) {
return _lastIsPB ? "DeepSkyBlue" : "White";
}
return gapBackgroundColor(driver_LastLapDelta(LBposition), _lastIsPB ? "DeepSkyBlue" : "White");
}
function lastLapBoxTextColor(LBposition) {
return gapTextColor(lastLapBoxBackground(LBposition));
}
function lastLapBoxText(LBposition, mode) {
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
return format(driver_BestLapDelta(LBposition), "0.0", true);
}
const _delta = driver_LastLapDelta(LBposition);
if (
_delta === null ||
Math.abs(_delta) >= 60 ||
DynLeaderboardsPluginProp(leaderBoardName, LBposition, "IsFocused") === 1 ||
focused_LastToBestDelta() >= 30 ||
mode === "time"
) {
return secToTimeStr(driver_LastLapTime(LBposition));
}
return format(_delta, "0.0", true);
}
/**
* delta box functions
*/
function deltaBoxCheckered(LBposition) {
if (DynLeaderboardsPluginProp(leaderBoardName, LBposition, "IsFinished") === 1) {
return true;
}
return false;
}
function deltaBoxVisible(LBposition) {
return true;
}
function deltaBoxBackground(LBposition) {
if (DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Pit.IsIn")) {
return "Black";
}
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
if (DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Laps.Current.IsOutLap")) {
return "OrangeRed";
}
return DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Laps.Current.IsValid") ? "Green" : "Red";
}
return gapBackgroundColor(driver_Gap(LBposition), "Black");
}
function deltaBoxTextColor(LBposition) {
return gapTextColor(deltaBoxBackground(LBposition));
}
function deltaBoxText(LBposition) {
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
if (DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Pit.IsIn")) {
return "in pit";
}
if (DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Laps.Current.IsOutLap")) {
return "out lap";
}
return DynLeaderboardsPluginProp(leaderBoardName, LBposition, "Laps.Current.IsValid") ? "fast" : "invalid";
}
return driver_Gap(LBposition);
}
/**
* sectors boxes functions
*/
function sectorBoxVisible(LBposition, sector) {
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
return driver_BestLapSectorTime(LBposition, sector) !== null;
}
return driver_LastLapSectorTime(LBposition, sector) !== null;
}
function sectorBoxBackground(LBposition, sector) {
let _delta = driver_LastLapSectorDelta(LBposition, sector);
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
_delta = driver_BestLapSectorDelta(LBposition, sector);
}
if (DynLeaderboardsPluginProp(leaderBoardName, LBposition, "IsFocused") === 1 || _delta === null) {
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
return "DeepSkyBlue";
}
return driver_LastSectorIsPB(LBposition, sector) ? "DeepSkyBlue" : "White";
}
return gapBackgroundColor(_delta, "White");
}
function sectorBoxTextColor(LBposition, sector) {
return gapTextColor(sectorBoxBackground(LBposition, sector));
}
function sectorBoxText(LBposition, sector, mode) {
let _delta = driver_LastLapSectorDelta(LBposition, sector);
let _time = driver_LastLapSectorTime(LBposition, sector);
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
_delta = driver_BestLapSectorDelta(LBposition, sector);
_time = driver_BestLapSectorTime(LBposition, sector);
}
if (DynLeaderboardsPluginProp(leaderBoardName, LBposition, "IsFocused") === 1 || _delta === null || mode === "time") {
return format(_time, "0.0", false);
}
return format(_delta, "0.0", true);
}
/**
* labels
*/
function leaderboardTypeVisible() {
return true;
}
function leaderboardTypeBackground() {
return "#80000000";
}
function leaderboardTypeTextColor() {
return "White";
}
function leaderboardTypeText() {
return $prop("DynLeaderboardsPlugin." + leaderBoardName + ".CurrentLeaderboard")
.replace(/([A-Z])/g, " $1")
.toLowerCase();
}
function classNameVisible() {
return leaderboardType() == "Class";
}
function classNameBackground() {
return "#80000000";
}
function classNameTextColor() {
return "White";
}
function classNameText() {
const _focusedPosition = $prop("DynLeaderboardsPlugin." + leaderBoardName + ".FocusedPosInCurrentLeaderboard") + 1;
return DynLeaderboardsPluginProp(leaderBoardName, _focusedPosition, "Car.Class");
}
function displayModeVisible() {
return true;
}
function displayModeBackground() {
return "#80000000";
}
function displayModeTextColor() {
return "White";
}
function displayModeText(mode) {
if ($prop("DataCorePlugin.GameData.SessionTypeName") === "QUALIFY") {
return "quali";
}
return mode;
}