persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
TextTypes.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <cstdlib>
5#include <string>
6
11{
12 Transparent = 0, // 8bpp uses palette index 0 as transparent
13 Black = 235,
14 White = 236,
15 DualGreen = 237,
17 DarkGreen = 239,
20 LightBlue = 242,
21 RichBlue = 243,
22 DarkBlue = 244,
23 NavyBlue = 245,
27 Red = 249,
28 Green = 250,
29 Blue = 251,
30 Yellow = 252,
31 Magenta = 253,
32 Cyan = 254,
33 Gray = 255
34};
35
40{
43 StyleBold = 0x01,
46 Reset = 0xFF
47};
48
49inline constexpr unsigned char TextInstructionMarker = 0xFF;
50
54struct Glyph
55{
56 int xPos;
57 int yPos;
58 int width = 0;
59 int height;
62};
63
68struct Font
69{
70 Font() = default;
71
76 {
77 free(bitmap);
78 free(bitmapBold);
79 }
80
81 Font(const Font&) = delete;
82 Font& operator=(const Font&) = delete;
83
84 std::uint8_t* bitmap = nullptr;
85 std::uint8_t* bitmapBold = nullptr;
86 int bitmapWidth = 256;
87 int bitmapHeight = 256;
88 int lineHeight = 32;
91 bool boldLoaded = false;
92};
93
97struct Text
98{
103 std::string content;
105 uint16_t* videoBuffer;
110 bool bold;
111 bool italic;
116
118 int maxX = 256;
120 int maxY = 0;
122 bool pageBreak = false;
123 bool hyphenate = false;
124};
125
130{
131 uint16_t* videoBuffer = nullptr;
132
134 std::string* fontNamePath = nullptr;
136
138 std::string* fontBitmapPath = nullptr;
139
141 std::string* fontPalettePath = nullptr;
142 bool isSub;
143
145 std::string* fontMetadataPath = nullptr;
147
148 TextConfig() = default;
149
151 TextConfig(uint16_t* iVideoBuffer, std::string* iFontNamePath, int iFontSize)
152 : videoBuffer(iVideoBuffer), fontNamePath(iFontNamePath), fontSize(iFontSize)
153 {
154 }
155
157 TextConfig(uint16_t* iVideoBuffer, std::string* iFontPalettePath, bool iIsSub)
158 : videoBuffer(iVideoBuffer), fontPalettePath(iFontPalettePath), isSub(iIsSub)
159 {
160 }
161};
TextInstruction
Human readable enum for text instructions.
Definition TextTypes.hpp:40
@ StyleUnderline
Definition TextTypes.hpp:45
@ StyleChange
Definition TextTypes.hpp:42
@ Reset
Definition TextTypes.hpp:46
@ ColorChange
Definition TextTypes.hpp:41
@ StyleBold
Definition TextTypes.hpp:43
@ StyleItalic
Definition TextTypes.hpp:44
constexpr unsigned char TextInstructionMarker
Definition TextTypes.hpp:49
TextColor
Human Readable enum for text colors.
Definition TextTypes.hpp:11
@ NavyBlue
Definition TextTypes.hpp:23
@ LightBlue
Definition TextTypes.hpp:20
@ LightOrange
Definition TextTypes.hpp:25
@ DualGreen
Definition TextTypes.hpp:15
@ Gray
Definition TextTypes.hpp:33
@ DualGreen2
Definition TextTypes.hpp:16
@ DarkerGreen
Definition TextTypes.hpp:18
@ DarkestBlue
Definition TextTypes.hpp:24
@ DarkGreen
Definition TextTypes.hpp:17
@ DarkBlue
Definition TextTypes.hpp:22
@ Cyan
Definition TextTypes.hpp:32
@ Magenta
Definition TextTypes.hpp:31
@ White
Definition TextTypes.hpp:14
@ Yellow
Definition TextTypes.hpp:30
@ Black
Definition TextTypes.hpp:13
@ Transparent
Definition TextTypes.hpp:12
@ LightPurple
Definition TextTypes.hpp:26
@ Green
Definition TextTypes.hpp:28
@ RichBlue
Definition TextTypes.hpp:21
@ Red
Definition TextTypes.hpp:27
@ DarkestGreen
Definition TextTypes.hpp:19
@ Blue
Definition TextTypes.hpp:29
Stores data for a font.
Definition TextTypes.hpp:69
~Font()
Frees the regular and bold bitmaps.
Definition TextTypes.hpp:75
Font & operator=(const Font &)=delete
Glyph glyphs[256]
Definition TextTypes.hpp:89
std::uint8_t * bitmapBold
Definition TextTypes.hpp:85
std::uint8_t * bitmap
Definition TextTypes.hpp:84
Glyph boldGlyphs[256]
Definition TextTypes.hpp:90
int bitmapHeight
Definition TextTypes.hpp:87
Font(const Font &)=delete
Font()=default
int lineHeight
Definition TextTypes.hpp:88
bool boldLoaded
Definition TextTypes.hpp:91
int bitmapWidth
Definition TextTypes.hpp:86
Stores data for a single glyph (character) in a font.
Definition TextTypes.hpp:55
int xPos
Definition TextTypes.hpp:56
int yPos
Definition TextTypes.hpp:57
int height
Used to check if the glyph was read in correctly. Setting it to 0 here wipes any old data.
Definition TextTypes.hpp:59
int width
Definition TextTypes.hpp:58
int yOffset
Definition TextTypes.hpp:61
int xOffset
Definition TextTypes.hpp:60
TextConfig(uint16_t *iVideoBuffer, std::string *iFontNamePath, int iFontSize)
load font (loads font, font bitmap, font metadata. NOT font palette)
std::string * fontPalettePath
for loadPalette
std::string * fontBitmapPath
for loadFontBitmap
uint16_t * videoBuffer
std::string * fontMetadataPath
for loadFontMetadata
bool isBoldBitmap
std::string * fontNamePath
for loadFont
TextConfig()=default
TextConfig(uint16_t *iVideoBuffer, std::string *iFontPalettePath, bool iIsSub)
load font palette
A struct that represents a block of text being rendered on the screen.
Definition TextTypes.hpp:98
int startX
int letterSpacing
bool hyphenate
int cursorX
Definition TextTypes.hpp:99
bool underline
bool bold
uint16_t * videoBuffer
int maxY
Bottom edge used for pagination. 0 disables pagination.
bool pageBreak
Set when the next glyph would not fit above maxY. Output pauses until the next page is requested.
int maxX
Right edge (exclusive) used for word wrapping.
int baseColor
int cursorPos
std::string content
int lineSpacing
int spaceWidth
int cursorY
int activeColor
int counter
Font * font
bool italic
int startY