Skip to content

Commit b31d89b

Browse files
committed
show ion storm maps for all layers
1 parent 0b357ff commit b31d89b

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

src/Module/Admin/View/Overview/Overview.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
use Stu\Module\Config\StuConfigInterface;
88
use Stu\Module\Control\GameControllerInterface;
99
use Stu\Module\Control\ViewControllerInterface;
10+
use Stu\Orm\Repository\LayerRepositoryInterface;
1011

1112
final class Overview implements ViewControllerInterface
1213
{
1314
public function __construct(
15+
private readonly LayerRepositoryInterface $layerRepository,
1416
private readonly StuConfigInterface $config
1517
) {}
1618

@@ -29,20 +31,27 @@ private function setWeatherReport(GameControllerInterface $game): void
2931
// load event map from file
3032
$historyFolder = $this->config->getGameSettings()->getTempDir() . '/history';
3133

32-
$fileName = $historyFolder . '/ionstorm_map_layer_2.gif';
33-
// check if file exists
34-
if (!file_exists($fileName)) {
35-
return;
36-
}
34+
/** @var array<string, string> $maps */
35+
$maps = [];
36+
37+
foreach ($this->layerRepository->findAllIndexed() as $layer) {
38+
$fileName = $historyFolder . '/ionstorm_map_layer_' . $layer->getId() . '.gif';
39+
// check if file exists
40+
if (!file_exists($fileName)) {
41+
continue;
42+
}
43+
44+
$fileContent = file_get_contents($fileName);
45+
if ($fileContent === false) {
46+
continue;
47+
}
3748

38-
$fileContent = file_get_contents($fileName);
39-
if ($fileContent === false) {
40-
return;
49+
$maps[$layer->getName()] = '<img src="data:image/gif;base64,' . base64_encode($fileContent) . '"/>';
4150
}
4251

4352
$game->setTemplateVar(
44-
'ION_STORM_MAP',
45-
'<img src="data:image/gif;base64,' . base64_encode($fileContent) . '"/>'
53+
'ION_STORM_MAPS',
54+
$maps
4655
);
4756
}
4857
}

src/html/admin/overview.twig

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22

33
{% block body %}
44
{% include 'html/breadcrumb.twig' %}
5-
{% if ION_STORM_MAP %}
6-
<div id="weather" style="width: 250px; margin-left: 5px; float: left;">
7-
<div class="divhead">Wetterbericht</div>
8-
<div class="divbody">
9-
{% autoescape false %}
10-
{{ ION_STORM_MAP }}
11-
{% endautoescape %}
12-
</div>
5+
{% if ION_STORM_MAPS %}
6+
<div id="weather" style="margin-left: 5px; float: left;">
7+
8+
<div class="divhead">Wetterbericht</div>
9+
{% for layerName, map in ION_STORM_MAPS %}
10+
<div id="weather_{{ layerName }}" style="width: 250px; margin-left: 5px; float: left;">
11+
<div class="divhead">{{ layerName }}</div>
12+
<div class="divbody">
13+
{% autoescape false %}
14+
{{ map }}
15+
{% endautoescape %}
16+
</div>
17+
</div>
18+
{% endfor %}
1319
</div>
1420
{% endif %}
1521

16-
1722
{% endblock %}

tests/inttest/html/__snapshots__/DefaultViewsControllerTest--ADMIN_VIEWS-DEFAULT_VIEW.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111

112112
<div id="result" style="display: none;">..</div>
113113

114-
115114
</div>
116115
<div class="footer">
117116
Rendered in 4.203s - Memory usage: 42.77Mb

0 commit comments

Comments
 (0)