Size of the HUD and menu text chosen by the player, from 100% to 200%.
More...
#include <aegis2d/render/text_layout.hpp>
|
| float | scale () const noexcept |
| | The factor, brought into [smallest, largest]; not-a-number gives 1.
|
| |
| int | percent () const noexcept |
| | The size as shown in a menu.
|
| |
| void | larger () noexcept |
| | One step larger, up to largest.
|
| |
| void | smaller () noexcept |
| | One step smaller, down to smallest.
|
| |
| TextStyle | apply (TextStyle style) const noexcept |
| | Applies the size to a text style.
|
| |
| void | save (core::Config &settings, std::string_view path) const |
| | Writes the size into the player's settings.
|
| |
| void | load (const core::Config &settings, std::string_view path) |
| | Reads the size written by save().
|
| |
|
| float | factor = 1.0F |
| | Factor applied to every text: 1 for 100%, 1.5 for 150%.
|
| |
|
| static constexpr float | smallest = 1.0F |
| | Smallest scale, the size the game was designed for.
|
| |
| static constexpr float | largest = 2.0F |
| | Largest scale.
|
| |
| static constexpr float | step = 0.25F |
| | Change of one larger() or smaller() step.
|
| |
Size of the HUD and menu text chosen by the player, from 100% to 200%.
Players with low vision, or far from the screen, make the text larger. The game multiplies the scale of each text by scale() (see apply()), and lays its texts out with flow_layout() and BitmapFont::wrap(), so larger text moves to the next row or line instead of overlapping.
◆ apply()
Applies the size to a text style.
- Parameters
-
| style | Style designed at 100%. |
- Returns
style with its scale multiplied by scale().
◆ larger()
| void aegis2d::render::TextSize::larger |
( |
| ) |
|
|
noexcept |
One step larger, up to largest.
◆ load()
| void aegis2d::render::TextSize::load |
( |
const core::Config & |
settings, |
|
|
std::string_view |
path |
|
) |
| |
Reads the size written by save().
A missing value keeps the size; one that is not a number is logged and kept; values out of range are clamped.
- Parameters
-
◆ percent()
| int aegis2d::render::TextSize::percent |
( |
| ) |
const |
|
noexcept |
The size as shown in a menu.
- Returns
- scale() in percent, such as 150.
◆ save()
| void aegis2d::render::TextSize::save |
( |
core::Config & |
settings, |
|
|
std::string_view |
path |
|
) |
| const |
Writes the size into the player's settings.
- Parameters
-
| settings | Settings to update, then saved with core::Config::save(). |
| path | Dotted path of the value, such as "accessibility.text_size". |
◆ scale()
| float aegis2d::render::TextSize::scale |
( |
| ) |
const |
|
noexcept |
The factor, brought into [smallest, largest]; not-a-number gives 1.
- Returns
- The scale to multiply text by.
◆ smaller()
| void aegis2d::render::TextSize::smaller |
( |
| ) |
|
|
noexcept |
One step smaller, down to smallest.
◆ factor
| float aegis2d::render::TextSize::factor = 1.0F |
Factor applied to every text: 1 for 100%, 1.5 for 150%.
◆ largest
| constexpr float aegis2d::render::TextSize::largest = 2.0F |
|
staticconstexpr |
◆ smallest
| constexpr float aegis2d::render::TextSize::smallest = 1.0F |
|
staticconstexpr |
Smallest scale, the size the game was designed for.
◆ step
| constexpr float aegis2d::render::TextSize::step = 0.25F |
|
staticconstexpr |
The documentation for this struct was generated from the following file: