1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
<!-- 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
@inherits Panel
<style>
tablistoverlay {
position: absolute;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
z-index: 99;
}
.container {
width: 40%;
height: 60%;
background-color: rgba(0, 0, 0, 0.2);
backdrop-filter-blur: 32px;
padding: 10px;
color: white;
font-family: "Roboto";
font-weight: 700;
text-shadow: 1px 1px 0 0 rgba(0,0,0,0.75);
display: flex;
flex-direction: column;
gap: 10px;
}
.tablist-header {
flex-direction: column;
}
.text-header {
font-size: 35px;
}
.text-aside {
font-size: 20px;
}
.list {
width: 100%;
display: flex;
flex-direction: column;
}
.list-header {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
font-size: 25px;
margin-bottom: 2px;
border-bottom: 2px solid rgba(255, 255, 255, 0.2);
padding-bottom: 2px;
}
.list-content {
width: 100%;
display: flex;
flex-direction: column;
gap: 5px;
font-size: 25px;
color: #DDDDDD;
}
.entry {
flex-direction: row;
justify-content: space-between;
}
</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="list">
<div class="list-header">
<span class="name">Name</span>
<span class="ping">Ping</span>
</div>
<div class="list-content" @ref="List">
</div>
</div>
</div>
@code
{
readonly Dictionary<IClient, TabListEntry> Entries = new();
public Panel List { get; set; }
public static TabListOverlay Instance { get; private set; }
public TabListOverlay()
{
Instance = this;
}
public bool IsOpen => Input.Down("score");
public override void Tick()
{
base.Tick();
SetClass("hidden", !IsOpen);
if (!IsVisible)
return;
foreach (var cl in Game.Clients.Except(Entries.Keys))
{
TabListEntry entry = new();
Entries.Add(cl, entry);
entry.UpdateFrom(cl);
entry.Parent = List;
}
foreach (var cl in Entries.Keys.Except(Game.Clients))
{
if (Entries.TryGetValue(cl, out var entry))
{
entry.Delete();
Entries.Remove(cl);
}
}
// foreach ( var entry in Entries )
// {
// entry.Value.Parent = List;
// }
}
}
|