9#include <tier1/utlstring.h>
10#include <tier1/utlvector.h>
29 out.SetDirect(
text.data(),
static_cast<int>(
text.size()));
36 _slotChanges =
slots.Changed += [
this](
int slot) {
37 _playersChangedSinceSpawn =
true;
48 _fullConnects =
slots.FullyConnected += [
this](
int slot) {
49 _playersChangedSinceSpawn =
true;
61 return static_cast<bool>(_entities.
Get(_entity));
77 if (!
Exists() && !SpawnOrWarn())
88 if (!_playersChangedSinceSpawn)
93 return SpawnOrWarn() && Covers(*
target);
151 return std::unexpected(
Error::Invalid(std::format(
"this screen belongs to slot {}", _owner)));
157int ScreenEntity::ContentSlotFor(
int cacheSlot)
const noexcept
162Status ScreenEntity::Spawn()
164 _playersChangedSinceSpawn =
false;
178 return std::unexpected(
Error::Engine(
"the engine refused to spawn custom_hud_layout"));
189bool ScreenEntity::SpawnOrWarn()
199int ScreenEntity::PlayerStateCount()
const
202 const Schema::CCSCustomHudLayout
layout{_entities.
Get(_entity).
Raw()};
206bool ScreenEntity::Covers(
int slot)
const
216 return std::unexpected(
Error::NotFound(
"the custom_hud_layout entity no longer exists"));
220 for (
const auto& [name,
table] :
221 {std::pair{
"element id",
layout.PanelIds()}, std::pair{
"class name",
layout.ClassNames()},
222 std::pair{
"text variable",
layout.DialogVariableNames()}})
227 return std::unexpected(
241 std::format(
"slot {} has no per-player layout state (the entity holds {})",
engineSlot,
states)));
252 return std::unexpected(
entity.error());
263 if (!
bindings.CustomHudSetDialogVariable)
265 return std::unexpected(
Error::Unsupported(
"the custom HUD text setter did not bind"));
271 if (!
bindings.CustomHudSetDialogVariableForPlayer)
273 return std::unexpected(
Error::Unsupported(
"the custom HUD per-player text setter did not bind"));
284 return std::unexpected(
entity.error());
297 return std::unexpected(
Error::Unsupported(
"the custom HUD class setter did not bind"));
303 if (!
bindings.CustomHudSetHasClassForPlayer)
305 return std::unexpected(
Error::Unsupported(
"the custom HUD per-player class setter did not bind"));
316 return std::unexpected(
entity.error());
324 return std::unexpected(
Error::Unsupported(
"the custom HUD input capture setter did not bind"));
331 Schema::CCSCustomHudLayout{*
entity}.GlobalLayoutState().SetInputCaptureEnabled(
shown);
runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see...
const VoltMod::Bindings & Bindings() const noexcept
Entity Spawn(std::string_view className, KeyValues &values)
Entity Get(EntityRef ref)
CEntityInstance * Raw() const noexcept
A layout resource the client will accept, checked before anything is spawned.
std::string_view Name() const noexcept
const std::string & Resource() const noexcept
void WriteText(int slot, std::string_view variable, std::string_view value)
void WriteClass(int slot, std::string_view elementId, std::string_view className, bool on)
bool EnsureSpawned(int slot)
ScreenEntity(EntitySystem &entities, SlotEvents &slots, Visibility &visibility, LayoutPath layout, int owner)
void WriteCursor(int slot, bool shown)
"The occupant of this slot changed" - raised by PlayerManager, consumed below it.
Which clients receive which entities, filtered after CheckTransmit.
void ShowToEveryone(EntityRef entity)
void ShowOnlyTo(EntityRef entity, int slot)
void Invalidate(int slot)
bool IsFirstFailure(int slot)
bool Changed(int slot, WriteKind kind, std::string_view elementId, std::string_view name, std::string_view value)
bool CursorChanged(int slot, bool shown)
void RemoveSlot(int slot)
void Warn(std::format_string< Args... > fmt, Args &&... args)
static constexpr int32_t ClassAbsent
static std::string ReadFile(const std::filesystem::path &path)
static constexpr int32_t ClassPresent
constexpr bool IsValidSlot(int slot)
static constexpr int StringTableCap
static void SetStr(CUtlString &out, std::string_view text)
static constexpr int StringTableHeadroom
std::expected< void, Error > Status
constexpr int EveryoneSlot
CUtlVector< CUtlString > StringTable
std::expected< T, Error > Result
Fn< void(void *, int32_t, bool)> CustomHudSetInputCapture
static Error Failed(std::string detail)
static Error Invalid(std::string detail)
static Error Engine(std::string detail)
static Error Unsupported(std::string detail)
static Error NotFound(std::string detail)