diff options
Diffstat (limited to 'code/ui')
| -rw-r--r-- | code/ui/Hud.razor | 26 | ||||
| -rw-r--r-- | code/ui/Hud.razor.scss | 21 | ||||
| -rw-r--r-- | code/ui/PlayerInfo.razor | 41 | ||||
| -rw-r--r-- | code/ui/health/Health.razor | 38 | ||||
| -rw-r--r-- | code/ui/mainmenu/LoadingScreen.razor | 41 | ||||
| -rw-r--r-- | code/ui/mainmenu/LoadingScreen.razor.scss | 101 | ||||
| -rw-r--r-- | code/ui/mainmenu/MainMenu.razor | 30 | ||||
| -rw-r--r-- | code/ui/mainmenu/MainMenu.razor.scss | 257 | ||||
| -rw-r--r-- | code/ui/overlay/BlindedOverlay.Network.cs | 20 | ||||
| -rw-r--r-- | code/ui/overlay/BlindedOverlay.razor | 65 | ||||
| -rw-r--r-- | code/ui/overlay/RoleOverlay.cs | 20 | ||||
| -rw-r--r-- | code/ui/overlay/RoleOverlay.razor | 94 | ||||
| -rw-r--r-- | code/ui/phase/PhaseInfo.razor | 23 | ||||
| -rw-r--r-- | code/ui/phase/PhaseTimer.razor | 61 | ||||
| -rw-r--r-- | code/ui/team/TeamInfo.razor | 37 | ||||
| -rw-r--r-- | code/ui/weapon/Crosshair.razor | 23 | ||||
| -rw-r--r-- | code/ui/weapon/Reload.razor | 82 |
17 files changed, 980 insertions, 0 deletions
diff --git a/code/ui/Hud.razor b/code/ui/Hud.razor new file mode 100644 index 0000000..6ea6103 --- /dev/null +++ b/code/ui/Hud.razor @@ -0,0 +1,26 @@ +@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits RootPanel
+@attribute [StyleSheet]
+<style>
+.hidden {
+ display: none;
+}
+</style>
+
+<root>
+ <BlindedOverlay/>
+ <RoleOverlay/>
+ <ChatBox/>
+ <VoiceList/>
+ <PhaseTimer/>
+ <Crosshair/>
+ <Reload/>
+ <PlayerInfo/>
+</root>
+
+@code
+{
+}
\ No newline at end of file diff --git a/code/ui/Hud.razor.scss b/code/ui/Hud.razor.scss new file mode 100644 index 0000000..fe07ac5 --- /dev/null +++ b/code/ui/Hud.razor.scss @@ -0,0 +1,21 @@ +Hud
+{
+ .header
+ {
+ left: 128px;
+ top: 128px;
+ flex-direction: column;
+
+ label
+ {
+ font-family: Roboto;
+ color: white;
+ font-size: 32px;
+
+ &.subtitle
+ {
+ font-size: 16px;
+ }
+ }
+ }
+}
diff --git a/code/ui/PlayerInfo.razor b/code/ui/PlayerInfo.razor new file mode 100644 index 0000000..53a71df --- /dev/null +++ b/code/ui/PlayerInfo.razor @@ -0,0 +1,41 @@ +@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+ playerinfo {
+ position: absolute;
+ left: 30px;
+ bottom: 30px;
+ background-color: rgba(0, 0, 0, 0.20);
+ backdrop-filter-blur: 8px;
+ display: flex;
+ align-items: center;
+ flex-direction: row;
+ gap: 10px;
+ padding: 10px;
+ }
+</style>
+
+<Health Colour="@GetTeamColour()"></Health>
+<TeamInfo Colour="@GetTeamColour()"></TeamInfo>
+
+@code
+{
+ public string GetTeamColour()
+ {
+ var ClientPawn = Game.LocalPawn;
+ if (ClientPawn is Player)
+ {
+ return TeamOperations.GetTeamColour(((Player)ClientPawn).CurrentTeam);
+ }
+ return "";
+ }
+
+ protected override int BuildHash()
+ {
+ return GetTeamColour().GetHashCode();
+ }
+}
diff --git a/code/ui/health/Health.razor b/code/ui/health/Health.razor new file mode 100644 index 0000000..9d7037b --- /dev/null +++ b/code/ui/health/Health.razor @@ -0,0 +1,38 @@ +@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+Health {
+ width: 400px;
+ height: 100%;
+ background-color: rgba(0, 0, 0, 0.90);
+}
+.fill {
+ height: 100%;
+ transition: width 0.2s ease-out;
+}
+</style>
+<div class="fill" style="background-color: @(Colour); width: @(GetHealth())%;"></div>
+
+@code
+{
+ public string Colour { get; set; }
+
+ public int GetHealth()
+ {
+ var ClientPawn = Game.LocalPawn;
+ if (ClientPawn is Player)
+ {
+ return ClientPawn.Health.CeilToInt();
+ }
+ return 0;
+ }
+
+ protected override int BuildHash()
+ {
+ return GetHealth().GetHashCode();
+ }
+}
diff --git a/code/ui/mainmenu/LoadingScreen.razor b/code/ui/mainmenu/LoadingScreen.razor new file mode 100644 index 0000000..9e3e5ae --- /dev/null +++ b/code/ui/mainmenu/LoadingScreen.razor @@ -0,0 +1,41 @@ +@using System
+@using Sandbox;
+@using Sandbox.UI;
+@using Sandbox.Menu;
+@attribute [StyleSheet]
+@inherits RootPanel
+@namespace DmMenu
+@implements Sandbox.Menu.ILoadingScreenPanel
+
+<root class="loadingpanel">
+
+ <div class="title">LOADING</div>
+ <div class="subtitle">@Progress.Title</div>
+
+ @if (Progress.Fraction > 0)
+ {
+ <div class="progress">
+ <div class="bar" style="width: @(Progress.Percent)%;"></div>
+ <div class="text-left">@(Progress.Percent.ToString("0") )%</div>
+ <div class="text-right"><span>@(Progress.Mbps.ToString("0"))</span><span class="unit">Mbps</span></div>
+ </div>
+ }
+
+ <div class="controls">
+ <div class="button" onclick="@Game.Menu.CancelLoading">
+ Cancel
+ </div>
+ </div>
+
+</root>
+
+@code
+{
+ public LoadingProgress Progress;
+
+ public void OnLoadingProgress( LoadingProgress progress )
+ {
+ Progress = progress;
+ StateHasChanged();
+ }
+}
\ No newline at end of file diff --git a/code/ui/mainmenu/LoadingScreen.razor.scss b/code/ui/mainmenu/LoadingScreen.razor.scss new file mode 100644 index 0000000..894d259 --- /dev/null +++ b/code/ui/mainmenu/LoadingScreen.razor.scss @@ -0,0 +1,101 @@ +.loadingpanel
+{
+ background-image: url( "menu/boxes.webm" );
+ background-position: center;
+ background-size: cover;
+ background-tint: #555;
+ width: 100%;
+ height: 100%;
+ color: white;
+ padding: 100px;
+ justify-content: center;
+ align-items: center;
+ flex-direction: column;
+ font-family: Poppins;
+ pointer-events: all;
+ color: #ccc;
+
+ > .title
+ {
+ font-size: 80px;
+ font-weight: bolder;
+ }
+
+ > .subtitle
+ {
+ font-size: 30px;
+ color: #aaa;
+ font-weight: 200;
+ }
+
+ > .controls
+ {
+ position: absolute;
+ bottom: 100px;
+ right: 200px;
+
+ .button
+ {
+ font-size: 20px;
+ padding: 10px 50px;
+ background-color: #666;
+ color: #111;
+ font-weight: bold;
+ cursor: pointer;
+
+ &:hover
+ {
+ background-color: #888;
+ }
+ }
+ }
+
+ > .progress
+ {
+ margin: 50px 0px;
+ background-color: #0003;
+ width: 500px;
+ border-radius: 5px;
+ overflow: hidden;
+
+ .bar
+ {
+ background-color: #fff1;
+ position: absolute;
+ height: 100%;
+ }
+
+ .text-left
+ {
+ flex-grow: 1;
+ flex-shrink: 0;
+ }
+
+ .text-right
+ {
+ flex-shrink: 0;
+ }
+
+ .text-left, .text-right
+ {
+ padding: 5px 20px;
+ white-space: nowrap;
+ font-weight: bold;
+ opacity: 0.2;
+ font-size: 20px;
+ align-items: flex-end;
+
+ .unit
+ {
+ font-size: 15px;
+ opacity: 0.5;
+ }
+ }
+ }
+}
+
+choosemappage.navigator-body
+{
+ margin: 0;
+ padding: 0;
+}
\ No newline at end of file diff --git a/code/ui/mainmenu/MainMenu.razor b/code/ui/mainmenu/MainMenu.razor new file mode 100644 index 0000000..ffca318 --- /dev/null +++ b/code/ui/mainmenu/MainMenu.razor @@ -0,0 +1,30 @@ +@using System
+@using Sandbox;
+@using Sandbox.MenuSystem;
+@using Sandbox.UI;
+@attribute [StyleSheet]
+@inherits Sandbox.UI.GameMenu.DefaultGameMenu
+
+<style>
+.wip-warning {
+ position: absolute;
+ z-index: 1000000;
+ background-color: #FF4136;
+ font-family: 'Roboto';
+ font-size: 40px;
+ width: 100%;
+ font-weight: 700;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+</style>
+<root class="gamemainmenu">
+
+
+ <div class="wip-warning">Work in progress! Expect bugs, missing features, and general weird-ness. Things *will* break.</div>
+
+ <div class="navigator-canvas" slot="navigator-canvas"></div>
+
+
+</root>
diff --git a/code/ui/mainmenu/MainMenu.razor.scss b/code/ui/mainmenu/MainMenu.razor.scss new file mode 100644 index 0000000..cbedff5 --- /dev/null +++ b/code/ui/mainmenu/MainMenu.razor.scss @@ -0,0 +1,257 @@ +
+.gamemainmenu
+{
+ background-image: url( "menu/boxes.webm" );
+ background-position: center;
+ background-size: cover;
+ opacity: 1;
+ flex-direction: column;
+ font-size: 25px;
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ transition: all 0.3s ease-out;
+ color: white;
+
+ &:intro
+ {
+ opacity: 0;
+ transform: scaleX( 1.1 );
+ }
+
+ &.ingame
+ {
+ background-color: #151313ee;
+ background-image: none;
+ }
+
+}
+
+.button, .block
+{
+ padding: 4px 16px;
+
+ opacity: 0.8;
+
+ font-size: 28px;
+ font-family: Poppins;
+ font-weight: 700;
+ flex-shrink: 0;
+}
+
+.button
+{
+ background-color: #000a;
+ cursor: pointer;
+
+ &:hover
+ {
+ opacity: 1;
+ }
+
+ &:active
+ {
+ left: 2px;
+ top: 3px;
+ }
+}
+
+
+.gamemainmenu .navigator-canvas
+{
+ height: 100%;
+ flex-grow: 1;
+ flex-shrink: 0;
+ backdrop-filter: blur( 20px );
+ padding: 0px 100px;
+
+ .navigator-body
+ {
+ width: 100%;
+ height: 100%;
+ flex-direction: column;
+ padding: 100px 0px;
+ }
+}
+
+section
+{
+ flex-direction: column;
+ flex-grow: 1;
+ flex-shrink: 0;
+
+ &.nogrow
+ {
+ flex-grow: 0;
+ }
+
+ &.box
+ {
+ background-color: rgba( black, 0.5 );
+
+ }
+}
+
+.scroll
+{
+ overflow-y: scroll;
+ flex-shrink: 1;
+ flex-grow: 0;
+}
+
+h2
+{
+ font-family: poppins;
+ font-weight: 400;
+ opacity: 0.2;
+ margin-bottom: 16px;
+ flex-shrink: 0;
+}
+
+.member-list
+{
+ overflow-x: scroll;
+ padding: 20px;
+ gap: 8px;
+}
+
+
+
+.hidden
+{
+ display: none;
+}
+
+.inset
+{
+ overflow: hidden;
+}
+
+.layout
+{
+ flex-direction: column;
+
+ > *
+ {
+ flex-shrink: 0;
+ }
+
+ > .body
+ {
+ flex-grow: 1;
+ flex-shrink: 0;
+ flex-direction: column;
+
+ &.columned
+ {
+ flex-direction: row;
+ flex-grow: 1;
+ flex-shrink: 1;
+ justify-content: space-around;
+ align-items: center;
+
+ > .left
+ {
+ flex-grow: 0;
+ flex-shrink: 0;
+ overflow-y: scroll;
+ flex-direction: column;
+ }
+
+ > .right
+ {
+ flex-grow: 0;
+ flex-shrink: 0;
+ flex-direction: column;
+ }
+ }
+ }
+}
+
+.navbar
+{
+ padding: 32px 0;
+ flex-shrink: 0;
+
+ .right, .left
+ {
+ flex-grow: 0;
+ flex-shrink: 0;
+ gap: 10px;
+ }
+
+ .left
+ {
+ flex-grow: 1;
+ }
+}
+
+$form-row-height: 48px;
+
+.form
+{
+ flex-direction: column;
+ flex-shrink: 0;
+ flex-grow: 0;
+ gap: 2px;
+ margin-bottom: 50px;
+
+ > .form-group
+ {
+ flex-direction: column;
+ flex-shrink: 0;
+ margin-bottom: 20px;
+
+ > .form-label
+ {
+ opacity: 0.5;
+ height: $form-row-height;
+ font-size: 20px;
+ white-space: nowrap;
+ }
+ }
+}
+
+.form .form-control
+{
+ flex-grow: 1;
+
+ SliderControl, > DropDown, > textentry, SliderControl textentry
+ {
+ flex-grow: 1;
+ font-size: 20px;
+ height: $form-row-height;
+ }
+
+ > textentry, SliderControl textentry
+ {
+ flex-grow: 1;
+ background-color: #ffffff05;
+ height: $form-row-height;
+ color: #aaa;
+ width: 600px;
+ border-radius: 0;
+ padding: 5px;
+
+ &:hover
+ {
+ background-color: #ffffff11;
+ }
+
+ &:focus
+ {
+ background-color: #ffffff22;
+ color: #fff;
+ }
+ }
+
+ SliderControl
+ {
+
+ }
+}
+
+choosemappage.navigator-body
+{
+ padding: 0;
+}
\ No newline at end of file diff --git a/code/ui/overlay/BlindedOverlay.Network.cs b/code/ui/overlay/BlindedOverlay.Network.cs new file mode 100644 index 0000000..c81751e --- /dev/null +++ b/code/ui/overlay/BlindedOverlay.Network.cs @@ -0,0 +1,20 @@ +using Sandbox;
+
+namespace MurderGame;
+
+public partial class BlindedOverlay
+{
+ [ClientRpc]
+ public static void Show( )
+ {
+ Instance.SetClass( "hidden", false );
+ Instance.ShowOverlay = true;
+ }
+
+ [ClientRpc]
+ public static void Hide()
+ {
+ Instance.SetClass( "hidden", true );
+ Instance.ShowOverlay = false;
+ }
+}
diff --git a/code/ui/overlay/BlindedOverlay.razor b/code/ui/overlay/BlindedOverlay.razor new file mode 100644 index 0000000..024c31a --- /dev/null +++ b/code/ui/overlay/BlindedOverlay.razor @@ -0,0 +1,65 @@ +@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+ @@keyframes fadeIn
+ {
+ 0% { opacity: 0; }
+ 100% { opacity: 1; }
+ }
+ blindedoverlay
+ {
+ position: absolute;
+ left: 0;
+ top: 0;
+ background-color: rgba(0, 0, 0, 0.80);
+ width: 100vw;
+ height: 100vh;
+ backdrop-filter-blur: 16px;
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ flex-direction: column;
+ gap: 100vh;
+ animation-name: fadeIn;
+ animation-duration: 1s;
+ animation-iteration-count: 1;
+ animation-timing-function: linear;
+ animation-fill-mode: forwards;
+ }
+ .overlay-message
+ {
+ margin: 20vh;
+ color: white;
+ font-size: 35px;
+ font-family: "Roboto";
+ font-weight: 700;
+ }
+</style>
+
+<div class="overlay-message">
+You shot a bystander!
+</div>
+
+@code
+{
+ public static BlindedOverlay Instance { get; private set; }
+
+ public bool ShowOverlay { get; set; } = false;
+
+ public BlindedOverlay()
+ {
+ SetClass( "hidden", true );
+
+ Instance = this;
+ }
+
+ protected override int BuildHash()
+ {
+ return ShowOverlay.GetHashCode();
+ }
+
+}
\ No newline at end of file diff --git a/code/ui/overlay/RoleOverlay.cs b/code/ui/overlay/RoleOverlay.cs new file mode 100644 index 0000000..84758b7 --- /dev/null +++ b/code/ui/overlay/RoleOverlay.cs @@ -0,0 +1,20 @@ +using Sandbox;
+
+namespace MurderGame;
+
+public partial class RoleOverlay
+{
+ [ClientRpc]
+ public static void Show( )
+ {
+ Instance.SetClass( "hidden", false );
+ Instance.ShowOverlay = true;
+ }
+
+ [ClientRpc]
+ public static void Hide()
+ {
+ Instance.SetClass( "hidden", true );
+ Instance.ShowOverlay = false;
+ }
+}
diff --git a/code/ui/overlay/RoleOverlay.razor b/code/ui/overlay/RoleOverlay.razor new file mode 100644 index 0000000..c41e359 --- /dev/null +++ b/code/ui/overlay/RoleOverlay.razor @@ -0,0 +1,94 @@ +
+@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+ roleoverlay
+ {
+ position: absolute;
+ left: 0;
+ top: 0;
+ background-color: #000000;
+ width: 100vw;
+ height: 100vh;
+ z-index: 10000;
+ }
+ .container {
+ display: flex;
+ align-items: center;
+ flex-direction: column;
+ max-width: 700px;
+ text-align: center;
+ gap: 50px;
+ margin: 0 auto;
+ top: 200px;
+ }
+ .name
+ {
+ font-size: 50;
+ font-weight: 700;
+ font-family: "Roboto";
+ }
+ .description
+ {
+ font-size: 30;
+ font-family: "Roboto";
+ }
+</style>
+
+<div class="container">
+ <div class="name" style="color: @(GetTeamColour())">
+ @GetTeamName()
+ </div>
+ <div class="description" style="color: @(GetTeamColour())">
+ @GetTeamDescription()
+ </div>
+</div>
+
+@code
+{
+ public string GetTeamName()
+ {
+ if (Game.LocalPawn is Player player)
+ {
+ return TeamOperations.GetTeamName(player.CurrentTeam);
+ }
+ return "";
+ }
+ public string GetTeamDescription()
+ {
+ if (Game.LocalPawn is Player player)
+ {
+ return TeamOperations.GetTeamDescription(player.CurrentTeam);
+ }
+ return "";
+ }
+ public string GetTeamColour()
+ {
+ if (Game.LocalPawn is Player player)
+ {
+ return TeamOperations.GetTeamColour(player.CurrentTeam);
+ }
+ return "";
+ }
+
+ public static RoleOverlay Instance { get; private set; }
+
+ public bool ShowOverlay { get; set; } = false;
+
+ public RoleOverlay()
+ {
+ SetClass( "hidden", true );
+
+ Instance = this;
+ }
+
+ protected override int BuildHash()
+ {
+ return ShowOverlay.GetHashCode();
+ }
+
+}
diff --git a/code/ui/phase/PhaseInfo.razor b/code/ui/phase/PhaseInfo.razor new file mode 100644 index 0000000..74bf237 --- /dev/null +++ b/code/ui/phase/PhaseInfo.razor @@ -0,0 +1,23 @@ +@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+@attribute [StyleSheet]
+
+<div>
+ @GetPhase().Title
+</div>
+
+@code
+{
+ public BasePhase GetPhase()
+ {
+ return MurderGame.Instance.CurrentPhase;
+ }
+
+ protected override int BuildHash() + { + return GetPhase().GetHashCode(); + }
+}
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()); + }
+}
diff --git a/code/ui/team/TeamInfo.razor b/code/ui/team/TeamInfo.razor new file mode 100644 index 0000000..18e1f7f --- /dev/null +++ b/code/ui/team/TeamInfo.razor @@ -0,0 +1,37 @@ +@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+.team-info {
+ font-size: 35px;
+ font-weight: 700;
+ font-family: "Roboto";
+}
+</style>
+
+<div class="team-info" style="color: @(Colour)">
+@GetTeamName()
+</div>
+
+@code
+{
+ public string Colour { get; set; }
+
+ public string GetTeamName()
+ {
+ var ClientPawn = Game.LocalPawn;
+ if (ClientPawn is Player)
+ {
+ return TeamOperations.GetTeamName(((Player)ClientPawn).CurrentTeam);
+ }
+ return "";
+ }
+
+ protected override int BuildHash()
+ {
+ return GetTeamName().GetHashCode();
+ }
+}
diff --git a/code/ui/weapon/Crosshair.razor b/code/ui/weapon/Crosshair.razor new file mode 100644 index 0000000..2dc5db1 --- /dev/null +++ b/code/ui/weapon/Crosshair.razor @@ -0,0 +1,23 @@ +@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+crosshair {
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ transform: translate(-50%, -50%);
+}
+.dot {
+ border-radius: 3px;
+ width: 6px;
+ height: 6px;
+ background-color: white;
+}
+</style>
+
+<div class="dot"></div>
+
diff --git a/code/ui/weapon/Reload.razor b/code/ui/weapon/Reload.razor new file mode 100644 index 0000000..d325ade --- /dev/null +++ b/code/ui/weapon/Reload.razor @@ -0,0 +1,82 @@ +@using Sandbox;
+@using Sandbox.UI;
+@using System;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+@@keyframes blink {
+ 0% {
+ background-color: rgba(0, 0, 0, 0.20);
+ }
+ 49% {
+ background-color: rgba(0, 0, 0, 0.20);
+ }
+ 50% {
+ background-color: rgba(255, 0, 0, 0.20);
+ }
+ 100% {
+ background-color: rgba(255, 0, 0, 0.20);
+ }
+}
+reload {
+ width: 100vw;
+ height: 100vh;
+}
+.box {
+ position: absolute;
+ left: 47%;
+ top: 60%;
+ width: 6%;
+ backdrop-filter-blur: 8px;
+ background-color: rgba(0, 0, 0, 0.20);
+ padding: 5px;
+ color: white;
+ font-weight: 700;
+ font-size: 30px;
+ font-family: "Roboto";
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+.blink {
+ animation-name: blink;
+ animation-duration: 0.33s;
+}
+</style>
+
+@if (ReloadNeeded) {
+<!--<div class="box @(@Blink ? "blink" : "")">-->
+<div class="box blink">
+ <div>Reload</div>
+</div>
+}
+
+@code
+{
+ public bool ReloadNeeded { get; set; }
+ public bool Blink { get; set; }
+
+ protected override int BuildHash()
+ {
+ var localPawn = Game.LocalPawn;
+ if (localPawn is Player player)
+ {
+ var inventory = player.Inventory;
+ if (inventory != null && inventory.GetCurrentWeapon() != null)
+ {
+ var weapon = inventory.GetCurrentWeapon();
+ var ammo = weapon.Ammo;
+ ReloadNeeded = ammo == 0 && !weapon.Reloading;
+ Blink = !weapon.Reloading;
+ return HashCode.Combine(ReloadNeeded.GetHashCode(), Blink.GetHashCode());
+ }
+ }
+ if (ReloadNeeded)
+ {
+ ReloadNeeded = false;
+ }
+ return ReloadNeeded.GetHashCode();
+ }
+}
|
