VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
CenterHtml.hpp
Go to the documentation of this file.
1#pragma once
2
8#include <cstdint>
9#include <functional>
10#include <string>
11
12namespace VoltMod
13{
14
15/** How often an unchanged center-HTML page is sent again: CS2 drops it on death, a team switch and
16 * HUD updates. */
17inline constexpr int64_t CenterHtmlKeepAliveMs = 250;
18
19/**
20 * @brief Shows a center-HTML panel until stopped. `render` runs every refresh, so live values stay
21 * current; a page goes out when it changes and at least every @ref CenterHtmlKeepAliveMs.
22 */
24{
25public:
26 /** @p slots stops a panel when its player leaves. All must outlive this. */
27 CenterHtml(Messages& messages, Scheduler& scheduler, SlotEvents& slots);
28
29 /** Render for @p slot every @p refreshMs and send what changed, replacing any panel shown. */
30 void Show(int slot, int refreshMs, std::function<std::string(int slot)> render);
31
32 /** Stop and clear the panel; safe when nothing is shown. */
33 void Stop(int slot);
34
35 void StopAll();
36
37private:
38 Messages& _messages;
39 Scheduler& _scheduler;
41};
42
43} // namespace VoltMod
CenterHtml(Messages &messages, Scheduler &scheduler, SlotEvents &slots)
void Show(int slot, int refreshMs, std::function< std::string(int slot)> render)
void Stop(int slot)
Send chat, center print, center HTML, and alert messages.
Definition Messages.hpp:30
Per-player-slot value store that never leaks state across occupants.
Definition PerSlot.hpp:25
One-shot delays and repeating timers, run on the game thread.
Definition Scheduler.hpp:18
"The occupant of this slot changed" - raised by PlayerManager, consumed below it.
constexpr int64_t CenterHtmlKeepAliveMs