VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::ScreenEntity Class Reference

The custom_hud_layout entity behind a Screen: spawning, removal, and every write. More...

#include <ScreenEntity.hpp>

Public Member Functions

 ScreenEntity (EntitySystem &entities, SlotEvents &slots, Visibility &visibility, LayoutPath layout, int owner)
 
 ~ScreenEntity ()
 
 ScreenEntity (const ScreenEntity &)=delete
 
ScreenEntity & operator= (const ScreenEntity &)=delete
 
bool Exists () const
 
bool EnsureSpawned (int slot)
 
void Remove ()
 
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)
 
void WriteCursor (int slot, bool shown)
 

Detailed Description

The custom_hud_layout entity behind a Screen: spawning, removal, and every write.

A shared screen writes the layout's global state (EveryoneSlot) or one player's state. The client shows per-player state for the pawn it is watching, so a player screen instead writes text and classes to the global state of an entity only its owner receives, and writes the cursor to the owner's own slot. That is what keeps a menu working while its owner is dead or spectating.

Writes never spawn; EnsureSpawned does. Unchanged values are skipped through WriteCache.

Definition at line 29 of file ScreenEntity.hpp.

Constructor & Destructor Documentation

◆ ScreenEntity() [1/2]

VoltMod::ScreenEntity::ScreenEntity ( EntitySystem &  entities,
SlotEvents &  slots,
Visibility &  visibility,
LayoutPath  layout,
int  owner 
)

Every reference must outlive this. owner is a player slot, or EveryoneSlot for a shared screen.

Definition at line 32 of file ScreenEntity.cpp.

References VoltMod::ReadFile(), Remove(), and VoltMod::WriteCache::RemoveSlot().

◆ ~ScreenEntity()

VoltMod::ScreenEntity::~ScreenEntity ( )

Definition at line 54 of file ScreenEntity.cpp.

References Remove().

◆ ScreenEntity() [2/2]

VoltMod::ScreenEntity::ScreenEntity ( const ScreenEntity &  )
delete

Member Function Documentation

◆ EnsureSpawned()

bool VoltMod::ScreenEntity::EnsureSpawned ( int  slot)

Spawn, or respawn after the player list changed, until the entity covers slot.

Definition at line 64 of file ScreenEntity.cpp.

References VoltMod::EveryoneSlot, Exists(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().

◆ Exists()

bool VoltMod::ScreenEntity::Exists ( ) const

Definition at line 59 of file ScreenEntity.cpp.

References VoltMod::EntitySystem::Get().

Referenced by EnsureSpawned().

◆ operator=()

ScreenEntity & VoltMod::ScreenEntity::operator= ( const ScreenEntity &  )
delete

◆ Remove()

void VoltMod::ScreenEntity::Remove ( )

Remove the entity and forget everything written to it. Safe to call again.

Definition at line 96 of file ScreenEntity.cpp.

References VoltMod::WriteCache::Clear(), VoltMod::EntitySystem::Get(), VoltMod::Entity::Remove(), and VoltMod::Visibility::ShowToEveryone().

Referenced by ScreenEntity(), and ~ScreenEntity().

◆ WriteClass()

void VoltMod::ScreenEntity::WriteClass ( int  slot,
std::string_view  elementId,
std::string_view  className,
bool  on 
)

◆ WriteCursor()

void VoltMod::ScreenEntity::WriteCursor ( int  slot,
bool  shown 
)

Definition at line 131 of file ScreenEntity.cpp.

References VoltMod::WriteCache::CursorChanged(), and VoltMod::ReadFile().

◆ WriteText()

void VoltMod::ScreenEntity::WriteText ( int  slot,
std::string_view  variable,
std::string_view  value 
)

The documentation for this class was generated from the following files: