MAPG-103 unify some styles and show map name in the header

This commit is contained in:
Bence Pőcze 2020-06-06 01:11:45 +02:00
parent 5dd877d075
commit 46ef7f3b3b
6 changed files with 47 additions and 18 deletions

View File

@ -100,6 +100,9 @@
} }
@media screen and (max-width: 599px) { @media screen and (max-width: 599px) {
#mapName {
display: none;
}
#showGuessButtonContainer { #showGuessButtonContainer {
position: absolute; position: absolute;
left: 20px; left: 20px;

View File

@ -98,7 +98,7 @@ sub {
} }
svg.inline, img.inline { svg.inline, img.inline {
display: inline-block; display: inline;
width: 1em; width: 1em;
height: 1em; height: 1em;
vertical-align: -0.15em; vertical-align: -0.15em;
@ -233,6 +233,19 @@ div.header>div.grid>:nth-child(2) {
text-align: right; text-align: right;
} }
div.header>div.grid>:nth-child(2)>span {
padding-left: 6px;
}
div.header>div.grid>:nth-child(2)>span>a:link, div.header>div.grid>:nth-child(2)>span>a:visited {
color: inherit;
}
div.header>div.grid>:nth-child(2)>span:not(:last-child) {
border-right: solid white 1px;
padding-right: 6px;
}
div.main { div.main {
padding: 6px 12px; padding: 6px 12px;
} }

View File

@ -7,14 +7,18 @@ use MapGuesser\Util\Geo\Bounds;
use MapGuesser\Response\HtmlContent; use MapGuesser\Response\HtmlContent;
use MapGuesser\Response\JsonContent; use MapGuesser\Response\JsonContent;
use MapGuesser\Interfaces\Response\IContent; use MapGuesser\Interfaces\Response\IContent;
use MapGuesser\Repository\MapRepository;
class GameController class GameController
{ {
private IRequest $request; private IRequest $request;
private MapRepository $mapRepository;
public function __construct(IRequest $request) public function __construct(IRequest $request)
{ {
$this->request = $request; $this->request = $request;
$this->mapRepository = new MapRepository();
} }
public function getGame(): IContent public function getGame(): IContent
@ -33,7 +37,9 @@ class GameController
private function prepareGame(int $mapId) private function prepareGame(int $mapId)
{ {
$bounds = $this->getMapBounds($mapId); $map = $this->mapRepository->getById($mapId);
$bounds = Bounds::createDirectly($map['bound_south_lat'], $map['bound_west_lng'], $map['bound_north_lat'], $map['bound_east_lng']);
$session = $this->request->session(); $session = $this->request->session();
@ -45,19 +51,6 @@ class GameController
]); ]);
} }
return ['mapId' => $mapId, 'bounds' => $bounds->toArray()]; return ['mapId' => $mapId, 'mapName' => $map['name'], 'bounds' => $bounds->toArray()];
}
private function getMapBounds(int $mapId): Bounds
{
$select = new Select(\Container::$dbConnection, 'maps');
$select->columns(['bound_south_lat', 'bound_west_lng', 'bound_north_lat', 'bound_east_lng']);
$select->whereId($mapId);
$map = $select->execute()->fetch(IResultSet::FETCH_ASSOC);
$bounds = Bounds::createDirectly($map['bound_south_lat'], $map['bound_west_lng'], $map['bound_north_lat'], $map['bound_east_lng']);
return $bounds;
} }
} }

View File

@ -0,0 +1,16 @@
<?php namespace MapGuesser\Repository;
use MapGuesser\Database\Query\Select;
use MapGuesser\Interfaces\Database\IResultSet;
class MapRepository
{
public function getById(int $mapId)
{
$select = new Select(\Container::$dbConnection, 'maps');
$select->columns(['id', 'name', 'description', 'bound_south_lat', 'bound_west_lng', 'bound_north_lat', 'bound_east_lng']);
$select->whereId($mapId);
return $select->execute()->fetch(IResultSet::FETCH_ASSOC);
}
}

View File

@ -8,7 +8,11 @@
<span>MapGuesser</span> <span>MapGuesser</span>
</a> </a>
</h1> </h1>
<p>Round: <span id="currentRound" class="mono bold"></span> | Score: <span id="currentScoreSum" class="mono bold"></span></p> <p>
<span id="mapName" class="bold"><?= $mapName ?></span><!--
--><span>Round <span id="currentRound" class="bold"></span></span><!--
--><span>Score <span id="currentScoreSum" class="bold"></span></span>
</p>
</div> </div>
</div> </div>
<div id="cover"></div> <div id="cover"></div>

View File

@ -10,7 +10,7 @@
<link href="<?= $cssFile ?>" rel="stylesheet"> <link href="<?= $cssFile ?>" rel="stylesheet">
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;500&family=Roboto+Mono:wght@300;500&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;500&display=swap" rel="stylesheet">
<link rel="icon" type="image/png" sizes="192x192" href="/static/img/favicon/192x192.png"> <link rel="icon" type="image/png" sizes="192x192" href="/static/img/favicon/192x192.png">
<link rel="icon" type="image/png" sizes="96x96" href="/static/img/favicon/96x96.png"> <link rel="icon" type="image/png" sizes="96x96" href="/static/img/favicon/96x96.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/img/favicon/32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="/static/img/favicon/32x32.png">