VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Screen.cpp
Go to the documentation of this file.
1#include "Ui/ScreenEntity.hpp"
2
4#include <utility>
5
6namespace VoltMod
7{
8
9Screen::Screen() = default;
10
11Screen::Screen(std::unique_ptr<ScreenEntity> entity) : _entity(std::move(entity)) {}
12
13Screen::~Screen() = default;
14
15Screen::Screen(Screen&&) noexcept = default;
16
17Screen& Screen::operator=(Screen&&) noexcept = default;
18
19Screen::operator bool() const
20{
21 return _entity && _entity->Exists();
22}
23
25{
26 return _entity && _entity->EnsureSpawned(slot);
27}
28
29void Screen::SetText(int slot, std::string_view variable, std::string_view value)
30{
31 if (_entity)
32 {
33 _entity->WriteText(slot, variable, value);
34 }
35}
36
37void Screen::SetClass(int slot, std::string_view elementId, std::string_view className, bool on)
38{
39 if (_entity)
40 {
41 _entity->WriteClass(slot, elementId, className, on);
42 }
43}
44
45void Screen::SetHidden(int slot, std::string_view elementId, bool hidden)
46{
47 SetClass(slot, elementId, "hidden", hidden);
48}
49
50void Screen::SetModifier(int slot, std::string_view elementId, std::string_view block,
51 std::span<const std::string_view> names, std::string_view name)
52{
53 if (_entity)
54 {
55 _entity->WriteModifier(slot, elementId, block, names, name);
56 }
57}
58
60{
61 return _entity && _entity->HasCursor();
62}
63
64void Screen::ShowCursor(int slot, bool shown)
65{
66 if (_entity)
67 {
68 _entity->WriteCursor(slot, shown);
69 }
70}
71
73{
74 if (_entity)
75 {
76 _entity->Remove();
77 }
78}
79
80} // namespace VoltMod
void ShowCursor(int slot, bool shown)
Definition Screen.cpp:64
bool HasCursor() const
Definition Screen.cpp:59
void SetHidden(int slot, std::string_view elementId, bool hidden)
Definition Screen.cpp:45
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:50
bool EnsureSpawned(int slot)
Definition Screen.cpp:24
void Remove()
Definition Screen.cpp:72
void SetClass(int slot, std::string_view elementId, std::string_view className, bool on)
Definition Screen.cpp:37
void SetText(int slot, std::string_view variable, std::string_view value)
Definition Screen.cpp:29