|
VoltMod
C++23 framework for CS2 server plugins
|
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 |
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.
The callback returns true to accept and clear input, or false to keep capturing.
Definition at line 35 of file ChatInput.hpp.
| 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(), and VoltMod::ReadFile().
| 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(), VoltMod::Scheduler::Delay(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by VoltMod::CenterHtmlMenu::Prompt(), and VoltMod::PanoramaMenu::Prompt().
Cancel without firing the callback.
Definition at line 70 of file ChatInput.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by BeginCapture(), ChatInput(), VoltMod::CenterHtmlMenu::Close(), VoltMod::PanoramaMenu::Close(), and VoltMod::CenterHtmlMenu::CloseAll().
| 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(), and VoltMod::ReadFile().
Definition at line 32 of file ChatInput.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Definition at line 41 of file ChatInput.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().