146 .split(
"\n", Qt::SkipEmptyParts);
148 QVector<QVector<var8>> ret;
149 for(
const auto& entry : res) {
151 QVector<var8> tmpBytes;
152 tmpBytes.reserve(tmp.size());
153 for (
int v : tmp) tmpBytes.append(
static_cast<var8>(v));
154 ret.append(tmpBytes);
191 baseImg.fill(QColor(
"transparent"));
197 p.setCompositionMode(QPainter::CompositionMode_SourceOver);
220 int yCounter = startY;
221 int xCounter = startX;
224 p.setCompositionMode(QPainter::CompositionMode_SourceOver);
226 p.setPen(QColor(
"transparent"));
229 for(
auto xTile : yLine) {
253 p.setCompositionMode(QPainter::CompositionMode_SourceOver);
254 p.drawImage(0, 0,
bgImg);
255 p.drawImage(0, 0,
boxImg);
256 p.drawImage(0, 0,
fgImg);
280 :
expanded->player->basics->playerName;
291 : QQuickImageProvider(QQuickImageProvider::Pixmap),
296 const QString&
id, QSize* size,
const QSize& requestedSize)
299 auto idParts =
id.split(
"/", Qt::KeepEmptyParts);
309 return inst.resultingImg;
321 auto img = QImage(actualSize.width(),
323 QImage::Format::Format_ARGB32);
325 img.fill(QColor(255, 0, 0, 255));
327 auto ret = QPixmap::fromImage(img);
330 (requestedSize.width() > 0) ? requestedSize.width() : img.width(),
331 (requestedSize.height() > 0) ? requestedSize.height() : img.height());
virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override
Render the preview for id (format documented above).
FontPreviewProvider(SaveFileExpanded *expanded)
SaveFileExpanded * expanded
Live save (for name substitution).
QPixmap getErrorImg(QSize *size, const QSize &requestedSize)
Fallback image when an id is invalid.
static FontsDB * inst()
< Number of font glyphs.
const QVector< int > convertToCode(QString str, int maxLen=11, const bool autoEnd=true) const
String -> font codes (see note; expensive).
const QString expandStr(const QString msg, const int maxLen, const QString rival, const QString player) const
Expand English text to in-game form (substitutes rival/player).
Root of the editable object tree – the friendly mirror of a raw save.
static QVector< QPixmap > buildTileset(QString id)
Build the per-tile pixmaps for id (format above).
const QString decodeAfterUrl(QString beforeStr) const
Decode the space-separated hex produced by encodeBeforeUrl() back to text.
static Utility * inst()
< The shared Random instance, reachable from QML as pseCommon.random.
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
The render pipeline for a single font-preview request.
int toWidth
Target width (id part).
QPixmap resultingImg
The finished pixmap.
QVector< QVector< var8 > > resultingText
Text as tile-code rows.
void getBaseImg()
Allocate the base image.
void getImageWidth()
Compute output width.
QString tileset
Tileset name (id part).
SaveFileExpanded * expanded
Live save (for name substitution).
int imgWidthTiles
Output width (tiles).
FontPreviewInstance(QStringList idParts, SaveFileExpanded *expanded, QSize *size, const QSize &requestedSize)
static constexpr int drawWidth
void setup(QStringList idParts)
Parse the id parts into the fields below.
void getRivalsName()
Read the rival's name from the save (for substitution).
static constexpr int drawWidthTiles
const QSize & requestedSize
Size QML requested.
QString type
Type, e.g. "outdoor" (id part).
static constexpr int drawHeightLines2
bool box
Render a dialogue box (id part).
QImage fgImg
Foreground layer.
void drawFg()
Draw the foreground text.
int toHeight
Target height (id part).
static constexpr int boxTiles[]
Tilemap for a 20x6 dialogue box with arrow (see note above).
QImage bgImg
Background layer.
QColor bgColor
Background colour (id part).
void postProcess()
Apply any post-processing.
QImage baseImg
Base canvas.
void getPlayersName()
Read the player's name from the save (for substitution).
static constexpr int drawHeightBox
QString placeholder
Template the str is inserted into (id part).
static constexpr int drawHeightBoxTiles
int imgWidth
Output width (px).
void getInputStr()
Resolve the final input string (placeholder + str + names).
int imgHeightTiles
Output height (tiles).
QSize * size
Out-param size handed back to QML.
void drawBox()
Draw the dialogue box background, if requested.
QString rivalsName
Resolved rival name.
int imgHeight
Output height (px).
QStringList idParts
The raw split id parts.
void getTiles()
Render the per-tile pixmaps for the text.
void getResultingText()
Convert the string to tile-code rows via FontsDB.
bool useFg
Whether the foreground is painted.
static constexpr int tileSize
Pixels per tile edge.
bool lines2
Render on two lines (id part).
int frame
Animation frame (id part).
void finishImg()
Composite into the final pixmap.
static constexpr int drawHeightLines1
int chopLen
Max line length before chopping (id part).
QColor fgColor
Foreground/text colour (id part; "none" = don't paint).
QString inputStr
The raw font string to render (id part).
QString playersName
Resolved player name.
void getImageHeight()
Compute output height.
QVector< QPixmap > tiles
Per-character tile pixmaps.