Initial commit

This commit is contained in:
gamer147
2023-08-02 19:47:53 -04:00
commit 285a130a81
33 changed files with 1699 additions and 0 deletions

27
code/UI/Hud.razor Normal file
View File

@@ -0,0 +1,27 @@
@using Sandbox;
@using Sandbox.UI;
@using LuckerGame.UI.HudComponents
@using LuckerGame.UI.Menus
@namespace LuckerGame.UI
@inherits RootPanel
@attribute [StyleSheet]
<root>
<ChatBox/>
<VoiceList/>
<VotingLobby/>
<Scoreboard/>
<div class="pointer-visible" />
</root>
@code
{
public override void Tick()
{
var devCam = Game.LocalClient.Components.Get<DevCamera>();
SetClass( "camera-movement", Input.UsingController || Input.Down( "attack2" ) || devCam is not null );
}
}

30
code/UI/Hud.razor.scss Normal file
View File

@@ -0,0 +1,30 @@
$primary-color: 0, 123, 160;
$primary-color-translucent: rgba($primary-color, 0.7);
Hud
{
}
.primary-color-background {
background-color: rgb($primary-color);
}
.primary-color-translucent-background {
background-color: $primary-color-translucent;
}
label
{
font-family: Poppins;
color: white;
font-size: 32px;
&.subtitle
{
font-size: 16px;
}
&.header {
font-size: 48px;
}
&.material-icon {
font-family: "Material Icons";
}
}

View File

@@ -0,0 +1,29 @@
@using System
@using System.Collections.Generic
@using System.Linq
@using LuckerGame.Entities
@using Sandbox
@using Sandbox.UI
@namespace LuckerGame.UI.HudComponents
@attribute [StyleSheet]
@inherits Panel
<root>
<div class="scoreboard-panel">
@foreach (var player in Luckers)
{
<label>@player.Name</label>
}
</div>
</root>
@code {
private IReadOnlyCollection<Lucker> Luckers => Entity.All.OfType<Lucker>().ToList();
protected override int BuildHash()
{
return HashCode.Combine(Luckers.Select(player => player.Name).ToList());
}
}

View File

@@ -0,0 +1,3 @@
Scoreboard {
z-index: 0;
}

View File

@@ -0,0 +1,26 @@
@using System
@using Sandbox.Razor
@using Sandbox.UI
@inherits Panel
@attribute [StyleSheet]
@namespace LuckerGame.UI.MenuComponents
<root>
<div class="lucker-button">
@ChildContent
</div>
</root>
@code {
private RenderFragment _childContent;
public RenderFragment ChildContent
{
get { return _childContent; }
set { _childContent = value; StateHasChanged(); }
}
}

View File

@@ -0,0 +1,15 @@
LuckerButton {
div {
&.lucker-button {
z-index: 11;
cursor: pointer;
background-color: gray;
padding: 5px;
border-radius: 10px;
:hover {
opacity: 0.7;
}
}
}
}

View File

@@ -0,0 +1,9 @@
@using Sandbox.UI
@namespace LuckerGame.UI.MenuComponents
@inherits Panel
@attribute [StyleSheet]
<root>
<div class="loader"/>
</root>

View File

@@ -0,0 +1,20 @@
LuckerSpinner {
.loader {
width: 48px;
height: 48px;
border: 5px solid #FFF;
border-bottom-color: transparent;
border-radius: 50%;
animation-name: rotation;
animation-duration: 1s;
animation-iteration-count: infinite;
}
}
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@@ -0,0 +1,77 @@
@using System
@using System.Collections.Generic
@using System.Linq
@using LuckerGame.Entities
@using LuckerGame.Enums
@using Sandbox.UI;
@using Sandbox;
@using LuckerGame.UI.MenuComponents
@inherits Panel
@attribute [StyleSheet]
@namespace LuckerGame.UI.Menus
@if (RoundManager == null)
{
<root>
<div class="voting-panel primary-color-translucent-background">
<LuckerSpinner/>
</div>
</root>
return;
}
@if (RoundManager.RoundState == RoundState.InProgress)
{
return;
}
<root>
<div class="voting-panel primary-color-translucent-background">
@if (RoundManager.RoundState == RoundState.NotStarted)
{
<label class="header">Waiting for players...</label>
}
else
{
if (@RoundManager.SecondsLeftInCountdown > 0)
{
<label class="header">@RoundManager.SecondsLeftInCountdown</label>
}
else
{
<label class="header">Good luck!</label>
}
}
<div class="voters">
@foreach (var lucker in Luckers)
{
<div class="voter">
<label>@lucker.Name </label><label class="material-icon">@(lucker.Ready ? "done" : "close")</label>
</div>
}
</div>
<LuckerButton @onclick=@ReadyButtonPressed>
<ChildContent>
<label>@(Ready ? "Unready" : "Ready")</label>
</ChildContent>
</LuckerButton>
</div>
</root>
@code {
private List<Lucker> Luckers => Entity.All.OfType<Lucker>().ToList();
private RoundManager RoundManager => Entity.All.OfType<RoundManager>().FirstOrDefault();
private Lucker ThisLucker => Game.LocalClient.Pawn as Lucker;
private bool Ready => ThisLucker.Ready;
protected override int BuildHash()
{
return HashCode.Combine(Luckers.Select(lucker => lucker.Ready), Ready, RoundManager?.SecondsLeftInCountdown);
}
private void ReadyButtonPressed()
{
ConsoleSystem.Run("set_ready", !ThisLucker.Ready);
StateHasChanged();
}
}

View File

@@ -0,0 +1,43 @@
VotingLobby {
z-index: 10;
.label {
text-align: center;
}
.voting-panel {
gap: 10px;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
backdrop-filter: blur(10px);
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
pointer-events: all;
.header {
position: absolute;
top: 0;
}
LuckerButton {
position: absolute;
bottom: 0;
margin-bottom: 10px;
}
}
.voters {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.voter {
width: 100vw;
.label {
width: 100%;
}
}
}