From 78016e8137ffcc1143f13a57aba6b719dc7d36d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dr=C3=A1bek?= Date: Sun, 13 Aug 2023 06:23:11 +0200 Subject: [PATCH] Show gaming time to everybody if set --- App/Presenters/BasePresenter.php | 1 + App/Presenters/templates/menu.latte | 2 +- App/Services/System/GameClockService.php | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/App/Presenters/BasePresenter.php b/App/Presenters/BasePresenter.php index 8443dab..f46550d 100644 --- a/App/Presenters/BasePresenter.php +++ b/App/Presenters/BasePresenter.php @@ -55,6 +55,7 @@ protected function beforeRender() } $this->template->currentTime = $this->gameClockService->get(); + $this->template->isTimeOverridden = $this->gameClockService->isOverridden(); if ($this->user->isAllowed(Resource::ADMIN_COMMON, Action::CHANGE_GAME_CLOCK) || $this->isImpersonated()) { $this->template->gameClockChange = true; $this->template->hasDatetimepicker = true; diff --git a/App/Presenters/templates/menu.latte b/App/Presenters/templates/menu.latte index 8e3d922..8c0b07b 100644 --- a/App/Presenters/templates/menu.latte +++ b/App/Presenters/templates/menu.latte @@ -135,7 +135,7 @@ {/if} -
+
Herní čas
{$currentTime|date: 'j. n. Y G:i:s'} diff --git a/App/Services/System/GameClockService.php b/App/Services/System/GameClockService.php index 9724ccc..a088ff1 100644 --- a/App/Services/System/GameClockService.php +++ b/App/Services/System/GameClockService.php @@ -48,6 +48,15 @@ public function get(): DateTimeImmutable return $current; } + /** + * Returns true if game time is overridden, false otherwise + * @return bool + */ + public function isOverridden(): bool + { + return $this->interval !== null; + } + /** * Sets game time from given datetime which should be considered as new now. *