File tree 2 files changed +23
-12
lines changed
code/UI/Communication/VoiceChat
2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 1
1
using Sandbox ;
2
2
using Sandbox . UI ;
3
- using Sandbox . UI . Construct ;
4
3
using System ;
5
4
6
5
namespace TTT . UI ;
@@ -31,9 +30,6 @@ public void Update( float level )
31
30
{
32
31
_timeSincePlayed = 0 ;
33
32
_targetVoiceLevel = level ;
34
-
35
- if ( _client . IsValid ( ) )
36
- SetClass ( "dead" , _client . Pawn is Player player && ! player . IsAlive ) ;
37
33
}
38
34
39
35
public override void Tick ( )
@@ -68,4 +64,10 @@ public override void Tick()
68
64
tx . Rotation = Camera . Rotation . RotateAroundAxis ( Vector3 . Up , 180f ) ;
69
65
_indicator . Transform = tx ;
70
66
}
67
+
68
+ protected override int BuildHash ( )
69
+ {
70
+ var player = _client . Pawn as Player ;
71
+ return HashCode . Combine ( player ? . IsAlive , player ? . Role . GetHashCode ( ) ) ;
72
+ }
71
73
}
Original file line number Diff line number Diff line change 1
1
@namespace TTT.UI
2
2
3
- <root class =" rounded opacity-heavy text-shadow background-color-gradient " >
3
+ <root class =" rounded opacity-heavy text-shadow" >
4
4
<img src =" avatar:@_client.SteamId" class =" avatar" />
5
5
<text class =" name" >@_client.Name </text >
6
6
</root >
7
7
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
+
8
21
<style >
9
22
VoiceChatEntry {
10
23
flex-direction : row ;
13
26
align-items : center ;
14
27
overflow : hidden ;
15
28
transition : all 0.05s ease-out ;
29
+ background-color : @BackgroundColor();
16
30
17
31
&:intro {
18
32
opacity: 0 ;
31
45
}
32
46
33
47
.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 ;
41
50
}
42
51
}
43
52
</style >
You can’t perform that action at this time.
0 commit comments