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

#include <TextSystem.hpp>

Inheritance diagram for TextSystem:
Collaboration diagram for TextSystem:

Public Member Functions

void init () override
void shutdown () override
void update (ae::q20_12_t) override
void drawText (const std::string &text, Font *font, uint16_t *videoBuffer, int x, int y, int color, int letterSpacing, int lineSpacing, int spaceWidth, int xBoundary)
 Draw text to the screen.
void appearText (std::unique_ptr< Text > &appearingText, const std::string &text, Font *font, uint16_t *videoBuffer, int x, int y, int color, int letterSpacing, int lineSpacing, int spaceWidth, int maxX=256, int maxY=0, bool hyphenate=false)
 Create a Text object and renders each character with a delay to simulate typing effect.
void appearTextSkip (Text *appearingText)
 If a text is currently being rendered with appearText, this function will immediately render the rest of the text without delay.
bool appearTextPaused (Text *appearingText)
 Check if the text being rendered with appearText is waiting for the next page.
void appearTextNextPage (Text *appearingText)
 Clear the text area and continue the paused text from the top of it.
bool appearTextDone (Text *appearingText)
 Check if the text being rendered with appearText has finished appearing.
void drawGlyph (const Glyph &glyph, Font *font, uint16_t *videoBuffer, int x, int y, int color, bool bold, bool italic, bool underline)
 Draw a single glyph to the screen.
void clearArea (uint16_t *videoBuffer, int x, int y, int width, int height)
 Clear a rectangular area of the text video buffer.

Private Member Functions

void drawNextFromText (Text *text)
 Draw the next character from the text struct to the screen.
std::unique_ptr< Text > createText (const std::string &text, Font *font, uint16_t *videoBuffer, int startX, int startY, int color, int letterSpacing, int lineSpacing, int spaceWidth, int maxX=256, int maxY=0)
 Create a Text object and initialize its properties.
char getNextChar (Text *text)
 Get the next character from a given Text object.
void drawPixel (uint16_t *videoBuffer, int x, int y, int paletteValue)
 Draw a single pixel to the video buffer.
void underlineGap (int startX, int y, int width, uint16_t *videoBuffer, int color)
 Underline a specificed area.
void testBitmap (Font *font, uint16_t *videoBuffer)
 Test function to draw the font bitmap to the screen.
void testPalette (uint16_t *videoBuffer)
 Test function to draw the currently loaded palette to the screen.

Private Attributes

int APPEAR_DELAY = 2
int SLANT_FACTOR = 64
 128 = 1 pixel shift every 2 rows, 64 = 1 pixel shift every 4 rows

Friends

class Singleton< TextSystem >
class TextComponent

Detailed Description

Definition at line 14 of file TextSystem.hpp.

Member Function Documentation

◆ appearText()

void TextSystem::appearText ( std::unique_ptr< Text > & appearingText,
const std::string & text,
Font * font,
uint16_t * videoBuffer,
int x,
int y,
int color,
int letterSpacing,
int lineSpacing,
int spaceWidth,
int maxX = 256,
int maxY = 0,
bool hyphenate = false )

Create a Text object and renders each character with a delay to simulate typing effect.

Parameters
appearingTextThe current apperance of the text
textThe text to render.
fontPointer to the font to use for rendering.
videoBufferPointer to the video buffer to draw to.
xThe x-coordinate to start drawing the text.
yThe y-coordinate to start drawing the text.
colorThe color to use for the text.
letterSpacingPixels of horizontal space to add after each glyph.
lineSpacingPixels of vertical space to add after each line, on top of the font's line height.
spaceWidthPixels of horizontal space a ' ' character takes up.
maxXRight edge (exclusive) used for word wrapping.
maxYBottom edge of the text area. When a line would not fit above it, the text pauses until appearTextNextPage() is called. 0 disables pagination.
hyphenateEnable character-based splitting of overlong words (dialogue only).

Definition at line 34 of file TextSystem.cpp.

Here is the call graph for this function:

◆ appearTextDone()

bool TextSystem::appearTextDone ( Text * appearingText)

Check if the text being rendered with appearText has finished appearing.

Parameters
appearingTextThe current apperance of the text
Returns
true if the text has finished appearing, false otherwise.

Definition at line 101 of file TextSystem.cpp.

◆ appearTextNextPage()

void TextSystem::appearTextNextPage ( Text * appearingText)

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

Parameters
appearingTextThe current apperance of the text

Definition at line 83 of file TextSystem.cpp.

Here is the call graph for this function:

◆ appearTextPaused()

bool TextSystem::appearTextPaused ( Text * appearingText)

Check if the text being rendered with appearText is waiting for the next page.

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

Definition at line 78 of file TextSystem.cpp.

Here is the caller graph for this function:

◆ appearTextSkip()

void TextSystem::appearTextSkip ( Text * appearingText)

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.
Parameters
appearingTextThe current apperance of the text

Definition at line 63 of file TextSystem.cpp.

Here is the call graph for this function:

◆ clearArea()

void TextSystem::clearArea ( uint16_t * videoBuffer,
int x,
int y,
int width,
int height )

Clear a rectangular area of the text video buffer.

Parameters
videoBufferPointer to the video buffer to clear.
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.

Definition at line 174 of file TextSystem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createText()

std::unique_ptr< Text > TextSystem::createText ( const std::string & text,
Font * font,
uint16_t * videoBuffer,
int startX,
int startY,
int color,
int letterSpacing,
int lineSpacing,
int spaceWidth,
int maxX = 256,
int maxY = 0 )
private

Create a Text object and initialize its properties.

Parameters
textThe text content for the Text object.
fontPointer to the font to use for rendering the text.
videoBufferPointer to the video buffer to draw to.
startXThe x-coordinate to start drawing the text.
startYThe y-coordinate to start drawing the text.
colorThe color to use for the text.
letterSpacingPixels of horizontal space to add after each glyph.
lineSpacingPixels of vertical space to add after each line, on top of the font's line height.
spaceWidthPixels of horizontal space a ' ' character takes up.
maxXRight edge (exclusive) used for word wrapping.
maxYBottom edge used for pagination. 0 disables pagination.
Returns
Owning pointer to the newly created Text object.

Definition at line 324 of file TextSystem.cpp.

Here is the caller graph for this function:

◆ drawGlyph()

void TextSystem::drawGlyph ( const Glyph & glyph,
Font * font,
uint16_t * videoBuffer,
int x,
int y,
int color,
bool bold,
bool italic,
bool underline )

Draw a single glyph to the screen.

Parameters
glyphThe glyph to draw.
fontPointer to the font that contains the glyph.
videoBufferPointer to the video buffer to draw to.
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.

Distance from baseline

Integer math equivalent of distY * (SLANT_FACTOR/256)

Position the underline just below the glyph

Definition at line 115 of file TextSystem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawNextFromText()

void TextSystem::drawNextFromText ( Text * text)
private

Draw the next character from the text struct to the screen.

Note
Used to draw text which appears character by character.

Handle Newline

Don't add a space at the beginning of a line

Handle special instructions for text formatting

Color change

Reset to base color

bg palette only has 256 colors

If the glyph width is 0, skip it (char has not been defined in the font)

Pause on the current character; it is drawn once the next page starts

Definition at line 214 of file TextSystem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawPixel()

void TextSystem::drawPixel ( uint16_t * videoBuffer,
int x,
int y,
int paletteValue )
private

Draw a single pixel to the video buffer.

Parameters
videoBufferPointer to the video buffer to draw to.
xThe x-coordinate of the pixel to draw.
yThe y-coordinate of the pixel to draw.
paletteValueThe color index in the palette to use for the pixel.

Definition at line 368 of file TextSystem.cpp.

Here is the caller graph for this function:

◆ drawText()

void TextSystem::drawText ( const std::string & text,
Font * font,
uint16_t * videoBuffer,
int x,
int y,
int color,
int letterSpacing,
int lineSpacing,
int spaceWidth,
int xBoundary )

Draw text to the screen.

Parameters
textThe text to draw.
fontPointer to the font to use for rendering.
videoBufferPointer to the video buffer to draw to.
xThe x-coordinate to start drawing the text.
yThe y-coordinate to start drawing the text.
colorThe color to use for the text.
letterSpacingPixels of horizontal space to add after each glyph.
lineSpacingPixels of vertical space to add after each line, on top of the font's line height.
spaceWidthPixels of horizontal space a ' ' character takes up.
xBoundaryRight edge (exclusive) used for word wrapping.

Definition at line 7 of file TextSystem.cpp.

Here is the call graph for this function:

◆ getNextChar()

char TextSystem::getNextChar ( Text * text)
private

Get the next character from a given Text object.

Parameters
textPointer to the Text object to extract the next character from.
Returns
The next character in the Text object's content, or a nullptr if there are no more characters.
Note
This function automatically increments the cursor position in the Text object.

Return a special value indicating no more characters

Definition at line 359 of file TextSystem.cpp.

Here is the caller graph for this function:

◆ init()

void TextSystem::init ( )
inlineoverride

Definition at line 17 of file TextSystem.hpp.

◆ shutdown()

void TextSystem::shutdown ( )
inlineoverride

Definition at line 21 of file TextSystem.hpp.

◆ testBitmap()

void TextSystem::testBitmap ( Font * font,
uint16_t * videoBuffer )
private

Test function to draw the font bitmap to the screen.

Parameters
fontPointer to the font to test.
videoBufferPointer to the video buffer to draw to.
Note
This function is intended for testing purposes.

Definition at line 394 of file TextSystem.cpp.

Here is the call graph for this function:

◆ testPalette()

void TextSystem::testPalette ( uint16_t * videoBuffer)
private

Test function to draw the currently loaded palette to the screen.

Parameters
videoBufferPointer to the video buffer to draw to.
Note
This function is intended for testing purposes.

Definition at line 410 of file TextSystem.cpp.

Here is the call graph for this function:

◆ underlineGap()

void TextSystem::underlineGap ( int startX,
int y,
int width,
uint16_t * videoBuffer,
int color )
private

Underline a specificed area.

Parameters
startXThe starting x-coordinate of the area to underline.
yThe y-coordinate of the area to underline.
widthThe width of the area to underline.
videoBufferPointer to the video buffer to draw to.
colorThe color to use for the underline.

This function draws a horizontal line of the specified width at the specified y-coordinate, starting from the specified x-coordinate. It should be used to underline gaps in the text, that are not handled by the regular text rendering, i.e. the gaps between letters or spaces.

Definition at line 382 of file TextSystem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void TextSystem::update ( ae::q20_12_t )
inlineoverride

Definition at line 25 of file TextSystem.hpp.

◆ Singleton< TextSystem >

friend class Singleton< TextSystem >
friend

Definition at line 141 of file TextSystem.hpp.

◆ TextComponent

friend class TextComponent
friend

Definition at line 145 of file TextSystem.hpp.

Member Data Documentation

◆ APPEAR_DELAY

int TextSystem::APPEAR_DELAY = 2
private

Definition at line 147 of file TextSystem.hpp.

◆ SLANT_FACTOR

int TextSystem::SLANT_FACTOR = 64
private

128 = 1 pixel shift every 2 rows, 64 = 1 pixel shift every 4 rows

Definition at line 149 of file TextSystem.hpp.


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