implemented help illustrations
This commit is contained in:
1 parent
3753749f2e
commit
3645c06305
2 files changed
+65
-12
No files matched your search
@@ -36,7 +36,9 @@
|
||||
// (Imp/Ter/Feature/Model/Text) still render a plain placeholder paragraph
|
||||
// instead of the original's full icon-rich, per-TextFormat layout engine
|
||||
// (pkAdvIcon/pkBigIcon/pkTer/pkModel/...); extend prepare() similarly if
|
||||
// needed. waterSign()/paintTerrIcon() (cosmetic pixel effects) are no-ops.
|
||||
// needed. waterSign() draws the real improvement/wonder illustration but
|
||||
// skips the original's per-pixel sky-detecting watermark blend (plain blit
|
||||
// instead); paintTerrIcon() (cosmetic terrain compositing) is still a no-op.
|
||||
|
||||
#include "Help.h"
|
||||
#include "ui_Help.h"
|
||||
@@ -808,11 +810,35 @@ void HelpDlg::addTextual(const QString &text)
|
||||
s.remove(0, p + 1);
|
||||
continue;
|
||||
}
|
||||
if (s.at(0) == QLatin1Char('@')) { // image - not rendered, skip
|
||||
int p = s.size() >= 2 && s.at(1) == QLatin1Char('@') ? 2 : 1;
|
||||
if (s.at(0) == QLatin1Char('@')) { // image
|
||||
if (s.size() >= 2 && s.at(1) == QLatin1Char('@')) { // generate from icon
|
||||
int picpix = 0;
|
||||
int p = 2;
|
||||
while (p < s.size() && s.at(p) != QLatin1Char('\\')) {
|
||||
picpix = picpix * 10 + (s.at(p).unicode() - QLatin1Char('0').unicode());
|
||||
++p;
|
||||
}
|
||||
if (picpix < 0 || picpix >= nImp)
|
||||
picpix = 0;
|
||||
mainText.addLine(QString(), TextFormat::Illu, picpix);
|
||||
mainText.lineFeed();
|
||||
mainText.lineFeed();
|
||||
s.remove(0, p + 1);
|
||||
} else { // external image
|
||||
int p = 1;
|
||||
while (p < s.size() && s.at(p) != QLatin1Char('\\'))
|
||||
++p;
|
||||
if (!extPic)
|
||||
extPic = std::make_unique<Dpi::Bitmap>();
|
||||
extPic->loadFromFile(localizedFilePath(QStringLiteral("Help/") + s.mid(1, p - 1) +
|
||||
QLatin1String(PngExt)));
|
||||
if (extPic->width() > 0 && extPic->height() > 0) {
|
||||
mainText.addLine(QString(), TextFormat::External);
|
||||
for (int i = 0; i <= (extPic->height() - 12) / 24; ++i)
|
||||
mainText.lineFeed();
|
||||
}
|
||||
s.remove(0, p + 1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1024,6 +1050,11 @@ void HelpDlg::paintTerrIcon(int x, int y, int xSrc, int ySrc)
|
||||
Q_UNUSED(ySrc);
|
||||
}
|
||||
|
||||
void HelpDlg::waterSign(int x0, int y0, int iix)
|
||||
{
|
||||
Term::impImage(offscreen.canvas(), x0, y0, iix);
|
||||
}
|
||||
|
||||
void HelpDlg::offscreenPaint()
|
||||
{
|
||||
FramedDlg::offscreenPaint();
|
||||
@@ -1031,6 +1062,21 @@ void HelpDlg::offscreenPaint()
|
||||
Dpi::Canvas &canvas = offscreen.canvas();
|
||||
canvas.begin();
|
||||
fillSeamless(canvas, 0, 0, innerWidth, innerHeight, 0, scrollBar->position() * 24, paper);
|
||||
|
||||
// External illustrations (Help/*.png) are drawn first, behind the text.
|
||||
if (extPic) {
|
||||
for (int idx = 0; idx <= scrollBar->position() + innerHeight / 24 && idx < mainText.count(); ++idx) {
|
||||
if (mainText.info(idx).format != TextFormat::External)
|
||||
continue;
|
||||
const int i = idx - scrollBar->position();
|
||||
int yl = extPic->height();
|
||||
if (4 + i * 24 + yl > innerHeight)
|
||||
yl = innerHeight - (4 + i * 24);
|
||||
if (yl > 0)
|
||||
bitBltBitmap(offscreen, 8, 4 + i * 24, extPic->width(), yl, *extPic, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
||||
for (int i = -2; i <= innerHeight / 24; ++i) {
|
||||
const int idx = scrollBar->position() + i;
|
||||
@@ -1038,6 +1084,8 @@ void HelpDlg::offscreenPaint()
|
||||
continue;
|
||||
x0[static_cast<std::size_t>(i + 2)] = 8;
|
||||
line(canvas, i, i == sel);
|
||||
if (mainText.info(idx).format == TextFormat::Illu)
|
||||
waterSign(8, i * 24 - 8, mainText.info(idx).picPix);
|
||||
}
|
||||
canvas.end();
|
||||
markUsedOffscreen(innerWidth, innerHeight);
|
||||
@@ -1052,7 +1100,7 @@ void HelpDlg::resizeEvent(QResizeEvent *event)
|
||||
|
||||
void HelpDlg::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// ExtPic.Height := 0; -- the external-link preview bitmap isn't ported.
|
||||
extPic.reset(); // Help.pas's ExtPic.Height := 0 - free the illustration bitmap.
|
||||
FramedDlg::closeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
+13
-8
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -45,6 +46,10 @@ class HelpDlg;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Dpi {
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
namespace Cevo {
|
||||
namespace Help {
|
||||
|
||||
@@ -161,14 +166,11 @@ private:
|
||||
void search(const QString &searchString);
|
||||
void line(Dpi::Canvas &canvas, int i, bool lit);
|
||||
void paintTerrIcon(int x, int y, int xSrc, int ySrc);
|
||||
// Placeholder for the original's pixel-level water-reflection effect
|
||||
// on wonder/illustration icons - purely cosmetic, not yet ported.
|
||||
void waterSign(int x0, int y0, int iix)
|
||||
{
|
||||
Q_UNUSED(x0);
|
||||
Q_UNUSED(y0);
|
||||
Q_UNUSED(iix);
|
||||
}
|
||||
// Help.pas's WaterSign(): draws a big improvement/wonder illustration.
|
||||
// Simplified from the original's per-pixel sky-detecting watermark blend
|
||||
// (2x upscaled, faded into the paper background) to a plain icon blit -
|
||||
// still shows the real illustration, just without the blend effect.
|
||||
void waterSign(int x0, int y0, int iix);
|
||||
void backBtnClicked();
|
||||
void topBtnClicked();
|
||||
void searchBtnClicked();
|
||||
@@ -182,6 +184,9 @@ private:
|
||||
HyperText mainText;
|
||||
HyperText searchResult;
|
||||
StringTable helpText;
|
||||
// Help.pas's ExtPic: the single external illustration bitmap (Help/*.png)
|
||||
// referenced by the currently displayed page's "@filename\" markup.
|
||||
std::unique_ptr<Dpi::Bitmap> extPic;
|
||||
std::vector<HistItem> histItems;
|
||||
PVScrollBar *scrollBar;
|
||||
std::array<int, 183> x0{}; // x0[-2..180], offset by +2
|
||||
|
||||
Reference in new issue
Block a user