From 46ef7f3b3b18b98d2655c2be314c9f6bc9498f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sat, 6 Jun 2020 01:11:45 +0200 Subject: [PATCH] MAPG-103 unify some styles and show map name in the header --- public/static/css/game.css | 3 +++ public/static/css/mapguesser.css | 15 ++++++++++++++- src/Controller/GameController.php | 23 ++++++++--------------- src/Repository/MapRepository.php | 16 ++++++++++++++++ views/game.php | 6 +++++- views/templates/main_header.php | 2 +- 6 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 src/Repository/MapRepository.php diff --git a/public/static/css/game.css b/public/static/css/game.css index 9fc1105..28f2d7d 100644 --- a/public/static/css/game.css +++ b/public/static/css/game.css @@ -100,6 +100,9 @@ } @media screen and (max-width: 599px) { + #mapName { + display: none; + } #showGuessButtonContainer { position: absolute; left: 20px; diff --git a/public/static/css/mapguesser.css b/public/static/css/mapguesser.css index 957f803..6be0b44 100644 --- a/public/static/css/mapguesser.css +++ b/public/static/css/mapguesser.css @@ -98,7 +98,7 @@ sub { } svg.inline, img.inline { - display: inline-block; + display: inline; width: 1em; height: 1em; vertical-align: -0.15em; @@ -233,6 +233,19 @@ div.header>div.grid>:nth-child(2) { 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 { padding: 6px 12px; } diff --git a/src/Controller/GameController.php b/src/Controller/GameController.php index 1664623..8a47d54 100644 --- a/src/Controller/GameController.php +++ b/src/Controller/GameController.php @@ -7,14 +7,18 @@ use MapGuesser\Util\Geo\Bounds; use MapGuesser\Response\HtmlContent; use MapGuesser\Response\JsonContent; use MapGuesser\Interfaces\Response\IContent; +use MapGuesser\Repository\MapRepository; class GameController { private IRequest $request; + private MapRepository $mapRepository; + public function __construct(IRequest $request) { $this->request = $request; + $this->mapRepository = new MapRepository(); } public function getGame(): IContent @@ -33,7 +37,9 @@ class GameController 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(); @@ -45,19 +51,6 @@ class GameController ]); } - return ['mapId' => $mapId, '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; + return ['mapId' => $mapId, 'mapName' => $map['name'], 'bounds' => $bounds->toArray()]; } } diff --git a/src/Repository/MapRepository.php b/src/Repository/MapRepository.php new file mode 100644 index 0000000..7fef975 --- /dev/null +++ b/src/Repository/MapRepository.php @@ -0,0 +1,16 @@ +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); + } +} diff --git a/views/game.php b/views/game.php index bd10951..c242c57 100644 --- a/views/game.php +++ b/views/game.php @@ -8,7 +8,11 @@ MapGuesser -

Round: | Score:

+

+ Round Score +

diff --git a/views/templates/main_header.php b/views/templates/main_header.php index cd488cd..13d3a0a 100644 --- a/views/templates/main_header.php +++ b/views/templates/main_header.php @@ -10,7 +10,7 @@ - +