|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
The render pipeline for a single font-preview request. More...
#include <fontpreviewprovider.h>
Public Types | |
| enum | : int { IdPartTileset = 0 , IdPartType , IdPartFrame , IdPartWidth , IdPartHeight , IdPartBox , IdPart2Line , IdPartChop , IdPartBGColor , IdPartFGColor , IdPartPlaceHolder , IdPartStr , IdPart_END } |
| Index of each field within the parsed id-string. More... | |
Public Member Functions | |
| FontPreviewInstance (QStringList idParts, SaveFileExpanded *expanded, QSize *size, const QSize &requestedSize) | |
| void | setup (QStringList idParts) |
| Parse the id parts into the fields below. | |
| void | getInputStr () |
| Resolve the final input string (placeholder + str + names). | |
| void | getTiles () |
| Render the per-tile pixmaps for the text. | |
| void | getResultingText () |
| Convert the string to tile-code rows via FontsDB. | |
| void | getImageWidth () |
| Compute output width. | |
| void | getImageHeight () |
| Compute output height. | |
| void | getBaseImg () |
| Allocate the base image. | |
| void | drawBox () |
| Draw the dialogue box background, if requested. | |
| void | drawFg () |
| Draw the foreground text. | |
| void | finishImg () |
| Composite into the final pixmap. | |
| void | postProcess () |
| Apply any post-processing. | |
| void | getPlayersName () |
| Read the player's name from the save (for substitution). | |
| void | getRivalsName () |
| Read the rival's name from the save (for substitution). | |
Public Attributes | |
| QString | tileset |
| Tileset name (id part). | |
| QString | type |
| Type, e.g. "outdoor" (id part). | |
| int | frame = 0 |
| Animation frame (id part). | |
| int | toWidth = 0 |
| Target width (id part). | |
| int | toHeight = 0 |
| Target height (id part). | |
| bool | box = false |
| Render a dialogue box (id part). | |
| bool | lines2 = false |
| Render on two lines (id part). | |
| int | chopLen = 0 |
| Max line length before chopping (id part). | |
| QColor | bgColor |
| Background colour (id part). | |
| QColor | fgColor |
| Foreground/text colour (id part; "none" = don't paint). | |
| QString | placeholder |
| Template the str is inserted into (id part). | |
| QString | inputStr |
| The raw font string to render (id part). | |
| QStringList | idParts |
| The raw split id parts. | |
| QVector< QVector< var8 > > | resultingText |
| Text as tile-code rows. | |
| QImage | bgImg |
| Background layer. | |
| QImage | baseImg |
| Base canvas. | |
| QImage | boxImg |
| Box layer. | |
| QImage | fgImg |
| Foreground layer. | |
| QPixmap | resultingImg |
| The finished pixmap. | |
| QVector< QPixmap > | tiles |
| Per-character tile pixmaps. | |
| QString | playersName |
| Resolved player name. | |
| QString | rivalsName |
| Resolved rival name. | |
| int | imgWidth = 0 |
| Output width (px). | |
| int | imgWidthTiles = 0 |
| Output width (tiles). | |
| int | imgHeight = 0 |
| Output height (px). | |
| int | imgHeightTiles = 0 |
| Output height (tiles). | |
| bool | useFg = false |
| Whether the foreground is painted. | |
| QSize * | size = nullptr |
| Out-param size handed back to QML. | |
| const QSize & | requestedSize |
| Size QML requested. | |
| SaveFileExpanded * | expanded = nullptr |
| Live save (for name substitution). | |
Static Public Attributes | |
| static constexpr int | boxTiles [] |
| Tilemap for a 20x6 dialogue box with arrow (see note above). | |
| static constexpr int | tileSize = 8 |
| Pixels per tile edge. | |
| static constexpr int | maxLines = 2 |
| Max text lines (must match FontsDB). | |
| static constexpr int | lineHeightTiles = 1 |
| static constexpr int | lineHeight = lineHeightTiles * tileSize |
| static constexpr int | drawWidthTiles = 20 |
| static constexpr int | drawHeightLines1Tiles = 1 |
| static constexpr int | drawHeightLines2Tiles = 2 + lineHeightTiles |
| static constexpr int | drawHeightBoxTiles = 6 |
| static constexpr int | drawWidth = drawWidthTiles * tileSize |
| static constexpr int | drawHeightLines1 = drawHeightLines1Tiles * tileSize |
| static constexpr int | drawHeightLines2 = drawHeightLines2Tiles * tileSize |
| static constexpr int | drawHeightBox = drawHeightBoxTiles * tileSize |
| static constexpr int | maxStrLenTiles = drawWidthTiles * maxLines |
The render pipeline for a single font-preview request.
Built per request from the parsed id-string parts (see IdPart* and FontPreviewProvider's id format). It renders in-game text – optionally inside a dialogue box, on 1 or 2 lines, in chosen colours – to a QPixmap, step by step (getInputStr -> getTiles -> drawBox -> drawFg -> finishImg -> postProcess). The static constexpr layout values capture the Game Boy box geometry.
Definition at line 42 of file fontpreviewprovider.h.
| anonymous enum : int |
Index of each field within the parsed id-string.
| Enumerator | |
|---|---|
| IdPartTileset | |
| IdPartType | |
| IdPartFrame | |
| IdPartWidth | |
| IdPartHeight | |
| IdPartBox | |
| IdPart2Line | |
| IdPartChop | |
| IdPartBGColor | |
| IdPartFGColor | |
| IdPartPlaceHolder | |
| IdPartStr | |
| IdPart_END | |
Definition at line 52 of file fontpreviewprovider.h.
| FontPreviewInstance::FontPreviewInstance | ( | QStringList | idParts, |
| SaveFileExpanded * | expanded, | ||
| QSize * | size, | ||
| const QSize & | requestedSize ) |
| idParts | the slash-split id; |
| expanded | the live save (for names); |
| size | out-param size; |
| requestedSize | QML's requested size. |
Definition at line 39 of file fontpreviewprovider.cpp.
References baseImg, bgColor, bgImg, box, boxImg, drawBox(), drawFg(), expanded, fgImg, finishImg(), getBaseImg(), getImageHeight(), getImageWidth(), getPlayersName(), getResultingText(), getRivalsName(), getTiles(), idParts, postProcess(), requestedSize, resultingImg, setup(), and size.
| void FontPreviewInstance::drawBox | ( | ) |
Draw the dialogue box background, if requested.
Definition at line 194 of file fontpreviewprovider.cpp.
References boxImg, boxTiles, drawHeightBoxTiles, drawWidthTiles, tiles, and tileSize.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::drawFg | ( | ) |
Draw the foreground text.
Definition at line 210 of file fontpreviewprovider.cpp.
References bgColor, box, fgImg, resultingText, tiles, and tileSize.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::finishImg | ( | ) |
Composite into the final pixmap.
Definition at line 243 of file fontpreviewprovider.cpp.
References bgImg, boxImg, fgImg, and resultingImg.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::getBaseImg | ( | ) |
Allocate the base image.
Definition at line 188 of file fontpreviewprovider.cpp.
References baseImg, imgHeight, and imgWidth.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::getImageHeight | ( | ) |
Compute output height.
Definition at line 173 of file fontpreviewprovider.cpp.
References box, drawHeightBox, drawHeightLines1, drawHeightLines2, imgHeight, imgHeightTiles, lines2, resultingText, and tileSize.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::getImageWidth | ( | ) |
Compute output width.
Definition at line 160 of file fontpreviewprovider.cpp.
References box, chopLen, drawWidth, imgWidth, imgWidthTiles, and tileSize.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::getInputStr | ( | ) |
Resolve the final input string (placeholder + str + names).
Definition at line 121 of file fontpreviewprovider.cpp.
References Utility::decodeAfterUrl(), idParts, IdPartStr, inputStr, and Utility::inst().
Referenced by setup().
| void FontPreviewInstance::getPlayersName | ( | ) |
Read the player's name from the save (for substitution).
Definition at line 276 of file fontpreviewprovider.cpp.
References expanded, and playersName.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::getResultingText | ( | ) |
Convert the string to tile-code rows via FontsDB.
Definition at line 137 of file fontpreviewprovider.cpp.
References FontsDB::convertToCode(), FontsDB::expandStr(), inputStr, FontsDB::inst(), placeholder, playersName, resultingText, and rivalsName.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::getRivalsName | ( | ) |
Read the rival's name from the save (for substitution).
Definition at line 283 of file fontpreviewprovider.cpp.
References expanded, and rivalsName.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::getTiles | ( | ) |
Render the per-tile pixmaps for the text.
Definition at line 128 of file fontpreviewprovider.cpp.
References TilesetEngine::buildTileset(), frame, tiles, tileset, and type.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::postProcess | ( | ) |
Apply any post-processing.
Definition at line 260 of file fontpreviewprovider.cpp.
References requestedSize, resultingImg, size, toHeight, and toWidth.
Referenced by FontPreviewInstance().
| void FontPreviewInstance::setup | ( | QStringList | idParts | ) |
Parse the id parts into the fields below.
Definition at line 94 of file fontpreviewprovider.cpp.
References bgColor, box, chopLen, Utility::decodeAfterUrl(), fgColor, frame, getInputStr(), IdPart2Line, IdPartBGColor, IdPartBox, IdPartChop, IdPartFGColor, IdPartFrame, IdPartHeight, IdPartPlaceHolder, idParts, IdPartTileset, IdPartType, IdPartWidth, Utility::inst(), lines2, placeholder, tileset, toHeight, toWidth, type, and useFg.
Referenced by FontPreviewInstance().
| QImage FontPreviewInstance::baseImg |
Base canvas.
Definition at line 141 of file fontpreviewprovider.h.
Referenced by FontPreviewInstance(), and getBaseImg().
| QColor FontPreviewInstance::bgColor |
Background colour (id part).
Definition at line 132 of file fontpreviewprovider.h.
Referenced by drawFg(), FontPreviewInstance(), and setup().
| QImage FontPreviewInstance::bgImg |
Background layer.
Definition at line 140 of file fontpreviewprovider.h.
Referenced by finishImg(), and FontPreviewInstance().
| bool FontPreviewInstance::box = false |
Render a dialogue box (id part).
Definition at line 129 of file fontpreviewprovider.h.
Referenced by drawFg(), FontPreviewInstance(), getImageHeight(), getImageWidth(), and setup().
| QImage FontPreviewInstance::boxImg |
Box layer.
Definition at line 142 of file fontpreviewprovider.h.
Referenced by drawBox(), finishImg(), and FontPreviewInstance().
|
staticconstexpr |
Tilemap for a 20x6 dialogue box with arrow (see note above).
Definition at line 74 of file fontpreviewprovider.h.
Referenced by drawBox().
| int FontPreviewInstance::chopLen = 0 |
Max line length before chopping (id part).
Definition at line 131 of file fontpreviewprovider.h.
Referenced by getImageWidth(), and setup().
|
staticconstexpr |
Definition at line 102 of file fontpreviewprovider.h.
Referenced by FontPreviewProvider::getErrorImg(), and getImageHeight().
|
staticconstexpr |
Definition at line 97 of file fontpreviewprovider.h.
Referenced by drawBox().
|
staticconstexpr |
Definition at line 100 of file fontpreviewprovider.h.
Referenced by getImageHeight().
|
staticconstexpr |
Definition at line 95 of file fontpreviewprovider.h.
|
staticconstexpr |
Definition at line 101 of file fontpreviewprovider.h.
Referenced by getImageHeight().
|
staticconstexpr |
Definition at line 96 of file fontpreviewprovider.h.
|
staticconstexpr |
Definition at line 99 of file fontpreviewprovider.h.
Referenced by FontPreviewProvider::getErrorImg(), and getImageWidth().
|
staticconstexpr |
Definition at line 94 of file fontpreviewprovider.h.
Referenced by drawBox().
| SaveFileExpanded* FontPreviewInstance::expanded = nullptr |
Live save (for name substitution).
Definition at line 160 of file fontpreviewprovider.h.
Referenced by FontPreviewInstance(), getPlayersName(), and getRivalsName().
| QColor FontPreviewInstance::fgColor |
Foreground/text colour (id part; "none" = don't paint).
Definition at line 133 of file fontpreviewprovider.h.
Referenced by setup().
| QImage FontPreviewInstance::fgImg |
Foreground layer.
Definition at line 143 of file fontpreviewprovider.h.
Referenced by drawFg(), finishImg(), and FontPreviewInstance().
| int FontPreviewInstance::frame = 0 |
Animation frame (id part).
Definition at line 126 of file fontpreviewprovider.h.
Referenced by getTiles(), and setup().
| QStringList FontPreviewInstance::idParts |
The raw split id parts.
Definition at line 138 of file fontpreviewprovider.h.
Referenced by FontPreviewInstance(), getInputStr(), and setup().
| int FontPreviewInstance::imgHeight = 0 |
Output height (px).
Definition at line 150 of file fontpreviewprovider.h.
Referenced by getBaseImg(), and getImageHeight().
| int FontPreviewInstance::imgHeightTiles = 0 |
Output height (tiles).
Definition at line 151 of file fontpreviewprovider.h.
Referenced by getImageHeight().
| int FontPreviewInstance::imgWidth = 0 |
Output width (px).
Definition at line 148 of file fontpreviewprovider.h.
Referenced by getBaseImg(), and getImageWidth().
| int FontPreviewInstance::imgWidthTiles = 0 |
Output width (tiles).
Definition at line 149 of file fontpreviewprovider.h.
Referenced by getImageWidth().
| QString FontPreviewInstance::inputStr |
The raw font string to render (id part).
Definition at line 135 of file fontpreviewprovider.h.
Referenced by getInputStr(), and getResultingText().
|
staticconstexpr |
Definition at line 91 of file fontpreviewprovider.h.
|
staticconstexpr |
Definition at line 90 of file fontpreviewprovider.h.
| bool FontPreviewInstance::lines2 = false |
Render on two lines (id part).
Definition at line 130 of file fontpreviewprovider.h.
Referenced by getImageHeight(), and setup().
|
staticconstexpr |
Max text lines (must match FontsDB).
Definition at line 87 of file fontpreviewprovider.h.
|
staticconstexpr |
Definition at line 105 of file fontpreviewprovider.h.
| QString FontPreviewInstance::placeholder |
Template the str is inserted into (id part).
Definition at line 134 of file fontpreviewprovider.h.
Referenced by getResultingText(), and setup().
| QString FontPreviewInstance::playersName |
Resolved player name.
Definition at line 146 of file fontpreviewprovider.h.
Referenced by getPlayersName(), and getResultingText().
| const QSize& FontPreviewInstance::requestedSize |
Size QML requested.
Definition at line 157 of file fontpreviewprovider.h.
Referenced by FontPreviewInstance(), and postProcess().
| QPixmap FontPreviewInstance::resultingImg |
The finished pixmap.
Definition at line 144 of file fontpreviewprovider.h.
Referenced by finishImg(), FontPreviewInstance(), and postProcess().
| QVector<QVector<var8> > FontPreviewInstance::resultingText |
Text as tile-code rows.
Definition at line 139 of file fontpreviewprovider.h.
Referenced by drawFg(), getImageHeight(), and getResultingText().
| QString FontPreviewInstance::rivalsName |
Resolved rival name.
Definition at line 147 of file fontpreviewprovider.h.
Referenced by getResultingText(), and getRivalsName().
| QSize* FontPreviewInstance::size = nullptr |
Out-param size handed back to QML.
Definition at line 156 of file fontpreviewprovider.h.
Referenced by FontPreviewInstance(), and postProcess().
| QVector<QPixmap> FontPreviewInstance::tiles |
Per-character tile pixmaps.
Definition at line 145 of file fontpreviewprovider.h.
Referenced by drawBox(), drawFg(), and getTiles().
| QString FontPreviewInstance::tileset |
Tileset name (id part).
Definition at line 124 of file fontpreviewprovider.h.
Referenced by getTiles(), and setup().
|
staticconstexpr |
Pixels per tile edge.
Definition at line 84 of file fontpreviewprovider.h.
Referenced by drawBox(), drawFg(), getImageHeight(), and getImageWidth().
| int FontPreviewInstance::toHeight = 0 |
Target height (id part).
Definition at line 128 of file fontpreviewprovider.h.
Referenced by postProcess(), and setup().
| int FontPreviewInstance::toWidth = 0 |
Target width (id part).
Definition at line 127 of file fontpreviewprovider.h.
Referenced by postProcess(), and setup().
| QString FontPreviewInstance::type |
Type, e.g. "outdoor" (id part).
Definition at line 125 of file fontpreviewprovider.h.
Referenced by getTiles(), and setup().
| bool FontPreviewInstance::useFg = false |
Whether the foreground is painted.
Definition at line 153 of file fontpreviewprovider.h.
Referenced by setup().