VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
PlayerRows.cpp
Go to the documentation of this file.
1// Apart from MenuPresets.cpp on purpose: Player::Name() is engine-side, and that file is in the SDK-free tests.
5
6namespace VoltMod
7{
8
10{
11 auto connected = players.All();
12 for (auto* player : connected)
13 {
14 // Resolve the original player, not a later occupant of the slot.
15 const PlayerRef target = player->Ref();
16
18 ? EnabledCondition([check = spec.Enabled, target](int) { return check(target); })
19 : EnabledCondition(true);
20
21 // Drivers escape this plain-text name for their output format.
22 if (spec.Open)
23 {
24 builder.Add(SubmenuRow{.Label = player->Name(),
25 .Build = [open = spec.Open, target](int) { return open(target); },
26 .Enabled = std::move(enabled)});
27 continue;
28 }
29
30 builder.Add(ButtonRow{.Label = player->Name(),
31 .Activate =
32 [pick = spec.Pick, target](int) {
33 if (pick)
34 {
35 pick(target);
36 }
37 },
38 .Enabled = std::move(enabled)});
39 }
40
41 if (connected.empty() && !spec.EmptyLabel.empty())
42 {
43 builder.Text(spec.EmptyLabel);
44 }
45}
46
47std::shared_ptr<Menu> BuildPlayerPicker(PlayerManager& players, PlayerPicker spec)
48{
49 MenuBuilder builder(spec.Title);
50 AppendPlayerRows(builder, players, spec);
51 return builder.Build();
52}
53
54} // namespace VoltMod
std::shared_ptr< Menu > Build()
The roster: every connected player, and the signals for the connection lifecycle.
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::shared_ptr< Menu > BuildPlayerPicker(PlayerManager &players, PlayerPicker spec)
void AppendPlayerRows(MenuBuilder &builder, PlayerManager &players, const PlayerPicker &spec)
Definition PlayerRows.cpp:9
A storable reference to a player: the slot plus the SteamID that occupied it.
Definition PlayerRef.hpp:19