-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
103 lines (96 loc) · 3.97 KB
/
index.php
File metadata and controls
103 lines (96 loc) · 3.97 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
<?php
declare(strict_types=1);
use Kryus\GeneRally\Track;
require_once 'vendor/autoload.php';
$trackname = $_SERVER['argv'][1];
$track = Track::createFromFilename(__DIR__ . '/' . $trackname);
$landmapRenderer = new Track\TrackData\Landmap\Renderer\GdRenderer($track->getTrackData()->getLandmap());
$landmapRenderer->saveAsBmp(__DIR__ . '/' . $trackname . '_LMap.bmp');
$track->getTrackData()->getHeightmap()->toImage()->save(__DIR__ . '/' . $trackname . '_HMap.bmp');
ob_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Track reading demo</title>
</head>
<body>
<div style="display: flex;">
<div style="flex: 1;">
<img src="<?php echo $landmapRenderer->toDataUri(); ?>" style="transform: perspective(1024px) rotateX(<?php echo $track->getTrackData()->getProperties()->getViewAngle(); ?>deg) rotateZ(<?php echo $track->getTrackData()->getProperties()->getRotation(); ?>deg) scale(0.7071)">
</div>
<div style="flex: 1;">
<table>
<tr>
<th>Version</th>
<td><?php echo $track->getHeader()->getVersion(); ?></td>
</tr>
</table>
<table>
<caption>Track properties</caption>
<tr>
<th>Water level</th>
<td><?php echo $track->getTrackData()->getProperties()->getWaterLevel(); ?></td>
</tr>
<tr>
<th>View angle</th>
<td><?php echo $track->getTrackData()->getProperties()->getViewAngle(); ?>°</td>
</tr>
<tr>
<th>Rotation</th>
<td><?php echo $track->getTrackData()->getProperties()->getRotation(); ?>°</td>
</tr>
<tr>
<th>Zoom</th>
<td><?php echo $track->getTrackData()->getProperties()->getZoom(); ?></td>
</tr>
<tr>
<th>World size</th>
<td><?php echo $track->getTrackData()->getProperties()->getWorldSize(); ?> m</td>
</tr>
<tr>
<th>S/F line</th>
<td><?php echo $track->getTrackData()->getProperties()->getSfLine()->toBool() ? 'Yes' : 'No'; ?></td>
</tr>
<tr>
<th>Track length</th>
<td><?php echo $track->getTrackData()->getProperties()->getTrackLength(); ?> m</td>
</tr>
<tr>
<th>Author</th>
<td><?php echo htmlspecialchars($track->getTrackData()->getProperties()->getAuthor()); ?></td>
</tr>
<tr>
<th>Author's comments</th>
<td><?php echo nl2br(htmlspecialchars($track->getTrackData()->getProperties()->getAuthorsComments())); ?></td>
</tr>
</table>
<table>
<caption>Track record</caption>
<?php if ($track->getTimeData()->getTrackRecord() !== null) { ?>
<tr>
<th></th>
<td><?php echo $track->getTimeData()->getTrackRecord()->getLapTime(); ?> s</td>
<td><?php echo htmlspecialchars($track->getTimeData()->getTrackRecord()->getDriverName()); ?></td>
<td><?php echo $track->getTimeData()->getTrackRecord()->getDateTime()->format('Y-m-d H:i:s.v T'); ?></td>
</tr>
<?php } ?>
</table>
<table>
<caption>Best times</caption>
<?php foreach ($track->getTimeData()->getBestTimes() as $i => $bestTime) { ?>
<tr>
<th><?php echo $i; ?>.</th>
<td><?php echo $bestTime->getLapTime(); ?> s</td>
<td><?php echo htmlspecialchars($bestTime->getDriverName()); ?></td>
<td><?php echo $bestTime->getDateTime()->format('Y-m-d H:i:s.v T'); ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</body>
</html>
<?php
file_put_contents(__DIR__ . '/' . $trackname . '.html', ob_get_clean());