VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
CenterHtmlRender.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <functional>
6#include <string>
7#include <string_view>
8
9namespace VoltMod
10{
11
12/** Rows one center-HTML page holds. A renderer limit, not a menu-model limit. */
13inline constexpr int CenterHtmlRowsPerPage = 5;
14
15/** The header block: what the menu is called, where it sits, and which page is showing. */
17{
18 std::string_view Title;
19 std::string_view Subtitle;
20 /** The menus this one was reached through, already joined; drawn small before the title. */
21 std::string_view Breadcrumb;
22 int Page = 0;
23 int Pages = 1;
24};
25
26/** Menu state needed by the renderer. */
28{
29 /** Row @p index as @ref MenuStack::Describe fills it in, so @ref MenuRow::Pending and
30 * @ref MenuRow::Changed are already answered. */
31 std::function<MenuRow(int index)> Describe;
32 /** The titles under this menu, joined; empty at the root. Borrowed for the render call. */
33 std::string_view Breadcrumb;
34 int Slot = 0;
36 bool IsSubmenu = false;
37};
38
39/** Renders the HTML for a menu, including its items and layout. @p translations localizes the
40 * default footer's nav labels and the empty-menu line, each looked up only where it is drawn. */
42
43/** Renders the chat-input capture overlay shown while a player is typing a value. */
44std::string RenderCaptureOverlay(const std::string& menuTitle, std::string_view prompt);
45
46/** The header HTML for a menu. Empty parts of @p header add nothing. */
47std::string RenderHeader(const CenterHtmlHeader& header);
48
49/**
50 * The footer HTML for a menu: the key hints.
51 * @param isSubmenu True if this menu is a submenu (shows "Back" hint), false if it's a root menu (shows "Close" hint).
52 * @param isPaginated True if the menu has multiple pages of items (shows page navigation hints)
53 * @param selectedRowSteps True when A/D steps the selected row's value rather than paging (shows "Change"/"Confirm"
54 * hints).
55 * @param slot Player slot used to look up the nav-label translations.
56 * @param translations Table the nav labels are looked up in.
57 * @return The generated HTML string for the menu footer.
58 */
60
61} // namespace VoltMod
Localization system. Loads one JSON file per language; nested objects flatten into dotted keys (categ...
std::string RenderMenuHtml(const Menu *menu, const CenterHtmlView &view, Translations &translations)
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::string RenderCaptureOverlay(const std::string &menuTitle, std::string_view prompt)
std::string RenderFooter(bool isSubmenu, bool isPaginated, bool selectedRowSteps, int slot, Translations &translations)
std::string RenderHeader(const CenterHtmlHeader &header)
constexpr int CenterHtmlRowsPerPage
std::function< MenuRow(int index)> Describe