aboutsummaryrefslogtreecommitdiffstats
path: root/code/ui/phase/PhaseTimer.razor
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2023-07-27 22:11:31 +0100
committerLeonardo Bishop <me@leonardobishop.com>2023-07-27 22:11:31 +0100
commit71db52c5443a7bf82d9a23a770994a42b043be04 (patch)
treef75f2605bb1bdc53842cd85c90d105dcc77e1c10 /code/ui/phase/PhaseTimer.razor
Initial commit
Diffstat (limited to 'code/ui/phase/PhaseTimer.razor')
-rw-r--r--code/ui/phase/PhaseTimer.razor61
1 files changed, 61 insertions, 0 deletions
diff --git a/code/ui/phase/PhaseTimer.razor b/code/ui/phase/PhaseTimer.razor
new file mode 100644
index 0000000..1fb0baa
--- /dev/null
+++ b/code/ui/phase/PhaseTimer.razor
@@ -0,0 +1,61 @@
+@using Sandbox;
+@using System
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+phasetimer {
+ position: absolute;
+ top: 0;
+ width: 100%;
+ margin: 30px auto;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+.box {
+ background-color: rgba(0, 0, 0, 0.20);
+ backdrop-filter-blur: 8px;
+ padding: 5px;
+ color: white;
+ font-weight: 700;
+ font-size: 30px;
+ font-family: "Roboto";
+}
+</style>
+
+@if (HasTime())
+{
+<div class="box">
+ @GetTime()
+</div>
+} else
+{
+<div class="box">
+ @GetPhase()
+</div>
+}
+
+@code
+{
+ public bool HasTime()
+ {
+ return MurderGame.Instance.CurrentPhase.TimeLeft >= 0;
+ }
+ public string GetTime()
+ {
+ TimeSpan timeSpan = TimeSpan.FromSeconds(MurderGame.Instance.CurrentPhase.TimeLeft);
+ return timeSpan.ToString(@"mm\:ss");
+ }
+ public string GetPhase()
+ {
+ return MurderGame.Instance.CurrentPhase.Title;
+ }
+
+ protected override int BuildHash()
+ {
+ return HashCode.Combine(MurderGame.Instance.CurrentPhase.TimeLeft.GetHashCode(), MurderGame.Instance.CurrentPhase.Title.GetHashCode());
+ }
+}