Initial commit
This commit is contained in:
77
code/UI/Menus/VotingLobby.razor
Normal file
77
code/UI/Menus/VotingLobby.razor
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
43
code/UI/Menus/VotingLobby.razor.scss
Normal file
43
code/UI/Menus/VotingLobby.razor.scss
Normal 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%;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user