Skip to content

Commit 90c23f6

Browse files
committed
Voice chat entry should show detective role like chat does
1 parent f19234e commit 90c23f6

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

code/UI/Communication/VoiceChat/VoiceChatEntry.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Sandbox;
22
using Sandbox.UI;
3-
using Sandbox.UI.Construct;
43
using System;
54

65
namespace TTT.UI;
@@ -31,9 +30,6 @@ public void Update( float level )
3130
{
3231
_timeSincePlayed = 0;
3332
_targetVoiceLevel = level;
34-
35-
if ( _client.IsValid() )
36-
SetClass( "dead", _client.Pawn is Player player && !player.IsAlive );
3733
}
3834

3935
public override void Tick()
@@ -68,4 +64,10 @@ public override void Tick()
6864
tx.Rotation = Camera.Rotation.RotateAroundAxis( Vector3.Up, 180f );
6965
_indicator.Transform = tx;
7066
}
67+
68+
protected override int BuildHash()
69+
{
70+
var player = _client.Pawn as Player;
71+
return HashCode.Combine( player?.IsAlive, player?.Role.GetHashCode() );
72+
}
7173
}

code/UI/Communication/VoiceChat/VoiceChatEntry.razor

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
@namespace TTT.UI
22

3-
<root class="rounded opacity-heavy text-shadow background-color-gradient">
3+
<root class="rounded opacity-heavy text-shadow">
44
<img src="avatar:@_client.SteamId" class="avatar" />
55
<text class="name">@_client.Name</text>
66
</root>
77

8+
@code {
9+
private string BackgroundColor()
10+
{
11+
if (_client.Pawn is not TTT.Player player || !player.IsAlive)
12+
return "#fcdb38";
13+
14+
if (player.Role is Detective)
15+
return player.Role.Color.Hex;
16+
17+
return "#303030";
18+
}
19+
}
20+
821
<style>
922
VoiceChatEntry {
1023
flex-direction: row;
@@ -13,6 +26,7 @@
1326
align-items: center;
1427
overflow: hidden;
1528
transition: all 0.05s ease-out;
29+
background-color: @BackgroundColor();
1630
1731
&:intro {
1832
opacity: 0;
@@ -31,13 +45,8 @@
3145
}
3246
3347
.name {
34-
font-size: 16px;
35-
margin-left: 10px;
36-
font-weight: 500;
37-
}
38-
39-
&.dead {
40-
background: linear-gradient(#fcc82d, #c59813);
48+
font-size: 18px;
49+
margin-left: 5px;
4150
}
4251
}
4352
</style>

0 commit comments

Comments
 (0)