From 71db52c5443a7bf82d9a23a770994a42b043be04 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Thu, 27 Jul 2023 22:11:31 +0100 Subject: Initial commit --- code/ui/Hud.razor | 26 +++ code/ui/Hud.razor.scss | 21 +++ code/ui/PlayerInfo.razor | 41 +++++ code/ui/health/Health.razor | 38 +++++ code/ui/mainmenu/LoadingScreen.razor | 41 +++++ code/ui/mainmenu/LoadingScreen.razor.scss | 101 ++++++++++++ code/ui/mainmenu/MainMenu.razor | 30 ++++ code/ui/mainmenu/MainMenu.razor.scss | 257 ++++++++++++++++++++++++++++++ code/ui/overlay/BlindedOverlay.Network.cs | 20 +++ code/ui/overlay/BlindedOverlay.razor | 65 ++++++++ code/ui/overlay/RoleOverlay.cs | 20 +++ code/ui/overlay/RoleOverlay.razor | 94 +++++++++++ code/ui/phase/PhaseInfo.razor | 23 +++ code/ui/phase/PhaseTimer.razor | 61 +++++++ code/ui/team/TeamInfo.razor | 37 +++++ code/ui/weapon/Crosshair.razor | 23 +++ code/ui/weapon/Reload.razor | 82 ++++++++++ 17 files changed, 980 insertions(+) create mode 100644 code/ui/Hud.razor create mode 100644 code/ui/Hud.razor.scss create mode 100644 code/ui/PlayerInfo.razor create mode 100644 code/ui/health/Health.razor create mode 100644 code/ui/mainmenu/LoadingScreen.razor create mode 100644 code/ui/mainmenu/LoadingScreen.razor.scss create mode 100644 code/ui/mainmenu/MainMenu.razor create mode 100644 code/ui/mainmenu/MainMenu.razor.scss create mode 100644 code/ui/overlay/BlindedOverlay.Network.cs create mode 100644 code/ui/overlay/BlindedOverlay.razor create mode 100644 code/ui/overlay/RoleOverlay.cs create mode 100644 code/ui/overlay/RoleOverlay.razor create mode 100644 code/ui/phase/PhaseInfo.razor create mode 100644 code/ui/phase/PhaseTimer.razor create mode 100644 code/ui/team/TeamInfo.razor create mode 100644 code/ui/weapon/Crosshair.razor create mode 100644 code/ui/weapon/Reload.razor (limited to 'code/ui') 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] + + + + + + + + + + + + + +@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 + + + + + + +@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 + + +
+ +@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 + + + +
LOADING
+
@Progress.Title
+ + @if (Progress.Fraction > 0) + { +
+
+
@(Progress.Percent.ToString("0") )%
+
@(Progress.Mbps.ToString("0"))Mbps
+
+ } + +
+
+ Cancel +
+
+ +
+ +@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 + + + + + +
Work in progress! Expect bugs, missing features, and general weird-ness. Things *will* break.
+ + + + +
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 + + + +
+You shot a bystander! +
+ +@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 + + + +
+
+ @GetTeamName() +
+
+ @GetTeamDescription() +
+
+ +@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] + +
+ @GetPhase().Title +
+ +@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 + + + +@if (HasTime()) +{ +
+ @GetTime() +
+} else +{ +
+ @GetPhase() +
+} + +@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 + + + +
+@GetTeamName() +
+ +@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 + + + +
+ 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 + + + +@if (ReloadNeeded) { + + +} + +@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(); + } +} -- cgit v1.2.3-70-g09d2