Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
FontPreviewInstance Struct Reference

The render pipeline for a single font-preview request. More...

#include <fontpreviewprovider.h>

Collaboration diagram for FontPreviewInstance:

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.
SaveFileExpandedexpanded = 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

Detailed Description

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.

See also
FontPreviewProvider (the QML image provider that drives this), FontsDB (the codec that turns text into tile codes).

Definition at line 42 of file fontpreviewprovider.h.

Member Enumeration Documentation

◆ anonymous enum

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.

Constructor & Destructor Documentation

◆ FontPreviewInstance()

FontPreviewInstance::FontPreviewInstance ( QStringList idParts,
SaveFileExpanded * expanded,
QSize * size,
const QSize & requestedSize )
Parameters
idPartsthe slash-split id;
expandedthe live save (for names);
sizeout-param size;
requestedSizeQML'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.

Member Function Documentation

◆ drawBox()

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().

◆ drawFg()

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().

◆ finishImg()

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().

◆ getBaseImg()

void FontPreviewInstance::getBaseImg ( )

Allocate the base image.

Definition at line 188 of file fontpreviewprovider.cpp.

References baseImg, imgHeight, and imgWidth.

Referenced by FontPreviewInstance().

◆ getImageHeight()

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().

◆ getImageWidth()

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().

◆ getInputStr()

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().

◆ getPlayersName()

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().

◆ getResultingText()

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().

◆ getRivalsName()

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().

◆ getTiles()

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().

◆ postProcess()

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().

◆ setup()

void FontPreviewInstance::setup ( QStringList idParts)

Member Data Documentation

◆ baseImg

QImage FontPreviewInstance::baseImg

Base canvas.

Definition at line 141 of file fontpreviewprovider.h.

Referenced by FontPreviewInstance(), and getBaseImg().

◆ bgColor

QColor FontPreviewInstance::bgColor

Background colour (id part).

Definition at line 132 of file fontpreviewprovider.h.

Referenced by drawFg(), FontPreviewInstance(), and setup().

◆ bgImg

QImage FontPreviewInstance::bgImg

Background layer.

Definition at line 140 of file fontpreviewprovider.h.

Referenced by finishImg(), and FontPreviewInstance().

◆ box

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().

◆ boxImg

QImage FontPreviewInstance::boxImg

Box layer.

Definition at line 142 of file fontpreviewprovider.h.

Referenced by drawBox(), finishImg(), and FontPreviewInstance().

◆ boxTiles

int FontPreviewInstance::boxTiles[]
staticconstexpr
Initial value:
= {
0x79,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7B,
0x7C,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7C,
0x7C,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7C,
0x7C,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7C,
0x7C,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0xEE,0x7C,
0x7D,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7A,0x7E
}

Tilemap for a 20x6 dialogue box with arrow (see note above).

Definition at line 74 of file fontpreviewprovider.h.

Referenced by drawBox().

◆ chopLen

int FontPreviewInstance::chopLen = 0

Max line length before chopping (id part).

Definition at line 131 of file fontpreviewprovider.h.

Referenced by getImageWidth(), and setup().

◆ drawHeightBox

int FontPreviewInstance::drawHeightBox = drawHeightBoxTiles * tileSize
staticconstexpr

Definition at line 102 of file fontpreviewprovider.h.

Referenced by FontPreviewProvider::getErrorImg(), and getImageHeight().

◆ drawHeightBoxTiles

int FontPreviewInstance::drawHeightBoxTiles = 6
staticconstexpr

Definition at line 97 of file fontpreviewprovider.h.

Referenced by drawBox().

◆ drawHeightLines1

int FontPreviewInstance::drawHeightLines1 = drawHeightLines1Tiles * tileSize
staticconstexpr

Definition at line 100 of file fontpreviewprovider.h.

Referenced by getImageHeight().

◆ drawHeightLines1Tiles

int FontPreviewInstance::drawHeightLines1Tiles = 1
staticconstexpr

Definition at line 95 of file fontpreviewprovider.h.

◆ drawHeightLines2

int FontPreviewInstance::drawHeightLines2 = drawHeightLines2Tiles * tileSize
staticconstexpr

Definition at line 101 of file fontpreviewprovider.h.

Referenced by getImageHeight().

◆ drawHeightLines2Tiles

int FontPreviewInstance::drawHeightLines2Tiles = 2 + lineHeightTiles
staticconstexpr

Definition at line 96 of file fontpreviewprovider.h.

◆ drawWidth

int FontPreviewInstance::drawWidth = drawWidthTiles * tileSize
staticconstexpr

Definition at line 99 of file fontpreviewprovider.h.

Referenced by FontPreviewProvider::getErrorImg(), and getImageWidth().

◆ drawWidthTiles

int FontPreviewInstance::drawWidthTiles = 20
staticconstexpr

Definition at line 94 of file fontpreviewprovider.h.

Referenced by drawBox().

◆ expanded

SaveFileExpanded* FontPreviewInstance::expanded = nullptr

Live save (for name substitution).

Definition at line 160 of file fontpreviewprovider.h.

Referenced by FontPreviewInstance(), getPlayersName(), and getRivalsName().

◆ fgColor

QColor FontPreviewInstance::fgColor

Foreground/text colour (id part; "none" = don't paint).

Definition at line 133 of file fontpreviewprovider.h.

Referenced by setup().

◆ fgImg

QImage FontPreviewInstance::fgImg

Foreground layer.

Definition at line 143 of file fontpreviewprovider.h.

Referenced by drawFg(), finishImg(), and FontPreviewInstance().

◆ frame

int FontPreviewInstance::frame = 0

Animation frame (id part).

Definition at line 126 of file fontpreviewprovider.h.

Referenced by getTiles(), and setup().

◆ idParts

QStringList FontPreviewInstance::idParts

The raw split id parts.

Definition at line 138 of file fontpreviewprovider.h.

Referenced by FontPreviewInstance(), getInputStr(), and setup().

◆ imgHeight

int FontPreviewInstance::imgHeight = 0

Output height (px).

Definition at line 150 of file fontpreviewprovider.h.

Referenced by getBaseImg(), and getImageHeight().

◆ imgHeightTiles

int FontPreviewInstance::imgHeightTiles = 0

Output height (tiles).

Definition at line 151 of file fontpreviewprovider.h.

Referenced by getImageHeight().

◆ imgWidth

int FontPreviewInstance::imgWidth = 0

Output width (px).

Definition at line 148 of file fontpreviewprovider.h.

Referenced by getBaseImg(), and getImageWidth().

◆ imgWidthTiles

int FontPreviewInstance::imgWidthTiles = 0

Output width (tiles).

Definition at line 149 of file fontpreviewprovider.h.

Referenced by getImageWidth().

◆ inputStr

QString FontPreviewInstance::inputStr

The raw font string to render (id part).

Definition at line 135 of file fontpreviewprovider.h.

Referenced by getInputStr(), and getResultingText().

◆ lineHeight

int FontPreviewInstance::lineHeight = lineHeightTiles * tileSize
staticconstexpr

Definition at line 91 of file fontpreviewprovider.h.

◆ lineHeightTiles

int FontPreviewInstance::lineHeightTiles = 1
staticconstexpr

Definition at line 90 of file fontpreviewprovider.h.

◆ lines2

bool FontPreviewInstance::lines2 = false

Render on two lines (id part).

Definition at line 130 of file fontpreviewprovider.h.

Referenced by getImageHeight(), and setup().

◆ maxLines

int FontPreviewInstance::maxLines = 2
staticconstexpr

Max text lines (must match FontsDB).

Definition at line 87 of file fontpreviewprovider.h.

◆ maxStrLenTiles

int FontPreviewInstance::maxStrLenTiles = drawWidthTiles * maxLines
staticconstexpr

Definition at line 105 of file fontpreviewprovider.h.

◆ placeholder

QString FontPreviewInstance::placeholder

Template the str is inserted into (id part).

Definition at line 134 of file fontpreviewprovider.h.

Referenced by getResultingText(), and setup().

◆ playersName

QString FontPreviewInstance::playersName

Resolved player name.

Definition at line 146 of file fontpreviewprovider.h.

Referenced by getPlayersName(), and getResultingText().

◆ requestedSize

const QSize& FontPreviewInstance::requestedSize

Size QML requested.

Definition at line 157 of file fontpreviewprovider.h.

Referenced by FontPreviewInstance(), and postProcess().

◆ resultingImg

QPixmap FontPreviewInstance::resultingImg

The finished pixmap.

Definition at line 144 of file fontpreviewprovider.h.

Referenced by finishImg(), FontPreviewInstance(), and postProcess().

◆ resultingText

QVector<QVector<var8> > FontPreviewInstance::resultingText

Text as tile-code rows.

Definition at line 139 of file fontpreviewprovider.h.

Referenced by drawFg(), getImageHeight(), and getResultingText().

◆ rivalsName

QString FontPreviewInstance::rivalsName

Resolved rival name.

Definition at line 147 of file fontpreviewprovider.h.

Referenced by getResultingText(), and getRivalsName().

◆ size

QSize* FontPreviewInstance::size = nullptr

Out-param size handed back to QML.

Definition at line 156 of file fontpreviewprovider.h.

Referenced by FontPreviewInstance(), and postProcess().

◆ tiles

QVector<QPixmap> FontPreviewInstance::tiles

Per-character tile pixmaps.

Definition at line 145 of file fontpreviewprovider.h.

Referenced by drawBox(), drawFg(), and getTiles().

◆ tileset

QString FontPreviewInstance::tileset

Tileset name (id part).

Definition at line 124 of file fontpreviewprovider.h.

Referenced by getTiles(), and setup().

◆ tileSize

int FontPreviewInstance::tileSize = 8
staticconstexpr

Pixels per tile edge.

Definition at line 84 of file fontpreviewprovider.h.

Referenced by drawBox(), drawFg(), getImageHeight(), and getImageWidth().

◆ toHeight

int FontPreviewInstance::toHeight = 0

Target height (id part).

Definition at line 128 of file fontpreviewprovider.h.

Referenced by postProcess(), and setup().

◆ toWidth

int FontPreviewInstance::toWidth = 0

Target width (id part).

Definition at line 127 of file fontpreviewprovider.h.

Referenced by postProcess(), and setup().

◆ type

QString FontPreviewInstance::type

Type, e.g. "outdoor" (id part).

Definition at line 125 of file fontpreviewprovider.h.

Referenced by getTiles(), and setup().

◆ useFg

bool FontPreviewInstance::useFg = false

Whether the foreground is painted.

Definition at line 153 of file fontpreviewprovider.h.

Referenced by setup().


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