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 <string>
5#include <utility>
6
7namespace VoltMod
8{
9
10Screen::Screen() = default;
11
12Screen::Screen(std::unique_ptr<ScreenEntity> entity) : _entity(std::move(entity)) {}
13
14Screen::~Screen() = default;
15
16Screen::Screen(Screen&&) noexcept = default;
17
18Screen& Screen::operator=(Screen&&) noexcept = default;
19
20Screen::operator bool() const
21{
22 return _entity && _entity->Exists();
23}
24
25bool Screen::EnsureSpawned(int slot)
26{
27 return _entity && _entity->EnsureSpawned(slot);
28}
29
30void Screen::SetText(int slot, std::string_view variable, std::string_view value)
31{
32 if (_entity)
33 {
34 _entity->WriteText(slot, variable, value);
35 }
36}
37
38void Screen::SetClass(int slot, std::string_view elementId, std::string_view className, bool on)
39{
40 if (_entity)
41 {
42 _entity->WriteClass(slot, elementId, className, on);
43 }
44}
45
46void Screen::SetHidden(int slot, std::string_view elementId, bool hidden)
47{
48 SetClass(slot, elementId, "hidden", hidden);
49}
50
51void Screen::SetModifier(int slot, std::string_view elementId, std::string_view block,
52 std::span<const std::string_view> names, std::string_view name)
53{
54 std::string className;
55 for (std::string_view each : names)
56 {
57 className.assign(block).append("--").append(each);
58 SetClass(slot, elementId, className, each == name);
59 }
60}
61
62void Screen::ShowCursor(int slot, bool shown)
63{
64 if (_entity)
65 {
66 _entity->WriteCursor(slot, shown);
67 }
68}
69
70void Screen::Remove()
71{
72 if (_entity)
73 {
74 _entity->Remove();
75 }
76}
77
78} // namespace VoltMod
A spawned Panorama layout created by ScreenManager.
Definition Screen.hpp:23
bool EnsureSpawned(int slot)
Definition Screen.cpp:25
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56