persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
TextComponent Class Reference

#include <TextComponent.hpp>

Inheritance diagram for TextComponent:
Collaboration diagram for TextComponent:

Public Member Functions

void init () override
void destroy () override
 Sets active to false on component destruction.
void update (ae::q20_12_t) override
ae::ComponentTypeID getType () const override
void configureText (const TextConfig &config, bool loadDefaultPalette=true)
 Configure the text system.
void drawText (const std::string &text, int x, int y, int color=TextColor::White, int xBoundary=256)
 A wrapper for drawText in TextSystem. Draws text to the screen.
void appearText (const std::string &text, int x, int y, int color=TextColor::White, int maxX=256, int maxY=0, bool hyphenate=false)
 A wrapper for appearText in TextSystem. Simulates text typing effect.
void appearTextSkip ()
 A wrapper for appearTextSkip in TextSystem. If a text is currently being rendered with appearText, this function will immediately render the rest of the text without delay.
bool appearTextPaused ()
 Check if the paginated text is waiting for the next page.
void appearTextNextPage ()
 Clear the text area and continue the paused text from the top of it.
void appearTextStop ()
 Stops the appearText animation immediately and clears the state.
bool appearTextDone ()
 A wrapper for appearTextDone in TextSystem. Check if the text being rendered with appearText has finished appearing.
void drawGlyph (const Glyph &glyph, int x, int y, int color, bool bold=false, bool italic=false, bool underline=false)
 A wrapper for drawGlyph in TextSystem. Draw a single glyph to the screen.
Glyph * getGlyph (const char &c, bool bold=false)
 Returns the Glyph struct for a given character. Useful for when drawing single characters from outside the text component.
void clearArea (int x, int y, int width, int height)
 A wrapper for clearArea in TextSystem. Clear a rectangular area of the text video buffer.
void clearScreen ()
 A wrapper for clearScreen in TextManager. Clear the text layer by filling the video buffer with black.
int getFontSize ()
 A getter to return the font size.
int getLineSpacing ()
 A getter to return the line spacing.
int getLetterSpacing ()
 A getter to return the letter spacing.
int getSpaceWidth ()
 A getter to return the space width (width of a ' ' character).
void setLetterSpacing (int value)
 Manually override the auto-calculated letter spacing.
void setLineSpacing (int value)
 Manually override the auto-calculated line spacing.
void setSpaceWidth (int value)
 Manually override the auto-calculated space width.

Static Public Attributes

static constexpr ae::ComponentTypeID TYPE_ID = static_cast<ae::ComponentTypeID>(ComponentType::Text)

Protected Member Functions

void submitToManager () override

Private Member Functions

void testBitmap ()
 A wrapper for testBitmap in TextSystem.
void testPalette ()
 A wrapper for testPalette in TextSystem.

Private Attributes

TextSystem & ts = TextSystem::getInstance()
TextManager & tm = TextManager::getInstance()
std::unique_ptr< Text > appearingText
std::unique_ptr< Font > font
uint16_t * videoBuffer = nullptr
int fontSize = 0
int letterSpacing = 1
 Auto-derived from fontSize in configureText(); can be overridden manually via the setters above.
int lineSpacing = 2
int spaceWidth = 2

Detailed Description

Definition at line 18 of file TextComponent.hpp.

Member Function Documentation

◆ appearText()

void TextComponent::appearText ( const std::string & text,
int x,
int y,
int color = TextColor::White,
int maxX = 256,
int maxY = 0,
bool hyphenate = false )

A wrapper for appearText in TextSystem. Simulates text typing effect.

Parameters
textThe text to render.
xThe x-coordinate to start drawing the text.
yThe y-coordinate to start drawing the text.
colorThe color to use for the text (default is white).
maxXRight edge (exclusive) used for word wrapping (default is the screen width).
maxYBottom edge of the text area. When the next line would not fit above it, the text pauses until appearTextNextPage() is called. 0 (default) disables pagination.
hyphenateEnable character-based splitting of overlong words.
See also
appearText

Definition at line 100 of file TextComponent.cpp.

Here is the call graph for this function:

◆ appearTextDone()

bool TextComponent::appearTextDone ( )

A wrapper for appearTextDone in TextSystem. Check if the text being rendered with appearText has finished appearing.

Returns
true if the text has finished appearing, false otherwise.
See also
appearTextDone

Definition at line 142 of file TextComponent.cpp.

◆ appearTextNextPage()

void TextComponent::appearTextNextPage ( )

Clear the text area and continue the paused text from the top of it.

Note
Does nothing if the text is not paused.

Definition at line 132 of file TextComponent.cpp.

◆ appearTextPaused()

bool TextComponent::appearTextPaused ( )

Check if the paginated text is waiting for the next page.

Returns
true if the current page is full and more text remains, false otherwise.

Definition at line 127 of file TextComponent.cpp.

◆ appearTextSkip()

void TextComponent::appearTextSkip ( )

A wrapper for appearTextSkip in TextSystem. If a text is currently being rendered with appearText, this function will immediately render the rest of the text without delay.

Note
Stops at the end of the current page if the text is paginated.
See also
appearTextSkip

Definition at line 122 of file TextComponent.cpp.

◆ appearTextStop()

void TextComponent::appearTextStop ( )

Stops the appearText animation immediately and clears the state.

Definition at line 137 of file TextComponent.cpp.

Here is the caller graph for this function:

◆ clearArea()

void TextComponent::clearArea ( int x,
int y,
int width,
int height )

A wrapper for clearArea in TextSystem. Clear a rectangular area of the text video buffer.

Parameters
xThe x-coordinate of the top-left corner of the area to clear.
yThe y-coordinate of the top-left corner of the area to clear.
widthThe width of the area to clear.
heightThe height of the area to clear.
See also
clearArea

Definition at line 165 of file TextComponent.cpp.

◆ clearScreen()

void TextComponent::clearScreen ( )

A wrapper for clearScreen in TextManager. Clear the text layer by filling the video buffer with black.

See also
clearScreen

Definition at line 170 of file TextComponent.cpp.

Here is the call graph for this function:

◆ configureText()

void TextComponent::configureText ( const TextConfig & config,
bool loadDefaultPalette = true )

Configure the text system.

Required to call before calling start(). Sets the font, font bitmap, font palette, and font metadata information

Parameters
configThe struct containing the text configuration to apply.
loadDefaultPaletteFlag to load the default font palette if true
Note
Loading a font and loading a font palette are mutually exclusive

Auto-derive spacing from fontSize, using the same ratios the old fixed defaults had at a 12px font (1/12 letter, 2/12 line, 2/12 space). Call the setters after configureText() to override any of these manually.

Definition at line 44 of file TextComponent.cpp.

Here is the call graph for this function:

◆ destroy()

void TextComponent::destroy ( )
override

Sets active to false on component destruction.

Definition at line 37 of file TextComponent.cpp.

Here is the call graph for this function:

◆ drawGlyph()

void TextComponent::drawGlyph ( const Glyph & glyph,
int x,
int y,
int color,
bool bold = false,
bool italic = false,
bool underline = false )

A wrapper for drawGlyph in TextSystem. Draw a single glyph to the screen.

Parameters
glyphThe glyph to draw.
xThe x-coordinate to start drawing the glyph.
yThe y-coordinate to start drawing the glyph.
colorThe color to use for the glyph.
boldWhether to use the bold version of the bitmap.
italicWhether the glyph should be sheared to simulate italic text.
underlineWhether the glyph should be underlined.
See also
drawGlyph

Definition at line 147 of file TextComponent.cpp.

◆ drawText()

void TextComponent::drawText ( const std::string & text,
int x,
int y,
int color = TextColor::White,
int xBoundary = 256 )

A wrapper for drawText in TextSystem. Draws text to the screen.

Parameters
textThe text to draw.
xThe x-coordinate to start drawing the text.
yThe y-coordinate to start drawing the text.
colorThe color to use for the text (default is white).
xBoundaryAn optional limit to the right side of a textbox, for when text is only supposed to take up an area of the screen.
See also
drawText

Definition at line 90 of file TextComponent.cpp.

Here is the call graph for this function:

◆ getFontSize()

int TextComponent::getFontSize ( )

A getter to return the font size.

Returns
The font size

Definition at line 176 of file TextComponent.cpp.

◆ getGlyph()

Glyph * TextComponent::getGlyph ( const char & c,
bool bold = false )

Returns the Glyph struct for a given character. Useful for when drawing single characters from outside the text component.

Definition at line 152 of file TextComponent.cpp.

◆ getLetterSpacing()

int TextComponent::getLetterSpacing ( )

A getter to return the letter spacing.

Returns
The letter spacing

Definition at line 186 of file TextComponent.cpp.

◆ getLineSpacing()

int TextComponent::getLineSpacing ( )

A getter to return the line spacing.

Returns
The line spacing

Definition at line 181 of file TextComponent.cpp.

◆ getSpaceWidth()

int TextComponent::getSpaceWidth ( )

A getter to return the space width (width of a ' ' character).

Returns
The space width

Definition at line 191 of file TextComponent.cpp.

◆ getType()

ae::ComponentTypeID TextComponent::getType ( ) const
inlineoverride

Definition at line 33 of file TextComponent.hpp.

◆ init()

void TextComponent::init ( )
inlineoverride

Definition at line 22 of file TextComponent.hpp.

◆ setLetterSpacing()

void TextComponent::setLetterSpacing ( int value)

Manually override the auto-calculated letter spacing.

Parameters
valuePixels of horizontal space to add after each glyph.

Definition at line 196 of file TextComponent.cpp.

◆ setLineSpacing()

void TextComponent::setLineSpacing ( int value)

Manually override the auto-calculated line spacing.

Parameters
valuePixels of vertical space to add after each line, on top of the font's line height.

Definition at line 201 of file TextComponent.cpp.

◆ setSpaceWidth()

void TextComponent::setSpaceWidth ( int value)

Manually override the auto-calculated space width.

Parameters
valuePixels of horizontal space a ' ' character takes up.

Definition at line 206 of file TextComponent.cpp.

◆ submitToManager()

void TextComponent::submitToManager ( )
inlineoverrideprotected

Definition at line 189 of file TextComponent.hpp.

◆ testBitmap()

void TextComponent::testBitmap ( )
private

A wrapper for testBitmap in TextSystem.

See also
testBitmap

Definition at line 211 of file TextComponent.cpp.

◆ testPalette()

void TextComponent::testPalette ( )
private

A wrapper for testPalette in TextSystem.

See also
testPalette

Definition at line 216 of file TextComponent.cpp.

◆ update()

void TextComponent::update ( ae::q20_12_t )
override

Definition at line 7 of file TextComponent.cpp.

Member Data Documentation

◆ appearingText

std::unique_ptr<Text> TextComponent::appearingText
private

Definition at line 197 of file TextComponent.hpp.

◆ font

std::unique_ptr<Font> TextComponent::font
private

Definition at line 198 of file TextComponent.hpp.

◆ fontSize

int TextComponent::fontSize = 0
private

Definition at line 200 of file TextComponent.hpp.

◆ letterSpacing

int TextComponent::letterSpacing = 1
private

Auto-derived from fontSize in configureText(); can be overridden manually via the setters above.

Definition at line 203 of file TextComponent.hpp.

◆ lineSpacing

int TextComponent::lineSpacing = 2
private

Definition at line 204 of file TextComponent.hpp.

◆ spaceWidth

int TextComponent::spaceWidth = 2
private

Definition at line 205 of file TextComponent.hpp.

◆ tm

TextManager& TextComponent::tm = TextManager::getInstance()
private

Definition at line 195 of file TextComponent.hpp.

◆ ts

TextSystem& TextComponent::ts = TextSystem::getInstance()
private

Definition at line 194 of file TextComponent.hpp.

◆ TYPE_ID

ae::ComponentTypeID TextComponent::TYPE_ID = static_cast<ae::ComponentTypeID>(ComponentType::Text)
staticconstexpr

Definition at line 21 of file TextComponent.hpp.

◆ videoBuffer

uint16_t* TextComponent::videoBuffer = nullptr
private

Definition at line 199 of file TextComponent.hpp.


The documentation for this class was generated from the following files: