splited help
This commit is contained in:
1 parent
3645c06305
commit
c961b30525
5 files changed
+1413
-883
No files matched your search
@@ -177,6 +177,8 @@ set(PROJECT_SOURCES
|
|||||||
game/localplayer/Tribes.cpp
|
game/localplayer/Tribes.cpp
|
||||||
game/localplayer/Tribes.h
|
game/localplayer/Tribes.h
|
||||||
game/localplayer/Help.cpp
|
game/localplayer/Help.cpp
|
||||||
|
game/localplayer/Help.Prepare.cpp
|
||||||
|
game/localplayer/Help.Paint.cpp
|
||||||
game/localplayer/Help.h
|
game/localplayer/Help.h
|
||||||
game/localplayer/Help.ui
|
game/localplayer/Help.ui
|
||||||
game/localplayer/Wonders.cpp
|
game/localplayer/Wonders.cpp
|
||||||
|
|||||||
@@ -0,0 +1,292 @@
|
|||||||
|
// This file is part of c-evo-evo.
|
||||||
|
//
|
||||||
|
// This software is governed by the CeCILL license under French law and
|
||||||
|
// abiding by the rules of distribution of free software. You can use,
|
||||||
|
// modify and/or redistribute the software under the terms of the CeCILL
|
||||||
|
// license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
// "http://www.cecill.info".
|
||||||
|
//
|
||||||
|
// As a counterpart to the access to the source code and rights to copy,
|
||||||
|
// modify and redistribute granted by the license, users are provided only
|
||||||
|
// with a limited warranty and the software's author, the holder of the
|
||||||
|
// economic rights, and the successive licensors have only limited
|
||||||
|
// liability.
|
||||||
|
//
|
||||||
|
// In this respect, the user's attention is drawn to the risks associated
|
||||||
|
// with loading, using, modifying and/or developing or reproducing the
|
||||||
|
// software by the user in light of its specific status of free software,
|
||||||
|
// that may mean that it is complicated to manipulate, and that also
|
||||||
|
// therefore means that it is reserved for developers and experienced
|
||||||
|
// professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
// encouraged to load and test the software's suitability as regards their
|
||||||
|
// requirements in conditions enabling the security of their systems and/or
|
||||||
|
// data to be ensured and, more generally, to use and operate it in the
|
||||||
|
// same conditions as regards security.
|
||||||
|
//
|
||||||
|
// The fact that you are presently reading this means that you have had
|
||||||
|
// knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
// See the PORT STATUS comment at the top of Help.cpp for how this file fits
|
||||||
|
// into the overall Help.pas port. This file: offscreenPaint()/line() and
|
||||||
|
// the real per-TextFormat icon rendering.
|
||||||
|
|
||||||
|
#include "Help.h"
|
||||||
|
#include "ui_Help.h"
|
||||||
|
|
||||||
|
#include "Cevo/CevoScreenTools.h"
|
||||||
|
#include "Cevo/Protocol.h"
|
||||||
|
#include "ClientTools.h"
|
||||||
|
#include "Term.h"
|
||||||
|
#include "Tribes.h"
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
namespace Help {
|
||||||
|
|
||||||
|
void HelpDlg::line(Dpi::Canvas &canvas, int i, bool lit)
|
||||||
|
{
|
||||||
|
const int idx = scrollBar->position() + i;
|
||||||
|
if (idx < 0 || idx >= mainText.count())
|
||||||
|
return;
|
||||||
|
const QString &s = mainText.text(idx);
|
||||||
|
if (s.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int x = x0[static_cast<std::size_t>(i + 2)];
|
||||||
|
int y = 2 + i * 24;
|
||||||
|
if (&canvas != &offscreen.canvas()) {
|
||||||
|
x += SideFrame;
|
||||||
|
y += WideFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HelpLineInfo &lineInfo = mainText.info(idx);
|
||||||
|
const bool isHeader = lineInfo.format == TextFormat::Caption || lineInfo.format == TextFormat::Section;
|
||||||
|
if (isHeader)
|
||||||
|
canvas.font().setBold(true);
|
||||||
|
const QColor textColor = isHeader ? captionColor : colorFromDelphi(0x000000);
|
||||||
|
biColorTextOut(canvas, textColor, colorFromDelphi(0x7F007F), x, y, s);
|
||||||
|
if (lit) {
|
||||||
|
canvas.pen().setColor(textColor);
|
||||||
|
canvas.moveTo(x + 1, y + 18);
|
||||||
|
canvas.lineTo(x + biColorTextWidth(canvas, s), y + 18);
|
||||||
|
}
|
||||||
|
if (isHeader)
|
||||||
|
canvas.font().setBold(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpDlg::paintTerIcon(Dpi::Canvas &canvas, int &x0Ref, int y, int picpix)
|
||||||
|
{
|
||||||
|
if (!noMap || !noMap->hGrTerrain)
|
||||||
|
return;
|
||||||
|
GraphicSet &hGrTerrain = *noMap->hGrTerrain;
|
||||||
|
const int xxt = noMap->xxt;
|
||||||
|
const int yyt = noMap->yyt;
|
||||||
|
|
||||||
|
int srcno;
|
||||||
|
if (picpix >= 3 * 12)
|
||||||
|
srcno = 2 * 9 + 6;
|
||||||
|
else if (picpix % 12 == Term::fJungle)
|
||||||
|
srcno = 18 * 9;
|
||||||
|
else if (picpix % 12 < Term::fJungle)
|
||||||
|
srcno = picpix % 12;
|
||||||
|
else
|
||||||
|
srcno = 27 + (picpix % 12 - 9) * 18;
|
||||||
|
|
||||||
|
const int ofs = x0Ref + 8;
|
||||||
|
x0Ref = 2 * xxt + 8 + ofs;
|
||||||
|
const int Y = y + 13;
|
||||||
|
|
||||||
|
if (srcno >= Term::fJungle) {
|
||||||
|
sprite(canvas, hGrTerrain, ofs + 4, Y - yyt + 2, xxt * 2 - 8, yyt * 2 - 4, 5 + 2 * (xxt * 2 + 1),
|
||||||
|
3 + yyt + 2 * (yyt * 3 + 1));
|
||||||
|
sprite(canvas, hGrTerrain, ofs, Y - 2 * yyt, xxt * 2, yyt * 3 - 2, 1 + srcno % 9 * (xxt * 2 + 1),
|
||||||
|
1 + srcno / 9 * (yyt * 3 + 1));
|
||||||
|
} else {
|
||||||
|
sprite(canvas, hGrTerrain, ofs + 4, Y - yyt + 2, xxt * 2 - 8, yyt * 2 - 4, 5 + srcno % 9 * (xxt * 2 + 1),
|
||||||
|
3 + yyt + srcno / 9 * (yyt * 3 + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (picpix >= 3 * 12) { // rare resource
|
||||||
|
sprite(canvas, hGrTerrain, ofs, Y - 2 * yyt, xxt * 2, yyt * 3, 1 + 8 * (xxt * 2 + 1),
|
||||||
|
1 + (picpix - 2 * 12) * (yyt * 3 + 1));
|
||||||
|
} else if (picpix >= 12) { // special tile
|
||||||
|
int srcno2;
|
||||||
|
if (picpix % 12 == Term::fJungle)
|
||||||
|
srcno2 = 17 * 9 + 8;
|
||||||
|
else if (picpix % 12 < Term::fJungle)
|
||||||
|
srcno2 = picpix % 12;
|
||||||
|
else
|
||||||
|
srcno2 = 18 + 8 + (picpix % 12 - 9) * 18;
|
||||||
|
srcno2 += picpix / 12 * 9;
|
||||||
|
sprite(canvas, hGrTerrain, ofs, Y - 2 * yyt, xxt * 2, yyt * 3, 1 + srcno2 % 9 * (xxt * 2 + 1),
|
||||||
|
1 + srcno2 / 9 * (yyt * 3 + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpDlg::paintTerrIcon(int x, int y, int xSrc, int ySrc)
|
||||||
|
{
|
||||||
|
if (!noMap || !noMap->hGrTerrain)
|
||||||
|
return;
|
||||||
|
GraphicSet &hGrTerrain = *noMap->hGrTerrain;
|
||||||
|
const int xxt = noMap->xxt;
|
||||||
|
const int yyt = noMap->yyt;
|
||||||
|
Dpi::Canvas &canvas = offscreen.canvas();
|
||||||
|
|
||||||
|
frame(canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig, Qt::black, Qt::black);
|
||||||
|
if (2 * yyt < 40) {
|
||||||
|
sprite(canvas, hGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc);
|
||||||
|
sprite(canvas, hGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt, xSrc, ySrc);
|
||||||
|
} else {
|
||||||
|
sprite(canvas, hGrTerrain, x, y, 56, 40, xSrc, ySrc);
|
||||||
|
}
|
||||||
|
sprite(canvas, hGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt);
|
||||||
|
sprite(canvas, hGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);
|
||||||
|
sprite(canvas, hGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt);
|
||||||
|
sprite(canvas, hGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt, xSrc, ySrc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpDlg::waterSign(int x0, int y0, int iix)
|
||||||
|
{
|
||||||
|
Term::impImage(offscreen.canvas(), x0, y0, iix);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpDlg::paintIcon(Dpi::Canvas &canvas, int i)
|
||||||
|
{
|
||||||
|
const int idx = scrollBar->position() + i;
|
||||||
|
if (idx < 0 || idx >= mainText.count())
|
||||||
|
return;
|
||||||
|
const HelpLineInfo &info = mainText.info(idx);
|
||||||
|
const int y = i * 24;
|
||||||
|
int &x0i = x0[static_cast<std::size_t>(i + 2)];
|
||||||
|
|
||||||
|
// Leading link-indicator dot (shown for every clickable line).
|
||||||
|
if (info.category != LinkCategory::NoLink && HGrSystem) {
|
||||||
|
if (i == sel)
|
||||||
|
sprite(canvas, *HGrSystem, 12, y + 5, 14, 14, 65, 20);
|
||||||
|
else if (info.crossLink)
|
||||||
|
sprite(canvas, *HGrSystem, 12, y + 5, 14, 14, 80, 1);
|
||||||
|
else if (!(kind == LinkCategory::Misc && no == static_cast<int>(MiscLinkIndex::Main)))
|
||||||
|
sprite(canvas, *HGrSystem, 10, y + 6, 14, 14, 65, 1);
|
||||||
|
x0i = 24;
|
||||||
|
} else {
|
||||||
|
x0i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!HGrSystem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (info.format) {
|
||||||
|
case TextFormat::AdvIcon:
|
||||||
|
case TextFormat::AdvIconAsPreq: {
|
||||||
|
frame(canvas, 8 - 1 + x0i, 2 - 1 + y, 8 + Term::xSizeSmall + x0i, 2 + Term::ySizeSmall + y, Qt::black,
|
||||||
|
Qt::black);
|
||||||
|
const int ai = Term::advIcon[static_cast<std::size_t>(info.picPix)];
|
||||||
|
if (ai < 84) {
|
||||||
|
if (Term::smallImp)
|
||||||
|
bitBltBitmap(offscreen, 8 + x0i, 2 + y, Term::xSizeSmall, Term::ySizeSmall, *Term::smallImp,
|
||||||
|
(ai + Term::SystemIconLines * 7) % 7 * Term::xSizeSmall,
|
||||||
|
(ai + Term::SystemIconLines * 7) / 7 * Term::ySizeSmall);
|
||||||
|
} else {
|
||||||
|
dump(offscreen, *HGrSystem, 8 + x0i, 2 + y, 36, 20, 1 + (ai - 84) % 8 * 37, 295 + (ai - 84) / 8 * 21);
|
||||||
|
}
|
||||||
|
const int era = ClientTools::advValue[static_cast<std::size_t>(info.picPix)] / 1000;
|
||||||
|
bitBltBitmap(offscreen, x0i + 4, 4 + y, 14, 14, HGrSystem->mask, 127 + era * 15, 85, RasterOp::And);
|
||||||
|
sprite(canvas, *HGrSystem, x0i + 3, 3 + y, 14, 14, 127 + era * 15, 85);
|
||||||
|
x0i += 8 + 8 + 36;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TextFormat::SmallIcon:
|
||||||
|
case TextFormat::SmallIconAsPreq: {
|
||||||
|
frame(canvas, 8 - 1 + x0i, 2 - 1 + y, 8 + Term::xSizeSmall + x0i, 2 + Term::ySizeSmall + y, Qt::black,
|
||||||
|
Qt::black);
|
||||||
|
if (Term::smallImp) {
|
||||||
|
if (info.picPix == imPalace)
|
||||||
|
bitBltBitmap(offscreen, 8 + x0i, 2 + y, Term::xSizeSmall, Term::ySizeSmall, *Term::smallImp, 0,
|
||||||
|
Term::ySizeSmall);
|
||||||
|
else
|
||||||
|
bitBltBitmap(offscreen, 8 + x0i, 2 + y, Term::xSizeSmall, Term::ySizeSmall, *Term::smallImp,
|
||||||
|
info.picPix % 7 * Term::xSizeSmall,
|
||||||
|
(info.picPix + Term::SystemIconLines * 7) / 7 * Term::ySizeSmall);
|
||||||
|
}
|
||||||
|
x0i += 8 + 8 + 36;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TextFormat::Domain:
|
||||||
|
frame(canvas, 8 - 1 + x0i, 2 - 1 + y, 8 + 36 + x0i, 2 + 20 + y, Qt::black, Qt::black);
|
||||||
|
dump(offscreen, *HGrSystem, 8 + x0i, 2 + y, 36, 20, 75 + info.picPix * 37, 295);
|
||||||
|
x0i += 8 + 8 + 36;
|
||||||
|
break;
|
||||||
|
case TextFormat::Gov:
|
||||||
|
frame(canvas, 8 - 1 + x0i, 2 - 1 + y, 8 + Term::xSizeSmall + x0i, 2 + 20 + y, Qt::black, Qt::black);
|
||||||
|
if (Term::smallImp)
|
||||||
|
bitBltBitmap(offscreen, 8 + x0i, 2 + y, Term::xSizeSmall, Term::ySizeSmall, *Term::smallImp,
|
||||||
|
(info.picPix - 1) * Term::xSizeSmall, Term::ySizeSmall);
|
||||||
|
x0i += 8 + 8 + 36;
|
||||||
|
break;
|
||||||
|
case TextFormat::Feature:
|
||||||
|
darkGradient(canvas, x0i + 8 - 1, 7 + y - 3, 16, 1);
|
||||||
|
frame(canvas, x0i + 8, 7 + y - 2, x0i + 8 + 13, 7 + y - 2 + 13, QColor(0xC0C0C0), QColor(0xC0C0C0));
|
||||||
|
sprite(canvas, *HGrSystem, x0i + 8 + 2, 7 + y, 10, 10, 66 + info.picPix % 11 * 11,
|
||||||
|
137 + info.picPix / 11 * 11);
|
||||||
|
x0i += 8 + 8 + 2 + 13;
|
||||||
|
break;
|
||||||
|
case TextFormat::Model:
|
||||||
|
if (bigImp)
|
||||||
|
frameImage(canvas, *bigImp, x0i + 12, y - 7, 56, 40, 0, 0);
|
||||||
|
if (Tribes::hGrStdUnits)
|
||||||
|
sprite(canvas, *Tribes::hGrStdUnits, x0i + 8, y - 11, 64, 44, 1 + info.picPix % 10 * 65,
|
||||||
|
1 + info.picPix / 10 * 49);
|
||||||
|
x0i += 64 + 8 + 8;
|
||||||
|
break;
|
||||||
|
case TextFormat::Ter:
|
||||||
|
paintTerIcon(canvas, x0i, y, info.picPix);
|
||||||
|
break;
|
||||||
|
case TextFormat::Dot:
|
||||||
|
sprite(canvas, *HGrSystem, x0i + 18, 9 + y, 8, 8, 81, 16);
|
||||||
|
x0i = 20 + 8 + 4;
|
||||||
|
break;
|
||||||
|
case TextFormat::NormalDot:
|
||||||
|
x0i = 20 + 8 + 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpDlg::offscreenPaint()
|
||||||
|
{
|
||||||
|
FramedDlg::offscreenPaint();
|
||||||
|
captionColor = colorFromDelphi(0xC08040);
|
||||||
|
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;
|
||||||
|
if (idx < 0 || idx >= mainText.count())
|
||||||
|
continue;
|
||||||
|
paintIcon(canvas, i);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Help
|
||||||
|
} // namespace Cevo
|
||||||
File diff suppressed because it is too large.
Load diff
+20
-879
@@ -27,18 +27,24 @@
|
|||||||
// knowledge of the CeCILL license and that you accept its terms.
|
// knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
// PORT STATUS (see /memories/repo/cevo-evo-game.md): Help.pas is 2297
|
// PORT STATUS (see /memories/repo/cevo-evo-game.md): Help.pas is 2297
|
||||||
// lines; this is a deliberately SIMPLIFIED port. The navigation/history/
|
// lines, split across 3 files here (matching the GameServer.cpp/
|
||||||
// search-plumbing/scrolling/link-click machinery is faithful. The real
|
// Term.MainScreen.cpp precedent for large files):
|
||||||
// Help/Help.txt content is loaded (resources/Help/Help.txt is shipped) and
|
// - Help.cpp (this file): the dialog shell - construction, navigation/
|
||||||
// used via the StringTable `helpText`/the global `phrases`. prepareAdvance()
|
// history, event handlers, the prepare() dispatcher.
|
||||||
// renders a reasonably faithful LinkCategory::Adv page (prereqs/governments/
|
// - Help.Prepare.cpp: per-LinkCategory content generation (prepareAdvance/
|
||||||
// improvements/features/follow-on research it unlocks). Other categories
|
// Improvement/Terrain/Feature/Model/Misc*), addTextual()'s markup
|
||||||
// (Imp/Ter/Feature/Model/Text) still render a plain placeholder paragraph
|
// parser, and search().
|
||||||
// instead of the original's full icon-rich, per-TextFormat layout engine
|
// - Help.Paint.cpp: offscreenPaint()/line() and the real per-TextFormat
|
||||||
// (pkAdvIcon/pkBigIcon/pkTer/pkModel/...); extend prepare() similarly if
|
// icon rendering (small/big advance+improvement icons, terrain tiles,
|
||||||
// needed. waterSign() draws the real improvement/wonder illustration but
|
// feature/domain/government icons, link-indicator dots).
|
||||||
// skips the original's per-pixel sky-detecting watermark blend (plain blit
|
// Remaining disclosed simplifications: waterSign() draws the real
|
||||||
// instead); paintTerrIcon() (cosmetic terrain compositing) is still a no-op.
|
// improvement/wonder illustration but skips the original's per-pixel
|
||||||
|
// sky-detecting watermark blend (plain blit instead); the isometric
|
||||||
|
// terrain-tile icon (TextFormat::Ter) draws a single representative sprite
|
||||||
|
// rather than the original's 2-layer edge-blended compositing (same
|
||||||
|
// simplification Enhance.cpp's own terrain preview already uses); the
|
||||||
|
// Credits page doesn't scan Graphics/Sounds/ for per-asset *.credits.txt
|
||||||
|
// filesystem credit rolls.
|
||||||
|
|
||||||
#include "Help.h"
|
#include "Help.h"
|
||||||
#include "ui_Help.h"
|
#include "ui_Help.h"
|
||||||
@@ -54,119 +60,15 @@
|
|||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Cevo {
|
namespace Cevo {
|
||||||
namespace Help {
|
namespace Help {
|
||||||
|
|
||||||
std::function<void(WindowMode, LinkCategory, int)> showNewContent;
|
std::function<void(WindowMode, LinkCategory, int)> showNewContent;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr int MaxHist = 16;
|
constexpr int MaxHist = 16;
|
||||||
constexpr int ScrollBarWidth = 16; // matches Dpi::ScrollBar's fixed width
|
|
||||||
|
|
||||||
// Help.txt phrases carry raw C printf-style specifiers (copied from the
|
|
||||||
// original's Format() call sites) - NOT Qt's %1/%2 .arg() syntax. Scans
|
|
||||||
// left to right, filling each %d/%s in order from args (supports formats
|
|
||||||
// with more than one placeholder, e.g. "#STRENGTH Strength: %d/%d").
|
|
||||||
QString formatArgs(const QString &fmt, const QStringList &args)
|
|
||||||
{
|
|
||||||
QString result;
|
|
||||||
result.reserve(fmt.size());
|
|
||||||
int argIndex = 0;
|
|
||||||
for (int i = 0; i < fmt.size(); ++i) {
|
|
||||||
if (fmt.at(i) == QLatin1Char('%') && i + 1 < fmt.size()) {
|
|
||||||
const QChar next = fmt.at(i + 1);
|
|
||||||
if ((next == QLatin1Char('d') || next == QLatin1Char('s')) && argIndex < args.size()) {
|
|
||||||
result += args.at(argIndex++);
|
|
||||||
++i;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (next == QLatin1Char('%')) {
|
|
||||||
result += QLatin1Char('%');
|
|
||||||
++i;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result += fmt.at(i);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString formatD(const QString &fmt, int value)
|
|
||||||
{
|
|
||||||
return formatArgs(fmt, { QString::number(value) });
|
|
||||||
}
|
|
||||||
|
|
||||||
QString formatS(const QString &fmt, const QString &value)
|
|
||||||
{
|
|
||||||
return formatArgs(fmt, { value });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Help.pas's `TerrainHelp` (the fixed display order for the "complete
|
|
||||||
// terrain type list" page).
|
|
||||||
constexpr int TerrainHelp[] = { fGrass, fGrass + 12, fPrairie, fForest, Term::fJungle, fHills,
|
|
||||||
fMountains, fSwamp, fTundra, fArctic, fDesert, 3 * 12,
|
|
||||||
fShore, fOcean };
|
|
||||||
|
|
||||||
// Help.pas's `JobHelp` (the fixed display order for the terrain-jobs list).
|
|
||||||
constexpr int JobHelp[] = { jRoad, jRR, jCanal, jIrr, jFarm, jMine, jFort, jBase };
|
|
||||||
|
|
||||||
// Help.pas's `SeeAlso` table: hand-authored extra cross-references shown
|
|
||||||
// in a page's "See Also" section beyond what's derivable algorithmically.
|
|
||||||
struct SeeAlsoEntry {
|
|
||||||
LinkCategory kind;
|
|
||||||
int no;
|
|
||||||
LinkCategory seeKind;
|
|
||||||
int seeNo;
|
|
||||||
};
|
|
||||||
constexpr SeeAlsoEntry SeeAlsoTable[] = {
|
|
||||||
{ LinkCategory::Imp, imWalls, LinkCategory::Feature, mcArtillery },
|
|
||||||
{ LinkCategory::Imp, imHydro, LinkCategory::Imp, woHoover },
|
|
||||||
{ LinkCategory::Imp, imHighways, LinkCategory::Adv, adWheel },
|
|
||||||
{ LinkCategory::Imp, imCathedral, LinkCategory::Imp, woBach },
|
|
||||||
{ LinkCategory::Imp, imBank, LinkCategory::Imp, imStockEx },
|
|
||||||
{ LinkCategory::Imp, imShipComp, LinkCategory::Imp, imSpacePort },
|
|
||||||
{ LinkCategory::Imp, imShipPow, LinkCategory::Imp, imSpacePort },
|
|
||||||
{ LinkCategory::Imp, imShipHab, LinkCategory::Imp, imSpacePort },
|
|
||||||
{ LinkCategory::Feature, mcSub, LinkCategory::Feature, mcRadar },
|
|
||||||
{ LinkCategory::Feature, mcDefense, LinkCategory::Adv, adSteel },
|
|
||||||
{ LinkCategory::Feature, mcSE, LinkCategory::Feature, mcNP },
|
|
||||||
{ LinkCategory::Adv, adWheel, LinkCategory::Imp, imHighways },
|
|
||||||
{ LinkCategory::Adv, adSteel, LinkCategory::Feature, mcDefense },
|
|
||||||
};
|
|
||||||
|
|
||||||
// Appends this page's hand-authored extra "See Also" cross-references (if
|
|
||||||
// any) onto `list`.
|
|
||||||
void appendSeeAlsoEntries(HyperText &list, LinkCategory kind, int no)
|
|
||||||
{
|
|
||||||
for (const SeeAlsoEntry &entry : SeeAlsoTable) {
|
|
||||||
if (entry.kind != kind || entry.no != no)
|
|
||||||
continue;
|
|
||||||
switch (entry.seeKind) {
|
|
||||||
case LinkCategory::Imp:
|
|
||||||
list.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), entry.seeNo), TextFormat::SmallIcon, 0,
|
|
||||||
LinkCategory::Imp, entry.seeNo, true);
|
|
||||||
break;
|
|
||||||
case LinkCategory::Adv:
|
|
||||||
list.addLine(phrases.lookup(QStringLiteral("ADVANCES"), entry.seeNo), TextFormat::AdvIcon, 0,
|
|
||||||
LinkCategory::Adv, entry.seeNo, true);
|
|
||||||
break;
|
|
||||||
case LinkCategory::Feature:
|
|
||||||
list.addLine(phrases.lookup(QStringLiteral("FEATURES"), entry.seeNo), TextFormat::Feature, 0,
|
|
||||||
LinkCategory::Feature, entry.seeNo, true);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void HyperText::addLine(const QString &s, TextFormat format, int picPix, LinkCategory linkCategory, int linkIndex,
|
void HyperText::addLine(const QString &s, TextFormat format, int picPix, LinkCategory linkCategory, int linkIndex,
|
||||||
@@ -216,6 +118,8 @@ HelpDlg::HelpDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::HelpDlg)
|
|||||||
smartUpdateContent(true);
|
smartUpdateContent(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
noMap = std::make_unique<IsoEngine::IsoMap>();
|
||||||
|
|
||||||
helpText.loadFromFile(localizedFilePath(QStringLiteral("Help/Help.txt")));
|
helpText.loadFromFile(localizedFilePath(QStringLiteral("Help/Help.txt")));
|
||||||
helpContext = QStringLiteral("CONCEPTS");
|
helpContext = QStringLiteral("CONCEPTS");
|
||||||
|
|
||||||
@@ -339,758 +243,6 @@ void HelpDlg::prepare(int sbPos)
|
|||||||
sel = -1;
|
sel = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpDlg::prepareAdvance(int advance)
|
|
||||||
{
|
|
||||||
// Section helper (NextSection in the original): only emits the section
|
|
||||||
// header + a blank line separator if the section actually has entries.
|
|
||||||
const auto addSection = [this](const QString &headerKey, const HyperText &entries) {
|
|
||||||
if (entries.count() == 0)
|
|
||||||
return;
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(headerKey), TextFormat::Section);
|
|
||||||
mainText.appendList(entries);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (IsFutureTech(advance)) {
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_FUTURE")));
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(advance == futResearchTechnology ? QStringLiteral("FUTURETECHHELP100")
|
|
||||||
: QStringLiteral("FUTURETECHHELP25")));
|
|
||||||
} else {
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_ADV")));
|
|
||||||
}
|
|
||||||
|
|
||||||
HyperText preqs;
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
if (AdvPreq[advance][i] != preNone)
|
|
||||||
preqs.addLine(phrases.lookup(QStringLiteral("ADVANCES"), AdvPreq[advance][i]), TextFormat::AdvIconAsPreq,
|
|
||||||
0, LinkCategory::Adv, AdvPreq[advance][i], true);
|
|
||||||
}
|
|
||||||
addSection(AdvPreq[advance][2] != preNone ? QStringLiteral("PREREQALT") : QStringLiteral("PREREQ"), preqs);
|
|
||||||
|
|
||||||
HyperText govs;
|
|
||||||
for (int i = 2; i < nGov; ++i) {
|
|
||||||
if (GovPreq[i] == advance)
|
|
||||||
govs.addLine(phrases.lookup(QStringLiteral("GOVERNMENT"), i), TextFormat::Gov, 0, LinkCategory::Misc,
|
|
||||||
static_cast<int>(MiscLinkIndex::GovList), true);
|
|
||||||
}
|
|
||||||
addSection(QStringLiteral("GOVALLOW"), govs);
|
|
||||||
|
|
||||||
HyperText imps;
|
|
||||||
for (int i = 0; i < nWonder; ++i) {
|
|
||||||
if (Imp[i].Preq == advance)
|
|
||||||
imps.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), i), TextFormat::SmallIcon, 0,
|
|
||||||
LinkCategory::Imp, i, true);
|
|
||||||
}
|
|
||||||
for (int i = nWonder; i < nImp; ++i) {
|
|
||||||
if (Imp[i].Preq == advance && Imp[i].Kind != ikCommon)
|
|
||||||
imps.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), i), TextFormat::SmallIcon, 0,
|
|
||||||
LinkCategory::Imp, i, true);
|
|
||||||
}
|
|
||||||
for (int i = nWonder; i < nImp; ++i) {
|
|
||||||
if (Imp[i].Preq == advance && Imp[i].Kind == ikCommon)
|
|
||||||
imps.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), i), TextFormat::SmallIcon, 0,
|
|
||||||
LinkCategory::Imp, i, true);
|
|
||||||
}
|
|
||||||
addSection(QStringLiteral("BUILDALLOW"), imps);
|
|
||||||
|
|
||||||
HyperText feats;
|
|
||||||
for (int i = 0; i < nFeature; ++i) {
|
|
||||||
if (Feature[i].Preq == advance)
|
|
||||||
feats.addLine(phrases.lookup(QStringLiteral("FEATURES"), i), TextFormat::Feature, 0,
|
|
||||||
LinkCategory::Feature, i, true);
|
|
||||||
}
|
|
||||||
addSection(QStringLiteral("FEATALLOW"), feats);
|
|
||||||
|
|
||||||
HyperText follow;
|
|
||||||
for (int i = 0; i < nAdv; ++i) {
|
|
||||||
if (AdvPreq[i][0] == advance || AdvPreq[i][1] == advance || AdvPreq[i][2] == advance)
|
|
||||||
follow.addLine(phrases.lookup(QStringLiteral("ADVANCES"), i), TextFormat::AdvIcon, 0, LinkCategory::Adv,
|
|
||||||
i, true);
|
|
||||||
}
|
|
||||||
addSection(QStringLiteral("FOLLOWADV"), follow);
|
|
||||||
|
|
||||||
HyperText seeAlso;
|
|
||||||
appendSeeAlsoEntries(seeAlso, LinkCategory::Adv, advance);
|
|
||||||
addSection(QStringLiteral("SEEALSO"), seeAlso);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::prepareImprovement(int imp)
|
|
||||||
{
|
|
||||||
const auto addSection = [this](const QString &headerKey, const HyperText &entries) {
|
|
||||||
if (entries.count() == 0)
|
|
||||||
return;
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(headerKey), TextFormat::Section);
|
|
||||||
mainText.appendList(entries);
|
|
||||||
};
|
|
||||||
|
|
||||||
switch (Imp[imp].Kind) {
|
|
||||||
case ikWonder: mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_WONDER"))); break;
|
|
||||||
case ikCommon: mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_IMP"))); break;
|
|
||||||
case ikShipPart: mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_SHIPPART"))); break;
|
|
||||||
default: mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_NAT"))); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Imp[imp].Kind != ikShipPart) {
|
|
||||||
const QString effect = helpText.lookup(QStringLiteral("IMPHELP"), imp);
|
|
||||||
if (!effect.isEmpty()) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("EFFECT")), TextFormat::Section);
|
|
||||||
mainText.addLine(effect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HyperText preqs;
|
|
||||||
if (Imp[imp].Preq != preNone)
|
|
||||||
preqs.addLine(phrases.lookup(QStringLiteral("ADVANCES"), Imp[imp].Preq), TextFormat::AdvIconAsPreq, 0,
|
|
||||||
LinkCategory::Adv, Imp[imp].Preq, true);
|
|
||||||
addSection(QStringLiteral("PREREQ"), preqs);
|
|
||||||
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("COSTS")), TextFormat::Section);
|
|
||||||
const int cost = difficulty == 0 ? Imp[imp].Cost : Imp[imp].Cost * BuildCostMod[difficulty] / 12;
|
|
||||||
mainText.addLine(formatD(helpText.lookup(QStringLiteral("BUILDCOST")), cost));
|
|
||||||
if (Imp[imp].Maint > 0)
|
|
||||||
mainText.addLine(formatD(helpText.lookup(QStringLiteral("MAINTCOST")), Imp[imp].Maint));
|
|
||||||
|
|
||||||
HyperText replaces;
|
|
||||||
for (int i = 0; i < nImpReplacement; ++i) {
|
|
||||||
if (ImpReplacement[i].NewImp == imp)
|
|
||||||
replaces.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), ImpReplacement[i].OldImp),
|
|
||||||
TextFormat::SmallIcon, 0, LinkCategory::Imp, ImpReplacement[i].OldImp, true);
|
|
||||||
}
|
|
||||||
addSection(QStringLiteral("REPLACE"), replaces);
|
|
||||||
|
|
||||||
if (imp < nWonder && Imp[imp].Expiration >= 0) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("EXPIRATION")), TextFormat::Section);
|
|
||||||
mainText.addLine(formatS(helpText.lookup(QStringLiteral("EXPWITH")),
|
|
||||||
phrases.lookup(QStringLiteral("ADVANCES"), Imp[imp].Expiration)));
|
|
||||||
}
|
|
||||||
|
|
||||||
HyperText seeAlso;
|
|
||||||
if (imp < nWonder && Imp[imp].Expiration >= 0)
|
|
||||||
seeAlso.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woEiffel), TextFormat::SmallIcon, 0,
|
|
||||||
LinkCategory::Imp, woEiffel, true);
|
|
||||||
for (int i = 0; i < nImpReplacement; ++i) {
|
|
||||||
if (ImpReplacement[i].OldImp == imp)
|
|
||||||
seeAlso.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), ImpReplacement[i].NewImp),
|
|
||||||
TextFormat::SmallIcon, 0, LinkCategory::Imp, ImpReplacement[i].NewImp, true);
|
|
||||||
}
|
|
||||||
if (imp == imSupermarket)
|
|
||||||
seeAlso.addLine(helpText.lookup(QStringLiteral("HELPTITLE_JOBLIST")), TextFormat::Normal, 0,
|
|
||||||
LinkCategory::Misc, static_cast<int>(MiscLinkIndex::JobList), true);
|
|
||||||
appendSeeAlsoEntries(seeAlso, LinkCategory::Imp, imp);
|
|
||||||
addSection(QStringLiteral("SEEALSO"), seeAlso);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::prepareTerrain(int no)
|
|
||||||
{
|
|
||||||
if (no == 200) { // complete terrain type list
|
|
||||||
for (int i : TerrainHelp) {
|
|
||||||
if (mainText.count() > 1)
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("TERRAIN"), i), TextFormat::Ter, 0, LinkCategory::Ter, i,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto addSection = [this](const QString &headerKey, const HyperText &entries) {
|
|
||||||
if (entries.count() == 0)
|
|
||||||
return;
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(headerKey), TextFormat::Section);
|
|
||||||
mainText.appendList(entries);
|
|
||||||
};
|
|
||||||
|
|
||||||
int terrType = no % 12;
|
|
||||||
if (terrType == Term::fJungle)
|
|
||||||
terrType = fForest;
|
|
||||||
int terrSubType = no / 12;
|
|
||||||
if (no == 3 * 12) {
|
|
||||||
terrType = fDesert;
|
|
||||||
terrSubType = 0;
|
|
||||||
}
|
|
||||||
const TerrainInfo &terrain = Terrain[terrType];
|
|
||||||
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_TER")));
|
|
||||||
mainText.lineFeed();
|
|
||||||
if (terrain.ProdRes[terrSubType] > 0 || terrain.MineEff > 0) {
|
|
||||||
QString line = formatD(helpText.lookup(QStringLiteral("RESPROD")), terrain.ProdRes[terrSubType]);
|
|
||||||
if (no < 3 * 12 && terrain.MineEff > 0)
|
|
||||||
line += QLatin1Char(' ') + formatD(helpText.lookup(QStringLiteral("MOREMINE")), terrain.MineEff);
|
|
||||||
mainText.addLine(line);
|
|
||||||
}
|
|
||||||
if (terrain.FoodRes[terrSubType] > 0 || terrain.IrrEff > 0) {
|
|
||||||
QString line = formatD(helpText.lookup(QStringLiteral("RESFOOD")), terrain.FoodRes[terrSubType]);
|
|
||||||
if (no < 3 * 12 && terrain.IrrEff > 0)
|
|
||||||
line += QLatin1Char(' ') + formatD(helpText.lookup(QStringLiteral("MOREIRR")), terrain.IrrEff);
|
|
||||||
mainText.addLine(line);
|
|
||||||
}
|
|
||||||
if (terrain.TradeRes[terrSubType] > 0)
|
|
||||||
mainText.addLine(formatD(helpText.lookup(QStringLiteral("RESTRADE")), terrain.TradeRes[terrSubType]));
|
|
||||||
if (terrain.Defense > 4)
|
|
||||||
mainText.addLine(formatD(helpText.lookup(QStringLiteral("DEFBONUS")), (terrain.Defense - 4) * 25));
|
|
||||||
if (terrType >= fGrass && terrType != fMountains)
|
|
||||||
mainText.addLine(
|
|
||||||
helpText.lookup(terrain.MoveCost == 2 ? QStringLiteral("MOVEHEAVY") : QStringLiteral("MOVEPLAIN")));
|
|
||||||
if (no == 3 * 12) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("DEADLANDS")));
|
|
||||||
}
|
|
||||||
if (terrType == fDesert && no != fDesert + 12) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(formatD(helpText.lookup(QStringLiteral("HOSTILE")), DesertThurst));
|
|
||||||
}
|
|
||||||
if (terrType == fArctic) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(formatD(helpText.lookup(QStringLiteral("HOSTILE")), ArcticThurst));
|
|
||||||
}
|
|
||||||
if (no < 3 * 12 && terrain.TransTerrain >= 0) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
int i = terrain.TransTerrain;
|
|
||||||
if (terrType != fGrass && i != fGrass)
|
|
||||||
i += terrSubType * 12;
|
|
||||||
mainText.addLine(formatS(helpText.lookup(QStringLiteral("TRAFO")), phrases.lookup(QStringLiteral("TERRAIN"), i)),
|
|
||||||
TextFormat::Ter, 0, LinkCategory::Ter, i, true);
|
|
||||||
if (no == fSwamp + 12) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(formatS(helpText.lookup(QStringLiteral("TRAFO")),
|
|
||||||
phrases.lookup(QStringLiteral("TERRAIN"), terrain.TransTerrain + 24)),
|
|
||||||
TextFormat::Ter, 0, LinkCategory::Ter, terrain.TransTerrain + 24, true);
|
|
||||||
} else if (i == fGrass) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(formatS(helpText.lookup(QStringLiteral("TRAFO")),
|
|
||||||
phrases.lookup(QStringLiteral("TERRAIN"), fGrass + 12)),
|
|
||||||
TextFormat::Ter, 0, LinkCategory::Ter, fGrass + 12, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HyperText special;
|
|
||||||
if (no == 3 * 12) {
|
|
||||||
for (int sp = 1; sp <= 3; ++sp) {
|
|
||||||
special.lineFeed();
|
|
||||||
special.addLine(phrases.lookup(QStringLiteral("TERRAIN"), 3 * 12 + sp), TextFormat::Ter, 0,
|
|
||||||
LinkCategory::Ter, 3 * 12 + sp, true);
|
|
||||||
}
|
|
||||||
} else if (no < 12 && no != fGrass && no != fOcean) {
|
|
||||||
for (int sp = 1; sp <= 2; ++sp) {
|
|
||||||
if ((no != fArctic && no != fSwamp) || sp < 2) {
|
|
||||||
special.lineFeed();
|
|
||||||
QString line = phrases.lookup(QStringLiteral("TERRAIN"), no + sp * 12);
|
|
||||||
const int df = terrain.FoodRes[sp] - terrain.FoodRes[0];
|
|
||||||
if (df != 0)
|
|
||||||
line += formatD(helpText.lookup(QStringLiteral("SPECIALFOOD")), df);
|
|
||||||
const int dp = terrain.ProdRes[sp] - terrain.ProdRes[0];
|
|
||||||
if (dp != 0)
|
|
||||||
line += formatD(helpText.lookup(QStringLiteral("SPECIALPROD")), dp);
|
|
||||||
const int dt = terrain.TradeRes[sp] - terrain.TradeRes[0];
|
|
||||||
if (dt != 0)
|
|
||||||
line += formatD(helpText.lookup(QStringLiteral("SPECIALTRADE")), dt);
|
|
||||||
special.addLine(line, TextFormat::Ter, 0, LinkCategory::Ter, no + sp * 12, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addSection(QStringLiteral("SPECIAL"), special);
|
|
||||||
|
|
||||||
if (no == 3 * 12) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("RARE")));
|
|
||||||
}
|
|
||||||
|
|
||||||
HyperText seeAlso;
|
|
||||||
if (no < 3 * 12 && (terrType == fDesert || terrType == fArctic))
|
|
||||||
seeAlso.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woGardens), TextFormat::SmallIcon, 0,
|
|
||||||
LinkCategory::Imp, woGardens, true);
|
|
||||||
addSection(QStringLiteral("SEEALSO"), seeAlso);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::prepareFeature(int no)
|
|
||||||
{
|
|
||||||
if (no == 200) { // complete feature list, grouped by capacity/special/advance
|
|
||||||
for (int group = 0; group < 3; ++group) {
|
|
||||||
if (mainText.count() > 1) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.lineFeed();
|
|
||||||
}
|
|
||||||
switch (group) {
|
|
||||||
case 0: mainText.addLine(helpText.lookup(QStringLiteral("HELPTITLE_FEATURE1LIST")), TextFormat::Section); break;
|
|
||||||
case 1: mainText.addLine(helpText.lookup(QStringLiteral("HELPTITLE_FEATURE2LIST")), TextFormat::Section); break;
|
|
||||||
case 2: mainText.addLine(helpText.lookup(QStringLiteral("HELPTITLE_FEATURE3LIST")), TextFormat::Section); break;
|
|
||||||
}
|
|
||||||
std::vector<QString> names;
|
|
||||||
std::vector<int> indices;
|
|
||||||
for (int i = 0; i < nFeature; ++i) {
|
|
||||||
if (Feature[i].Preq == preNA)
|
|
||||||
continue;
|
|
||||||
const int which = i < mcFirstNonCap ? 0 : (AutoFeature & (1u << i)) ? 2 : 1;
|
|
||||||
if (which == group) {
|
|
||||||
names.push_back(phrases.lookup(QStringLiteral("FEATURES"), i));
|
|
||||||
indices.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::vector<std::size_t> order(names.size());
|
|
||||||
for (std::size_t i = 0; i < order.size(); ++i)
|
|
||||||
order[i] = i;
|
|
||||||
std::sort(order.begin(), order.end(),
|
|
||||||
[&names](std::size_t a, std::size_t b) { return names[a] < names[b]; });
|
|
||||||
for (std::size_t i : order)
|
|
||||||
mainText.addLine(names[i], TextFormat::Feature, 0, LinkCategory::Feature, indices[i], true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto addSection = [this](const QString &headerKey, const HyperText &entries) {
|
|
||||||
if (entries.count() == 0)
|
|
||||||
return;
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(headerKey), TextFormat::Section);
|
|
||||||
mainText.appendList(entries);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (no < mcFirstNonCap)
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_CAP")));
|
|
||||||
else if (AutoFeature & (1u << no))
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_STANDARD")));
|
|
||||||
else
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("HELPSPEC_FEATURE")));
|
|
||||||
|
|
||||||
const QString effect = helpText.lookup(QStringLiteral("FEATUREHELP"), no);
|
|
||||||
if (!effect.isEmpty()) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("EFFECT")), TextFormat::Section);
|
|
||||||
mainText.addLine(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Feature[no].Weight != 0 || Feature[no].Cost != 0) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("COSTS")), TextFormat::Section);
|
|
||||||
QString cost = QString::number(Feature[no].Cost);
|
|
||||||
if (Feature[no].Cost >= 0)
|
|
||||||
cost = QLatin1Char('+') + cost;
|
|
||||||
mainText.addLine(formatS(helpText.lookup(QStringLiteral("COSTBASE")), cost));
|
|
||||||
if (Feature[no].Weight > 0) {
|
|
||||||
mainText.addLine(formatS(helpText.lookup(QStringLiteral("WEIGHT")),
|
|
||||||
QLatin1Char('+') + QString::number(Feature[no].Weight)));
|
|
||||||
if (no == mcDefense)
|
|
||||||
mainText.addLine(formatS(helpText.lookup(QStringLiteral("WEIGHT")), QStringLiteral("+2")),
|
|
||||||
TextFormat::Domain, dGround);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Feature[no].Preq != preNone) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
if (Feature[no].Preq == preSun)
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woSun), TextFormat::SmallIconAsPreq, 0,
|
|
||||||
LinkCategory::Imp, woSun, true);
|
|
||||||
else
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("ADVANCES"), Feature[no].Preq), TextFormat::AdvIconAsPreq,
|
|
||||||
0, LinkCategory::Adv, Feature[no].Preq, true);
|
|
||||||
mainText.text(mainText.count() - 1) =
|
|
||||||
formatS(helpText.lookup(QStringLiteral("REQUIRED")), mainText.text(mainText.count() - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
HyperText seeAlso;
|
|
||||||
appendSeeAlsoEntries(seeAlso, LinkCategory::Feature, no);
|
|
||||||
addSection(QStringLiteral("SEEALSO"), seeAlso);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::prepareModel(int)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < nSpecialModel; ++i) {
|
|
||||||
if (i == 2) // skip pixSlaves/pixNoSlaves-style gap, matches the original
|
|
||||||
continue;
|
|
||||||
if (mainText.count() > 1) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.lineFeed();
|
|
||||||
}
|
|
||||||
int pix = 0;
|
|
||||||
QString name;
|
|
||||||
Tribes::findStdModelPicture(Term::SpecialModelPictureCode[static_cast<std::size_t>(i)], pix, name);
|
|
||||||
mainText.addLine(name, TextFormat::Section);
|
|
||||||
mainText.addLine(formatArgs(helpText.lookup(QStringLiteral("STRENGTH")),
|
|
||||||
{ QString::number(SpecialModel[i].Attack), QString::number(SpecialModel[i].Defense) }));
|
|
||||||
mainText.addLine(formatS(helpText.lookup(QStringLiteral("SPEED")), movementToString(SpecialModel[i].Speed)),
|
|
||||||
TextFormat::Model, pix);
|
|
||||||
const int cost =
|
|
||||||
difficulty == 0 ? SpecialModel[i].Cost : SpecialModel[i].Cost * BuildCostMod[difficulty] / 12;
|
|
||||||
mainText.addLine(formatD(helpText.lookup(QStringLiteral("BUILDCOST")), cost));
|
|
||||||
const QString special = helpText.lookup(QStringLiteral("SPECIALMODEL"), i);
|
|
||||||
if (!special.isEmpty() && special != QLatin1String("*"))
|
|
||||||
mainText.addLine(special);
|
|
||||||
if (SpecialModelPreq[i] >= 0)
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("ADVANCES"), SpecialModelPreq[i]),
|
|
||||||
TextFormat::AdvIconAsPreq, 0, LinkCategory::Adv, SpecialModelPreq[i], true);
|
|
||||||
else if (SpecialModelPreq[i] == preLighthouse)
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woLighthouse),
|
|
||||||
TextFormat::SmallIconAsPreq, 0, LinkCategory::Imp, woLighthouse, true);
|
|
||||||
else if (SpecialModelPreq[i] == preBuilder)
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woPyramids), TextFormat::SmallIconAsPreq,
|
|
||||||
0, LinkCategory::Imp, woPyramids, true);
|
|
||||||
else if (SpecialModelPreq[i] == preLeo)
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("IMPROVEMENTS"), woLeo), TextFormat::SmallIconAsPreq, 0,
|
|
||||||
LinkCategory::Imp, woLeo, true);
|
|
||||||
if (SpecialModelPreq[i] != preNone)
|
|
||||||
mainText.text(mainText.count() - 1) =
|
|
||||||
formatS(helpText.lookup(QStringLiteral("REQUIRED")), mainText.text(mainText.count() - 1));
|
|
||||||
}
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("MODELNOTE")));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::decodeItem(const QString &item, LinkCategory &category, int &index) const
|
|
||||||
{
|
|
||||||
// item is e.g. ":A47" (coded category+number) or "QUICK" (a plain
|
|
||||||
// Help.txt key name) - the caller already stripped the outer ':'/';'
|
|
||||||
// that marks a link token; a SECOND leading ':' here means "coded".
|
|
||||||
if (!item.isEmpty() && item.at(0) == QLatin1Char(':')) {
|
|
||||||
category = LinkCategory::Misc;
|
|
||||||
index = 0;
|
|
||||||
for (int i = 2; i < item.size(); ++i)
|
|
||||||
index = index * 10 + item.at(i).unicode() - QLatin1Char('0').unicode();
|
|
||||||
if (item.size() >= 2) {
|
|
||||||
switch (item.at(1).toLatin1()) {
|
|
||||||
case 'A': category = LinkCategory::Adv; break;
|
|
||||||
case 'B': category = LinkCategory::Imp; break;
|
|
||||||
case 'T': category = LinkCategory::Ter; break;
|
|
||||||
case 'F': category = LinkCategory::Feature; break;
|
|
||||||
case 'E': category = LinkCategory::Internet; break;
|
|
||||||
case 'S': category = LinkCategory::Model; break;
|
|
||||||
case 'C': index = static_cast<int>(MiscLinkIndex::Credits); break;
|
|
||||||
case 'J': index = static_cast<int>(MiscLinkIndex::JobList); break;
|
|
||||||
case 'G': index = static_cast<int>(MiscLinkIndex::GovList); break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (category != LinkCategory::Misc && index == 0)
|
|
||||||
index = 200;
|
|
||||||
} else {
|
|
||||||
category = LinkCategory::Text;
|
|
||||||
index = helpText.getHandle(item.left(255));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::addTextual(const QString &text)
|
|
||||||
{
|
|
||||||
// Throwaway canvas just for measuring word-wrap widths (same pattern as
|
|
||||||
// BaseMessgDlg::splitText: never painted, just needed for text metrics).
|
|
||||||
QPixmap dummy(1, 1);
|
|
||||||
QPainter painter(&dummy);
|
|
||||||
Dpi::Canvas canvas;
|
|
||||||
canvas.bind(&painter);
|
|
||||||
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
|
||||||
|
|
||||||
const auto charAt = [](const QString &str, int k) -> QChar { // Pascal S[k], 1-based, safe past end
|
|
||||||
return (k >= 1 && k <= str.size()) ? str.at(k - 1) : QChar();
|
|
||||||
};
|
|
||||||
|
|
||||||
const int rightMargin = innerWidth - 16 - ScrollBarWidth;
|
|
||||||
QString s = text;
|
|
||||||
TextFormat followFormat = TextFormat::Normal;
|
|
||||||
|
|
||||||
while (!s.isEmpty()) {
|
|
||||||
LinkCategory linkCategory = LinkCategory::NoLink;
|
|
||||||
int linkIndex = 0;
|
|
||||||
TextFormat currentFormat;
|
|
||||||
bool crossLink = false;
|
|
||||||
|
|
||||||
if (s.at(0) == QLatin1Char('$')) { // window caption
|
|
||||||
int p = 1;
|
|
||||||
while (p < s.size() && s.at(p) != QLatin1Char('\\'))
|
|
||||||
++p;
|
|
||||||
s.remove(0, p + 1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (s.at(0) == QLatin1Char('&')) { // standard block - not ported, skip
|
|
||||||
int p = 1;
|
|
||||||
while (p < s.size() && s.at(p) != QLatin1Char('\\'))
|
|
||||||
++p;
|
|
||||||
s.remove(0, p + 1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QChar c0 = s.at(0);
|
|
||||||
if (c0 == QLatin1Char(':') || c0 == QLatin1Char(';')) {
|
|
||||||
int p = 1; // Pascal 1-based P
|
|
||||||
do {
|
|
||||||
++p;
|
|
||||||
} while (!(p > s.size() || charAt(s, p) == QLatin1Char('\\') || charAt(s, p) == QLatin1Char(' ')));
|
|
||||||
decodeItem(s.mid(1, p - 2), linkCategory, linkIndex);
|
|
||||||
currentFormat = TextFormat::Normal;
|
|
||||||
if (linkCategory != LinkCategory::Text && linkIndex < 200) {
|
|
||||||
switch (linkCategory) {
|
|
||||||
case LinkCategory::Adv: currentFormat = TextFormat::AdvIcon; break;
|
|
||||||
case LinkCategory::Imp: currentFormat = TextFormat::SmallIcon; break;
|
|
||||||
case LinkCategory::Ter: currentFormat = TextFormat::Ter; break;
|
|
||||||
case LinkCategory::Feature: currentFormat = TextFormat::Feature; break;
|
|
||||||
case LinkCategory::Model: currentFormat = TextFormat::Model; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
crossLink = (c0 == QLatin1Char(':'));
|
|
||||||
if (p > s.size() || charAt(s, p) == QLatin1Char(' '))
|
|
||||||
s.remove(0, p);
|
|
||||||
else
|
|
||||||
s.remove(0, p - 1);
|
|
||||||
} else if (c0 == QLatin1Char('!')) {
|
|
||||||
if (s.size() >= 2 && s.at(1) == QLatin1Char('!')) {
|
|
||||||
if (mainText.count() > 1)
|
|
||||||
mainText.lineFeed();
|
|
||||||
followFormat = TextFormat::Caption;
|
|
||||||
currentFormat = TextFormat::Caption;
|
|
||||||
s.remove(0, 2);
|
|
||||||
} else {
|
|
||||||
followFormat = TextFormat::Section;
|
|
||||||
currentFormat = TextFormat::Section;
|
|
||||||
s.remove(0, 1);
|
|
||||||
}
|
|
||||||
} else if (c0 == QLatin1Char('-')) {
|
|
||||||
followFormat = TextFormat::NormalDot;
|
|
||||||
currentFormat = TextFormat::Dot;
|
|
||||||
s.remove(0, 1);
|
|
||||||
} else {
|
|
||||||
currentFormat = followFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s.isEmpty())
|
|
||||||
break;
|
|
||||||
|
|
||||||
const int ofs = followFormat == TextFormat::NormalDot ? (20 + 4 + 8) : 8;
|
|
||||||
int p = 0;
|
|
||||||
int l = 0;
|
|
||||||
do {
|
|
||||||
do {
|
|
||||||
++p;
|
|
||||||
} while (p <= s.size() && charAt(s, p) != QLatin1Char(' ') && charAt(s, p) != QLatin1Char('\\'));
|
|
||||||
if (biColorTextWidth(canvas, s.left(p - 1)) <= rightMargin - ofs)
|
|
||||||
l = p - 1;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
} while (!(p >= s.size() || charAt(s, l + 1) == QLatin1Char('\\')));
|
|
||||||
|
|
||||||
const QString lineText = s.left(l);
|
|
||||||
if (linkCategory == LinkCategory::Internet) {
|
|
||||||
mainText.addLine(linkIndex == 1 ? QString::fromLatin1(AITemplateManual)
|
|
||||||
: linkIndex == 2 ? QString::fromLatin1(CevoHomepageShort)
|
|
||||||
: QString::fromLatin1(CevoContactShort),
|
|
||||||
currentFormat, 0, linkCategory, linkIndex, crossLink);
|
|
||||||
} else {
|
|
||||||
mainText.addLine(lineText, currentFormat, 0, linkCategory, linkIndex, crossLink);
|
|
||||||
}
|
|
||||||
if (l < s.size() && charAt(s, l + 1) == QLatin1Char('\\'))
|
|
||||||
followFormat = TextFormat::Normal;
|
|
||||||
s.remove(0, l + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::prepareMiscMain()
|
|
||||||
{
|
|
||||||
const auto addLink = [this](const QString &titleKey, LinkCategory category, int index) {
|
|
||||||
mainText.addLine(helpText.lookup(titleKey), TextFormat::Normal, 0, category, index, true);
|
|
||||||
mainText.lineFeed();
|
|
||||||
};
|
|
||||||
addLink(QStringLiteral("HELPTITLE_QUICKSTART"), LinkCategory::Text, textIndex(QStringLiteral("QUICK")));
|
|
||||||
addLink(QStringLiteral("HELPTITLE_CONCEPTS"), LinkCategory::Text, textIndex(QStringLiteral("CONCEPTS")));
|
|
||||||
addLink(QStringLiteral("HELPTITLE_TERLIST"), LinkCategory::Ter, 200);
|
|
||||||
addLink(QStringLiteral("HELPTITLE_JOBLIST"), LinkCategory::Misc, static_cast<int>(MiscLinkIndex::JobList));
|
|
||||||
addLink(QStringLiteral("HELPTITLE_TECHLIST"), LinkCategory::Adv, 200);
|
|
||||||
addLink(QStringLiteral("HELPTITLE_MODELLIST"), LinkCategory::Model, 0);
|
|
||||||
addLink(QStringLiteral("HELPTITLE_FEATURELIST"), LinkCategory::Feature, 200);
|
|
||||||
addLink(QStringLiteral("HELPTITLE_IMPLIST"), LinkCategory::Imp, 200);
|
|
||||||
addLink(QStringLiteral("HELPTITLE_UNIQUELIST"), LinkCategory::Imp, 201);
|
|
||||||
addLink(QStringLiteral("HELPTITLE_WONDERLIST"), LinkCategory::Imp, 202);
|
|
||||||
addLink(QStringLiteral("HELPTITLE_GOVLIST"), LinkCategory::Misc, static_cast<int>(MiscLinkIndex::GovList));
|
|
||||||
addLink(QStringLiteral("HELPTITLE_KEYS"), LinkCategory::Text, textIndex(QStringLiteral("HOTKEYS")));
|
|
||||||
addLink(QStringLiteral("HELPTITLE_ABOUT"), LinkCategory::Text, textIndex(QStringLiteral("ABOUT")));
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("HELPTITLE_CREDITS")), TextFormat::Normal, 0, LinkCategory::Misc,
|
|
||||||
static_cast<int>(MiscLinkIndex::Credits), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::prepareMiscCredits()
|
|
||||||
{
|
|
||||||
addTextual(helpText.lookup(QStringLiteral("CREDITS")));
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("CRED_CAPAI")), TextFormat::Section);
|
|
||||||
const char *aiCredits = nullptr;
|
|
||||||
ClientTools::server(sGetAICredits, 0, 0, &aiCredits);
|
|
||||||
if (aiCredits) {
|
|
||||||
const QStringList lines = QString::fromUtf8(aiCredits).split(QLatin1Char('\n'));
|
|
||||||
for (const QString &creditLine : lines)
|
|
||||||
mainText.addLine(creditLine);
|
|
||||||
}
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.addLine(helpText.lookup(QStringLiteral("CRED_CAPLANG")), TextFormat::Section);
|
|
||||||
addTextual(helpText.lookup(QStringLiteral("AUTHOR")));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::prepareMiscGovList()
|
|
||||||
{
|
|
||||||
for (int i = 1; i <= nGov; ++i) {
|
|
||||||
const int gov = i % nGov;
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("GOVERNMENT"), gov), TextFormat::Section);
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.lineFeed();
|
|
||||||
addTextual(helpText.lookup(QStringLiteral("GOVHELP"), gov));
|
|
||||||
if (gov >= 2) {
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("ADVANCES"), GovPreq[gov]), TextFormat::AdvIconAsPreq, 0,
|
|
||||||
LinkCategory::Adv, GovPreq[gov], true);
|
|
||||||
mainText.text(mainText.count() - 1) =
|
|
||||||
formatS(helpText.lookup(QStringLiteral("REQUIRED")), mainText.text(mainText.count() - 1));
|
|
||||||
}
|
|
||||||
if (i < nGov) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.lineFeed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::prepareMiscJobList()
|
|
||||||
{
|
|
||||||
constexpr int nJobHelp = sizeof(JobHelp) / sizeof(JobHelp[0]);
|
|
||||||
for (int i = 0; i < nJobHelp; ++i) {
|
|
||||||
if (i > 0) {
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.lineFeed();
|
|
||||||
}
|
|
||||||
const int job = JobHelp[i];
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("JOBRESULT"), job), TextFormat::Section);
|
|
||||||
mainText.lineFeed();
|
|
||||||
mainText.lineFeed();
|
|
||||||
addTextual(helpText.lookup(QStringLiteral("JOBHELP"), i));
|
|
||||||
int jobCost = -1;
|
|
||||||
switch (job) {
|
|
||||||
case jCanal: jobCost = CanalWork; break;
|
|
||||||
case jFort: jobCost = FortWork; break;
|
|
||||||
case jBase: jobCost = BaseWork; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
mainText.addLine(jobCost >= 0 ? formatS(helpText.lookup(QStringLiteral("JOBCOST")), movementToString(jobCost))
|
|
||||||
: helpText.lookup(QStringLiteral("JOBCOSTVAR")));
|
|
||||||
if (JobPreq[job] != preNone) {
|
|
||||||
mainText.addLine(phrases.lookup(QStringLiteral("ADVANCES"), JobPreq[job]), TextFormat::AdvIconAsPreq, 0,
|
|
||||||
LinkCategory::Adv, JobPreq[job], true);
|
|
||||||
mainText.text(mainText.count() - 1) =
|
|
||||||
formatS(helpText.lookup(QStringLiteral("REQUIRED")), mainText.text(mainText.count() - 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::line(Dpi::Canvas &canvas, int i, bool lit)
|
|
||||||
{
|
|
||||||
const int idx = scrollBar->position() + i;
|
|
||||||
if (idx < 0 || idx >= mainText.count())
|
|
||||||
return;
|
|
||||||
const QString &s = mainText.text(idx);
|
|
||||||
if (s.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
int x = x0[static_cast<std::size_t>(i + 2)];
|
|
||||||
int y = 2 + i * 24;
|
|
||||||
if (&canvas != &offscreen.canvas()) {
|
|
||||||
x += SideFrame;
|
|
||||||
y += WideFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
const HelpLineInfo &lineInfo = mainText.info(idx);
|
|
||||||
const bool isCaption = lineInfo.format == TextFormat::Caption;
|
|
||||||
if (isCaption)
|
|
||||||
canvas.font().setBold(true);
|
|
||||||
const QColor textColor = isCaption ? captionColor : colorFromDelphi(0x000000);
|
|
||||||
biColorTextOut(canvas, textColor, colorFromDelphi(0x7F007F), x, y, s);
|
|
||||||
if (lit) {
|
|
||||||
canvas.pen().setColor(textColor);
|
|
||||||
canvas.moveTo(x + 1, y + 18);
|
|
||||||
canvas.lineTo(x + biColorTextWidth(canvas, s), y + 18);
|
|
||||||
}
|
|
||||||
if (isCaption)
|
|
||||||
canvas.font().setBold(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::paintTerrIcon(int x, int y, int xSrc, int ySrc)
|
|
||||||
{
|
|
||||||
// Cosmetic terrain-icon compositing (uses a TIsoMap instance in the
|
|
||||||
// original) - not ported, no caller in this simplified offscreenPaint.
|
|
||||||
Q_UNUSED(x);
|
|
||||||
Q_UNUSED(y);
|
|
||||||
Q_UNUSED(xSrc);
|
|
||||||
Q_UNUSED(ySrc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::waterSign(int x0, int y0, int iix)
|
|
||||||
{
|
|
||||||
Term::impImage(offscreen.canvas(), x0, y0, iix);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::offscreenPaint()
|
|
||||||
{
|
|
||||||
FramedDlg::offscreenPaint();
|
|
||||||
captionColor = colorFromDelphi(0xC08040);
|
|
||||||
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;
|
|
||||||
if (idx < 0 || idx >= mainText.count())
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpDlg::resizeEvent(QResizeEvent *event)
|
void HelpDlg::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
FramedDlg::resizeEvent(event);
|
FramedDlg::resizeEvent(event);
|
||||||
@@ -1207,16 +359,5 @@ void HelpDlg::searchBtnClicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpDlg::search(const QString &searchString)
|
|
||||||
{
|
|
||||||
searchResult.clear();
|
|
||||||
// The result list isn't built yet (needs the Help.txt layout engine):
|
|
||||||
// the matches are found but not recorded.
|
|
||||||
int handle = -1;
|
|
||||||
int index = -1;
|
|
||||||
while (helpText.search(searchString, handle, index)) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Help
|
} // namespace Help
|
||||||
} // namespace Cevo
|
} // namespace Cevo
|
||||||
+26
-4
@@ -31,6 +31,7 @@
|
|||||||
#include "Cevo/CevoBaseWin.h"
|
#include "Cevo/CevoBaseWin.h"
|
||||||
#include "Cevo/CevoPVScrollBar.h"
|
#include "Cevo/CevoPVScrollBar.h"
|
||||||
#include "Cevo/CevoStringTables.h"
|
#include "Cevo/CevoStringTables.h"
|
||||||
|
#include "IsoEngine.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -111,10 +112,10 @@ struct HistItem {
|
|||||||
|
|
||||||
// THelpDlg equivalent: the in-game encyclopedia/hypertext browser. UI built
|
// THelpDlg equivalent: the in-game encyclopedia/hypertext browser. UI built
|
||||||
// from Help.ui (adapted from the original's Help.lfm). The real content
|
// from Help.ui (adapted from the original's Help.lfm). The real content
|
||||||
// (Help/Help.txt via StringTables.pas) isn't available, so prepare()/
|
// (Help/Help.txt) is loaded and rendered with real per-TextFormat icons
|
||||||
// offscreenPaint() render a simplified, disclosed-placeholder version of
|
// (see Help.Paint.cpp); a handful of cosmetic pixel-level effects (the
|
||||||
// each page rather than the original's full icon-rich layout - the
|
// WaterSign watermark blend, isometric terrain-tile edge blending) are
|
||||||
// history/search/scrolling/link-click machinery itself is faithful.
|
// simplified - see the PORT STATUS comment at the top of Help.cpp.
|
||||||
class HelpDlg : public FramedDlg {
|
class HelpDlg : public FramedDlg {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -165,6 +166,14 @@ private:
|
|||||||
void addTextual(const QString &text);
|
void addTextual(const QString &text);
|
||||||
void search(const QString &searchString);
|
void search(const QString &searchString);
|
||||||
void line(Dpi::Canvas &canvas, int i, bool lit);
|
void line(Dpi::Canvas &canvas, int i, bool lit);
|
||||||
|
// Draws the leading link-indicator dot and, per `mainText.info(idx)`'s
|
||||||
|
// TextFormat, the line's icon (if any) - advancing x0[i+2] so line()
|
||||||
|
// then draws the text starting right after it.
|
||||||
|
void paintIcon(Dpi::Canvas &canvas, int i);
|
||||||
|
// The pkTer/pkBigTer inline terrain-tile icon (edge-blended sprite
|
||||||
|
// pair) - a free-standing helper since it's also reused for the
|
||||||
|
// "complete terrain list" page's many icons.
|
||||||
|
void paintTerIcon(Dpi::Canvas &canvas, int &x0Ref, int y, int picpix);
|
||||||
void paintTerrIcon(int x, int y, int xSrc, int ySrc);
|
void paintTerrIcon(int x, int y, int xSrc, int ySrc);
|
||||||
// Help.pas's WaterSign(): draws a big improvement/wonder illustration.
|
// Help.pas's WaterSign(): draws a big improvement/wonder illustration.
|
||||||
// Simplified from the original's per-pixel sky-detecting watermark blend
|
// Simplified from the original's per-pixel sky-detecting watermark blend
|
||||||
@@ -187,6 +196,10 @@ private:
|
|||||||
// Help.pas's ExtPic: the single external illustration bitmap (Help/*.png)
|
// Help.pas's ExtPic: the single external illustration bitmap (Help/*.png)
|
||||||
// referenced by the currently displayed page's "@filename\" markup.
|
// referenced by the currently displayed page's "@filename\" markup.
|
||||||
std::unique_ptr<Dpi::Bitmap> extPic;
|
std::unique_ptr<Dpi::Bitmap> extPic;
|
||||||
|
// Help.pas's NoMap: a TIsoMap instance used only for its terrain-tile
|
||||||
|
// geometry (xxt/yyt) and sprite sheet (hGrTerrain) - never shown as a
|
||||||
|
// real game map.
|
||||||
|
std::unique_ptr<IsoEngine::IsoMap> noMap;
|
||||||
std::vector<HistItem> histItems;
|
std::vector<HistItem> histItems;
|
||||||
PVScrollBar *scrollBar;
|
PVScrollBar *scrollBar;
|
||||||
std::array<int, 183> x0{}; // x0[-2..180], offset by +2
|
std::array<int, 183> x0{}; // x0[-2..180], offset by +2
|
||||||
@@ -194,5 +207,14 @@ private:
|
|||||||
Ui::HelpDlg *ui;
|
Ui::HelpDlg *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Help.txt phrases carry raw C printf-style specifiers (copied from the
|
||||||
|
// original's Format() call sites) - NOT Qt's %1/%2 .arg() syntax. Scans left
|
||||||
|
// to right, filling each %d/%s in order from args (supports formats with
|
||||||
|
// more than one placeholder, e.g. "#STRENGTH Strength: %d/%d"). Shared by
|
||||||
|
// Help.cpp and Help.Prepare.cpp.
|
||||||
|
QString formatArgs(const QString &fmt, const QStringList &args);
|
||||||
|
QString formatD(const QString &fmt, int value);
|
||||||
|
QString formatS(const QString &fmt, const QString &value);
|
||||||
|
|
||||||
} // namespace Help
|
} // namespace Help
|
||||||
} // namespace Cevo
|
} // namespace Cevo
|
||||||
Reference in new issue
Block a user