persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
TextComponent.hpp
Go to the documentation of this file.
1
8
9#pragma once
12#include "types/TextTypes.hpp"
13#include "types/aeTypes.hpp"
14
15#include <aegis/component.hpp>
16#include <memory>
17
18class TextComponent : public ae::Component
19{
20 public:
21 static constexpr ae::ComponentTypeID TYPE_ID = static_cast<ae::ComponentTypeID>(ComponentType::Text);
22 void init() override
23 {
24 }
25
29 void destroy() override;
30
31 void update(ae::q20_12_t /*dt*/) override;
32
33 ae::ComponentTypeID getType() const override
34 {
35 return TYPE_ID;
36 }
37
47 void configureText(const TextConfig& config, bool loadDefaultPalette = true);
48
58 void drawText(const std::string& text, int x, int y, int color = TextColor::White, int xBoundary = 256);
59
72 void appearText(const std::string& text,
73 int x,
74 int y,
75 int color = TextColor::White,
76 int maxX = 256,
77 int maxY = 0,
78 bool hyphenate = false);
79
85 void appearTextSkip();
86
91 bool appearTextPaused();
92
97 void appearTextNextPage();
98
102 void appearTextStop();
103
109 bool appearTextDone();
110
122 void drawGlyph(
123 const Glyph& glyph, int x, int y, int color, bool bold = false, bool italic = false, bool underline = false);
124
128 Glyph* getGlyph(const char& c, bool bold = false);
129
138 void clearArea(int x, int y, int width, int height);
139
144 void clearScreen();
145
150 int getFontSize();
151
156 int getLineSpacing();
157
162 int getLetterSpacing();
163
168 int getSpaceWidth();
169
174 void setLetterSpacing(int value);
175
180 void setLineSpacing(int value);
181
186 void setSpaceWidth(int value);
187
188 protected:
189 void submitToManager() override
190 {
191 }
192
193 private:
194 TextSystem& ts = TextSystem::getInstance();
195 TextManager& tm = TextManager::getInstance();
196
197 std::unique_ptr<Text> appearingText;
198 std::unique_ptr<Font> font;
199 uint16_t* videoBuffer = nullptr;
200 int fontSize = 0;
201
204 int lineSpacing = 2;
205 int spaceWidth = 2;
206
211 void testBitmap();
212
217 void testPalette();
218};
Manager for text loading.
Manages rendering text from a bitmap.
@ White
Definition TextTypes.hpp:14
void configureText(const TextConfig &config, bool loadDefaultPalette=true)
Configure the text system.
void init() override
int getLetterSpacing()
A getter to return the letter spacing.
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.
ae::ComponentTypeID getType() const override
void appearTextSkip()
A wrapper for appearTextSkip in TextSystem. If a text is currently being rendered with appearText,...
std::unique_ptr< Font > font
void testPalette()
A wrapper for testPalette in TextSystem.
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.
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 update(ae::q20_12_t) override
void testBitmap()
A wrapper for testBitmap in TextSystem.
int getSpaceWidth()
A getter to return the space width (width of a ' ' character).
std::unique_ptr< Text > appearingText
static constexpr ae::ComponentTypeID TYPE_ID
void appearTextStop()
Stops the appearText animation immediately and clears the state.
TextSystem & ts
int letterSpacing
Auto-derived from fontSize in configureText(); can be overridden manually via the setters above.
void setSpaceWidth(int value)
Manually override the auto-calculated space width.
int getLineSpacing()
A getter to return the line spacing.
uint16_t * videoBuffer
bool appearTextDone()
A wrapper for appearTextDone in TextSystem. Check if the text being rendered with appearText has fini...
void submitToManager() override
void setLetterSpacing(int value)
Manually override the auto-calculated letter spacing.
bool appearTextPaused()
Check if the paginated text is waiting for the next page.
void destroy() override
Sets active to false on component destruction.
Glyph * getGlyph(const char &c, bool bold=false)
Returns the Glyph struct for a given character. Useful for when drawing single characters from outsid...
void appearTextNextPage()
Clear the text area and continue the paused text from the top of it.
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 setLineSpacing(int value)
Manually override the auto-calculated line spacing.
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.
TextManager & tm
Stores data for a single glyph (character) in a font.
Definition TextTypes.hpp:55
A struct that holds initial config values for the TextComponent.