|
VoltMod
C++23 framework for CS2 server plugins
|
One held-back row commit per player: what a stepped row was left showing, applied once the stepping stops. More...
#include <PendingCommit.hpp>
Public Types | |
| using | Timer = std::function< Subscription(int64_t delayMs, std::function< void()> callback)> |
Public Member Functions | |
| PendingCommit (Timer timer, SlotEvents &slots) | |
| void | Hold (int slot, int index, std::function< void()> commit) |
| int | Index (int slot) const |
| bool | IsPending (int slot, int index) const |
| void | Apply (int slot) |
| void | Drop (int slot) |
Static Public Attributes | |
| static constexpr int64_t | DelayMs = 400 |
One held-back row commit per player: what a stepped row was left showing, applied once the stepping stops.
A stepped row shows its new value the moment A/D or a stepper is pressed, but running its action on every press would make five taps five actions and five broadcasts. Hold keeps the commit back for DelayMs and replaces whatever the slot was holding, so a burst commits once.
Every other way out of the row runs what is held rather than dropping it - activating the row, closing the menu, moving the cursor off it - because a value the player picked and watched appear is a value they asked for. A slot changing hands is the one case that cancels: nobody is left to have asked for it.
SDK-free. The delay arrives as a Timer, which is Scheduler::Delay in the framework and a hand-fired one in the tests, so the policy is unit-tested without an engine or a real clock.
Definition at line 28 of file PendingCommit.hpp.
| using VoltMod::PendingCommit::Timer = std::function<Subscription(int64_t delayMs, std::function<void()> callback)> |
Run callback after delayMs; dropping the returned subscription cancels it.
Definition at line 32 of file PendingCommit.hpp.
| VoltMod::PendingCommit::PendingCommit | ( | Timer | timer, |
| SlotEvents & | slots | ||
| ) |
Store the timer used by Hold. A slot's pending commit is dropped unrun when the slot changes hands; slots must outlive this.
Definition at line 9 of file PendingCommit.cpp.
Apply slot's pending commit now, if it has one, and stop its timer.
Definition at line 41 of file PendingCommit.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by VoltMod::MenuStack::Activate(), and Hold().
Drop slot's pending commit without applying it.
Definition at line 58 of file PendingCommit.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by VoltMod::MenuStack::Activate().
Hold commit for row index of slot. Holding the same row again restarts the delay; holding a different one applies what the previous row was holding first.
Definition at line 11 of file PendingCommit.cpp.
References Apply(), DelayMs, Index(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by VoltMod::MenuStack::Step().
Pending row for slot, or -1.
Definition at line 31 of file PendingCommit.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by Hold(), and IsPending().
True while slot's pending commit belongs to row index.
Definition at line 36 of file PendingCommit.cpp.
References Index(), and VoltMod::ReadFile().
Referenced by VoltMod::MenuStack::Activate(), and VoltMod::MenuStack::Describe().
How long a stepped value waits before it is applied.
Definition at line 35 of file PendingCommit.hpp.
Referenced by Hold().