VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
PlayerScreens.hpp
Go to the documentation of this file.
1#pragma once
2
7#include <optional>
8#include <string>
9
10namespace VoltMod
11{
12
13/**
14 * @brief One layout's player screens, each created the first time something draws for that slot.
15 *
16 * A player screen costs an entity, so this makes one per player who is actually shown the layout
17 * rather than one per connected player. A screen removes its entity when its slot changes hands
18 * and respawns for the next player on @ref Screen::EnsureSpawned.
19 */
21{
22public:
23 /** @p screens must outlive this. */
24 PlayerScreens(ScreenManager& screens, std::string layout);
25
26 /** @p slot's screen, created on first use. One @ref ScreenManager::Create refuses is logged
27 * once and stays empty, so its writes fail quietly. */
28 Screen& For(int slot);
29
30 /** @p slot's screen if one was created, or null. Never creates. */
31 Screen* Find(int slot);
32
33 /** @p slot's screen created and spawned, ready to draw; null for a bot, an empty slot, or a screen
34 * that cannot spawn. */
35 Screen* FindSpawned(int slot);
36
37 /** @ref FindSpawned, then shows the layout's root element and gives the player a cursor, so it takes
38 * their clicks until @ref Close. Null when it cannot spawn. */
39 Screen* Open(int slot);
40
41 /** Takes the cursor back and removes the entity: clients draw only their first custom_hud_layout, so a
42 * hidden one would block the next. */
43 void Close(int slot);
44
45 /** Whether @p slot's screen is open: after @ref Open, until @ref Close, the slot changing hands or a
46 * map change removing the entity. */
47 bool IsOpen(int slot) const;
48
49private:
50 ScreenManager& _screens;
51 std::string _layout;
52 /** The layout's root element, which @ref Open shows. */
53 std::string _root;
55 /** Handed out for a slot that is not a player slot. */
56 Screen _empty;
57};
58
59} // namespace VoltMod
Per-player-slot value store that never leaks state across occupants.
Definition PerSlot.hpp:25
Screen & For(int slot)
Screen * FindSpawned(int slot)
Screen * Open(int slot)
Screen * Find(int slot)
bool IsOpen(int slot) const
PlayerScreens(ScreenManager &screens, std::string layout)
Create Screen objects and report their button presses.
A spawned Panorama layout created by ScreenManager.
Definition Screen.hpp:23