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

runtime.Menus: the surface menus start on, chosen once per session. More...

#include <MenuRouter.hpp>

Inheritance diagram for VoltMod::MenuRouter:

Public Member Functions

 MenuRouter (MenuSurface &fallback)
Subscription Prefer (MenuSurface &surface)
bool OpenSession (int slot, std::shared_ptr< Menu > menu, MenuOptions options) override
void Open (int slot, std::shared_ptr< Menu > menu) override
bool IsOpen (int slot) const override
void Close (int slot) override
void CloseAll (int slot) override
void CloseAll (int slot, std::string_view replyKey) override
void Prompt (int slot, std::string prompt, std::function< bool(int slot, std::string_view text)> callback) override
std::string Translate (int slot, std::string_view key, std::string_view fallback) const override
Public Member Functions inherited from VoltMod::MenuSurface
virtual ~MenuSurface ()=default
 MenuSurface (const MenuSurface &)=delete
MenuSurface & operator= (const MenuSurface &)=delete

Additional Inherited Members

Protected Member Functions inherited from VoltMod::MenuSurface
 MenuSurface ()=default

Detailed Description

runtime.Menus: the surface menus start on, chosen once per session.

A session starts on the preferred surface when it can draw for the player, and on the fallback otherwise. Every later call follows the surface holding that player's session, and a player has one session across both. Rows and flows are built against this, so they never pick a surface themselves. SDK-free.

Definition at line 21 of file MenuRouter.hpp.

Constructor & Destructor Documentation

◆ MenuRouter()

VoltMod::MenuRouter::MenuRouter ( MenuSurface & fallback)
explicit

fallback takes every session no preferred surface does, and must outlive this.

Definition at line 7 of file MenuRouter.cpp.

References VoltMod::MenuSurface::MenuSurface().

Member Function Documentation

◆ Close()

void VoltMod::MenuRouter::Close ( int slot)
overridevirtual

Pops the top menu, returning to its parent when one exists.

Implements VoltMod::MenuSurface.

Definition at line 53 of file MenuRouter.cpp.

◆ CloseAll() [1/2]

void VoltMod::MenuRouter::CloseAll ( int slot)
overridevirtual

Clears the stack and removes the menu from the player's screen.

Implements VoltMod::MenuSurface.

Definition at line 58 of file MenuRouter.cpp.

◆ CloseAll() [2/2]

void VoltMod::MenuRouter::CloseAll ( int slot,
std::string_view replyKey )
overridevirtual

Translates and sends replyKey, then closes every menu.

Implements VoltMod::MenuSurface.

Definition at line 63 of file MenuRouter.cpp.

◆ IsOpen()

bool VoltMod::MenuRouter::IsOpen ( int slot) const
overridevirtual

Implements VoltMod::MenuSurface.

Definition at line 48 of file MenuRouter.cpp.

Referenced by Open().

◆ Open()

void VoltMod::MenuRouter::Open ( int slot,
std::shared_ptr< Menu > menu )
overridevirtual

Pushes menu onto slot's session and shows it, starting one with default options when none is open. What a row calls.

Implements VoltMod::MenuSurface.

Definition at line 37 of file MenuRouter.cpp.

References IsOpen(), and OpenSession().

◆ OpenSession()

bool VoltMod::MenuRouter::OpenSession ( int slot,
std::shared_ptr< Menu > menu,
MenuOptions options )
overridevirtual

Opens a session for slot showing menu, closing any the player has open here. What a command calls. False when this surface cannot draw for slot; nothing is left open then.

Implements VoltMod::MenuSurface.

Definition at line 21 of file MenuRouter.cpp.

Referenced by Open().

◆ Prefer()

Subscription VoltMod::MenuRouter::Prefer ( MenuSurface & surface)
nodiscard

Try surface first for new sessions while the returned Subscription is held; hold it no longer than surface lives. A later call replaces the preference.

Definition at line 9 of file MenuRouter.cpp.

References VoltMod::MenuSurface::MenuSurface().

◆ Prompt()

void VoltMod::MenuRouter::Prompt ( int slot,
std::string prompt,
std::function< bool(int slot, std::string_view text)> callback )
overridevirtual

Routes the next chat line to callback. Closing the menu cancels it.

Implements VoltMod::MenuSurface.

Definition at line 68 of file MenuRouter.cpp.

◆ Translate()

std::string VoltMod::MenuRouter::Translate ( int slot,
std::string_view key,
std::string_view fallback ) const
overridevirtual

Translates key for slot, using fallback when missing.

Implements VoltMod::MenuSurface.

Definition at line 73 of file MenuRouter.cpp.


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