VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::Flow< TState > Class Template Reference

#include <Flow.hpp>

+ Inheritance diagram for VoltMod::Flow< TState >:

Classes

struct  ConfirmSpec
 
struct  DurationStep
 
struct  OptionsStep
 

Public Types

using Ptr = std::shared_ptr< Flow >
 
using BuildFn = std::function< std::shared_ptr< Menu >(Flow &flow)>
 
using AppliesFn = std::function< bool(const TState &)>
 

Public Member Functions

Ptr AddStep (BuildFn build, AppliesFn applies={})
 
Ptr AddDurationStep (DurationStep step)
 
Ptr AddOptionsStep (OptionsStep step)
 
Ptr Validate (std::function< std::optional< std::string >(const TState &)> check)
 
Ptr Confirm (ConfirmSpec spec)
 
Ptr Finish (std::function< void(TState &)> finish)
 
void Begin ()
 
void Advance ()
 
TState & State ()
 

Static Public Member Functions

static Ptr Create (MenuSurface &menus, int slot, TState initial)
 

Detailed Description

template<class TState>
class VoltMod::Flow< TState >

Runs a sequence of menus while collecting state for one player.

Definition at line 22 of file Flow.hpp.

Member Typedef Documentation

◆ AppliesFn

template<class TState >
using VoltMod::Flow< TState >::AppliesFn = std::function<bool(const TState&)>

Step predicate over the current state; a false skips the step.

Definition at line 29 of file Flow.hpp.

◆ BuildFn

template<class TState >
using VoltMod::Flow< TState >::BuildFn = std::function<std::shared_ptr<Menu>(Flow& flow)>

Menu factory for a custom step; call flow.Advance() after mutating flow.State().

Definition at line 27 of file Flow.hpp.

◆ Ptr

template<class TState >
using VoltMod::Flow< TState >::Ptr = std::shared_ptr<Flow>

Definition at line 25 of file Flow.hpp.

Member Function Documentation

◆ AddDurationStep()

template<class TState >
Ptr VoltMod::Flow< TState >::AddDurationStep ( DurationStep  step)
inline

Append a duration-picker step, drawn by VoltMod::BuildDurationMenu.

Definition at line 78 of file Flow.hpp.

References VoltMod::Flow< TState >::AddStep(), VoltMod::BuildDurationMenu(), and VoltMod::ReadFile().

◆ AddOptionsStep()

template<class TState >
Ptr VoltMod::Flow< TState >::AddOptionsStep ( OptionsStep  step)
inline

Append an options step.

Definition at line 108 of file Flow.hpp.

References VoltMod::Flow< TState >::AddStep(), and VoltMod::ReadFile().

◆ AddStep()

template<class TState >
Ptr VoltMod::Flow< TState >::AddStep ( BuildFn  build,
AppliesFn  applies = {} 
)
inline

Append a custom step.

Definition at line 71 of file Flow.hpp.

Referenced by VoltMod::Flow< TState >::AddDurationStep(), and VoltMod::Flow< TState >::AddOptionsStep().

◆ Advance()

template<class TState >
void VoltMod::Flow< TState >::Advance ( )
inline

Move past the current step. Steps call this after writing their value into State.

Definition at line 144 of file Flow.hpp.

◆ Begin()

template<class TState >
void VoltMod::Flow< TState >::Begin ( )
inline

Open the first applicable step (or the confirm/finish when there are none).

Definition at line 141 of file Flow.hpp.

◆ Confirm()

template<class TState >
Ptr VoltMod::Flow< TState >::Confirm ( ConfirmSpec  spec)
inline

End with a summary confirm dialog instead of finishing straight away.

Definition at line 128 of file Flow.hpp.

References VoltMod::ReadFile().

◆ Create()

template<class TState >
static Ptr VoltMod::Flow< TState >::Create ( MenuSurface &  menus,
int  slot,
TState  initial 
)
inlinestatic

menus must outlive the flow.

Definition at line 65 of file Flow.hpp.

References VoltMod::ReadFile().

◆ Finish()

template<class TState >
Ptr VoltMod::Flow< TState >::Finish ( std::function< void(TState &)>  finish)
inline

Definition at line 134 of file Flow.hpp.

References VoltMod::ReadFile().

◆ State()

template<class TState >
TState & VoltMod::Flow< TState >::State ( )
inline

Definition at line 146 of file Flow.hpp.

◆ Validate()

template<class TState >
Ptr VoltMod::Flow< TState >::Validate ( std::function< std::optional< std::string >(const TState &)>  check)
inline

Runs before each step and finish. Return a translation key to abort.

Definition at line 121 of file Flow.hpp.

References VoltMod::ReadFile().


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