diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-08-06 17:21:45 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-08-06 17:21:45 +0100 |
| commit | 0bba89a7858ce091f485e04284f853e1f7f304af (patch) | |
| tree | 89ba42616e0f245cc84c96cc5b353eea117057d0 /code/ui/overlay | |
| parent | 87d74b50bf443bf199be05bd03afdca6ece082ff (diff) | |
Diffstat (limited to 'code/ui/overlay')
| -rw-r--r-- | code/ui/overlay/BlindedOverlay.Network.cs | 24 | ||||
| -rw-r--r-- | code/ui/overlay/BlindedOverlay.razor | 9 | ||||
| -rw-r--r-- | code/ui/overlay/DeathOverlay.Network.cs | 26 | ||||
| -rw-r--r-- | code/ui/overlay/DeathOverlay.razor | 29 | ||||
| -rw-r--r-- | code/ui/overlay/RoleOverlay.Network.cs | 24 | ||||
| -rw-r--r-- | code/ui/overlay/RoleOverlay.razor | 13 | ||||
| -rw-r--r-- | code/ui/overlay/TabListEntry.cs | 20 | ||||
| -rw-r--r-- | code/ui/overlay/TabListOverlay.razor | 61 |
8 files changed, 104 insertions, 102 deletions
diff --git a/code/ui/overlay/BlindedOverlay.Network.cs b/code/ui/overlay/BlindedOverlay.Network.cs index 0a80628..83569ea 100644 --- a/code/ui/overlay/BlindedOverlay.Network.cs +++ b/code/ui/overlay/BlindedOverlay.Network.cs @@ -4,17 +4,17 @@ namespace MurderGame; public partial class BlindedOverlay
{
- [ClientRpc]
- public static void Show( )
- {
- Instance.SetClass( "hidden", false );
- Instance.ShowOverlay = true;
- }
+ [ClientRpc]
+ public static void Show()
+ {
+ Instance.SetClass( "hidden", false );
+ Instance.ShowOverlay = true;
+ }
- [ClientRpc]
- public static void Hide()
- {
- Instance.SetClass( "hidden", true );
- Instance.ShowOverlay = false;
- }
+ [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 index 0cd397a..3afe578 100644 --- a/code/ui/overlay/BlindedOverlay.razor +++ b/code/ui/overlay/BlindedOverlay.razor @@ -1,8 +1,5 @@ -@using Sandbox;
-@using Sandbox.UI;
-
@namespace MurderGame
-@inherits Panel
+@inherits Sandbox.UI.Panel
<style>
@@keyframes fadeIn
@@ -41,7 +38,7 @@ blindedoverlay </style>
<div class="overlay-message">
-You shot a bystander!
+ You shot a bystander!
</div>
@code
@@ -52,7 +49,7 @@ You shot a bystander! public BlindedOverlay()
{
- SetClass( "hidden", true );
+ SetClass("hidden", true);
Instance = this;
}
diff --git a/code/ui/overlay/DeathOverlay.Network.cs b/code/ui/overlay/DeathOverlay.Network.cs index f1f3bb2..33e354c 100644 --- a/code/ui/overlay/DeathOverlay.Network.cs +++ b/code/ui/overlay/DeathOverlay.Network.cs @@ -4,15 +4,21 @@ namespace MurderGame; public partial class DeathOverlay
{
- [ClientRpc]
- public static void Show( )
- {
- if (Instance != null) Instance.ShowOverlay = true;
- }
+ [ClientRpc]
+ public static void Show()
+ {
+ if ( Instance != null )
+ {
+ Instance.ShowOverlay = true;
+ }
+ }
- [ClientRpc]
- public static void Hide()
- {
- if (Instance != null) Instance.ShowOverlay = false;
- }
+ [ClientRpc]
+ public static void Hide()
+ {
+ if ( Instance != null )
+ {
+ Instance.ShowOverlay = false;
+ }
+ }
}
diff --git a/code/ui/overlay/DeathOverlay.razor b/code/ui/overlay/DeathOverlay.razor index 23c3a17..7751a38 100644 --- a/code/ui/overlay/DeathOverlay.razor +++ b/code/ui/overlay/DeathOverlay.razor @@ -1,8 +1,5 @@ -@using Sandbox;
-@using Sandbox.UI;
-
@namespace MurderGame
-@inherits Panel
+@inherits Sandbox.UI.Panel
<style>
@@keyframes fadeIn
@@ -72,15 +69,15 @@ deathoverlay { @if (ShowOverlay)
{
-<div class="overlay fade">
-</div>
-<div class="overlay blur">
-</div>
-<div class="box-container">
- <div class="box">
- You have died
- </div>
-</div>
+ <div class="overlay fade">
+ </div>
+ <div class="overlay blur">
+ </div>
+ <div class="box-container">
+ <div class="box">
+ You have died
+ </div>
+ </div>
}
@code
@@ -92,10 +89,10 @@ deathoverlay { Instance = this;
}
- public bool ShowOverlay { get; set; }
+ public bool ShowOverlay { get; set; }
- protected override int BuildHash()
- {
+ protected override int BuildHash()
+ {
return ShowOverlay.GetHashCode();
}
diff --git a/code/ui/overlay/RoleOverlay.Network.cs b/code/ui/overlay/RoleOverlay.Network.cs index 300d0bf..be69c24 100644 --- a/code/ui/overlay/RoleOverlay.Network.cs +++ b/code/ui/overlay/RoleOverlay.Network.cs @@ -4,17 +4,17 @@ namespace MurderGame; public partial class RoleOverlay
{
- [ClientRpc]
- public static void Show( )
- {
- Instance.SetClass( "hidden", false );
- Instance.ShowOverlay = true;
- }
+ [ClientRpc]
+ public static void Show()
+ {
+ Instance.SetClass( "hidden", false );
+ Instance.ShowOverlay = true;
+ }
- [ClientRpc]
- public static void Hide()
- {
- Instance.SetClass( "hidden", true );
- Instance.ShowOverlay = false;
- }
+ [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 index cd3cd88..3afce0c 100644 --- a/code/ui/overlay/RoleOverlay.razor +++ b/code/ui/overlay/RoleOverlay.razor @@ -1,9 +1,6 @@ -
-@using Sandbox;
-@using Sandbox.UI;
-
@namespace MurderGame
-@inherits Panel
+@using Sandbox
+@inherits Sandbox.UI.Panel
<style>
roleoverlay
@@ -58,6 +55,7 @@ roleoverlay }
return "";
}
+
public string GetTeamDescription()
{
if (Game.LocalPawn is Player player)
@@ -66,6 +64,7 @@ roleoverlay }
return "";
}
+
public string GetTeamColour()
{
if (Game.LocalPawn is Player player)
@@ -81,7 +80,7 @@ roleoverlay public RoleOverlay()
{
- SetClass( "hidden", true );
+ SetClass("hidden", true);
Instance = this;
}
@@ -91,4 +90,4 @@ roleoverlay return ShowOverlay.GetHashCode();
}
-}
+}
\ No newline at end of file diff --git a/code/ui/overlay/TabListEntry.cs b/code/ui/overlay/TabListEntry.cs index b4d7769..5f78f55 100644 --- a/code/ui/overlay/TabListEntry.cs +++ b/code/ui/overlay/TabListEntry.cs @@ -6,14 +6,13 @@ namespace MurderGame; public class TabListEntry : Panel
{
-
public IClient Client;
+ public Label Ping;
public Label PlayerName;
- public Label Ping;
-
- RealTimeSince TimeSinceUpdate = 0;
-
+
+ private RealTimeSince TimeSinceUpdate = 0;
+
public TabListEntry()
{
AddClass( "entry" );
@@ -27,28 +26,33 @@ public class TabListEntry : Panel base.Tick();
if ( !IsVisible )
+ {
return;
+ }
if ( !Client.IsValid() )
+ {
return;
+ }
if ( TimeSinceUpdate < 0.1f )
+ {
return;
+ }
TimeSinceUpdate = 0;
UpdateData();
}
-
+
public virtual void UpdateData()
{
PlayerName.Text = Client.Name;
Ping.Text = Client.Ping.ToString();
}
-
+
public virtual void UpdateFrom( IClient client )
{
Client = client;
UpdateData();
}
-
}
diff --git a/code/ui/overlay/TabListOverlay.razor b/code/ui/overlay/TabListOverlay.razor index d240c9e..82c0959 100644 --- a/code/ui/overlay/TabListOverlay.razor +++ b/code/ui/overlay/TabListOverlay.razor @@ -1,11 +1,10 @@ <!-- this class is temporary and will be replaced with a proper scoreboard -->
+@namespace MurderGame
@using System.Collections.Generic
@using System.Linq
-@using Sandbox;
-@using Sandbox.UI;
-
-@namespace MurderGame
+@using Sandbox
+@using Sandbox.UI
@inherits Panel
<style>
@@ -75,27 +74,27 @@ tablistoverlay { </style>
<div class="container">
- <div class="tablist-header">
- <span class="text-header">Murder</span>
- <span class="text-aside" style="color: #FF4136">This game mode is still a work in progress. Source code available at https://github.com/LMBishop/murder.</span>
- </div>
+ <div class="tablist-header">
+ <span class="text-header">Murder</span>
+ <span class="text-aside" style="color: #FF4136">This game mode is still a work in progress. Source code available at https://github.com/LMBishop/murder.</span>
+ </div>
- <div class="list">
- <div class="list-header">
- <span class="name">Name</span>
- <span class="ping">Ping</span>
- </div>
+ <div class="list">
+ <div class="list-header">
+ <span class="name">Name</span>
+ <span class="ping">Ping</span>
+ </div>
- <div class="list-content" @ref="List">
+ <div class="list-content" @ref="List">
- </div>
- </div>
+ </div>
+ </div>
</div>
@code
{
- Dictionary<IClient, TabListEntry> Entries = new();
-
+ readonly Dictionary<IClient, TabListEntry> Entries = new();
+
public Panel List { get; set; }
public static TabListOverlay Instance { get; private set; }
@@ -105,38 +104,38 @@ tablistoverlay { Instance = this;
}
- public bool IsOpen => Input.Down( "score" );
+ public bool IsOpen => Input.Down("score");
public override void Tick()
{
base.Tick();
- SetClass( "hidden", !IsOpen );
+ SetClass("hidden", !IsOpen);
- if ( !IsVisible )
+ if (!IsVisible)
return;
- foreach ( IClient cl in Game.Clients.Except( Entries.Keys ) )
+ foreach (var cl in Game.Clients.Except(Entries.Keys))
{
TabListEntry entry = new();
Entries.Add(cl, entry);
entry.UpdateFrom(cl);
- entry.Parent = List;
+ entry.Parent = List;
}
- foreach ( IClient cl in Entries.Keys.Except( Game.Clients ) )
+ foreach (var cl in Entries.Keys.Except(Game.Clients))
{
- if( Entries.TryGetValue( cl, out var entry ) )
+ if (Entries.TryGetValue(cl, out var entry))
{
entry.Delete();
- Entries.Remove( cl );
+ Entries.Remove(cl);
}
}
-
- // foreach ( var entry in Entries )
- // {
- // entry.Value.Parent = List;
- // }
+
+ // foreach ( var entry in Entries )
+ // {
+ // entry.Value.Parent = List;
+ // }
}
}
\ No newline at end of file |
