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

Per-player pending-prompt registry for menu free-text input. More...

#include <ChatInput.hpp>

Public Types

using Callback = std::function<bool(int slot, std::string_view text)>

Public Member Functions

 ChatInput (Scheduler &scheduler, SlotEvents &slots)
 ChatInput (const ChatInput &)=delete
ChatInput & operator= (const ChatInput &)=delete
void BeginCapture (int slot, std::string prompt, Callback callback, int timeoutMs=60000)
bool IsCapturing (int slot) const
bool TryConsume (int slot, std::string_view text)
void CancelCapture (int slot)
std::optional< std::string > GetPrompt (int slot) const

Detailed Description

Per-player pending-prompt registry for menu free-text input.

The framework calls TryConsume for every say/say_team message before command parsing. An active capture routes the message to its callback and suppresses the chat broadcast.

This service does not install a separate chat hook: player_say runs after the broadcast. The consume call must remain in Hook_DispatchConCommand.

Definition at line 26 of file ChatInput.hpp.

Member Typedef Documentation

◆ Callback

using VoltMod::ChatInput::Callback = std::function<bool(int slot, std::string_view text)>

The callback returns true to accept and clear input, or false to keep capturing.

Definition at line 35 of file ChatInput.hpp.

Constructor & Destructor Documentation

◆ ChatInput() [1/2]

VoltMod::ChatInput::ChatInput ( Scheduler & scheduler,
SlotEvents & slots )

Uses scheduler for timeouts and slots to clear recycled slots. Both must outlive this object.

Definition at line 8 of file ChatInput.cpp.

References CancelCapture().

Referenced by ChatInput(), and operator=().

◆ ChatInput() [2/2]

VoltMod::ChatInput::ChatInput ( const ChatInput & )
delete

References ChatInput().

Member Function Documentation

◆ BeginCapture()

void VoltMod::ChatInput::BeginCapture ( int slot,
std::string prompt,
Callback callback,
int timeoutMs = 60000 )

Begin capturing the next chat line from slot. Replaces and cancels any existing capture. A positive timeoutMs cancels the capture without input.

Definition at line 14 of file ChatInput.cpp.

References CancelCapture(), and VoltMod::IsValidSlot().

◆ CancelCapture()

void VoltMod::ChatInput::CancelCapture ( int slot)

Cancel without firing the callback.

Definition at line 70 of file ChatInput.cpp.

References VoltMod::IsValidSlot().

Referenced by BeginCapture(), and ChatInput().

◆ GetPrompt()

std::optional< std::string > VoltMod::ChatInput::GetPrompt ( int slot) const

Returns a copy of the active prompt, or nullopt. The copy remains valid if the capture changes.

Definition at line 80 of file ChatInput.cpp.

References VoltMod::IsValidSlot().

◆ IsCapturing()

bool VoltMod::ChatInput::IsCapturing ( int slot) const

Definition at line 32 of file ChatInput.cpp.

References VoltMod::IsValidSlot().

◆ operator=()

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

References ChatInput().

◆ TryConsume()

bool VoltMod::ChatInput::TryConsume ( int slot,
std::string_view text )

Definition at line 41 of file ChatInput.cpp.

References VoltMod::IsValidSlot().


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