|
VoltMod
C++23 framework for CS2 server plugins
|
One player's open menus, and the row behaviour every surface shares. More...
#include <MenuStack.hpp>
Public Member Functions | |
| MenuStack (MenuSurface &surface, Translations &translations, Scheduler &scheduler, SlotEvents &slots) | |
| MenuStack (MenuSurface &surface, Translations &translations, PendingCommit::Timer timer, SlotEvents &slots) | |
| Menu * | Current (int slot) |
| Menu * | Root (int slot) |
| int | Depth (int slot) const |
| bool | IsOpen (int slot) const |
| bool | AnyOpen () const |
| std::string_view | Breadcrumb (int slot) const |
| void | Push (int slot, std::shared_ptr< Menu > menu) |
| void | Pop (int slot) |
| void | Clear (int slot) |
| void | PopToRoot (int slot) |
| MenuRow | Describe (int slot, int index) |
| void | Activate (int slot, int index) |
| bool | Step (int slot, int index, int direction) |
| void | ApplyPending (int slot) |
| bool | IsPending (int slot, int index) const |
Public Attributes | |
| Event< int > | Committed |
One player's open menus, and the row behaviour every surface shares.
The half of a menu session that has nothing to do with how it is drawn: the stack, the breadcrumb, how a row describes itself, what activating a row does, and how a stepped value is held back so a burst of presses is one action. CenterHtmlMenu draws this as center HTML; a plugin drawing its own Panorama screen holds one too, so the same Menu behaves the same way whichever surface a player is on.
What stays outside: the cursor, page shape, key or click routing, freezing, and prompts. Those differ per surface, and a surface that has no cursor should not be made to carry one.
SDK-free. A surface hands it the Scheduler; the tests hand it a PendingCommit::Timer they fire by hand.
Definition at line 34 of file MenuStack.hpp.
| VoltMod::MenuStack::MenuStack | ( | MenuSurface & | surface, |
| Translations & | translations, | ||
| Scheduler & | scheduler, | ||
| SlotEvents & | slots | ||
| ) |
surface is what a row's Activate callback is handed: the surface owning this stack. A slot's stack is dropped when slots reports it changed hands. Every reference must outlive this instance.
Definition at line 17 of file MenuStack.cpp.
| VoltMod::MenuStack::MenuStack | ( | MenuSurface & | surface, |
| Translations & | translations, | ||
| PendingCommit::Timer | timer, | ||
| SlotEvents & | slots | ||
| ) |
The same, with the held commit's delay driven by timer instead of a Scheduler.
Definition at line 21 of file MenuStack.cpp.
Run row index, as if it had been selected and confirmed. Ignores rows that are disabled, unselectable, or out of range.
Runs a commit held for another row first, and cancels one held for this row: a row whose activation is its own commit would otherwise apply the value twice.
Definition at line 187 of file MenuStack.cpp.
References VoltMod::MenuItem::Activate, VoltMod::PendingCommit::Apply(), Current(), VoltMod::PendingCommit::Drop(), VoltMod::PendingCommit::IsPending(), VoltMod::IsRowActionable(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().
| bool VoltMod::MenuStack::AnyOpen | ( | ) | const |
Definition at line 53 of file MenuStack.cpp.
References VoltMod::MaxPlayers, and VoltMod::ReadFile().
Apply whatever a stepped row was left showing, and forget it. Every way out of a row that is not another step goes through here.
Definition at line 253 of file MenuStack.cpp.
Referenced by Clear(), Pop(), and PopToRoot().
| std::string_view VoltMod::MenuStack::Breadcrumb | ( | int | slot | ) | const |
Parent menu titles joined. Valid until the stack changes.
Definition at line 65 of file MenuStack.cpp.
References Breadcrumb(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by Breadcrumb().
Clear the whole stack, applying whatever a stepped row was left showing.
Definition at line 103 of file MenuStack.cpp.
References ApplyPending(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by VoltMod::CenterHtmlMenu::CloseAll(), and VoltMod::PanoramaMenu::CloseAll().
Top menu, or null when none is open.
Definition at line 25 of file MenuStack.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by Activate(), Describe(), and Step().
Definition at line 43 of file MenuStack.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by VoltMod::PanoramaMenu::Close(), and IsOpen().
Row index as it describes itself, with MenuRow::Pending and MenuRow::Changed filled in and a Toggle's on/off word spelled. An index with no row behind it describes as a disabled, unselectable line.
Definition at line 143 of file MenuStack.cpp.
References Current(), VoltMod::MenuRow::Enabled, VoltMod::Translations::GetOr(), VoltMod::PendingCommit::IsPending(), VoltMod::Time::MonotonicMs(), VoltMod::ReadFile(), and VoltMod::Toggle.
Definition at line 48 of file MenuStack.cpp.
References Depth(), and VoltMod::ReadFile().
Referenced by VoltMod::CenterHtmlMenu::Close(), VoltMod::CenterHtmlMenu::CloseAll(), VoltMod::CenterHtmlMenu::IsOpen(), VoltMod::PanoramaMenu::IsOpen(), and VoltMod::CenterHtmlMenu::Open().
True while slot is holding a stepped value for row index.
Definition at line 258 of file MenuStack.cpp.
Pop the top menu, applying whatever a stepped row was left showing. Ask IsOpen after it: an empty stack is the caller's cue to unfreeze and take the menu off screen.
Definition at line 81 of file MenuStack.cpp.
References ApplyPending(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by VoltMod::CenterHtmlMenu::Close(), and VoltMod::PanoramaMenu::Close().
Pop every menu but the root without closing the session, for a surface where entering a branch is a jump rather than a push. Does nothing when nothing is open.
Definition at line 114 of file MenuStack.cpp.
References ApplyPending(), VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Definition at line 70 of file MenuStack.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Referenced by VoltMod::PanoramaMenu::Open(), and VoltMod::PanoramaMenu::OpenSession().
Bottom menu - the one the session was opened with - or null.
Definition at line 34 of file MenuStack.cpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Step row index's value by direction (-1 or +1). True when the row consumed it, which is what tells a keyboard surface to page instead. A row with a MenuItem::Commit is stepped, not applied: the commit is held so a burst of presses runs one action.
Definition at line 221 of file MenuStack.cpp.
References Committed, Current(), VoltMod::PendingCommit::Hold(), VoltMod::Event< Args >::Raise(), and VoltMod::ReadFile().
A held commit was applied. A surface that redraws every frame can ignore this; one that draws on demand needs it, because the commit lands on a timer rather than on a press.
Definition at line 97 of file MenuStack.hpp.
Referenced by VoltMod::PanoramaMenu::PanoramaMenu(), and Step().