VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
ButtonPresses.hpp
Go to the documentation of this file.
1#pragma once
2
5
10#include <string>
11#include <vector>
12
13namespace VoltMod
14{
15
16/**
17 * @brief The FilterMessage hook for every plugin: custom HUD button presses, raised on the frame
18 * after they arrive. Game thread only.
19 */
21{
22public:
23 /** A missing message registry hooks nothing. @p bindings and @p registry must outlive this. */
24 ButtonPresses(const Bindings& bindings, const EngineInterfaces& engine, PluginRegistry& registry);
25
26 ButtonPresses(const ButtonPresses&) = delete;
28
29 /** Raise the presses that arrived since the last frame. */
30 void OnFrame();
31
32private:
33 struct Press
34 {
35 int Slot = -1;
36 std::string ButtonId;
37 };
38
39 Status Install(const EngineInterfaces& engine);
40
41 void Queue(const CNetMessage* message, const INetworkMessageProcessingPreFilter& filter);
42 void WarnMalformed(int slot);
43
44 PluginRegistry& _registry;
45 const Bindings& _bindings;
46 int _messageId = -1;
47 std::vector<Press> _queued;
48 Cooldown<int> _warnings; ///< a client can send malformed presses at will
49 Subscription _hook;
50};
51
52} // namespace VoltMod
ButtonPresses(const Bindings &bindings, const EngineInterfaces &engine, PluginRegistry &registry)
ButtonPresses(const ButtonPresses &)=delete
ButtonPresses & operator=(const ButtonPresses &)=delete
A per-key cooldown, such as one notice per player per minute.
Definition Cooldown.hpp:18
The loaded plugins and the engine events raised on them, one per process.
Owns one registration and releases it on destruction.
std::expected< void, Error > Status
Definition Result.hpp:67