VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Screen.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <memory>
5#include <span>
6#include <string_view>
7
8namespace VoltMod
9{
10
11/**
12 * @brief A spawned Panorama layout created by @ref ScreenManager.
13 *
14 * Shared screens write for @ref EveryoneSlot or a selected player. Player screens are networked only
15 * to their owner and remain visible while the owner is dead or spectating.
16 *
17 * Writes do not spawn the entity. Call @ref EnsureSpawned before drawing; it also respawns after a
18 * map change. Unchanged values are not resent, and a failed write is logged once per slot and retried
19 * on the next change. Destruction removes the entity. Operations are inert unless
20 * @ref ScreenManager::Available succeeds.
21 */
22class Screen
23{
24public:
25 /** Construct an empty screen. Writes do nothing until an entity is assigned. */
28
30 /** Replace the entity, removing the one previously held by this screen. */
34
35 explicit operator bool() const;
36
37 /** Spawn or respawn until @p slot can be written to. False logs why once per attempt. */
38 bool EnsureSpawned(int slot);
39
40 /** Set the text a `text="{s:variable}"` Label shows, for @p slot or @ref EveryoneSlot. */
41 void SetText(int slot, std::string_view variable, std::string_view value);
42
43 void SetClass(int slot, std::string_view elementId, std::string_view className, bool on);
44
45 void SetHidden(int slot, std::string_view elementId, bool hidden);
46
47 /** Turn `<block>--<name>` on for @p elementId and every other of @p names off, such as an icon
48 * set's shown icon or a bar's step. @p names is the generated header's `IconSetNames` or `BarNames`. */
50 std::span<const std::string_view> names, std::string_view name);
51
52 void ShowCursor(int slot, bool shown);
53
54 /** Remove the entity now. The next @ref EnsureSpawned creates a new one. */
55 void Remove();
56
59
61
62 std::unique_ptr<ScreenEntity> _entity;
63};
64
65} // namespace VoltMod
The custom_hud_layout entity behind a Screen: spawning, removal, and every write.
Create Screen objects and report their button presses.
A spawned Panorama layout created by ScreenManager.
Definition Screen.hpp:23
void ShowCursor(int slot, bool shown)
Definition Screen.cpp:62
void SetHidden(int slot, std::string_view elementId, bool hidden)
Definition Screen.cpp:46
void SetModifier(int slot, std::string_view elementId, std::string_view block, std::span< const std::string_view > names, std::string_view name)
Definition Screen.cpp:51
bool EnsureSpawned(int slot)
Definition Screen.cpp:25
void Remove()
Definition Screen.cpp:70
void SetClass(int slot, std::string_view elementId, std::string_view className, bool on)
Definition Screen.cpp:38
void SetText(int slot, std::string_view variable, std::string_view value)
Definition Screen.cpp:30
Screen(Screen &&) noexcept
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56