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

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
 

Detailed Description

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.

Member Typedef Documentation

◆ Timer

Run callback after delayMs; dropping the returned subscription cancels it.

Definition at line 32 of file PendingCommit.hpp.

Constructor & Destructor Documentation

◆ PendingCommit()

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.

Member Function Documentation

◆ Apply()

void VoltMod::PendingCommit::Apply ( int  slot)

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()

void VoltMod::PendingCommit::Drop ( int  slot)

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()

void VoltMod::PendingCommit::Hold ( int  slot,
int  index,
std::function< void()>  commit 
)

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().

◆ Index()

int VoltMod::PendingCommit::Index ( int  slot) const

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().

◆ IsPending()

bool VoltMod::PendingCommit::IsPending ( int  slot,
int  index 
) const

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().

Member Data Documentation

◆ DelayMs

constexpr int64_t VoltMod::PendingCommit::DelayMs = 400
staticconstexpr

How long a stepped value waits before it is applied.

Definition at line 35 of file PendingCommit.hpp.

Referenced by Hold().


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