|
Aegis2D
Modular C++26 2D game engine for networked games
|
Window and input on top of SDL3, independent of the graphics API (client only). More...
Classes | |
| class | ActionMap |
| Actions of the game and the keys and gamepad buttons that trigger them. More... | |
| struct | CapturedKey |
| End of a key capture. More... | |
| struct | ControlLine |
| One line of a controls reminder: an action and the keys (or gamepad buttons) that trigger it now. More... | |
| struct | Extent |
| Width and height of a window or a framebuffer. More... | |
| class | Gamepad |
| Buttons held down, and those pressed or released since the start of the frame, with the position of the sticks and triggers. More... | |
| class | Keyboard |
| Keys held down, and those pressed or released since the start of the frame. More... | |
| class | KeyCapture |
| Key binding step of a settings menu: "press a key for Fire". More... | |
| class | LatchedAction |
| An action the player can hold without holding a key, such as fire. More... | |
| class | Mouse |
| Position of the mouse, buttons held, and those pressed or released and the wheel turned since the start of the frame. More... | |
| class | TextInput |
| UTF-8 text typed during a frame, following the user's keyboard layout. More... | |
| class | Window |
| Desktop window: creation, size and events. Drawing is left to a render backend. More... | |
| struct | WindowConfig |
| Settings of a new window. More... | |
| class | WindowError |
| Thrown when the window cannot be created. More... | |
Typedefs | |
| using | ActionId = std::size_t |
| Identifier of an action in its ActionMap, given by ActionMap::add(). | |
| using | ActionLabels = std::map< std::string, std::string, std::less<> > |
Display labels of actions, by action name: {"up", "Move up"}. | |
Functions | |
| std::string | action_label (std::string_view name) |
| Default label of an action name. | |
| std::string | keys_label (const ActionMap &actions, ActionId action) |
| The keys of an action as shown to the player. | |
| std::string | buttons_label (const ActionMap &actions, ActionId action, GamepadStyle style) |
| The gamepad buttons of an action as printed on the player's pad. | |
| std::vector< ControlLine > | control_lines (const ActionMap &actions, const ActionLabels &labels={}) |
| Every action with the keys that trigger it now, in the order they were declared. | |
| std::vector< ControlLine > | control_lines (const ActionMap &actions, GamepadStyle style, const ActionLabels &labels={}) |
| Every action with the gamepad buttons that trigger it now, for a player using a pad, in the order they were declared. | |
| std::string_view | button_name (GamepadButton button) noexcept |
| Stable name of a button, as written in settings files. | |
| std::optional< GamepadButton > | button_from_name (std::string_view name) |
Button whose name is name, ignoring case. | |
| std::string | button_label (GamepadButton button, GamepadStyle style={}) |
| Name of a button as printed on a pad of the given family, for a controls reminder. | |
| std::string_view | key_name (Key key) noexcept |
| Stable name of a key, as written in settings files. | |
| std::optional< Key > | key_from_name (std::string_view name) |
Key whose name is name, ignoring case. | |
| std::string | key_label (Key key) |
| Name of a key as shown to the player, such as in a controls reminder. | |
| std::string_view | name () noexcept |
| Name of the module, used to check that it is linked. | |
| std::filesystem::path | settings_dir (std::string_view organization, std::string_view application) |
| Folder of the player's settings for one game, created if needed. | |
| core::Config | read_settings (const std::filesystem::path &file) |
| Reads the player's settings file. | |
| bool | pop_back_utf8 (std::string &text) noexcept |
| Removes the last UTF-8 code point of a string, as Backspace does. | |
Variables | |
| constexpr std::size_t | gamepad_button_count |
| Number of GamepadButton values. | |
| constexpr std::size_t | gamepad_axis_count |
| Number of GamepadAxis values. | |
| constexpr std::size_t | key_count = static_cast<std::size_t>(Key::KeypadEnter) + 1 |
| Number of keys in Key, to size per-key tables. | |
| constexpr std::size_t | mouse_button_count = static_cast<std::size_t>(MouseButton::X2) + 1 |
| Number of MouseButton values. | |
Window and input on top of SDL3, independent of the graphics API (client only).
| using aegis2d::platform::ActionId = typedef std::size_t |
Identifier of an action in its ActionMap, given by ActionMap::add().
| using aegis2d::platform::ActionLabels = typedef std::map<std::string, std::string, std::less<> > |
Display labels of actions, by action name: {"up", "Move up"}.
|
strong |
Analog controls of a gamepad.
|
strong |
Buttons of a gamepad, named by their position on the pad.
The four face buttons are named by side: South is A on an Xbox pad, Cross on a PlayStation pad and B on a Nintendo pad. Triggers and stick directions also act as buttons, held while pushed far enough (Gamepad::press_threshold), so actions bind to them like to any button: the left stick moves the player as the D-pad does.
|
strong |
|
strong |
Graphics API the window is prepared for.
Some APIs need the window to be created for them; the render backend then attaches its context or swapchain to the window.
| Enumerator | |
|---|---|
| None | No API-specific setup (APIs that only need the native window, or none). |
| OpenGL | The window can receive an OpenGL context (render::opengl::Context). |
|
strong |
Keyboard key, independent of SDL.
Letters, digits and symbols follow the character printed on the key in the user's layout, so the key labeled Z on an AZERTY keyboard is Key::Z; keys whose character has no Key (such as & on the AZERTY digit row) fall back to their position on a US keyboard (Key::Num1). NumN are the digits of the main row, KeypadN those of the numeric keypad.
|
strong |
| std::string aegis2d::platform::action_label | ( | std::string_view | name | ) |
Default label of an action name.
| name | Action name, such as "move-up". |
- and _ as spaces: "Move up". | std::optional< GamepadButton > aegis2d::platform::button_from_name | ( | std::string_view | name | ) |
Button whose name is name, ignoring case.
| name | Name returned by button_name(), such as "south" or "RightTrigger". |
| std::string aegis2d::platform::button_label | ( | GamepadButton | button, |
| GamepadStyle | style = {} |
||
| ) |
Name of a button as printed on a pad of the given family, for a controls reminder.
Face, shoulder, trigger and center buttons get their family's label ("A", "Cross", "RB", "R2", "ZR", "Menu"); the D-pad and the sticks are spelled out ("D-pad up", "Left stick left", "LS" for the left stick pressed in).
| button | Button to name. |
| style | Family of the pad, such as Gamepad::style(). |
"Unknown" for a value outside GamepadButton.
|
noexcept |
Stable name of a button, as written in settings files.
The enumerator's name: "South", "DpadUp", "LeftStickLeft".
| button | Button to name. |
"Unknown" for a value outside GamepadButton. | std::string aegis2d::platform::buttons_label | ( | const ActionMap & | actions, |
| ActionId | action, | ||
| GamepadStyle | style | ||
| ) |
The gamepad buttons of an action as printed on the player's pad.
| actions | Actions of the game. |
| action | Action to describe. |
| style | Family of the pad, usually window.gamepad().style(). |
" / ", in the order they were bound, or "not bound" when it has none. | std::out_of_range | if action is not declared. |
| std::vector< ControlLine > aegis2d::platform::control_lines | ( | const ActionMap & | actions, |
| const ActionLabels & | labels = {} |
||
| ) |
Every action with the keys that trigger it now, in the order they were declared.
Built from the bindings in use, so a reminder shows the player's own keys after a remap (#51), not the defaults.
| actions | Actions of the game. |
| labels | Display labels by action name; other actions use action_label(). |
| std::vector< ControlLine > aegis2d::platform::control_lines | ( | const ActionMap & | actions, |
| GamepadStyle | style, | ||
| const ActionLabels & | labels = {} |
||
| ) |
Every action with the gamepad buttons that trigger it now, for a player using a pad, in the order they were declared.
| actions | Actions of the game. |
| style | Family of the player's pad, usually window.gamepad().style(). |
| labels | Display labels by action name; other actions use action_label(). |
keys holding buttons_label(). | std::optional< Key > aegis2d::platform::key_from_name | ( | std::string_view | name | ) |
Key whose name is name, ignoring case.
| name | Name returned by key_name(), such as "space" or "F5". |
| std::string aegis2d::platform::key_label | ( | Key | key | ) |
Name of a key as shown to the player, such as in a controls reminder.
key_name() split into words: "Left Shift", "Page Up", "Keypad 5"; single letters, digits and function keys stay as they are ("A", "7", "F5").
| key | Key to name. |
"Unknown" for a value outside Key.
|
noexcept |
Stable name of a key, as written in settings files.
Letters are upper case ("A"), digits are "0" to "9", the other names are the enumerator's ("Space", "LeftShift", "Keypad0").
| key | Key to name. |
"Unknown" for a value outside Key. The keys of an action as shown to the player.
| actions | Actions of the game. |
| action | Action to describe. |
" / ", in the order they were bound, or "not bound" when it has none. | std::out_of_range | if action is not declared. |
|
noexcept |
Name of the module, used to check that it is linked.
"platform", a view of a static string.
|
noexcept |
Removes the last UTF-8 code point of a string, as Backspace does.
| text | UTF-8 text; unchanged when empty. |
true if something was removed. | core::Config aegis2d::platform::read_settings | ( | const std::filesystem::path & | file | ) |
Reads the player's settings file.
A missing file gives an empty configuration: it is the first start. A file that cannot be read or parsed is logged as a warning and gives an empty configuration too, so a broken settings file never stops the game; the next save replaces it.
| file | Settings file, usually settings_dir(...) / "settings.json". |
| std::filesystem::path aegis2d::platform::settings_dir | ( | std::string_view | organization, |
| std::string_view | application | ||
| ) |
Folder of the player's settings for one game, created if needed.
The per-user folder the operating system gives for application data (SDL's "pref path"), outside the game folder so settings survive an update and each player of a shared computer has their own: under APPDATA% on Windows, ~/Library/Application Support on macOS, $XDG_DATA_HOME (by default ~/.local/share) on Linux.
| organization | Name of the studio, such as "Aegis2D": letters, digits and spaces. |
| application | Name of the game, such as "RType"; never change it once released. |
| std::runtime_error | if the operating system gives no such folder. |
|
inlineconstexpr |
Number of GamepadAxis values.
|
inlineconstexpr |
Number of GamepadButton values.
|
inlineconstexpr |
Number of keys in Key, to size per-key tables.
|
inlineconstexpr |
Number of MouseButton values.