diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-07-31 02:37:57 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-07-31 02:42:42 +0100 |
| commit | 6d38a73a43db7eec57cecf980eebe6e610df4de4 (patch) | |
| tree | fe4aa66a7ab1a27b4488b5bf8f7334019ba4cf29 /code/ui/character/NameInfo.razor | |
| parent | fcca74deba166218deaf1e906acc0c206d96d27e (diff) | |
Add character names
Diffstat (limited to 'code/ui/character/NameInfo.razor')
| -rw-r--r-- | code/ui/character/NameInfo.razor | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/code/ui/character/NameInfo.razor b/code/ui/character/NameInfo.razor new file mode 100644 index 0000000..8b6dce1 --- /dev/null +++ b/code/ui/character/NameInfo.razor @@ -0,0 +1,37 @@ +@using Sandbox;
+@using Sandbox.UI;
+
+@namespace MurderGame
+@inherits Panel
+
+<style>
+.team-info {
+ font-size: 30px;
+ font-weight: 700;
+ font-family: "Roboto";
+}
+</style>
+
+<div class="team-info" style="color: @(Colour)">
+@GetName()
+</div>
+
+@code
+{
+ public string Colour { get; set; }
+
+ public string GetName()
+ {
+ var clientPawn = Game.LocalPawn;
+ if (clientPawn is Player {Camera: not null } player)
+ {
+ return player.Camera.GetObservedName();
+ }
+ return "";
+ }
+
+ protected override int BuildHash()
+ {
+ return GetName().GetHashCode();
+ }
+}
|
