class
#include <bn_sprite_text_generator.h>
sprite_text_generator Generates sprites containing text from a given sprite_
Currently, it supports 4 bits per pixel (16 colors) fixed width AND variable width characters.
Text can be printed in one sprite per character or multiple characters per sprite.
Also, UTF-8 characters are supported.
Public types
- enum class alignment_type: uint8_t { LEFT, CENTER, RIGHT }
- Available horizontal alignment types.
Constructors, destructors, conversion operators
-
sprite_text_generator(const sprite_
font& font) explicit - Constructor.
-
sprite_text_generator(const sprite_
font& font, const sprite_ palette_ item& palette_item) - Constructor.
Public functions
-
auto font() const -> const sprite_
font& - Returns the sprite font for drawing text.
-
auto palette_item() const -> const sprite_
palette_ item& - Returns the sprite_
palette_ item that generates the color palette used by the text sprites. -
void set_palette_item(const sprite_
palette_ item& palette_item) - Sets the 16 colors (4 bits per pixel) sprite_
palette_ item that generates the color palette used by the text sprites. -
auto alignment() const -> alignment_
type - Returns the horizontal alignment of the output text sprites.
-
void set_alignment(alignment_
type alignment) - Sets the horizontal alignment of the output text sprites.
- void set_left_alignment()
- Sets the horizontal alignment of the output text sprites to the left.
- void set_center_alignment()
- Sets the horizontal alignment of the output text sprites to the center.
- void set_right_alignment()
- Sets the horizontal alignment of the output text sprites to the right.
- auto bg_priority() const -> int
- Returns the priority of the output sprites priority relative to backgrounds.
- void set_bg_priority(int bg_priority)
- Sets the priority of the output sprites relative to backgrounds.
- auto z_order() const -> int
- Returns the priority of the output sprites relative to other sprites.
- void set_z_order(int z_order)
- Sets the priority of the output sprites relative to other sprites.
- auto mosaic_enabled() const -> bool
- Indicates if the mosaic effect must be applied to the output sprites or not.
- void set_mosaic_enabled(bool mosaic_enabled)
- Sets if the mosaic effect must be applied to the output sprites or not.
- auto blending_enabled() const -> bool
- Indicates if blending must be applied to the output sprites or not.
- void set_blending_enabled(bool blending_enabled)
- Sets if blending must be applied to the output sprites or not.
- auto visible() const -> bool
- Indicates if the output sprites must be committed to the GBA or not.
- void set_visible(bool visible)
- Sets if the output sprites must be committed to the GBA or not.
-
auto camera() const -> const optional<camera_
ptr>& - Returns the camera_
ptr to attach to the output sprites (if any). -
void set_camera(const camera_
ptr& camera) - Sets the camera_
ptr to attach to the output sprites. -
void set_camera(camera_
ptr&& camera) - Sets the camera_
ptr to attach to the output sprites. -
void set_camera(const optional<camera_
ptr>& camera) - Sets or removes the camera_
ptr to attach to the output sprites. -
void set_camera(optional<camera_
ptr>&& camera) - Sets or removes the camera_
ptr to attach to the output sprites. - void remove_camera()
- Removes the camera_
ptr to attach to the output sprites. -
auto release_camera() -> optional<camera_
ptr> - Releases and returns the camera_
ptr to attach to the output sprites (if any). - auto one_sprite_per_character() const -> bool
- Indicates if this sprite_
text_ generator must generate one sprite per character or print multiple characters in each output sprite, generating as less sprites as possible. - void set_one_sprite_per_character(bool one_sprite_per_character)
- Sets if this sprite_
text_ generator must generate one sprite per character or print multiple characters in each output sprite, generating as less sprites as possible. -
auto width(const string_
view& text) const -> int - Returns the width in pixels of the given text.
-
template<int MaxSprites>auto generate(const string_
view& text) const -> vector<sprite_ ptr, MaxSprites> - Generates text sprites for the given single line of text.
-
template<int MaxSprites>auto generate(fixed x, fixed y, const string_
view& text) const -> vector<sprite_ ptr, MaxSprites> - Generates text sprites for the given single line of text.
-
template<int MaxSprites>auto generate(const fixed_
point& position, const string_ view& text) const -> vector<sprite_ ptr, MaxSprites> - Generates text sprites for the given single line of text.
-
void generate(const string_
view& text, ivector<sprite_ ptr>& output_sprites) const - Generates text sprites for the given single line of text.
-
void generate(fixed x,
fixed y,
const string_
view& text, ivector<sprite_ ptr>& output_sprites) const - Generates text sprites for the given single line of text.
-
void generate(const fixed_
point& position, const string_ view& text, ivector<sprite_ ptr>& output_sprites) const - Generates text sprites for the given single line of text.
-
template<int MaxSprites>auto generate_top_left(fixed top_left_x, fixed top_left_y, const string_
view& text) const -> vector<sprite_ ptr, MaxSprites> - Generates text sprites for the given single line of text.
-
template<int MaxSprites>auto generate_top_left(const fixed_
point& top_left_position, const string_ view& text) const -> vector<sprite_ ptr, MaxSprites> - Generates text sprites for the given single line of text.
-
void generate_top_left(fixed top_left_x,
fixed top_left_y,
const string_
view& text, ivector<sprite_ ptr>& output_sprites) const - Generates text sprites for the given single line of text.
-
void generate_top_left(const fixed_
point& top_left_position, const string_ view& text, ivector<sprite_ ptr>& output_sprites) const - Generates text sprites for the given single line of text.
-
auto generate_optional(const string_
view& text, ivector<sprite_ ptr>& output_sprites) const -> bool - Generates text sprites for the given single line of text.
-
auto generate_optional(fixed x,
fixed y,
const string_
view& text, ivector<sprite_ ptr>& output_sprites) const -> bool - Generates text sprites for the given single line of text.
-
auto generate_optional(const fixed_
point& position, const string_ view& text, ivector<sprite_ ptr>& output_sprites) const -> bool - Generates text sprites for the given single line of text.
-
auto generate_top_left_optional(fixed top_left_x,
fixed top_left_y,
const string_
view& text, ivector<sprite_ ptr>& output_sprites) const -> bool - Generates text sprites for the given single line of text.
-
auto generate_top_left_optional(const fixed_
point& top_left_position, const string_ view& text, ivector<sprite_ ptr>& output_sprites) const -> bool - Generates text sprites for the given single line of text.
Enum documentation
enum class bn:: sprite_text_generator:: alignment_type: uint8_t
Available horizontal alignment types.
Enumerators | |
---|---|
LEFT |
Aligns with the left text edge. |
CENTER |
Aligns with the middle of the text. |
RIGHT |
Aligns with the right text edge. |
Function documentation
bn:: sprite_text_generator:: sprite_text_generator(const sprite_ font& font) explicit
Constructor.
Parameters | |
---|---|
font | Sprite font for drawing text. |
bn:: sprite_text_generator:: sprite_text_generator(const sprite_ font& font,
const sprite_ palette_ item& palette_item)
Constructor.
Parameters | |
---|---|
font | Sprite font for drawing text. |
palette_item | 16 colors (4 bits per pixel) sprite_ |
int bn:: sprite_text_generator:: bg_priority() const
Returns the priority of the output sprites priority relative to backgrounds.
Sprites with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds). Sprites cover backgrounds of the same priority.
void bn:: sprite_text_generator:: set_bg_priority(int bg_priority)
Sets the priority of the output sprites relative to backgrounds.
Parameters | |
---|---|
bg_priority | Priority relative to backgrounds in the range [0..3]. |
Sprites with higher priority are drawn first (and therefore can be covered by later sprites and backgrounds). Sprites cover backgrounds of the same priority.
int bn:: sprite_text_generator:: z_order() const
Returns the priority of the output sprites relative to other sprites.
Sprites with higher z orders are drawn first (and therefore can be covered by later sprites).
void bn:: sprite_text_generator:: set_z_order(int z_order)
Sets the priority of the output sprites relative to other sprites.
Parameters | |
---|---|
z_order | Priority relative to other sprites in the range [-32767..32767]. |
Sprites with higher z orders are drawn first (and therefore can be covered by later sprites).
template<int MaxSprites>
vector<sprite_ ptr, MaxSprites> bn:: sprite_text_generator:: generate(const string_ view& text) const
Generates text sprites for the given single line of text.
Template parameters | |
---|---|
MaxSprites | Maximum size of the returned sprite_ |
Parameters | |
text | Single line of text to print. |
Returns | sprite_ |
template<int MaxSprites>
vector<sprite_ ptr, MaxSprites> bn:: sprite_text_generator:: generate(fixed x,
fixed y,
const string_ view& text) const
Generates text sprites for the given single line of text.
Template parameters | |
---|---|
MaxSprites | Maximum size of the returned sprite_ |
Parameters | |
x | Horizontal position of the first generated sprite, considering the current alignment. |
y | Vertical position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
Returns | sprite_ |
template<int MaxSprites>
vector<sprite_ ptr, MaxSprites> bn:: sprite_text_generator:: generate(const fixed_ point& position,
const string_ view& text) const
Generates text sprites for the given single line of text.
Template parameters | |
---|---|
MaxSprites | Maximum size of the returned sprite_ |
Parameters | |
position | Position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
Returns | sprite_ |
void bn:: sprite_text_generator:: generate(const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Keep in mind that this vector is not cleared before generating text.
void bn:: sprite_text_generator:: generate(fixed x,
fixed y,
const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
x | Horizontal position of the first generated sprite, considering the current alignment. |
y | Vertical position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Keep in mind that this vector is not cleared before generating text.
void bn:: sprite_text_generator:: generate(const fixed_ point& position,
const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
position | Position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Keep in mind that this vector is not cleared before generating text.
template<int MaxSprites>
vector<sprite_ ptr, MaxSprites> bn:: sprite_text_generator:: generate_top_left(fixed top_left_x,
fixed top_left_y,
const string_ view& text) const
Generates text sprites for the given single line of text.
Template parameters | |
---|---|
MaxSprites | Maximum size of the returned sprite_ |
Parameters | |
top_left_x | Horizontal top-left position of the first generated sprite, considering the current alignment. |
top_left_y | Vertical top-left position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
Returns | sprite_ |
template<int MaxSprites>
vector<sprite_ ptr, MaxSprites> bn:: sprite_text_generator:: generate_top_left(const fixed_ point& top_left_position,
const string_ view& text) const
Generates text sprites for the given single line of text.
Template parameters | |
---|---|
MaxSprites | Maximum size of the returned sprite_ |
Parameters | |
top_left_position | Top-left position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
Returns | sprite_ |
void bn:: sprite_text_generator:: generate_top_left(fixed top_left_x,
fixed top_left_y,
const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
top_left_x | Horizontal top-left position of the first generated sprite, considering the current alignment. |
top_left_y | Vertical top-left position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Keep in mind that this vector is not cleared before generating text.
void bn:: sprite_text_generator:: generate_top_left(const fixed_ point& top_left_position,
const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
top_left_position | Top-left position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Keep in mind that this vector is not cleared before generating text.
bool bn:: sprite_text_generator:: generate_optional(const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Returns | true if the text generation finished successfully, otherwise false . |
Keep in mind that this vector is not cleared before generating text.
bool bn:: sprite_text_generator:: generate_optional(fixed x,
fixed y,
const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
x | Horizontal position of the first generated sprite, considering the current alignment. |
y | Vertical position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Returns | true if the text generation finished successfully, otherwise false . |
Keep in mind that this vector is not cleared before generating text.
bool bn:: sprite_text_generator:: generate_optional(const fixed_ point& position,
const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
position | Position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Returns | true if the text generation finished successfully, otherwise false . |
Keep in mind that this vector is not cleared before generating text.
bool bn:: sprite_text_generator:: generate_top_left_optional(fixed top_left_x,
fixed top_left_y,
const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
top_left_x | Horizontal top-left position of the first generated sprite, considering the current alignment. |
top_left_y | Vertical top-left position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Keep in mind that this vector is not cleared before generating text.
bool bn:: sprite_text_generator:: generate_top_left_optional(const fixed_ point& top_left_position,
const string_ view& text,
ivector<sprite_ ptr>& output_sprites) const
Generates text sprites for the given single line of text.
Parameters | |
---|---|
top_left_position | Top-left position of the first generated sprite, considering the current alignment. |
text | Single line of text to print. |
output_sprites | Generated text sprites are stored in this vector. |
Returns | true if the text generation finished successfully, otherwise false . |
Keep in mind that this vector is not cleared before generating text.